@storybook/cli 10.0.0-beta.6 → 10.0.0-beta.8
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/{block-dependencies-versions-JH3YVYT7.js → block-dependencies-versions-7PF6VFLK.js} +11 -11
- package/dist/_node-chunks/{block-experimental-addon-test-547DKYP6.js → block-experimental-addon-test-UZVHWL5L.js} +9 -9
- package/dist/_node-chunks/{block-major-version-CNHJBRVI.js → block-major-version-RTQDCS7T.js} +9 -9
- package/dist/_node-chunks/{block-node-version-3X26NW5I.js → block-node-version-PK2XYE6O.js} +9 -9
- package/dist/_node-chunks/{block-webpack5-frameworks-RUF4COLB.js → block-webpack5-frameworks-S4TRNJTE.js} +11 -11
- package/dist/_node-chunks/chunk-3NPIEKKJ.js +24 -0
- package/dist/_node-chunks/{chunk-DBYX7WCZ.js → chunk-5GK6BISL.js} +51 -16
- package/dist/_node-chunks/{chunk-YFERDIJG.js → chunk-DOKPKYG5.js} +7 -7
- package/dist/_node-chunks/{chunk-LCIGIRFL.js → chunk-WAFXDNPZ.js} +7 -7
- package/dist/_node-chunks/{chunk-3DG4P2SK.js → chunk-ZUZDBWGR.js} +6 -6
- package/dist/_node-chunks/{globby-NKK4SHD2.js → globby-475IGOM2.js} +8 -8
- package/dist/_node-chunks/{p-limit-BDAJ2ZPF.js → p-limit-OZUVCRX2.js} +7 -7
- package/dist/_node-chunks/{run-6B6BTUCM.js → run-EXKB3FRZ.js} +610 -131
- package/dist/bin/index.js +7 -7
- package/package.json +4 -4
- package/dist/_node-chunks/chunk-4HPAS2Q2.js +0 -24
|
@@ -1,37 +1,42 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_0cg1pmj6ouw from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_0cg1pmj6ouw from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_0cg1pmj6ouw from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_0cg1pmj6ouw.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_0cg1pmj6ouw.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_0cg1pmj6ouw.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
|
+
bannerComment,
|
|
14
|
+
containsESMUsage,
|
|
15
|
+
containsRequireUsage,
|
|
13
16
|
findFilesUp,
|
|
14
17
|
getFrameworkPackageName,
|
|
15
18
|
getProjects,
|
|
19
|
+
getRequireBanner,
|
|
16
20
|
getStorybookData,
|
|
21
|
+
hasRequireBanner,
|
|
17
22
|
processAutoblockerResults,
|
|
18
23
|
require_picocolors,
|
|
19
24
|
shortenPath,
|
|
20
25
|
updateMainConfig,
|
|
21
26
|
upgradeStorybookDependencies
|
|
22
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-5GK6BISL.js";
|
|
23
28
|
import {
|
|
24
29
|
slash
|
|
25
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-WAFXDNPZ.js";
|
|
26
31
|
import {
|
|
27
32
|
require_semver
|
|
28
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-DOKPKYG5.js";
|
|
29
34
|
import {
|
|
30
35
|
__commonJS,
|
|
31
36
|
__name,
|
|
32
37
|
__require,
|
|
33
38
|
__toESM
|
|
34
|
-
} from "./chunk-
|
|
39
|
+
} from "./chunk-ZUZDBWGR.js";
|
|
35
40
|
|
|
36
41
|
// ../../node_modules/envinfo/dist/envinfo.js
|
|
37
42
|
var require_envinfo = __commonJS({
|
|
@@ -4448,22 +4453,22 @@ var require_isexe = __commonJS({
|
|
|
4448
4453
|
// ../../node_modules/which/which.js
|
|
4449
4454
|
var require_which = __commonJS({
|
|
4450
4455
|
"../../node_modules/which/which.js"(exports, module) {
|
|
4451
|
-
var
|
|
4456
|
+
var isWindows2 = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
|
|
4452
4457
|
var path4 = __require("path");
|
|
4453
|
-
var COLON =
|
|
4458
|
+
var COLON = isWindows2 ? ";" : ":";
|
|
4454
4459
|
var isexe = require_isexe();
|
|
4455
4460
|
var getNotFoundError = /* @__PURE__ */ __name((cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" }), "getNotFoundError");
|
|
4456
4461
|
var getPathInfo = /* @__PURE__ */ __name((cmd, opt) => {
|
|
4457
4462
|
const colon = opt.colon || COLON;
|
|
4458
|
-
const pathEnv = cmd.match(/\//) ||
|
|
4463
|
+
const pathEnv = cmd.match(/\//) || isWindows2 && cmd.match(/\\/) ? [""] : [
|
|
4459
4464
|
// windows always checks the cwd first
|
|
4460
|
-
...
|
|
4465
|
+
...isWindows2 ? [process.cwd()] : [],
|
|
4461
4466
|
...(opt.path || process.env.PATH || /* istanbul ignore next: very unusual */
|
|
4462
4467
|
"").split(colon)
|
|
4463
4468
|
];
|
|
4464
|
-
const pathExtExe =
|
|
4465
|
-
const pathExt =
|
|
4466
|
-
if (
|
|
4469
|
+
const pathExtExe = isWindows2 ? opt.pathExt || process.env.PATHEXT || ".EXE;.CMD;.BAT;.COM" : "";
|
|
4470
|
+
const pathExt = isWindows2 ? pathExtExe.split(colon) : [""];
|
|
4471
|
+
if (isWindows2) {
|
|
4467
4472
|
if (cmd.indexOf(".") !== -1 && pathExt[0] !== "")
|
|
4468
4473
|
pathExt.unshift("");
|
|
4469
4474
|
}
|
|
@@ -4916,7 +4921,7 @@ __name(leven, "leven");
|
|
|
4916
4921
|
var import_picocolors17 = __toESM(require_picocolors(), 1);
|
|
4917
4922
|
|
|
4918
4923
|
// package.json
|
|
4919
|
-
var version = "10.0.0-beta.
|
|
4924
|
+
var version = "10.0.0-beta.8";
|
|
4920
4925
|
|
|
4921
4926
|
// src/add.ts
|
|
4922
4927
|
var import_semver = __toESM(require_semver(), 1);
|
|
@@ -5009,10 +5014,13 @@ function getAbsolutePathWrapperAsCallExpression(isConfigTypescript) {
|
|
|
5009
5014
|
t.identifier("resolve")
|
|
5010
5015
|
),
|
|
5011
5016
|
[
|
|
5012
|
-
t.
|
|
5013
|
-
|
|
5014
|
-
|
|
5015
|
-
|
|
5017
|
+
t.templateLiteral(
|
|
5018
|
+
[
|
|
5019
|
+
t.templateElement({ raw: "" }),
|
|
5020
|
+
t.templateElement({ raw: "/package.json" }, true)
|
|
5021
|
+
],
|
|
5022
|
+
[t.identifier("value")]
|
|
5023
|
+
)
|
|
5016
5024
|
]
|
|
5017
5025
|
)
|
|
5018
5026
|
])
|
|
@@ -5064,6 +5072,314 @@ import { createRequire, register } from "node:module";
|
|
|
5064
5072
|
import { win32 } from "node:path/win32";
|
|
5065
5073
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
5066
5074
|
|
|
5075
|
+
// ../../node_modules/exsolve/dist/index.mjs
|
|
5076
|
+
import assert from "node:assert";
|
|
5077
|
+
import v8 from "node:v8";
|
|
5078
|
+
import { format, inspect } from "node:util";
|
|
5079
|
+
var own$1 = {}.hasOwnProperty;
|
|
5080
|
+
var classRegExp = /^([A-Z][a-z\d]*)+$/;
|
|
5081
|
+
var kTypes = /* @__PURE__ */ new Set([
|
|
5082
|
+
"string",
|
|
5083
|
+
"function",
|
|
5084
|
+
"number",
|
|
5085
|
+
"object",
|
|
5086
|
+
// Accept 'Function' and 'Object' as alternative to the lower cased version.
|
|
5087
|
+
"Function",
|
|
5088
|
+
"Object",
|
|
5089
|
+
"boolean",
|
|
5090
|
+
"bigint",
|
|
5091
|
+
"symbol"
|
|
5092
|
+
]);
|
|
5093
|
+
var messages = /* @__PURE__ */ new Map();
|
|
5094
|
+
var nodeInternalPrefix = "__node_internal_";
|
|
5095
|
+
var userStackTraceLimit;
|
|
5096
|
+
function formatList(array2, type = "and") {
|
|
5097
|
+
return array2.length < 3 ? array2.join(` ${type} `) : `${array2.slice(0, -1).join(", ")}, ${type} ${array2.at(-1)}`;
|
|
5098
|
+
}
|
|
5099
|
+
__name(formatList, "formatList");
|
|
5100
|
+
function createError(sym, value, constructor) {
|
|
5101
|
+
messages.set(sym, value);
|
|
5102
|
+
return makeNodeErrorWithCode(constructor, sym);
|
|
5103
|
+
}
|
|
5104
|
+
__name(createError, "createError");
|
|
5105
|
+
function makeNodeErrorWithCode(Base, key) {
|
|
5106
|
+
return /* @__PURE__ */ __name(function NodeError(...parameters) {
|
|
5107
|
+
const limit = Error.stackTraceLimit;
|
|
5108
|
+
if (isErrorStackTraceLimitWritable()) Error.stackTraceLimit = 0;
|
|
5109
|
+
const error = new Base();
|
|
5110
|
+
if (isErrorStackTraceLimitWritable()) Error.stackTraceLimit = limit;
|
|
5111
|
+
const message = getMessage(key, parameters, error);
|
|
5112
|
+
Object.defineProperties(error, {
|
|
5113
|
+
// Note: no need to implement `kIsNodeError` symbol, would be hard,
|
|
5114
|
+
// probably.
|
|
5115
|
+
message: {
|
|
5116
|
+
value: message,
|
|
5117
|
+
enumerable: false,
|
|
5118
|
+
writable: true,
|
|
5119
|
+
configurable: true
|
|
5120
|
+
},
|
|
5121
|
+
toString: {
|
|
5122
|
+
/** @this {Error} */
|
|
5123
|
+
value() {
|
|
5124
|
+
return `${this.name} [${key}]: ${this.message}`;
|
|
5125
|
+
},
|
|
5126
|
+
enumerable: false,
|
|
5127
|
+
writable: true,
|
|
5128
|
+
configurable: true
|
|
5129
|
+
}
|
|
5130
|
+
});
|
|
5131
|
+
captureLargerStackTrace(error);
|
|
5132
|
+
error.code = key;
|
|
5133
|
+
return error;
|
|
5134
|
+
}, "NodeError");
|
|
5135
|
+
}
|
|
5136
|
+
__name(makeNodeErrorWithCode, "makeNodeErrorWithCode");
|
|
5137
|
+
function isErrorStackTraceLimitWritable() {
|
|
5138
|
+
try {
|
|
5139
|
+
if (v8.startupSnapshot.isBuildingSnapshot()) {
|
|
5140
|
+
return false;
|
|
5141
|
+
}
|
|
5142
|
+
} catch {
|
|
5143
|
+
}
|
|
5144
|
+
const desc = Object.getOwnPropertyDescriptor(Error, "stackTraceLimit");
|
|
5145
|
+
if (desc === void 0) {
|
|
5146
|
+
return Object.isExtensible(Error);
|
|
5147
|
+
}
|
|
5148
|
+
return own$1.call(desc, "writable") && desc.writable !== void 0 ? desc.writable : desc.set !== void 0;
|
|
5149
|
+
}
|
|
5150
|
+
__name(isErrorStackTraceLimitWritable, "isErrorStackTraceLimitWritable");
|
|
5151
|
+
function hideStackFrames(wrappedFunction) {
|
|
5152
|
+
const hidden = nodeInternalPrefix + wrappedFunction.name;
|
|
5153
|
+
Object.defineProperty(wrappedFunction, "name", { value: hidden });
|
|
5154
|
+
return wrappedFunction;
|
|
5155
|
+
}
|
|
5156
|
+
__name(hideStackFrames, "hideStackFrames");
|
|
5157
|
+
var captureLargerStackTrace = hideStackFrames(function(error) {
|
|
5158
|
+
const stackTraceLimitIsWritable = isErrorStackTraceLimitWritable();
|
|
5159
|
+
if (stackTraceLimitIsWritable) {
|
|
5160
|
+
userStackTraceLimit = Error.stackTraceLimit;
|
|
5161
|
+
Error.stackTraceLimit = Number.POSITIVE_INFINITY;
|
|
5162
|
+
}
|
|
5163
|
+
Error.captureStackTrace(error);
|
|
5164
|
+
if (stackTraceLimitIsWritable) Error.stackTraceLimit = userStackTraceLimit;
|
|
5165
|
+
return error;
|
|
5166
|
+
});
|
|
5167
|
+
function getMessage(key, parameters, self2) {
|
|
5168
|
+
const message = messages.get(key);
|
|
5169
|
+
assert(message !== void 0, "expected `message` to be found");
|
|
5170
|
+
if (typeof message === "function") {
|
|
5171
|
+
assert(
|
|
5172
|
+
message.length <= parameters.length,
|
|
5173
|
+
// Default options do not count.
|
|
5174
|
+
`Code: ${key}; The provided arguments length (${parameters.length}) does not match the required ones (${message.length}).`
|
|
5175
|
+
);
|
|
5176
|
+
return Reflect.apply(message, self2, parameters);
|
|
5177
|
+
}
|
|
5178
|
+
const regex = /%[dfijoOs]/g;
|
|
5179
|
+
let expectedLength = 0;
|
|
5180
|
+
while (regex.exec(message) !== null) expectedLength++;
|
|
5181
|
+
assert(
|
|
5182
|
+
expectedLength === parameters.length,
|
|
5183
|
+
`Code: ${key}; The provided arguments length (${parameters.length}) does not match the required ones (${expectedLength}).`
|
|
5184
|
+
);
|
|
5185
|
+
if (parameters.length === 0) return message;
|
|
5186
|
+
parameters.unshift(message);
|
|
5187
|
+
return Reflect.apply(format, null, parameters);
|
|
5188
|
+
}
|
|
5189
|
+
__name(getMessage, "getMessage");
|
|
5190
|
+
function determineSpecificType(value) {
|
|
5191
|
+
if (value === null || value === void 0) {
|
|
5192
|
+
return String(value);
|
|
5193
|
+
}
|
|
5194
|
+
if (typeof value === "function" && value.name) {
|
|
5195
|
+
return `function ${value.name}`;
|
|
5196
|
+
}
|
|
5197
|
+
if (typeof value === "object") {
|
|
5198
|
+
if (value.constructor && value.constructor.name) {
|
|
5199
|
+
return `an instance of ${value.constructor.name}`;
|
|
5200
|
+
}
|
|
5201
|
+
return `${inspect(value, { depth: -1 })}`;
|
|
5202
|
+
}
|
|
5203
|
+
let inspected = inspect(value, { colors: false });
|
|
5204
|
+
if (inspected.length > 28) {
|
|
5205
|
+
inspected = `${inspected.slice(0, 25)}...`;
|
|
5206
|
+
}
|
|
5207
|
+
return `type ${typeof value} (${inspected})`;
|
|
5208
|
+
}
|
|
5209
|
+
__name(determineSpecificType, "determineSpecificType");
|
|
5210
|
+
createError(
|
|
5211
|
+
"ERR_INVALID_ARG_TYPE",
|
|
5212
|
+
(name, expected, actual) => {
|
|
5213
|
+
assert(typeof name === "string", "'name' must be a string");
|
|
5214
|
+
if (!Array.isArray(expected)) {
|
|
5215
|
+
expected = [expected];
|
|
5216
|
+
}
|
|
5217
|
+
let message = "The ";
|
|
5218
|
+
if (name.endsWith(" argument")) {
|
|
5219
|
+
message += `${name} `;
|
|
5220
|
+
} else {
|
|
5221
|
+
const type = name.includes(".") ? "property" : "argument";
|
|
5222
|
+
message += `"${name}" ${type} `;
|
|
5223
|
+
}
|
|
5224
|
+
message += "must be ";
|
|
5225
|
+
const types = [];
|
|
5226
|
+
const instances = [];
|
|
5227
|
+
const other = [];
|
|
5228
|
+
for (const value of expected) {
|
|
5229
|
+
assert(
|
|
5230
|
+
typeof value === "string",
|
|
5231
|
+
"All expected entries have to be of type string"
|
|
5232
|
+
);
|
|
5233
|
+
if (kTypes.has(value)) {
|
|
5234
|
+
types.push(value.toLowerCase());
|
|
5235
|
+
} else if (classRegExp.exec(value) === null) {
|
|
5236
|
+
assert(
|
|
5237
|
+
value !== "object",
|
|
5238
|
+
'The value "object" should be written as "Object"'
|
|
5239
|
+
);
|
|
5240
|
+
other.push(value);
|
|
5241
|
+
} else {
|
|
5242
|
+
instances.push(value);
|
|
5243
|
+
}
|
|
5244
|
+
}
|
|
5245
|
+
if (instances.length > 0) {
|
|
5246
|
+
const pos = types.indexOf("object");
|
|
5247
|
+
if (pos !== -1) {
|
|
5248
|
+
types.slice(pos, 1);
|
|
5249
|
+
instances.push("Object");
|
|
5250
|
+
}
|
|
5251
|
+
}
|
|
5252
|
+
if (types.length > 0) {
|
|
5253
|
+
message += `${types.length > 1 ? "one of type" : "of type"} ${formatList(
|
|
5254
|
+
types,
|
|
5255
|
+
"or"
|
|
5256
|
+
)}`;
|
|
5257
|
+
if (instances.length > 0 || other.length > 0) message += " or ";
|
|
5258
|
+
}
|
|
5259
|
+
if (instances.length > 0) {
|
|
5260
|
+
message += `an instance of ${formatList(instances, "or")}`;
|
|
5261
|
+
if (other.length > 0) message += " or ";
|
|
5262
|
+
}
|
|
5263
|
+
if (other.length > 0) {
|
|
5264
|
+
if (other.length > 1) {
|
|
5265
|
+
message += `one of ${formatList(other, "or")}`;
|
|
5266
|
+
} else {
|
|
5267
|
+
if (other[0]?.toLowerCase() !== other[0]) message += "an ";
|
|
5268
|
+
message += `${other[0]}`;
|
|
5269
|
+
}
|
|
5270
|
+
}
|
|
5271
|
+
message += `. Received ${determineSpecificType(actual)}`;
|
|
5272
|
+
return message;
|
|
5273
|
+
},
|
|
5274
|
+
TypeError
|
|
5275
|
+
);
|
|
5276
|
+
var ERR_INVALID_MODULE_SPECIFIER = createError(
|
|
5277
|
+
"ERR_INVALID_MODULE_SPECIFIER",
|
|
5278
|
+
/**
|
|
5279
|
+
* @param {string} request
|
|
5280
|
+
* @param {string} reason
|
|
5281
|
+
* @param {string} [base]
|
|
5282
|
+
*/
|
|
5283
|
+
(request, reason, base) => {
|
|
5284
|
+
return `Invalid module "${request}" ${reason}${base ? ` imported from ${base}` : ""}`;
|
|
5285
|
+
},
|
|
5286
|
+
TypeError
|
|
5287
|
+
);
|
|
5288
|
+
var ERR_INVALID_PACKAGE_CONFIG = createError(
|
|
5289
|
+
"ERR_INVALID_PACKAGE_CONFIG",
|
|
5290
|
+
(path4, base, message) => {
|
|
5291
|
+
return `Invalid package config ${path4}${base ? ` while importing ${base}` : ""}${message ? `. ${message}` : ""}`;
|
|
5292
|
+
},
|
|
5293
|
+
Error
|
|
5294
|
+
);
|
|
5295
|
+
var ERR_INVALID_PACKAGE_TARGET = createError(
|
|
5296
|
+
"ERR_INVALID_PACKAGE_TARGET",
|
|
5297
|
+
(packagePath, key, target, isImport = false, base) => {
|
|
5298
|
+
const relatedError = typeof target === "string" && !isImport && target.length > 0 && !target.startsWith("./");
|
|
5299
|
+
if (key === ".") {
|
|
5300
|
+
assert(isImport === false);
|
|
5301
|
+
return `Invalid "exports" main target ${JSON.stringify(target)} defined in the package config ${packagePath}package.json${base ? ` imported from ${base}` : ""}${relatedError ? '; targets must start with "./"' : ""}`;
|
|
5302
|
+
}
|
|
5303
|
+
return `Invalid "${isImport ? "imports" : "exports"}" target ${JSON.stringify(
|
|
5304
|
+
target
|
|
5305
|
+
)} defined for '${key}' in the package config ${packagePath}package.json${base ? ` imported from ${base}` : ""}${relatedError ? '; targets must start with "./"' : ""}`;
|
|
5306
|
+
},
|
|
5307
|
+
Error
|
|
5308
|
+
);
|
|
5309
|
+
var ERR_MODULE_NOT_FOUND = createError(
|
|
5310
|
+
"ERR_MODULE_NOT_FOUND",
|
|
5311
|
+
(path4, base, exactUrl = false) => {
|
|
5312
|
+
return `Cannot find ${exactUrl ? "module" : "package"} '${path4}' imported from ${base}`;
|
|
5313
|
+
},
|
|
5314
|
+
Error
|
|
5315
|
+
);
|
|
5316
|
+
createError(
|
|
5317
|
+
"ERR_NETWORK_IMPORT_DISALLOWED",
|
|
5318
|
+
"import of '%s' by %s is not supported: %s",
|
|
5319
|
+
Error
|
|
5320
|
+
);
|
|
5321
|
+
var ERR_PACKAGE_IMPORT_NOT_DEFINED = createError(
|
|
5322
|
+
"ERR_PACKAGE_IMPORT_NOT_DEFINED",
|
|
5323
|
+
(specifier, packagePath, base) => {
|
|
5324
|
+
return `Package import specifier "${specifier}" is not defined${packagePath ? ` in package ${packagePath || ""}package.json` : ""} imported from ${base}`;
|
|
5325
|
+
},
|
|
5326
|
+
TypeError
|
|
5327
|
+
);
|
|
5328
|
+
var ERR_PACKAGE_PATH_NOT_EXPORTED = createError(
|
|
5329
|
+
"ERR_PACKAGE_PATH_NOT_EXPORTED",
|
|
5330
|
+
/**
|
|
5331
|
+
* @param {string} packagePath
|
|
5332
|
+
* @param {string} subpath
|
|
5333
|
+
* @param {string} [base]
|
|
5334
|
+
*/
|
|
5335
|
+
(packagePath, subpath, base) => {
|
|
5336
|
+
if (subpath === ".")
|
|
5337
|
+
return `No "exports" main defined in ${packagePath}package.json${base ? ` imported from ${base}` : ""}`;
|
|
5338
|
+
return `Package subpath '${subpath}' is not defined by "exports" in ${packagePath}package.json${base ? ` imported from ${base}` : ""}`;
|
|
5339
|
+
},
|
|
5340
|
+
Error
|
|
5341
|
+
);
|
|
5342
|
+
var ERR_UNSUPPORTED_DIR_IMPORT = createError(
|
|
5343
|
+
"ERR_UNSUPPORTED_DIR_IMPORT",
|
|
5344
|
+
"Directory import '%s' is not supported resolving ES modules imported from %s",
|
|
5345
|
+
Error
|
|
5346
|
+
);
|
|
5347
|
+
var ERR_UNSUPPORTED_RESOLVE_REQUEST = createError(
|
|
5348
|
+
"ERR_UNSUPPORTED_RESOLVE_REQUEST",
|
|
5349
|
+
'Failed to resolve module specifier "%s" from "%s": Invalid relative URL or base scheme is not hierarchical.',
|
|
5350
|
+
TypeError
|
|
5351
|
+
);
|
|
5352
|
+
var ERR_UNKNOWN_FILE_EXTENSION = createError(
|
|
5353
|
+
"ERR_UNKNOWN_FILE_EXTENSION",
|
|
5354
|
+
(extension, path4) => {
|
|
5355
|
+
return `Unknown file extension "${extension}" for ${path4}`;
|
|
5356
|
+
},
|
|
5357
|
+
TypeError
|
|
5358
|
+
);
|
|
5359
|
+
createError(
|
|
5360
|
+
"ERR_INVALID_ARG_VALUE",
|
|
5361
|
+
(name, value, reason = "is invalid") => {
|
|
5362
|
+
let inspected = inspect(value);
|
|
5363
|
+
if (inspected.length > 128) {
|
|
5364
|
+
inspected = `${inspected.slice(0, 128)}...`;
|
|
5365
|
+
}
|
|
5366
|
+
const type = name.includes(".") ? "property" : "argument";
|
|
5367
|
+
return `The ${type} '${name}' ${reason}. Received ${inspected}`;
|
|
5368
|
+
},
|
|
5369
|
+
TypeError
|
|
5370
|
+
// Note: extra classes have been shaken out.
|
|
5371
|
+
// , RangeError
|
|
5372
|
+
);
|
|
5373
|
+
var hasOwnProperty$1 = {}.hasOwnProperty;
|
|
5374
|
+
var hasOwnProperty = {}.hasOwnProperty;
|
|
5375
|
+
var RegExpPrototypeSymbolReplace = RegExp.prototype[Symbol.replace];
|
|
5376
|
+
var own = {}.hasOwnProperty;
|
|
5377
|
+
var isWindows = (() => process.platform === "win32")();
|
|
5378
|
+
var globalCache = (() => (
|
|
5379
|
+
// eslint-disable-next-line unicorn/no-unreadable-iife
|
|
5380
|
+
globalThis["__EXSOLVE_CACHE__"] ||= /* @__PURE__ */ new Map()
|
|
5381
|
+
))();
|
|
5382
|
+
|
|
5067
5383
|
// ../../node_modules/pathe/dist/shared/pathe.ff20891b.mjs
|
|
5068
5384
|
var _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
|
|
5069
5385
|
function normalizeWindowsPath(input = "") {
|
|
@@ -5387,7 +5703,7 @@ function invariant(condition, message) {
|
|
|
5387
5703
|
__name(invariant, "invariant");
|
|
5388
5704
|
|
|
5389
5705
|
// src/automigrate/index.ts
|
|
5390
|
-
import { dedent as
|
|
5706
|
+
import { dedent as dedent13 } from "ts-dedent";
|
|
5391
5707
|
|
|
5392
5708
|
// src/doctor/index.ts
|
|
5393
5709
|
var import_picocolors4 = __toESM(require_picocolors(), 1);
|
|
@@ -5456,7 +5772,7 @@ function getDuplicatedDepsWarnings(installationMetadata) {
|
|
|
5456
5772
|
if (!installationMetadata || !installationMetadata?.duplicatedDependencies || Object.keys(installationMetadata.duplicatedDependencies).length === 0) {
|
|
5457
5773
|
return void 0;
|
|
5458
5774
|
}
|
|
5459
|
-
const
|
|
5775
|
+
const messages2 = [];
|
|
5460
5776
|
const { critical, trivial } = Object.entries(
|
|
5461
5777
|
installationMetadata?.duplicatedDependencies
|
|
5462
5778
|
).reduce(
|
|
@@ -5479,37 +5795,37 @@ ${packageVersions.join(", ")}`);
|
|
|
5479
5795
|
{ critical: [], trivial: [] }
|
|
5480
5796
|
);
|
|
5481
5797
|
if (critical.length === 0 && trivial.length === 0) {
|
|
5482
|
-
return
|
|
5798
|
+
return messages2;
|
|
5483
5799
|
}
|
|
5484
5800
|
if (critical.length > 0) {
|
|
5485
|
-
|
|
5801
|
+
messages2.push(
|
|
5486
5802
|
`${import_picocolors.default.bold(
|
|
5487
5803
|
"Critical:"
|
|
5488
5804
|
)} The following dependencies are duplicated and WILL cause unexpected behavior:`
|
|
5489
5805
|
);
|
|
5490
|
-
|
|
5806
|
+
messages2.push(critical.join(messageDivider), "\n");
|
|
5491
5807
|
}
|
|
5492
5808
|
if (trivial.length > 0) {
|
|
5493
|
-
|
|
5809
|
+
messages2.push(
|
|
5494
5810
|
`${import_picocolors.default.bold(
|
|
5495
5811
|
"Attention:"
|
|
5496
5812
|
)} The following dependencies are duplicated which might cause unexpected behavior:`
|
|
5497
5813
|
);
|
|
5498
|
-
|
|
5814
|
+
messages2.push(trivial.join(messageDivider));
|
|
5499
5815
|
}
|
|
5500
|
-
|
|
5816
|
+
messages2.push(
|
|
5501
5817
|
"\n",
|
|
5502
5818
|
`Please try de-duplicating these dependencies by running ${import_picocolors.default.cyan(
|
|
5503
5819
|
`${installationMetadata.dedupeCommand}`
|
|
5504
5820
|
)}`
|
|
5505
5821
|
);
|
|
5506
|
-
|
|
5822
|
+
messages2.push(
|
|
5507
5823
|
"\n",
|
|
5508
5824
|
`You can find more information for a given dependency by running ${import_picocolors.default.cyan(
|
|
5509
5825
|
`${installationMetadata.infoCommand} <package-name>`
|
|
5510
5826
|
)}`
|
|
5511
5827
|
);
|
|
5512
|
-
return
|
|
5828
|
+
return messages2;
|
|
5513
5829
|
} catch (err) {
|
|
5514
5830
|
return void 0;
|
|
5515
5831
|
}
|
|
@@ -5684,7 +6000,7 @@ function getMismatchingVersionsWarnings(installationMetadata) {
|
|
|
5684
6000
|
if (!installationMetadata) {
|
|
5685
6001
|
return void 0;
|
|
5686
6002
|
}
|
|
5687
|
-
const
|
|
6003
|
+
const messages2 = [];
|
|
5688
6004
|
try {
|
|
5689
6005
|
const frameworkPackageName = Object.keys(installationMetadata?.dependencies || []).find(
|
|
5690
6006
|
(packageName) => {
|
|
@@ -5696,7 +6012,7 @@ function getMismatchingVersionsWarnings(installationMetadata) {
|
|
|
5696
6012
|
if (!cliVersion || !frameworkVersion || import_semver4.default.eq(cliVersion, frameworkVersion)) {
|
|
5697
6013
|
return void 0;
|
|
5698
6014
|
}
|
|
5699
|
-
|
|
6015
|
+
messages2.push(
|
|
5700
6016
|
`${import_picocolors3.default.bold(
|
|
5701
6017
|
"Attention:"
|
|
5702
6018
|
)} There seems to be a mismatch between your Storybook package versions. This can result in a broken Storybook installation.`
|
|
@@ -5710,7 +6026,7 @@ function getMismatchingVersionsWarnings(installationMetadata) {
|
|
|
5710
6026
|
versionToCompare = cliVersion;
|
|
5711
6027
|
packageToDisplay = "storybook";
|
|
5712
6028
|
}
|
|
5713
|
-
|
|
6029
|
+
messages2.push(
|
|
5714
6030
|
`The version of your storybook core packages should align with ${import_picocolors3.default.yellow(
|
|
5715
6031
|
versionToCompare
|
|
5716
6032
|
)} (from the ${import_picocolors3.default.cyan(packageToDisplay)} package) or higher.`
|
|
@@ -5725,17 +6041,17 @@ function getMismatchingVersionsWarnings(installationMetadata) {
|
|
|
5725
6041
|
}
|
|
5726
6042
|
);
|
|
5727
6043
|
if (filteredDependencies.length > 0) {
|
|
5728
|
-
|
|
6044
|
+
messages2.push(
|
|
5729
6045
|
`Based on your lockfile, these dependencies should be aligned:`,
|
|
5730
6046
|
filteredDependencies.map(([name, dep]) => `${import_picocolors3.default.yellow(name)}: ${dep[0].version}`).join("\n")
|
|
5731
6047
|
);
|
|
5732
6048
|
}
|
|
5733
|
-
|
|
6049
|
+
messages2.push(
|
|
5734
6050
|
`You can run ${import_picocolors3.default.cyan("npx storybook@latest upgrade")} to upgrade all of your Storybook packages to the latest version.
|
|
5735
6051
|
|
|
5736
6052
|
Alternatively you can try manually changing the versions to match in your package.json. We also recommend regenerating your lockfile, or running the following command to possibly deduplicate your Storybook package versions: ${import_picocolors3.default.cyan(installationMetadata?.dedupeCommand)}`
|
|
5737
6053
|
);
|
|
5738
|
-
return
|
|
6054
|
+
return messages2.join("\n\n");
|
|
5739
6055
|
} catch (err) {
|
|
5740
6056
|
return void 0;
|
|
5741
6057
|
}
|
|
@@ -6016,7 +6332,7 @@ async function collectDoctorResultsByProject(projectOptions) {
|
|
|
6016
6332
|
try {
|
|
6017
6333
|
const checkResults = await getDoctorDiagnostics(options);
|
|
6018
6334
|
const diagnostics = {};
|
|
6019
|
-
const
|
|
6335
|
+
const messages2 = {};
|
|
6020
6336
|
Object.values(DiagnosticType).forEach((type) => {
|
|
6021
6337
|
diagnostics[type] = "passed" /* PASSED */;
|
|
6022
6338
|
});
|
|
@@ -6030,30 +6346,30 @@ async function collectDoctorResultsByProject(projectOptions) {
|
|
|
6030
6346
|
diagnostics[checkResult.type] = "has_issues" /* HAS_ISSUES */;
|
|
6031
6347
|
hasIssues = true;
|
|
6032
6348
|
}
|
|
6033
|
-
|
|
6349
|
+
messages2[checkResult.type] = checkResult.message;
|
|
6034
6350
|
}
|
|
6035
6351
|
const status = hasErrors ? "check_error" : hasIssues ? "has_issues" : "healthy";
|
|
6036
6352
|
projectResults[configDir] = {
|
|
6037
6353
|
configDir,
|
|
6038
6354
|
status,
|
|
6039
6355
|
diagnostics,
|
|
6040
|
-
messages
|
|
6356
|
+
messages: messages2
|
|
6041
6357
|
};
|
|
6042
6358
|
} catch (error) {
|
|
6043
6359
|
logger2.error(`Failed to run doctor checks for project ${configDir}:
|
|
6044
6360
|
${error}`);
|
|
6045
6361
|
const diagnostics = {};
|
|
6046
|
-
const
|
|
6362
|
+
const messages2 = {};
|
|
6047
6363
|
Object.values(DiagnosticType).forEach((type) => {
|
|
6048
6364
|
diagnostics[type] = "passed" /* PASSED */;
|
|
6049
6365
|
});
|
|
6050
6366
|
diagnostics["configuration_error" /* CONFIGURATION_ERROR */] = "check_error" /* CHECK_ERROR */;
|
|
6051
|
-
|
|
6367
|
+
messages2["configuration_error" /* CONFIGURATION_ERROR */] = `Failed to run doctor checks: ${error instanceof Error ? error.message : String(error)}`;
|
|
6052
6368
|
projectResults[configDir] = {
|
|
6053
6369
|
configDir,
|
|
6054
6370
|
status: "check_error",
|
|
6055
6371
|
diagnostics,
|
|
6056
|
-
messages
|
|
6372
|
+
messages: messages2
|
|
6057
6373
|
};
|
|
6058
6374
|
}
|
|
6059
6375
|
}
|
|
@@ -6081,7 +6397,7 @@ async function runCodemod(globPattern = "**/*.stories.*", transform, { dryRun =
|
|
|
6081
6397
|
let modifiedCount = 0;
|
|
6082
6398
|
let unmodifiedCount = 0;
|
|
6083
6399
|
let errorCount = 0;
|
|
6084
|
-
const { globby } = await import("./globby-
|
|
6400
|
+
const { globby } = await import("./globby-475IGOM2.js");
|
|
6085
6401
|
const files = await globby(slash(globPattern), {
|
|
6086
6402
|
followSymbolicLinks: true,
|
|
6087
6403
|
ignore: ["**/node_modules/**", "**/dist/**", "**/storybook-static/**", "**/build/**"]
|
|
@@ -6095,7 +6411,7 @@ Please try a different pattern.
|
|
|
6095
6411
|
throw new Error("No files matched");
|
|
6096
6412
|
}
|
|
6097
6413
|
try {
|
|
6098
|
-
const pLimit = (await import("./p-limit-
|
|
6414
|
+
const pLimit = (await import("./p-limit-OZUVCRX2.js")).default;
|
|
6099
6415
|
const limit = pLimit(maxConcurrentTasks);
|
|
6100
6416
|
await Promise.all(
|
|
6101
6417
|
files.map(
|
|
@@ -6256,8 +6572,37 @@ ${err}`);
|
|
|
6256
6572
|
const defineConfigProps = getConfigProperties(exportDecls, { configType });
|
|
6257
6573
|
const hasNamedExports = defineConfigProps.length > 0;
|
|
6258
6574
|
if (config._exportsObject && hasNamedExports) {
|
|
6259
|
-
config._exportsObject.properties
|
|
6575
|
+
config._exportsObject.properties = [...defineConfigProps, ...config._exportsObject.properties];
|
|
6260
6576
|
programNode.body = removeExportDeclarations(programNode, exportDecls);
|
|
6577
|
+
const defineConfigCall = t3.callExpression(t3.identifier(methodName), [config._exportsObject]);
|
|
6578
|
+
let exportDefaultNode = null;
|
|
6579
|
+
let declarationNodeIndex = -1;
|
|
6580
|
+
programNode.body.forEach((node) => {
|
|
6581
|
+
if (t3.isExportDefaultDeclaration(node) && t3.isIdentifier(node.declaration)) {
|
|
6582
|
+
const declarationName = node.declaration.name;
|
|
6583
|
+
declarationNodeIndex = programNode.body.findIndex(
|
|
6584
|
+
(n) => t3.isVariableDeclaration(n) && n.declarations.some(
|
|
6585
|
+
(d) => t3.isIdentifier(d.id) && d.id.name === declarationName && t3.isObjectExpression(d.init)
|
|
6586
|
+
)
|
|
6587
|
+
);
|
|
6588
|
+
if (declarationNodeIndex !== -1) {
|
|
6589
|
+
exportDefaultNode = node;
|
|
6590
|
+
const declarationNode = programNode.body[declarationNodeIndex];
|
|
6591
|
+
if (t3.isVariableDeclaration(declarationNode)) {
|
|
6592
|
+
const id = declarationNode.declarations[0].id;
|
|
6593
|
+
const variableName = t3.isIdentifier(id) && id.name;
|
|
6594
|
+
if (variableName) {
|
|
6595
|
+
programNode.body.splice(declarationNodeIndex, 1);
|
|
6596
|
+
}
|
|
6597
|
+
}
|
|
6598
|
+
}
|
|
6599
|
+
} else if (t3.isExportDefaultDeclaration(node) && t3.isObjectExpression(node.declaration)) {
|
|
6600
|
+
exportDefaultNode = node;
|
|
6601
|
+
}
|
|
6602
|
+
});
|
|
6603
|
+
if (exportDefaultNode !== null) {
|
|
6604
|
+
exportDefaultNode.declaration = defineConfigCall;
|
|
6605
|
+
}
|
|
6261
6606
|
} else if (config._exportsObject) {
|
|
6262
6607
|
const defineConfigCall = t3.callExpression(t3.identifier(methodName), [config._exportsObject]);
|
|
6263
6608
|
let exportDefaultNode = null;
|
|
@@ -6350,6 +6695,9 @@ async function storyToCsfFactory(info, { previewConfigPath, useSubPathImports })
|
|
|
6350
6695
|
${err}`);
|
|
6351
6696
|
return info.source;
|
|
6352
6697
|
}
|
|
6698
|
+
const detectedStories = csf.stories;
|
|
6699
|
+
const detectedStoryNames = detectedStories.map((story) => story.name);
|
|
6700
|
+
const transformedStoryExports = /* @__PURE__ */ new Set();
|
|
6353
6701
|
const metaVariableName = csf._metaVariableName ?? "meta";
|
|
6354
6702
|
const programNode = csf._ast.program;
|
|
6355
6703
|
let previewImport;
|
|
@@ -6382,7 +6730,7 @@ ${err}`);
|
|
|
6382
6730
|
}
|
|
6383
6731
|
});
|
|
6384
6732
|
const hasMeta = !!csf._meta;
|
|
6385
|
-
Object.entries(csf._storyExports).forEach(([
|
|
6733
|
+
Object.entries(csf._storyExports).forEach(([exportName, decl]) => {
|
|
6386
6734
|
const id = decl.id;
|
|
6387
6735
|
const declarator = decl;
|
|
6388
6736
|
let init = t4.isVariableDeclarator(declarator) ? declarator.init : void 0;
|
|
@@ -6398,11 +6746,37 @@ ${err}`);
|
|
|
6398
6746
|
t4.memberExpression(t4.identifier(metaVariableName), t4.identifier("story")),
|
|
6399
6747
|
init.properties.length === 0 ? [] : [init]
|
|
6400
6748
|
);
|
|
6749
|
+
if (t4.isIdentifier(id)) {
|
|
6750
|
+
transformedStoryExports.add(exportName);
|
|
6751
|
+
}
|
|
6401
6752
|
} else if (t4.isArrowFunctionExpression(init)) {
|
|
6402
6753
|
declarator.init = t4.callExpression(
|
|
6403
6754
|
t4.memberExpression(t4.identifier(metaVariableName), t4.identifier("story")),
|
|
6404
6755
|
[init]
|
|
6405
6756
|
);
|
|
6757
|
+
if (t4.isIdentifier(id)) {
|
|
6758
|
+
transformedStoryExports.add(exportName);
|
|
6759
|
+
}
|
|
6760
|
+
}
|
|
6761
|
+
}
|
|
6762
|
+
});
|
|
6763
|
+
Object.entries(csf._storyExports).forEach(([exportName, decl]) => {
|
|
6764
|
+
if (t4.isFunctionDeclaration(decl) && decl.id) {
|
|
6765
|
+
const arrowFn = t4.arrowFunctionExpression(decl.params, decl.body);
|
|
6766
|
+
arrowFn.async = !!decl.async;
|
|
6767
|
+
const wrappedCall = t4.callExpression(
|
|
6768
|
+
t4.memberExpression(t4.identifier(metaVariableName), t4.identifier("story")),
|
|
6769
|
+
[arrowFn]
|
|
6770
|
+
);
|
|
6771
|
+
const replacement = t4.exportNamedDeclaration(
|
|
6772
|
+
t4.variableDeclaration("const", [
|
|
6773
|
+
t4.variableDeclarator(t4.identifier(exportName), wrappedCall)
|
|
6774
|
+
])
|
|
6775
|
+
);
|
|
6776
|
+
const pathForExport = csf._storyPaths?.[exportName];
|
|
6777
|
+
if (pathForExport && pathForExport.replaceWith) {
|
|
6778
|
+
pathForExport.replaceWith(replacement);
|
|
6779
|
+
transformedStoryExports.add(exportName);
|
|
6406
6780
|
}
|
|
6407
6781
|
}
|
|
6408
6782
|
});
|
|
@@ -6448,6 +6822,13 @@ ${err}`);
|
|
|
6448
6822
|
}
|
|
6449
6823
|
}
|
|
6450
6824
|
});
|
|
6825
|
+
if (detectedStoryNames.length > 0 && transformedStoryExports.size > 0 && transformedStoryExports.size !== detectedStoryNames.length) {
|
|
6826
|
+
logger5.warn(
|
|
6827
|
+
`Skipping codemod for ${info.path}:
|
|
6828
|
+
Some of the detected stories [${detectedStoryNames.map((name) => `"${name}"`).join(", ")}] would not be transformed because they are written in an unsupported format.`
|
|
6829
|
+
);
|
|
6830
|
+
return info.source;
|
|
6831
|
+
}
|
|
6451
6832
|
if (csf._metaPath) {
|
|
6452
6833
|
let declaration = csf._metaPath.node.declaration;
|
|
6453
6834
|
if (t4.isTSSatisfiesExpression(declaration) || t4.isTSAsExpression(declaration)) {
|
|
@@ -6524,7 +6905,7 @@ async function runStoriesCodemod(options) {
|
|
|
6524
6905
|
logger6.log("Please enter the glob for your stories to migrate");
|
|
6525
6906
|
globString = await prompt2.text({
|
|
6526
6907
|
message: "glob",
|
|
6527
|
-
initialValue: "
|
|
6908
|
+
initialValue: "**/*.stories.*"
|
|
6528
6909
|
});
|
|
6529
6910
|
}
|
|
6530
6911
|
logger6.log("\n\u{1F6E0}\uFE0F Applying codemod on your stories, this might take some time...");
|
|
@@ -6558,7 +6939,7 @@ var csfFactories = {
|
|
|
6558
6939
|
let useSubPathImports = true;
|
|
6559
6940
|
if (!optionalEnvToBoolean(process.env.IN_STORYBOOK_SANDBOX)) {
|
|
6560
6941
|
logger6.logBox(dedent3`
|
|
6561
|
-
The CSF factories format benefits from subpath imports (the imports property in your \`package.json\`), which is a node standard for module resolution. This makes it more convenient to import the preview config in your story files.
|
|
6942
|
+
The CSF factories format benefits from subpath imports (the imports property in your \`package.json\`), which is a node standard for module resolution (commonly known as alias imports). This makes it more convenient to import the preview config in your story files.
|
|
6562
6943
|
|
|
6563
6944
|
However, please note that this might not work if you have an outdated tsconfig, use custom paths, or have type alias plugins configured in your project. You can always rerun this codemod and select another option to update your code later.
|
|
6564
6945
|
|
|
@@ -6572,7 +6953,7 @@ var csfFactories = {
|
|
|
6572
6953
|
useSubPathImports = await prompt2.select({
|
|
6573
6954
|
message: "Which would you like to use?",
|
|
6574
6955
|
options: [
|
|
6575
|
-
{ label: "Subpath imports", value: true },
|
|
6956
|
+
{ label: "Subpath imports (alias)", value: true },
|
|
6576
6957
|
{ label: "Relative imports", value: false }
|
|
6577
6958
|
]
|
|
6578
6959
|
});
|
|
@@ -7033,7 +7414,7 @@ var addonA11yParameters = {
|
|
|
7033
7414
|
}
|
|
7034
7415
|
}
|
|
7035
7416
|
}
|
|
7036
|
-
const { default: pLimit } = await import("./p-limit-
|
|
7417
|
+
const { default: pLimit } = await import("./p-limit-OZUVCRX2.js");
|
|
7037
7418
|
const limit = pLimit(10);
|
|
7038
7419
|
await Promise.all(
|
|
7039
7420
|
storyFilesToUpdate.map(
|
|
@@ -7279,7 +7660,7 @@ function transformPackageJson(content) {
|
|
|
7279
7660
|
__name(transformPackageJson, "transformPackageJson");
|
|
7280
7661
|
var transformPackageJsonFiles = /* @__PURE__ */ __name(async (files, dryRun) => {
|
|
7281
7662
|
const errors = [];
|
|
7282
|
-
const { default: pLimit } = await import("./p-limit-
|
|
7663
|
+
const { default: pLimit } = await import("./p-limit-OZUVCRX2.js");
|
|
7283
7664
|
const limit = pLimit(10);
|
|
7284
7665
|
await Promise.all(
|
|
7285
7666
|
files.map(
|
|
@@ -7341,11 +7722,22 @@ var consolidatedImports = {
|
|
|
7341
7722
|
dryRun
|
|
7342
7723
|
);
|
|
7343
7724
|
errors.push(...packageJsonErrors);
|
|
7344
|
-
const { globby } = await import("./globby-
|
|
7725
|
+
const { globby } = await import("./globby-475IGOM2.js");
|
|
7345
7726
|
const configFiles = await globby([`${configDir}/**/*`]);
|
|
7346
7727
|
const importErrors = await transformImportFiles(
|
|
7347
7728
|
[...storiesPaths, ...configFiles].filter(Boolean),
|
|
7348
|
-
|
|
7729
|
+
{
|
|
7730
|
+
...consolidatedPackages,
|
|
7731
|
+
"storybook/internal/manager-api": "storybook/manager-api",
|
|
7732
|
+
"storybook/internal/preview-api": "storybook/preview-api",
|
|
7733
|
+
"storybook/internal/theming": "storybook/theming",
|
|
7734
|
+
"storybook/internal/theming/create": "storybook/theming/create",
|
|
7735
|
+
"storybook/internal/test": "storybook/test",
|
|
7736
|
+
"storybook/internal/actions": "storybook/internal/actions",
|
|
7737
|
+
"storybook/internal/actions/decorator": "storybook/internal/actions/decorator",
|
|
7738
|
+
"storybook/internal/highlight": "storybook/internal/highlight",
|
|
7739
|
+
"storybook/internal/viewport": "storybook/internal/viewport"
|
|
7740
|
+
},
|
|
7349
7741
|
!!dryRun
|
|
7350
7742
|
);
|
|
7351
7743
|
errors.push(...importErrors);
|
|
@@ -7419,9 +7811,49 @@ var eslintPlugin = {
|
|
|
7419
7811
|
}
|
|
7420
7812
|
};
|
|
7421
7813
|
|
|
7814
|
+
// src/automigrate/fixes/fix-faux-esm-require.ts
|
|
7815
|
+
import { readFile as readFile3, writeFile as writeFile2 } from "node:fs/promises";
|
|
7816
|
+
import { dedent as dedent8 } from "ts-dedent";
|
|
7817
|
+
var fixFauxEsmRequire = {
|
|
7818
|
+
id: "fix-faux-esm-require",
|
|
7819
|
+
link: "https://storybook.js.org/docs/faq#how-do-i-fix-module-resolution-in-special-environments",
|
|
7820
|
+
async check({ mainConfigPath }) {
|
|
7821
|
+
if (!mainConfigPath) {
|
|
7822
|
+
return null;
|
|
7823
|
+
}
|
|
7824
|
+
const content = await readFile3(mainConfigPath, "utf-8");
|
|
7825
|
+
const isESM = containsESMUsage(content);
|
|
7826
|
+
const isWithRequire = containsRequireUsage(content);
|
|
7827
|
+
const isWithBanner = hasRequireBanner(content);
|
|
7828
|
+
if (!isESM) {
|
|
7829
|
+
return null;
|
|
7830
|
+
}
|
|
7831
|
+
if (isWithBanner) {
|
|
7832
|
+
return null;
|
|
7833
|
+
}
|
|
7834
|
+
if (!isWithRequire) {
|
|
7835
|
+
return null;
|
|
7836
|
+
}
|
|
7837
|
+
return true;
|
|
7838
|
+
},
|
|
7839
|
+
prompt() {
|
|
7840
|
+
return dedent8`Main config is ESM but uses 'require'. This will break in Storybook 10; Adding compatibility banner`;
|
|
7841
|
+
},
|
|
7842
|
+
async run({ dryRun, mainConfigPath }) {
|
|
7843
|
+
if (dryRun) {
|
|
7844
|
+
return;
|
|
7845
|
+
}
|
|
7846
|
+
const content = await readFile3(mainConfigPath, "utf-8");
|
|
7847
|
+
const banner = getRequireBanner();
|
|
7848
|
+
const comment = bannerComment;
|
|
7849
|
+
const newContent = [banner, comment, content].join("\n");
|
|
7850
|
+
await writeFile2(mainConfigPath, newContent);
|
|
7851
|
+
}
|
|
7852
|
+
};
|
|
7853
|
+
|
|
7422
7854
|
// src/automigrate/fixes/initial-globals.ts
|
|
7423
7855
|
var import_picocolors10 = __toESM(require_picocolors(), 1);
|
|
7424
|
-
import { readFile as
|
|
7856
|
+
import { readFile as readFile4, writeFile as writeFile3 } from "node:fs/promises";
|
|
7425
7857
|
import { formatConfig as formatConfig2, loadConfig as loadConfig4 } from "storybook/internal/csf-tools";
|
|
7426
7858
|
var initialGlobals = {
|
|
7427
7859
|
id: "initial-globals",
|
|
@@ -7430,7 +7862,7 @@ var initialGlobals = {
|
|
|
7430
7862
|
if (!previewConfigPath) {
|
|
7431
7863
|
return null;
|
|
7432
7864
|
}
|
|
7433
|
-
const previewConfig = loadConfig4((await
|
|
7865
|
+
const previewConfig = loadConfig4((await readFile4(previewConfigPath)).toString()).parse();
|
|
7434
7866
|
const globals = previewConfig.getFieldNode(["globals"]);
|
|
7435
7867
|
if (!globals) {
|
|
7436
7868
|
return null;
|
|
@@ -7444,7 +7876,7 @@ var initialGlobals = {
|
|
|
7444
7876
|
result.previewConfig.removeField(["globals"]);
|
|
7445
7877
|
result.previewConfig.setFieldNode(["initialGlobals"], result.globals);
|
|
7446
7878
|
if (!dryRun) {
|
|
7447
|
-
await
|
|
7879
|
+
await writeFile3(result.previewConfigPath, formatConfig2(result.previewConfig));
|
|
7448
7880
|
}
|
|
7449
7881
|
}
|
|
7450
7882
|
};
|
|
@@ -7860,7 +8292,7 @@ ${errors.map(({ file, error }) => `- ${file}: ${error.message}`).join("\n")}`
|
|
|
7860
8292
|
};
|
|
7861
8293
|
|
|
7862
8294
|
// src/automigrate/fixes/renderer-to-framework.ts
|
|
7863
|
-
import { readFile as
|
|
8295
|
+
import { readFile as readFile5, writeFile as writeFile4 } from "node:fs/promises";
|
|
7864
8296
|
import {
|
|
7865
8297
|
frameworkPackages as frameworkPackages3,
|
|
7866
8298
|
frameworkToRenderer,
|
|
@@ -7883,16 +8315,16 @@ var replaceImports = /* @__PURE__ */ __name((source, renderer, framework) => {
|
|
|
7883
8315
|
}, "replaceImports");
|
|
7884
8316
|
var transformSourceFiles = /* @__PURE__ */ __name(async (files, renderer, framework, dryRun) => {
|
|
7885
8317
|
const errors = [];
|
|
7886
|
-
const { default: pLimit } = await import("./p-limit-
|
|
8318
|
+
const { default: pLimit } = await import("./p-limit-OZUVCRX2.js");
|
|
7887
8319
|
const limit = pLimit(10);
|
|
7888
8320
|
await Promise.all(
|
|
7889
8321
|
files.map(
|
|
7890
8322
|
(file) => limit(async () => {
|
|
7891
8323
|
try {
|
|
7892
|
-
const contents = await
|
|
8324
|
+
const contents = await readFile5(file, "utf-8");
|
|
7893
8325
|
const transformed = replaceImports(contents, renderer, framework);
|
|
7894
8326
|
if (!dryRun && transformed) {
|
|
7895
|
-
await
|
|
8327
|
+
await writeFile4(file, transformed);
|
|
7896
8328
|
}
|
|
7897
8329
|
} catch (error) {
|
|
7898
8330
|
errors.push({ file, error });
|
|
@@ -7904,7 +8336,7 @@ var transformSourceFiles = /* @__PURE__ */ __name(async (files, renderer, framew
|
|
|
7904
8336
|
}, "transformSourceFiles");
|
|
7905
8337
|
var removeRendererInPackageJson = /* @__PURE__ */ __name(async (packageJsonPath, renderer, dryRun) => {
|
|
7906
8338
|
try {
|
|
7907
|
-
const content = await
|
|
8339
|
+
const content = await readFile5(packageJsonPath, "utf-8");
|
|
7908
8340
|
const packageJson = JSON.parse(content);
|
|
7909
8341
|
let hasChanges = false;
|
|
7910
8342
|
if (packageJson.dependencies?.[renderer]) {
|
|
@@ -7916,7 +8348,7 @@ var removeRendererInPackageJson = /* @__PURE__ */ __name(async (packageJsonPath,
|
|
|
7916
8348
|
hasChanges = true;
|
|
7917
8349
|
}
|
|
7918
8350
|
if (!dryRun && hasChanges) {
|
|
7919
|
-
await
|
|
8351
|
+
await writeFile4(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
|
7920
8352
|
}
|
|
7921
8353
|
return hasChanges;
|
|
7922
8354
|
} catch (error) {
|
|
@@ -7924,7 +8356,7 @@ var removeRendererInPackageJson = /* @__PURE__ */ __name(async (packageJsonPath,
|
|
|
7924
8356
|
}
|
|
7925
8357
|
}, "removeRendererInPackageJson");
|
|
7926
8358
|
var checkPackageJson = /* @__PURE__ */ __name(async (packageJsonPath) => {
|
|
7927
|
-
const content = await
|
|
8359
|
+
const content = await readFile5(packageJsonPath, "utf-8");
|
|
7928
8360
|
const packageJson = JSON.parse(content);
|
|
7929
8361
|
const dependencies = getAllDependencies(packageJson);
|
|
7930
8362
|
const frameworks = detectFrameworks(dependencies);
|
|
@@ -7985,7 +8417,7 @@ var rendererToFramework = {
|
|
|
7985
8417
|
}
|
|
7986
8418
|
logger12.debug(`
|
|
7987
8419
|
Migrating ${rendererPackage} to ${selectedFramework}`);
|
|
7988
|
-
const { globby } = await import("./globby-
|
|
8420
|
+
const { globby } = await import("./globby-475IGOM2.js");
|
|
7989
8421
|
const configFiles = await globby([`${configDir}/**/*`]);
|
|
7990
8422
|
await transformSourceFiles(
|
|
7991
8423
|
[...storiesPaths, ...configFiles].filter(Boolean),
|
|
@@ -8005,14 +8437,14 @@ Migrating ${rendererPackage} to ${selectedFramework}`);
|
|
|
8005
8437
|
|
|
8006
8438
|
// src/automigrate/fixes/rnstorybook-config.ts
|
|
8007
8439
|
import { existsSync as existsSync2 } from "node:fs";
|
|
8008
|
-
import { readFile as
|
|
8440
|
+
import { readFile as readFile6, rename, writeFile as writeFile5 } from "node:fs/promises";
|
|
8009
8441
|
import { join as join2 } from "node:path";
|
|
8010
|
-
import { dedent as
|
|
8442
|
+
import { dedent as dedent9 } from "ts-dedent";
|
|
8011
8443
|
async function renameInFile(filePath, oldText, newText) {
|
|
8012
8444
|
try {
|
|
8013
|
-
const content = await
|
|
8445
|
+
const content = await readFile6(filePath, "utf8");
|
|
8014
8446
|
const updatedContent = content.replaceAll(oldText, newText);
|
|
8015
|
-
await
|
|
8447
|
+
await writeFile5(filePath, updatedContent, "utf8");
|
|
8016
8448
|
} catch (error) {
|
|
8017
8449
|
console.error(`Error updating references in ${filePath}:`, error);
|
|
8018
8450
|
}
|
|
@@ -8020,8 +8452,8 @@ async function renameInFile(filePath, oldText, newText) {
|
|
|
8020
8452
|
__name(renameInFile, "renameInFile");
|
|
8021
8453
|
var getDotStorybookReferences = /* @__PURE__ */ __name(async (searchDir) => {
|
|
8022
8454
|
try {
|
|
8023
|
-
const { globby } = await import("./globby-
|
|
8024
|
-
const { readFile:
|
|
8455
|
+
const { globby } = await import("./globby-475IGOM2.js");
|
|
8456
|
+
const { readFile: readFile8 } = await import("node:fs/promises");
|
|
8025
8457
|
const files = await globby(`${searchDir}/**/*`, {
|
|
8026
8458
|
onlyFiles: true,
|
|
8027
8459
|
gitignore: true
|
|
@@ -8030,7 +8462,7 @@ var getDotStorybookReferences = /* @__PURE__ */ __name(async (searchDir) => {
|
|
|
8030
8462
|
await Promise.all(
|
|
8031
8463
|
files.map(async (file) => {
|
|
8032
8464
|
try {
|
|
8033
|
-
const content = await
|
|
8465
|
+
const content = await readFile8(file, "utf8");
|
|
8034
8466
|
if (content.includes(".storybook")) {
|
|
8035
8467
|
referencedFiles.push(file);
|
|
8036
8468
|
}
|
|
@@ -8055,7 +8487,7 @@ var rnstorybookConfig = {
|
|
|
8055
8487
|
const projectDir = mainConfigPath ? join2(mainConfigPath, "..", "..") : process.cwd();
|
|
8056
8488
|
const storybookDir = join2(projectDir, ".storybook");
|
|
8057
8489
|
const rnStorybookDir = join2(projectDir, ".rnstorybook");
|
|
8058
|
-
const { globby } = await import("./globby-
|
|
8490
|
+
const { globby } = await import("./globby-475IGOM2.js");
|
|
8059
8491
|
const requiresFiles = await globby(join2(storybookDir, "storybook.requires.*"));
|
|
8060
8492
|
if (existsSync2(storybookDir) && requiresFiles.length > 0 && !existsSync2(rnStorybookDir)) {
|
|
8061
8493
|
return { storybookDir, rnStorybookDir };
|
|
@@ -8063,7 +8495,7 @@ var rnstorybookConfig = {
|
|
|
8063
8495
|
return null;
|
|
8064
8496
|
},
|
|
8065
8497
|
prompt() {
|
|
8066
|
-
return
|
|
8498
|
+
return dedent9`We'll rename your .storybook directory to .rnstorybook and update all references to it.`;
|
|
8067
8499
|
},
|
|
8068
8500
|
async run({ result: { storybookDir, rnStorybookDir }, dryRun, packageManager }) {
|
|
8069
8501
|
const instanceDir = packageManager.instanceDir;
|
|
@@ -8085,7 +8517,7 @@ import { readFileSync as readFileSync4 } from "node:fs";
|
|
|
8085
8517
|
import { dirname as dirname2 } from "node:path";
|
|
8086
8518
|
import { isCorePackage, isSatelliteAddon } from "storybook/internal/common";
|
|
8087
8519
|
import { logger as logger13 } from "storybook/internal/node-logger";
|
|
8088
|
-
import { dedent as
|
|
8520
|
+
import { dedent as dedent10 } from "ts-dedent";
|
|
8089
8521
|
async function getLatestVersions(packageManager, packages) {
|
|
8090
8522
|
return Promise.all(
|
|
8091
8523
|
packages.map(async ([packageName]) => ({
|
|
@@ -8141,7 +8573,7 @@ var upgradeStorybookRelatedDependencies = {
|
|
|
8141
8573
|
},
|
|
8142
8574
|
async run({ result: { upgradable }, packageManager, dryRun }) {
|
|
8143
8575
|
if (dryRun) {
|
|
8144
|
-
logger13.log(
|
|
8576
|
+
logger13.log(dedent10`
|
|
8145
8577
|
The following would have been upgraded:
|
|
8146
8578
|
${upgradable.map(
|
|
8147
8579
|
({ packageName, afterVersion, beforeVersion }) => `${packageName}: ${beforeVersion} => ${afterVersion}`
|
|
@@ -8178,7 +8610,7 @@ var upgradeStorybookRelatedDependencies = {
|
|
|
8178
8610
|
import { detectPnp } from "storybook/internal/cli";
|
|
8179
8611
|
import { readConfig as readConfig3 } from "storybook/internal/csf-tools";
|
|
8180
8612
|
import { CommonJsConfigNotSupportedError } from "storybook/internal/server-errors";
|
|
8181
|
-
import { dedent as
|
|
8613
|
+
import { dedent as dedent11 } from "ts-dedent";
|
|
8182
8614
|
var wrapGetAbsolutePath = {
|
|
8183
8615
|
id: "wrap-getAbsolutePath",
|
|
8184
8616
|
link: "https://storybook.js.org/docs/faq#how-do-i-fix-module-resolution-in-special-environments",
|
|
@@ -8201,7 +8633,7 @@ var wrapGetAbsolutePath = {
|
|
|
8201
8633
|
return { storybookVersion, isStorybookInMonorepo, isPnp, isConfigTypescript };
|
|
8202
8634
|
},
|
|
8203
8635
|
prompt() {
|
|
8204
|
-
return
|
|
8636
|
+
return dedent11`We have detected that you're using Storybook in a monorepo or PnP project. Some fields in your main config must be updated.`;
|
|
8205
8637
|
},
|
|
8206
8638
|
async run({ dryRun, mainConfigPath, result }) {
|
|
8207
8639
|
await updateMainConfig({ dryRun: !!dryRun, mainConfigPath }, (mainConfig) => {
|
|
@@ -8212,7 +8644,7 @@ var wrapGetAbsolutePath = {
|
|
|
8212
8644
|
if (mainConfig?.fileName?.endsWith(".cjs") || mainConfig?.fileName?.endsWith(".cts") || mainConfig?.fileName?.endsWith(".cjsx") || mainConfig?.fileName?.endsWith(".ctsx") || mainConfig._code.includes("module.exports")) {
|
|
8213
8645
|
throw new CommonJsConfigNotSupportedError();
|
|
8214
8646
|
} else {
|
|
8215
|
-
mainConfig.setImport(["dirname"
|
|
8647
|
+
mainConfig.setImport(["dirname"], "node:path");
|
|
8216
8648
|
mainConfig.setImport(["fileURLToPath"], "node:url");
|
|
8217
8649
|
}
|
|
8218
8650
|
mainConfig.setBodyDeclaration(
|
|
@@ -8240,25 +8672,26 @@ var allFixes = [
|
|
|
8240
8672
|
removeEssentials,
|
|
8241
8673
|
addonA11yParameters,
|
|
8242
8674
|
removeDocsAutodocs,
|
|
8243
|
-
wrapGetAbsolutePath
|
|
8675
|
+
wrapGetAbsolutePath,
|
|
8676
|
+
fixFauxEsmRequire
|
|
8244
8677
|
];
|
|
8245
8678
|
var commandFixes = [csfFactories];
|
|
8246
8679
|
|
|
8247
8680
|
// src/automigrate/helpers/logMigrationSummary.ts
|
|
8248
8681
|
var import_picocolors12 = __toESM(require_picocolors(), 1);
|
|
8249
8682
|
import { logger as logger14 } from "storybook/internal/node-logger";
|
|
8250
|
-
import { dedent as
|
|
8683
|
+
import { dedent as dedent12 } from "ts-dedent";
|
|
8251
8684
|
var messageDivider2 = "\n\n";
|
|
8252
8685
|
var segmentDivider = "\n\n\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n";
|
|
8253
8686
|
function getGlossaryMessages(fixSummary, fixResults) {
|
|
8254
|
-
const
|
|
8687
|
+
const messages2 = [];
|
|
8255
8688
|
if (fixSummary.succeeded.length > 0) {
|
|
8256
|
-
|
|
8257
|
-
|
|
8689
|
+
messages2.push(import_picocolors12.default.bold("Successful migrations:"));
|
|
8690
|
+
messages2.push(fixSummary.succeeded.map((m) => import_picocolors12.default.green(m)).join(", "));
|
|
8258
8691
|
}
|
|
8259
8692
|
if (Object.keys(fixSummary.failed).length > 0) {
|
|
8260
|
-
|
|
8261
|
-
|
|
8693
|
+
messages2.push(import_picocolors12.default.bold("Failed migrations:"));
|
|
8694
|
+
messages2.push(
|
|
8262
8695
|
Object.entries(fixSummary.failed).map(([id, error]) => {
|
|
8263
8696
|
return `${import_picocolors12.default.bold(import_picocolors12.default.red(id))}:
|
|
8264
8697
|
${error}`;
|
|
@@ -8266,34 +8699,34 @@ ${error}`;
|
|
|
8266
8699
|
);
|
|
8267
8700
|
}
|
|
8268
8701
|
if (fixSummary.manual.length > 0) {
|
|
8269
|
-
|
|
8270
|
-
|
|
8702
|
+
messages2.push(import_picocolors12.default.bold("Manual migrations:"));
|
|
8703
|
+
messages2.push(
|
|
8271
8704
|
fixSummary.manual.map(
|
|
8272
8705
|
(m) => fixResults[m] === "manual_succeeded" /* MANUAL_SUCCEEDED */ ? import_picocolors12.default.green(m) : import_picocolors12.default.blue(m)
|
|
8273
8706
|
).join(", ")
|
|
8274
8707
|
);
|
|
8275
8708
|
}
|
|
8276
8709
|
if (fixSummary.skipped.length > 0) {
|
|
8277
|
-
|
|
8278
|
-
|
|
8710
|
+
messages2.push(import_picocolors12.default.bold("Skipped migrations:"));
|
|
8711
|
+
messages2.push(fixSummary.skipped.map((m) => import_picocolors12.default.cyan(m)).join(", "));
|
|
8279
8712
|
}
|
|
8280
|
-
return
|
|
8713
|
+
return messages2;
|
|
8281
8714
|
}
|
|
8282
8715
|
__name(getGlossaryMessages, "getGlossaryMessages");
|
|
8283
8716
|
function logMigrationSummary({
|
|
8284
8717
|
fixResults,
|
|
8285
8718
|
fixSummary
|
|
8286
8719
|
}) {
|
|
8287
|
-
const
|
|
8288
|
-
|
|
8289
|
-
|
|
8720
|
+
const messages2 = [];
|
|
8721
|
+
messages2.push(getGlossaryMessages(fixSummary, fixResults).join(messageDivider2));
|
|
8722
|
+
messages2.push(dedent12`If you'd like to run the migrations again, you can do so by running '${import_picocolors12.default.cyan(
|
|
8290
8723
|
"npx storybook automigrate"
|
|
8291
8724
|
)}'
|
|
8292
8725
|
|
|
8293
8726
|
The automigrations try to migrate common patterns in your project, but might not contain everything needed to migrate to the latest version of Storybook.
|
|
8294
8727
|
|
|
8295
8728
|
Please check the changelog and migration guide for manual migrations and more information: ${import_picocolors12.default.yellow(
|
|
8296
|
-
"https://storybook.js.org/docs/
|
|
8729
|
+
"https://storybook.js.org/docs/migration-guide?ref=upgrade?ref=upgrade"
|
|
8297
8730
|
)}
|
|
8298
8731
|
And reach out on Discord if you need help: ${import_picocolors12.default.yellow("https://discord.gg/storybook")}
|
|
8299
8732
|
`);
|
|
@@ -8302,7 +8735,7 @@ function logMigrationSummary({
|
|
|
8302
8735
|
(r) => r === "failed" /* FAILED */ || r === "check_failed" /* CHECK_FAILED */
|
|
8303
8736
|
);
|
|
8304
8737
|
const title = hasNoFixes ? "No migrations were applicable to your project" : hasFailures2 ? "Migration check ran with failures" : "Migration check ran successfully";
|
|
8305
|
-
return logger14.logBox(
|
|
8738
|
+
return logger14.logBox(messages2.filter(Boolean).join(segmentDivider), {
|
|
8306
8739
|
title,
|
|
8307
8740
|
borderColor: hasFailures2 ? "red" : "green"
|
|
8308
8741
|
});
|
|
@@ -8312,7 +8745,7 @@ __name(logMigrationSummary, "logMigrationSummary");
|
|
|
8312
8745
|
// src/automigrate/index.ts
|
|
8313
8746
|
var logAvailableMigrations = /* @__PURE__ */ __name(() => {
|
|
8314
8747
|
const availableFixes = [...allFixes, ...commandFixes].map((f) => import_picocolors13.default.yellow(f.id)).map((x) => `- ${x}`).join("\n");
|
|
8315
|
-
logger15.log(
|
|
8748
|
+
logger15.log(dedent13`
|
|
8316
8749
|
The following migrations are available:
|
|
8317
8750
|
${availableFixes}
|
|
8318
8751
|
`);
|
|
@@ -8614,7 +9047,7 @@ __name(runFixes, "runFixes");
|
|
|
8614
9047
|
// src/link.ts
|
|
8615
9048
|
var import_cross_spawn = __toESM(require_cross_spawn(), 1);
|
|
8616
9049
|
var import_picocolors14 = __toESM(require_picocolors(), 1);
|
|
8617
|
-
import { mkdir, readFile as
|
|
9050
|
+
import { mkdir, readFile as readFile7, writeFile as writeFile6 } from "node:fs/promises";
|
|
8618
9051
|
import { basename as basename2, extname as extname2, join as join3 } from "node:path";
|
|
8619
9052
|
import { logger as logger16 } from "storybook/internal/node-logger";
|
|
8620
9053
|
var exec = /* @__PURE__ */ __name(async (command2, options = {}, {
|
|
@@ -8656,7 +9089,7 @@ var exec = /* @__PURE__ */ __name(async (command2, options = {}, {
|
|
|
8656
9089
|
var link = /* @__PURE__ */ __name(async ({ target, local, start }) => {
|
|
8657
9090
|
const storybookDir = process.cwd();
|
|
8658
9091
|
try {
|
|
8659
|
-
const packageJson = JSON.parse(await
|
|
9092
|
+
const packageJson = JSON.parse(await readFile7("package.json", { encoding: "utf8" }));
|
|
8660
9093
|
if (packageJson.name !== "@storybook/root") {
|
|
8661
9094
|
throw new Error();
|
|
8662
9095
|
}
|
|
@@ -8690,7 +9123,7 @@ var link = /* @__PURE__ */ __name(async ({ target, local, start }) => {
|
|
|
8690
9123
|
await exec(`yarn link --all --relative "${storybookDir}"`, { cwd: reproDir });
|
|
8691
9124
|
logger16.info(`Installing ${reproName}`);
|
|
8692
9125
|
const reproPackageJson = JSON.parse(
|
|
8693
|
-
await
|
|
9126
|
+
await readFile7(join3(reproDir, "package.json"), { encoding: "utf8" })
|
|
8694
9127
|
);
|
|
8695
9128
|
if (!reproPackageJson.devDependencies?.vite) {
|
|
8696
9129
|
reproPackageJson.devDependencies = {
|
|
@@ -8702,7 +9135,7 @@ var link = /* @__PURE__ */ __name(async ({ target, local, start }) => {
|
|
|
8702
9135
|
...reproPackageJson.devDependencies,
|
|
8703
9136
|
"@types/node": "^22"
|
|
8704
9137
|
};
|
|
8705
|
-
await
|
|
9138
|
+
await writeFile6(join3(reproDir, "package.json"), JSON.stringify(reproPackageJson, null, 2));
|
|
8706
9139
|
await exec(`yarn install`, { cwd: reproDir });
|
|
8707
9140
|
if (start) {
|
|
8708
9141
|
logger16.info(`Running ${reproName} storybook`);
|
|
@@ -8738,7 +9171,7 @@ import { logger as logger18, prompt as prompt4 } from "storybook/internal/node-l
|
|
|
8738
9171
|
import { downloadTemplate } from "giget";
|
|
8739
9172
|
var import_picocolors15 = __toESM(require_picocolors(), 1);
|
|
8740
9173
|
var import_semver6 = __toESM(require_semver(), 1);
|
|
8741
|
-
import { dedent as
|
|
9174
|
+
import { dedent as dedent14 } from "ts-dedent";
|
|
8742
9175
|
|
|
8743
9176
|
// src/sandbox-templates.ts
|
|
8744
9177
|
var baseTemplates = {
|
|
@@ -8760,6 +9193,9 @@ var baseTemplates = {
|
|
|
8760
9193
|
mainConfig: /* @__PURE__ */ __name((config) => {
|
|
8761
9194
|
const stories = config.getFieldValue(["stories"]);
|
|
8762
9195
|
return {
|
|
9196
|
+
features: {
|
|
9197
|
+
experimentalTestSyntax: true
|
|
9198
|
+
},
|
|
8763
9199
|
stories: stories?.map((s) => {
|
|
8764
9200
|
if (typeof s === "string") {
|
|
8765
9201
|
return s.replace(/\|(tsx?|ts)\b|\b(tsx?|ts)\|/g, "");
|
|
@@ -8786,7 +9222,12 @@ var baseTemplates = {
|
|
|
8786
9222
|
},
|
|
8787
9223
|
modifications: {
|
|
8788
9224
|
useCsfFactory: true,
|
|
8789
|
-
extraDependencies: ["prop-types"]
|
|
9225
|
+
extraDependencies: ["prop-types"],
|
|
9226
|
+
mainConfig: {
|
|
9227
|
+
features: {
|
|
9228
|
+
experimentalTestSyntax: true
|
|
9229
|
+
}
|
|
9230
|
+
}
|
|
8790
9231
|
}
|
|
8791
9232
|
},
|
|
8792
9233
|
"nextjs/14-ts": {
|
|
@@ -8802,7 +9243,8 @@ var baseTemplates = {
|
|
|
8802
9243
|
mainConfig: {
|
|
8803
9244
|
features: {
|
|
8804
9245
|
experimentalRSC: true,
|
|
8805
|
-
developmentModeForBuild: true
|
|
9246
|
+
developmentModeForBuild: true,
|
|
9247
|
+
experimentalTestSyntax: true
|
|
8806
9248
|
}
|
|
8807
9249
|
},
|
|
8808
9250
|
extraDependencies: ["server-only", "prop-types"]
|
|
@@ -8822,7 +9264,8 @@ var baseTemplates = {
|
|
|
8822
9264
|
mainConfig: {
|
|
8823
9265
|
features: {
|
|
8824
9266
|
experimentalRSC: true,
|
|
8825
|
-
developmentModeForBuild: true
|
|
9267
|
+
developmentModeForBuild: true,
|
|
9268
|
+
experimentalTestSyntax: true
|
|
8826
9269
|
}
|
|
8827
9270
|
},
|
|
8828
9271
|
extraDependencies: ["server-only", "prop-types"]
|
|
@@ -8842,7 +9285,8 @@ var baseTemplates = {
|
|
|
8842
9285
|
mainConfig: {
|
|
8843
9286
|
features: {
|
|
8844
9287
|
experimentalRSC: true,
|
|
8845
|
-
developmentModeForBuild: true
|
|
9288
|
+
developmentModeForBuild: true,
|
|
9289
|
+
experimentalTestSyntax: true
|
|
8846
9290
|
}
|
|
8847
9291
|
},
|
|
8848
9292
|
extraDependencies: ["server-only", "prop-types"]
|
|
@@ -8863,7 +9307,8 @@ var baseTemplates = {
|
|
|
8863
9307
|
framework: "@storybook/nextjs-vite",
|
|
8864
9308
|
features: {
|
|
8865
9309
|
experimentalRSC: true,
|
|
8866
|
-
developmentModeForBuild: true
|
|
9310
|
+
developmentModeForBuild: true,
|
|
9311
|
+
experimentalTestSyntax: true
|
|
8867
9312
|
}
|
|
8868
9313
|
},
|
|
8869
9314
|
extraDependencies: ["server-only", "@storybook/nextjs-vite", "vite", "prop-types"]
|
|
@@ -8884,7 +9329,8 @@ var baseTemplates = {
|
|
|
8884
9329
|
framework: "@storybook/nextjs-vite",
|
|
8885
9330
|
features: {
|
|
8886
9331
|
experimentalRSC: true,
|
|
8887
|
-
developmentModeForBuild: true
|
|
9332
|
+
developmentModeForBuild: true,
|
|
9333
|
+
experimentalTestSyntax: true
|
|
8888
9334
|
}
|
|
8889
9335
|
},
|
|
8890
9336
|
extraDependencies: ["server-only", "@storybook/nextjs-vite", "vite", "prop-types"]
|
|
@@ -8904,7 +9350,8 @@ var baseTemplates = {
|
|
|
8904
9350
|
extraDependencies: ["prop-types"],
|
|
8905
9351
|
mainConfig: {
|
|
8906
9352
|
features: {
|
|
8907
|
-
developmentModeForBuild: true
|
|
9353
|
+
developmentModeForBuild: true,
|
|
9354
|
+
experimentalTestSyntax: true
|
|
8908
9355
|
}
|
|
8909
9356
|
}
|
|
8910
9357
|
},
|
|
@@ -8923,7 +9370,8 @@ var baseTemplates = {
|
|
|
8923
9370
|
extraDependencies: ["prop-types"],
|
|
8924
9371
|
mainConfig: {
|
|
8925
9372
|
features: {
|
|
8926
|
-
developmentModeForBuild: true
|
|
9373
|
+
developmentModeForBuild: true,
|
|
9374
|
+
experimentalTestSyntax: true
|
|
8927
9375
|
}
|
|
8928
9376
|
}
|
|
8929
9377
|
},
|
|
@@ -8934,12 +9382,12 @@ var baseTemplates = {
|
|
|
8934
9382
|
/**
|
|
8935
9383
|
* 1. Create a Vite project with the React template
|
|
8936
9384
|
* 2. Add React beta versions
|
|
8937
|
-
* 3. Add resolutions for
|
|
9385
|
+
* 3. Add resolutions for react, react-dom,@types/react and @types/react-dom, see
|
|
8938
9386
|
* https://react.dev/blog/2024/04/25/react-19-upgrade-guide#installing
|
|
8939
9387
|
* 4. Add @types/react and @types/react-dom pointing to the beta packages
|
|
8940
9388
|
*/
|
|
8941
9389
|
script: `
|
|
8942
|
-
npm create vite --yes {{beforeDir}} -- --template react-ts && cd {{beforeDir}} &&
|
|
9390
|
+
npm create vite --yes {{beforeDir}} -- --template react-ts && cd {{beforeDir}} && jq '.resolutions += {"@types/react": "npm:types-react@beta", "@types/react-dom": "npm:types-react-dom@beta", "react": "npm:react@beta", "react-dom": "npm:react-dom@beta"}' package.json > tmp.json && mv tmp.json package.json && yarn add react@beta react-dom@beta && yarn add --dev @types/react@npm:types-react@beta @types/react-dom@npm:types-react-dom@beta
|
|
8943
9391
|
`,
|
|
8944
9392
|
expected: {
|
|
8945
9393
|
framework: "@storybook/react-vite",
|
|
@@ -8951,7 +9399,8 @@ var baseTemplates = {
|
|
|
8951
9399
|
extraDependencies: ["prop-types"],
|
|
8952
9400
|
mainConfig: {
|
|
8953
9401
|
features: {
|
|
8954
|
-
developmentModeForBuild: true
|
|
9402
|
+
developmentModeForBuild: true,
|
|
9403
|
+
experimentalTestSyntax: true
|
|
8955
9404
|
}
|
|
8956
9405
|
}
|
|
8957
9406
|
},
|
|
@@ -8967,7 +9416,12 @@ var baseTemplates = {
|
|
|
8967
9416
|
},
|
|
8968
9417
|
modifications: {
|
|
8969
9418
|
useCsfFactory: true,
|
|
8970
|
-
extraDependencies: ["prop-types"]
|
|
9419
|
+
extraDependencies: ["prop-types"],
|
|
9420
|
+
mainConfig: {
|
|
9421
|
+
features: {
|
|
9422
|
+
experimentalTestSyntax: true
|
|
9423
|
+
}
|
|
9424
|
+
}
|
|
8971
9425
|
},
|
|
8972
9426
|
skipTasks: ["e2e-tests", "bench", "vitest-integration"]
|
|
8973
9427
|
},
|
|
@@ -8981,7 +9435,12 @@ var baseTemplates = {
|
|
|
8981
9435
|
},
|
|
8982
9436
|
modifications: {
|
|
8983
9437
|
useCsfFactory: true,
|
|
8984
|
-
extraDependencies: ["prop-types"]
|
|
9438
|
+
extraDependencies: ["prop-types"],
|
|
9439
|
+
mainConfig: {
|
|
9440
|
+
features: {
|
|
9441
|
+
experimentalTestSyntax: true
|
|
9442
|
+
}
|
|
9443
|
+
}
|
|
8985
9444
|
},
|
|
8986
9445
|
skipTasks: ["e2e-tests", "bench", "vitest-integration"]
|
|
8987
9446
|
},
|
|
@@ -9003,7 +9462,12 @@ var baseTemplates = {
|
|
|
9003
9462
|
},
|
|
9004
9463
|
modifications: {
|
|
9005
9464
|
useCsfFactory: true,
|
|
9006
|
-
extraDependencies: ["prop-types"]
|
|
9465
|
+
extraDependencies: ["prop-types"],
|
|
9466
|
+
mainConfig: {
|
|
9467
|
+
features: {
|
|
9468
|
+
experimentalTestSyntax: true
|
|
9469
|
+
}
|
|
9470
|
+
}
|
|
9007
9471
|
},
|
|
9008
9472
|
skipTasks: ["e2e-tests", "bench", "vitest-integration"]
|
|
9009
9473
|
},
|
|
@@ -9226,7 +9690,12 @@ var baseTemplates = {
|
|
|
9226
9690
|
builder: "@storybook/builder-vite"
|
|
9227
9691
|
},
|
|
9228
9692
|
modifications: {
|
|
9229
|
-
useCsfFactory: true
|
|
9693
|
+
useCsfFactory: true,
|
|
9694
|
+
mainConfig: {
|
|
9695
|
+
features: {
|
|
9696
|
+
experimentalTestSyntax: true
|
|
9697
|
+
}
|
|
9698
|
+
}
|
|
9230
9699
|
},
|
|
9231
9700
|
skipTasks: ["bench", "vitest-integration"]
|
|
9232
9701
|
},
|
|
@@ -9263,7 +9732,12 @@ var internalTemplates = {
|
|
|
9263
9732
|
extraDependencies: ["@storybook/addon-webpack5-compiler-babel", "prop-types"],
|
|
9264
9733
|
editAddons: /* @__PURE__ */ __name((addons) => [...addons, "@storybook/addon-webpack5-compiler-babel"].filter(
|
|
9265
9734
|
(a) => a !== "@storybook/addon-webpack5-compiler-swc"
|
|
9266
|
-
), "editAddons")
|
|
9735
|
+
), "editAddons"),
|
|
9736
|
+
mainConfig: {
|
|
9737
|
+
features: {
|
|
9738
|
+
experimentalTestSyntax: true
|
|
9739
|
+
}
|
|
9740
|
+
}
|
|
9267
9741
|
},
|
|
9268
9742
|
isInternal: true,
|
|
9269
9743
|
skipTasks: ["e2e-tests", "bench", "vitest-integration"]
|
|
@@ -9278,7 +9752,12 @@ var internalTemplates = {
|
|
|
9278
9752
|
},
|
|
9279
9753
|
modifications: {
|
|
9280
9754
|
useCsfFactory: true,
|
|
9281
|
-
extraDependencies: ["prop-types"]
|
|
9755
|
+
extraDependencies: ["prop-types"],
|
|
9756
|
+
mainConfig: {
|
|
9757
|
+
features: {
|
|
9758
|
+
experimentalTestSyntax: true
|
|
9759
|
+
}
|
|
9760
|
+
}
|
|
9282
9761
|
},
|
|
9283
9762
|
skipTasks: ["e2e-tests", "bench", "vitest-integration"],
|
|
9284
9763
|
isInternal: true
|
|
@@ -9459,9 +9938,9 @@ var sandbox = /* @__PURE__ */ __name(async ({
|
|
|
9459
9938
|
const borderColor = isOutdated ? "#FC521F" : "#F1618C";
|
|
9460
9939
|
const downloadType = !isOutdated && init ? "after-storybook" : "before-storybook";
|
|
9461
9940
|
const branch = isPrerelease ? "next" : "main";
|
|
9462
|
-
const
|
|
9941
|
+
const messages2 = {
|
|
9463
9942
|
welcome: `Creating a Storybook ${import_picocolors15.default.bold(currentVersion)} sandbox..`,
|
|
9464
|
-
notLatest: import_picocolors15.default.red(
|
|
9943
|
+
notLatest: import_picocolors15.default.red(dedent14`
|
|
9465
9944
|
This version is behind the latest release, which is: ${import_picocolors15.default.bold(latestVersion)}!
|
|
9466
9945
|
You likely ran the init command through npx, which can use a locally cached version, to get the latest please run:
|
|
9467
9946
|
${import_picocolors15.default.bold("npx storybook@latest sandbox")}
|
|
@@ -9474,7 +9953,7 @@ var sandbox = /* @__PURE__ */ __name(async ({
|
|
|
9474
9953
|
prerelease: import_picocolors15.default.yellow("This is a pre-release version.")
|
|
9475
9954
|
};
|
|
9476
9955
|
logger18.logBox(
|
|
9477
|
-
[
|
|
9956
|
+
[messages2.welcome].concat(isOutdated && !isPrerelease ? [messages2.notLatest] : []).concat(init && (isOutdated || isPrerelease) ? [messages2.longInitTime] : []).concat(isPrerelease ? [messages2.prerelease] : []).join("\n"),
|
|
9478
9957
|
{ borderStyle: "round", padding: 1, borderColor }
|
|
9479
9958
|
);
|
|
9480
9959
|
if (!selectedConfig) {
|
|
@@ -9494,7 +9973,7 @@ var sandbox = /* @__PURE__ */ __name(async ({
|
|
|
9494
9973
|
}, []);
|
|
9495
9974
|
if (choices.length === 0) {
|
|
9496
9975
|
logger18.logBox(
|
|
9497
|
-
|
|
9976
|
+
dedent14`
|
|
9498
9977
|
🔎 You filtered out all templates. 🔍
|
|
9499
9978
|
|
|
9500
9979
|
After filtering all the templates with "${import_picocolors15.default.yellow(
|
|
@@ -9512,7 +9991,7 @@ var sandbox = /* @__PURE__ */ __name(async ({
|
|
|
9512
9991
|
[templateId] = choices;
|
|
9513
9992
|
} else {
|
|
9514
9993
|
logger18.logBox(
|
|
9515
|
-
|
|
9994
|
+
dedent14`
|
|
9516
9995
|
🤗 Welcome to ${import_picocolors15.default.yellow("sb sandbox")}! 🤗
|
|
9517
9996
|
|
|
9518
9997
|
Create a ${import_picocolors15.default.green("new project")} to minimally reproduce Storybook issues.
|
|
@@ -9572,7 +10051,7 @@ var sandbox = /* @__PURE__ */ __name(async ({
|
|
|
9572
10051
|
});
|
|
9573
10052
|
if ((await readdir(templateDestination)).length === 0) {
|
|
9574
10053
|
const selected = import_picocolors15.default.yellow(templateId);
|
|
9575
|
-
throw new Error(
|
|
10054
|
+
throw new Error(dedent14`
|
|
9576
10055
|
Template downloaded from ${import_picocolors15.default.blue(gitPath)} is empty.
|
|
9577
10056
|
Are you use it exists? Or did you want to set ${selected} to inDevelopment first?
|
|
9578
10057
|
`);
|
|
@@ -9592,12 +10071,12 @@ var sandbox = /* @__PURE__ */ __name(async ({
|
|
|
9592
10071
|
logger18.error(`\u{1F6A8} Failed to download sandbox template: ${String(err)}`);
|
|
9593
10072
|
throw err;
|
|
9594
10073
|
}
|
|
9595
|
-
const initMessage = init ? import_picocolors15.default.yellow(
|
|
10074
|
+
const initMessage = init ? import_picocolors15.default.yellow(dedent14`
|
|
9596
10075
|
yarn install
|
|
9597
10076
|
yarn storybook
|
|
9598
10077
|
`) : `Recreate your setup, then ${import_picocolors15.default.yellow(`npx storybook@latest init`)}`;
|
|
9599
10078
|
logger18.logBox(
|
|
9600
|
-
|
|
10079
|
+
dedent14`
|
|
9601
10080
|
🎉 Your Storybook reproduction project is ready to use! 🎉
|
|
9602
10081
|
|
|
9603
10082
|
${import_picocolors15.default.yellow(`cd ${selectedDirectory}`)}
|
|
@@ -9646,7 +10125,7 @@ import {
|
|
|
9646
10125
|
UpgradeStorybookUnknownCurrentVersionError
|
|
9647
10126
|
} from "storybook/internal/server-errors";
|
|
9648
10127
|
import { telemetry } from "storybook/internal/telemetry";
|
|
9649
|
-
import { dedent as
|
|
10128
|
+
import { dedent as dedent15 } from "ts-dedent";
|
|
9650
10129
|
|
|
9651
10130
|
// src/automigrate/multi-project.ts
|
|
9652
10131
|
import { CLI_COLORS as CLI_COLORS2, logger as logger19, prompt as prompt5 } from "storybook/internal/node-logger";
|
|
@@ -10066,7 +10545,7 @@ ${projectList}`);
|
|
|
10066
10545
|
logger20.log(automigrationLinksMessage);
|
|
10067
10546
|
}
|
|
10068
10547
|
logger20.log(
|
|
10069
|
-
`For a full list of changes, please check our migration guide: ${CLI_COLORS3.cta("https://storybook.js.org/docs/
|
|
10548
|
+
`For a full list of changes, please check our migration guide: ${CLI_COLORS3.cta("https://storybook.js.org/docs/migration-guide?ref=upgrade?ref=upgrade")}`
|
|
10070
10549
|
);
|
|
10071
10550
|
}
|
|
10072
10551
|
__name(logUpgradeResults, "logUpgradeResults");
|
|
@@ -10144,7 +10623,7 @@ async function upgrade(options) {
|
|
|
10144
10623
|
process.on("SIGTERM", handleInterruption);
|
|
10145
10624
|
try {
|
|
10146
10625
|
const hasBlockers = processAutoblockerResults(storybookProjects, (message) => {
|
|
10147
|
-
logger20.error(
|
|
10626
|
+
logger20.error(dedent15`Blockers detected\n\n${message}`);
|
|
10148
10627
|
});
|
|
10149
10628
|
if (hasBlockers) {
|
|
10150
10629
|
throw new HandledError("Blockers detected");
|