superset/superset-frontend/temporary_superset_ui/superset-ui/packages/generator-superset/generators/plugin-chart/index.js

100 lines
2.9 KiB
JavaScript
Raw Normal View History

/* eslint-disable sort-keys */
const Generator = require('yeoman-generator');
const _ = require('lodash');
module.exports = class extends Generator {
async prompting() {
this.option('skipInstall');
this.answers = await this.prompt([
{
type: 'input',
name: 'packageName',
message: 'Package name:',
// Default to current folder name
default: _.kebabCase(this.appname.replace('plugin chart', '').trim()),
},
{
type: 'input',
name: 'description',
message: 'Description:',
// Default to current folder name
default: _.upperFirst(_.startCase(this.appname.replace('plugin chart', '').trim())),
},
feat: updated viz plugin generator (#636) * feat: hello world plugin * Fix yeoman generator * Adding Emotion to template and template result * adding `reactify` technique to example code * fixing errant comma * annoying lint issue * React needed for JSX * questionable typing fix * labelling options * freshly generated hello world * linting and freshly generated plugin * add comments to buildQuery * Add docs * nixing word cloud console logs * lint annoyance * a note on multiple plugin exports * second option for building a plugin is now enabled * Officially supporting viz plugins ;) * fresh plugin build * Adding note about controls, and TODOs for example controls * linting * new lock file * adding file structure to readme * more transform props notes * better notes, better linting * Adding a third option for rendering plugin * fresh package rendering * manually updated plugin. Now let's see if the generator matches it! * template changes, fresh plugin render. * moving file tree to the right place * touchups to template (killing third option) * thumbnail update * Spit out form data, for good measure. * more clarity * dummy controls * bold control works, fresh docs, fresh build! * typing for fancy props * bump superset-ui deps to 0.14 * Implement header text and font size * Add tests + mcense headers + inor cleanup * Replace YourPluginName with packageLabel in README * remove trailing spaces * fix hard coded reference to HelloWorld * removing legacy generators * plugin comment tweaks * typescript comments, minor formatting * adding option for badges in readme * generator offers choice of function or class plugin * Add timeseries option * killing the plugin... we'll make that a separate PR. * add new tests * remove unnecessary imports * fix timeseries type * comment on value/label in select options Co-authored-by: Jesse Yang <jesse.yang@airbnb.com> * moving renderTrigger note up to first instance * control-utils -> chart-controls * Wrapper -> Styles nomenclature * Stronger typing (H/T @ktmud) * ControlPanelConfig type on control config * nixing requiresTime * moving Styles component to be external, passing it props * lint nits * typing tweak Co-authored-by: Ville Brofeldt <ville.v.brofeldt@gmail.com> Co-authored-by: Jesse Yang <jesse.yang@airbnb.com>
2020-07-02 11:52:24 -04:00
{
type: 'list',
name: 'componentType',
message: 'What type of React component would you like?',
choices: [
{
name: 'Class component',
value: 'class',
},
{
name: 'Function component (with hooks)',
value: 'function',
},
],
},
{
type: 'list',
name: 'chartType',
message: 'What type of chart would you like?',
choices: [
{
name: 'Time-series chart',
value: 'timeseries',
},
{
name: 'Regular chart',
value: 'regular',
},
],
},
{
type: 'confirm',
name: 'addBadges',
message: "Add superset-ui badges to your plugin's README.md",
default: true,
},
]);
}
writing() {
// 'hello-world' -> 'HelloWorld'
const packageLabel = _.upperFirst(_.camelCase(this.answers.packageName));
// 'hello-world' -> 'Hello World'
const pluginName = _.startCase(_.camelCase(this.answers.packageName));
const params = {
...this.answers,
packageLabel,
pluginName,
};
[
['package.erb', 'package.json'],
['tsconfig.json', 'tsconfig.json'],
['README.erb', 'README.md'],
['src/index.erb', 'src/index.ts'],
feat: updated viz plugin generator (#636) * feat: hello world plugin * Fix yeoman generator * Adding Emotion to template and template result * adding `reactify` technique to example code * fixing errant comma * annoying lint issue * React needed for JSX * questionable typing fix * labelling options * freshly generated hello world * linting and freshly generated plugin * add comments to buildQuery * Add docs * nixing word cloud console logs * lint annoyance * a note on multiple plugin exports * second option for building a plugin is now enabled * Officially supporting viz plugins ;) * fresh plugin build * Adding note about controls, and TODOs for example controls * linting * new lock file * adding file structure to readme * more transform props notes * better notes, better linting * Adding a third option for rendering plugin * fresh package rendering * manually updated plugin. Now let's see if the generator matches it! * template changes, fresh plugin render. * moving file tree to the right place * touchups to template (killing third option) * thumbnail update * Spit out form data, for good measure. * more clarity * dummy controls * bold control works, fresh docs, fresh build! * typing for fancy props * bump superset-ui deps to 0.14 * Implement header text and font size * Add tests + mcense headers + inor cleanup * Replace YourPluginName with packageLabel in README * remove trailing spaces * fix hard coded reference to HelloWorld * removing legacy generators * plugin comment tweaks * typescript comments, minor formatting * adding option for badges in readme * generator offers choice of function or class plugin * Add timeseries option * killing the plugin... we'll make that a separate PR. * add new tests * remove unnecessary imports * fix timeseries type * comment on value/label in select options Co-authored-by: Jesse Yang <jesse.yang@airbnb.com> * moving renderTrigger note up to first instance * control-utils -> chart-controls * Wrapper -> Styles nomenclature * Stronger typing (H/T @ktmud) * ControlPanelConfig type on control config * nixing requiresTime * moving Styles component to be external, passing it props * lint nits * typing tweak Co-authored-by: Ville Brofeldt <ville.v.brofeldt@gmail.com> Co-authored-by: Jesse Yang <jesse.yang@airbnb.com>
2020-07-02 11:52:24 -04:00
['src/plugin/buildQuery.erb', 'src/plugin/buildQuery.ts'],
['src/plugin/controlPanel.erb', 'src/plugin/controlPanel.ts'],
['src/plugin/index.erb', 'src/plugin/index.ts'],
feat: updated viz plugin generator (#636) * feat: hello world plugin * Fix yeoman generator * Adding Emotion to template and template result * adding `reactify` technique to example code * fixing errant comma * annoying lint issue * React needed for JSX * questionable typing fix * labelling options * freshly generated hello world * linting and freshly generated plugin * add comments to buildQuery * Add docs * nixing word cloud console logs * lint annoyance * a note on multiple plugin exports * second option for building a plugin is now enabled * Officially supporting viz plugins ;) * fresh plugin build * Adding note about controls, and TODOs for example controls * linting * new lock file * adding file structure to readme * more transform props notes * better notes, better linting * Adding a third option for rendering plugin * fresh package rendering * manually updated plugin. Now let's see if the generator matches it! * template changes, fresh plugin render. * moving file tree to the right place * touchups to template (killing third option) * thumbnail update * Spit out form data, for good measure. * more clarity * dummy controls * bold control works, fresh docs, fresh build! * typing for fancy props * bump superset-ui deps to 0.14 * Implement header text and font size * Add tests + mcense headers + inor cleanup * Replace YourPluginName with packageLabel in README * remove trailing spaces * fix hard coded reference to HelloWorld * removing legacy generators * plugin comment tweaks * typescript comments, minor formatting * adding option for badges in readme * generator offers choice of function or class plugin * Add timeseries option * killing the plugin... we'll make that a separate PR. * add new tests * remove unnecessary imports * fix timeseries type * comment on value/label in select options Co-authored-by: Jesse Yang <jesse.yang@airbnb.com> * moving renderTrigger note up to first instance * control-utils -> chart-controls * Wrapper -> Styles nomenclature * Stronger typing (H/T @ktmud) * ControlPanelConfig type on control config * nixing requiresTime * moving Styles component to be external, passing it props * lint nits * typing tweak Co-authored-by: Ville Brofeldt <ville.v.brofeldt@gmail.com> Co-authored-by: Jesse Yang <jesse.yang@airbnb.com>
2020-07-02 11:52:24 -04:00
['src/plugin/transformProps.erb', 'src/plugin/transformProps.ts'],
['src/types.erb', 'src/types.ts'],
['src/MyChart.erb', `src/${packageLabel}.tsx`],
['test/index.erb', 'test/index.test.ts'],
feat: updated viz plugin generator (#636) * feat: hello world plugin * Fix yeoman generator * Adding Emotion to template and template result * adding `reactify` technique to example code * fixing errant comma * annoying lint issue * React needed for JSX * questionable typing fix * labelling options * freshly generated hello world * linting and freshly generated plugin * add comments to buildQuery * Add docs * nixing word cloud console logs * lint annoyance * a note on multiple plugin exports * second option for building a plugin is now enabled * Officially supporting viz plugins ;) * fresh plugin build * Adding note about controls, and TODOs for example controls * linting * new lock file * adding file structure to readme * more transform props notes * better notes, better linting * Adding a third option for rendering plugin * fresh package rendering * manually updated plugin. Now let's see if the generator matches it! * template changes, fresh plugin render. * moving file tree to the right place * touchups to template (killing third option) * thumbnail update * Spit out form data, for good measure. * more clarity * dummy controls * bold control works, fresh docs, fresh build! * typing for fancy props * bump superset-ui deps to 0.14 * Implement header text and font size * Add tests + mcense headers + inor cleanup * Replace YourPluginName with packageLabel in README * remove trailing spaces * fix hard coded reference to HelloWorld * removing legacy generators * plugin comment tweaks * typescript comments, minor formatting * adding option for badges in readme * generator offers choice of function or class plugin * Add timeseries option * killing the plugin... we'll make that a separate PR. * add new tests * remove unnecessary imports * fix timeseries type * comment on value/label in select options Co-authored-by: Jesse Yang <jesse.yang@airbnb.com> * moving renderTrigger note up to first instance * control-utils -> chart-controls * Wrapper -> Styles nomenclature * Stronger typing (H/T @ktmud) * ControlPanelConfig type on control config * nixing requiresTime * moving Styles component to be external, passing it props * lint nits * typing tweak Co-authored-by: Ville Brofeldt <ville.v.brofeldt@gmail.com> Co-authored-by: Jesse Yang <jesse.yang@airbnb.com>
2020-07-02 11:52:24 -04:00
['test/plugin/buildQuery.test.erb', 'test/plugin/buildQuery.test.ts'],
['test/plugin/transformProps.test.erb', 'test/plugin/transformProps.test.ts'],
].forEach(([src, dest]) => {
this.fs.copyTpl(this.templatePath(src), this.destinationPath(dest), params);
});
['types/external.d.ts', 'src/images/thumbnail.png'].forEach(file => {
this.fs.copy(this.templatePath(file), this.destinationPath(file));
});
}
};