Skip to content

Commit 7ac2fcc

Browse files
committed
[ docs] contributing file
[ docs ] readme update wizard to ts types fixing
1 parent ac1f029 commit 7ac2fcc

File tree

8 files changed

+166
-97
lines changed

8 files changed

+166
-97
lines changed

CONTRIBUTING.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2+
## Issues & Pull Requests (not for Profiles)
3+
4+
### Creating an Issue
5+
6+
Before **creating** an Issue please follow these steps:
7+
8+
1. search existing Issues before creating a new issue (has someone raised this already)
9+
2. if it doesn't exist create a new issue giving as much context as possible
10+
3. if you wish to work on the Issue please check the relative checkbox
11+
12+
### Working on an Issue (get it assigned to you)
13+
14+
Before working on an existing Issue please follow these steps:
15+
16+
1. comment asking for the issue to be assigned to you
17+
2. after the Issue is assigned to you, you can start working on it
18+
3. **only** start working on this Issue (and open a Pull Request) when it has been assigned to you.
19+
4. when forking the issue, create a branch for your edits
20+
5. reference the Issue in your Pull Request (for example `closes #123`)
21+
6. please do **not** force push to your PR branch, this makes it very difficult to re-review - commits will be squashed when merged

README.md

Lines changed: 5 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -3,77 +3,26 @@ This package is born from the idea to expand the previous [make-vue-component](h
33

44
- [Make Js Component](#make-js-component)
55
- [Basic Usage](#basic-usage)
6-
- [Frameworks](#frameworks)
6+
- [Available Frameworks](#available-frameworks)
77
- [Vue](#vue)
8-
- [Arguments \& Options](#arguments--options)
9-
- [Component-name `REQUIRED`](#component-name-required)
10-
- [-c](#-c)
11-
- [-f --folder](#-f---folder)
128
- [Angular](#angular)
13-
- [Arguments \& Options](#arguments--options-1)
14-
- [Component-name `REQUIRED`](#component-name-required-1)
15-
- [-c](#-c-1)
169
- [Contributing](#contributing)
17-
- [Open issue](#open-issue)
18-
- [Pull Request](#pull-request)
1910

2011

2112
## Basic Usage
2213

2314
```bash
24-
npx make-js-component [framework name] <component-name>
15+
npx make-js-component
2516
```
2617

27-
For example:
18+
This will run a short wizard so you can easily create your component in few steps
2819

29-
```bash
30-
npx make-js-component vue my-great-component
31-
```
32-
33-
## Frameworks
34-
Many frameworks are going to be implemented; for each you'll have some options to generate the component how it suits you best
20+
## Available Frameworks
3521

3622
## Vue
37-
Creates a vue component
38-
39-
### Arguments & Options
40-
41-
42-
#### Component-name `REQUIRED`
43-
The name of the component you want to create
44-
45-
46-
#### -c
47-
If creating a Vue Comonent, it will use the composition API, defaults on Option API
48-
49-
#### -f --folder
50-
Select a custom nested folder inside src/components
51-
5223

5324
## Angular
54-
Creates a angular component
55-
56-
### Arguments & Options
57-
58-
59-
#### Component-name `REQUIRED`
60-
The name of the component you want to create
61-
62-
63-
#### -c
64-
If creating a Vue Comonent, it will use the composition API, defaults on Option API
65-
6625

6726

6827
## Contributing
69-
Every contribution is more than welcome
70-
71-
### Open issue
72-
If you find any issue please open it and explain clearly what's the problem giving also some context indication; ideas for enhancements are also welcome.
73-
74-
### Pull Request
75-
You can ask to have an issue assigned and work on it. I will merge the pull requests related to an issue, so first have it assigned and then work on the code
76-
77-
When forking, work on a separate branch not on main
78-
79-
28+
Read the [Contributing guide](./CONTRIBUTING.md) for the contribution process

cmd/make-js-component.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@ import createComponent from "../src/utils/utils.mjs";
55
wizard().then((answers) => {
66
const { componentName, framework, template, folder } = answers;
77
createComponent(componentName, framework, template, folder);
8+
}).catch((e) => {
9+
console.error(e.message);
810
});

cmd/make-js-component.mts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,6 @@ wizard().then((answers: Answers)=>{
1616
const {componentName, framework, template, folder} = answers;
1717

1818
createComponent(componentName, framework, template, folder)
19+
}).catch((e:Error)=>{
20+
console.error(e.message)
1921
})

package-lock.json

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "make-js-component",
3-
"version": "0.1.0",
3+
"version": "0.1.1",
44
"description": "Easily create your js framework component in one command",
55
"repository": "https://github.com/Giuliano1993/make-js-component",
66
"bin": "./cmd/make-js-component.mjs",
@@ -21,6 +21,7 @@
2121
"author": "Giuliano Gostinfini (Ghostylab)",
2222
"license": "ISC",
2323
"devDependencies": {
24+
"@types/inquirer": "^9.0.7",
2425
"@types/node": "^20.9.0",
2526
"typescript": "^5.2.2"
2627
},

utils/wizard.mjs

Lines changed: 34 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import inquirer from 'inquirer';
2-
3-
const wizard = async()=>{
4-
2+
const wizard = async () => {
53
return inquirer.prompt([
64
{
75
type: "input",
@@ -12,57 +10,53 @@ const wizard = async()=>{
1210
type: "list",
1311
name: "framework",
1412
message: "pick a framework to create the component for",
15-
choices: ["vue","angular"]
13+
choices: ["vue", "angular"]
1614
}
17-
]).then((answers)=>{
15+
]).then((answers) => {
1816
const componentName = answers.name;
1917
const framework = answers.framework;
20-
if(framework === 'vue'){
18+
if (framework === 'vue') {
2119
return inquirer.prompt([{
22-
type: "list",
23-
name: "api",
24-
message: "choose wich api to use",
25-
choices: ["Composition API", "Options API"]
26-
},{
27-
type: 'input',
28-
name: 'folder',
29-
message: "custom path under the component folder for saving your component",
30-
default: ""
31-
}]).then((answers)=>{
20+
type: "list",
21+
name: "api",
22+
message: "choose wich api to use",
23+
choices: ["Composition API", "Options API"]
24+
}, {
25+
type: 'input',
26+
name: 'folder',
27+
message: "custom path under the component folder for saving your component",
28+
default: ""
29+
}]).then((answers) => {
3230
return {
3331
componentName: componentName,
3432
framework: framework,
3533
template: answers.api === "Composition API" ? "component-composition.vue" : "component-options.vue",
3634
folder: answers.folder
37-
}
38-
})
39-
}else if(framework === 'angular'){
35+
};
36+
});
37+
}
38+
else if (framework === 'angular') {
4039
return inquirer.prompt([{
41-
type: 'input',
42-
name: 'folder',
43-
message: "custom path under the component folder for saving your component",
44-
default: ""
45-
}]).then((answers)=>{
40+
type: 'input',
41+
name: 'folder',
42+
message: "custom path under the component folder for saving your component",
43+
default: ""
44+
}]).then((answers) => {
4645
return {
4746
componentName: componentName,
4847
framework: framework,
4948
template: "component.component.js",
5049
folder: answers.folder
51-
}
52-
})
50+
};
51+
});
5352
}
54-
else{
55-
return new Promise((resolve,reject)=>{
56-
resolve({
57-
componentName: componentName,
58-
framework:framework
59-
})
60-
})
53+
else {
54+
throw new Error("a framework must be selected");
6155
}
62-
63-
64-
}).then((values)=>{
65-
return values
66-
})
67-
}
68-
export default wizard;
56+
}).then((values) => {
57+
return values;
58+
}).catch((e) => {
59+
throw new Error(e.message);
60+
});
61+
};
62+
export default wizard;

utils/wizard.mts

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
import inquirer from 'inquirer';
2+
3+
4+
type Answers = {
5+
componentName: string,
6+
framework: string,
7+
template: string,
8+
folder: string
9+
}
10+
const wizard = async()=>{
11+
12+
return inquirer.prompt([
13+
{
14+
type: "input",
15+
name: "name",
16+
message: "give a name to your component"
17+
},
18+
{
19+
type: "list",
20+
name: "framework",
21+
message: "pick a framework to create the component for",
22+
choices: ["vue","angular"]
23+
}
24+
]).then((answers: {
25+
name: string,
26+
framework: string
27+
})=>{
28+
const componentName = answers.name;
29+
const framework = answers.framework;
30+
if(framework === 'vue'){
31+
return inquirer.prompt([{
32+
type: "list",
33+
name: "api",
34+
message: "choose wich api to use",
35+
choices: ["Composition API", "Options API"]
36+
},{
37+
type: 'input',
38+
name: 'folder',
39+
message: "custom path under the component folder for saving your component",
40+
default: ""
41+
}]).then((answers: {
42+
api: string,
43+
folder: string
44+
})=>{
45+
return {
46+
componentName: componentName,
47+
framework: framework,
48+
template: answers.api === "Composition API" ? "component-composition.vue" : "component-options.vue",
49+
folder: answers.folder
50+
}
51+
})
52+
}else if(framework === 'angular'){
53+
return inquirer.prompt([{
54+
type: 'input',
55+
name: 'folder',
56+
message: "custom path under the component folder for saving your component",
57+
default: ""
58+
}]).then((answers: {
59+
folder:string
60+
})=>{
61+
return {
62+
componentName: componentName,
63+
framework: framework,
64+
template: "component.component.js",
65+
folder: answers.folder
66+
}
67+
})
68+
}else{
69+
throw new Error("a framework must be selected");
70+
}
71+
72+
73+
}).then<Answers>((values : Answers|PromiseLike<Answers>)=>{
74+
return values
75+
}).catch((e:Error)=>{
76+
throw new Error(e.message);
77+
})
78+
79+
}
80+
export default wizard;

0 commit comments

Comments
 (0)