Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
9 changes: 9 additions & 0 deletions x-pack/legacy/plugins/canvas/.storybook/webpack.dll.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,25 @@ module.exports = {
'@storybook/theming',
'angular-mocks',
'angular',
'brace',
'chroma-js',
'highlight.js',
'html-entities',
'jquery',
'lodash.clone',
'lodash',
'markdown-it',
'mocha',
'monaco-editor',
'prop-types',
'react-ace',
'react-beautiful-dnd',
'react-dom',
'react-focus-lock',
'react-markdown',
'react-monaco-editor',
'react-resize-detector',
'react-virtualized',
'react',
'recompose',
'redux-actions',
Expand Down
10 changes: 0 additions & 10 deletions x-pack/legacy/plugins/canvas/scripts/clean_storybook_dll.js

This file was deleted.

134 changes: 106 additions & 28 deletions x-pack/legacy/plugins/canvas/scripts/storybook.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,40 +5,118 @@
*/

const path = require('path');
const devUtils = require('@kbn/dev-utils');
const fs = require('fs');
const del = require('del');
const { run } = require('@kbn/dev-utils');
const storybook = require('@storybook/react/standalone');
const execa = require('execa');

const log = new devUtils.ToolingLog({
level: 'info',
writeTo: process.stdout,
});
const { DLL_OUTPUT } = require('./../.storybook/constants');

const options = {
stdio: ['ignore', 'inherit', 'inherit'],
buffer: false,
};

execa.sync('node', ['storybook_dll.js'], {
cwd: __dirname,
...options,
});

// Ensure SASS has been built completely before starting Storybook
execa.sync(process.execPath, ['scripts/build_sass'], {
cwd: path.resolve(__dirname, '../../../../..'),
...options,
});

// Now watch the SASS sheets for changes
execa(process.execPath, ['scripts/build_sass', '--watch'], {
cwd: path.resolve(__dirname, '../../../../..'),
...options,
});

log.info('storybook: Starting Storybook');
storybook({
mode: 'dev',
port: 9001,
const storybookOptions = {
configDir: path.resolve(__dirname, './../.storybook'),
});
mode: 'dev',
};

run(
({ log, flags }) => {
const { dll, clean, stats, site } = flags;

// Delete the existing DLL if we're cleaning or building.
if (clean || dll) {
del.sync([DLL_OUTPUT], { force: true });

if (clean) {
return;
}
}

// Ensure SASS dependencies have been built before doing anything.
execa.sync(process.execPath, ['scripts/build_sass'], {
cwd: path.resolve(__dirname, '../../../../..'),
...options,
});

// Build the DLL if necessary.
if (fs.existsSync(DLL_OUTPUT)) {
log.info('storybook: DLL exists from previous build; skipping');
} else {
log.info('storybook: Building DLL');
execa.sync(
'yarn',
[
'webpack',
'--config',
'x-pack/legacy/plugins/canvas/.storybook/webpack.dll.config.js',
'--progress',
'--hide-modules',
'--display-entrypoints',
'false',
],
{
cwd: path.resolve(__dirname, '../../../../..'),
stdio: ['ignore', 'inherit', 'inherit'],
buffer: false,
}
);
log.success('storybook: DLL built');
}

// If we're only building the DLL, we're done.
if (dll) {
return;
}

// Build statistics and exit
if (stats) {
log.success('storybook: Generating Storybook statistics');
storybook({
...storybookOptions,
smokeTest: true,
});
return;
}

// Build site and exit
if (site) {
log.success('storybook: Generating Storybook site');
storybook({
...storybookOptions,
mode: 'static',
outputDir: path.resolve(__dirname, './../storybook'),
});
return;
}

log.info('storybook: Starting Storybook');

// Watch the SASS sheets for changes
execa(process.execPath, ['scripts/build_sass', '--watch'], {
cwd: path.resolve(__dirname, '../../../../..'),
...options,
});

storybook({
...storybookOptions,
port: 9001,
});
},
{
description: `
Storybook runner for Canvas.
`,
flags: {
boolean: ['dll', 'clean', 'stats', 'site'],
help: `
--clean Forces a clean of the Storybook DLL and exits.
--dll Cleans and builds the Storybook dependency DLL and exits.
--stats Produces a Webpack stats file.
--site Produces a site deployment of this Storybook.
`,
},
}
);
40 changes: 0 additions & 40 deletions x-pack/legacy/plugins/canvas/scripts/storybook_dll.js

This file was deleted.

31 changes: 0 additions & 31 deletions x-pack/legacy/plugins/canvas/scripts/storybook_static.js

This file was deleted.

2 changes: 1 addition & 1 deletion x-pack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"license": "Elastic-License",
"scripts": {
"kbn": "node ../scripts/kbn",
"kbn:bootstrap": "node legacy/plugins/canvas/scripts/clean_storybook_dll",
"kbn:bootstrap": "node legacy/plugins/canvas/scripts/storybook --clean",
"start": "gulp dev",
"build": "gulp build",
"testonly": "gulp testonly",
Expand Down