Skip to content

Commit

Permalink
Minor updates for generators (apache#87)
Browse files Browse the repository at this point in the history
* update version in package template

* change only first letter to uppercase

* update template

* add language choice
  • Loading branch information
kristw committed Feb 1, 2019
1 parent 4333c0a commit cebf104
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module.exports = class extends Generator {
type: 'input',
name: 'packageLabel',
message: 'Package label:',
default: _.capitalize(_.camelCase(this.appname.replace('legacy plugin chart', '').trim())), // Default to current folder name
default: _.upperFirst(_.camelCase(this.appname.replace('legacy plugin chart', '').trim())), // Default to current folder name
},
]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ export default [
chartType="<%= packageName %>"
chartProps={{
formData: {},
height: 600,
height: 400,
payload: {
data: [],
},
width: 600,
width: 400,
}}
/>
),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
/* eslint-disable sort-keys */

const Generator = require('yeoman-generator');
const chalk = require('chalk');
const yosay = require('yosay');
const _ = require('lodash');

module.exports = class extends Generator {
async prompting() {
// Have Yeoman greet the user.
this.log(yosay(`Welcome to the rad ${chalk.red('generator-superset')} generator!`));

this.option('skipInstall');

this.answers = await this.prompt([
Expand All @@ -23,7 +18,7 @@ module.exports = class extends Generator {
type: 'input',
name: 'description',
message: 'Description:',
default: _.capitalize(
default: _.upperFirst(
_.startCase(this.appname.replace('superset ui legacy plugin chart', '').trim()),
), // Default to current folder name
},
Expand All @@ -38,7 +33,7 @@ module.exports = class extends Generator {
);
this.fs.copyTpl(this.templatePath('README.md'), this.destinationPath('README.md'), {
...this.answers,
packageLabel: _.capitalize(_.camelCase(this.answers.packageName)),
packageLabel: _.upperFirst(_.camelCase(this.answers.packageName)),
});
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,14 @@
"access": "public"
},
"dependencies": {
"@superset-ui/core": "^0.9.0",
"prop-types": "^15.6.2"
},
"devDependencies": {
"@superset-ui/chart": "^0.9.0",
"@superset-ui/translation": "^0.9.1"
"@superset-ui/chart": "latest",
"@superset-ui/translation": "latest"
},
"peerDependencies": {
"@superset-ui/chart": "^0.9.0",
"@superset-ui/translation": "^0.9.1"
"@superset-ui/chart": "latest",
"@superset-ui/translation": "latest"
}
}
30 changes: 23 additions & 7 deletions packages/generator-superset/generators/package/index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
/* eslint-disable sort-keys */

const Generator = require('yeoman-generator');
const chalk = require('chalk');
const yosay = require('yosay');
const _ = require('lodash');

module.exports = class extends Generator {
async prompting() {
// Have Yeoman greet the user.
this.log(yosay(`Welcome to the rad ${chalk.red('generator-superset')} generator!`));

this.option('skipInstall');

this.answers = await this.prompt([
Expand All @@ -19,6 +14,23 @@ module.exports = class extends Generator {
message: 'Package name:',
default: _.kebabCase(this.appname.replace('superset ui', '').trim()), // Default to current folder name
},
{
type: 'list',
name: 'language',
message: 'Choose language',
choices: [
{
name: 'typescript',
value: 'typescript',
short: 't',
},
{
name: 'javascript',
value: 'javascript',
short: 'j',
},
],
},
]);
}

Expand All @@ -33,7 +45,11 @@ module.exports = class extends Generator {
this.destinationPath('README.md'),
this.answers,
);
this.fs.copy(this.templatePath('src/index.js'), this.destinationPath('src/index.js'));
this.fs.copy(this.templatePath('test/index.js'), this.destinationPath('test/index.test.js'));
const ext = this.answers.language === 'typescript' ? 'ts' : 'js';
this.fs.copy(this.templatePath('src/index.js'), this.destinationPath(`src/index.${ext}`));
this.fs.copy(
this.templatePath('test/index.js'),
this.destinationPath(`test/index.test.${ext}`),
);
}
};

0 comments on commit cebf104

Please sign in to comment.