Skip to content

Commit

Permalink
refactor(monorepo): update plugin dependencies (apache#17837)
Browse files Browse the repository at this point in the history
* refactor(monorepo): use local dependencies in packages.json

* add prettier ignore

* update commit message

* fix release workflow

* refine release script
  • Loading branch information
zhaoyongjie committed Dec 22, 2021
1 parent ec48dd5 commit 9840fbf
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 88 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,14 @@ jobs:
${{ runner.os }}-npm-
- name: Install dependencies
working-directory: ./superset-frontend
run: npm ci
- name: Build packages
run: npm run plugins:build
- name: Run unit tests
working-directory: ./superset-frontend
run: npm run test -- plugins packages
- name: Build packages
working-directory: ./superset-frontend
run: npm run plugins:build

- name: Configure npm and git
run: |
Expand All @@ -73,6 +76,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Bump version and publish package(s)
working-directory: ./superset-frontend
run: |
git tag -d `git tag | grep -E '^trigger-'`
npm run plugins:release-from-tag
Expand Down
1 change: 1 addition & 0 deletions superset-frontend/.prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ lib/
tmp/
node_modules/
tsconfig.json
lerna.json
CHANGELOG.md
*.geojson
*-topo.json
Expand Down
56 changes: 28 additions & 28 deletions superset-frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

62 changes: 31 additions & 31 deletions superset-frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@
"plugins:build-assets": "node ./scripts/copyAssets.js",
"plugins:build-storybook": "cd packages/superset-ui-demo && npm run build-storybook",
"plugins:chromatic": "cd packages/superset-ui-demo && npm run chromatic",
"plugins:create-conventional-version": "npm run prune && ./scripts/lernaVersion.sh '--conventional-commits --create-release github'",
"plugins:create-minor-version": "npm run prune && ./scripts/lernaVersion.sh minor",
"plugins:create-patch-version": "npm run prune && ./scripts/lernaVersion.sh patch",
"plugins:create-conventional-version": "npm run prune && lerna version --conventional-commits --create-release github --yes",
"plugins:create-minor-version": "npm run prune && lerna version minor --yes",
"plugins:create-patch-version": "npm run prune && lerna version patch --yes",
"plugins:release-conventional": "npm run prune && lerna publish --conventional-commits --create-release github --yes",
"plugins:release-from-tag": "npm run prune && lerna publish from-package --yes",
"plugins:storybook": "cd packages/superset-ui-demo && npm run storybook",
Expand All @@ -80,34 +80,34 @@
"@emotion/cache": "^11.4.0",
"@emotion/react": "^11.4.1",
"@emotion/styled": "^11.3.0",
"@superset-ui/chart-controls": "^0.18.25",
"@superset-ui/core": "^0.18.25",
"@superset-ui/legacy-plugin-chart-calendar": "^0.18.25",
"@superset-ui/legacy-plugin-chart-chord": "^0.18.25",
"@superset-ui/legacy-plugin-chart-country-map": "^0.18.25",
"@superset-ui/legacy-plugin-chart-event-flow": "^0.18.25",
"@superset-ui/legacy-plugin-chart-force-directed": "^0.18.25",
"@superset-ui/legacy-plugin-chart-heatmap": "^0.18.25",
"@superset-ui/legacy-plugin-chart-histogram": "^0.18.25",
"@superset-ui/legacy-plugin-chart-horizon": "^0.18.25",
"@superset-ui/legacy-plugin-chart-map-box": "^0.18.25",
"@superset-ui/legacy-plugin-chart-paired-t-test": "^0.18.25",
"@superset-ui/legacy-plugin-chart-parallel-coordinates": "^0.18.25",
"@superset-ui/legacy-plugin-chart-partition": "^0.18.25",
"@superset-ui/legacy-plugin-chart-pivot-table": "^0.18.25",
"@superset-ui/legacy-plugin-chart-rose": "^0.18.25",
"@superset-ui/legacy-plugin-chart-sankey": "^0.18.25",
"@superset-ui/legacy-plugin-chart-sankey-loop": "^0.18.25",
"@superset-ui/legacy-plugin-chart-sunburst": "^0.18.25",
"@superset-ui/legacy-plugin-chart-treemap": "^0.18.25",
"@superset-ui/legacy-plugin-chart-world-map": "^0.18.25",
"@superset-ui/legacy-preset-chart-deckgl": "^0.4.13",
"@superset-ui/legacy-preset-chart-nvd3": "^0.18.25",
"@superset-ui/plugin-chart-echarts": "^0.18.25",
"@superset-ui/plugin-chart-pivot-table": "^0.18.25",
"@superset-ui/plugin-chart-table": "^0.18.25",
"@superset-ui/plugin-chart-word-cloud": "^0.18.25",
"@superset-ui/preset-chart-xy": "^0.18.25",
"@superset-ui/chart-controls": "file://./packages/superset-ui-chart-controls",
"@superset-ui/core": "file://./packages/superset-ui-core",
"@superset-ui/legacy-plugin-chart-calendar": "file://./plugins/legacy-plugin-chart-calendar",
"@superset-ui/legacy-plugin-chart-chord": "file://./plugins/legacy-plugin-chart-chord",
"@superset-ui/legacy-plugin-chart-country-map": "file://./plugins/legacy-plugin-chart-country-map",
"@superset-ui/legacy-plugin-chart-event-flow": "file://./plugins/legacy-plugin-chart-event-flow",
"@superset-ui/legacy-plugin-chart-force-directed": "file://./plugins/legacy-plugin-chart-force-directed",
"@superset-ui/legacy-plugin-chart-heatmap": "file://./plugins/legacy-plugin-chart-heatmap",
"@superset-ui/legacy-plugin-chart-histogram": "file://./plugins/legacy-plugin-chart-histogram",
"@superset-ui/legacy-plugin-chart-horizon": "file://./plugins/legacy-plugin-chart-horizon",
"@superset-ui/legacy-plugin-chart-map-box": "file://./plugins/legacy-plugin-chart-map-box",
"@superset-ui/legacy-plugin-chart-paired-t-test": "file://./plugins/legacy-plugin-chart-paired-t-test",
"@superset-ui/legacy-plugin-chart-parallel-coordinates": "file://./plugins/legacy-plugin-chart-parallel-coordinates",
"@superset-ui/legacy-plugin-chart-partition": "file://./plugins/legacy-plugin-chart-partition",
"@superset-ui/legacy-plugin-chart-pivot-table": "file://./plugins/legacy-plugin-chart-pivot-table",
"@superset-ui/legacy-plugin-chart-rose": "file://./plugins/legacy-plugin-chart-rose",
"@superset-ui/legacy-plugin-chart-sankey": "file://./plugins/legacy-plugin-chart-sankey",
"@superset-ui/legacy-plugin-chart-sankey-loop": "file://./plugins/legacy-plugin-chart-sankey-loop",
"@superset-ui/legacy-plugin-chart-sunburst": "file://./plugins/legacy-plugin-chart-sunburst",
"@superset-ui/legacy-plugin-chart-treemap": "file://./plugins/legacy-plugin-chart-treemap",
"@superset-ui/legacy-plugin-chart-world-map": "file://./plugins/legacy-plugin-chart-world-map",
"@superset-ui/legacy-preset-chart-deckgl": "file://./plugins/legacy-preset-chart-deckgl",
"@superset-ui/legacy-preset-chart-nvd3": "file://./plugins/legacy-preset-chart-nvd3",
"@superset-ui/plugin-chart-echarts": "file://./plugins/plugin-chart-echarts",
"@superset-ui/plugin-chart-pivot-table": "file://./plugins/plugin-chart-pivot-table",
"@superset-ui/plugin-chart-table": "file://./plugins/plugin-chart-table",
"@superset-ui/plugin-chart-word-cloud": "file://./plugins/plugin-chart-word-cloud",
"@superset-ui/preset-chart-xy": "file://./plugins/preset-chart-xy",
"@vx/responsive": "^0.0.195",
"abortcontroller-polyfill": "^1.1.9",
"antd": "^4.9.4",
Expand Down
6 changes: 1 addition & 5 deletions superset-frontend/scripts/lernaVersion.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,7 @@ fi

# Get the current tag version
tag=v$(node -e "process.stdout.write(require('./lerna.json').version)");
message="chore: publish $tag"

# Update the lock file here
rm "$rootDir/package-lock.json"
npm i --package-lock-only
message="chore(plugins): publish $tag"

if [[ $? -ne 0 ]]; then
echo '[ERROR] Can not update package-lock.json'
Expand Down
32 changes: 10 additions & 22 deletions superset-frontend/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ const config = {
resolve: {
modules: [APP_DIR, 'node_modules', ROOT_DIR],
alias: {
// TODO: remove alias once React has been upgraaded to v. 17
react: path.resolve('./node_modules/react'),
},
extensions: ['.ts', '.tsx', '.js', '.jsx', '.yml'],
Expand Down Expand Up @@ -422,33 +423,20 @@ const config = {
};

// find all the symlinked plugins and use their source code for imports
Object.entries(packageConfig.dependencies).forEach(([pkg, version]) => {
Object.entries(packageConfig.dependencies).forEach(([pkg, relativeDir]) => {
const srcPath = `./node_modules/${pkg}/src`;
const dir = relativeDir.replace('file://', '');

if (/^superset-plugin-/.test(pkg) && fs.existsSync(srcPath)) {
console.log(
`[Superset External Plugin] Use symlink source for ${pkg} @ ${version}`,
`[Superset External Plugin] Use symlink source for ${pkg} @ ${dir}`,
);
// TODO: remove alias once React has been upgraaded to v. 17
config.resolve.alias[pkg] = path.resolve(
APP_DIR,
`node_modules/${pkg}/src`,
);
} else if (/^@superset-ui/.test(pkg) && fs.existsSync(srcPath)) {
console.log(`[Superset Plugin] Use symlink source for ${pkg} @ ${version}`);
// only allow exact match so imports like `@superset-ui/plugin-name/lib`
// and `@superset-ui/plugin-name/esm` can still work.
const pkgDirectory = pkg.split('/').pop();
if (/^(core|chart-controls)/.test(pkgDirectory)) {
config.resolve.alias[pkg] = path.resolve(
APP_DIR,
`packages/superset-ui-${pkgDirectory}/src`,
);
} else {
config.resolve.alias[pkg] = path.resolve(
APP_DIR,
`plugins/${pkgDirectory}/src`,
);
}
config.resolve.alias[pkg] = path.resolve(APP_DIR, `${dir}/src`);
}
if (/^@superset-ui/.test(pkg) && fs.existsSync(srcPath)) {
console.log(`[Superset Plugin] Use symlink source for ${pkg} @ ${dir}`);
config.resolve.alias[pkg] = path.resolve(APP_DIR, `${dir}/src`);
}
});
console.log(''); // pure cosmetic new line
Expand Down

0 comments on commit 9840fbf

Please sign in to comment.