Skip to content

Commit 2f80aa8

Browse files
committed
feat(generator): reduce questions to 4 by asking org instead of homepage, bugs & repository urls
1 parent d92666e commit 2f80aa8

File tree

2 files changed

+18
-23
lines changed

2 files changed

+18
-23
lines changed

generators/app/index.js

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,18 @@ module.exports = class extends Generator {
1010
this.log(yosay(`Welcome to the ${chalk.red(pkg.name)} generator!`));
1111

1212
const appName = changeCase.paramCase(this.appname);
13-
const gitName = this.user.git.name() || 'organization';
14-
const gitEmail = this.user.git.email() || 'hi@domain.com';
15-
const githubUsername = await (async () => {
13+
const organizationName = await (async () => {
1614
try {
1715
const username = await this.user.github.username();
1816

1917
return username;
2018
} catch (err) {
21-
return gitName;
19+
return 'organization-name';
2220
}
2321
})();
22+
const gitName = this.user.git.name() || organizationName;
23+
const gitEmail =
24+
this.user.git.email() || `my-email@${organizationName}.com`;
2425
const prompts = [
2526
{
2627
type: 'input',
@@ -36,32 +37,26 @@ module.exports = class extends Generator {
3637
},
3738
{
3839
type: 'input',
39-
name: 'elementHomepage',
40-
message: 'Homepage?',
41-
default: `https://github.com/${githubUsername}/${appName}`,
42-
},
43-
{
44-
type: 'input',
45-
name: 'elementBugs',
46-
message: 'Bugs tracker?',
47-
default: `https://github.com/${githubUsername}/${appName}/issues`,
40+
name: 'elementOrganizationName',
41+
message: 'GitHub organization name?',
42+
default: organizationName,
4843
},
4944
{
5045
type: 'input',
5146
name: 'elementAuthor',
5247
message: 'Author?',
5348
default: `${gitName} \<${gitEmail}\>`,
5449
},
55-
{
56-
type: 'input',
57-
name: 'elementRepository',
58-
message: 'Repository?',
59-
default: `https://github.com/${githubUsername}/${appName}.git`,
60-
},
6150
];
6251

6352
return this.prompt(prompts).then((props) => {
64-
this.props = props;
53+
this.props = {
54+
...props,
55+
elementName: changeCase.paramCase(props.elementName),
56+
elementOrganizationName: changeCase.paramCase(
57+
props.elementOrganizationName,
58+
),
59+
};
6560
});
6661
}
6762

generators/app/templates/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
"name": "<%= elementName %>",
33
"version": "0.0.0",
44
"description": "<%= elementDescription %>",
5-
"homepage": "<%= elementHomepage %>",
6-
"bugs": "<%= elementBugs %>",
5+
"homepage": "https://github.com/<%= elementOrganizationName %>/<%= elementName %>",
6+
"bugs": "https://github.com/<%= elementOrganizationName %>/<%= elementName %>/issues",
77
"license": "MIT",
88
"author": "<%- elementAuthor %>",
9-
"repository": "<%= elementRepository %>",
9+
"repository": "https://github.com/<%= elementOrganizationName %>/<%= elementName %>.git",
1010
"main": "index.js",
1111
"typings": "index.d.ts",
1212
"scripts": {

0 commit comments

Comments
 (0)