Minor updates for generators (#87)

* update version in package template

* change only first letter to uppercase

* update template

* add language choice
This commit is contained in:
Krist Wongsuphasawat 2019-02-01 11:42:22 -08:00 committed by Yongjie Zhao
parent fcbd7222cd
commit df7a49cfac
5 changed files with 32 additions and 22 deletions

View File

@ -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
},
]);
}

View File

@ -9,11 +9,11 @@ export default [
chartType="<%= packageName %>"
chartProps={{
formData: {},
height: 600,
height: 400,
payload: {
data: [],
},
width: 600,
width: 400,
}}
/>
),

View File

@ -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([
@ -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
},
@ -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)),
});
}
};

View File

@ -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"
}
}

View File

@ -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([
@ -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',
},
],
},
]);
}
@ -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}`),
);
}
};