Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(generator-superset): migrate to monorepo #17829

Merged
merged 4 commits into from
Dec 21, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,36 +27,13 @@ module.exports = class extends Generator {
async prompting() {
// Have Yeoman greet the user.
this.log(
yosay(`Welcome to the rad ${chalk.red('generator-superset')} generator!`),
yosay(`Welcome to the ${chalk.red('generator-superset')} generator!`),
);

this.option('skipInstall');

this.answers = await this.prompt([
{
type: 'list',
name: 'subgenerator',
message: 'What do you want to do?',
choices: [
{
name: 'Create superset-ui core package',
value: 'package',
},
{
name: 'Create superset-ui chart plugin package',
value: 'plugin-chart',
},
],
},
]);
}

configuring() {
// Redirect the default 'app' generator
// to 'package' subgenerator
// until there are multiple subgenerators
// then this can be changed into a menu to select
// subgenerator.
this.composeWith(require.resolve(`../${this.answers.subgenerator}`));
this.composeWith(require.resolve(`../plugin-chart`));
}
};

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -32,32 +32,19 @@ module.exports = class extends Generator {
name: 'packageName',
message: 'Package name:',
// Default to current folder name
default: _.kebabCase(this.appname.replace('plugin chart', '').trim()),
default: _.kebabCase(
this.appname.replace('superset plugin chart', '').trim(),
),
},
{
type: 'input',
name: 'description',
message: 'Description:',
// Default to current folder name
default: _.upperFirst(
_.startCase(this.appname.replace('plugin chart', '').trim()),
_.startCase(this.appname.replace('superset plugin chart', '').trim()),
),
},
{
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',
Expand All @@ -73,12 +60,6 @@ module.exports = class extends Generator {
},
],
},
{
type: 'confirm',
name: 'addBadges',
message: "Add superset-ui badges to your plugin's README.md",
default: true,
},
]);
}

Expand All @@ -96,9 +77,10 @@ module.exports = class extends Generator {
};

[
['babel.config.js', 'babel.config.js'],
['package.erb', 'package.json'],
['tsconfig.json', 'tsconfig.json'],
['README.erb', 'README.md'],
['tsconfig.json', 'tsconfig.json'],
['src/index.erb', 'src/index.ts'],
['src/plugin/buildQuery.erb', 'src/plugin/buildQuery.ts'],
['src/plugin/controlPanel.erb', 'src/plugin/controlPanel.ts'],
Expand All @@ -107,6 +89,10 @@ module.exports = class extends Generator {
['src/types.erb', 'src/types.ts'],
['src/MyChart.erb', `src/${packageLabel}.tsx`],
['test/index.erb', 'test/index.test.ts'],
[
'test/__mocks__/mockExportString.js',
'test/__mocks__/mockExportString.js',
],
['test/plugin/buildQuery.test.erb', 'test/plugin/buildQuery.test.ts'],
[
'test/plugin/transformProps.test.erb',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
## @superset-ui/plugin-chart-<%= packageName %>

<%if (addBadges) { %>[![Version](https://img.shields.io/npm/v/@superset-ui/plugin-chart-<%= packageName %>.svg?style=flat-square)](https://www.npmjs.com/package/@superset-ui/plugin-chart-<%= packageName %>)<% } %>
## superset-plugin-chart-<%= packageName %>

This plugin provides <%= description %> for Superset.

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const { getConfig } = require('@airbnb/config-babel');

const config = getConfig({
library: true,
react: true,
next: true,
esm: process.env.BABEL_OUTPUT === 'esm',
node: process.env.NODE_ENV === 'test',
typescript: true,
env: {
targets: { esmodules: true },
},
});

config.plugins = [
['babel-plugin-transform-dev', { evaluate: false }],
['babel-plugin-typescript-to-proptypes', { loose: true }],
['@babel/plugin-proposal-class-properties', { loose: true }],
];
module.exports = config;
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
moduleFileExtensions: ['mock.js', 'ts', 'tsx', 'js', 'jsx', 'json', 'node'],
moduleNameMapper: {
'\\.(gif|ttf|eot|png|jpg)$': '<rootDir>/test/__mocks__/mockExportString.js',
},
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@superset-ui/plugin-chart-<%= packageName %>",
"version": "0.0.0",
"name": "superset-plugin-chart-<%= packageName %>",
"version": "0.1.0",
"description": "Superset Chart - <%= description %>",
"sideEffects": false,
"main": "lib/index.js",
Expand All @@ -9,31 +9,38 @@
"esm",
"lib"
],
"repository": {
"type": "git",
"url": "git+https://github.com/apache-superset/superset-ui.git"
"scripts": {
"build": "npm run build-cjs && npm run build-esm && npm run ts-types",
"build-cjs": "babel src --extensions \".ts,.tsx,.js,.jsx\" --copy-files --out-dir lib",
"build-clean": "npm run clean && npm run build",
"build-esm": "BABEL_OUTPUT=esm babel src --extensions \".ts,.tsx,.js,.jsx\" --copy-files --out-dir esm",
"clean": "rm -rf {lib,esm,tsconfig.tsbuildinfo}",
"dev": "webpack --mode=development --color --watch",
"ts-types": "tsc --build",
"test": "jest"
},
"keywords": [
"superset"
],
"author": "Superset",
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/apache-superset/superset-ui/issues"
},
"homepage": "https://github.com/apache-superset/superset-ui#readme",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@superset-ui/core": "^0.17.40",
"@superset-ui/chart-controls": "^0.17.41"
"@superset-ui/core": "^0.18.25",
"@superset-ui/chart-controls": "^0.18.25"
},
"peerDependencies": {
"react": "^16.13.1"
},
"devDependencies": {
"@types/jest": "^26.0.0",
"jest": "^26.0.1"
"@airbnb/config-babel": "^2.0.1",
"@babel/cli": "^7.16.0",
"@types/jest": "^26.0.4",
"babel-loader": "^8.2.2",
"clean-webpack-plugin": "^4.0.0",
"jest": "^26.6.3",
"thread-loader": "^3.0.4",
"ts-loader": "^9.2.5",
"typescript": "^4.1.2",
"url-loader": "^4.1.1"
}
}
Loading