From df7a49cfacc43ace8f54f2bfa085e62c8f9744ac Mon Sep 17 00:00:00 2001 From: Krist Wongsuphasawat Date: Fri, 1 Feb 2019 11:42:22 -0800 Subject: [PATCH] Minor updates for generators (#87) * update version in package template * change only first letter to uppercase * update template * add language choice --- .../legacy-plugin-chart-demo/index.js | 2 +- .../templates/Stories.jsx | 4 +-- .../generators/legacy-plugin-chart/index.js | 9 ++---- .../templates/_package.json | 9 +++--- .../generators/package/index.js | 30 ++++++++++++++----- 5 files changed, 32 insertions(+), 22 deletions(-) diff --git a/superset-frontend/temporary_superset_ui/superset-ui/packages/generator-superset/generators/legacy-plugin-chart-demo/index.js b/superset-frontend/temporary_superset_ui/superset-ui/packages/generator-superset/generators/legacy-plugin-chart-demo/index.js index 90a708f527..d730dcb3d3 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/packages/generator-superset/generators/legacy-plugin-chart-demo/index.js +++ b/superset-frontend/temporary_superset_ui/superset-ui/packages/generator-superset/generators/legacy-plugin-chart-demo/index.js @@ -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 }, ]); } diff --git a/superset-frontend/temporary_superset_ui/superset-ui/packages/generator-superset/generators/legacy-plugin-chart-demo/templates/Stories.jsx b/superset-frontend/temporary_superset_ui/superset-ui/packages/generator-superset/generators/legacy-plugin-chart-demo/templates/Stories.jsx index a5f1224242..681bc7d081 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/packages/generator-superset/generators/legacy-plugin-chart-demo/templates/Stories.jsx +++ b/superset-frontend/temporary_superset_ui/superset-ui/packages/generator-superset/generators/legacy-plugin-chart-demo/templates/Stories.jsx @@ -9,11 +9,11 @@ export default [ chartType="<%= packageName %>" chartProps={{ formData: {}, - height: 600, + height: 400, payload: { data: [], }, - width: 600, + width: 400, }} /> ), diff --git a/superset-frontend/temporary_superset_ui/superset-ui/packages/generator-superset/generators/legacy-plugin-chart/index.js b/superset-frontend/temporary_superset_ui/superset-ui/packages/generator-superset/generators/legacy-plugin-chart/index.js index 7cf0867943..1e2558c094 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/packages/generator-superset/generators/legacy-plugin-chart/index.js +++ b/superset-frontend/temporary_superset_ui/superset-ui/packages/generator-superset/generators/legacy-plugin-chart/index.js @@ -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)), }); } }; diff --git a/superset-frontend/temporary_superset_ui/superset-ui/packages/generator-superset/generators/legacy-plugin-chart/templates/_package.json b/superset-frontend/temporary_superset_ui/superset-ui/packages/generator-superset/generators/legacy-plugin-chart/templates/_package.json index 315e34c244..df3e368069 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/packages/generator-superset/generators/legacy-plugin-chart/templates/_package.json +++ b/superset-frontend/temporary_superset_ui/superset-ui/packages/generator-superset/generators/legacy-plugin-chart/templates/_package.json @@ -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" } } \ No newline at end of file diff --git a/superset-frontend/temporary_superset_ui/superset-ui/packages/generator-superset/generators/package/index.js b/superset-frontend/temporary_superset_ui/superset-ui/packages/generator-superset/generators/package/index.js index 3a70962ed2..b12547471d 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/packages/generator-superset/generators/package/index.js +++ b/superset-frontend/temporary_superset_ui/superset-ui/packages/generator-superset/generators/package/index.js @@ -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}`), + ); } };