@storybook/core-server 6.5.7 → 7.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -1
- package/dist/cjs/build-dev.js +55 -140
- package/dist/cjs/build-static.js +45 -75
- package/dist/cjs/dev-server.js +10 -7
- package/dist/cjs/presets/babel-cache-preset.js +2 -4
- package/dist/cjs/presets/common-preset.js +32 -16
- package/dist/cjs/standalone.js +9 -1
- package/dist/cjs/utils/StoryIndexGenerator.js +16 -4
- package/dist/cjs/utils/{get-manager-builder.js → get-builders.js} +31 -25
- package/dist/esm/build-dev.js +53 -130
- package/dist/esm/build-static.js +40 -64
- package/dist/esm/dev-server.js +10 -6
- package/dist/esm/presets/babel-cache-preset.js +1 -2
- package/dist/esm/presets/common-preset.js +24 -15
- package/dist/esm/standalone.js +8 -1
- package/dist/esm/utils/StoryIndexGenerator.js +17 -5
- package/dist/esm/utils/get-builders.js +36 -0
- package/dist/types/build-dev.d.ts +2 -0
- package/dist/{ts3.9 → types}/build-static.d.ts +0 -1
- package/dist/{ts3.9 → types}/dev-server.d.ts +0 -0
- package/dist/{ts3.9 → types}/index.d.ts +0 -0
- package/dist/types/presets/babel-cache-preset.d.ts +1 -0
- package/dist/{ts3.4 → types}/presets/common-preset.d.ts +29 -31
- package/dist/{ts3.9 → types}/standalone.d.ts +0 -0
- package/dist/{ts3.9 → types}/utils/StoryIndexGenerator.d.ts +4 -1
- package/dist/{ts3.9 → types}/utils/__mockdata__/E.stories.d.ts +0 -0
- package/dist/{ts3.9 → types}/utils/__mockdata__/deeply/nested/single/File.stories.d.ts +0 -0
- package/dist/{ts3.9 → types}/utils/__mockdata__/src/B.stories.d.ts +0 -0
- package/dist/{ts3.9 → types}/utils/__mockdata__/src/NoMeta.stories.d.ts +0 -0
- package/dist/{ts3.9 → types}/utils/__mockdata__/src/nested/Button.d.ts +0 -0
- package/dist/{ts3.9 → types}/utils/__mockdata__/src/nested/Button.stories.d.ts +0 -0
- package/dist/{ts3.9 → types}/utils/__mockdata__/src/second-nested/G.stories.d.ts +0 -0
- package/dist/{ts3.9 → types}/utils/copy-all-static-files.d.ts +0 -0
- package/dist/types/utils/get-builders.d.ts +2 -0
- package/dist/{ts3.9 → types}/utils/get-server-channel.d.ts +0 -0
- package/dist/{ts3.9 → types}/utils/metadata.d.ts +0 -0
- package/dist/{ts3.9 → types}/utils/middleware.d.ts +0 -0
- package/dist/{ts3.9 → types}/utils/open-in-browser.d.ts +0 -0
- package/dist/{ts3.9 → types}/utils/output-startup-information.d.ts +0 -0
- package/dist/{ts3.4 → types}/utils/output-stats.d.ts +3 -3
- package/dist/{ts3.9 → types}/utils/release-notes.d.ts +0 -0
- package/dist/{ts3.9 → types}/utils/server-address.d.ts +0 -0
- package/dist/{ts3.9 → types}/utils/server-init.d.ts +0 -0
- package/dist/{ts3.9 → types}/utils/server-statics.d.ts +0 -0
- package/dist/{ts3.9 → types}/utils/stories-json.d.ts +0 -0
- package/dist/{ts3.9 → types}/utils/update-check.d.ts +0 -0
- package/dist/{ts3.9 → types}/utils/watch-story-specifiers.d.ts +0 -0
- package/package.json +14 -23
- package/dist/cjs/cli/dev.js +0 -63
- package/dist/cjs/cli/index.js +0 -31
- package/dist/cjs/cli/prod.js +0 -43
- package/dist/cjs/cli/utils.js +0 -63
- package/dist/cjs/utils/get-preview-builder.js +0 -47
- package/dist/esm/cli/dev.js +0 -44
- package/dist/esm/cli/index.js +0 -2
- package/dist/esm/cli/prod.js +0 -26
- package/dist/esm/cli/utils.js +0 -48
- package/dist/esm/utils/get-manager-builder.js +0 -26
- package/dist/esm/utils/get-preview-builder.js +0 -28
- package/dist/modern/build-dev.js +0 -232
- package/dist/modern/build-static.js +0 -237
- package/dist/modern/cli/dev.js +0 -44
- package/dist/modern/cli/index.js +0 -2
- package/dist/modern/cli/prod.js +0 -26
- package/dist/modern/cli/utils.js +0 -48
- package/dist/modern/dev-server.js +0 -200
- package/dist/modern/index.js +0 -4
- package/dist/modern/presets/babel-cache-preset.js +0 -18
- package/dist/modern/presets/common-preset.js +0 -124
- package/dist/modern/standalone.js +0 -30
- package/dist/modern/utils/StoryIndexGenerator.js +0 -222
- package/dist/modern/utils/__mockdata__/E.stories.js +0 -5
- package/dist/modern/utils/__mockdata__/deeply/nested/single/File.stories.js +0 -4
- package/dist/modern/utils/__mockdata__/preview.js +0 -1
- package/dist/modern/utils/__mockdata__/src/A.stories.js +0 -5
- package/dist/modern/utils/__mockdata__/src/B.stories.js +0 -5
- package/dist/modern/utils/__mockdata__/src/C.js +0 -1
- package/dist/modern/utils/__mockdata__/src/D.stories.js +0 -5
- package/dist/modern/utils/__mockdata__/src/NoMeta.stories.js +0 -4
- package/dist/modern/utils/__mockdata__/src/first-nested/deeply/F.stories.js +0 -5
- package/dist/modern/utils/__mockdata__/src/nested/Button.js +0 -1
- package/dist/modern/utils/__mockdata__/src/nested/Button.stories.js +0 -5
- package/dist/modern/utils/__mockdata__/src/second-nested/G.stories.js +0 -5
- package/dist/modern/utils/copy-all-static-files.js +0 -62
- package/dist/modern/utils/get-manager-builder.js +0 -26
- package/dist/modern/utils/get-preview-builder.js +0 -28
- package/dist/modern/utils/get-server-channel.js +0 -39
- package/dist/modern/utils/metadata.js +0 -14
- package/dist/modern/utils/middleware.js +0 -27
- package/dist/modern/utils/open-in-browser.js +0 -26
- package/dist/modern/utils/output-startup-information.js +0 -54
- package/dist/modern/utils/output-stats.js +0 -37
- package/dist/modern/utils/release-notes.js +0 -63
- package/dist/modern/utils/server-address.js +0 -20
- package/dist/modern/utils/server-init.js +0 -29
- package/dist/modern/utils/server-statics.js +0 -97
- package/dist/modern/utils/stories-json.js +0 -42
- package/dist/modern/utils/update-check.js +0 -65
- package/dist/modern/utils/watch-story-specifiers.js +0 -99
- package/dist/ts3.4/build-dev.d.ts +0 -3
- package/dist/ts3.4/build-static.d.ts +0 -3
- package/dist/ts3.4/cli/dev.d.ts +0 -6
- package/dist/ts3.4/cli/index.d.ts +0 -2
- package/dist/ts3.4/cli/prod.d.ts +0 -7
- package/dist/ts3.4/cli/utils.d.ts +0 -5
- package/dist/ts3.4/dev-server.d.ts +0 -24
- package/dist/ts3.4/index.d.ts +0 -4
- package/dist/ts3.4/presets/babel-cache-preset.d.ts +0 -2
- package/dist/ts3.4/standalone.d.ts +0 -2
- package/dist/ts3.4/utils/StoryIndexGenerator.d.ts +0 -27
- package/dist/ts3.4/utils/__mockdata__/E.stories.d.ts +0 -5
- package/dist/ts3.4/utils/__mockdata__/deeply/nested/single/File.stories.d.ts +0 -5
- package/dist/ts3.4/utils/__mockdata__/src/B.stories.d.ts +0 -5
- package/dist/ts3.4/utils/__mockdata__/src/NoMeta.stories.d.ts +0 -1
- package/dist/ts3.4/utils/__mockdata__/src/nested/Button.d.ts +0 -1
- package/dist/ts3.4/utils/__mockdata__/src/nested/Button.stories.d.ts +0 -5
- package/dist/ts3.4/utils/__mockdata__/src/second-nested/G.stories.d.ts +0 -5
- package/dist/ts3.4/utils/copy-all-static-files.d.ts +0 -2
- package/dist/ts3.4/utils/get-manager-builder.d.ts +0 -2
- package/dist/ts3.4/utils/get-preview-builder.d.ts +0 -2
- package/dist/ts3.4/utils/get-server-channel.d.ts +0 -9
- package/dist/ts3.4/utils/metadata.d.ts +0 -3
- package/dist/ts3.4/utils/middleware.d.ts +0 -1
- package/dist/ts3.4/utils/open-in-browser.d.ts +0 -1
- package/dist/ts3.4/utils/output-startup-information.d.ts +0 -16
- package/dist/ts3.4/utils/release-notes.d.ts +0 -8
- package/dist/ts3.4/utils/server-address.d.ts +0 -8
- package/dist/ts3.4/utils/server-init.d.ts +0 -10
- package/dist/ts3.4/utils/server-statics.d.ts +0 -8
- package/dist/ts3.4/utils/stories-json.d.ts +0 -13
- package/dist/ts3.4/utils/update-check.d.ts +0 -3
- package/dist/ts3.4/utils/watch-story-specifiers.d.ts +0 -5
- package/dist/ts3.9/build-dev.d.ts +0 -3
- package/dist/ts3.9/cli/dev.d.ts +0 -6
- package/dist/ts3.9/cli/index.d.ts +0 -2
- package/dist/ts3.9/cli/prod.d.ts +0 -7
- package/dist/ts3.9/cli/utils.d.ts +0 -5
- package/dist/ts3.9/presets/babel-cache-preset.d.ts +0 -2
- package/dist/ts3.9/presets/common-preset.d.ts +0 -31
- package/dist/ts3.9/utils/get-manager-builder.d.ts +0 -2
- package/dist/ts3.9/utils/get-preview-builder.d.ts +0 -2
- package/dist/ts3.9/utils/output-stats.d.ts +0 -3
package/dist/esm/cli/dev.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2
|
-
|
|
3
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
-
|
|
5
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
-
|
|
7
|
-
import "core-js/modules/es.promise.js";
|
|
8
|
-
import program from 'commander';
|
|
9
|
-
import chalk from 'chalk';
|
|
10
|
-
import { logger } from '@storybook/node-logger';
|
|
11
|
-
import { parseList, getEnvConfig, checkDeprecatedFlags } from './utils';
|
|
12
|
-
export async function getDevCli(packageJson) {
|
|
13
|
-
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
|
|
14
|
-
program.version(packageJson.version).option('-p, --port <number>', 'Port to run Storybook', function (str) {
|
|
15
|
-
return parseInt(str, 10);
|
|
16
|
-
}).option('-h, --host <string>', 'Host to run Storybook').option('-s, --static-dir <dir-names>', 'Directory where to load static files from', parseList).option('-c, --config-dir <dir-name>', 'Directory where to load Storybook configurations from').option('--https', 'Serve Storybook over HTTPS. Note: You must provide your own certificate information.').option('--ssl-ca <ca>', 'Provide an SSL certificate authority. (Optional with --https, required if using a self-signed certificate)', parseList).option('--ssl-cert <cert>', 'Provide an SSL certificate. (Required with --https)').option('--ssl-key <key>', 'Provide an SSL key. (Required with --https)').option('--smoke-test', 'Exit after successful start').option('--ci', "CI mode (skip interactive prompts, don't open browser)").option('--no-open', 'Do not open Storybook automatically in the browser').option('--loglevel <level>', 'Control level of logging during build').option('--quiet', 'Suppress verbose build output').option('--no-version-updates', 'Suppress update check', true).option('--disable-telemetry', 'Disable sending telemetry', // default value is false, but if the user sets STORYBOOK_DISABLE_TELEMETRY, it can be true
|
|
17
|
-
process.env.STORYBOOK_DISABLE_TELEMETRY && process.env.STORYBOOK_DISABLE_TELEMETRY !== 'false').option('--enable-crash-reports', 'enable sending crash reports to telemetry data').option('--no-release-notes', 'Suppress automatic redirects to the release notes after upgrading', true).option('--no-manager-cache', 'Do not cache the manager UI').option('--no-dll', 'Do not use dll references (no-op)').option('--docs-dll', 'Use Docs dll reference (legacy)').option('--ui-dll', 'Use UI dll reference (legacy)').option('--debug-webpack', 'Display final webpack configurations for debugging purposes').option('--webpack-stats-json [directory]', 'Write Webpack Stats JSON to disk').option('--preview-url <string>', 'Disables the default storybook preview and lets your use your own').option('--force-build-preview', 'Build the preview iframe even if you are using --preview-url').option('--docs', 'Build a documentation-only site using addon-docs').option('--modern', 'Use modern browser modules').parse(process.argv);
|
|
18
|
-
logger.setLevel(program.loglevel); // Workaround the `-h` shorthand conflict.
|
|
19
|
-
// Output the help if `-h` is called without any value.
|
|
20
|
-
// See storybookjs/storybook#5360
|
|
21
|
-
|
|
22
|
-
program.on('option:host', function (value) {
|
|
23
|
-
if (!value) {
|
|
24
|
-
program.help();
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
logger.info(chalk.bold(`${packageJson.name} v${packageJson.version}`) + chalk.reset('\n')); // The key is the field created in `program` variable for
|
|
28
|
-
// each command line argument. Value is the env variable.
|
|
29
|
-
|
|
30
|
-
getEnvConfig(program, {
|
|
31
|
-
port: 'SBCONFIG_PORT',
|
|
32
|
-
host: 'SBCONFIG_HOSTNAME',
|
|
33
|
-
staticDir: 'SBCONFIG_STATIC_DIR',
|
|
34
|
-
configDir: 'SBCONFIG_CONFIG_DIR',
|
|
35
|
-
ci: 'CI'
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
if (typeof program.port === 'string' && program.port.length > 0) {
|
|
39
|
-
program.port = parseInt(program.port, 10);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
checkDeprecatedFlags(program);
|
|
43
|
-
return _objectSpread({}, program);
|
|
44
|
-
}
|
package/dist/esm/cli/index.js
DELETED
package/dist/esm/cli/prod.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2
|
-
|
|
3
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
-
|
|
5
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
-
|
|
7
|
-
import program from 'commander';
|
|
8
|
-
import chalk from 'chalk';
|
|
9
|
-
import { logger } from '@storybook/node-logger';
|
|
10
|
-
import { parseList, getEnvConfig, checkDeprecatedFlags } from './utils';
|
|
11
|
-
export function getProdCli(packageJson) {
|
|
12
|
-
process.env.NODE_ENV = process.env.NODE_ENV || 'production';
|
|
13
|
-
program.version(packageJson.version).option('-s, --static-dir <dir-names>', 'Directory where to load static files from', parseList).option('-o, --output-dir <dir-name>', 'Directory where to store built files').option('-c, --config-dir <dir-name>', 'Directory where to load Storybook configurations from').option('--quiet', 'Suppress verbose build output').option('--loglevel <level>', 'Control level of logging during build').option('--no-dll', 'Do not use dll reference (no-op)').option('--docs-dll', 'Use Docs dll reference (legacy)').option('--ui-dll', 'Use UI dll reference (legacy)').option('--debug-webpack', 'Display final webpack configurations for debugging purposes').option('--webpack-stats-json [directory]', 'Write Webpack Stats JSON to disk').option('--preview-url <string>', 'Disables the default storybook preview and lets your use your own').option('--force-build-preview', 'Build the preview iframe even if you are using --preview-url').option('--docs', 'Build a documentation-only site using addon-docs').option('--modern', 'Use modern browser modules').option('--no-manager-cache', 'Do not cache the manager UI').option('--disable-telemetry', 'Disable sending telemetry', // default value is false, but if the user sets STORYBOOK_DISABLE_TELEMETRY, it can be true
|
|
14
|
-
process.env.STORYBOOK_DISABLE_TELEMETRY && process.env.STORYBOOK_DISABLE_TELEMETRY !== 'false').option('--enable-crash-reports', 'enable sending crash reports to telemetry data').parse(process.argv);
|
|
15
|
-
logger.setLevel(program.loglevel);
|
|
16
|
-
logger.info(chalk.bold(`${packageJson.name} v${packageJson.version}\n`)); // The key is the field created in `program` variable for
|
|
17
|
-
// each command line argument. Value is the env variable.
|
|
18
|
-
|
|
19
|
-
getEnvConfig(program, {
|
|
20
|
-
staticDir: 'SBCONFIG_STATIC_DIR',
|
|
21
|
-
outputDir: 'SBCONFIG_OUTPUT_DIR',
|
|
22
|
-
configDir: 'SBCONFIG_CONFIG_DIR'
|
|
23
|
-
});
|
|
24
|
-
checkDeprecatedFlags(program);
|
|
25
|
-
return _objectSpread({}, program);
|
|
26
|
-
}
|
package/dist/esm/cli/utils.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import deprecate from 'util-deprecate';
|
|
2
|
-
import dedent from 'ts-dedent';
|
|
3
|
-
export function parseList(str) {
|
|
4
|
-
return str.split(',').map(function (item) {
|
|
5
|
-
return item.trim();
|
|
6
|
-
}).filter(function (item) {
|
|
7
|
-
return item.length > 0;
|
|
8
|
-
});
|
|
9
|
-
}
|
|
10
|
-
export function getEnvConfig(program, configEnv) {
|
|
11
|
-
Object.keys(configEnv).forEach(function (fieldName) {
|
|
12
|
-
var envVarName = configEnv[fieldName];
|
|
13
|
-
var envVarValue = process.env[envVarName];
|
|
14
|
-
|
|
15
|
-
if (envVarValue) {
|
|
16
|
-
program[fieldName] = envVarValue; // eslint-disable-line
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
var warnDeprecatedFlag = function (message) {
|
|
22
|
-
return deprecate(function () {}, dedent(message));
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
var warnDLLsDeprecated = warnDeprecatedFlag(`
|
|
26
|
-
DLL-related CLI flags are deprecated, see:
|
|
27
|
-
|
|
28
|
-
https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#deprecated-dll-flags
|
|
29
|
-
`);
|
|
30
|
-
var warnStaticDirDeprecated = warnDeprecatedFlag(`
|
|
31
|
-
--static-dir CLI flag is deprecated, see:
|
|
32
|
-
|
|
33
|
-
https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#deprecated---static-dir-cli-flag
|
|
34
|
-
`);
|
|
35
|
-
export function checkDeprecatedFlags({
|
|
36
|
-
dll: dll,
|
|
37
|
-
uiDll: uiDll,
|
|
38
|
-
docsDll: docsDll,
|
|
39
|
-
staticDir: staticDir
|
|
40
|
-
}) {
|
|
41
|
-
if (!dll || uiDll || docsDll) {
|
|
42
|
-
warnDLLsDeprecated();
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if (staticDir) {
|
|
46
|
-
warnStaticDirDeprecated();
|
|
47
|
-
}
|
|
48
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import "core-js/modules/es.promise.js";
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import { getInterpretedFile, serverRequire } from '@storybook/core-common';
|
|
4
|
-
export async function getManagerBuilder(configDir) {
|
|
5
|
-
var _core$builder;
|
|
6
|
-
|
|
7
|
-
var main = path.resolve(configDir, 'main');
|
|
8
|
-
var mainFile = getInterpretedFile(main);
|
|
9
|
-
|
|
10
|
-
var _ref = mainFile ? serverRequire(mainFile) : {
|
|
11
|
-
core: null
|
|
12
|
-
},
|
|
13
|
-
core = _ref.core;
|
|
14
|
-
|
|
15
|
-
var builderName = typeof (core === null || core === void 0 ? void 0 : core.builder) === 'string' ? core.builder : core === null || core === void 0 ? void 0 : (_core$builder = core.builder) === null || _core$builder === void 0 ? void 0 : _core$builder.name; // Builder can be any string including community builders like `storybook-builder-vite`.
|
|
16
|
-
// - For now, `webpack5` triggers `manager-webpack5`
|
|
17
|
-
// - Everything else builds with `manager-webpack4`
|
|
18
|
-
//
|
|
19
|
-
// Unlike preview builders, manager building is not pluggable!
|
|
20
|
-
|
|
21
|
-
var builderPackage = ['webpack5', '@storybook/builder-webpack5'].includes(builderName) ? require.resolve('@storybook/manager-webpack5', {
|
|
22
|
-
paths: [main]
|
|
23
|
-
}) : '@storybook/manager-webpack4';
|
|
24
|
-
var managerBuilder = await import(builderPackage);
|
|
25
|
-
return managerBuilder;
|
|
26
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import "core-js/modules/es.promise.js";
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import { getInterpretedFile, serverRequire } from '@storybook/core-common';
|
|
4
|
-
export async function getPreviewBuilder(configDir) {
|
|
5
|
-
var main = path.resolve(configDir, 'main');
|
|
6
|
-
var mainFile = getInterpretedFile(main);
|
|
7
|
-
|
|
8
|
-
var _ref = mainFile ? serverRequire(mainFile) : {
|
|
9
|
-
core: null
|
|
10
|
-
},
|
|
11
|
-
core = _ref.core;
|
|
12
|
-
|
|
13
|
-
var builderPackage;
|
|
14
|
-
|
|
15
|
-
if (core !== null && core !== void 0 && core.builder) {
|
|
16
|
-
var _core$builder;
|
|
17
|
-
|
|
18
|
-
var builderName = typeof core.builder === 'string' ? core.builder : (_core$builder = core.builder) === null || _core$builder === void 0 ? void 0 : _core$builder.name;
|
|
19
|
-
builderPackage = require.resolve(['webpack4', 'webpack5'].includes(builderName) ? `@storybook/builder-${builderName}` : builderName, {
|
|
20
|
-
paths: [main]
|
|
21
|
-
});
|
|
22
|
-
} else {
|
|
23
|
-
builderPackage = require.resolve('@storybook/builder-webpack4');
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
var previewBuilder = await import(builderPackage);
|
|
27
|
-
return previewBuilder;
|
|
28
|
-
}
|
package/dist/modern/build-dev.js
DELETED
|
@@ -1,232 +0,0 @@
|
|
|
1
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2
|
-
|
|
3
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
-
|
|
5
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
-
|
|
7
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
8
|
-
|
|
9
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
10
|
-
|
|
11
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
12
|
-
|
|
13
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
14
|
-
|
|
15
|
-
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
16
|
-
|
|
17
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
18
|
-
|
|
19
|
-
import "core-js/modules/es.promise.js";
|
|
20
|
-
import "core-js/modules/es.symbol.description.js";
|
|
21
|
-
import { logger, instance as npmLog } from '@storybook/node-logger';
|
|
22
|
-
import prompts from 'prompts';
|
|
23
|
-
import { resolvePathInStorybookCache, loadAllPresets, cache } from '@storybook/core-common';
|
|
24
|
-
import { telemetry } from '@storybook/telemetry';
|
|
25
|
-
import dedent from 'ts-dedent';
|
|
26
|
-
import global from 'global';
|
|
27
|
-
import path from 'path';
|
|
28
|
-
import { storybookDevServer } from './dev-server';
|
|
29
|
-
import { getDevCli } from './cli';
|
|
30
|
-
import { getReleaseNotesData, getReleaseNotesFailedState } from './utils/release-notes';
|
|
31
|
-
import { outputStats } from './utils/output-stats';
|
|
32
|
-
import { outputStartupInformation } from './utils/output-startup-information';
|
|
33
|
-
import { updateCheck } from './utils/update-check';
|
|
34
|
-
import { getServerPort, getServerChannelUrl } from './utils/server-address';
|
|
35
|
-
import { getPreviewBuilder } from './utils/get-preview-builder';
|
|
36
|
-
import { getManagerBuilder } from './utils/get-manager-builder';
|
|
37
|
-
export async function buildDevStandalone(options) {
|
|
38
|
-
var packageJson = options.packageJson,
|
|
39
|
-
versionUpdates = options.versionUpdates,
|
|
40
|
-
releaseNotes = options.releaseNotes;
|
|
41
|
-
var version = packageJson.version,
|
|
42
|
-
_packageJson$name = packageJson.name,
|
|
43
|
-
name = _packageJson$name === void 0 ? '' : _packageJson$name; // updateInfo and releaseNotesData are cached, so this is typically pretty fast
|
|
44
|
-
|
|
45
|
-
var _await$Promise$all = await Promise.all([getServerPort(options.port), versionUpdates ? updateCheck(version) : Promise.resolve({
|
|
46
|
-
success: false,
|
|
47
|
-
data: {},
|
|
48
|
-
time: Date.now()
|
|
49
|
-
}), releaseNotes ? getReleaseNotesData(version, cache) : Promise.resolve(getReleaseNotesFailedState(version))]),
|
|
50
|
-
_await$Promise$all2 = _slicedToArray(_await$Promise$all, 3),
|
|
51
|
-
port = _await$Promise$all2[0],
|
|
52
|
-
versionCheck = _await$Promise$all2[1],
|
|
53
|
-
releaseNotesData = _await$Promise$all2[2];
|
|
54
|
-
|
|
55
|
-
if (!options.ci && !options.smokeTest && options.port != null && port !== options.port) {
|
|
56
|
-
var _await$prompts = await prompts({
|
|
57
|
-
type: 'confirm',
|
|
58
|
-
initial: true,
|
|
59
|
-
name: 'shouldChangePort',
|
|
60
|
-
message: `Port ${options.port} is not available. Would you like to run Storybook on port ${port} instead?`
|
|
61
|
-
}),
|
|
62
|
-
shouldChangePort = _await$prompts.shouldChangePort;
|
|
63
|
-
|
|
64
|
-
if (!shouldChangePort) process.exit(1);
|
|
65
|
-
}
|
|
66
|
-
/* eslint-disable no-param-reassign */
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
options.port = port;
|
|
70
|
-
options.versionCheck = versionCheck;
|
|
71
|
-
options.releaseNotesData = releaseNotesData;
|
|
72
|
-
options.configType = 'DEVELOPMENT';
|
|
73
|
-
options.configDir = path.resolve(options.configDir);
|
|
74
|
-
options.outputDir = options.smokeTest ? resolvePathInStorybookCache('public') : path.resolve(options.outputDir || resolvePathInStorybookCache('public'));
|
|
75
|
-
options.serverChannelUrl = getServerChannelUrl(port, options);
|
|
76
|
-
/* eslint-enable no-param-reassign */
|
|
77
|
-
|
|
78
|
-
var previewBuilder = await getPreviewBuilder(options.configDir);
|
|
79
|
-
var managerBuilder = await getManagerBuilder(options.configDir);
|
|
80
|
-
var presets = loadAllPresets(_objectSpread({
|
|
81
|
-
corePresets: [require.resolve('./presets/common-preset'), ...managerBuilder.corePresets, ...previewBuilder.corePresets, require.resolve('./presets/babel-cache-preset')],
|
|
82
|
-
overridePresets: previewBuilder.overridePresets
|
|
83
|
-
}, options));
|
|
84
|
-
var features = await presets.apply('features');
|
|
85
|
-
global.FEATURES = features;
|
|
86
|
-
|
|
87
|
-
var fullOptions = _objectSpread(_objectSpread({}, options), {}, {
|
|
88
|
-
presets: presets,
|
|
89
|
-
features: features
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
var _await$storybookDevSe = await storybookDevServer(fullOptions),
|
|
93
|
-
address = _await$storybookDevSe.address,
|
|
94
|
-
networkAddress = _await$storybookDevSe.networkAddress,
|
|
95
|
-
managerResult = _await$storybookDevSe.managerResult,
|
|
96
|
-
previewResult = _await$storybookDevSe.previewResult;
|
|
97
|
-
|
|
98
|
-
var previewTotalTime = previewResult && previewResult.totalTime;
|
|
99
|
-
var managerTotalTime = managerResult && managerResult.totalTime;
|
|
100
|
-
var previewStats = previewResult && previewResult.stats;
|
|
101
|
-
var managerStats = managerResult && managerResult.stats;
|
|
102
|
-
|
|
103
|
-
if (options.webpackStatsJson) {
|
|
104
|
-
var target = options.webpackStatsJson === true ? options.outputDir : options.webpackStatsJson;
|
|
105
|
-
await outputStats(target, previewStats, managerStats);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
if (options.smokeTest) {
|
|
109
|
-
// @ts-ignore
|
|
110
|
-
var managerWarnings = managerStats && managerStats.toJson().warnings || [];
|
|
111
|
-
if (managerWarnings.length > 0) logger.warn(`manager: ${JSON.stringify(managerWarnings, null, 2)}`); // I'm a little reticent to import webpack types in this file :shrug:
|
|
112
|
-
// @ts-ignore
|
|
113
|
-
|
|
114
|
-
var previewWarnings = previewStats && previewStats.toJson().warnings || [];
|
|
115
|
-
if (previewWarnings.length > 0) logger.warn(`preview: ${JSON.stringify(previewWarnings, null, 2)}`);
|
|
116
|
-
process.exit(managerWarnings.length > 0 || previewWarnings.length > 0 && !options.ignorePreview ? 1 : 0);
|
|
117
|
-
return;
|
|
118
|
-
} // Get package name and capitalize it e.g. @storybook/react -> React
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
var packageName = name.split('@storybook/').length > 1 ? name.split('@storybook/')[1] : name;
|
|
122
|
-
var frameworkName = packageName.charAt(0).toUpperCase() + packageName.slice(1);
|
|
123
|
-
outputStartupInformation({
|
|
124
|
-
updateInfo: versionCheck,
|
|
125
|
-
version: version,
|
|
126
|
-
name: frameworkName,
|
|
127
|
-
address: address,
|
|
128
|
-
networkAddress: networkAddress,
|
|
129
|
-
managerTotalTime: managerTotalTime,
|
|
130
|
-
previewTotalTime: previewTotalTime
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
export async function buildDev(loadOptions) {
|
|
134
|
-
var cliOptions = await getDevCli(loadOptions.packageJson);
|
|
135
|
-
|
|
136
|
-
var options = _objectSpread(_objectSpread(_objectSpread({}, cliOptions), loadOptions), {}, {
|
|
137
|
-
configDir: loadOptions.configDir || cliOptions.configDir || './.storybook',
|
|
138
|
-
configType: 'DEVELOPMENT',
|
|
139
|
-
ignorePreview: !!cliOptions.previewUrl && !cliOptions.forceBuildPreview,
|
|
140
|
-
docsMode: !!cliOptions.docs,
|
|
141
|
-
cache: cache
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
try {
|
|
145
|
-
await buildDevStandalone(options);
|
|
146
|
-
} catch (error) {
|
|
147
|
-
var _error$compilation;
|
|
148
|
-
|
|
149
|
-
// this is a weird bugfix, somehow 'node-pre-gyp' is polluting the npmLog header
|
|
150
|
-
npmLog.heading = '';
|
|
151
|
-
|
|
152
|
-
if (error instanceof Error) {
|
|
153
|
-
if (error.error) {
|
|
154
|
-
logger.error(error.error);
|
|
155
|
-
} else if (error.stats && error.stats.compilation.errors) {
|
|
156
|
-
error.stats.compilation.errors.forEach(function (e) {
|
|
157
|
-
return logger.plain(e);
|
|
158
|
-
});
|
|
159
|
-
} else {
|
|
160
|
-
logger.error(error);
|
|
161
|
-
}
|
|
162
|
-
} else if ((_error$compilation = error.compilation) !== null && _error$compilation !== void 0 && _error$compilation.errors) {
|
|
163
|
-
error.compilation.errors.forEach(function (e) {
|
|
164
|
-
return logger.plain(e);
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
logger.line();
|
|
169
|
-
logger.warn(error.close ? dedent`
|
|
170
|
-
FATAL broken build!, will close the process,
|
|
171
|
-
Fix the error below and restart storybook.
|
|
172
|
-
` : dedent`
|
|
173
|
-
Broken build, fix the error above.
|
|
174
|
-
You may need to refresh the browser.
|
|
175
|
-
`);
|
|
176
|
-
logger.line();
|
|
177
|
-
var presets = loadAllPresets(_objectSpread({
|
|
178
|
-
corePresets: [require.resolve('./presets/common-preset')],
|
|
179
|
-
overridePresets: []
|
|
180
|
-
}, options));
|
|
181
|
-
var core = await presets.apply('core');
|
|
182
|
-
|
|
183
|
-
if (!(core !== null && core !== void 0 && core.disableTelemetry)) {
|
|
184
|
-
var enableCrashReports;
|
|
185
|
-
|
|
186
|
-
if (core.enableCrashReports !== undefined) {
|
|
187
|
-
enableCrashReports = core.enableCrashReports;
|
|
188
|
-
} else {
|
|
189
|
-
var valueFromCache = await cache.get('enableCrashreports');
|
|
190
|
-
|
|
191
|
-
if (valueFromCache !== undefined) {
|
|
192
|
-
enableCrashReports = valueFromCache;
|
|
193
|
-
} else {
|
|
194
|
-
var valueFromPrompt = await promptCrashReports(options);
|
|
195
|
-
|
|
196
|
-
if (valueFromPrompt !== undefined) {
|
|
197
|
-
enableCrashReports = valueFromPrompt;
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
await telemetry('error-dev', {
|
|
203
|
-
error: error
|
|
204
|
-
}, {
|
|
205
|
-
immediate: true,
|
|
206
|
-
configDir: options.configDir,
|
|
207
|
-
enableCrashReports: enableCrashReports
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
process.exit(1);
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
var promptCrashReports = async function ({
|
|
216
|
-
packageJson: packageJson
|
|
217
|
-
}) {
|
|
218
|
-
if (process.env.CI) {
|
|
219
|
-
return undefined;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
var _await$prompts2 = await prompts({
|
|
223
|
-
type: 'confirm',
|
|
224
|
-
name: 'enableCrashReports',
|
|
225
|
-
message: `Would you like to send crash reports to Storybook?`,
|
|
226
|
-
initial: true
|
|
227
|
-
}),
|
|
228
|
-
enableCrashReports = _await$prompts2.enableCrashReports;
|
|
229
|
-
|
|
230
|
-
await cache.set('enableCrashreports', enableCrashReports);
|
|
231
|
-
return enableCrashReports;
|
|
232
|
-
};
|
|
@@ -1,237 +0,0 @@
|
|
|
1
|
-
import "core-js/modules/es.symbol.description.js";
|
|
2
|
-
var _excluded = ["packageJson"];
|
|
3
|
-
|
|
4
|
-
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
5
|
-
|
|
6
|
-
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
7
|
-
|
|
8
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
9
|
-
|
|
10
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
11
|
-
|
|
12
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
13
|
-
|
|
14
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
15
|
-
|
|
16
|
-
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
17
|
-
|
|
18
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
19
|
-
|
|
20
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
21
|
-
|
|
22
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
23
|
-
|
|
24
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
25
|
-
|
|
26
|
-
import "core-js/modules/es.promise.js";
|
|
27
|
-
import chalk from 'chalk';
|
|
28
|
-
import cpy from 'cpy';
|
|
29
|
-
import fs from 'fs-extra';
|
|
30
|
-
import path from 'path';
|
|
31
|
-
import dedent from 'ts-dedent';
|
|
32
|
-
import global from 'global';
|
|
33
|
-
import { logger } from '@storybook/node-logger';
|
|
34
|
-
import { telemetry } from '@storybook/telemetry';
|
|
35
|
-
import { normalizeStories, loadAllPresets, cache, logConfig } from '@storybook/core-common';
|
|
36
|
-
import { getProdCli } from './cli';
|
|
37
|
-
import { outputStats } from './utils/output-stats';
|
|
38
|
-
import { copyAllStaticFiles, copyAllStaticFilesRelativeToMain } from './utils/copy-all-static-files';
|
|
39
|
-
import { getPreviewBuilder } from './utils/get-preview-builder';
|
|
40
|
-
import { getManagerBuilder } from './utils/get-manager-builder';
|
|
41
|
-
import { extractStoriesJson } from './utils/stories-json';
|
|
42
|
-
import { extractStorybookMetadata } from './utils/metadata';
|
|
43
|
-
import { StoryIndexGenerator } from './utils/StoryIndexGenerator';
|
|
44
|
-
export async function buildStaticStandalone(options) {
|
|
45
|
-
var _options$staticDir, _core$builder;
|
|
46
|
-
|
|
47
|
-
/* eslint-disable no-param-reassign */
|
|
48
|
-
options.configType = 'PRODUCTION';
|
|
49
|
-
|
|
50
|
-
if (options.outputDir === '') {
|
|
51
|
-
throw new Error("Won't remove current directory. Check your outputDir!");
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
if ((_options$staticDir = options.staticDir) !== null && _options$staticDir !== void 0 && _options$staticDir.includes('/')) {
|
|
55
|
-
throw new Error("Won't copy root directory. Check your staticDirs!");
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
options.outputDir = path.isAbsolute(options.outputDir) ? options.outputDir : path.join(process.cwd(), options.outputDir);
|
|
59
|
-
options.configDir = path.resolve(options.configDir);
|
|
60
|
-
/* eslint-enable no-param-reassign */
|
|
61
|
-
|
|
62
|
-
var defaultFavIcon = require.resolve('@storybook/core-server/public/favicon.ico');
|
|
63
|
-
|
|
64
|
-
logger.info(chalk`=> Cleaning outputDir: {cyan ${options.outputDir}}`);
|
|
65
|
-
|
|
66
|
-
if (options.outputDir === '/') {
|
|
67
|
-
throw new Error("Won't remove directory '/'. Check your outputDir!");
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
await fs.emptyDir(options.outputDir);
|
|
71
|
-
await cpy(defaultFavIcon, options.outputDir);
|
|
72
|
-
var previewBuilder = await getPreviewBuilder(options.configDir);
|
|
73
|
-
var managerBuilder = await getManagerBuilder(options.configDir);
|
|
74
|
-
var presets = loadAllPresets(_objectSpread({
|
|
75
|
-
corePresets: [require.resolve('./presets/common-preset'), ...managerBuilder.corePresets, ...previewBuilder.corePresets, require.resolve('./presets/babel-cache-preset')],
|
|
76
|
-
overridePresets: previewBuilder.overridePresets
|
|
77
|
-
}, options));
|
|
78
|
-
var staticDirs = await presets.apply('staticDirs');
|
|
79
|
-
|
|
80
|
-
if (staticDirs && options.staticDir) {
|
|
81
|
-
throw new Error(dedent`
|
|
82
|
-
Conflict when trying to read staticDirs:
|
|
83
|
-
* Storybook's configuration option: 'staticDirs'
|
|
84
|
-
* Storybook's CLI flag: '--staticDir' or '-s'
|
|
85
|
-
|
|
86
|
-
Choose one of them, but not both.
|
|
87
|
-
`);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
if (staticDirs) {
|
|
91
|
-
await copyAllStaticFilesRelativeToMain(staticDirs, options.outputDir, options.configDir);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
if (options.staticDir) {
|
|
95
|
-
await copyAllStaticFiles(options.staticDir, options.outputDir);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
var features = await presets.apply('features');
|
|
99
|
-
global.FEATURES = features;
|
|
100
|
-
var extractTasks = [];
|
|
101
|
-
var initializedStoryIndexGenerator = Promise.resolve(undefined);
|
|
102
|
-
|
|
103
|
-
if (features !== null && features !== void 0 && features.buildStoriesJson || features !== null && features !== void 0 && features.storyStoreV7) {
|
|
104
|
-
var workingDir = process.cwd();
|
|
105
|
-
var directories = {
|
|
106
|
-
configDir: options.configDir,
|
|
107
|
-
workingDir: workingDir
|
|
108
|
-
};
|
|
109
|
-
var normalizedStories = normalizeStories(await presets.apply('stories'), directories);
|
|
110
|
-
var generator = new StoryIndexGenerator(normalizedStories, _objectSpread(_objectSpread({}, directories), {}, {
|
|
111
|
-
storiesV2Compatibility: !(features !== null && features !== void 0 && features.breakingChangesV7) && !(features !== null && features !== void 0 && features.storyStoreV7),
|
|
112
|
-
storyStoreV7: features === null || features === void 0 ? void 0 : features.storyStoreV7
|
|
113
|
-
}));
|
|
114
|
-
initializedStoryIndexGenerator = generator.initialize().then(function () {
|
|
115
|
-
return generator;
|
|
116
|
-
});
|
|
117
|
-
extractTasks.push(extractStoriesJson(path.join(options.outputDir, 'stories.json'), initializedStoryIndexGenerator));
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
var core = await presets.apply('core');
|
|
121
|
-
|
|
122
|
-
if (!(core !== null && core !== void 0 && core.disableTelemetry)) {
|
|
123
|
-
initializedStoryIndexGenerator.then(async function (generator) {
|
|
124
|
-
if (!generator) {
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
var storyIndex = await generator.getIndex();
|
|
129
|
-
var payload = storyIndex ? {
|
|
130
|
-
storyIndex: {
|
|
131
|
-
storyCount: Object.keys(storyIndex.stories).length,
|
|
132
|
-
version: storyIndex.v
|
|
133
|
-
}
|
|
134
|
-
} : undefined;
|
|
135
|
-
telemetry('build', payload, {
|
|
136
|
-
configDir: options.configDir
|
|
137
|
-
});
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
if (!(core !== null && core !== void 0 && core.disableProjectJson)) {
|
|
142
|
-
extractTasks.push(extractStorybookMetadata(path.join(options.outputDir, 'project.json'), options.configDir));
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
var fullOptions = _objectSpread(_objectSpread({}, options), {}, {
|
|
146
|
-
presets: presets,
|
|
147
|
-
features: features
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
if (options.debugWebpack) {
|
|
151
|
-
logConfig('Preview webpack config', await previewBuilder.getConfig(fullOptions));
|
|
152
|
-
logConfig('Manager webpack config', await managerBuilder.getConfig(fullOptions));
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
var builderName = typeof (core === null || core === void 0 ? void 0 : core.builder) === 'string' ? core.builder : core === null || core === void 0 ? void 0 : (_core$builder = core.builder) === null || _core$builder === void 0 ? void 0 : _core$builder.name;
|
|
156
|
-
|
|
157
|
-
var _ref = builderName === 'webpack5' ? // eslint-disable-next-line import/no-extraneous-dependencies
|
|
158
|
-
await import('@storybook/manager-webpack5/prebuilt-manager') : await import('@storybook/manager-webpack4/prebuilt-manager'),
|
|
159
|
-
getPrebuiltDir = _ref.getPrebuiltDir;
|
|
160
|
-
|
|
161
|
-
var prebuiltDir = await getPrebuiltDir(fullOptions);
|
|
162
|
-
var startTime = process.hrtime(); // When using the prebuilt manager, we straight up copy it into the outputDir instead of building it
|
|
163
|
-
|
|
164
|
-
var manager = prebuiltDir ? cpy('**', options.outputDir, {
|
|
165
|
-
cwd: prebuiltDir,
|
|
166
|
-
parents: true
|
|
167
|
-
}).then(function () {}) : managerBuilder.build({
|
|
168
|
-
startTime: startTime,
|
|
169
|
-
options: fullOptions
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
if (options.ignorePreview) {
|
|
173
|
-
logger.info(`=> Not building preview`);
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
var preview = options.ignorePreview ? Promise.resolve() : previewBuilder.build({
|
|
177
|
-
startTime: startTime,
|
|
178
|
-
options: fullOptions
|
|
179
|
-
});
|
|
180
|
-
|
|
181
|
-
var _await$Promise$all = await Promise.all([manager.catch(async function (err) {
|
|
182
|
-
await previewBuilder.bail();
|
|
183
|
-
throw err;
|
|
184
|
-
}), preview.catch(async function (err) {
|
|
185
|
-
await managerBuilder.bail();
|
|
186
|
-
throw err;
|
|
187
|
-
}), ...extractTasks]),
|
|
188
|
-
_await$Promise$all2 = _slicedToArray(_await$Promise$all, 2),
|
|
189
|
-
managerStats = _await$Promise$all2[0],
|
|
190
|
-
previewStats = _await$Promise$all2[1];
|
|
191
|
-
|
|
192
|
-
if (options.webpackStatsJson) {
|
|
193
|
-
var target = options.webpackStatsJson === true ? options.outputDir : options.webpackStatsJson;
|
|
194
|
-
await outputStats(target, previewStats, managerStats);
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
logger.info(`=> Output directory: ${options.outputDir}`);
|
|
198
|
-
}
|
|
199
|
-
export async function buildStatic(_ref2) {
|
|
200
|
-
var packageJson = _ref2.packageJson,
|
|
201
|
-
loadOptions = _objectWithoutProperties(_ref2, _excluded);
|
|
202
|
-
|
|
203
|
-
var cliOptions = getProdCli(packageJson);
|
|
204
|
-
|
|
205
|
-
var options = _objectSpread(_objectSpread(_objectSpread({}, cliOptions), loadOptions), {}, {
|
|
206
|
-
packageJson: packageJson,
|
|
207
|
-
configDir: loadOptions.configDir || cliOptions.configDir || './.storybook',
|
|
208
|
-
outputDir: loadOptions.outputDir || cliOptions.outputDir || './storybook-static',
|
|
209
|
-
ignorePreview: (!!loadOptions.ignorePreview || !!cliOptions.previewUrl) && !cliOptions.forceBuildPreview,
|
|
210
|
-
docsMode: !!cliOptions.docs,
|
|
211
|
-
configType: 'PRODUCTION',
|
|
212
|
-
cache: cache
|
|
213
|
-
});
|
|
214
|
-
|
|
215
|
-
try {
|
|
216
|
-
await buildStaticStandalone(options);
|
|
217
|
-
} catch (error) {
|
|
218
|
-
logger.error(error);
|
|
219
|
-
var presets = loadAllPresets(_objectSpread({
|
|
220
|
-
corePresets: [require.resolve('./presets/common-preset')],
|
|
221
|
-
overridePresets: []
|
|
222
|
-
}, options));
|
|
223
|
-
var core = await presets.apply('core');
|
|
224
|
-
|
|
225
|
-
if (!(core !== null && core !== void 0 && core.disableTelemetry)) {
|
|
226
|
-
await telemetry('error-build', {
|
|
227
|
-
error: error
|
|
228
|
-
}, {
|
|
229
|
-
immediate: true,
|
|
230
|
-
configDir: options.configDir,
|
|
231
|
-
enableCrashReports: options.enableCrashReports
|
|
232
|
-
});
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
process.exit(1);
|
|
236
|
-
}
|
|
237
|
-
}
|