storybook 10.1.0-beta.3 → 10.1.0-beta.4
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/_node-chunks/{builder-manager-OAF6SRKJ.js → builder-manager-T3A7QLUO.js} +24 -26
- package/dist/_node-chunks/{camelcase-UG5ZJHCD.js → camelcase-WMMYRUH4.js} +7 -7
- package/dist/_node-chunks/{chunk-WBULWRM7.js → chunk-3MVB5IZX.js} +28 -24
- package/dist/_node-chunks/{chunk-N5IE6WWR.js → chunk-5DEFF2GB.js} +7 -7
- package/dist/_node-chunks/{chunk-JOOO54RB.js → chunk-67VVNDJJ.js} +6 -6
- package/dist/_node-chunks/{chunk-SUILKNPA.js → chunk-C6RLDV2P.js} +8 -8
- package/dist/_node-chunks/{chunk-473LXK7O.js → chunk-CM44JL5Z.js} +6 -6
- package/dist/_node-chunks/{chunk-XS5QCZP7.js → chunk-CSFSQ2I4.js} +7 -7
- package/dist/_node-chunks/{chunk-H6HVK5J2.js → chunk-EFN4RLWH.js} +7 -7
- package/dist/_node-chunks/{chunk-WYLXFNIP.js → chunk-EFTR6VSG.js} +9 -9
- package/dist/_node-chunks/{chunk-SKFAHEPX.js → chunk-EJPOXNSG.js} +15 -15
- package/dist/_node-chunks/{chunk-7WOMK33B.js → chunk-HDMHX5QM.js} +7 -7
- package/dist/_node-chunks/{chunk-U24W5IIW.js → chunk-HT32VUX7.js} +7 -7
- package/dist/_node-chunks/chunk-IQFN7VY4.js +23 -0
- package/dist/_node-chunks/{chunk-RABBUYPA.js → chunk-JYAXWHGH.js} +9 -9
- package/dist/_node-chunks/chunk-K7U3BSTR.js +61 -0
- package/dist/_node-chunks/{chunk-CRJ7M6EO.js → chunk-KAVR7KJP.js} +285 -280
- package/dist/_node-chunks/{chunk-6YYH64IJ.js → chunk-KI6KY2ZN.js} +13 -13
- package/dist/_node-chunks/{chunk-Y7VDA7NY.js → chunk-NORFPLB6.js} +7 -7
- package/dist/_node-chunks/{chunk-LZ2HPFRB.js → chunk-PMZEJJNX.js} +7 -7
- package/dist/_node-chunks/{chunk-NOTIBODG.js → chunk-RSJK2D7X.js} +6 -6
- package/dist/_node-chunks/{chunk-UWK6Z4VL.js → chunk-TBYOSPAV.js} +6 -6
- package/dist/_node-chunks/{chunk-STYUJSG3.js → chunk-TC7X5DN2.js} +10 -10
- package/dist/_node-chunks/{chunk-TUQOGYET.js → chunk-TCLOOFNE.js} +7 -7
- package/dist/_node-chunks/{chunk-WSIZMTN2.js → chunk-VN7SAKM4.js} +6 -6
- package/dist/_node-chunks/{chunk-745GFLCZ.js → chunk-VW25O2YM.js} +6 -6
- package/dist/_node-chunks/{chunk-A5VW7257.js → chunk-WGBDDI6W.js} +642 -639
- package/dist/_node-chunks/chunk-YN3C74EA.js +18 -0
- package/dist/_node-chunks/{chunk-NKT3R6IH.js → chunk-YTTOTUWC.js} +6 -6
- package/dist/_node-chunks/{chunk-Q65ED3UK.js → chunk-YZ3XRP4N.js} +6 -6
- package/dist/_node-chunks/{dist-N33YQ3NH.js → dist-L6XLFQOU.js} +9 -9
- package/dist/_node-chunks/{globby-5IBS67N3.js → globby-7IXLXFEA.js} +9 -9
- package/dist/_node-chunks/{lib-2XH6KQ2B.js → lib-T5L2ZSAG.js} +7 -7
- package/dist/_node-chunks/{mdx-N42X6CFJ-3GGSRLVV.js → mdx-N42X6CFJ-GOOKUTSA.js} +8 -8
- package/dist/_node-chunks/{p-limit-Z3A7N5MY.js → p-limit-7GKATDEW.js} +7 -7
- package/dist/babel/index.js +10 -10
- package/dist/bin/core.js +12 -12
- package/dist/bin/dispatcher.js +11 -11
- package/dist/bin/loader.js +9 -9
- package/dist/cli/index.d.ts +1 -2
- package/dist/cli/index.js +18 -18
- package/dist/common/index.d.ts +553 -560
- package/dist/common/index.js +19 -21
- package/dist/core-server/index.js +33 -33
- package/dist/core-server/presets/common-override-preset.js +9 -9
- package/dist/core-server/presets/common-preset.js +25 -25
- package/dist/csf-tools/index.js +9 -9
- package/dist/manager/globals-runtime.js +1 -1
- package/dist/manager/runtime.js +70 -96
- package/dist/manager-api/index.d.ts +178 -178
- package/dist/manager-api/index.js +1 -1
- package/dist/mocking-utils/index.js +8 -8
- package/dist/node-logger/index.d.ts +3 -1
- package/dist/node-logger/index.js +9 -9
- package/dist/server-errors.js +11 -11
- package/dist/telemetry/index.js +23 -23
- package/dist/types/index.d.ts +1 -1
- package/package.json +2 -2
- package/dist/_node-chunks/chunk-5N3H43LE.js +0 -23
- package/dist/_node-chunks/chunk-DRN5YXX5.js +0 -18
- package/dist/_node-chunks/chunk-LJRIVT23.js +0 -61
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_a6gceaz3qeh from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_a6gceaz3qeh from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_a6gceaz3qeh from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_a6gceaz3qeh.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_a6gceaz3qeh.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_a6gceaz3qeh.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
11
|
// ------------------------------------------------------------
|
|
12
12
|
import {
|
|
13
13
|
versions_default
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-K7U3BSTR.js";
|
|
15
15
|
import {
|
|
16
16
|
require_picomatch
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-HT32VUX7.js";
|
|
18
18
|
import {
|
|
19
19
|
logger
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-WGBDDI6W.js";
|
|
21
21
|
import {
|
|
22
22
|
any,
|
|
23
23
|
from,
|
|
24
24
|
invariant,
|
|
25
25
|
up,
|
|
26
26
|
up2
|
|
27
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-YTTOTUWC.js";
|
|
28
28
|
import {
|
|
29
29
|
importModule,
|
|
30
30
|
resolveModulePath,
|
|
31
31
|
resolvePackageDir,
|
|
32
32
|
safeResolveModule
|
|
33
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-NORFPLB6.js";
|
|
34
34
|
import {
|
|
35
35
|
join,
|
|
36
36
|
parse,
|
|
37
37
|
resolve
|
|
38
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-TBYOSPAV.js";
|
|
39
39
|
import {
|
|
40
40
|
glob,
|
|
41
41
|
globSync
|
|
42
|
-
} from "./chunk-
|
|
42
|
+
} from "./chunk-CSFSQ2I4.js";
|
|
43
43
|
import {
|
|
44
44
|
slash
|
|
45
|
-
} from "./chunk-
|
|
45
|
+
} from "./chunk-YZ3XRP4N.js";
|
|
46
46
|
import {
|
|
47
47
|
require_dist
|
|
48
|
-
} from "./chunk-
|
|
48
|
+
} from "./chunk-HDMHX5QM.js";
|
|
49
49
|
import {
|
|
50
50
|
require_picocolors
|
|
51
|
-
} from "./chunk-
|
|
51
|
+
} from "./chunk-TCLOOFNE.js";
|
|
52
52
|
import {
|
|
53
53
|
__commonJS,
|
|
54
54
|
__esm,
|
|
@@ -56,7 +56,7 @@ import {
|
|
|
56
56
|
__require,
|
|
57
57
|
__toCommonJS,
|
|
58
58
|
__toESM
|
|
59
|
-
} from "./chunk-
|
|
59
|
+
} from "./chunk-VW25O2YM.js";
|
|
60
60
|
|
|
61
61
|
// ../node_modules/resolve/lib/homedir.js
|
|
62
62
|
var require_homedir = __commonJS({
|
|
@@ -10300,9 +10300,9 @@ var cache2 = createFileSystemCache({
|
|
|
10300
10300
|
|
|
10301
10301
|
// src/common/utils/cli.ts
|
|
10302
10302
|
import { createWriteStream, mkdirSync as mkdirSync3 } from "node:fs";
|
|
10303
|
-
import { copyFile, readFile as
|
|
10303
|
+
import { copyFile, readFile as readFile2, realpath, rm as rm2, writeFile as writeFile2 } from "node:fs/promises";
|
|
10304
10304
|
import os from "node:os";
|
|
10305
|
-
import { join as
|
|
10305
|
+
import { join as join5 } from "node:path";
|
|
10306
10306
|
|
|
10307
10307
|
// ../node_modules/crypto-random-string/index.js
|
|
10308
10308
|
import { promisify } from "util";
|
|
@@ -10391,30 +10391,67 @@ var satellite_addons_default = [
|
|
|
10391
10391
|
"@storybook/react-native"
|
|
10392
10392
|
];
|
|
10393
10393
|
|
|
10394
|
-
// src/common/utils/
|
|
10395
|
-
|
|
10396
|
-
|
|
10397
|
-
|
|
10398
|
-
|
|
10399
|
-
|
|
10400
|
-
|
|
10401
|
-
|
|
10402
|
-
|
|
10403
|
-
|
|
10404
|
-
|
|
10405
|
-
|
|
10394
|
+
// src/common/utils/cli.ts
|
|
10395
|
+
var tempDir = () => realpath(os.tmpdir()), getPath = async (prefix = "") => join5(await tempDir(), prefix + uniqueString());
|
|
10396
|
+
async function temporaryDirectory({ prefix = "" } = {}) {
|
|
10397
|
+
let directory = await getPath(prefix);
|
|
10398
|
+
return mkdirSync3(directory), directory;
|
|
10399
|
+
}
|
|
10400
|
+
async function temporaryFile({ name, extension } = {}) {
|
|
10401
|
+
if (name) {
|
|
10402
|
+
if (extension != null)
|
|
10403
|
+
throw new Error("The `name` and `extension` options are mutually exclusive");
|
|
10404
|
+
return join5(await temporaryDirectory(), name);
|
|
10405
|
+
}
|
|
10406
|
+
return await getPath() + (extension == null ? "" : "." + extension.replace(/^\./, ""));
|
|
10407
|
+
}
|
|
10408
|
+
function parseList(str) {
|
|
10409
|
+
return str.split(",").map((item) => item.trim()).filter((item) => item.length > 0);
|
|
10410
|
+
}
|
|
10411
|
+
function getEnvConfig(program, configEnv) {
|
|
10412
|
+
Object.keys(configEnv).forEach((fieldName) => {
|
|
10413
|
+
let envVarName = configEnv[fieldName], envVarValue = process.env[envVarName];
|
|
10414
|
+
envVarValue && (program[fieldName] = envVarValue);
|
|
10415
|
+
});
|
|
10416
|
+
}
|
|
10417
|
+
var createLogStream = async (logFileName = "storybook.log") => {
|
|
10418
|
+
let finalLogPath = join5(process.cwd(), logFileName), temporaryLogPath = await temporaryFile({ name: logFileName }), logStream = createWriteStream(temporaryLogPath, { encoding: "utf8" });
|
|
10419
|
+
return new Promise((resolve11, reject) => {
|
|
10420
|
+
logStream.once("open", () => {
|
|
10421
|
+
let clearLogFile = async () => writeFile2(temporaryLogPath, ""), removeLogFile = async () => rm2(temporaryLogPath, { recursive: !0, force: !0 });
|
|
10422
|
+
resolve11({ logStream, moveLogFile: async () => copyFile(temporaryLogPath, finalLogPath).then(removeLogFile), clearLogFile, removeLogFile, readLogFile: async () => readFile2(temporaryLogPath, { encoding: "utf8" }) });
|
|
10423
|
+
}), logStream.once("error", reject);
|
|
10424
|
+
});
|
|
10425
|
+
}, isCorePackage = (pkg) => !!versions_default[pkg], isSatelliteAddon = (pkg) => satellite_addons_default.includes(pkg);
|
|
10406
10426
|
|
|
10407
|
-
// src/common/utils/
|
|
10408
|
-
|
|
10409
|
-
|
|
10410
|
-
|
|
10411
|
-
|
|
10412
|
-
|
|
10427
|
+
// src/common/utils/check-addon-order.ts
|
|
10428
|
+
import { logger as logger3 } from "storybook/internal/node-logger";
|
|
10429
|
+
var predicateFor = (addon) => (entry) => {
|
|
10430
|
+
let name = entry.name || entry;
|
|
10431
|
+
return name && name.replaceAll(/(\\){1,2}/g, "/").includes(addon);
|
|
10432
|
+
}, isCorrectOrder = (addons, before, after) => {
|
|
10433
|
+
let essentialsIndex = addons.findIndex(predicateFor("@storybook/addon-essentials")), beforeIndex = addons.findIndex(predicateFor(before.name)), afterIndex = addons.findIndex(predicateFor(after.name));
|
|
10434
|
+
return beforeIndex === -1 && before.inEssentials && (beforeIndex = essentialsIndex), afterIndex === -1 && after.inEssentials && (afterIndex = essentialsIndex), beforeIndex !== -1 && afterIndex !== -1 && beforeIndex <= afterIndex;
|
|
10435
|
+
}, checkAddonOrder = async ({ before, after, configFile, getConfig }) => {
|
|
10436
|
+
try {
|
|
10437
|
+
let config = await getConfig(configFile);
|
|
10438
|
+
if (!config?.addons) {
|
|
10439
|
+
logger3.warn("Unable to find 'addons' config in main Storybook config");
|
|
10440
|
+
return;
|
|
10441
|
+
}
|
|
10442
|
+
if (!isCorrectOrder(config.addons, before, after)) {
|
|
10443
|
+
let orEssentials = " (or '@storybook/addon-essentials')", beforeText = `'${before.name}'${before.inEssentials ? orEssentials : ""}`, afterText = `'${after.name}'${after.inEssentials ? orEssentials : ""}`;
|
|
10444
|
+
logger3.warn(
|
|
10445
|
+
`Expected ${beforeText} to be listed before ${afterText} in main Storybook config.`
|
|
10446
|
+
);
|
|
10447
|
+
}
|
|
10448
|
+
} catch {
|
|
10449
|
+
logger3.warn(`Unable to load config file: ${configFile}`);
|
|
10413
10450
|
}
|
|
10414
10451
|
};
|
|
10415
10452
|
|
|
10416
10453
|
// src/common/utils/paths.ts
|
|
10417
|
-
import { join as
|
|
10454
|
+
import { join as join6, relative as relative2, resolve as resolve5, sep as sep3 } from "node:path";
|
|
10418
10455
|
|
|
10419
10456
|
// ../node_modules/tinyglobby/dist/index.mjs
|
|
10420
10457
|
import nativeFs2 from "fs";
|
|
@@ -11010,7 +11047,7 @@ var projectRoot, getProjectRoot = () => {
|
|
|
11010
11047
|
try {
|
|
11011
11048
|
let found = up2(".git") || up2(".svn") || up2(".hg");
|
|
11012
11049
|
if (found)
|
|
11013
|
-
return projectRoot =
|
|
11050
|
+
return projectRoot = join6(found, ".."), projectRoot;
|
|
11014
11051
|
} catch (e) {
|
|
11015
11052
|
process.stdout.write(`
|
|
11016
11053
|
error searching for repository root: ${e}
|
|
@@ -11019,7 +11056,7 @@ error searching for repository root: ${e}
|
|
|
11019
11056
|
try {
|
|
11020
11057
|
let found = any(LOCK_FILES);
|
|
11021
11058
|
if (found)
|
|
11022
|
-
return projectRoot =
|
|
11059
|
+
return projectRoot = join6(found, ".."), projectRoot;
|
|
11023
11060
|
} catch (e) {
|
|
11024
11061
|
process.stdout.write(`
|
|
11025
11062
|
error searching for lock file: ${e}
|
|
@@ -11047,6 +11084,135 @@ function normalizeStoryPath(filename) {
|
|
|
11047
11084
|
return relativePattern.test(filename) ? filename : `.${sep3}${filename}`;
|
|
11048
11085
|
}
|
|
11049
11086
|
|
|
11087
|
+
// src/common/utils/envs.ts
|
|
11088
|
+
async function loadEnvs(options = {}) {
|
|
11089
|
+
let { getEnvironment } = await import("./lib-T5L2ZSAG.js"), defaultNodeEnv = options.production ? "production" : "development", env2 = {
|
|
11090
|
+
// eslint-disable-next-line @typescript-eslint/dot-notation
|
|
11091
|
+
NODE_ENV: process.env.NODE_ENV || defaultNodeEnv,
|
|
11092
|
+
NODE_PATH: process.env.NODE_PATH || "",
|
|
11093
|
+
STORYBOOK: process.env.STORYBOOK || "true",
|
|
11094
|
+
// This is to support CRA's public folder feature.
|
|
11095
|
+
// In production we set this to dot(.) to allow the browser to access these assets
|
|
11096
|
+
// even when deployed inside a subpath. (like in GitHub pages)
|
|
11097
|
+
// In development this is just empty as we always serves from the root.
|
|
11098
|
+
PUBLIC_URL: options.production ? "." : ""
|
|
11099
|
+
};
|
|
11100
|
+
Object.keys(process.env).filter((name) => /^STORYBOOK_/.test(name)).forEach((name) => {
|
|
11101
|
+
env2[name] = process.env[name];
|
|
11102
|
+
});
|
|
11103
|
+
let base = Object.entries(env2).reduce(
|
|
11104
|
+
(acc, [k, v]) => Object.assign(acc, { [k]: JSON.stringify(v) }),
|
|
11105
|
+
{}
|
|
11106
|
+
), { stringified, raw } = getEnvironment({ nodeEnv: env2.NODE_ENV }), fullRaw = { ...env2, ...raw };
|
|
11107
|
+
return fullRaw.NODE_PATH = nodePathsToArray(fullRaw.NODE_PATH || ""), {
|
|
11108
|
+
stringified: { ...base, ...stringified },
|
|
11109
|
+
raw: fullRaw
|
|
11110
|
+
};
|
|
11111
|
+
}
|
|
11112
|
+
var stringifyEnvs = (raw) => Object.entries(raw).reduce((acc, [key, value]) => (acc[key] = JSON.stringify(value), acc), {}), stringifyProcessEnvs = (raw) => Object.entries(raw).reduce((acc, [key, value]) => (acc[`process.env.${key}`] = JSON.stringify(value), acc), {}), optionalEnvToBoolean = (input) => {
|
|
11113
|
+
if (input !== void 0)
|
|
11114
|
+
return input.toUpperCase() === "FALSE" || input === "0" ? !1 : input.toUpperCase() === "TRUE" || input === "1" ? !0 : !!input;
|
|
11115
|
+
};
|
|
11116
|
+
function isCI() {
|
|
11117
|
+
return optionalEnvToBoolean(process.env.CI);
|
|
11118
|
+
}
|
|
11119
|
+
|
|
11120
|
+
// src/common/utils/common-glob-options.ts
|
|
11121
|
+
var NODE_MODULES_RE = /node_modules/, commonGlobOptions = (glob2) => NODE_MODULES_RE.test(glob2) ? {} : { ignore: ["**/node_modules/**"] };
|
|
11122
|
+
|
|
11123
|
+
// src/common/utils/framework.ts
|
|
11124
|
+
import { SupportedBuilder, SupportedFramework, SupportedRenderer } from "storybook/internal/types";
|
|
11125
|
+
var frameworkToRenderer = {
|
|
11126
|
+
// frameworks
|
|
11127
|
+
[SupportedFramework.ANGULAR]: SupportedRenderer.ANGULAR,
|
|
11128
|
+
[SupportedFramework.EMBER]: SupportedRenderer.EMBER,
|
|
11129
|
+
[SupportedFramework.HTML_VITE]: SupportedRenderer.HTML,
|
|
11130
|
+
[SupportedFramework.NEXTJS]: SupportedRenderer.REACT,
|
|
11131
|
+
[SupportedFramework.NEXTJS_VITE]: SupportedRenderer.REACT,
|
|
11132
|
+
[SupportedFramework.PREACT_VITE]: SupportedRenderer.PREACT,
|
|
11133
|
+
[SupportedFramework.QWIK]: SupportedRenderer.QWIK,
|
|
11134
|
+
[SupportedFramework.REACT_VITE]: SupportedRenderer.REACT,
|
|
11135
|
+
[SupportedFramework.REACT_WEBPACK5]: SupportedRenderer.REACT,
|
|
11136
|
+
[SupportedFramework.SERVER_WEBPACK5]: SupportedRenderer.SERVER,
|
|
11137
|
+
[SupportedFramework.SOLID]: SupportedRenderer.SOLID,
|
|
11138
|
+
[SupportedFramework.SVELTE_VITE]: SupportedRenderer.SVELTE,
|
|
11139
|
+
[SupportedFramework.SVELTEKIT]: SupportedRenderer.SVELTE,
|
|
11140
|
+
[SupportedFramework.VUE3_VITE]: SupportedRenderer.VUE3,
|
|
11141
|
+
[SupportedFramework.WEB_COMPONENTS_VITE]: SupportedRenderer.WEB_COMPONENTS,
|
|
11142
|
+
[SupportedFramework.REACT_RSBUILD]: SupportedRenderer.REACT,
|
|
11143
|
+
[SupportedFramework.VUE3_RSBUILD]: SupportedRenderer.VUE3,
|
|
11144
|
+
[SupportedFramework.HTML_RSBUILD]: SupportedRenderer.HTML,
|
|
11145
|
+
[SupportedFramework.WEB_COMPONENTS_RSBUILD]: SupportedRenderer.WEB_COMPONENTS,
|
|
11146
|
+
[SupportedFramework.REACT_NATIVE_WEB_VITE]: SupportedRenderer.REACT,
|
|
11147
|
+
[SupportedFramework.NUXT]: SupportedRenderer.VUE3,
|
|
11148
|
+
// renderers
|
|
11149
|
+
[SupportedRenderer.HTML]: SupportedRenderer.HTML,
|
|
11150
|
+
[SupportedRenderer.PREACT]: SupportedRenderer.PREACT,
|
|
11151
|
+
[SupportedRenderer.REACT_NATIVE]: SupportedRenderer.REACT_NATIVE,
|
|
11152
|
+
[SupportedRenderer.REACT]: SupportedRenderer.REACT,
|
|
11153
|
+
[SupportedRenderer.SERVER]: SupportedRenderer.SERVER,
|
|
11154
|
+
[SupportedRenderer.SVELTE]: SupportedRenderer.SVELTE,
|
|
11155
|
+
[SupportedRenderer.VUE3]: SupportedRenderer.VUE3,
|
|
11156
|
+
[SupportedRenderer.WEB_COMPONENTS]: SupportedRenderer.WEB_COMPONENTS
|
|
11157
|
+
}, frameworkToBuilder = {
|
|
11158
|
+
// frameworks
|
|
11159
|
+
[SupportedFramework.ANGULAR]: SupportedBuilder.WEBPACK5,
|
|
11160
|
+
[SupportedFramework.EMBER]: SupportedBuilder.WEBPACK5,
|
|
11161
|
+
[SupportedFramework.HTML_VITE]: SupportedBuilder.VITE,
|
|
11162
|
+
[SupportedFramework.NEXTJS]: SupportedBuilder.WEBPACK5,
|
|
11163
|
+
[SupportedFramework.NEXTJS_VITE]: SupportedBuilder.VITE,
|
|
11164
|
+
[SupportedFramework.PREACT_VITE]: SupportedBuilder.VITE,
|
|
11165
|
+
[SupportedFramework.REACT_NATIVE_WEB_VITE]: SupportedBuilder.VITE,
|
|
11166
|
+
[SupportedFramework.REACT_VITE]: SupportedBuilder.VITE,
|
|
11167
|
+
[SupportedFramework.REACT_WEBPACK5]: SupportedBuilder.WEBPACK5,
|
|
11168
|
+
[SupportedFramework.SERVER_WEBPACK5]: SupportedBuilder.WEBPACK5,
|
|
11169
|
+
[SupportedFramework.SVELTE_VITE]: SupportedBuilder.VITE,
|
|
11170
|
+
[SupportedFramework.SVELTEKIT]: SupportedBuilder.VITE,
|
|
11171
|
+
[SupportedFramework.VUE3_VITE]: SupportedBuilder.VITE,
|
|
11172
|
+
[SupportedFramework.WEB_COMPONENTS_VITE]: SupportedBuilder.VITE,
|
|
11173
|
+
[SupportedFramework.QWIK]: SupportedBuilder.VITE,
|
|
11174
|
+
[SupportedFramework.SOLID]: SupportedBuilder.VITE,
|
|
11175
|
+
[SupportedFramework.NUXT]: SupportedBuilder.VITE,
|
|
11176
|
+
[SupportedFramework.REACT_RSBUILD]: SupportedBuilder.RSBUILD,
|
|
11177
|
+
[SupportedFramework.VUE3_RSBUILD]: SupportedBuilder.RSBUILD,
|
|
11178
|
+
[SupportedFramework.HTML_RSBUILD]: SupportedBuilder.RSBUILD,
|
|
11179
|
+
[SupportedFramework.WEB_COMPONENTS_RSBUILD]: SupportedBuilder.RSBUILD
|
|
11180
|
+
};
|
|
11181
|
+
|
|
11182
|
+
// src/common/utils/get-builder-options.ts
|
|
11183
|
+
async function getBuilderOptions(options) {
|
|
11184
|
+
let framework = await options.presets.apply("framework", {}, options);
|
|
11185
|
+
if (typeof framework != "string" && framework?.options?.builder)
|
|
11186
|
+
return framework.options.builder;
|
|
11187
|
+
let { builder } = await options.presets.apply("core", {}, options);
|
|
11188
|
+
return typeof builder != "string" && builder?.options ? builder.options : {};
|
|
11189
|
+
}
|
|
11190
|
+
|
|
11191
|
+
// src/common/utils/get-framework-name.ts
|
|
11192
|
+
var import_ts_dedent4 = __toESM(require_dist(), 1);
|
|
11193
|
+
|
|
11194
|
+
// src/common/utils/get-storybook-info.ts
|
|
11195
|
+
import { existsSync as existsSync3, readFileSync as readFileSync3 } from "node:fs";
|
|
11196
|
+
import { dirname as dirname4, join as join9 } from "node:path";
|
|
11197
|
+
import { CoreWebpackCompiler, SupportedFramework as SupportedFramework2 } from "storybook/internal/types";
|
|
11198
|
+
import { SupportedBuilder as SupportedBuilder2, SupportedRenderer as SupportedRenderer2 } from "storybook/internal/types";
|
|
11199
|
+
|
|
11200
|
+
// src/common/js-package-manager/JsPackageManager.ts
|
|
11201
|
+
import { readFileSync as readFileSync2, writeFileSync as writeFileSync2 } from "node:fs";
|
|
11202
|
+
import { dirname as dirname3, isAbsolute, join as join7, normalize as normalize2, resolve as resolve6 } from "node:path";
|
|
11203
|
+
import { logger as logger4, prompt } from "storybook/internal/node-logger";
|
|
11204
|
+
var import_picocolors = __toESM(require_picocolors(), 1);
|
|
11205
|
+
import { coerce, gt, satisfies } from "semver";
|
|
11206
|
+
|
|
11207
|
+
// src/common/utils/HandledError.ts
|
|
11208
|
+
var HandledError = class extends Error {
|
|
11209
|
+
constructor(error) {
|
|
11210
|
+
super(String(error));
|
|
11211
|
+
this.handled = !0;
|
|
11212
|
+
typeof error != "string" && (this.cause = error);
|
|
11213
|
+
}
|
|
11214
|
+
};
|
|
11215
|
+
|
|
11050
11216
|
// src/common/js-package-manager/JsPackageManager.ts
|
|
11051
11217
|
var PackageManagerName = /* @__PURE__ */ ((PackageManagerName2) => (PackageManagerName2.NPM = "npm", PackageManagerName2.YARN1 = "yarn1", PackageManagerName2.YARN2 = "yarn2", PackageManagerName2.PNPM = "pnpm", PackageManagerName2.BUN = "bun", PackageManagerName2))(PackageManagerName || {});
|
|
11052
11218
|
function getPackageDetails(pkg) {
|
|
@@ -11070,7 +11236,7 @@ var JsPackageManager = class _JsPackageManager {
|
|
|
11070
11236
|
this.packageJsonCache = /* @__PURE__ */ new Map();
|
|
11071
11237
|
}
|
|
11072
11238
|
constructor(options) {
|
|
11073
|
-
this.cwd = options?.cwd || process.cwd(), this.instanceDir = options?.configDir ? isAbsolute(options?.configDir) ? dirname3(options?.configDir) : dirname3(
|
|
11239
|
+
this.cwd = options?.cwd || process.cwd(), this.instanceDir = options?.configDir ? isAbsolute(options?.configDir) ? dirname3(options?.configDir) : dirname3(join7(this.cwd, options?.configDir)) : this.cwd, this.packageJsonPaths = _JsPackageManager.listAllPackageJsonPaths(
|
|
11074
11240
|
this.instanceDir,
|
|
11075
11241
|
options?.storiesPaths
|
|
11076
11242
|
), this.primaryPackageJson = this.#getPrimaryPackageJson();
|
|
@@ -11111,7 +11277,7 @@ var JsPackageManager = class _JsPackageManager {
|
|
|
11111
11277
|
static getPackageJson(packageJsonPath) {
|
|
11112
11278
|
let absolutePath = normalize2(resolve6(packageJsonPath)), cached = _JsPackageManager.packageJsonCache.get(absolutePath);
|
|
11113
11279
|
if (cached)
|
|
11114
|
-
return
|
|
11280
|
+
return logger4.debug(`Using cached package.json for ${absolutePath}...`), cached;
|
|
11115
11281
|
let jsonContent = readFileSync2(absolutePath, "utf8"), packageJSON = JSON.parse(jsonContent), result = {
|
|
11116
11282
|
...packageJSON,
|
|
11117
11283
|
dependencies: { ...packageJSON.dependencies || {} },
|
|
@@ -11186,8 +11352,8 @@ var JsPackageManager = class _JsPackageManager {
|
|
|
11186
11352
|
);
|
|
11187
11353
|
return this.clearInstalledVersionCache(), result;
|
|
11188
11354
|
} catch (e) {
|
|
11189
|
-
throw
|
|
11190
|
-
An error occurred while adding dependencies to your package.json:`),
|
|
11355
|
+
throw logger4.error(`
|
|
11356
|
+
An error occurred while adding dependencies to your package.json:`), logger4.log(String(e)), new HandledError(e);
|
|
11191
11357
|
}
|
|
11192
11358
|
}
|
|
11193
11359
|
/**
|
|
@@ -11213,7 +11379,7 @@ An error occurred while adding dependencies to your package.json:`), logger3.log
|
|
|
11213
11379
|
break;
|
|
11214
11380
|
}
|
|
11215
11381
|
} catch (e) {
|
|
11216
|
-
|
|
11382
|
+
logger4.warn(`Could not process ${pjPath} for dependency removal: ${String(e)}`);
|
|
11217
11383
|
}
|
|
11218
11384
|
}
|
|
11219
11385
|
/**
|
|
@@ -11268,9 +11434,9 @@ An error occurred while adding dependencies to your package.json:`), logger3.log
|
|
|
11268
11434
|
throw new Error(`No version found for ${packageName}`);
|
|
11269
11435
|
} catch (e) {
|
|
11270
11436
|
if (current)
|
|
11271
|
-
return
|
|
11437
|
+
return logger4.warn(`
|
|
11272
11438
|
${import_picocolors.default.yellow(String(e))}`), current;
|
|
11273
|
-
throw
|
|
11439
|
+
throw logger4.error(`
|
|
11274
11440
|
${import_picocolors.default.red(String(e))}`), new HandledError(e);
|
|
11275
11441
|
}
|
|
11276
11442
|
return `^${current && (!constraint || satisfies(current, constraint)) && gt(current, latest) ? current : latest}`;
|
|
@@ -11285,9 +11451,9 @@ An error occurred while adding dependencies to your package.json:`), logger3.log
|
|
|
11285
11451
|
async latestVersion(packageName, constraint) {
|
|
11286
11452
|
let cacheKey = constraint ? `${packageName}@${constraint}` : packageName, cachedVersion = _JsPackageManager.latestVersionCache.get(cacheKey);
|
|
11287
11453
|
if (cachedVersion)
|
|
11288
|
-
return
|
|
11454
|
+
return logger4.debug(`Using cached version for ${packageName}...`), cachedVersion;
|
|
11289
11455
|
let result;
|
|
11290
|
-
|
|
11456
|
+
logger4.debug(`Getting CLI versions from NPM for ${packageName}...`);
|
|
11291
11457
|
try {
|
|
11292
11458
|
if (!constraint)
|
|
11293
11459
|
result = await this.runGetVersions(packageName, !1);
|
|
@@ -11363,13 +11529,13 @@ An error occurred while adding dependencies to your package.json:`), logger3.log
|
|
|
11363
11529
|
try {
|
|
11364
11530
|
let cachedVersion = _JsPackageManager.installedVersionCache.get(cacheKey);
|
|
11365
11531
|
if (cachedVersion !== void 0)
|
|
11366
|
-
return
|
|
11367
|
-
|
|
11532
|
+
return logger4.debug(`Using cached installed version for ${packageName}...`), cachedVersion;
|
|
11533
|
+
logger4.debug(`Getting installed version for ${packageName}...`);
|
|
11368
11534
|
let installations = await this.findInstallations([packageName]);
|
|
11369
11535
|
if (!installations)
|
|
11370
11536
|
return _JsPackageManager.installedVersionCache.set(cacheKey, null), null;
|
|
11371
11537
|
let version = Object.entries(installations.dependencies)[0]?.[1]?.[0].version || null, coercedVersion = coerce(version, { includePrerelease: !0 })?.toString() ?? version;
|
|
11372
|
-
return
|
|
11538
|
+
return logger4.debug(`Installed version for ${packageName}: ${coercedVersion}`), _JsPackageManager.installedVersionCache.set(cacheKey, coercedVersion), coercedVersion;
|
|
11373
11539
|
} catch {
|
|
11374
11540
|
return _JsPackageManager.installedVersionCache.set(cacheKey, null), null;
|
|
11375
11541
|
}
|
|
@@ -11382,7 +11548,7 @@ An error occurred while adding dependencies to your package.json:`), logger3.log
|
|
|
11382
11548
|
* the dependency.
|
|
11383
11549
|
*/
|
|
11384
11550
|
getDependencyVersion(dependency) {
|
|
11385
|
-
return
|
|
11551
|
+
return logger4.debug(`Getting dependency version for ${dependency}...`), this.packageJsonPaths.map((path4) => {
|
|
11386
11552
|
let packageJson = _JsPackageManager.getPackageJson(path4);
|
|
11387
11553
|
return packageJson.dependencies?.[dependency] ?? packageJson.devDependencies?.[dependency];
|
|
11388
11554
|
}).filter(Boolean)[0] ?? null;
|
|
@@ -11444,7 +11610,7 @@ An error occurred while adding dependencies to your package.json:`), logger3.log
|
|
|
11444
11610
|
return _JsPackageManager.getPackageJsonInfo(finalTargetPackageJsonPath);
|
|
11445
11611
|
}
|
|
11446
11612
|
static getPackageJsonInfo(packageJsonPath) {
|
|
11447
|
-
|
|
11613
|
+
logger4.debug(`Getting package.json info for ${packageJsonPath}...`);
|
|
11448
11614
|
let operationDir = dirname3(packageJsonPath);
|
|
11449
11615
|
return {
|
|
11450
11616
|
packageJsonPath,
|
|
@@ -11456,65 +11622,6 @@ An error occurred while adding dependencies to your package.json:`), logger3.log
|
|
|
11456
11622
|
}
|
|
11457
11623
|
};
|
|
11458
11624
|
|
|
11459
|
-
// src/common/utils/framework.ts
|
|
11460
|
-
import { SupportedBuilder, SupportedFramework, SupportedRenderer } from "storybook/internal/types";
|
|
11461
|
-
var frameworkToRenderer = {
|
|
11462
|
-
// frameworks
|
|
11463
|
-
[SupportedFramework.ANGULAR]: SupportedRenderer.ANGULAR,
|
|
11464
|
-
[SupportedFramework.EMBER]: SupportedRenderer.EMBER,
|
|
11465
|
-
[SupportedFramework.HTML_VITE]: SupportedRenderer.HTML,
|
|
11466
|
-
[SupportedFramework.NEXTJS]: SupportedRenderer.REACT,
|
|
11467
|
-
[SupportedFramework.NEXTJS_VITE]: SupportedRenderer.REACT,
|
|
11468
|
-
[SupportedFramework.PREACT_VITE]: SupportedRenderer.PREACT,
|
|
11469
|
-
[SupportedFramework.QWIK]: SupportedRenderer.QWIK,
|
|
11470
|
-
[SupportedFramework.REACT_VITE]: SupportedRenderer.REACT,
|
|
11471
|
-
[SupportedFramework.REACT_WEBPACK5]: SupportedRenderer.REACT,
|
|
11472
|
-
[SupportedFramework.SERVER_WEBPACK5]: SupportedRenderer.SERVER,
|
|
11473
|
-
[SupportedFramework.SOLID]: SupportedRenderer.SOLID,
|
|
11474
|
-
[SupportedFramework.SVELTE_VITE]: SupportedRenderer.SVELTE,
|
|
11475
|
-
[SupportedFramework.SVELTEKIT]: SupportedRenderer.SVELTE,
|
|
11476
|
-
[SupportedFramework.VUE3_VITE]: SupportedRenderer.VUE3,
|
|
11477
|
-
[SupportedFramework.WEB_COMPONENTS_VITE]: SupportedRenderer.WEB_COMPONENTS,
|
|
11478
|
-
[SupportedFramework.REACT_RSBUILD]: SupportedRenderer.REACT,
|
|
11479
|
-
[SupportedFramework.VUE3_RSBUILD]: SupportedRenderer.VUE3,
|
|
11480
|
-
[SupportedFramework.HTML_RSBUILD]: SupportedRenderer.HTML,
|
|
11481
|
-
[SupportedFramework.WEB_COMPONENTS_RSBUILD]: SupportedRenderer.WEB_COMPONENTS,
|
|
11482
|
-
[SupportedFramework.REACT_NATIVE_WEB_VITE]: SupportedRenderer.REACT,
|
|
11483
|
-
[SupportedFramework.NUXT]: SupportedRenderer.VUE3,
|
|
11484
|
-
// renderers
|
|
11485
|
-
[SupportedRenderer.HTML]: SupportedRenderer.HTML,
|
|
11486
|
-
[SupportedRenderer.PREACT]: SupportedRenderer.PREACT,
|
|
11487
|
-
[SupportedRenderer.REACT_NATIVE]: SupportedRenderer.REACT_NATIVE,
|
|
11488
|
-
[SupportedRenderer.REACT]: SupportedRenderer.REACT,
|
|
11489
|
-
[SupportedRenderer.SERVER]: SupportedRenderer.SERVER,
|
|
11490
|
-
[SupportedRenderer.SVELTE]: SupportedRenderer.SVELTE,
|
|
11491
|
-
[SupportedRenderer.VUE3]: SupportedRenderer.VUE3,
|
|
11492
|
-
[SupportedRenderer.WEB_COMPONENTS]: SupportedRenderer.WEB_COMPONENTS
|
|
11493
|
-
}, frameworkToBuilder = {
|
|
11494
|
-
// frameworks
|
|
11495
|
-
[SupportedFramework.ANGULAR]: SupportedBuilder.WEBPACK5,
|
|
11496
|
-
[SupportedFramework.EMBER]: SupportedBuilder.WEBPACK5,
|
|
11497
|
-
[SupportedFramework.HTML_VITE]: SupportedBuilder.VITE,
|
|
11498
|
-
[SupportedFramework.NEXTJS]: SupportedBuilder.WEBPACK5,
|
|
11499
|
-
[SupportedFramework.NEXTJS_VITE]: SupportedBuilder.VITE,
|
|
11500
|
-
[SupportedFramework.PREACT_VITE]: SupportedBuilder.VITE,
|
|
11501
|
-
[SupportedFramework.REACT_NATIVE_WEB_VITE]: SupportedBuilder.VITE,
|
|
11502
|
-
[SupportedFramework.REACT_VITE]: SupportedBuilder.VITE,
|
|
11503
|
-
[SupportedFramework.REACT_WEBPACK5]: SupportedBuilder.WEBPACK5,
|
|
11504
|
-
[SupportedFramework.SERVER_WEBPACK5]: SupportedBuilder.WEBPACK5,
|
|
11505
|
-
[SupportedFramework.SVELTE_VITE]: SupportedBuilder.VITE,
|
|
11506
|
-
[SupportedFramework.SVELTEKIT]: SupportedBuilder.VITE,
|
|
11507
|
-
[SupportedFramework.VUE3_VITE]: SupportedBuilder.VITE,
|
|
11508
|
-
[SupportedFramework.WEB_COMPONENTS_VITE]: SupportedBuilder.VITE,
|
|
11509
|
-
[SupportedFramework.QWIK]: SupportedBuilder.VITE,
|
|
11510
|
-
[SupportedFramework.SOLID]: SupportedBuilder.VITE,
|
|
11511
|
-
[SupportedFramework.NUXT]: SupportedBuilder.VITE,
|
|
11512
|
-
[SupportedFramework.REACT_RSBUILD]: SupportedBuilder.RSBUILD,
|
|
11513
|
-
[SupportedFramework.VUE3_RSBUILD]: SupportedBuilder.RSBUILD,
|
|
11514
|
-
[SupportedFramework.HTML_RSBUILD]: SupportedBuilder.RSBUILD,
|
|
11515
|
-
[SupportedFramework.WEB_COMPONENTS_RSBUILD]: SupportedBuilder.RSBUILD
|
|
11516
|
-
};
|
|
11517
|
-
|
|
11518
11625
|
// src/common/utils/normalize-path.ts
|
|
11519
11626
|
import { posix as posix3 } from "node:path";
|
|
11520
11627
|
function normalizePath3(p) {
|
|
@@ -11528,23 +11635,6 @@ var getAddonNames = (mainConfig) => (mainConfig.addons || []).map((addon) => {
|
|
|
11528
11635
|
return name = normalizePath3(name), name = name.replace(/.*node_modules\//, ""), name.replace(/\/dist\/.*$/, "").replace(/\.[mc]?[tj]?sx?$/, "").replace(/\/register$/, "").replace(/\/manager$/, "").replace(/\/preset$/, "");
|
|
11529
11636
|
}).filter((item) => item != null);
|
|
11530
11637
|
|
|
11531
|
-
// src/common/utils/get-framework-name.ts
|
|
11532
|
-
var import_ts_dedent3 = __toESM(require_dist(), 1);
|
|
11533
|
-
async function getFrameworkName(options) {
|
|
11534
|
-
let framework = await options.presets.apply("framework", "", options);
|
|
11535
|
-
if (!framework)
|
|
11536
|
-
throw new Error(import_ts_dedent3.dedent`
|
|
11537
|
-
You must specify a framework in '.storybook/main.js' config.
|
|
11538
|
-
|
|
11539
|
-
https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#framework-field-mandatory
|
|
11540
|
-
`);
|
|
11541
|
-
return typeof framework == "object" ? framework.name : framework;
|
|
11542
|
-
}
|
|
11543
|
-
var extractFrameworkPackageName = (framework) => {
|
|
11544
|
-
let normalizedPath = normalizePath3(framework);
|
|
11545
|
-
return Object.keys(frameworkPackages).find((pkg) => normalizedPath.endsWith(pkg)) ?? framework;
|
|
11546
|
-
};
|
|
11547
|
-
|
|
11548
11638
|
// src/common/utils/get-renderer-name.ts
|
|
11549
11639
|
async function getRendererName(options) {
|
|
11550
11640
|
let core = await options.presets.apply("core", {}, options);
|
|
@@ -11564,10 +11654,10 @@ function getStorybookConfiguration(storybookScript, shortName, longName) {
|
|
|
11564
11654
|
}
|
|
11565
11655
|
|
|
11566
11656
|
// src/common/utils/load-main-config.ts
|
|
11567
|
-
var
|
|
11568
|
-
import { readFile as
|
|
11569
|
-
import { join as
|
|
11570
|
-
import { logger as
|
|
11657
|
+
var import_ts_dedent3 = __toESM(require_dist(), 1);
|
|
11658
|
+
import { readFile as readFile3, rm as rm3, writeFile as writeFile3 } from "node:fs/promises";
|
|
11659
|
+
import { join as join8, parse as parse2, relative as relative3, resolve as resolve7 } from "node:path";
|
|
11660
|
+
import { logger as logger5 } from "storybook/internal/node-logger";
|
|
11571
11661
|
import { MainFileEvaluationError } from "storybook/internal/server-errors";
|
|
11572
11662
|
async function loadMainConfig({
|
|
11573
11663
|
configDir = ".storybook",
|
|
@@ -11582,12 +11672,12 @@ async function loadMainConfig({
|
|
|
11582
11672
|
if (!(e instanceof Error))
|
|
11583
11673
|
throw e;
|
|
11584
11674
|
if (e.message.includes("not defined in ES module scope")) {
|
|
11585
|
-
|
|
11675
|
+
logger5.info(
|
|
11586
11676
|
"Loading main config failed as the file does not seem to be valid ESM. Trying a temporary fix, please ensure the main config is valid ESM."
|
|
11587
11677
|
);
|
|
11588
|
-
let comment = "// end of Storybook 10 migration assistant header, you can delete the above code", content = await
|
|
11678
|
+
let comment = "// end of Storybook 10 migration assistant header, you can delete the above code", content = await readFile3(mainPath, "utf-8");
|
|
11589
11679
|
if (!content.includes(comment)) {
|
|
11590
|
-
let header =
|
|
11680
|
+
let header = import_ts_dedent3.dedent`
|
|
11591
11681
|
import { createRequire } from "node:module";
|
|
11592
11682
|
import { dirname } from "node:path";
|
|
11593
11683
|
import { fileURLToPath } from "node:url";
|
|
@@ -11595,15 +11685,15 @@ async function loadMainConfig({
|
|
|
11595
11685
|
const __filename = fileURLToPath(import.meta.url);
|
|
11596
11686
|
const __dirname = dirname(__filename);
|
|
11597
11687
|
const require = createRequire(import.meta.url);
|
|
11598
|
-
`, { ext, name, dir } = parse2(mainPath), modifiedMainPath =
|
|
11599
|
-
await
|
|
11688
|
+
`, { ext, name, dir } = parse2(mainPath), modifiedMainPath = join8(dir, `${name}.tmp.${ext}`);
|
|
11689
|
+
await writeFile3(modifiedMainPath, [header, comment, content].join(`
|
|
11600
11690
|
|
|
11601
11691
|
`));
|
|
11602
11692
|
let out;
|
|
11603
11693
|
try {
|
|
11604
11694
|
out = await importModule(modifiedMainPath);
|
|
11605
11695
|
} finally {
|
|
11606
|
-
await
|
|
11696
|
+
await rm3(modifiedMainPath);
|
|
11607
11697
|
}
|
|
11608
11698
|
return out;
|
|
11609
11699
|
}
|
|
@@ -11672,7 +11762,7 @@ var rendererPackages = {
|
|
|
11672
11762
|
return version;
|
|
11673
11763
|
}
|
|
11674
11764
|
}, validConfigExtensions = ["ts", "js", "tsx", "jsx", "mjs", "cjs"], findConfigFile = (prefix, configDir) => {
|
|
11675
|
-
let filePrefix =
|
|
11765
|
+
let filePrefix = join9(configDir, prefix), extension = validConfigExtensions.find((ext) => existsSync3(`${filePrefix}.${ext}`));
|
|
11676
11766
|
return extension ? `${filePrefix}.${extension}` : null;
|
|
11677
11767
|
}, getConfigInfo = (configDir) => {
|
|
11678
11768
|
let storybookConfigDir = configDir ?? ".storybook";
|
|
@@ -11701,11 +11791,11 @@ var rendererPackages = {
|
|
|
11701
11791
|
cwd
|
|
11702
11792
|
});
|
|
11703
11793
|
invariant(mainConfig, `Unable to find or evaluate ${configInfo.mainConfigPath}`);
|
|
11704
|
-
let frameworkValue = mainConfig.framework, frameworkField = typeof frameworkValue == "string" ? frameworkValue : frameworkValue?.name, addons = getAddonNames(mainConfig),
|
|
11794
|
+
let frameworkValue = mainConfig.framework, frameworkField = typeof frameworkValue == "string" ? frameworkValue : frameworkValue?.name, addons = getAddonNames(mainConfig), versionSpecifier = getStorybookVersionSpecifier(configDir);
|
|
11705
11795
|
if (!frameworkField)
|
|
11706
11796
|
return {
|
|
11707
11797
|
...configInfo,
|
|
11708
|
-
|
|
11798
|
+
versionSpecifier,
|
|
11709
11799
|
addons,
|
|
11710
11800
|
mainConfig,
|
|
11711
11801
|
mainConfigPath: configInfo.mainConfigPath ?? void 0,
|
|
@@ -11722,7 +11812,7 @@ var rendererPackages = {
|
|
|
11722
11812
|
addons,
|
|
11723
11813
|
mainConfig,
|
|
11724
11814
|
framework,
|
|
11725
|
-
|
|
11815
|
+
versionSpecifier,
|
|
11726
11816
|
renderer: renderer ?? void 0,
|
|
11727
11817
|
builder: builder ?? void 0,
|
|
11728
11818
|
frameworkPackage,
|
|
@@ -11734,117 +11824,21 @@ var rendererPackages = {
|
|
|
11734
11824
|
};
|
|
11735
11825
|
};
|
|
11736
11826
|
|
|
11737
|
-
// src/common/utils/
|
|
11738
|
-
|
|
11739
|
-
|
|
11740
|
-
|
|
11741
|
-
|
|
11742
|
-
|
|
11743
|
-
async function temporaryFile({ name, extension } = {}) {
|
|
11744
|
-
if (name) {
|
|
11745
|
-
if (extension != null)
|
|
11746
|
-
throw new Error("The `name` and `extension` options are mutually exclusive");
|
|
11747
|
-
return join9(await temporaryDirectory(), name);
|
|
11748
|
-
}
|
|
11749
|
-
return await getPath() + (extension == null ? "" : "." + extension.replace(/^\./, ""));
|
|
11750
|
-
}
|
|
11751
|
-
function parseList(str) {
|
|
11752
|
-
return str.split(",").map((item) => item.trim()).filter((item) => item.length > 0);
|
|
11753
|
-
}
|
|
11754
|
-
async function getCoercedStorybookVersion(packageManager) {
|
|
11755
|
-
return (await Promise.all(
|
|
11756
|
-
Object.keys(rendererPackages).map(async (pkg) => ({
|
|
11757
|
-
name: pkg,
|
|
11758
|
-
version: (await packageManager.getModulePackageJSON(pkg))?.version ?? null
|
|
11759
|
-
}))
|
|
11760
|
-
)).filter(({ version }) => !!version)[0]?.version || versions_default.storybook;
|
|
11761
|
-
}
|
|
11762
|
-
function getEnvConfig(program, configEnv) {
|
|
11763
|
-
Object.keys(configEnv).forEach((fieldName) => {
|
|
11764
|
-
let envVarName = configEnv[fieldName], envVarValue = process.env[envVarName];
|
|
11765
|
-
envVarValue && (program[fieldName] = envVarValue);
|
|
11766
|
-
});
|
|
11767
|
-
}
|
|
11768
|
-
var createLogStream = async (logFileName = "storybook.log") => {
|
|
11769
|
-
let finalLogPath = join9(process.cwd(), logFileName), temporaryLogPath = await temporaryFile({ name: logFileName }), logStream = createWriteStream(temporaryLogPath, { encoding: "utf8" });
|
|
11770
|
-
return new Promise((resolve11, reject) => {
|
|
11771
|
-
logStream.once("open", () => {
|
|
11772
|
-
let clearLogFile = async () => writeFile3(temporaryLogPath, ""), removeLogFile = async () => rm3(temporaryLogPath, { recursive: !0, force: !0 });
|
|
11773
|
-
resolve11({ logStream, moveLogFile: async () => copyFile(temporaryLogPath, finalLogPath).then(removeLogFile), clearLogFile, removeLogFile, readLogFile: async () => readFile3(temporaryLogPath, { encoding: "utf8" }) });
|
|
11774
|
-
}), logStream.once("error", reject);
|
|
11775
|
-
});
|
|
11776
|
-
}, isCorePackage = (pkg) => !!versions_default[pkg], isSatelliteAddon = (pkg) => satellite_addons_default.includes(pkg);
|
|
11777
|
-
|
|
11778
|
-
// src/common/utils/check-addon-order.ts
|
|
11779
|
-
import { logger as logger5 } from "storybook/internal/node-logger";
|
|
11780
|
-
var predicateFor = (addon) => (entry) => {
|
|
11781
|
-
let name = entry.name || entry;
|
|
11782
|
-
return name && name.replaceAll(/(\\){1,2}/g, "/").includes(addon);
|
|
11783
|
-
}, isCorrectOrder = (addons, before, after) => {
|
|
11784
|
-
let essentialsIndex = addons.findIndex(predicateFor("@storybook/addon-essentials")), beforeIndex = addons.findIndex(predicateFor(before.name)), afterIndex = addons.findIndex(predicateFor(after.name));
|
|
11785
|
-
return beforeIndex === -1 && before.inEssentials && (beforeIndex = essentialsIndex), afterIndex === -1 && after.inEssentials && (afterIndex = essentialsIndex), beforeIndex !== -1 && afterIndex !== -1 && beforeIndex <= afterIndex;
|
|
11786
|
-
}, checkAddonOrder = async ({ before, after, configFile, getConfig }) => {
|
|
11787
|
-
try {
|
|
11788
|
-
let config = await getConfig(configFile);
|
|
11789
|
-
if (!config?.addons) {
|
|
11790
|
-
logger5.warn("Unable to find 'addons' config in main Storybook config");
|
|
11791
|
-
return;
|
|
11792
|
-
}
|
|
11793
|
-
if (!isCorrectOrder(config.addons, before, after)) {
|
|
11794
|
-
let orEssentials = " (or '@storybook/addon-essentials')", beforeText = `'${before.name}'${before.inEssentials ? orEssentials : ""}`, afterText = `'${after.name}'${after.inEssentials ? orEssentials : ""}`;
|
|
11795
|
-
logger5.warn(
|
|
11796
|
-
`Expected ${beforeText} to be listed before ${afterText} in main Storybook config.`
|
|
11797
|
-
);
|
|
11798
|
-
}
|
|
11799
|
-
} catch {
|
|
11800
|
-
logger5.warn(`Unable to load config file: ${configFile}`);
|
|
11801
|
-
}
|
|
11802
|
-
};
|
|
11827
|
+
// src/common/utils/get-framework-name.ts
|
|
11828
|
+
async function getFrameworkName(options) {
|
|
11829
|
+
let framework = await options.presets.apply("framework", "", options);
|
|
11830
|
+
if (!framework)
|
|
11831
|
+
throw new Error(import_ts_dedent4.dedent`
|
|
11832
|
+
You must specify a framework in '.storybook/main.js' config.
|
|
11803
11833
|
|
|
11804
|
-
|
|
11805
|
-
|
|
11806
|
-
|
|
11807
|
-
// eslint-disable-next-line @typescript-eslint/dot-notation
|
|
11808
|
-
NODE_ENV: process.env.NODE_ENV || defaultNodeEnv,
|
|
11809
|
-
NODE_PATH: process.env.NODE_PATH || "",
|
|
11810
|
-
STORYBOOK: process.env.STORYBOOK || "true",
|
|
11811
|
-
// This is to support CRA's public folder feature.
|
|
11812
|
-
// In production we set this to dot(.) to allow the browser to access these assets
|
|
11813
|
-
// even when deployed inside a subpath. (like in GitHub pages)
|
|
11814
|
-
// In development this is just empty as we always serves from the root.
|
|
11815
|
-
PUBLIC_URL: options.production ? "." : ""
|
|
11816
|
-
};
|
|
11817
|
-
Object.keys(process.env).filter((name) => /^STORYBOOK_/.test(name)).forEach((name) => {
|
|
11818
|
-
env2[name] = process.env[name];
|
|
11819
|
-
});
|
|
11820
|
-
let base = Object.entries(env2).reduce(
|
|
11821
|
-
(acc, [k, v]) => Object.assign(acc, { [k]: JSON.stringify(v) }),
|
|
11822
|
-
{}
|
|
11823
|
-
), { stringified, raw } = getEnvironment({ nodeEnv: env2.NODE_ENV }), fullRaw = { ...env2, ...raw };
|
|
11824
|
-
return fullRaw.NODE_PATH = nodePathsToArray(fullRaw.NODE_PATH || ""), {
|
|
11825
|
-
stringified: { ...base, ...stringified },
|
|
11826
|
-
raw: fullRaw
|
|
11827
|
-
};
|
|
11834
|
+
https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#framework-field-mandatory
|
|
11835
|
+
`);
|
|
11836
|
+
return typeof framework == "object" ? framework.name : framework;
|
|
11828
11837
|
}
|
|
11829
|
-
var
|
|
11830
|
-
|
|
11831
|
-
|
|
11838
|
+
var extractFrameworkPackageName = (framework) => {
|
|
11839
|
+
let normalizedPath = normalizePath3(framework);
|
|
11840
|
+
return Object.keys(frameworkPackages).find((pkg) => normalizedPath.endsWith(pkg)) ?? framework;
|
|
11832
11841
|
};
|
|
11833
|
-
function isCI() {
|
|
11834
|
-
return optionalEnvToBoolean(process.env.CI);
|
|
11835
|
-
}
|
|
11836
|
-
|
|
11837
|
-
// src/common/utils/common-glob-options.ts
|
|
11838
|
-
var NODE_MODULES_RE = /node_modules/, commonGlobOptions = (glob2) => NODE_MODULES_RE.test(glob2) ? {} : { ignore: ["**/node_modules/**"] };
|
|
11839
|
-
|
|
11840
|
-
// src/common/utils/get-builder-options.ts
|
|
11841
|
-
async function getBuilderOptions(options) {
|
|
11842
|
-
let framework = await options.presets.apply("framework", {}, options);
|
|
11843
|
-
if (typeof framework != "string" && framework?.options?.builder)
|
|
11844
|
-
return framework.options.builder;
|
|
11845
|
-
let { builder } = await options.presets.apply("core", {}, options);
|
|
11846
|
-
return typeof builder != "string" && builder?.options ? builder.options : {};
|
|
11847
|
-
}
|
|
11848
11842
|
|
|
11849
11843
|
// src/common/utils/get-storybook-refs.ts
|
|
11850
11844
|
import { readFile as readFile4 } from "node:fs/promises";
|
|
@@ -13726,7 +13720,10 @@ var NPM_ERROR_REGEX = /npm ERR! code (\w+)/, NPM_ERROR_CODES = {
|
|
|
13726
13720
|
return `bunx ${pkg}${specifier ? `@${specifier}` : ""} ${args.join(" ")}`;
|
|
13727
13721
|
}
|
|
13728
13722
|
async getModulePackageJSON(packageName) {
|
|
13729
|
-
let wantedPath = join11("node_modules", packageName, "package.json"), packageJsonPath = up2(wantedPath, {
|
|
13723
|
+
let wantedPath = join11("node_modules", packageName, "package.json"), packageJsonPath = up2(wantedPath, {
|
|
13724
|
+
cwd: this.primaryPackageJson.operationDir,
|
|
13725
|
+
last: getProjectRoot()
|
|
13726
|
+
});
|
|
13730
13727
|
return packageJsonPath ? JSON.parse(readFileSync6(packageJsonPath, "utf-8")) : null;
|
|
13731
13728
|
}
|
|
13732
13729
|
getInstallArgs() {
|
|
@@ -13906,7 +13903,10 @@ var NPM_ERROR_REGEX2 = /npm (ERR!|error) (code|errno) (\w+)/i, NPM_ERROR_CODES2
|
|
|
13906
13903
|
return `npm run ${command}`;
|
|
13907
13904
|
}
|
|
13908
13905
|
async getModulePackageJSON(packageName) {
|
|
13909
|
-
let wantedPath = join12("node_modules", packageName, "package.json"), packageJsonPath = up2(wantedPath, {
|
|
13906
|
+
let wantedPath = join12("node_modules", packageName, "package.json"), packageJsonPath = up2(wantedPath, {
|
|
13907
|
+
cwd: this.primaryPackageJson.operationDir,
|
|
13908
|
+
last: getProjectRoot()
|
|
13909
|
+
});
|
|
13910
13910
|
return packageJsonPath ? JSON.parse(readFileSync7(packageJsonPath, "utf-8")) : null;
|
|
13911
13911
|
}
|
|
13912
13912
|
getInstallArgs() {
|
|
@@ -14123,7 +14123,10 @@ var PNPM_ERROR_REGEX = /(ELIFECYCLE|ERR_PNPM_[A-Z_]+)\s+(.*)/i, PNPMProxy = clas
|
|
|
14123
14123
|
} catch (error) {
|
|
14124
14124
|
return error.code !== "MODULE_NOT_FOUND" && console.error("Error while fetching package version in PNPM PnP mode:", error), null;
|
|
14125
14125
|
}
|
|
14126
|
-
let wantedPath = join13("node_modules", packageName, "package.json"), packageJsonPath = up2(wantedPath, {
|
|
14126
|
+
let wantedPath = join13("node_modules", packageName, "package.json"), packageJsonPath = up2(wantedPath, {
|
|
14127
|
+
cwd: this.primaryPackageJson.operationDir,
|
|
14128
|
+
last: getProjectRoot()
|
|
14129
|
+
});
|
|
14127
14130
|
return packageJsonPath ? JSON.parse(readFileSync8(packageJsonPath, "utf-8")) : null;
|
|
14128
14131
|
}
|
|
14129
14132
|
getResolutions(packageJson, versions) {
|
|
@@ -14246,7 +14249,10 @@ var YARN1_ERROR_REGEX = /^error\s(.*)$/gm, Yarn1Proxy = class extends JsPackageM
|
|
|
14246
14249
|
});
|
|
14247
14250
|
}
|
|
14248
14251
|
async getModulePackageJSON(packageName) {
|
|
14249
|
-
let wantedPath = join14("node_modules", packageName, "package.json"), packageJsonPath = up2(wantedPath, {
|
|
14252
|
+
let wantedPath = join14("node_modules", packageName, "package.json"), packageJsonPath = up2(wantedPath, {
|
|
14253
|
+
cwd: this.primaryPackageJson.operationDir,
|
|
14254
|
+
last: getProjectRoot()
|
|
14255
|
+
});
|
|
14250
14256
|
return packageJsonPath ? JSON.parse(readFileSync9(packageJsonPath, "utf-8")) : null;
|
|
14251
14257
|
}
|
|
14252
14258
|
async getRegistryURL() {
|
|
@@ -14451,7 +14457,7 @@ var CRITICAL_YARN2_ERROR_CODES = {
|
|
|
14451
14457
|
// TODO: Remove pnp compatibility code in SB11
|
|
14452
14458
|
async getModulePackageJSON(packageName) {
|
|
14453
14459
|
let pnpapiPath = any([".pnp.js", ".pnp.cjs"], {
|
|
14454
|
-
cwd: this.
|
|
14460
|
+
cwd: this.primaryPackageJson.operationDir,
|
|
14455
14461
|
last: getProjectRoot()
|
|
14456
14462
|
});
|
|
14457
14463
|
if (pnpapiPath)
|
|
@@ -14721,7 +14727,7 @@ async function scanAndTransformFiles({
|
|
|
14721
14727
|
initialValue: defaultGlob
|
|
14722
14728
|
});
|
|
14723
14729
|
logger13.log("Scanning for affected files...");
|
|
14724
|
-
let globby = (await import("./globby-
|
|
14730
|
+
let globby = (await import("./globby-7IXLXFEA.js")).globby, sourceFiles = await globby([glob2], {
|
|
14725
14731
|
...commonGlobOptions(""),
|
|
14726
14732
|
ignore: ["**/node_modules/**"],
|
|
14727
14733
|
dot: !0,
|
|
@@ -14742,7 +14748,7 @@ function transformImports(source, renamedImports) {
|
|
|
14742
14748
|
return hasChanges ? transformed : null;
|
|
14743
14749
|
}
|
|
14744
14750
|
var transformImportFiles = async (files, renamedImports, dryRun) => {
|
|
14745
|
-
let errors = [], { default: pLimit } = await import("./p-limit-
|
|
14751
|
+
let errors = [], { default: pLimit } = await import("./p-limit-7GKATDEW.js"), limit = pLimit(10);
|
|
14746
14752
|
return await Promise.all(
|
|
14747
14753
|
files.map(
|
|
14748
14754
|
(file) => limit(async () => {
|
|
@@ -14772,20 +14778,33 @@ export {
|
|
|
14772
14778
|
up3 as up,
|
|
14773
14779
|
resolvePathInStorybookCache,
|
|
14774
14780
|
cache2 as cache,
|
|
14775
|
-
|
|
14781
|
+
temporaryDirectory,
|
|
14782
|
+
temporaryFile,
|
|
14783
|
+
parseList,
|
|
14784
|
+
getEnvConfig,
|
|
14785
|
+
createLogStream,
|
|
14786
|
+
isCorePackage,
|
|
14787
|
+
isSatelliteAddon,
|
|
14788
|
+
checkAddonOrder,
|
|
14776
14789
|
getProjectRoot,
|
|
14777
14790
|
invalidateProjectRootCache,
|
|
14778
14791
|
findFilesUp,
|
|
14779
14792
|
nodePathsToArray,
|
|
14780
14793
|
normalizeStoryPath,
|
|
14794
|
+
loadEnvs,
|
|
14795
|
+
stringifyEnvs,
|
|
14796
|
+
stringifyProcessEnvs,
|
|
14797
|
+
optionalEnvToBoolean,
|
|
14798
|
+
isCI,
|
|
14799
|
+
commonGlobOptions,
|
|
14800
|
+
frameworkToRenderer,
|
|
14801
|
+
frameworkToBuilder,
|
|
14802
|
+
getBuilderOptions,
|
|
14803
|
+
HandledError,
|
|
14781
14804
|
PackageManagerName,
|
|
14782
14805
|
getPackageDetails,
|
|
14783
14806
|
JsPackageManager,
|
|
14784
|
-
frameworkToRenderer,
|
|
14785
|
-
frameworkToBuilder,
|
|
14786
14807
|
getAddonNames,
|
|
14787
|
-
getFrameworkName,
|
|
14788
|
-
extractFrameworkPackageName,
|
|
14789
14808
|
getRendererName,
|
|
14790
14809
|
extractRenderer,
|
|
14791
14810
|
getStorybookConfiguration,
|
|
@@ -14797,22 +14816,8 @@ export {
|
|
|
14797
14816
|
findConfigFile,
|
|
14798
14817
|
getConfigInfo,
|
|
14799
14818
|
getStorybookInfo,
|
|
14800
|
-
|
|
14801
|
-
|
|
14802
|
-
parseList,
|
|
14803
|
-
getCoercedStorybookVersion,
|
|
14804
|
-
getEnvConfig,
|
|
14805
|
-
createLogStream,
|
|
14806
|
-
isCorePackage,
|
|
14807
|
-
isSatelliteAddon,
|
|
14808
|
-
checkAddonOrder,
|
|
14809
|
-
loadEnvs,
|
|
14810
|
-
stringifyEnvs,
|
|
14811
|
-
stringifyProcessEnvs,
|
|
14812
|
-
optionalEnvToBoolean,
|
|
14813
|
-
isCI,
|
|
14814
|
-
commonGlobOptions,
|
|
14815
|
-
getBuilderOptions,
|
|
14819
|
+
getFrameworkName,
|
|
14820
|
+
extractFrameworkPackageName,
|
|
14816
14821
|
getAutoRefs,
|
|
14817
14822
|
getRefs,
|
|
14818
14823
|
globToRegexp,
|