@storybook/core-server 6.4.0-beta.26 → 6.4.0-beta.27
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/dist/cjs/build-static.js +22 -1
- package/dist/cjs/cli/utils.js +21 -3
- package/dist/cjs/utils/copy-all-static-files.js +33 -0
- package/dist/cjs/utils/server-statics.js +35 -4
- package/dist/esm/build-static.js +22 -2
- package/dist/esm/cli/utils.js +22 -3
- package/dist/esm/utils/copy-all-static-files.js +27 -0
- package/dist/esm/utils/server-statics.js +33 -4
- package/dist/modern/build-static.js +22 -2
- package/dist/modern/cli/utils.js +22 -3
- package/dist/modern/utils/copy-all-static-files.js +27 -0
- package/dist/modern/utils/server-statics.js +33 -4
- package/dist/ts3.4/cli/prod.d.ts +2 -15
- package/dist/ts3.4/cli/utils.d.ts +3 -5
- package/dist/ts3.4/utils/copy-all-static-files.d.ts +1 -0
- package/dist/ts3.4/utils/server-statics.d.ts +2 -3
- package/dist/ts3.9/cli/prod.d.ts +2 -15
- package/dist/ts3.9/cli/utils.d.ts +3 -5
- package/dist/ts3.9/utils/copy-all-static-files.d.ts +1 -0
- package/dist/ts3.9/utils/server-statics.d.ts +2 -3
- package/package.json +13 -13
package/dist/cjs/build-static.js
CHANGED
|
@@ -18,6 +18,8 @@ var _fsExtra = _interopRequireDefault(require("fs-extra"));
|
|
|
18
18
|
|
|
19
19
|
var _path = _interopRequireDefault(require("path"));
|
|
20
20
|
|
|
21
|
+
var _tsDedent = _interopRequireDefault(require("ts-dedent"));
|
|
22
|
+
|
|
21
23
|
var _nodeLogger = require("@storybook/node-logger");
|
|
22
24
|
|
|
23
25
|
var _coreCommon = require("@storybook/core-common");
|
|
@@ -90,13 +92,32 @@ async function buildStaticStandalone(options) {
|
|
|
90
92
|
|
|
91
93
|
await _fsExtra.default.emptyDir(options.outputDir);
|
|
92
94
|
await (0, _cpy.default)(defaultFavIcon, options.outputDir);
|
|
93
|
-
await (0, _copyAllStaticFiles.copyAllStaticFiles)(options.staticDir, options.outputDir);
|
|
94
95
|
var previewBuilder = await (0, _getPreviewBuilder.getPreviewBuilder)(options.configDir);
|
|
95
96
|
var managerBuilder = await (0, _getManagerBuilder.getManagerBuilder)(options.configDir);
|
|
96
97
|
var presets = (0, _coreCommon.loadAllPresets)(_objectSpread({
|
|
97
98
|
corePresets: [require.resolve('./presets/common-preset'), ...managerBuilder.corePresets, ...previewBuilder.corePresets, require.resolve('./presets/babel-cache-preset')],
|
|
98
99
|
overridePresets: previewBuilder.overridePresets
|
|
99
100
|
}, options));
|
|
101
|
+
var staticDirs = await presets.apply('staticDirs');
|
|
102
|
+
|
|
103
|
+
if (staticDirs && options.staticDir) {
|
|
104
|
+
throw new Error((0, _tsDedent.default)`
|
|
105
|
+
Conflict when trying to read staticDirs:
|
|
106
|
+
* Storybook's configuration option: 'staticDirs'
|
|
107
|
+
* Storybook's CLI flag: '--staticDir' or '-s'
|
|
108
|
+
|
|
109
|
+
Choose one of them, but not both.
|
|
110
|
+
`);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (staticDirs) {
|
|
114
|
+
await (0, _copyAllStaticFiles.copyAllStaticFilesRelativeToMain)(staticDirs, options.outputDir, options.configDir);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (options.staticDir) {
|
|
118
|
+
await (0, _copyAllStaticFiles.copyAllStaticFiles)(options.staticDir, options.outputDir);
|
|
119
|
+
}
|
|
120
|
+
|
|
100
121
|
var features = await presets.apply('features');
|
|
101
122
|
|
|
102
123
|
if (features !== null && features !== void 0 && features.buildStoriesJson || features !== null && features !== void 0 && features.storyStoreV7) {
|
package/dist/cjs/cli/utils.js
CHANGED
|
@@ -32,14 +32,32 @@ function getEnvConfig(program, configEnv) {
|
|
|
32
32
|
});
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
var
|
|
35
|
+
var warnDeprecatedFlag = function (message) {
|
|
36
|
+
return (0, _utilDeprecate.default)(function () {}, (0, _tsDedent.default)(message));
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
var warnDLLsDeprecated = warnDeprecatedFlag(`
|
|
36
40
|
DLL-related CLI flags are deprecated, see:
|
|
37
41
|
|
|
38
42
|
https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#deprecated-dll-flags
|
|
39
43
|
`);
|
|
44
|
+
var warnStaticDirDeprecated = warnDeprecatedFlag(`
|
|
45
|
+
--static-dir CLI flag is deprecated, see:
|
|
46
|
+
|
|
47
|
+
https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#deprecated-static-dir-flag
|
|
48
|
+
`);
|
|
40
49
|
|
|
41
|
-
function checkDeprecatedFlags(
|
|
42
|
-
|
|
50
|
+
function checkDeprecatedFlags({
|
|
51
|
+
dll: dll,
|
|
52
|
+
uiDll: uiDll,
|
|
53
|
+
docsDll: docsDll,
|
|
54
|
+
staticDir: staticDir
|
|
55
|
+
}) {
|
|
56
|
+
if (!dll || uiDll || docsDll) {
|
|
43
57
|
warnDLLsDeprecated();
|
|
44
58
|
}
|
|
59
|
+
|
|
60
|
+
if (staticDir) {
|
|
61
|
+
warnStaticDirDeprecated();
|
|
62
|
+
}
|
|
45
63
|
}
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.copyAllStaticFiles = copyAllStaticFiles;
|
|
7
|
+
exports.copyAllStaticFilesRelativeToMain = copyAllStaticFilesRelativeToMain;
|
|
7
8
|
|
|
8
9
|
require("core-js/modules/es.promise.js");
|
|
9
10
|
|
|
@@ -15,6 +16,8 @@ var _path = _interopRequireDefault(require("path"));
|
|
|
15
16
|
|
|
16
17
|
var _nodeLogger = require("@storybook/node-logger");
|
|
17
18
|
|
|
19
|
+
var _coreCommon = require("@storybook/core-common");
|
|
20
|
+
|
|
18
21
|
var _serverStatics = require("./server-statics");
|
|
19
22
|
|
|
20
23
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -50,4 +53,34 @@ async function copyAllStaticFiles(staticDirs, outputDir) {
|
|
|
50
53
|
}
|
|
51
54
|
}));
|
|
52
55
|
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
async function copyAllStaticFilesRelativeToMain(staticDirs, outputDir, configDir) {
|
|
59
|
+
staticDirs.forEach(async function (dir) {
|
|
60
|
+
var staticDirAndTarget = typeof dir === 'string' ? dir : `${dir.from}:${dir.to}`;
|
|
61
|
+
|
|
62
|
+
var _await$parseStaticDir2 = await (0, _serverStatics.parseStaticDir)((0, _coreCommon.getDirectoryFromWorkingDir)({
|
|
63
|
+
configDir: configDir,
|
|
64
|
+
workingDir: process.cwd(),
|
|
65
|
+
directory: staticDirAndTarget
|
|
66
|
+
})),
|
|
67
|
+
from = _await$parseStaticDir2.staticPath,
|
|
68
|
+
to = _await$parseStaticDir2.targetEndpoint;
|
|
69
|
+
|
|
70
|
+
var targetPath = _path.default.join(outputDir, to);
|
|
71
|
+
|
|
72
|
+
var skipPaths = ['index.html', 'iframe.html'].map(function (f) {
|
|
73
|
+
return _path.default.join(targetPath, f);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
_nodeLogger.logger.info((0, _chalk.default)`=> Copying static files: {cyan ${from}} at {cyan ${targetPath}}`);
|
|
77
|
+
|
|
78
|
+
await _fsExtra.default.copy(from, targetPath, {
|
|
79
|
+
dereference: true,
|
|
80
|
+
preserveTimestamps: true,
|
|
81
|
+
filter: function (_, dest) {
|
|
82
|
+
return !skipPaths.includes(dest);
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
});
|
|
53
86
|
}
|
|
@@ -12,6 +12,8 @@ require("core-js/modules/es.promise.js");
|
|
|
12
12
|
|
|
13
13
|
var _nodeLogger = require("@storybook/node-logger");
|
|
14
14
|
|
|
15
|
+
var _coreCommon = require("@storybook/core-common");
|
|
16
|
+
|
|
15
17
|
var _chalk = _interopRequireDefault(require("chalk"));
|
|
16
18
|
|
|
17
19
|
var _express = _interopRequireDefault(require("express"));
|
|
@@ -42,14 +44,43 @@ var defaultFavIcon = require.resolve('../public/favicon.ico');
|
|
|
42
44
|
|
|
43
45
|
async function useStatics(router, options) {
|
|
44
46
|
var hasCustomFavicon = false;
|
|
47
|
+
var staticDirs = await options.presets.apply('staticDirs', []);
|
|
48
|
+
|
|
49
|
+
if (staticDirs && options.staticDir) {
|
|
50
|
+
throw new Error((0, _tsDedent.default)`
|
|
51
|
+
Conflict when trying to read staticDirs:
|
|
52
|
+
* Storybook's configuration option: 'staticDirs'
|
|
53
|
+
* Storybook's CLI flag: '--staticDir' or '-s'
|
|
54
|
+
|
|
55
|
+
Choose one of them, but not both.
|
|
56
|
+
`);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
staticDirs.forEach(async function (dir) {
|
|
60
|
+
var staticDirAndTarget = typeof dir === 'string' ? dir : `${dir.from}:${dir.to}`;
|
|
61
|
+
|
|
62
|
+
var _await$parseStaticDir = await parseStaticDir((0, _coreCommon.getDirectoryFromWorkingDir)({
|
|
63
|
+
configDir: options.configDir,
|
|
64
|
+
workingDir: process.cwd(),
|
|
65
|
+
directory: staticDirAndTarget
|
|
66
|
+
})),
|
|
67
|
+
from = _await$parseStaticDir.staticPath,
|
|
68
|
+
to = _await$parseStaticDir.targetEndpoint;
|
|
69
|
+
|
|
70
|
+
_nodeLogger.logger.info((0, _chalk.default)`=> Serving static files from {cyan ${from}} at {cyan ${to}}`);
|
|
71
|
+
|
|
72
|
+
router.use(to, _express.default.static(from, {
|
|
73
|
+
index: false
|
|
74
|
+
}));
|
|
75
|
+
});
|
|
45
76
|
|
|
46
77
|
if (options.staticDir && options.staticDir.length > 0) {
|
|
47
78
|
await Promise.all(options.staticDir.map(async function (dir) {
|
|
48
79
|
try {
|
|
49
|
-
var _await$
|
|
50
|
-
staticDir = _await$
|
|
51
|
-
staticPath = _await$
|
|
52
|
-
targetEndpoint = _await$
|
|
80
|
+
var _await$parseStaticDir2 = await parseStaticDir(dir),
|
|
81
|
+
staticDir = _await$parseStaticDir2.staticDir,
|
|
82
|
+
staticPath = _await$parseStaticDir2.staticPath,
|
|
83
|
+
targetEndpoint = _await$parseStaticDir2.targetEndpoint;
|
|
53
84
|
|
|
54
85
|
_nodeLogger.logger.info((0, _chalk.default)`=> Serving static files from {cyan ${staticDir}} at {cyan ${targetEndpoint}}`);
|
|
55
86
|
|
package/dist/esm/build-static.js
CHANGED
|
@@ -26,11 +26,12 @@ import chalk from 'chalk';
|
|
|
26
26
|
import cpy from 'cpy';
|
|
27
27
|
import fs from 'fs-extra';
|
|
28
28
|
import path from 'path';
|
|
29
|
+
import dedent from 'ts-dedent';
|
|
29
30
|
import { logger } from '@storybook/node-logger';
|
|
30
31
|
import { loadAllPresets, cache, normalizeStories, logConfig } from '@storybook/core-common';
|
|
31
32
|
import { getProdCli } from './cli';
|
|
32
33
|
import { outputStats } from './utils/output-stats';
|
|
33
|
-
import { copyAllStaticFiles } from './utils/copy-all-static-files';
|
|
34
|
+
import { copyAllStaticFiles, copyAllStaticFilesRelativeToMain } from './utils/copy-all-static-files';
|
|
34
35
|
import { getPreviewBuilder } from './utils/get-preview-builder';
|
|
35
36
|
import { getManagerBuilder } from './utils/get-manager-builder';
|
|
36
37
|
import { extractStoriesJson } from './utils/stories-json';
|
|
@@ -62,13 +63,32 @@ export async function buildStaticStandalone(options) {
|
|
|
62
63
|
|
|
63
64
|
await fs.emptyDir(options.outputDir);
|
|
64
65
|
await cpy(defaultFavIcon, options.outputDir);
|
|
65
|
-
await copyAllStaticFiles(options.staticDir, options.outputDir);
|
|
66
66
|
var previewBuilder = await getPreviewBuilder(options.configDir);
|
|
67
67
|
var managerBuilder = await getManagerBuilder(options.configDir);
|
|
68
68
|
var presets = loadAllPresets(_objectSpread({
|
|
69
69
|
corePresets: [require.resolve('./presets/common-preset'), ...managerBuilder.corePresets, ...previewBuilder.corePresets, require.resolve('./presets/babel-cache-preset')],
|
|
70
70
|
overridePresets: previewBuilder.overridePresets
|
|
71
71
|
}, options));
|
|
72
|
+
var staticDirs = await presets.apply('staticDirs');
|
|
73
|
+
|
|
74
|
+
if (staticDirs && options.staticDir) {
|
|
75
|
+
throw new Error(dedent`
|
|
76
|
+
Conflict when trying to read staticDirs:
|
|
77
|
+
* Storybook's configuration option: 'staticDirs'
|
|
78
|
+
* Storybook's CLI flag: '--staticDir' or '-s'
|
|
79
|
+
|
|
80
|
+
Choose one of them, but not both.
|
|
81
|
+
`);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (staticDirs) {
|
|
85
|
+
await copyAllStaticFilesRelativeToMain(staticDirs, options.outputDir, options.configDir);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (options.staticDir) {
|
|
89
|
+
await copyAllStaticFiles(options.staticDir, options.outputDir);
|
|
90
|
+
}
|
|
91
|
+
|
|
72
92
|
var features = await presets.apply('features');
|
|
73
93
|
|
|
74
94
|
if (features !== null && features !== void 0 && features.buildStoriesJson || features !== null && features !== void 0 && features.storyStoreV7) {
|
package/dist/esm/cli/utils.js
CHANGED
|
@@ -17,13 +17,32 @@ export function getEnvConfig(program, configEnv) {
|
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
|
-
|
|
20
|
+
|
|
21
|
+
var warnDeprecatedFlag = function (message) {
|
|
22
|
+
return deprecate(function () {}, dedent(message));
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
var warnDLLsDeprecated = warnDeprecatedFlag(`
|
|
21
26
|
DLL-related CLI flags are deprecated, see:
|
|
22
27
|
|
|
23
28
|
https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#deprecated-dll-flags
|
|
24
29
|
`);
|
|
25
|
-
|
|
26
|
-
|
|
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-flag
|
|
34
|
+
`);
|
|
35
|
+
export function checkDeprecatedFlags({
|
|
36
|
+
dll: dll,
|
|
37
|
+
uiDll: uiDll,
|
|
38
|
+
docsDll: docsDll,
|
|
39
|
+
staticDir: staticDir
|
|
40
|
+
}) {
|
|
41
|
+
if (!dll || uiDll || docsDll) {
|
|
27
42
|
warnDLLsDeprecated();
|
|
28
43
|
}
|
|
44
|
+
|
|
45
|
+
if (staticDir) {
|
|
46
|
+
warnStaticDirDeprecated();
|
|
47
|
+
}
|
|
29
48
|
}
|
|
@@ -3,6 +3,7 @@ import chalk from 'chalk';
|
|
|
3
3
|
import fs from 'fs-extra';
|
|
4
4
|
import path from 'path';
|
|
5
5
|
import { logger } from '@storybook/node-logger';
|
|
6
|
+
import { getDirectoryFromWorkingDir } from '@storybook/core-common';
|
|
6
7
|
import { parseStaticDir } from './server-statics';
|
|
7
8
|
export async function copyAllStaticFiles(staticDirs, outputDir) {
|
|
8
9
|
if (staticDirs && staticDirs.length > 0) {
|
|
@@ -32,4 +33,30 @@ export async function copyAllStaticFiles(staticDirs, outputDir) {
|
|
|
32
33
|
}
|
|
33
34
|
}));
|
|
34
35
|
}
|
|
36
|
+
}
|
|
37
|
+
export async function copyAllStaticFilesRelativeToMain(staticDirs, outputDir, configDir) {
|
|
38
|
+
staticDirs.forEach(async function (dir) {
|
|
39
|
+
var staticDirAndTarget = typeof dir === 'string' ? dir : `${dir.from}:${dir.to}`;
|
|
40
|
+
|
|
41
|
+
var _await$parseStaticDir2 = await parseStaticDir(getDirectoryFromWorkingDir({
|
|
42
|
+
configDir: configDir,
|
|
43
|
+
workingDir: process.cwd(),
|
|
44
|
+
directory: staticDirAndTarget
|
|
45
|
+
})),
|
|
46
|
+
from = _await$parseStaticDir2.staticPath,
|
|
47
|
+
to = _await$parseStaticDir2.targetEndpoint;
|
|
48
|
+
|
|
49
|
+
var targetPath = path.join(outputDir, to);
|
|
50
|
+
var skipPaths = ['index.html', 'iframe.html'].map(function (f) {
|
|
51
|
+
return path.join(targetPath, f);
|
|
52
|
+
});
|
|
53
|
+
logger.info(chalk`=> Copying static files: {cyan ${from}} at {cyan ${targetPath}}`);
|
|
54
|
+
await fs.copy(from, targetPath, {
|
|
55
|
+
dereference: true,
|
|
56
|
+
preserveTimestamps: true,
|
|
57
|
+
filter: function (_, dest) {
|
|
58
|
+
return !skipPaths.includes(dest);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
});
|
|
35
62
|
}
|
|
@@ -13,6 +13,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
13
13
|
import "core-js/modules/es.promise.js";
|
|
14
14
|
import "core-js/modules/es.symbol.description.js";
|
|
15
15
|
import { logger } from '@storybook/node-logger';
|
|
16
|
+
import { getDirectoryFromWorkingDir } from '@storybook/core-common';
|
|
16
17
|
import chalk from 'chalk';
|
|
17
18
|
import express from 'express';
|
|
18
19
|
import { pathExists } from 'fs-extra';
|
|
@@ -24,14 +25,42 @@ var defaultFavIcon = require.resolve('../public/favicon.ico');
|
|
|
24
25
|
|
|
25
26
|
export async function useStatics(router, options) {
|
|
26
27
|
var hasCustomFavicon = false;
|
|
28
|
+
var staticDirs = await options.presets.apply('staticDirs', []);
|
|
29
|
+
|
|
30
|
+
if (staticDirs && options.staticDir) {
|
|
31
|
+
throw new Error(dedent`
|
|
32
|
+
Conflict when trying to read staticDirs:
|
|
33
|
+
* Storybook's configuration option: 'staticDirs'
|
|
34
|
+
* Storybook's CLI flag: '--staticDir' or '-s'
|
|
35
|
+
|
|
36
|
+
Choose one of them, but not both.
|
|
37
|
+
`);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
staticDirs.forEach(async function (dir) {
|
|
41
|
+
var staticDirAndTarget = typeof dir === 'string' ? dir : `${dir.from}:${dir.to}`;
|
|
42
|
+
|
|
43
|
+
var _await$parseStaticDir = await parseStaticDir(getDirectoryFromWorkingDir({
|
|
44
|
+
configDir: options.configDir,
|
|
45
|
+
workingDir: process.cwd(),
|
|
46
|
+
directory: staticDirAndTarget
|
|
47
|
+
})),
|
|
48
|
+
from = _await$parseStaticDir.staticPath,
|
|
49
|
+
to = _await$parseStaticDir.targetEndpoint;
|
|
50
|
+
|
|
51
|
+
logger.info(chalk`=> Serving static files from {cyan ${from}} at {cyan ${to}}`);
|
|
52
|
+
router.use(to, express.static(from, {
|
|
53
|
+
index: false
|
|
54
|
+
}));
|
|
55
|
+
});
|
|
27
56
|
|
|
28
57
|
if (options.staticDir && options.staticDir.length > 0) {
|
|
29
58
|
await Promise.all(options.staticDir.map(async function (dir) {
|
|
30
59
|
try {
|
|
31
|
-
var _await$
|
|
32
|
-
staticDir = _await$
|
|
33
|
-
staticPath = _await$
|
|
34
|
-
targetEndpoint = _await$
|
|
60
|
+
var _await$parseStaticDir2 = await parseStaticDir(dir),
|
|
61
|
+
staticDir = _await$parseStaticDir2.staticDir,
|
|
62
|
+
staticPath = _await$parseStaticDir2.staticPath,
|
|
63
|
+
targetEndpoint = _await$parseStaticDir2.targetEndpoint;
|
|
35
64
|
|
|
36
65
|
logger.info(chalk`=> Serving static files from {cyan ${staticDir}} at {cyan ${targetEndpoint}}`);
|
|
37
66
|
router.use(targetEndpoint, express.static(staticPath, {
|
|
@@ -26,11 +26,12 @@ import chalk from 'chalk';
|
|
|
26
26
|
import cpy from 'cpy';
|
|
27
27
|
import fs from 'fs-extra';
|
|
28
28
|
import path from 'path';
|
|
29
|
+
import dedent from 'ts-dedent';
|
|
29
30
|
import { logger } from '@storybook/node-logger';
|
|
30
31
|
import { loadAllPresets, cache, normalizeStories, logConfig } from '@storybook/core-common';
|
|
31
32
|
import { getProdCli } from './cli';
|
|
32
33
|
import { outputStats } from './utils/output-stats';
|
|
33
|
-
import { copyAllStaticFiles } from './utils/copy-all-static-files';
|
|
34
|
+
import { copyAllStaticFiles, copyAllStaticFilesRelativeToMain } from './utils/copy-all-static-files';
|
|
34
35
|
import { getPreviewBuilder } from './utils/get-preview-builder';
|
|
35
36
|
import { getManagerBuilder } from './utils/get-manager-builder';
|
|
36
37
|
import { extractStoriesJson } from './utils/stories-json';
|
|
@@ -62,13 +63,32 @@ export async function buildStaticStandalone(options) {
|
|
|
62
63
|
|
|
63
64
|
await fs.emptyDir(options.outputDir);
|
|
64
65
|
await cpy(defaultFavIcon, options.outputDir);
|
|
65
|
-
await copyAllStaticFiles(options.staticDir, options.outputDir);
|
|
66
66
|
var previewBuilder = await getPreviewBuilder(options.configDir);
|
|
67
67
|
var managerBuilder = await getManagerBuilder(options.configDir);
|
|
68
68
|
var presets = loadAllPresets(_objectSpread({
|
|
69
69
|
corePresets: [require.resolve('./presets/common-preset'), ...managerBuilder.corePresets, ...previewBuilder.corePresets, require.resolve('./presets/babel-cache-preset')],
|
|
70
70
|
overridePresets: previewBuilder.overridePresets
|
|
71
71
|
}, options));
|
|
72
|
+
var staticDirs = await presets.apply('staticDirs');
|
|
73
|
+
|
|
74
|
+
if (staticDirs && options.staticDir) {
|
|
75
|
+
throw new Error(dedent`
|
|
76
|
+
Conflict when trying to read staticDirs:
|
|
77
|
+
* Storybook's configuration option: 'staticDirs'
|
|
78
|
+
* Storybook's CLI flag: '--staticDir' or '-s'
|
|
79
|
+
|
|
80
|
+
Choose one of them, but not both.
|
|
81
|
+
`);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (staticDirs) {
|
|
85
|
+
await copyAllStaticFilesRelativeToMain(staticDirs, options.outputDir, options.configDir);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (options.staticDir) {
|
|
89
|
+
await copyAllStaticFiles(options.staticDir, options.outputDir);
|
|
90
|
+
}
|
|
91
|
+
|
|
72
92
|
var features = await presets.apply('features');
|
|
73
93
|
|
|
74
94
|
if (features !== null && features !== void 0 && features.buildStoriesJson || features !== null && features !== void 0 && features.storyStoreV7) {
|
package/dist/modern/cli/utils.js
CHANGED
|
@@ -17,13 +17,32 @@ export function getEnvConfig(program, configEnv) {
|
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
|
-
|
|
20
|
+
|
|
21
|
+
var warnDeprecatedFlag = function (message) {
|
|
22
|
+
return deprecate(function () {}, dedent(message));
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
var warnDLLsDeprecated = warnDeprecatedFlag(`
|
|
21
26
|
DLL-related CLI flags are deprecated, see:
|
|
22
27
|
|
|
23
28
|
https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#deprecated-dll-flags
|
|
24
29
|
`);
|
|
25
|
-
|
|
26
|
-
|
|
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-flag
|
|
34
|
+
`);
|
|
35
|
+
export function checkDeprecatedFlags({
|
|
36
|
+
dll: dll,
|
|
37
|
+
uiDll: uiDll,
|
|
38
|
+
docsDll: docsDll,
|
|
39
|
+
staticDir: staticDir
|
|
40
|
+
}) {
|
|
41
|
+
if (!dll || uiDll || docsDll) {
|
|
27
42
|
warnDLLsDeprecated();
|
|
28
43
|
}
|
|
44
|
+
|
|
45
|
+
if (staticDir) {
|
|
46
|
+
warnStaticDirDeprecated();
|
|
47
|
+
}
|
|
29
48
|
}
|
|
@@ -3,6 +3,7 @@ import chalk from 'chalk';
|
|
|
3
3
|
import fs from 'fs-extra';
|
|
4
4
|
import path from 'path';
|
|
5
5
|
import { logger } from '@storybook/node-logger';
|
|
6
|
+
import { getDirectoryFromWorkingDir } from '@storybook/core-common';
|
|
6
7
|
import { parseStaticDir } from './server-statics';
|
|
7
8
|
export async function copyAllStaticFiles(staticDirs, outputDir) {
|
|
8
9
|
if (staticDirs && staticDirs.length > 0) {
|
|
@@ -32,4 +33,30 @@ export async function copyAllStaticFiles(staticDirs, outputDir) {
|
|
|
32
33
|
}
|
|
33
34
|
}));
|
|
34
35
|
}
|
|
36
|
+
}
|
|
37
|
+
export async function copyAllStaticFilesRelativeToMain(staticDirs, outputDir, configDir) {
|
|
38
|
+
staticDirs.forEach(async function (dir) {
|
|
39
|
+
var staticDirAndTarget = typeof dir === 'string' ? dir : `${dir.from}:${dir.to}`;
|
|
40
|
+
|
|
41
|
+
var _await$parseStaticDir2 = await parseStaticDir(getDirectoryFromWorkingDir({
|
|
42
|
+
configDir: configDir,
|
|
43
|
+
workingDir: process.cwd(),
|
|
44
|
+
directory: staticDirAndTarget
|
|
45
|
+
})),
|
|
46
|
+
from = _await$parseStaticDir2.staticPath,
|
|
47
|
+
to = _await$parseStaticDir2.targetEndpoint;
|
|
48
|
+
|
|
49
|
+
var targetPath = path.join(outputDir, to);
|
|
50
|
+
var skipPaths = ['index.html', 'iframe.html'].map(function (f) {
|
|
51
|
+
return path.join(targetPath, f);
|
|
52
|
+
});
|
|
53
|
+
logger.info(chalk`=> Copying static files: {cyan ${from}} at {cyan ${targetPath}}`);
|
|
54
|
+
await fs.copy(from, targetPath, {
|
|
55
|
+
dereference: true,
|
|
56
|
+
preserveTimestamps: true,
|
|
57
|
+
filter: function (_, dest) {
|
|
58
|
+
return !skipPaths.includes(dest);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
});
|
|
35
62
|
}
|
|
@@ -13,6 +13,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
13
13
|
import "core-js/modules/es.promise.js";
|
|
14
14
|
import "core-js/modules/es.symbol.description.js";
|
|
15
15
|
import { logger } from '@storybook/node-logger';
|
|
16
|
+
import { getDirectoryFromWorkingDir } from '@storybook/core-common';
|
|
16
17
|
import chalk from 'chalk';
|
|
17
18
|
import express from 'express';
|
|
18
19
|
import { pathExists } from 'fs-extra';
|
|
@@ -24,14 +25,42 @@ var defaultFavIcon = require.resolve('../public/favicon.ico');
|
|
|
24
25
|
|
|
25
26
|
export async function useStatics(router, options) {
|
|
26
27
|
var hasCustomFavicon = false;
|
|
28
|
+
var staticDirs = await options.presets.apply('staticDirs', []);
|
|
29
|
+
|
|
30
|
+
if (staticDirs && options.staticDir) {
|
|
31
|
+
throw new Error(dedent`
|
|
32
|
+
Conflict when trying to read staticDirs:
|
|
33
|
+
* Storybook's configuration option: 'staticDirs'
|
|
34
|
+
* Storybook's CLI flag: '--staticDir' or '-s'
|
|
35
|
+
|
|
36
|
+
Choose one of them, but not both.
|
|
37
|
+
`);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
staticDirs.forEach(async function (dir) {
|
|
41
|
+
var staticDirAndTarget = typeof dir === 'string' ? dir : `${dir.from}:${dir.to}`;
|
|
42
|
+
|
|
43
|
+
var _await$parseStaticDir = await parseStaticDir(getDirectoryFromWorkingDir({
|
|
44
|
+
configDir: options.configDir,
|
|
45
|
+
workingDir: process.cwd(),
|
|
46
|
+
directory: staticDirAndTarget
|
|
47
|
+
})),
|
|
48
|
+
from = _await$parseStaticDir.staticPath,
|
|
49
|
+
to = _await$parseStaticDir.targetEndpoint;
|
|
50
|
+
|
|
51
|
+
logger.info(chalk`=> Serving static files from {cyan ${from}} at {cyan ${to}}`);
|
|
52
|
+
router.use(to, express.static(from, {
|
|
53
|
+
index: false
|
|
54
|
+
}));
|
|
55
|
+
});
|
|
27
56
|
|
|
28
57
|
if (options.staticDir && options.staticDir.length > 0) {
|
|
29
58
|
await Promise.all(options.staticDir.map(async function (dir) {
|
|
30
59
|
try {
|
|
31
|
-
var _await$
|
|
32
|
-
staticDir = _await$
|
|
33
|
-
staticPath = _await$
|
|
34
|
-
targetEndpoint = _await$
|
|
60
|
+
var _await$parseStaticDir2 = await parseStaticDir(dir),
|
|
61
|
+
staticDir = _await$parseStaticDir2.staticDir,
|
|
62
|
+
staticPath = _await$parseStaticDir2.staticPath,
|
|
63
|
+
targetEndpoint = _await$parseStaticDir2.targetEndpoint;
|
|
35
64
|
|
|
36
65
|
logger.info(chalk`=> Serving static files from {cyan ${staticDir}} at {cyan ${targetEndpoint}}`);
|
|
37
66
|
router.use(targetEndpoint, express.static(staticPath, {
|
package/dist/ts3.4/cli/prod.d.ts
CHANGED
|
@@ -1,19 +1,6 @@
|
|
|
1
1
|
import { CommanderStatic } from 'commander';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
outputDir?: string;
|
|
5
|
-
configDir?: string;
|
|
6
|
-
quiet?: boolean;
|
|
7
|
-
loglevel?: string;
|
|
8
|
-
dll?: boolean;
|
|
9
|
-
docsDll?: boolean;
|
|
10
|
-
uiDll?: boolean;
|
|
11
|
-
debugWebpack?: boolean;
|
|
12
|
-
previewUrl?: string;
|
|
13
|
-
forceBuildPreview?: boolean;
|
|
14
|
-
docs?: boolean;
|
|
15
|
-
modern?: boolean;
|
|
16
|
-
}
|
|
2
|
+
import { CLIOptions } from '@storybook/core-common';
|
|
3
|
+
export declare type ProdCliOptions = Pick<CLIOptions, 'configDir' | 'debugWebpack' | 'dll' | 'docs' | 'docsDll' | 'forceBuildPreview' | 'loglevel' | 'modern' | 'outputDir' | 'previewUrl' | 'quiet' | 'staticDir' | 'uiDll'>;
|
|
17
4
|
export declare function getProdCli(packageJson: {
|
|
18
5
|
version: string;
|
|
19
6
|
name: string;
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
+
import { CLIOptions } from '@storybook/core-common';
|
|
2
|
+
import { ProdCliOptions } from './prod';
|
|
1
3
|
export declare function parseList(str: string): string[];
|
|
2
4
|
export declare function getEnvConfig(program: Record<string, any>, configEnv: Record<string, any>): void;
|
|
3
|
-
export declare function checkDeprecatedFlags(
|
|
4
|
-
dll?: boolean;
|
|
5
|
-
uiDll?: boolean;
|
|
6
|
-
docsDll?: boolean;
|
|
7
|
-
}): void;
|
|
5
|
+
export declare function checkDeprecatedFlags({ dll, uiDll, docsDll, staticDir, }: CLIOptions | ProdCliOptions): void;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
}): Promise<void>;
|
|
1
|
+
import { Options } from '@storybook/core-common';
|
|
2
|
+
export declare function useStatics(router: any, options: Options): Promise<void>;
|
|
4
3
|
export declare const parseStaticDir: (arg: string) => Promise<{
|
|
5
4
|
staticDir: string;
|
|
6
5
|
staticPath: string;
|
package/dist/ts3.9/cli/prod.d.ts
CHANGED
|
@@ -1,19 +1,6 @@
|
|
|
1
1
|
import { CommanderStatic } from 'commander';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
outputDir?: string;
|
|
5
|
-
configDir?: string;
|
|
6
|
-
quiet?: boolean;
|
|
7
|
-
loglevel?: string;
|
|
8
|
-
dll?: boolean;
|
|
9
|
-
docsDll?: boolean;
|
|
10
|
-
uiDll?: boolean;
|
|
11
|
-
debugWebpack?: boolean;
|
|
12
|
-
previewUrl?: string;
|
|
13
|
-
forceBuildPreview?: boolean;
|
|
14
|
-
docs?: boolean;
|
|
15
|
-
modern?: boolean;
|
|
16
|
-
}
|
|
2
|
+
import type { CLIOptions } from '@storybook/core-common';
|
|
3
|
+
export declare type ProdCliOptions = Pick<CLIOptions, 'configDir' | 'debugWebpack' | 'dll' | 'docs' | 'docsDll' | 'forceBuildPreview' | 'loglevel' | 'modern' | 'outputDir' | 'previewUrl' | 'quiet' | 'staticDir' | 'uiDll'>;
|
|
17
4
|
export declare function getProdCli(packageJson: {
|
|
18
5
|
version: string;
|
|
19
6
|
name: string;
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
+
import type { CLIOptions } from '@storybook/core-common';
|
|
2
|
+
import type { ProdCliOptions } from './prod';
|
|
1
3
|
export declare function parseList(str: string): string[];
|
|
2
4
|
export declare function getEnvConfig(program: Record<string, any>, configEnv: Record<string, any>): void;
|
|
3
|
-
export declare function checkDeprecatedFlags(
|
|
4
|
-
dll?: boolean;
|
|
5
|
-
uiDll?: boolean;
|
|
6
|
-
docsDll?: boolean;
|
|
7
|
-
}): void;
|
|
5
|
+
export declare function checkDeprecatedFlags({ dll, uiDll, docsDll, staticDir, }: CLIOptions | ProdCliOptions): void;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
}): Promise<void>;
|
|
1
|
+
import type { Options } from '@storybook/core-common';
|
|
2
|
+
export declare function useStatics(router: any, options: Options): Promise<void>;
|
|
4
3
|
export declare const parseStaticDir: (arg: string) => Promise<{
|
|
5
4
|
staticDir: string;
|
|
6
5
|
staticPath: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/core-server",
|
|
3
|
-
"version": "6.4.0-beta.
|
|
3
|
+
"version": "6.4.0-beta.27",
|
|
4
4
|
"description": "Storybook framework-agnostic API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook"
|
|
@@ -41,16 +41,16 @@
|
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@discoveryjs/json-ext": "^0.5.3",
|
|
44
|
-
"@storybook/builder-webpack4": "6.4.0-beta.
|
|
45
|
-
"@storybook/core-client": "6.4.0-beta.
|
|
46
|
-
"@storybook/core-common": "6.4.0-beta.
|
|
47
|
-
"@storybook/core-events": "6.4.0-beta.
|
|
44
|
+
"@storybook/builder-webpack4": "6.4.0-beta.27",
|
|
45
|
+
"@storybook/core-client": "6.4.0-beta.27",
|
|
46
|
+
"@storybook/core-common": "6.4.0-beta.27",
|
|
47
|
+
"@storybook/core-events": "6.4.0-beta.27",
|
|
48
48
|
"@storybook/csf": "0.0.2--canary.87bc651.0",
|
|
49
|
-
"@storybook/csf-tools": "6.4.0-beta.
|
|
50
|
-
"@storybook/manager-webpack4": "6.4.0-beta.
|
|
51
|
-
"@storybook/node-logger": "6.4.0-beta.
|
|
49
|
+
"@storybook/csf-tools": "6.4.0-beta.27",
|
|
50
|
+
"@storybook/manager-webpack4": "6.4.0-beta.27",
|
|
51
|
+
"@storybook/node-logger": "6.4.0-beta.27",
|
|
52
52
|
"@storybook/semver": "^7.3.2",
|
|
53
|
-
"@storybook/store": "6.4.0-beta.
|
|
53
|
+
"@storybook/store": "6.4.0-beta.27",
|
|
54
54
|
"@types/node": "^14.0.10",
|
|
55
55
|
"@types/node-fetch": "^2.5.7",
|
|
56
56
|
"@types/pretty-hrtime": "^1.0.0",
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
"ws": "^8.2.3"
|
|
85
85
|
},
|
|
86
86
|
"devDependencies": {
|
|
87
|
-
"@storybook/builder-webpack5": "6.4.0-beta.
|
|
87
|
+
"@storybook/builder-webpack5": "6.4.0-beta.27",
|
|
88
88
|
"@types/compression": "^1.7.0",
|
|
89
89
|
"@types/ip": "^1.1.0",
|
|
90
90
|
"@types/serve-favicon": "^2.5.2",
|
|
@@ -92,8 +92,8 @@
|
|
|
92
92
|
"jest-specific-snapshot": "^4.0.0"
|
|
93
93
|
},
|
|
94
94
|
"peerDependencies": {
|
|
95
|
-
"@storybook/builder-webpack5": "6.4.0-beta.
|
|
96
|
-
"@storybook/manager-webpack5": "6.4.0-beta.
|
|
95
|
+
"@storybook/builder-webpack5": "6.4.0-beta.27",
|
|
96
|
+
"@storybook/manager-webpack5": "6.4.0-beta.27",
|
|
97
97
|
"react": "^16.8.0 || ^17.0.0",
|
|
98
98
|
"react-dom": "^16.8.0 || ^17.0.0"
|
|
99
99
|
},
|
|
@@ -111,6 +111,6 @@
|
|
|
111
111
|
"publishConfig": {
|
|
112
112
|
"access": "public"
|
|
113
113
|
},
|
|
114
|
-
"gitHead": "
|
|
114
|
+
"gitHead": "b73d9e79cf41328a21eb5f8c1490f450abaf4142",
|
|
115
115
|
"sbmodern": "dist/modern/index.js"
|
|
116
116
|
}
|