Skip to content

Commit

Permalink
build: migrate to storybook 5 (apache-superset#46)
Browse files Browse the repository at this point in the history
* build: migrate to storybook 5

* fix: configuration

* fix: delete dir on build
  • Loading branch information
kristw committed Apr 10, 2019
1 parent 98387ff commit 62d7c71
Show file tree
Hide file tree
Showing 9 changed files with 97 additions and 100 deletions.
6 changes: 3 additions & 3 deletions plugins/superset-ui-plugins/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"private": true,
"scripts": {
"build": "yarn build:cjs && yarn build:esm && yarn run type:dts && yarn build:assets",
"build:cjs": "NODE_ENV=production beemo babel --extensions=\".js,.jsx,.ts,.tsx\" ./src --out-dir lib/ --minify --workspaces=\"@superset-ui/!(plugins-demo)\"",
"build:esm": "NODE_ENV=production beemo babel --extensions=\".js,.jsx,.ts,.tsx\" ./src --out-dir esm/ --esm --minify --workspaces=\"@superset-ui/!(plugins-demo)\"",
"build:cjs": "NODE_ENV=production beemo babel --extensions=\".js,.jsx,.ts,.tsx\" ./src --out-dir lib/ --delete-dir-on-start --minify --workspaces=\"@superset-ui/!(plugins-demo)\"",
"build:esm": "NODE_ENV=production beemo babel --extensions=\".js,.jsx,.ts,.tsx\" ./src --out-dir esm/ --delete-dir-on-start --esm --minify --workspaces=\"@superset-ui/!(plugins-demo)\"",
"build:assets": "node ./buildAssets.js",
"commit": "superset-commit",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0",
Expand All @@ -15,7 +15,7 @@
"lint": "beemo create-config prettier && beemo eslint \"./packages/*/{src,test,storybook}/**/*.{js,jsx,ts,tsx}\"",
"lint:fix": "beemo create-config prettier && beemo eslint --fix \"./packages/*/{src,test,storybook}/**/*.{js,jsx,ts,tsx}\"",
"jest": "beemo jest --color --coverage --react",
"postrelease": "lerna run gh-pages",
"postrelease": "lerna run deploy-demo",
"prepare-release": "git checkout master && git pull --rebase origin master && lerna bootstrap && yarn run test",
"prerelease": "yarn run build",
"pretest": "yarn run lint",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// note that the import order here determines the order in the UI!
import '@storybook/addon-actions/register';
import '@storybook/addon-links/register';
import '@storybook/addon-knobs/register';
import '@storybook/addon-options/register';
import 'storybook-addon-jsx/register';
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
import { addDecorator } from '@storybook/react';
import { withOptions } from '@storybook/addon-options';
import { addParameters, configure } from '@storybook/react';

addDecorator(
withOptions({
addParameters({
options: {
name: '@superset-ui/plugins 🔌💡',
addonPanelInRight: false,
enableShortcuts: false,
goFullScreen: false,
hierarchySeparator: /\|/,
// hierarchyRootSeparator: null,
name: '@superset-ui/plugins 🔌💡',
selectedAddonPanel: undefined, // The order of addons in the "Addon panel" is the same as you import them in 'addons.js'. The first panel will be opened by default as you run Storybook
showAddonPanel: true,
showSearchBox: false,
showStoriesPanel: true,
sidebarAnimations: true,
sortStoriesByKind: false,
url: '#',
}),
);
},
});

function loadStorybook() {
require('./storybook.css');
require('../storybook/stories'); // all of the stories
}

configure(loadStorybook, module);
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
const path = require('path');

const BABEL_TYPESCRIPT_OPTIONS = {
presets: [
['@babel/preset-env', { useBuiltIns: 'entry' }],
'@babel/preset-react',
'@babel/preset-typescript',
],
plugins: [
'@babel/plugin-proposal-object-rest-spread',
'@babel/plugin-proposal-class-properties',
'@babel/plugin-syntax-dynamic-import',
]
};

const SIBLING_PACKAGES_PATH_REGEXP = new RegExp(
`${path.resolve(__dirname, '../../superset-ui-(legacy-)*(plugin|preset)-')}.+/src`,
);

module.exports = async ({ config }) => {
config.resolve = config.resolve || {};
config.resolve.extensions = ['.tsx', '.ts', '.jsx', '.js'];

// To enable live debugging of other packages when referring to `src`
config.module.rules.push({
include: SIBLING_PACKAGES_PATH_REGEXP,
exclude: /node_modules/,
test: /\.jsx?$/,
use: config.module.rules[0].use,
});

// Enable TypeScript
config.module.rules.push({
include: SIBLING_PACKAGES_PATH_REGEXP,
exclude: /node_modules/,
test: /\.tsx?$/,
use: [{
loader: 'babel-loader',
options: BABEL_TYPESCRIPT_OPTIONS,
}],
});

config.module.rules.push({
exclude: /node_modules/,
test: /\.tsx?$/,
use: [{
loader: 'babel-loader',
options: BABEL_TYPESCRIPT_OPTIONS,
}],
});

return config;
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
"private": true,
"main": "index.js",
"scripts": {
"gh-pages:clean": "rm -rf _gh-pages",
"gh-pages:build": "build-storybook -o _gh-pages -c storybook-config",
"gh-pages:publish": "git-directory-deploy --directory _gh-pages",
"gh-pages": "npm run gh-pages:clean && npm run gh-pages:build && npm run gh-pages:publish && npm run gh-pages:clean",
"storybook": "start-storybook -p 9001 -c storybook-config"
"demo:clean": "rm -rf _gh-pages",
"demo:build": "build-storybook -o _gh-pages",
"demo:publish": "gh-pages -d _gh-pages",
"deploy-demo": "npm run demo:clean && npm run demo:build && npm run demo:publish && npm run demo:clean",
"storybook": "start-storybook -p 9001"
},
"repository": {
"type": "git",
Expand All @@ -29,26 +29,29 @@
},
"homepage": "https://github.com/apache-superset/superset-ui-plugins#readme",
"dependencies": {
"@babel/core": "^7.1.2",
"@babel/plugin-syntax-dynamic-import": "^7.2.0",
"@babel/polyfill": "^7.4.3",
"@data-ui/event-flow": "^0.0.54",
"@storybook/addon-knobs": "^4.0.2",
"@storybook/addon-options": "^4.0.3",
"@storybook/react": "^4.1.11",
"@storybook/addon-actions": "^5.0.6",
"@storybook/addon-knobs": "^5.0.6",
"@storybook/addon-links": "^5.0.6",
"@storybook/addons": "^5.0.6",
"@storybook/react": "^5.0.6",
"@types/react": "^16.8.8",
"@types/storybook__addon-knobs": "^4.0.4",
"bootstrap": "^4.3.1",
"react": "^16.6.0",
"storybook-addon-jsx": "^7.1.0"
},
"devDependencies": {
"@babel/core": "^7.4.3",
"@babel/plugin-syntax-dynamic-import": "^7.2.0",
"babel-loader": "^8.0.5",
"gh-pages": "^2.0.1"
},
"peerDependencies": {
"@superset-ui/chart": "^0.11.0",
"@superset-ui/color": "^0.11.0",
"@superset-ui/time-format": "^0.11.0",
"@superset-ui/translation": "^0.11.0",
"@types/react": "^16.8.8",
"babel-loader": "^8.0.4",
"bootstrap": "^3.3.6",
"cache-loader": "^1.2.2",
"fork-ts-checker-webpack-plugin": "^0.4.9",
"git-directory-deploy": "^1.5.1",
"react": "^16.6.0",
"react-dom": "^16.6.0",
"storybook-addon-jsx": "^5.4.0",
"thread-loader": "^1.2.0",
"ts-loader": "^5.2.0"
"@superset-ui/translation": "^0.11.0"
}
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import '@babel/polyfill';
import { setAddon, storiesOf } from '@storybook/react';
import { withKnobs } from '@storybook/addon-knobs';
import JSXAddon from 'storybook-addon-jsx';
Expand Down

0 comments on commit 62d7c71

Please sign in to comment.