@storybook/cli 10.4.0-alpha.17 → 10.4.0-alpha.19
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-2FTSXOV4.js → block-dependencies-versions-IKES7YRT.js} +11 -11
- package/dist/_node-chunks/{block-experimental-addon-test-MBAWHIVX.js → block-experimental-addon-test-RJODMTE5.js} +9 -9
- package/dist/_node-chunks/{block-major-version-GLL4GDWB.js → block-major-version-ME3DAZLS.js} +9 -9
- package/dist/_node-chunks/{block-node-version-RVJJJ4XR.js → block-node-version-HY6L7AKJ.js} +9 -9
- package/dist/_node-chunks/{block-webpack5-frameworks-XEU7EO2R.js → block-webpack5-frameworks-JUAO5GW2.js} +11 -11
- package/dist/_node-chunks/{chunk-JNFHA3R2.js → chunk-32FNNTYD.js} +6 -6
- package/dist/_node-chunks/{chunk-RXAW6T4J.js → chunk-BCB3TTXC.js} +118 -7
- package/dist/_node-chunks/{chunk-CXC2V53L.js → chunk-CWAIOGFA.js} +15 -15
- package/dist/_node-chunks/{optimized-tests-V6WOQ2XH.js → chunk-F2Y5RBHG.js} +23 -15
- package/dist/_node-chunks/chunk-FAH2KGM4.js +11 -0
- package/dist/_node-chunks/{chunk-3FXXXDDK.js → chunk-LWAB637S.js} +7 -7
- package/dist/_node-chunks/{chunk-C2UHYVPK.js → chunk-NGTJLSV5.js} +7 -7
- package/dist/_node-chunks/{chunk-34WT6WHN.js → chunk-OVANZ2BU.js} +6 -6
- package/dist/_node-chunks/{chunk-INX3KICK.js → chunk-S6GEVWW4.js} +6 -6
- package/dist/_node-chunks/{globby-N46UCCVS.js → globby-DWIJHLZT.js} +8 -8
- package/dist/_node-chunks/{monorepo-TVSJOSCW.js → monorepo-UR4HJTCQ.js} +23 -15
- package/dist/_node-chunks/monorepo-optimized-tests-relaxed-limits-no-story-deletion-QDUUXYRM.js +119 -0
- package/dist/_node-chunks/optimized-tests-NIXP5HST.js +20 -0
- package/dist/_node-chunks/{p-limit-BGPAPMNJ.js → p-limit-MZRXK4EV.js} +7 -7
- package/dist/_node-chunks/{chunk-6HOHNSVJ.js → pattern-copy-play-OWJMSCMN.js} +11 -11
- package/dist/_node-chunks/{relaxed-limits-YQA6Y4DQ.js → relaxed-limits-IPKLQ6HO.js} +23 -15
- package/dist/_node-chunks/{run-IPZ5VOW3.js → run-GYEDVAMP.js} +611 -267
- package/dist/_node-chunks/{setup-HAYJDL6K.js → setup-F6H7TC4J.js} +8 -8
- package/dist/bin/index.js +7 -7
- package/package.json +5 -4
- package/dist/_node-chunks/chunk-SIZ5DHPZ.js +0 -11
- package/dist/_node-chunks/pattern-copy-play-6YIEGMCW.js +0 -20
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_qll1c0hfcx from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_qll1c0hfcx from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_qll1c0hfcx from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_qll1c0hfcx.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_qll1c0hfcx.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_qll1c0hfcx.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
|
instructions
|
|
14
|
-
} from "./chunk-
|
|
15
|
-
import "./chunk-
|
|
16
|
-
import "./chunk-
|
|
14
|
+
} from "./chunk-F2Y5RBHG.js";
|
|
15
|
+
import "./chunk-BCB3TTXC.js";
|
|
16
|
+
import "./chunk-32FNNTYD.js";
|
|
17
17
|
import {
|
|
18
18
|
bannerComment,
|
|
19
19
|
containsDirnameUsage,
|
|
@@ -31,18 +31,18 @@ import {
|
|
|
31
31
|
up,
|
|
32
32
|
updateMainConfig,
|
|
33
33
|
upgradeStorybookDependencies
|
|
34
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-CWAIOGFA.js";
|
|
35
35
|
import {
|
|
36
36
|
slash
|
|
37
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-NGTJLSV5.js";
|
|
38
38
|
import {
|
|
39
39
|
require_semver
|
|
40
|
-
} from "./chunk-
|
|
40
|
+
} from "./chunk-LWAB637S.js";
|
|
41
41
|
import {
|
|
42
42
|
__commonJS,
|
|
43
43
|
__require,
|
|
44
44
|
__toESM
|
|
45
|
-
} from "./chunk-
|
|
45
|
+
} from "./chunk-OVANZ2BU.js";
|
|
46
46
|
|
|
47
47
|
// ../../../node_modules/envinfo/dist/envinfo.js
|
|
48
48
|
var require_envinfo = __commonJS({
|
|
@@ -4696,7 +4696,7 @@ var require_cross_spawn = __commonJS({
|
|
|
4696
4696
|
"../../../node_modules/cross-spawn/index.js"(exports, module) {
|
|
4697
4697
|
"use strict";
|
|
4698
4698
|
var cp = __require("child_process"), parse2 = require_parse(), enoent = require_enoent();
|
|
4699
|
-
function
|
|
4699
|
+
function spawn2(command2, args, options) {
|
|
4700
4700
|
let parsed = parse2(command2, args, options), spawned = cp.spawn(parsed.command, parsed.args, parsed.options);
|
|
4701
4701
|
return enoent.hookChildProcess(spawned, parsed), spawned;
|
|
4702
4702
|
}
|
|
@@ -4704,8 +4704,8 @@ var require_cross_spawn = __commonJS({
|
|
|
4704
4704
|
let parsed = parse2(command2, args, options), result = cp.spawnSync(parsed.command, parsed.args, parsed.options);
|
|
4705
4705
|
return result.error = result.error || enoent.verifyENOENTSync(result.status, parsed), result;
|
|
4706
4706
|
}
|
|
4707
|
-
module.exports =
|
|
4708
|
-
module.exports.spawn =
|
|
4707
|
+
module.exports = spawn2;
|
|
4708
|
+
module.exports.spawn = spawn2;
|
|
4709
4709
|
module.exports.sync = spawnSync4;
|
|
4710
4710
|
module.exports._parse = parse2;
|
|
4711
4711
|
module.exports._enoent = enoent;
|
|
@@ -4724,7 +4724,7 @@ import {
|
|
|
4724
4724
|
versions as versions5
|
|
4725
4725
|
} from "storybook/internal/common";
|
|
4726
4726
|
import { withTelemetry } from "storybook/internal/core-server";
|
|
4727
|
-
import { CLI_COLORS as CLI_COLORS5, logTracker as logTracker4, logger as
|
|
4727
|
+
import { CLI_COLORS as CLI_COLORS5, logTracker as logTracker4, logger as logger26 } from "storybook/internal/node-logger";
|
|
4728
4728
|
import { addToGlobalContext, telemetry as telemetry3 } from "storybook/internal/telemetry";
|
|
4729
4729
|
import { Option, program } from "commander";
|
|
4730
4730
|
|
|
@@ -4763,10 +4763,10 @@ function leven(first, second, options) {
|
|
|
4763
4763
|
}
|
|
4764
4764
|
|
|
4765
4765
|
// src/bin/run.ts
|
|
4766
|
-
var
|
|
4766
|
+
var import_picocolors18 = __toESM(require_picocolors(), 1);
|
|
4767
4767
|
|
|
4768
4768
|
// package.json
|
|
4769
|
-
var version = "10.4.0-alpha.
|
|
4769
|
+
var version = "10.4.0-alpha.19";
|
|
4770
4770
|
|
|
4771
4771
|
// src/add.ts
|
|
4772
4772
|
var import_semver = __toESM(require_semver(), 1);
|
|
@@ -5006,9 +5006,9 @@ var DIR_CWD = process.cwd(), require2 = createRequire2(DIR_CWD), postinstallAddo
|
|
|
5006
5006
|
} catch {
|
|
5007
5007
|
return;
|
|
5008
5008
|
}
|
|
5009
|
-
let postinstall = moduledLoaded?.default || moduledLoaded?.postinstall || moduledLoaded,
|
|
5009
|
+
let postinstall = moduledLoaded?.default || moduledLoaded?.postinstall || moduledLoaded, logger27 = options.logger;
|
|
5010
5010
|
if (!postinstall || typeof postinstall != "function") {
|
|
5011
|
-
|
|
5011
|
+
logger27.error(`Error finding postinstall function for ${addonName}`);
|
|
5012
5012
|
return;
|
|
5013
5013
|
}
|
|
5014
5014
|
try {
|
|
@@ -5029,7 +5029,7 @@ async function add(addon, {
|
|
|
5029
5029
|
configDir: userSpecifiedConfigDir,
|
|
5030
5030
|
yes,
|
|
5031
5031
|
skipInstall
|
|
5032
|
-
},
|
|
5032
|
+
}, logger27 = nodeLogger) {
|
|
5033
5033
|
let [addonName, inputVersion] = getVersionSpecifier(addon), { mainConfig, mainConfigPath, configDir, previewConfigPath, packageManager } = await getStorybookData({
|
|
5034
5034
|
configDir: userSpecifiedConfigDir,
|
|
5035
5035
|
packageManagerName: pkgMgr
|
|
@@ -5039,16 +5039,16 @@ async function add(addon, {
|
|
|
5039
5039
|
Unable to find storybook config directory. Please specify your Storybook config directory with the --config-dir flag.
|
|
5040
5040
|
`);
|
|
5041
5041
|
if (!mainConfigPath) {
|
|
5042
|
-
|
|
5042
|
+
logger27.error("Unable to find Storybook main.js config");
|
|
5043
5043
|
return;
|
|
5044
5044
|
}
|
|
5045
5045
|
let shouldAddToMain = !0;
|
|
5046
|
-
if (checkInstalled(addonName, mainConfig) && (shouldAddToMain = !1, !yes && (
|
|
5046
|
+
if (checkInstalled(addonName, mainConfig) && (shouldAddToMain = !1, !yes && (logger27.log(`The Storybook addon "${addonName}" is already present in ${mainConfigPath}.`), !await prompt.confirm({
|
|
5047
5047
|
message: "Do you wish to install it again?"
|
|
5048
5048
|
}))))
|
|
5049
5049
|
return;
|
|
5050
5050
|
let main = await readConfig(mainConfigPath);
|
|
5051
|
-
|
|
5051
|
+
logger27.log(`Verifying ${addonName}`);
|
|
5052
5052
|
let version2 = inputVersion;
|
|
5053
5053
|
if (!version2 && isCoreAddon(addonName) && (version2 = versions.storybook), !version2) {
|
|
5054
5054
|
let latestVersion = await packageManager.latestVersion(addonName);
|
|
@@ -5057,14 +5057,14 @@ async function add(addon, {
|
|
|
5057
5057
|
version2 = latestVersion;
|
|
5058
5058
|
}
|
|
5059
5059
|
let storybookVersion = versions.storybook, versionIsStorybook = version2 === versions.storybook;
|
|
5060
|
-
isCoreAddon(addonName) && !versionIsStorybook &&
|
|
5060
|
+
isCoreAddon(addonName) && !versionIsStorybook && logger27.warn(
|
|
5061
5061
|
`The version of ${addonName} (${version2}) you are installing is not the same as the version of Storybook you are using (${storybookVersion}). This may lead to unexpected behavior.`
|
|
5062
5062
|
);
|
|
5063
5063
|
let versionRange = packageManager.getDependencyVersion("storybook")?.match(/^[~^]/)?.[0] ?? "", addonWithVersion = versionIsStorybook ? `${addonName}@${versionRange}${storybookVersion}` : isValidVersion(version2) && !version2.includes("-pr-") ? `${addonName}@^${version2}` : `${addonName}@${version2}`;
|
|
5064
|
-
|
|
5064
|
+
logger27.log(`Installing ${addonWithVersion}`), await packageManager.addDependencies(
|
|
5065
5065
|
{ type: "devDependencies", writeOutputToFile: !1, skipInstall },
|
|
5066
5066
|
[addonWithVersion]
|
|
5067
|
-
), shouldAddToMain && (
|
|
5067
|
+
), shouldAddToMain && (logger27.log(`Adding '${addon}' to the "addons" field in ${mainConfigPath}`), await setupAddonInConfig({
|
|
5068
5068
|
addonName,
|
|
5069
5069
|
mainConfigCSFFile: main,
|
|
5070
5070
|
previewConfigPath,
|
|
@@ -5073,7 +5073,7 @@ async function add(addon, {
|
|
|
5073
5073
|
packageManager: packageManager.type,
|
|
5074
5074
|
configDir,
|
|
5075
5075
|
yes,
|
|
5076
|
-
logger:
|
|
5076
|
+
logger: logger27,
|
|
5077
5077
|
prompt,
|
|
5078
5078
|
skipInstall
|
|
5079
5079
|
});
|
|
@@ -5083,9 +5083,9 @@ function isValidVersion(version2) {
|
|
|
5083
5083
|
}
|
|
5084
5084
|
|
|
5085
5085
|
// src/automigrate/index.ts
|
|
5086
|
-
var
|
|
5086
|
+
var import_picocolors15 = __toESM(require_picocolors(), 1);
|
|
5087
5087
|
import { versions as versions3 } from "storybook/internal/common";
|
|
5088
|
-
import { logTracker as logTracker2, logger as
|
|
5088
|
+
import { logTracker as logTracker2, logger as logger18, prompt as prompt4 } from "storybook/internal/node-logger";
|
|
5089
5089
|
import { AutomigrateError } from "storybook/internal/server-errors";
|
|
5090
5090
|
|
|
5091
5091
|
// ../../../node_modules/tiny-invariant/dist/esm/tiny-invariant.js
|
|
@@ -5100,7 +5100,7 @@ function invariant(condition, message) {
|
|
|
5100
5100
|
}
|
|
5101
5101
|
|
|
5102
5102
|
// src/automigrate/index.ts
|
|
5103
|
-
import { dedent as
|
|
5103
|
+
import { dedent as dedent15 } from "ts-dedent";
|
|
5104
5104
|
|
|
5105
5105
|
// src/doctor/index.ts
|
|
5106
5106
|
var import_picocolors4 = __toESM(require_picocolors(), 1);
|
|
@@ -5630,7 +5630,7 @@ import { logger as logger3 } from "storybook/internal/node-logger";
|
|
|
5630
5630
|
import { promises as fs } from "fs";
|
|
5631
5631
|
var maxConcurrentTasks = Math.max(1, os.cpus().length - 1);
|
|
5632
5632
|
async function runCodemod(globPattern = "**/*.{stories,story}.{js,jsx,ts,tsx,mjs,mjsx,mts,mtsx}", transform, { dryRun = !1, skipFormatting = !1 } = {}) {
|
|
5633
|
-
let modifiedCount = 0, unmodifiedCount = 0, errorCount = 0, { globby } = await import("./globby-
|
|
5633
|
+
let modifiedCount = 0, unmodifiedCount = 0, errorCount = 0, { globby } = await import("./globby-DWIJHLZT.js"), files = await globby(slash(globPattern), {
|
|
5634
5634
|
followSymbolicLinks: !0,
|
|
5635
5635
|
ignore: ["**/node_modules/**", "**/dist/**", "**/storybook-static/**", "**/build/**"]
|
|
5636
5636
|
});
|
|
@@ -5641,7 +5641,7 @@ Please try a different pattern.
|
|
|
5641
5641
|
`
|
|
5642
5642
|
), new Error("No files matched");
|
|
5643
5643
|
try {
|
|
5644
|
-
let pLimit = (await import("./p-limit-
|
|
5644
|
+
let pLimit = (await import("./p-limit-MZRXK4EV.js")).default, limit = pLimit(maxConcurrentTasks);
|
|
5645
5645
|
await Promise.all(
|
|
5646
5646
|
files.map(
|
|
5647
5647
|
(file) => limit(async () => {
|
|
@@ -6484,7 +6484,7 @@ var addonA11yParameters = {
|
|
|
6484
6484
|
errors.push({ file: previewFileToUpdate, error });
|
|
6485
6485
|
}
|
|
6486
6486
|
}
|
|
6487
|
-
let { default: pLimit } = await import("./p-limit-
|
|
6487
|
+
let { default: pLimit } = await import("./p-limit-MZRXK4EV.js"), limit = pLimit(10);
|
|
6488
6488
|
if (await Promise.all(
|
|
6489
6489
|
storyFilesToUpdate.map(
|
|
6490
6490
|
(file) => limit(async () => {
|
|
@@ -6638,7 +6638,7 @@ var addonGlobalsApi = {
|
|
|
6638
6638
|
}
|
|
6639
6639
|
};
|
|
6640
6640
|
async function transformStoryFiles(files, options, dryRun) {
|
|
6641
|
-
let errors = [], { default: pLimit } = await import("./p-limit-
|
|
6641
|
+
let errors = [], { default: pLimit } = await import("./p-limit-MZRXK4EV.js"), limit = pLimit(10);
|
|
6642
6642
|
return await Promise.all(
|
|
6643
6643
|
files.map(
|
|
6644
6644
|
(file) => limit(async () => {
|
|
@@ -6830,7 +6830,7 @@ function transformPackageJson(content) {
|
|
|
6830
6830
|
return hasChanges ? JSON.stringify(packageJson, null, 2) : null;
|
|
6831
6831
|
}
|
|
6832
6832
|
var transformPackageJsonFiles = async (files, dryRun) => {
|
|
6833
|
-
let errors = [], { default: pLimit } = await import("./p-limit-
|
|
6833
|
+
let errors = [], { default: pLimit } = await import("./p-limit-MZRXK4EV.js"), limit = pLimit(10);
|
|
6834
6834
|
return await Promise.all(
|
|
6835
6835
|
files.map(
|
|
6836
6836
|
(file) => limit(async () => {
|
|
@@ -6869,7 +6869,7 @@ var transformPackageJsonFiles = async (files, dryRun) => {
|
|
|
6869
6869
|
dryRun
|
|
6870
6870
|
);
|
|
6871
6871
|
errors.push(...packageJsonErrors);
|
|
6872
|
-
let { globby } = await import("./globby-
|
|
6872
|
+
let { globby } = await import("./globby-DWIJHLZT.js"), configFiles = await globby([`${configDir}/**/*`]), importErrors = await transformImportFiles(
|
|
6873
6873
|
[...storiesPaths, ...configFiles].filter(Boolean),
|
|
6874
6874
|
{
|
|
6875
6875
|
...consolidatedPackages,
|
|
@@ -7225,7 +7225,7 @@ var VITE_DEFAULT_VERSION = "^7.0.0", transformMainConfig = async (mainConfigPath
|
|
|
7225
7225
|
]);
|
|
7226
7226
|
}
|
|
7227
7227
|
mainConfigPath && (logger11.debug("Updating main config file..."), await transformMainConfig(mainConfigPath, dryRun)), logger11.debug("Scanning and updating import statements...");
|
|
7228
|
-
let { globby } = await import("./globby-
|
|
7228
|
+
let { globby } = await import("./globby-DWIJHLZT.js"), configFiles = await globby([`${configDir}/**/*`]), allFiles = [...storiesPaths, ...configFiles].filter(Boolean), transformErrors = await transformImportFiles2(
|
|
7229
7229
|
allFiles,
|
|
7230
7230
|
{
|
|
7231
7231
|
"@storybook/nextjs": "@storybook/nextjs-vite"
|
|
@@ -7240,6 +7240,334 @@ var VITE_DEFAULT_VERSION = "^7.0.0", transformMainConfig = async (mainConfigPath
|
|
|
7240
7240
|
}
|
|
7241
7241
|
};
|
|
7242
7242
|
|
|
7243
|
+
// src/automigrate/fixes/react-vite-to-tanstack-react.ts
|
|
7244
|
+
import { readFile as readFile7, writeFile as writeFile6 } from "node:fs/promises";
|
|
7245
|
+
import { transformImportFiles as transformImportFiles3 } from "storybook/internal/common";
|
|
7246
|
+
import { logger as logger12, prompt as prompt3 } from "storybook/internal/node-logger";
|
|
7247
|
+
|
|
7248
|
+
// ../../../node_modules/tinyclip/dist/index.js
|
|
7249
|
+
import { spawn } from "node:child_process";
|
|
7250
|
+
var TIMEOUT = 2e3;
|
|
7251
|
+
function checkUnixCommandExists(command2) {
|
|
7252
|
+
return new Promise((resolve5) => {
|
|
7253
|
+
let proc = spawn("which", [command2]);
|
|
7254
|
+
proc.on("error", () => resolve5(!1)), proc.on("close", (code) => resolve5(code === 0));
|
|
7255
|
+
});
|
|
7256
|
+
}
|
|
7257
|
+
async function getWriteCommand() {
|
|
7258
|
+
switch (process.platform) {
|
|
7259
|
+
case "darwin":
|
|
7260
|
+
return ["pbcopy", []];
|
|
7261
|
+
case "win32":
|
|
7262
|
+
return ["clip", []];
|
|
7263
|
+
case "linux":
|
|
7264
|
+
case "freebsd":
|
|
7265
|
+
case "openbsd":
|
|
7266
|
+
return process.env.WSL_DISTRO_NAME ? ["clip.exe", []] : process.env.WAYLAND_DISPLAY ? ["wl-copy", []] : await checkUnixCommandExists("xsel") ? ["xsel", ["--clipboard", "--input"]] : ["xclip", ["-selection", "clipboard", "-i"]];
|
|
7267
|
+
case "android":
|
|
7268
|
+
return ["termux-clipboard-set", []];
|
|
7269
|
+
default:
|
|
7270
|
+
return;
|
|
7271
|
+
}
|
|
7272
|
+
}
|
|
7273
|
+
function writeText(text) {
|
|
7274
|
+
return new Promise(async (resolve5, reject) => {
|
|
7275
|
+
let command2 = await getWriteCommand();
|
|
7276
|
+
if (!command2)
|
|
7277
|
+
return reject(new Error("No clipboard tool found"));
|
|
7278
|
+
let proc = spawn(...command2, {
|
|
7279
|
+
stdio: ["pipe", "ignore", "ignore"],
|
|
7280
|
+
signal: AbortSignal.timeout(TIMEOUT)
|
|
7281
|
+
});
|
|
7282
|
+
proc.on("error", (cause) => reject(new Error("An error occurred while copying", { cause }))), proc.on("close", (code) => code === 0 ? resolve5() : reject(new Error("An unknown error occurred while copying"))), proc.stdin.write(text), proc.stdin.end();
|
|
7283
|
+
});
|
|
7284
|
+
}
|
|
7285
|
+
|
|
7286
|
+
// src/automigrate/fixes/react-vite-to-tanstack-react.ts
|
|
7287
|
+
var import_picocolors11 = __toESM(require_picocolors(), 1);
|
|
7288
|
+
import { dedent as dedent9 } from "ts-dedent";
|
|
7289
|
+
var REACT_VITE_PACKAGE = "@storybook/react-vite", TANSTACK_REACT_PACKAGE = "@storybook/tanstack-react", TANSTACK_ROUTER_DECORATOR_MARKERS = [
|
|
7290
|
+
"createMemoryHistory",
|
|
7291
|
+
"createRootRoute",
|
|
7292
|
+
"createRouter",
|
|
7293
|
+
"RouterProvider"
|
|
7294
|
+
], TANSTACK_ROUTER_PACKAGES = [
|
|
7295
|
+
"@tanstack/react-router",
|
|
7296
|
+
"@tanstack/router-core",
|
|
7297
|
+
"@tanstack/start",
|
|
7298
|
+
"@tanstack/react-start"
|
|
7299
|
+
], fileLooksLikeTanstackRouterDecorator = (content) => TANSTACK_ROUTER_PACKAGES.some(
|
|
7300
|
+
(pkg) => new RegExp(`from\\s+['"]${pkg.replace(/[.*+?^${}()|[\\]\\\\]/g, "\\$&")}['"]`).test(content)
|
|
7301
|
+
) ? TANSTACK_ROUTER_DECORATOR_MARKERS.some((marker) => content.includes(marker)) : !1, detectTanstackRouterDecorator = async ({
|
|
7302
|
+
previewConfigPath,
|
|
7303
|
+
configDir,
|
|
7304
|
+
storiesPaths
|
|
7305
|
+
}) => {
|
|
7306
|
+
let { globby } = await import("./globby-DWIJHLZT.js"), configFiles = configDir ? await globby([`${configDir}/**/*.{ts,tsx,js,jsx,mjs,cjs}`], {
|
|
7307
|
+
ignore: ["**/node_modules/**", "**/dist/**"]
|
|
7308
|
+
}) : [], candidateFiles = Array.from(
|
|
7309
|
+
/* @__PURE__ */ new Set([...previewConfigPath ? [previewConfigPath] : [], ...configFiles, ...storiesPaths])
|
|
7310
|
+
);
|
|
7311
|
+
for (let file of candidateFiles)
|
|
7312
|
+
try {
|
|
7313
|
+
let content = await readFile7(file, "utf-8");
|
|
7314
|
+
if (fileLooksLikeTanstackRouterDecorator(content))
|
|
7315
|
+
return !0;
|
|
7316
|
+
} catch {
|
|
7317
|
+
continue;
|
|
7318
|
+
}
|
|
7319
|
+
return !1;
|
|
7320
|
+
}, transformMainConfig2 = async (mainConfigPath, dryRun) => {
|
|
7321
|
+
try {
|
|
7322
|
+
let content = await readFile7(mainConfigPath, "utf-8");
|
|
7323
|
+
if (!content.includes(REACT_VITE_PACKAGE))
|
|
7324
|
+
return !1;
|
|
7325
|
+
let transformedContent = content.replaceAll(REACT_VITE_PACKAGE, TANSTACK_REACT_PACKAGE);
|
|
7326
|
+
return transformedContent !== content && !dryRun && await writeFile6(mainConfigPath, transformedContent), transformedContent !== content;
|
|
7327
|
+
} catch (error) {
|
|
7328
|
+
return logger12.error(`Failed to update main config at ${mainConfigPath}: ${error}`), !1;
|
|
7329
|
+
}
|
|
7330
|
+
}, buildAiMigrationPrompt = (previewConfigPath) => dedent9`
|
|
7331
|
+
You are migrating a Storybook project from the "${REACT_VITE_PACKAGE}" framework to the
|
|
7332
|
+
"${TANSTACK_REACT_PACKAGE}" framework. The framework swap in .storybook/main.* and the
|
|
7333
|
+
package.json dependency change have already been performed by the Storybook automigration
|
|
7334
|
+
CLI — do not redo those. Your job is to clean up the user-land code that the CLI cannot
|
|
7335
|
+
safely transform.
|
|
7336
|
+
|
|
7337
|
+
Reference documentation:
|
|
7338
|
+
https://storybook.js.org/docs/get-started/frameworks/tanstack-react
|
|
7339
|
+
|
|
7340
|
+
# Background
|
|
7341
|
+
|
|
7342
|
+
"${TANSTACK_REACT_PACKAGE}" is a TanStack Router-aware Storybook framework built on top
|
|
7343
|
+
of @storybook/react-vite. It mounts every story inside a TanStack Router (in-memory
|
|
7344
|
+
history) automatically. Manual router setup that users previously wired into a
|
|
7345
|
+
decorator is now redundant and must be removed — leaving it in place creates a nested
|
|
7346
|
+
router and breaks stories.
|
|
7347
|
+
|
|
7348
|
+
Telltale signs of a manual decorator that must be removed (any of these in
|
|
7349
|
+
preview / decorator / story files):
|
|
7350
|
+
- imports from "@tanstack/react-router", "@tanstack/router-core",
|
|
7351
|
+
"@tanstack/start", or "@tanstack/react-start" used to construct a router
|
|
7352
|
+
- calls to createMemoryHistory(...), createRootRoute(...), createRouter(...)
|
|
7353
|
+
- JSX usage of <RouterProvider router={...} />
|
|
7354
|
+
- a decorator function (e.g. const withRouter = (Story) => <RouterProvider .../>)
|
|
7355
|
+
wired into "decorators: [...]" of a meta or preview
|
|
7356
|
+
|
|
7357
|
+
# The replacement APIs from "${TANSTACK_REACT_PACKAGE}"
|
|
7358
|
+
|
|
7359
|
+
All of the following are exported from "${TANSTACK_REACT_PACKAGE}" — re-exporting the
|
|
7360
|
+
@storybook/react primitives plus the TanStack-specific additions. Use these instead of
|
|
7361
|
+
a hand-rolled router decorator. Only opt in when a story actually needs a specific
|
|
7362
|
+
route — by default the framework's auto-router is enough.
|
|
7363
|
+
|
|
7364
|
+
1) Preview-level default route (CSF factories — recommended).
|
|
7365
|
+
|
|
7366
|
+
In ${previewConfigPath ?? ".storybook/preview.*"}:
|
|
7367
|
+
|
|
7368
|
+
import { definePreview } from '@storybook/tanstack-react';
|
|
7369
|
+
import { routeTree } from '../src/routeTree.gen'; // or a custom Route
|
|
7370
|
+
|
|
7371
|
+
export default definePreview({
|
|
7372
|
+
// optional — registers a default route for every story in the project
|
|
7373
|
+
route: routeTree,
|
|
7374
|
+
parameters: { /* ... */ },
|
|
7375
|
+
});
|
|
7376
|
+
|
|
7377
|
+
2) Per-meta route via "parameters.tanstack.router" (works with both CSF factories
|
|
7378
|
+
and CSF3). Most TanStack-Router-decorator removals translate to this:
|
|
7379
|
+
|
|
7380
|
+
// CSF factories style (preferred when the project already uses preview.meta):
|
|
7381
|
+
import preview from '#.storybook/preview';
|
|
7382
|
+
import { Route } from './Page';
|
|
7383
|
+
|
|
7384
|
+
const meta = preview.meta({
|
|
7385
|
+
title: 'Example/Page',
|
|
7386
|
+
parameters: {
|
|
7387
|
+
tanstack: {
|
|
7388
|
+
router: {
|
|
7389
|
+
route: Route,
|
|
7390
|
+
},
|
|
7391
|
+
},
|
|
7392
|
+
},
|
|
7393
|
+
});
|
|
7394
|
+
|
|
7395
|
+
export const Default = meta.story();
|
|
7396
|
+
|
|
7397
|
+
// CSF3 style:
|
|
7398
|
+
import type { Meta, StoryObj } from '@storybook/tanstack-react';
|
|
7399
|
+
import { Route } from './Page';
|
|
7400
|
+
|
|
7401
|
+
const meta = {
|
|
7402
|
+
title: 'Example/Page',
|
|
7403
|
+
parameters: {
|
|
7404
|
+
tanstack: { router: { route: Route } },
|
|
7405
|
+
},
|
|
7406
|
+
} satisfies Meta<typeof Route>;
|
|
7407
|
+
|
|
7408
|
+
export default meta;
|
|
7409
|
+
export const Default: StoryObj<typeof meta> = {};
|
|
7410
|
+
|
|
7411
|
+
3) Per-story override — same shape, but on a single story's "parameters" instead of
|
|
7412
|
+
the meta. Useful when one story needs a different route than the others.
|
|
7413
|
+
|
|
7414
|
+
4) Additional "parameters.tanstack.router" fields you can use when needed:
|
|
7415
|
+
- "path" initial pathname (e.g. '/users/$id')
|
|
7416
|
+
- "params" URL params object (typed against the route)
|
|
7417
|
+
- "query" search params object (typed against the route)
|
|
7418
|
+
- "routeOverrides" map of route id -> { loader / beforeLoad / validateSearch / ... }
|
|
7419
|
+
for mocking specific routes in the registered tree
|
|
7420
|
+
- "useRouterContext" function that returns a custom router context per story
|
|
7421
|
+
|
|
7422
|
+
Do NOT introduce any of these unless the original decorator was clearly setting up
|
|
7423
|
+
that exact behavior. Remove the decorator first; only port over the bits that were
|
|
7424
|
+
actually doing work.
|
|
7425
|
+
|
|
7426
|
+
5) Type imports. If the project uses CSF3 types, switch them from "@storybook/react"
|
|
7427
|
+
(or "@storybook/react-vite") to "@storybook/tanstack-react":
|
|
7428
|
+
|
|
7429
|
+
- import type { Meta, StoryObj } from '@storybook/react';
|
|
7430
|
+
+ import type { Meta, StoryObj } from '@storybook/tanstack-react';
|
|
7431
|
+
|
|
7432
|
+
The TanStack-aware "Meta" infers TanStack parameter types from the route in
|
|
7433
|
+
"component" / parameters, giving type-safe params/query.
|
|
7434
|
+
|
|
7435
|
+
# Tasks (perform in order, in the user's repository)
|
|
7436
|
+
|
|
7437
|
+
1. Open ${previewConfigPath ?? ".storybook/preview.*"} and remove any TanStack Router
|
|
7438
|
+
decorator from the "decorators" array. The decorator may be:
|
|
7439
|
+
- defined inline in this file, or
|
|
7440
|
+
- imported from another module (commonly .storybook/decorators.ts,
|
|
7441
|
+
.storybook/withRouter.tsx, or similar) — in that case remove BOTH the
|
|
7442
|
+
import + usage here AND delete the decorator definition at its source.
|
|
7443
|
+
If the source decorator file becomes empty after removal, delete the file.
|
|
7444
|
+
|
|
7445
|
+
Confirm "definePreview" is imported from "@storybook/tanstack-react" (not
|
|
7446
|
+
"@storybook/react" or "@storybook/react-vite"). If the project has a single
|
|
7447
|
+
project-wide route to register, pass it via "definePreview({ route })".
|
|
7448
|
+
|
|
7449
|
+
2. Search the whole repository (not just .storybook/) for any *.stories.* file that
|
|
7450
|
+
declares a per-story or per-meta TanStack Router decorator and remove it. If the
|
|
7451
|
+
removed decorator was setting up a specific route, port that to
|
|
7452
|
+
"parameters.tanstack.router" using the APIs above (route / path / params / query /
|
|
7453
|
+
routeOverrides — whichever applies).
|
|
7454
|
+
|
|
7455
|
+
3. Drop now-unused imports of: RouterProvider, createRouter, createMemoryHistory,
|
|
7456
|
+
createRootRoute, Outlet (from "@tanstack/react-router" / "@tanstack/router-core" /
|
|
7457
|
+
"@tanstack/start" / "@tanstack/react-start"). Keep imports that are still
|
|
7458
|
+
legitimately used elsewhere in the file (Link, useNavigate, createRoute when used
|
|
7459
|
+
to build a Route passed to "parameters.tanstack.router.route", etc.).
|
|
7460
|
+
|
|
7461
|
+
4. Update story-type imports from "@storybook/react" / "@storybook/react-vite" to
|
|
7462
|
+
"@storybook/tanstack-react" wherever the story uses TanStack router parameters,
|
|
7463
|
+
so the types pick up the TanStack additions.
|
|
7464
|
+
|
|
7465
|
+
5. Preserve CSF factories syntax. If the file uses
|
|
7466
|
+
"definePreview({...})" / "preview.meta({...})" / "meta.story(...)", keep that shape;
|
|
7467
|
+
only mutate the affected fields. Do not rewrite CSF1/CSF2/CSF3 -> CSF factories or
|
|
7468
|
+
vice versa.
|
|
7469
|
+
|
|
7470
|
+
6. Preserve all other decorators, parameters, args, argTypes, loaders, beforeEach,
|
|
7471
|
+
tags, and globals exactly as they were. Only the TanStack Router decorator is
|
|
7472
|
+
being removed.
|
|
7473
|
+
|
|
7474
|
+
7. Do not edit .storybook/main.*, package.json, or any lockfile — those are already
|
|
7475
|
+
handled by the automigration CLI.
|
|
7476
|
+
|
|
7477
|
+
# Verification checklist before finishing
|
|
7478
|
+
|
|
7479
|
+
- No remaining manual "RouterProvider", "createRouter", "createMemoryHistory",
|
|
7480
|
+
"createRootRoute" usage in preview, .storybook/**, or *.stories.*.
|
|
7481
|
+
- "decorators" arrays no longer contain the removed TanStack Router decorator.
|
|
7482
|
+
- All previously imported router symbols that are no longer referenced are gone.
|
|
7483
|
+
- Story files importing TanStack-aware types use "@storybook/tanstack-react".
|
|
7484
|
+
- TypeScript still compiles. Storybook still loads. Stories that don't need a
|
|
7485
|
+
specific route now rely on the framework's default in-memory router; stories
|
|
7486
|
+
that do specify a route do so via "parameters.tanstack.router".
|
|
7487
|
+
`, reactViteToTanstackReact = {
|
|
7488
|
+
id: "react-vite-to-tanstack-react",
|
|
7489
|
+
link: "https://storybook.js.org/docs/get-started/frameworks/tanstack-react",
|
|
7490
|
+
defaultSelected: !1,
|
|
7491
|
+
async check({
|
|
7492
|
+
packageManager,
|
|
7493
|
+
previewConfigPath,
|
|
7494
|
+
configDir,
|
|
7495
|
+
storiesPaths
|
|
7496
|
+
}) {
|
|
7497
|
+
let allDeps = packageManager.getAllDependencies(), hasReactVitePackage = !!allDeps[REACT_VITE_PACKAGE], hasTanstackRouter = TANSTACK_ROUTER_PACKAGES.some((pkg) => !!allDeps[pkg]);
|
|
7498
|
+
return !hasReactVitePackage || !hasTanstackRouter ? null : {
|
|
7499
|
+
hasTanstackRouterDecorator: await detectTanstackRouterDecorator({
|
|
7500
|
+
previewConfigPath,
|
|
7501
|
+
configDir,
|
|
7502
|
+
storiesPaths: storiesPaths ?? []
|
|
7503
|
+
})
|
|
7504
|
+
};
|
|
7505
|
+
},
|
|
7506
|
+
prompt() {
|
|
7507
|
+
return `Migrate from ${REACT_VITE_PACKAGE} to ${TANSTACK_REACT_PACKAGE} (TanStack Router-aware framework)`;
|
|
7508
|
+
},
|
|
7509
|
+
async run({
|
|
7510
|
+
result,
|
|
7511
|
+
dryRun = !1,
|
|
7512
|
+
mainConfigPath,
|
|
7513
|
+
previewConfigPath,
|
|
7514
|
+
storiesPaths,
|
|
7515
|
+
configDir,
|
|
7516
|
+
packageManager,
|
|
7517
|
+
storybookVersion,
|
|
7518
|
+
yes
|
|
7519
|
+
}) {
|
|
7520
|
+
if (!result)
|
|
7521
|
+
return;
|
|
7522
|
+
logger12.step(`Migrating from ${REACT_VITE_PACKAGE} to ${TANSTACK_REACT_PACKAGE}...`), dryRun ? logger12.debug("Dry run: Skipping package.json updates.") : (logger12.debug("Updating package.json files..."), await packageManager.removeDependencies([REACT_VITE_PACKAGE]), await packageManager.addDependencies({ type: "devDependencies", skipInstall: !0 }, [
|
|
7523
|
+
`${TANSTACK_REACT_PACKAGE}@${storybookVersion}`
|
|
7524
|
+
])), mainConfigPath && (logger12.debug("Updating main config file..."), await transformMainConfig2(mainConfigPath, dryRun)), logger12.debug("Scanning and updating import statements...");
|
|
7525
|
+
let { globby } = await import("./globby-DWIJHLZT.js"), configFiles = configDir ? await globby([`${configDir}/**/*.{ts,tsx,js,jsx,mjs,cjs}`], {
|
|
7526
|
+
ignore: ["**/node_modules/**", "**/dist/**"]
|
|
7527
|
+
}) : [], allFiles = [...storiesPaths, ...configFiles, previewConfigPath].filter(
|
|
7528
|
+
Boolean
|
|
7529
|
+
), transformErrors = await transformImportFiles3(
|
|
7530
|
+
allFiles,
|
|
7531
|
+
{
|
|
7532
|
+
[REACT_VITE_PACKAGE]: TANSTACK_REACT_PACKAGE
|
|
7533
|
+
},
|
|
7534
|
+
!!dryRun
|
|
7535
|
+
);
|
|
7536
|
+
if (transformErrors.length > 0 && (logger12.warn(`Encountered ${transformErrors.length} errors during file transformation:`), transformErrors.forEach(({ file, error }) => {
|
|
7537
|
+
logger12.warn(` - ${file}: ${error.message}`);
|
|
7538
|
+
})), result.hasTanstackRouterDecorator && (logger12.logBox(
|
|
7539
|
+
dedent9`
|
|
7540
|
+
We detected what looks like a manual TanStack Router decorator in
|
|
7541
|
+
${import_picocolors11.default.cyan(previewConfigPath ?? ".storybook/preview")}.
|
|
7542
|
+
|
|
7543
|
+
${import_picocolors11.default.bold(TANSTACK_REACT_PACKAGE)} wraps every story in a TanStack Router
|
|
7544
|
+
automatically (see ${import_picocolors11.default.yellow(
|
|
7545
|
+
"https://storybook.js.org/docs/get-started/frameworks/tanstack-react"
|
|
7546
|
+
)}), so that decorator is no longer needed and should be removed.
|
|
7547
|
+
`
|
|
7548
|
+
), yes ? !0 : await prompt3.confirm({
|
|
7549
|
+
message: "Would you like a ready-to-paste AI prompt to help remove the now-unused TanStack Router decorator?",
|
|
7550
|
+
initialValue: !0
|
|
7551
|
+
}))) {
|
|
7552
|
+
let aiPrompt = buildAiMigrationPrompt(previewConfigPath), separator = import_picocolors11.default.dim("\u2500".repeat(60)), clipboardOk = !1;
|
|
7553
|
+
try {
|
|
7554
|
+
await writeText(aiPrompt), clipboardOk = !0;
|
|
7555
|
+
} catch {
|
|
7556
|
+
}
|
|
7557
|
+
logger12.logBox(
|
|
7558
|
+
dedent9`${clipboardOk ? "AI migration prompt copied to clipboard. Full prompt below:" : "Clipboard not available in this environment. Copy the AI migration prompt below manually:"}
|
|
7559
|
+
|
|
7560
|
+
${separator}
|
|
7561
|
+
${aiPrompt}
|
|
7562
|
+
${separator}`
|
|
7563
|
+
);
|
|
7564
|
+
}
|
|
7565
|
+
logger12.step("Migration completed successfully!"), logger12.log(
|
|
7566
|
+
"For more information, see: https://storybook.js.org/docs/get-started/frameworks/tanstack-react"
|
|
7567
|
+
);
|
|
7568
|
+
}
|
|
7569
|
+
};
|
|
7570
|
+
|
|
7243
7571
|
// src/automigrate/fixes/remove-addon-interactions.ts
|
|
7244
7572
|
import { getAddonNames as getAddonNames5, removeAddon as removeAddon4 } from "storybook/internal/common";
|
|
7245
7573
|
var removeAddonInteractions = {
|
|
@@ -7262,10 +7590,10 @@ var removeAddonInteractions = {
|
|
|
7262
7590
|
};
|
|
7263
7591
|
|
|
7264
7592
|
// src/automigrate/fixes/remove-docs-autodocs.ts
|
|
7265
|
-
var
|
|
7593
|
+
var import_picocolors12 = __toESM(require_picocolors(), 1);
|
|
7266
7594
|
import { Tag } from "storybook/internal/core-server";
|
|
7267
7595
|
import { readConfig as readConfig2 } from "storybook/internal/csf-tools";
|
|
7268
|
-
var
|
|
7596
|
+
var logger13 = {
|
|
7269
7597
|
log: (message) => {
|
|
7270
7598
|
process.env.NODE_ENV !== "test" && console.log(message);
|
|
7271
7599
|
}
|
|
@@ -7284,13 +7612,13 @@ var logger12 = {
|
|
|
7284
7612
|
return null;
|
|
7285
7613
|
}
|
|
7286
7614
|
},
|
|
7287
|
-
prompt: () => `${
|
|
7615
|
+
prompt: () => `${import_picocolors12.default.cyan("docs.autodocs")} has been removed in Storybook 9 and will be removed from your configuration.`,
|
|
7288
7616
|
async run({ result, dryRun, mainConfigPath, previewConfigPath }) {
|
|
7289
7617
|
let { autodocs } = result;
|
|
7290
|
-
|
|
7618
|
+
logger13.log(`\u{1F504} Updating ${import_picocolors12.default.cyan("docs")} parameter in main config file...`), await updateMainConfig({ mainConfigPath, dryRun: !!dryRun }, async (main) => {
|
|
7291
7619
|
let docs = main.getFieldValue(["docs"]) || {};
|
|
7292
7620
|
dryRun || (delete docs.autodocs, Object.keys(docs).length === 0 ? main.removeField(["docs"]) : main.setFieldValue(["docs"], docs));
|
|
7293
|
-
}), autodocs === !0 && previewConfigPath && (
|
|
7621
|
+
}), autodocs === !0 && previewConfigPath && (logger13.log(`\u{1F504} Updating ${import_picocolors12.default.cyan("tags")} parameter in preview config file...`), await updateMainConfig(
|
|
7294
7622
|
{ mainConfigPath: previewConfigPath, dryRun: !!dryRun },
|
|
7295
7623
|
async (preview) => {
|
|
7296
7624
|
let tags = preview.getFieldValue(["tags"]) || [];
|
|
@@ -7301,7 +7629,7 @@ var logger12 = {
|
|
|
7301
7629
|
};
|
|
7302
7630
|
|
|
7303
7631
|
// src/automigrate/fixes/remove-essentials.ts
|
|
7304
|
-
import { getAddonNames as getAddonNames6, removeAddon as removeAddon5, transformImportFiles as
|
|
7632
|
+
import { getAddonNames as getAddonNames6, removeAddon as removeAddon5, transformImportFiles as transformImportFiles4 } from "storybook/internal/common";
|
|
7305
7633
|
|
|
7306
7634
|
// src/automigrate/fixes/remove-essentials.utils.ts
|
|
7307
7635
|
function moveEssentialOptions(dryRun, essentialsOptions) {
|
|
@@ -7395,7 +7723,7 @@ var consolidatedAddons = {
|
|
|
7395
7723
|
packageManager,
|
|
7396
7724
|
skipInstall: !0
|
|
7397
7725
|
});
|
|
7398
|
-
let errors = await
|
|
7726
|
+
let errors = await transformImportFiles4(
|
|
7399
7727
|
[...storiesPaths, mainConfigPath, previewConfigPath].filter(Boolean),
|
|
7400
7728
|
consolidatedAddons,
|
|
7401
7729
|
dryRun
|
|
@@ -7421,13 +7749,13 @@ ${errors.map(({ file, error }) => `- ${file}: ${error.message}`).join(`
|
|
|
7421
7749
|
};
|
|
7422
7750
|
|
|
7423
7751
|
// src/automigrate/fixes/renderer-to-framework.ts
|
|
7424
|
-
import { readFile as
|
|
7752
|
+
import { readFile as readFile8, writeFile as writeFile7 } from "node:fs/promises";
|
|
7425
7753
|
import {
|
|
7426
7754
|
frameworkPackages as frameworkPackages4,
|
|
7427
7755
|
frameworkToRenderer,
|
|
7428
7756
|
rendererPackages as rendererPackages2
|
|
7429
7757
|
} from "storybook/internal/common";
|
|
7430
|
-
import { logger as
|
|
7758
|
+
import { logger as logger14 } from "storybook/internal/node-logger";
|
|
7431
7759
|
var getAllDependencies = (packageJson) => Object.keys({
|
|
7432
7760
|
...packageJson.dependencies || {},
|
|
7433
7761
|
...packageJson.devDependencies || {}
|
|
@@ -7435,13 +7763,13 @@ var getAllDependencies = (packageJson) => Object.keys({
|
|
|
7435
7763
|
let regex = new RegExp(`(['"])${renderer}(['"])`, "g");
|
|
7436
7764
|
return regex.test(source) ? source.replace(regex, `$1${framework}$2`) : null;
|
|
7437
7765
|
}, transformSourceFiles = async (files, renderer, framework, dryRun) => {
|
|
7438
|
-
let errors = [], { default: pLimit } = await import("./p-limit-
|
|
7766
|
+
let errors = [], { default: pLimit } = await import("./p-limit-MZRXK4EV.js"), limit = pLimit(10);
|
|
7439
7767
|
return await Promise.all(
|
|
7440
7768
|
files.map(
|
|
7441
7769
|
(file) => limit(async () => {
|
|
7442
7770
|
try {
|
|
7443
|
-
let contents = await
|
|
7444
|
-
!dryRun && transformed && await
|
|
7771
|
+
let contents = await readFile8(file, "utf-8"), transformed = replaceImports(contents, renderer, framework);
|
|
7772
|
+
!dryRun && transformed && await writeFile7(file, transformed);
|
|
7445
7773
|
} catch (error) {
|
|
7446
7774
|
errors.push({ file, error });
|
|
7447
7775
|
}
|
|
@@ -7450,13 +7778,13 @@ var getAllDependencies = (packageJson) => Object.keys({
|
|
|
7450
7778
|
), errors;
|
|
7451
7779
|
}, removeRendererInPackageJson = async (packageJsonPath, renderer, dryRun) => {
|
|
7452
7780
|
try {
|
|
7453
|
-
let content = await
|
|
7454
|
-
return packageJson.dependencies?.[renderer] && (delete packageJson.dependencies[renderer], hasChanges = !0), packageJson.devDependencies?.[renderer] && (delete packageJson.devDependencies[renderer], hasChanges = !0), !dryRun && hasChanges && await
|
|
7781
|
+
let content = await readFile8(packageJsonPath, "utf-8"), packageJson = JSON.parse(content), hasChanges = !1;
|
|
7782
|
+
return packageJson.dependencies?.[renderer] && (delete packageJson.dependencies[renderer], hasChanges = !0), packageJson.devDependencies?.[renderer] && (delete packageJson.devDependencies[renderer], hasChanges = !0), !dryRun && hasChanges && await writeFile7(packageJsonPath, JSON.stringify(packageJson, null, 2)), hasChanges;
|
|
7455
7783
|
} catch (error) {
|
|
7456
7784
|
throw new Error(`Failed to update package.json: ${error}`);
|
|
7457
7785
|
}
|
|
7458
7786
|
}, checkPackageJson = async (packageJsonPath) => {
|
|
7459
|
-
let content = await
|
|
7787
|
+
let content = await readFile8(packageJsonPath, "utf-8"), packageJson = JSON.parse(content), dependencies = getAllDependencies(packageJson), frameworks = detectFrameworks(dependencies);
|
|
7460
7788
|
if (frameworks.length === 0)
|
|
7461
7789
|
return null;
|
|
7462
7790
|
let renderers = detectRenderers(dependencies);
|
|
@@ -7490,25 +7818,25 @@ var getAllDependencies = (packageJson) => Object.keys({
|
|
|
7490
7818
|
let { result, dryRun = !1, storiesPaths, configDir } = options;
|
|
7491
7819
|
for (let selectedFramework of result.frameworks) {
|
|
7492
7820
|
if (!frameworkPackages4[selectedFramework]) {
|
|
7493
|
-
|
|
7821
|
+
logger14.warn(`Framework name not found for ${selectedFramework}, skipping.`);
|
|
7494
7822
|
continue;
|
|
7495
7823
|
}
|
|
7496
7824
|
let rendererName = frameworkToRenderer[frameworkPackages4[selectedFramework]], [rendererPackage] = Object.entries(rendererPackages2).find(([, renderer]) => renderer === rendererName) ?? [];
|
|
7497
7825
|
if (!rendererPackage) {
|
|
7498
|
-
|
|
7826
|
+
logger14.warn(`Renderer package not found for ${selectedFramework}, skipping.`);
|
|
7499
7827
|
continue;
|
|
7500
7828
|
}
|
|
7501
7829
|
if (rendererPackage === selectedFramework)
|
|
7502
7830
|
continue;
|
|
7503
|
-
|
|
7831
|
+
logger14.debug(`
|
|
7504
7832
|
Migrating ${rendererPackage} to ${selectedFramework}`);
|
|
7505
|
-
let { globby } = await import("./globby-
|
|
7833
|
+
let { globby } = await import("./globby-DWIJHLZT.js"), configFiles = await globby([`${configDir}/**/*`]);
|
|
7506
7834
|
await transformSourceFiles(
|
|
7507
7835
|
[...storiesPaths, ...configFiles].filter(Boolean),
|
|
7508
7836
|
rendererPackage,
|
|
7509
7837
|
selectedFramework,
|
|
7510
7838
|
dryRun
|
|
7511
|
-
),
|
|
7839
|
+
), logger14.debug("Updating package.json files..."), await Promise.all(
|
|
7512
7840
|
result.packageJsonFiles.map(
|
|
7513
7841
|
(file) => removeRendererInPackageJson(file, rendererPackage, dryRun)
|
|
7514
7842
|
)
|
|
@@ -7521,7 +7849,7 @@ Migrating ${rendererPackage} to ${selectedFramework}`);
|
|
|
7521
7849
|
import { existsSync as existsSync2 } from "node:fs";
|
|
7522
7850
|
import { basename as basename2, dirname as dirname2, isAbsolute as isAbsolute2, join as join2, resolve as resolve2 } from "node:path";
|
|
7523
7851
|
import { findConfigFile, loadMainConfig } from "storybook/internal/common";
|
|
7524
|
-
import { logger as
|
|
7852
|
+
import { logger as logger15 } from "storybook/internal/node-logger";
|
|
7525
7853
|
|
|
7526
7854
|
// ../../core/src/shared/constants/config-folder.ts
|
|
7527
7855
|
var RN_STORYBOOK_DIR = ".rnstorybook";
|
|
@@ -7571,7 +7899,7 @@ var resolveAbsoluteConfigDir = (configDir) => isAbsolute2(configDir) ? configDir
|
|
|
7571
7899
|
try {
|
|
7572
7900
|
cfg = await loadMainConfig({ configDir: dir });
|
|
7573
7901
|
} catch (e) {
|
|
7574
|
-
|
|
7902
|
+
logger15.debug(
|
|
7575
7903
|
`Failed to load Storybook main config at ${dir}: ${e instanceof Error ? e.message : String(e)}`
|
|
7576
7904
|
);
|
|
7577
7905
|
continue;
|
|
@@ -7595,27 +7923,27 @@ var resolveAbsoluteConfigDir = (configDir) => isAbsolute2(configDir) ? configDir
|
|
|
7595
7923
|
|
|
7596
7924
|
// src/automigrate/fixes/rnstorybook-config.ts
|
|
7597
7925
|
import { existsSync as existsSync3 } from "node:fs";
|
|
7598
|
-
import { readFile as
|
|
7926
|
+
import { readFile as readFile9, rename, writeFile as writeFile8 } from "node:fs/promises";
|
|
7599
7927
|
import { join as join3 } from "node:path";
|
|
7600
|
-
import { dedent as
|
|
7928
|
+
import { dedent as dedent10 } from "ts-dedent";
|
|
7601
7929
|
async function renameInFile(filePath, oldText, newText) {
|
|
7602
7930
|
try {
|
|
7603
|
-
let updatedContent = (await
|
|
7604
|
-
await
|
|
7931
|
+
let updatedContent = (await readFile9(filePath, "utf8")).replaceAll(oldText, newText);
|
|
7932
|
+
await writeFile8(filePath, updatedContent, "utf8");
|
|
7605
7933
|
} catch (error) {
|
|
7606
7934
|
console.error(`Error updating references in ${filePath}:`, error);
|
|
7607
7935
|
}
|
|
7608
7936
|
}
|
|
7609
7937
|
var getDotStorybookReferences = async (searchDir) => {
|
|
7610
7938
|
try {
|
|
7611
|
-
let { globby } = await import("./globby-
|
|
7939
|
+
let { globby } = await import("./globby-DWIJHLZT.js"), { readFile: readFile11 } = await import("node:fs/promises"), files = await globby(`${searchDir}/**/*`, {
|
|
7612
7940
|
onlyFiles: !0,
|
|
7613
7941
|
gitignore: !0
|
|
7614
7942
|
}), referencedFiles = [];
|
|
7615
7943
|
return await Promise.all(
|
|
7616
7944
|
files.map(async (file) => {
|
|
7617
7945
|
try {
|
|
7618
|
-
(await
|
|
7946
|
+
(await readFile11(file, "utf8")).includes(".storybook") && referencedFiles.push(file);
|
|
7619
7947
|
} catch {
|
|
7620
7948
|
}
|
|
7621
7949
|
})
|
|
@@ -7629,11 +7957,11 @@ var getDotStorybookReferences = async (searchDir) => {
|
|
|
7629
7957
|
async check({ packageManager, mainConfigPath }) {
|
|
7630
7958
|
if (!packageManager.getAllDependencies()["@storybook/react-native"])
|
|
7631
7959
|
return null;
|
|
7632
|
-
let projectDir = mainConfigPath ? join3(mainConfigPath, "..", "..") : process.cwd(), storybookDir = join3(projectDir, ".storybook"), rnStorybookDir = join3(projectDir, RN_STORYBOOK_DIR), { globby } = await import("./globby-
|
|
7960
|
+
let projectDir = mainConfigPath ? join3(mainConfigPath, "..", "..") : process.cwd(), storybookDir = join3(projectDir, ".storybook"), rnStorybookDir = join3(projectDir, RN_STORYBOOK_DIR), { globby } = await import("./globby-DWIJHLZT.js"), requiresFiles = await globby(join3(storybookDir, "storybook.requires.*"));
|
|
7633
7961
|
return existsSync3(storybookDir) && requiresFiles.length > 0 && !existsSync3(rnStorybookDir) ? { storybookDir, rnStorybookDir } : null;
|
|
7634
7962
|
},
|
|
7635
7963
|
prompt() {
|
|
7636
|
-
return
|
|
7964
|
+
return dedent10`We'll rename your .storybook directory to .rnstorybook and update all references to it.`;
|
|
7637
7965
|
},
|
|
7638
7966
|
async run({ result: { storybookDir, rnStorybookDir }, dryRun, packageManager }) {
|
|
7639
7967
|
let instanceDir = packageManager.instanceDir, dotStorybookReferences = await getDotStorybookReferences(instanceDir);
|
|
@@ -7646,8 +7974,8 @@ var getDotStorybookReferences = async (searchDir) => {
|
|
|
7646
7974
|
};
|
|
7647
7975
|
|
|
7648
7976
|
// src/automigrate/fixes/storybook-package-name-conflict.ts
|
|
7649
|
-
var
|
|
7650
|
-
import { dedent as
|
|
7977
|
+
var import_picocolors13 = __toESM(require_picocolors(), 1);
|
|
7978
|
+
import { dedent as dedent11 } from "ts-dedent";
|
|
7651
7979
|
var storybookPackageNameConflict = {
|
|
7652
7980
|
id: "storybookPackageNameConflict",
|
|
7653
7981
|
promptType: "notification",
|
|
@@ -7657,15 +7985,15 @@ var storybookPackageNameConflict = {
|
|
|
7657
7985
|
return packageName === "storybook" ? { packageName } : null;
|
|
7658
7986
|
},
|
|
7659
7987
|
prompt() {
|
|
7660
|
-
return
|
|
7661
|
-
Your package.json ${
|
|
7988
|
+
return dedent11`
|
|
7989
|
+
Your package.json ${import_picocolors13.default.cyan('"name"')} field is set to ${import_picocolors13.default.cyan('"storybook"')}.
|
|
7662
7990
|
|
|
7663
7991
|
In npm, pnpm, or yarn workspaces this creates a symlink at
|
|
7664
|
-
${
|
|
7665
|
-
package, causing ${
|
|
7992
|
+
${import_picocolors13.default.yellow("node_modules/storybook")} that shadows the real Storybook
|
|
7993
|
+
package, causing ${import_picocolors13.default.red('"Cannot find module storybook/internal/..."')} errors.
|
|
7666
7994
|
|
|
7667
|
-
To fix this, rename the ${
|
|
7668
|
-
to something other than ${
|
|
7995
|
+
To fix this, rename the ${import_picocolors13.default.cyan('"name"')} field in your package.json
|
|
7996
|
+
to something other than ${import_picocolors13.default.cyan('"storybook"')} (e.g. "my-storybook", "docs", "@myorg/storybook").
|
|
7669
7997
|
`;
|
|
7670
7998
|
}
|
|
7671
7999
|
};
|
|
@@ -7675,8 +8003,8 @@ var import_semver5 = __toESM(require_semver(), 1);
|
|
|
7675
8003
|
import { readFileSync as readFileSync4 } from "node:fs";
|
|
7676
8004
|
import { dirname as dirname3 } from "node:path";
|
|
7677
8005
|
import { isCorePackage, isSatelliteAddon } from "storybook/internal/common";
|
|
7678
|
-
import { logger as
|
|
7679
|
-
import { dedent as
|
|
8006
|
+
import { logger as logger16 } from "storybook/internal/node-logger";
|
|
8007
|
+
import { dedent as dedent12 } from "ts-dedent";
|
|
7680
8008
|
async function getLatestVersions(packageManager, packages) {
|
|
7681
8009
|
return Promise.all(
|
|
7682
8010
|
packages.map(async ([packageName]) => ({
|
|
@@ -7687,14 +8015,14 @@ async function getLatestVersions(packageManager, packages) {
|
|
|
7687
8015
|
);
|
|
7688
8016
|
}
|
|
7689
8017
|
function isValidVersionType(packageName, specifier) {
|
|
7690
|
-
return specifier.startsWith("patch:") || specifier.startsWith("file:") || specifier.startsWith("link:") || specifier.startsWith("portal:") || specifier.startsWith("git:") || specifier.startsWith("git+") || specifier.startsWith("http:") || specifier.startsWith("https:") || specifier.startsWith("workspace:") ? (
|
|
8018
|
+
return specifier.startsWith("patch:") || specifier.startsWith("file:") || specifier.startsWith("link:") || specifier.startsWith("portal:") || specifier.startsWith("git:") || specifier.startsWith("git+") || specifier.startsWith("http:") || specifier.startsWith("https:") || specifier.startsWith("workspace:") ? (logger16.debug(`Skipping ${packageName} as it does not have a valid version type: ${specifier}`), !1) : !0;
|
|
7691
8019
|
}
|
|
7692
8020
|
var upgradeStorybookRelatedDependencies = {
|
|
7693
8021
|
id: "upgrade-storybook-related-dependencies",
|
|
7694
8022
|
promptType: "auto",
|
|
7695
8023
|
defaultSelected: !1,
|
|
7696
8024
|
async check({ packageManager, storybookVersion }) {
|
|
7697
|
-
|
|
8025
|
+
logger16.debug("Checking for incompatible storybook packages...");
|
|
7698
8026
|
let analyzedPackages = await getIncompatibleStorybookPackages({
|
|
7699
8027
|
currentStorybookVersion: storybookVersion,
|
|
7700
8028
|
packageManager,
|
|
@@ -7715,7 +8043,7 @@ var upgradeStorybookRelatedDependencies = {
|
|
|
7715
8043
|
},
|
|
7716
8044
|
async run({ result: { upgradable }, packageManager, dryRun }) {
|
|
7717
8045
|
if (dryRun) {
|
|
7718
|
-
|
|
8046
|
+
logger16.log(dedent12`
|
|
7719
8047
|
The following would have been upgraded:
|
|
7720
8048
|
${upgradable.map(
|
|
7721
8049
|
({ packageName, afterVersion, beforeVersion }) => `${packageName}: ${beforeVersion} => ${afterVersion}`
|
|
@@ -7747,7 +8075,7 @@ import {
|
|
|
7747
8075
|
} from "storybook/internal/common";
|
|
7748
8076
|
import { readConfig as readConfig3 } from "storybook/internal/csf-tools";
|
|
7749
8077
|
import { CommonJsConfigNotSupportedError } from "storybook/internal/server-errors";
|
|
7750
|
-
import { dedent as
|
|
8078
|
+
import { dedent as dedent13 } from "ts-dedent";
|
|
7751
8079
|
var wrapGetAbsolutePath = {
|
|
7752
8080
|
id: "wrap-getAbsolutePath",
|
|
7753
8081
|
link: "https://storybook.js.org/docs/faq#how-do-i-fix-module-resolution-in-special-environments",
|
|
@@ -7764,7 +8092,7 @@ var wrapGetAbsolutePath = {
|
|
|
7764
8092
|
return { storybookVersion, isStorybookInMonorepo, isPnp, isConfigTypescript };
|
|
7765
8093
|
},
|
|
7766
8094
|
prompt() {
|
|
7767
|
-
return
|
|
8095
|
+
return dedent13`We have detected that you're using Storybook in a monorepo or PnP project. Some fields in your main config must be updated.`;
|
|
7768
8096
|
},
|
|
7769
8097
|
async run({ dryRun, mainConfigPath, result }) {
|
|
7770
8098
|
await updateMainConfig({ dryRun: !!dryRun, mainConfigPath }, (mainConfig) => {
|
|
@@ -7796,6 +8124,7 @@ var allFixes = [
|
|
|
7796
8124
|
rnOndeviceAddonsToDeviceAddons,
|
|
7797
8125
|
migrateAddonConsole,
|
|
7798
8126
|
nextjsToNextjsVite,
|
|
8127
|
+
reactViteToTanstackReact,
|
|
7799
8128
|
removeAddonInteractions,
|
|
7800
8129
|
rendererToFramework,
|
|
7801
8130
|
removeEssentials,
|
|
@@ -7808,9 +8137,9 @@ var allFixes = [
|
|
|
7808
8137
|
var commandFixes = [csfFactories];
|
|
7809
8138
|
|
|
7810
8139
|
// src/automigrate/helpers/logMigrationSummary.ts
|
|
7811
|
-
var
|
|
7812
|
-
import { CLI_COLORS as CLI_COLORS2, logger as
|
|
7813
|
-
import { dedent as
|
|
8140
|
+
var import_picocolors14 = __toESM(require_picocolors(), 1);
|
|
8141
|
+
import { CLI_COLORS as CLI_COLORS2, logger as logger17 } from "storybook/internal/node-logger";
|
|
8142
|
+
import { dedent as dedent14 } from "ts-dedent";
|
|
7814
8143
|
var messageDivider2 = `
|
|
7815
8144
|
|
|
7816
8145
|
`, segmentDivider = `
|
|
@@ -7820,23 +8149,23 @@ var messageDivider2 = `
|
|
|
7820
8149
|
`;
|
|
7821
8150
|
function getGlossaryMessages(fixSummary, fixResults) {
|
|
7822
8151
|
let messages2 = [];
|
|
7823
|
-
return fixSummary.succeeded.length > 0 && (messages2.push(
|
|
7824
|
-
Object.entries(fixSummary.failed).map(([id, error]) => `${
|
|
8152
|
+
return fixSummary.succeeded.length > 0 && (messages2.push(import_picocolors14.default.bold("Successful migrations:")), messages2.push(fixSummary.succeeded.map((m) => import_picocolors14.default.green(m)).join(", "))), Object.keys(fixSummary.failed).length > 0 && (messages2.push(import_picocolors14.default.bold("Failed migrations:")), messages2.push(
|
|
8153
|
+
Object.entries(fixSummary.failed).map(([id, error]) => `${import_picocolors14.default.bold(import_picocolors14.default.red(id))}:
|
|
7825
8154
|
${error}`).join(`
|
|
7826
8155
|
`)
|
|
7827
|
-
)), fixSummary.manual.length > 0 && (messages2.push(
|
|
8156
|
+
)), fixSummary.manual.length > 0 && (messages2.push(import_picocolors14.default.bold("Manual migrations:")), messages2.push(
|
|
7828
8157
|
fixSummary.manual.map(
|
|
7829
|
-
(m) => fixResults[m] === "manual_succeeded" /* MANUAL_SUCCEEDED */ ?
|
|
8158
|
+
(m) => fixResults[m] === "manual_succeeded" /* MANUAL_SUCCEEDED */ ? import_picocolors14.default.green(m) : import_picocolors14.default.blue(m)
|
|
7830
8159
|
).join(", ")
|
|
7831
|
-
)), fixSummary.skipped.length > 0 && (messages2.push(
|
|
8160
|
+
)), fixSummary.skipped.length > 0 && (messages2.push(import_picocolors14.default.bold("Skipped migrations:")), messages2.push(fixSummary.skipped.map((m) => import_picocolors14.default.cyan(m)).join(", "))), messages2;
|
|
7832
8161
|
}
|
|
7833
8162
|
function logMigrationSummary({
|
|
7834
8163
|
fixResults,
|
|
7835
8164
|
fixSummary
|
|
7836
8165
|
}) {
|
|
7837
8166
|
let messages2 = [];
|
|
7838
|
-
messages2.push(getGlossaryMessages(fixSummary, fixResults).join(messageDivider2)), messages2.push(
|
|
7839
|
-
${
|
|
8167
|
+
messages2.push(getGlossaryMessages(fixSummary, fixResults).join(messageDivider2)), messages2.push(dedent14`If you'd like to run the migrations again, you can do so by running
|
|
8168
|
+
${import_picocolors14.default.cyan("npx storybook automigrate")}
|
|
7840
8169
|
|
|
7841
8170
|
The automigrations try to migrate common patterns in your project, but might not contain everything needed to migrate to the latest version of Storybook.
|
|
7842
8171
|
|
|
@@ -7847,21 +8176,21 @@ function logMigrationSummary({
|
|
|
7847
8176
|
let hasNoFixes = Object.values(fixResults).every((r) => r === "unnecessary" /* UNNECESSARY */), hasFailures2 = Object.values(fixResults).some(
|
|
7848
8177
|
(r) => r === "failed" /* FAILED */ || r === "check_failed" /* CHECK_FAILED */
|
|
7849
8178
|
);
|
|
7850
|
-
hasNoFixes ?
|
|
8179
|
+
hasNoFixes ? logger17.warn("No migrations were applicable to your project") : hasFailures2 ? logger17.error("Migration check ran with failures") : logger17.step(CLI_COLORS2.success("Migration check ran successfully")), logger17.log(messages2.filter(Boolean).join(segmentDivider));
|
|
7851
8180
|
}
|
|
7852
8181
|
|
|
7853
8182
|
// src/automigrate/index.ts
|
|
7854
8183
|
var logAvailableMigrations = () => {
|
|
7855
|
-
let availableFixes = [...allFixes, ...commandFixes].map((f) =>
|
|
8184
|
+
let availableFixes = [...allFixes, ...commandFixes].map((f) => import_picocolors15.default.yellow(f.id)).map((x) => `- ${x}`).join(`
|
|
7856
8185
|
`);
|
|
7857
|
-
|
|
8186
|
+
logger18.log(dedent15`
|
|
7858
8187
|
The following migrations are available:
|
|
7859
8188
|
${availableFixes}
|
|
7860
8189
|
`);
|
|
7861
8190
|
}, hasFailures = (fixResults) => Object.values(fixResults || {}).some(
|
|
7862
8191
|
(r) => r === "failed" /* FAILED */ || r === "check_failed" /* CHECK_FAILED */
|
|
7863
8192
|
), doAutomigrate = async (options) => {
|
|
7864
|
-
|
|
8193
|
+
logger18.debug("Extracting storybook data...");
|
|
7865
8194
|
let {
|
|
7866
8195
|
mainConfig,
|
|
7867
8196
|
mainConfigPath,
|
|
@@ -7895,7 +8224,7 @@ var logAvailableMigrations = () => {
|
|
|
7895
8224
|
) && !options.skipInstall && await packageManager.installDependencies(), outcome && !options.skipDoctor && await doctor({ configDir, packageManager: options.packageManager }), hasFailures(outcome?.fixResults)) {
|
|
7896
8225
|
let failedMigrations = Object.entries(outcome?.fixResults ?? {}).filter(([, status]) => status === "failed" /* FAILED */ || status === "check_failed" /* CHECK_FAILED */).map(([id, status]) => {
|
|
7897
8226
|
let statusLabel = status === "check_failed" /* CHECK_FAILED */ ? "check failed" : "failed";
|
|
7898
|
-
return `${
|
|
8227
|
+
return `${import_picocolors15.default.cyan(id)} (${statusLabel})`;
|
|
7899
8228
|
});
|
|
7900
8229
|
throw new AutomigrateError({ errors: failedMigrations });
|
|
7901
8230
|
}
|
|
@@ -7924,7 +8253,7 @@ var logAvailableMigrations = () => {
|
|
|
7924
8253
|
return logAvailableMigrations(), null;
|
|
7925
8254
|
let commandFix = commandFixes.find((f) => f.id === fixId);
|
|
7926
8255
|
if (commandFix)
|
|
7927
|
-
return
|
|
8256
|
+
return logger18.step(`Running migration ${import_picocolors15.default.magenta(fixId)}..`), await commandFix.run({
|
|
7928
8257
|
mainConfigPath,
|
|
7929
8258
|
previewConfigPath,
|
|
7930
8259
|
packageManager,
|
|
@@ -7939,8 +8268,8 @@ var logAvailableMigrations = () => {
|
|
|
7939
8268
|
}), null;
|
|
7940
8269
|
let selectedFixes = inputFixes || allFixes.filter((fix) => !(fix.id === upgradeStorybookRelatedDependencies.id && isLatest === !1 && fixId !== upgradeStorybookRelatedDependencies.id)), fixes = fixId ? selectedFixes.filter((f) => f.id === fixId) : selectedFixes;
|
|
7941
8270
|
if (fixId && fixes.length === 0)
|
|
7942
|
-
return
|
|
7943
|
-
|
|
8271
|
+
return logger18.log(`\u{1F4ED} No migrations found for ${import_picocolors15.default.magenta(fixId)}.`), logAvailableMigrations(), null;
|
|
8272
|
+
logger18.step("Checking possible migrations..");
|
|
7944
8273
|
let { fixResults, fixSummary, preCheckFailure } = await runFixes({
|
|
7945
8274
|
fixes,
|
|
7946
8275
|
packageManager,
|
|
@@ -7981,7 +8310,7 @@ async function runFixes({
|
|
|
7981
8310
|
for (let i = 0; i < fixes.length; i += 1) {
|
|
7982
8311
|
let f = fixes[i], result;
|
|
7983
8312
|
try {
|
|
7984
|
-
|
|
8313
|
+
logger18.debug(`Running ${import_picocolors15.default.cyan(f.id)} migration checks`), result = await f.check({
|
|
7985
8314
|
packageManager,
|
|
7986
8315
|
configDir,
|
|
7987
8316
|
rendererPackage,
|
|
@@ -7991,14 +8320,14 @@ async function runFixes({
|
|
|
7991
8320
|
mainConfigPath,
|
|
7992
8321
|
storiesPaths,
|
|
7993
8322
|
hasCsfFactoryPreview
|
|
7994
|
-
}),
|
|
8323
|
+
}), logger18.debug(`End of ${import_picocolors15.default.cyan(f.id)} migration checks`);
|
|
7995
8324
|
} catch (error) {
|
|
7996
|
-
|
|
8325
|
+
logger18.warn(`\u26A0\uFE0F failed to check fix ${import_picocolors15.default.bold(f.id)}`), error instanceof Error && (logger18.error(`
|
|
7997
8326
|
${error.stack}`), fixSummary.failed[f.id] = error.message), fixResults[f.id] = "check_failed" /* CHECK_FAILED */;
|
|
7998
8327
|
}
|
|
7999
8328
|
if (result) {
|
|
8000
8329
|
let promptType = typeof f.promptType == "function" ? await f.promptType(result) : f.promptType ?? "auto";
|
|
8001
|
-
|
|
8330
|
+
logger18.log(`\u{1F50E} found a '${import_picocolors15.default.cyan(f.id)}' migration:`);
|
|
8002
8331
|
let getTitle = () => {
|
|
8003
8332
|
switch (promptType) {
|
|
8004
8333
|
case "auto":
|
|
@@ -8008,11 +8337,11 @@ ${error.stack}`), fixSummary.failed[f.id] = error.message), fixResults[f.id] = "
|
|
|
8008
8337
|
case "notification":
|
|
8009
8338
|
return "Migration notification";
|
|
8010
8339
|
}
|
|
8011
|
-
}, currentTaskLogger =
|
|
8340
|
+
}, currentTaskLogger = prompt4.taskLog({
|
|
8012
8341
|
id: `automigrate-task-${f.id}`,
|
|
8013
|
-
title: `${getTitle()}: ${
|
|
8342
|
+
title: `${getTitle()}: ${import_picocolors15.default.cyan(f.id)}`
|
|
8014
8343
|
});
|
|
8015
|
-
|
|
8344
|
+
logger18.logBox(f.prompt());
|
|
8016
8345
|
let runAnswer;
|
|
8017
8346
|
try {
|
|
8018
8347
|
if (dryRun)
|
|
@@ -8020,7 +8349,7 @@ ${error.stack}`), fixSummary.failed[f.id] = error.message), fixResults[f.id] = "
|
|
|
8020
8349
|
else if (yes)
|
|
8021
8350
|
runAnswer = { fix: !0 }, promptType === "manual" && (fixResults[f.id] = "manual_succeeded" /* MANUAL_SUCCEEDED */, fixSummary.manual.push(f.id));
|
|
8022
8351
|
else if (promptType === "manual") {
|
|
8023
|
-
if (fixResults[f.id] = "manual_succeeded" /* MANUAL_SUCCEEDED */, fixSummary.manual.push(f.id), !await
|
|
8352
|
+
if (fixResults[f.id] = "manual_succeeded" /* MANUAL_SUCCEEDED */, fixSummary.manual.push(f.id), !await prompt4.confirm(
|
|
8024
8353
|
{
|
|
8025
8354
|
message: "Select continue once you have made the required changes, or quit to exit the migration process",
|
|
8026
8355
|
initialValue: !0,
|
|
@@ -8036,9 +8365,9 @@ ${error.stack}`), fixSummary.failed[f.id] = error.message), fixResults[f.id] = "
|
|
|
8036
8365
|
fixResults[f.id] = "manual_skipped" /* MANUAL_SKIPPED */;
|
|
8037
8366
|
break;
|
|
8038
8367
|
}
|
|
8039
|
-
} else promptType === "auto" ? runAnswer = { fix: yes ? !0 : await
|
|
8368
|
+
} else promptType === "auto" ? runAnswer = { fix: yes ? !0 : await prompt4.confirm(
|
|
8040
8369
|
{
|
|
8041
|
-
message: `Do you want to run the '${
|
|
8370
|
+
message: `Do you want to run the '${import_picocolors15.default.cyan(f.id)}' migration on your project?`,
|
|
8042
8371
|
initialValue: f.defaultSelected ?? !0
|
|
8043
8372
|
},
|
|
8044
8373
|
{
|
|
@@ -8046,7 +8375,7 @@ ${error.stack}`), fixSummary.failed[f.id] = error.message), fixResults[f.id] = "
|
|
|
8046
8375
|
throw new Error();
|
|
8047
8376
|
}
|
|
8048
8377
|
}
|
|
8049
|
-
) } : promptType === "notification" && (runAnswer = { fix: await
|
|
8378
|
+
) } : promptType === "notification" && (runAnswer = { fix: await prompt4.confirm(
|
|
8050
8379
|
{
|
|
8051
8380
|
message: "Do you want to continue?"
|
|
8052
8381
|
},
|
|
@@ -8074,14 +8403,14 @@ ${error.stack}`), fixSummary.failed[f.id] = error.message), fixResults[f.id] = "
|
|
|
8074
8403
|
storybookVersion,
|
|
8075
8404
|
storiesPaths,
|
|
8076
8405
|
yes
|
|
8077
|
-
}),
|
|
8406
|
+
}), logger18.log(`\u2705 ran ${import_picocolors15.default.cyan(f.id)} migration`), fixResults[f.id] = "succeeded" /* SUCCEEDED */, fixSummary.succeeded.push(f.id), currentTaskLogger.success(`Ran ${import_picocolors15.default.cyan(f.id)} migration`);
|
|
8078
8407
|
} catch (error) {
|
|
8079
8408
|
fixResults[f.id] = "failed" /* FAILED */;
|
|
8080
8409
|
let errorMessage = error instanceof Error ? error.message : "Failed to run migration";
|
|
8081
|
-
fixSummary.failed[f.id] = errorMessage, currentTaskLogger.error(`Error when running ${
|
|
8410
|
+
fixSummary.failed[f.id] = errorMessage, currentTaskLogger.error(`Error when running ${import_picocolors15.default.cyan(f.id)} migration`);
|
|
8082
8411
|
}
|
|
8083
8412
|
else
|
|
8084
|
-
fixResults[f.id] = "skipped" /* SKIPPED */, fixSummary.skipped.push(f.id), currentTaskLogger.success(`Skipped ${
|
|
8413
|
+
fixResults[f.id] = "skipped" /* SKIPPED */, fixSummary.skipped.push(f.id), currentTaskLogger.success(`Skipped ${import_picocolors15.default.cyan(f.id)} migration`);
|
|
8085
8414
|
} else
|
|
8086
8415
|
fixResults[f.id] = fixResults[f.id] || "unnecessary" /* UNNECESSARY */;
|
|
8087
8416
|
}
|
|
@@ -8090,14 +8419,14 @@ ${error.stack}`), fixSummary.failed[f.id] = error.message), fixResults[f.id] = "
|
|
|
8090
8419
|
|
|
8091
8420
|
// src/link.ts
|
|
8092
8421
|
var import_cross_spawn = __toESM(require_cross_spawn(), 1);
|
|
8093
|
-
import { mkdir, readFile as
|
|
8422
|
+
import { mkdir, readFile as readFile10, writeFile as writeFile9 } from "node:fs/promises";
|
|
8094
8423
|
import { basename as basename3, extname as extname2, join as join4 } from "node:path";
|
|
8095
8424
|
import { executeCommand } from "storybook/internal/common";
|
|
8096
|
-
import { logger as
|
|
8425
|
+
import { logger as logger19 } from "storybook/internal/node-logger";
|
|
8097
8426
|
var link = async ({ target, local, start }) => {
|
|
8098
8427
|
let storybookDir = process.cwd();
|
|
8099
8428
|
try {
|
|
8100
|
-
if (JSON.parse(await
|
|
8429
|
+
if (JSON.parse(await readFile10("package.json", { encoding: "utf8" })).name !== "@storybook/code")
|
|
8101
8430
|
throw new Error();
|
|
8102
8431
|
} catch {
|
|
8103
8432
|
throw new Error("Expected to run link from the root of the storybook monorepo");
|
|
@@ -8105,7 +8434,7 @@ var link = async ({ target, local, start }) => {
|
|
|
8105
8434
|
let reproDir = target, reproName = basename3(target);
|
|
8106
8435
|
if (!local) {
|
|
8107
8436
|
let reprosDir = join4(storybookDir, "../storybook-repros");
|
|
8108
|
-
|
|
8437
|
+
logger19.info(`Ensuring directory ${reprosDir}`), await mkdir(reprosDir, { recursive: !0 }), logger19.info(`Cloning ${target}`), await executeCommand({
|
|
8109
8438
|
command: "git",
|
|
8110
8439
|
args: ["clone", target],
|
|
8111
8440
|
cwd: reprosDir
|
|
@@ -8117,16 +8446,16 @@ var link = async ({ target, local, start }) => {
|
|
|
8117
8446
|
shell: !0
|
|
8118
8447
|
}).stdout.toString();
|
|
8119
8448
|
if (!/^[2-4]\./.test(version2)) {
|
|
8120
|
-
|
|
8449
|
+
logger19.warn(`\u{1F6A8} Expected yarn 2 or higher in ${reproDir}!`), logger19.warn(""), logger19.warn("Please set it up with `yarn set version berry`,"), logger19.warn(`then link '${reproDir}' with the '--local' flag.`);
|
|
8121
8450
|
return;
|
|
8122
8451
|
}
|
|
8123
|
-
|
|
8452
|
+
logger19.info(`Linking ${reproDir}`), await executeCommand({
|
|
8124
8453
|
command: "yarn",
|
|
8125
8454
|
args: ["link", "--all", "--relative", storybookDir],
|
|
8126
8455
|
cwd: reproDir
|
|
8127
|
-
}),
|
|
8456
|
+
}), logger19.info(`Installing ${reproName}`);
|
|
8128
8457
|
let reproPackageJson = JSON.parse(
|
|
8129
|
-
await
|
|
8458
|
+
await readFile10(join4(reproDir, "package.json"), { encoding: "utf8" })
|
|
8130
8459
|
);
|
|
8131
8460
|
reproPackageJson.devDependencies?.vite || (reproPackageJson.devDependencies = {
|
|
8132
8461
|
...reproPackageJson.devDependencies,
|
|
@@ -8134,11 +8463,11 @@ var link = async ({ target, local, start }) => {
|
|
|
8134
8463
|
}), reproPackageJson.devDependencies = {
|
|
8135
8464
|
...reproPackageJson.devDependencies,
|
|
8136
8465
|
"@types/node": "^22"
|
|
8137
|
-
}, await
|
|
8466
|
+
}, await writeFile9(join4(reproDir, "package.json"), JSON.stringify(reproPackageJson, null, 2)), await executeCommand({
|
|
8138
8467
|
command: "yarn",
|
|
8139
8468
|
args: ["install"],
|
|
8140
8469
|
cwd: reproDir
|
|
8141
|
-
}), start && (
|
|
8470
|
+
}), start && (logger19.info(`Running ${reproName} storybook`), await executeCommand({
|
|
8142
8471
|
command: "yarn",
|
|
8143
8472
|
args: ["run", "storybook"],
|
|
8144
8473
|
cwd: reproDir
|
|
@@ -8146,13 +8475,13 @@ var link = async ({ target, local, start }) => {
|
|
|
8146
8475
|
};
|
|
8147
8476
|
|
|
8148
8477
|
// src/migrate.ts
|
|
8149
|
-
import { logger as
|
|
8478
|
+
import { logger as logger20 } from "storybook/internal/node-logger";
|
|
8150
8479
|
import { listCodemods, runCodemod as runCodemod2 } from "@storybook/codemod";
|
|
8151
8480
|
async function migrate(migration, { glob, dryRun, list, rename: rename2, parser }) {
|
|
8152
8481
|
if (list)
|
|
8153
|
-
listCodemods().forEach((key) =>
|
|
8482
|
+
listCodemods().forEach((key) => logger20.log(key));
|
|
8154
8483
|
else if (migration)
|
|
8155
|
-
await runCodemod2(migration, { glob, dryRun, logger:
|
|
8484
|
+
await runCodemod2(migration, { glob, dryRun, logger: logger20, rename: rename2, parser });
|
|
8156
8485
|
else
|
|
8157
8486
|
throw new Error("Migrate: please specify a migration name or --list");
|
|
8158
8487
|
}
|
|
@@ -8169,9 +8498,9 @@ import {
|
|
|
8169
8498
|
optionalEnvToBoolean as optionalEnvToBoolean2,
|
|
8170
8499
|
versions as versions4
|
|
8171
8500
|
} from "storybook/internal/common";
|
|
8172
|
-
import { logger as
|
|
8173
|
-
var
|
|
8174
|
-
import { dedent as
|
|
8501
|
+
import { logger as logger21, prompt as prompt5 } from "storybook/internal/node-logger";
|
|
8502
|
+
var import_picocolors16 = __toESM(require_picocolors(), 1), import_semver6 = __toESM(require_semver(), 1);
|
|
8503
|
+
import { dedent as dedent16 } from "ts-dedent";
|
|
8175
8504
|
|
|
8176
8505
|
// src/sandbox-templates.ts
|
|
8177
8506
|
var baseTemplates = {
|
|
@@ -8286,7 +8615,8 @@ var baseTemplates = {
|
|
|
8286
8615
|
features: {
|
|
8287
8616
|
experimentalRSC: !0,
|
|
8288
8617
|
developmentModeForBuild: !0,
|
|
8289
|
-
experimentalTestSyntax: !0
|
|
8618
|
+
experimentalTestSyntax: !0,
|
|
8619
|
+
changeDetection: !0
|
|
8290
8620
|
}
|
|
8291
8621
|
},
|
|
8292
8622
|
extraDependencies: ["server-only", "prop-types"]
|
|
@@ -8379,7 +8709,8 @@ var baseTemplates = {
|
|
|
8379
8709
|
features: {
|
|
8380
8710
|
experimentalRSC: !0,
|
|
8381
8711
|
developmentModeForBuild: !0,
|
|
8382
|
-
experimentalTestSyntax: !0
|
|
8712
|
+
experimentalTestSyntax: !0,
|
|
8713
|
+
changeDetection: !0
|
|
8383
8714
|
}
|
|
8384
8715
|
},
|
|
8385
8716
|
extraDependencies: ["server-only", "vite", "prop-types"]
|
|
@@ -8421,7 +8752,8 @@ var baseTemplates = {
|
|
|
8421
8752
|
mainConfig: {
|
|
8422
8753
|
features: {
|
|
8423
8754
|
developmentModeForBuild: !0,
|
|
8424
|
-
experimentalTestSyntax: !0
|
|
8755
|
+
experimentalTestSyntax: !0,
|
|
8756
|
+
changeDetection: !0
|
|
8425
8757
|
}
|
|
8426
8758
|
}
|
|
8427
8759
|
},
|
|
@@ -9123,20 +9455,20 @@ var toChoices = (c) => ({ label: allTemplates[c].name, value: c }), sandbox = as
|
|
|
9123
9455
|
let selectedConfig = allTemplates[filterValue], templateId = selectedConfig ? filterValue : null, packageManager = JsPackageManagerFactory.getPackageManager({
|
|
9124
9456
|
force: PackageManagerName.NPM
|
|
9125
9457
|
}), latestVersion = await packageManager.latestVersion("storybook"), nextVersion = await packageManager.latestVersion("storybook@next") ?? "0.0.0", currentVersion = versions4.storybook, isPrerelease = (0, import_semver6.prerelease)(currentVersion), isOutdated = (0, import_semver6.lt)(currentVersion, isPrerelease ? nextVersion : latestVersion), downloadType = !isOutdated && init ? "after-storybook" : "before-storybook", branch = isPrerelease ? "next" : "main", messages2 = {
|
|
9126
|
-
welcome: `Creating a Storybook ${
|
|
9127
|
-
notLatest:
|
|
9128
|
-
This version is behind the latest release, which is: ${
|
|
9458
|
+
welcome: `Creating a Storybook ${import_picocolors16.default.bold(currentVersion)} sandbox..`,
|
|
9459
|
+
notLatest: import_picocolors16.default.red(dedent16`
|
|
9460
|
+
This version is behind the latest release, which is: ${import_picocolors16.default.bold(latestVersion)}!
|
|
9129
9461
|
You likely ran the init command through npx, which can use a locally cached version, to get the latest please run:
|
|
9130
|
-
${
|
|
9462
|
+
${import_picocolors16.default.bold("npx storybook@latest sandbox")}
|
|
9131
9463
|
|
|
9132
9464
|
You may want to CTRL+C to stop, and run with the latest version instead.
|
|
9133
9465
|
`),
|
|
9134
|
-
longInitTime:
|
|
9466
|
+
longInitTime: import_picocolors16.default.yellow(
|
|
9135
9467
|
"The creation of the sandbox will take longer, because we will need to run init."
|
|
9136
9468
|
),
|
|
9137
|
-
prerelease:
|
|
9469
|
+
prerelease: import_picocolors16.default.yellow("This is a pre-release version.")
|
|
9138
9470
|
};
|
|
9139
|
-
if (
|
|
9471
|
+
if (logger21.logBox(
|
|
9140
9472
|
[messages2.welcome].concat(isOutdated && !isPrerelease ? [messages2.notLatest] : []).concat(init && (isOutdated || isPrerelease) ? [messages2.longInitTime] : []).concat(isPrerelease ? [messages2.prerelease] : []).join(`
|
|
9141
9473
|
`),
|
|
9142
9474
|
{
|
|
@@ -9147,24 +9479,24 @@ var toChoices = (c) => ({ label: allTemplates[c].name, value: c }), sandbox = as
|
|
|
9147
9479
|
let current = allTemplates[group];
|
|
9148
9480
|
return (!filterValue || current.name.match(filterRegex) || group.match(filterRegex) || current.expected.builder.match(filterRegex) || current.expected.framework.match(filterRegex) || current.expected.renderer.match(filterRegex)) && acc.push(group), acc;
|
|
9149
9481
|
}, []);
|
|
9150
|
-
if (choices.length === 0 && (
|
|
9151
|
-
|
|
9482
|
+
if (choices.length === 0 && (logger21.logBox(
|
|
9483
|
+
dedent16`
|
|
9152
9484
|
🔎 You filtered out all templates. 🔍
|
|
9153
9485
|
|
|
9154
|
-
After filtering all the templates with "${
|
|
9486
|
+
After filtering all the templates with "${import_picocolors16.default.yellow(
|
|
9155
9487
|
filterValue
|
|
9156
9488
|
)}", we found no results. Please try again with a different filter.
|
|
9157
9489
|
|
|
9158
9490
|
Available templates:
|
|
9159
|
-
${keys.map((key) =>
|
|
9491
|
+
${keys.map((key) => import_picocolors16.default.blue(`- ${key}`)).join(`
|
|
9160
9492
|
`)}
|
|
9161
9493
|
`.trim(),
|
|
9162
9494
|
{ borderStyle: "round", padding: 1, borderColor: "#F1618C" }
|
|
9163
|
-
), process.exit(1)), choices.length === 1 ? [templateId] = choices : (
|
|
9164
|
-
|
|
9165
|
-
🤗 Welcome to ${
|
|
9495
|
+
), process.exit(1)), choices.length === 1 ? [templateId] = choices : (logger21.logBox(
|
|
9496
|
+
dedent16`
|
|
9497
|
+
🤗 Welcome to ${import_picocolors16.default.yellow("sb sandbox")}! 🤗
|
|
9166
9498
|
|
|
9167
|
-
Create a ${
|
|
9499
|
+
Create a ${import_picocolors16.default.green("new project")} to minimally reproduce Storybook issues.
|
|
9168
9500
|
|
|
9169
9501
|
1. select an environment that most closely matches your project setup.
|
|
9170
9502
|
2. select a location for the reproduction, outside of your project.
|
|
@@ -9173,14 +9505,14 @@ var toChoices = (c) => ({ label: allTemplates[c].name, value: c }), sandbox = as
|
|
|
9173
9505
|
`.trim(),
|
|
9174
9506
|
{ borderStyle: "round", padding: 1, borderColor: "#F1618C" }
|
|
9175
9507
|
), templateId = await promptSelectedTemplate(choices)), !!!(templateId ?? null)) {
|
|
9176
|
-
|
|
9508
|
+
logger21.error("Somehow we got no templates. Please rerun this command!");
|
|
9177
9509
|
return;
|
|
9178
9510
|
}
|
|
9179
9511
|
if (selectedConfig = templateId ? allTemplates[templateId] : void 0, !selectedConfig)
|
|
9180
9512
|
throw new Error("\u{1F6A8} Sandbox: please specify a valid template type");
|
|
9181
9513
|
}
|
|
9182
9514
|
let selectedDirectory = outputDirectory, outputDirectoryName = outputDirectory || templateId;
|
|
9183
|
-
selectedDirectory && existsSync4(`${selectedDirectory}`) && (
|
|
9515
|
+
selectedDirectory && existsSync4(`${selectedDirectory}`) && (logger21.log(`\u26A0\uFE0F ${selectedDirectory} already exists! Overwriting...`), await rm(selectedDirectory, { recursive: !0, force: !0 })), selectedDirectory || (selectedDirectory = await prompt5.text(
|
|
9184
9516
|
{
|
|
9185
9517
|
message: "Enter the output directory",
|
|
9186
9518
|
initialValue: outputDirectoryName ?? void 0,
|
|
@@ -9188,21 +9520,21 @@ var toChoices = (c) => ({ label: allTemplates[c].name, value: c }), sandbox = as
|
|
|
9188
9520
|
},
|
|
9189
9521
|
{
|
|
9190
9522
|
onCancel: () => {
|
|
9191
|
-
|
|
9523
|
+
logger21.log("Command cancelled by the user. Exiting..."), process.exit(1);
|
|
9192
9524
|
}
|
|
9193
9525
|
}
|
|
9194
9526
|
)), invariant(selectedDirectory);
|
|
9195
9527
|
try {
|
|
9196
9528
|
let templateDestination = isAbsolute3(selectedDirectory) ? selectedDirectory : join(process.cwd(), selectedDirectory);
|
|
9197
|
-
|
|
9529
|
+
logger21.log(`\u{1F3C3} Adding ${selectedConfig.name} into ${templateDestination}`), logger21.log(`\u{1F4E6} Downloading sandbox template (${import_picocolors16.default.bold(downloadType)})...`);
|
|
9198
9530
|
try {
|
|
9199
9531
|
let gitPath = `storybookjs/sandboxes/tree/${branch}/${templateId}/${downloadType}`;
|
|
9200
9532
|
if (await mkdir2(templateDestination, { recursive: !0 }), (0, import_cross_spawn2.sync)("npx", ["gitpick@4.12.4", gitPath, templateDestination, "-o"], {
|
|
9201
9533
|
stdio: "inherit"
|
|
9202
9534
|
}), (await readdir(templateDestination)).length === 0) {
|
|
9203
|
-
let selected =
|
|
9204
|
-
throw new Error(
|
|
9205
|
-
Template downloaded from ${
|
|
9535
|
+
let selected = import_picocolors16.default.yellow(templateId);
|
|
9536
|
+
throw new Error(dedent16`
|
|
9537
|
+
Template downloaded from ${import_picocolors16.default.blue(gitPath)} is empty.
|
|
9206
9538
|
Are you use it exists? Or did you want to set ${selected} to inDevelopment first?
|
|
9207
9539
|
`);
|
|
9208
9540
|
}
|
|
@@ -9218,22 +9550,22 @@ var toChoices = (c) => ({ label: allTemplates[c].name, value: c }), sandbox = as
|
|
|
9218
9550
|
}), process.chdir(before);
|
|
9219
9551
|
}
|
|
9220
9552
|
} catch (err) {
|
|
9221
|
-
throw
|
|
9553
|
+
throw logger21.error(`\u{1F6A8} Failed to download sandbox template: ${String(err)}`), err;
|
|
9222
9554
|
}
|
|
9223
|
-
let initMessage = init ?
|
|
9555
|
+
let initMessage = init ? import_picocolors16.default.yellow(dedent16`
|
|
9224
9556
|
yarn install
|
|
9225
9557
|
yarn storybook
|
|
9226
|
-
`) : `Recreate your setup, then ${
|
|
9227
|
-
|
|
9228
|
-
|
|
9558
|
+
`) : `Recreate your setup, then ${import_picocolors16.default.yellow("npx storybook@latest init")}`;
|
|
9559
|
+
logger21.logBox(
|
|
9560
|
+
dedent16`
|
|
9229
9561
|
🎉 Your Storybook reproduction project is ready to use! 🎉
|
|
9230
9562
|
|
|
9231
|
-
${
|
|
9563
|
+
${import_picocolors16.default.yellow(`cd ${selectedDirectory}`)}
|
|
9232
9564
|
${initMessage}
|
|
9233
9565
|
|
|
9234
9566
|
Once you've recreated the problem you're experiencing, please:
|
|
9235
9567
|
|
|
9236
|
-
1. Document any additional steps in ${
|
|
9568
|
+
1. Document any additional steps in ${import_picocolors16.default.cyan("README.md")}
|
|
9237
9569
|
2. Publish the repository to github
|
|
9238
9570
|
3. Link to the repro repository in your issue
|
|
9239
9571
|
|
|
@@ -9242,21 +9574,21 @@ var toChoices = (c) => ({ label: allTemplates[c].name, value: c }), sandbox = as
|
|
|
9242
9574
|
{ rounded: !0 }
|
|
9243
9575
|
);
|
|
9244
9576
|
} catch (error) {
|
|
9245
|
-
throw
|
|
9577
|
+
throw logger21.error("\u{1F6A8} Failed to create sandbox"), error;
|
|
9246
9578
|
}
|
|
9247
9579
|
};
|
|
9248
9580
|
async function promptSelectedTemplate(choices) {
|
|
9249
|
-
return await
|
|
9581
|
+
return await prompt5.select({
|
|
9250
9582
|
message: "Select a template",
|
|
9251
9583
|
options: choices.map(toChoices)
|
|
9252
9584
|
});
|
|
9253
9585
|
}
|
|
9254
9586
|
|
|
9255
9587
|
// src/ai/index.ts
|
|
9256
|
-
import { writeFile as
|
|
9588
|
+
import { writeFile as writeFile10 } from "node:fs/promises";
|
|
9257
9589
|
import { resolve as resolve4 } from "node:path";
|
|
9258
9590
|
import { cache, getPrettyPackageManagerName } from "storybook/internal/common";
|
|
9259
|
-
import { logger as
|
|
9591
|
+
import { logger as logger23 } from "storybook/internal/node-logger";
|
|
9260
9592
|
import { telemetry } from "storybook/internal/telemetry";
|
|
9261
9593
|
import { SupportedLanguage as SupportedLanguage2 } from "storybook/internal/types";
|
|
9262
9594
|
|
|
@@ -9265,7 +9597,7 @@ import { existsSync as existsSync6 } from "node:fs";
|
|
|
9265
9597
|
import { resolve as resolve3 } from "node:path";
|
|
9266
9598
|
import { ProjectType as ProjectType2 } from "storybook/internal/cli";
|
|
9267
9599
|
import { HandledError, getProjectRoot } from "storybook/internal/common";
|
|
9268
|
-
import { logger as
|
|
9600
|
+
import { logger as logger22 } from "storybook/internal/node-logger";
|
|
9269
9601
|
import { NxProjectDetectedError } from "storybook/internal/server-errors";
|
|
9270
9602
|
import { SupportedLanguage } from "storybook/internal/types";
|
|
9271
9603
|
|
|
@@ -9280,7 +9612,7 @@ function up2(name, options) {
|
|
|
9280
9612
|
|
|
9281
9613
|
// ../create-storybook/src/services/ProjectTypeService.ts
|
|
9282
9614
|
var import_semver7 = __toESM(require_semver(), 1);
|
|
9283
|
-
import { dedent as
|
|
9615
|
+
import { dedent as dedent17 } from "ts-dedent";
|
|
9284
9616
|
var ProjectTypeService = class {
|
|
9285
9617
|
constructor(jsPackageManager) {
|
|
9286
9618
|
this.jsPackageManager = jsPackageManager;
|
|
@@ -9382,7 +9714,7 @@ var ProjectTypeService = class {
|
|
|
9382
9714
|
(t10) => !["undetected", "unsupported", "nx"].includes(String(t10))
|
|
9383
9715
|
).includes(projectTypeProvided))
|
|
9384
9716
|
return projectTypeProvided;
|
|
9385
|
-
throw
|
|
9717
|
+
throw logger22.error(
|
|
9386
9718
|
`The provided project type ${projectTypeProvided} was not recognized by Storybook`
|
|
9387
9719
|
), new HandledError(`Unknown project type supplied: ${projectTypeProvided}`);
|
|
9388
9720
|
}
|
|
@@ -9390,7 +9722,7 @@ var ProjectTypeService = class {
|
|
|
9390
9722
|
try {
|
|
9391
9723
|
let detectedType = await this.detectProjectType(options);
|
|
9392
9724
|
if (detectedType === ProjectType2.UNDETECTED || detectedType === null)
|
|
9393
|
-
throw
|
|
9725
|
+
throw logger22.error(dedent17`
|
|
9394
9726
|
Unable to initialize Storybook in this directory.
|
|
9395
9727
|
|
|
9396
9728
|
Storybook couldn't detect a supported framework or configuration for your project. Make sure you're inside a framework project (e.g., React, Vue, Svelte, Angular, Next.js) and that its dependencies are installed.
|
|
@@ -9403,14 +9735,16 @@ var ProjectTypeService = class {
|
|
|
9403
9735
|
throw new NxProjectDetectedError();
|
|
9404
9736
|
return detectedType;
|
|
9405
9737
|
} catch (err) {
|
|
9406
|
-
throw err instanceof HandledError || err instanceof NxProjectDetectedError ? err : (
|
|
9738
|
+
throw err instanceof HandledError || err instanceof NxProjectDetectedError ? err : (logger22.error(String(err)), new HandledError(err instanceof Error ? err.message : String(err)));
|
|
9407
9739
|
}
|
|
9408
9740
|
}
|
|
9409
9741
|
async detectLanguage() {
|
|
9410
9742
|
let language = SupportedLanguage.JAVASCRIPT;
|
|
9411
|
-
|
|
9412
|
-
|
|
9413
|
-
|
|
9743
|
+
return existsSync6("jsconfig.json") || (!!this.jsPackageManager.getAllDependencies().typescript ? (await this.detectIncompatiblePackageVersions()).length === 0 && (language = SupportedLanguage.TYPESCRIPT) : existsSync6("tsconfig.json") && (language = SupportedLanguage.TYPESCRIPT)), language;
|
|
9744
|
+
}
|
|
9745
|
+
/** Check installed tooling versions for TypeScript compatibility constraints */
|
|
9746
|
+
async detectIncompatiblePackageVersions() {
|
|
9747
|
+
let getModulePackageJSONVersion = async (pkg) => (await this.jsPackageManager.getModulePackageJSON(pkg))?.version ?? null, [
|
|
9414
9748
|
typescriptVersion,
|
|
9415
9749
|
prettierVersion,
|
|
9416
9750
|
babelPluginTransformTypescriptVersion,
|
|
@@ -9422,10 +9756,14 @@ var ProjectTypeService = class {
|
|
|
9422
9756
|
getModulePackageJSONVersion("@babel/plugin-transform-typescript"),
|
|
9423
9757
|
getModulePackageJSONVersion("@typescript-eslint/parser"),
|
|
9424
9758
|
getModulePackageJSONVersion("eslint-plugin-storybook")
|
|
9425
|
-
]), satisfies = (version2, range) => version2 ? import_semver7.default.satisfies(version2, range, { includePrerelease: !0 }) : !1;
|
|
9426
|
-
return
|
|
9427
|
-
|
|
9428
|
-
)
|
|
9759
|
+
]), satisfies = (version2, range) => version2 ? import_semver7.default.satisfies(version2, range, { includePrerelease: !0 }) : !1, incompatibleReasons = [];
|
|
9760
|
+
return typescriptVersion && !satisfies(typescriptVersion, ">=4.9.0") && incompatibleReasons.push(`typescript ${typescriptVersion} is below 4.9.0`), prettierVersion && !import_semver7.default.gte(prettierVersion, "2.8.0") && incompatibleReasons.push(`prettier ${prettierVersion} is below 2.8.0`), babelPluginTransformTypescriptVersion && !satisfies(babelPluginTransformTypescriptVersion, ">=7.20.0") && incompatibleReasons.push(
|
|
9761
|
+
`@babel/plugin-transform-typescript ${babelPluginTransformTypescriptVersion} is below 7.20.0`
|
|
9762
|
+
), typescriptEslintParserVersion && !satisfies(typescriptEslintParserVersion, ">=5.44.0") && incompatibleReasons.push(
|
|
9763
|
+
`@typescript-eslint/parser ${typescriptEslintParserVersion} is below 5.44.0`
|
|
9764
|
+
), eslintPluginStorybookVersion && !eslintPluginStorybookVersion.startsWith("0.0.0-") && !satisfies(eslintPluginStorybookVersion, ">=0.6.8") && incompatibleReasons.push(
|
|
9765
|
+
`eslint-plugin-storybook ${eslintPluginStorybookVersion} is below 0.6.8`
|
|
9766
|
+
), incompatibleReasons;
|
|
9429
9767
|
}
|
|
9430
9768
|
eqMajor(versionRange, major) {
|
|
9431
9769
|
return import_semver7.default.validRange(versionRange) ? import_semver7.default.minVersion(versionRange)?.major === major : !1;
|
|
@@ -9484,7 +9822,7 @@ var ProjectTypeService = class {
|
|
|
9484
9822
|
};
|
|
9485
9823
|
|
|
9486
9824
|
// src/ai/setup-prompts/index.ts
|
|
9487
|
-
import { dedent as
|
|
9825
|
+
import { dedent as dedent18 } from "ts-dedent";
|
|
9488
9826
|
|
|
9489
9827
|
// src/ai/utils/project-overview.ts
|
|
9490
9828
|
function getProjectOverview(projectInfo) {
|
|
@@ -9504,14 +9842,15 @@ function getProjectOverview(projectInfo) {
|
|
|
9504
9842
|
}
|
|
9505
9843
|
|
|
9506
9844
|
// src/ai/setup-prompts/index.ts
|
|
9507
|
-
var DEFAULT_PROMPT_NAME = "
|
|
9845
|
+
var DEFAULT_PROMPT_NAME = "optimized-tests", CURRENTLY_USED_PROMPT = {
|
|
9508
9846
|
[DEFAULT_PROMPT_NAME]: instructions
|
|
9509
9847
|
}, FORMERLY_USED_PROMPTS = {
|
|
9510
|
-
monorepo: async () => (await import("./monorepo-
|
|
9511
|
-
"optimized-tests": async () => (await import("./optimized-tests-
|
|
9512
|
-
"relaxed-limits": async () => (await import("./relaxed-limits-
|
|
9513
|
-
setup: async () => (await import("./setup-
|
|
9514
|
-
"pattern-copy-play": async () => (await import("./pattern-copy-play-
|
|
9848
|
+
monorepo: async () => (await import("./monorepo-UR4HJTCQ.js")).instructions,
|
|
9849
|
+
"optimized-tests": async () => (await import("./optimized-tests-NIXP5HST.js")).instructions,
|
|
9850
|
+
"relaxed-limits": async () => (await import("./relaxed-limits-IPKLQ6HO.js")).instructions,
|
|
9851
|
+
setup: async () => (await import("./setup-F6H7TC4J.js")).instructions,
|
|
9852
|
+
"pattern-copy-play": async () => (await import("./pattern-copy-play-OWJMSCMN.js")).instructions,
|
|
9853
|
+
"monorepo-optimized-tests-relaxed-limits-no-story-deletion": async () => (await import("./monorepo-optimized-tests-relaxed-limits-no-story-deletion-QDUUXYRM.js")).instructions
|
|
9515
9854
|
}, PROMPT_NAMES = [
|
|
9516
9855
|
...Object.keys(CURRENTLY_USED_PROMPT),
|
|
9517
9856
|
...Object.keys(FORMERLY_USED_PROMPTS)
|
|
@@ -9522,17 +9861,19 @@ function resolvePromptName() {
|
|
|
9522
9861
|
}
|
|
9523
9862
|
async function getAiSetupPrompt(projectInfo) {
|
|
9524
9863
|
let name = resolvePromptName();
|
|
9525
|
-
return (CURRENTLY_USED_PROMPT[name] ?? await FORMERLY_USED_PROMPTS[name]())(projectInfo);
|
|
9864
|
+
return { content: (CURRENTLY_USED_PROMPT[name] ?? await FORMERLY_USED_PROMPTS[name]())(projectInfo), name };
|
|
9526
9865
|
}
|
|
9527
9866
|
async function getAiSetupMarkdownOutput(projectInfo) {
|
|
9867
|
+
let { content, name } = await getAiSetupPrompt(projectInfo);
|
|
9528
9868
|
return {
|
|
9529
|
-
markdown:
|
|
9869
|
+
markdown: dedent18`
|
|
9530
9870
|
# Storybook Setup
|
|
9531
9871
|
|
|
9532
9872
|
${getProjectOverview(projectInfo)}
|
|
9533
9873
|
|
|
9534
|
-
${
|
|
9535
|
-
|
|
9874
|
+
${content}
|
|
9875
|
+
`,
|
|
9876
|
+
prompt: name
|
|
9536
9877
|
};
|
|
9537
9878
|
}
|
|
9538
9879
|
|
|
@@ -9545,7 +9886,7 @@ async function aiSetup(options) {
|
|
|
9545
9886
|
packageManagerName: packageManager
|
|
9546
9887
|
});
|
|
9547
9888
|
if (!data.frameworkPackage || !data.rendererPackage || !data.builderPackage) {
|
|
9548
|
-
|
|
9889
|
+
logger23.error(
|
|
9549
9890
|
"Could not detect framework, renderer, or builder from your Storybook config. Make sure you are running this command from your project root, or specify --config-dir."
|
|
9550
9891
|
);
|
|
9551
9892
|
return;
|
|
@@ -9568,39 +9909,42 @@ async function aiSetup(options) {
|
|
|
9568
9909
|
needsUserOnboarding
|
|
9569
9910
|
};
|
|
9570
9911
|
} catch (err) {
|
|
9571
|
-
|
|
9912
|
+
logger23.error(
|
|
9572
9913
|
`Failed to read Storybook configuration: ${err instanceof Error ? err.message : String(err)}`
|
|
9573
|
-
),
|
|
9914
|
+
), logger23.log(
|
|
9574
9915
|
"Make sure you are running this command from your project root, or specify --config-dir."
|
|
9575
9916
|
);
|
|
9576
9917
|
return;
|
|
9577
9918
|
}
|
|
9578
9919
|
if (projectInfo.rendererPackage !== "@storybook/react" || projectInfo.builderPackage !== "@storybook/builder-vite") {
|
|
9579
|
-
|
|
9920
|
+
logger23.log(
|
|
9580
9921
|
"AI-assisted setup is currently only available for projects using the React renderer with Vite builder. Detected renderer: " + projectInfo.rendererPackage + ", builder: " + projectInfo.builderPackage
|
|
9581
9922
|
);
|
|
9582
9923
|
return;
|
|
9583
9924
|
}
|
|
9584
|
-
let
|
|
9925
|
+
let result = await getAiSetupMarkdownOutput(projectInfo), markdownOutput = result.markdown;
|
|
9585
9926
|
if (await cache.set("ai-setup-ran", {
|
|
9586
9927
|
timestamp: Date.now(),
|
|
9928
|
+
runId: options.runId,
|
|
9587
9929
|
configDir: resolve4(projectInfo.configDir)
|
|
9588
9930
|
}).catch(() => {
|
|
9589
9931
|
}), await telemetry("ai-setup", {
|
|
9590
9932
|
cliOptions: {
|
|
9591
9933
|
output: output ? "file" : void 0,
|
|
9592
9934
|
configDir: projectInfo.configDir,
|
|
9593
|
-
packageManager: projectInfo.packageManager.type
|
|
9935
|
+
packageManager: projectInfo.packageManager.type,
|
|
9936
|
+
prompt: result.prompt
|
|
9594
9937
|
},
|
|
9595
9938
|
project: {
|
|
9596
9939
|
framework: projectInfo.framework,
|
|
9597
9940
|
renderer: projectInfo.rendererPackage,
|
|
9598
9941
|
builder: projectInfo.builderPackage,
|
|
9599
9942
|
language: projectInfo.language
|
|
9600
|
-
}
|
|
9943
|
+
},
|
|
9944
|
+
runId: options.runId
|
|
9601
9945
|
}), output) {
|
|
9602
9946
|
let outputPath = resolve4(output);
|
|
9603
|
-
await
|
|
9947
|
+
await writeFile10(outputPath, markdownOutput, "utf-8"), logger23.log(`Prompt written to ${outputPath}`);
|
|
9604
9948
|
} else
|
|
9605
9949
|
process.stdout.write(`${markdownOutput}
|
|
9606
9950
|
`);
|
|
@@ -9611,29 +9955,29 @@ function parseMajorVersion(version2) {
|
|
|
9611
9955
|
}
|
|
9612
9956
|
|
|
9613
9957
|
// src/upgrade.ts
|
|
9614
|
-
var import_cross_spawn3 = __toESM(require_cross_spawn(), 1),
|
|
9958
|
+
var import_cross_spawn3 = __toESM(require_cross_spawn(), 1), import_picocolors17 = __toESM(require_picocolors(), 1), import_semver8 = __toESM(require_semver(), 1);
|
|
9615
9959
|
import { PackageManagerName as PackageManagerName2 } from "storybook/internal/common";
|
|
9616
9960
|
import { HandledError as HandledError2, JsPackageManagerFactory as JsPackageManagerFactory2, isCorePackage as isCorePackage2 } from "storybook/internal/common";
|
|
9617
9961
|
import {
|
|
9618
9962
|
CLI_COLORS as CLI_COLORS4,
|
|
9619
9963
|
createHyperlink,
|
|
9620
9964
|
logTracker as logTracker3,
|
|
9621
|
-
logger as
|
|
9622
|
-
prompt as
|
|
9965
|
+
logger as logger25,
|
|
9966
|
+
prompt as prompt7
|
|
9623
9967
|
} from "storybook/internal/node-logger";
|
|
9624
9968
|
import {
|
|
9625
9969
|
UpgradeStorybookToLowerVersionError,
|
|
9626
9970
|
UpgradeStorybookUnknownCurrentVersionError
|
|
9627
9971
|
} from "storybook/internal/server-errors";
|
|
9628
9972
|
import { telemetry as telemetry2 } from "storybook/internal/telemetry";
|
|
9629
|
-
import { dedent as
|
|
9973
|
+
import { dedent as dedent19 } from "ts-dedent";
|
|
9630
9974
|
|
|
9631
9975
|
// src/automigrate/multi-project.ts
|
|
9632
|
-
import { CLI_COLORS as CLI_COLORS3, logger as
|
|
9976
|
+
import { CLI_COLORS as CLI_COLORS3, logger as logger24, prompt as prompt6 } from "storybook/internal/node-logger";
|
|
9633
9977
|
import { ErrorCollector, sanitizeError } from "storybook/internal/telemetry";
|
|
9634
9978
|
async function collectAutomigrationsAcrossProjects(options) {
|
|
9635
9979
|
let { fixes, projects, taskLog } = options, automigrationMap = /* @__PURE__ */ new Map();
|
|
9636
|
-
|
|
9980
|
+
logger24.debug(
|
|
9637
9981
|
`Starting automigration collection across ${projects.length} projects and ${fixes.length} fixes...`
|
|
9638
9982
|
);
|
|
9639
9983
|
function collectResult(fix, project, status, result) {
|
|
@@ -9655,10 +9999,10 @@ async function collectAutomigrationsAcrossProjects(options) {
|
|
|
9655
9999
|
}
|
|
9656
10000
|
for (let project of projects) {
|
|
9657
10001
|
let projectName = shortenPath(project.configDir);
|
|
9658
|
-
taskLog.message(`Checking automigrations for ${projectName}...`),
|
|
10002
|
+
taskLog.message(`Checking automigrations for ${projectName}...`), logger24.debug(`Processing project: ${projectName}`);
|
|
9659
10003
|
for (let fix of fixes)
|
|
9660
10004
|
try {
|
|
9661
|
-
|
|
10005
|
+
logger24.debug(`Checking fix ${fix.id} for project ${projectName}...`);
|
|
9662
10006
|
let checkOptions = {
|
|
9663
10007
|
packageManager: project.packageManager,
|
|
9664
10008
|
configDir: project.configDir,
|
|
@@ -9671,9 +10015,9 @@ async function collectAutomigrationsAcrossProjects(options) {
|
|
|
9671
10015
|
}, result = await fix.check(checkOptions);
|
|
9672
10016
|
result !== null ? collectResult(fix, project, "check_succeeded", result) : collectResult(fix, project, "not_applicable");
|
|
9673
10017
|
} catch (error) {
|
|
9674
|
-
collectResult(fix, project, "check_failed"),
|
|
10018
|
+
collectResult(fix, project, "check_failed"), logger24.debug(
|
|
9675
10019
|
`Failed to check fix ${fix.id} for project ${shortenPath(project.configDir)}.`
|
|
9676
|
-
),
|
|
10020
|
+
), logger24.debug(`${error instanceof Error ? error.stack : String(error)}`), ErrorCollector.addError(error);
|
|
9677
10021
|
}
|
|
9678
10022
|
}
|
|
9679
10023
|
let allAutomigrations = Array.from(automigrationMap.values()), applicableAutomigrations = allAutomigrations.filter(
|
|
@@ -9687,9 +10031,9 @@ async function collectAutomigrationsAcrossProjects(options) {
|
|
|
9687
10031
|
);
|
|
9688
10032
|
return taskLog.message(`
|
|
9689
10033
|
Automigrations detected:`), successAutomigrations.forEach((fixId) => {
|
|
9690
|
-
taskLog.message(`${CLI_COLORS3.success(`${
|
|
10034
|
+
taskLog.message(`${CLI_COLORS3.success(`${logger24.SYMBOLS.success} ${fixId}`)}`);
|
|
9691
10035
|
}), failedAutomigrations.forEach((fixId) => {
|
|
9692
|
-
taskLog.message(`${CLI_COLORS3.error(`${
|
|
10036
|
+
taskLog.message(`${CLI_COLORS3.error(`${logger24.SYMBOLS.error} ${fixId}`)}`);
|
|
9693
10037
|
}), failedAutomigrations.length > 0 ? taskLog.error(
|
|
9694
10038
|
`${failedAutomigrations.length} automigration ${failedAutomigrations.length > 1 ? "checks" : "check"} failed`
|
|
9695
10039
|
) : taskLog.success(
|
|
@@ -9707,12 +10051,12 @@ async function promptForAutomigrations(automigrations, options) {
|
|
|
9707
10051
|
if (automigrations.length === 0)
|
|
9708
10052
|
return [];
|
|
9709
10053
|
if (options.dryRun)
|
|
9710
|
-
return
|
|
9711
|
-
|
|
10054
|
+
return logger24.log("Detected automigrations (dry run - no changes will be made):"), automigrations.forEach(({ fix, reports: list }) => {
|
|
10055
|
+
logger24.log(` - ${fix.id} (${formatProjectDirs(list)})`);
|
|
9712
10056
|
}), [];
|
|
9713
10057
|
if (options.yes)
|
|
9714
|
-
return
|
|
9715
|
-
|
|
10058
|
+
return logger24.log("Running all detected automigrations:"), automigrations.forEach(({ fix, reports: list }) => {
|
|
10059
|
+
logger24.log(` - ${fix.id} (${formatProjectDirs(list)})`);
|
|
9716
10060
|
}), automigrations;
|
|
9717
10061
|
let choices = automigrations.map((am) => {
|
|
9718
10062
|
let hint = [];
|
|
@@ -9725,7 +10069,7 @@ async function promptForAutomigrations(automigrations, options) {
|
|
|
9725
10069
|
`),
|
|
9726
10070
|
defaultSelected: am.fix.defaultSelected ?? !0
|
|
9727
10071
|
};
|
|
9728
|
-
}), selectedIds = await
|
|
10072
|
+
}), selectedIds = await prompt6.multiselect({
|
|
9729
10073
|
message: "Select automigrations to run",
|
|
9730
10074
|
options: choices,
|
|
9731
10075
|
initialValues: choices.filter((c) => c.defaultSelected).map((c) => c.value),
|
|
@@ -9756,18 +10100,18 @@ async function runAutomigrationsForProjects(selectedAutomigrations, options) {
|
|
|
9756
10100
|
}
|
|
9757
10101
|
let projectIndex = 0;
|
|
9758
10102
|
for (let [configDir, projectAutomigration] of projectAutomigrationResults) {
|
|
9759
|
-
let countPrefix = projectAutomigrationResults.size > 1 ? `(${++projectIndex}/${projectAutomigrationResults.size}) ` : "", { project } = projectAutomigration[0], projectName = shortenPath(project.configDir), taskLog = applicableAutomigrations.length > 0 ?
|
|
10103
|
+
let countPrefix = projectAutomigrationResults.size > 1 ? `(${++projectIndex}/${projectAutomigrationResults.size}) ` : "", { project } = projectAutomigration[0], projectName = shortenPath(project.configDir), taskLog = applicableAutomigrations.length > 0 ? prompt6.taskLog({
|
|
9760
10104
|
id: `automigrate-${projectName}`,
|
|
9761
10105
|
title: `${countPrefix}Running automigrations for ${projectName}`
|
|
9762
10106
|
}) : {
|
|
9763
10107
|
message: (message) => {
|
|
9764
|
-
|
|
10108
|
+
logger24.debug(`${message}`);
|
|
9765
10109
|
},
|
|
9766
10110
|
error: (message) => {
|
|
9767
|
-
|
|
10111
|
+
logger24.debug(`${message}`);
|
|
9768
10112
|
},
|
|
9769
10113
|
success: (message) => {
|
|
9770
|
-
|
|
10114
|
+
logger24.debug(`${message}`);
|
|
9771
10115
|
}
|
|
9772
10116
|
}, fixResults = {}, fixFailures = {};
|
|
9773
10117
|
for (let automigration of projectAutomigration) {
|
|
@@ -9801,11 +10145,11 @@ async function runAutomigrationsForProjects(selectedAutomigrations, options) {
|
|
|
9801
10145
|
storiesPaths: project2.storiesPaths,
|
|
9802
10146
|
yes
|
|
9803
10147
|
};
|
|
9804
|
-
await fix.run(runOptions), fixResults[fix.id] = "succeeded" /* SUCCEEDED */, taskLog.message(CLI_COLORS3.success(`${
|
|
10148
|
+
await fix.run(runOptions), fixResults[fix.id] = "succeeded" /* SUCCEEDED */, taskLog.message(CLI_COLORS3.success(`${logger24.SYMBOLS.success} ${fix.id}`));
|
|
9805
10149
|
}
|
|
9806
10150
|
} catch (error) {
|
|
9807
10151
|
let errorMessage = (error instanceof Error ? error.stack : String(error)) ?? "Unknown error";
|
|
9808
|
-
fixResults[fix.id] = "failed" /* FAILED */, fixFailures[fix.id] = sanitizeError(error), taskLog.message(CLI_COLORS3.error(`${
|
|
10152
|
+
fixResults[fix.id] = "failed" /* FAILED */, fixFailures[fix.id] = sanitizeError(error), taskLog.message(CLI_COLORS3.error(`${logger24.SYMBOLS.error} ${automigration.fix.id}`)), logger24.debug(errorMessage), ErrorCollector.addError(error);
|
|
9809
10153
|
}
|
|
9810
10154
|
}
|
|
9811
10155
|
let automigrationsWithErrors = Object.values(fixResults).filter(
|
|
@@ -9834,7 +10178,7 @@ async function runAutomigrations(projects, options) {
|
|
|
9834
10178
|
beforeVersion: project.beforeVersion,
|
|
9835
10179
|
storiesPaths: project.storiesPaths,
|
|
9836
10180
|
hasCsfFactoryPreview: project.hasCsfFactoryPreview
|
|
9837
|
-
})), detectingAutomigrationTask =
|
|
10181
|
+
})), detectingAutomigrationTask = prompt6.taskLog({
|
|
9838
10182
|
id: "detect-automigrations",
|
|
9839
10183
|
title: projectAutomigrationData.length > 1 ? `Detecting automigrations for ${projectAutomigrationData.length} projects...` : "Detecting automigrations..."
|
|
9840
10184
|
}), detectedAutomigrations = await collectAutomigrationsAcrossProjects({
|
|
@@ -9915,29 +10259,29 @@ function logUpgradeResults(projectResults, detectedAutomigrations, doctorResults
|
|
|
9915
10259
|
doctorResults
|
|
9916
10260
|
);
|
|
9917
10261
|
if (failedProjects.length > 0) {
|
|
9918
|
-
if (logTracker3.enableLogWriting(),
|
|
10262
|
+
if (logTracker3.enableLogWriting(), logger25.step(
|
|
9919
10263
|
"The upgrade is complete, but some projects failed to upgrade or migrate completely. Please see the debug logs for more details."
|
|
9920
10264
|
), successfulProjects.length > 0) {
|
|
9921
10265
|
let successfulProjectsList = successfulProjects.map((dir) => ` \u2022 ${shortenPath(dir)}`).join(`
|
|
9922
10266
|
`);
|
|
9923
|
-
|
|
10267
|
+
logger25.log(`${CLI_COLORS4.success("Successfully upgraded:")}
|
|
9924
10268
|
${successfulProjectsList}`);
|
|
9925
10269
|
}
|
|
9926
10270
|
let failedProjectsList = failedProjects.map((dir) => ` \u2022 ${shortenPath(dir)}`).join(`
|
|
9927
10271
|
`);
|
|
9928
|
-
if (
|
|
10272
|
+
if (logger25.log(
|
|
9929
10273
|
`${CLI_COLORS4.error("Failed to upgrade:")}
|
|
9930
10274
|
Some automigrations failed, please check the logs in the log file for more details.
|
|
9931
10275
|
${failedProjectsList}`
|
|
9932
10276
|
), projectsWithNoFixes.length > 0) {
|
|
9933
10277
|
let projectList = projectsWithNoFixes.map((dir) => ` \u2022 ${shortenPath(dir)}`).join(`
|
|
9934
10278
|
`);
|
|
9935
|
-
|
|
10279
|
+
logger25.log(`${CLI_COLORS4.info("No applicable migrations:")}
|
|
9936
10280
|
${projectList}`);
|
|
9937
10281
|
}
|
|
9938
10282
|
} else
|
|
9939
|
-
Object.values(doctorResults).every((result) => result.status === "healthy") ?
|
|
9940
|
-
`${
|
|
10283
|
+
Object.values(doctorResults).every((result) => result.status === "healthy") ? logger25.step(`${CLI_COLORS4.success("Your project(s) have been upgraded successfully! \u{1F389}")}`) : logger25.step(
|
|
10284
|
+
`${import_picocolors17.default.yellow("Your project(s) have been upgraded successfully, but some issues were found which need your attention, please check Storybook doctor logs above.")}`
|
|
9941
10285
|
);
|
|
9942
10286
|
let automigrationLinks = detectedAutomigrations.filter(
|
|
9943
10287
|
(am) => Object.entries(projectResults).some(
|
|
@@ -9950,9 +10294,9 @@ ${projectList}`);
|
|
|
9950
10294
|
...automigrationLinks
|
|
9951
10295
|
].join(`
|
|
9952
10296
|
`);
|
|
9953
|
-
|
|
10297
|
+
logger25.log(automigrationLinksMessage);
|
|
9954
10298
|
}
|
|
9955
|
-
|
|
10299
|
+
logger25.log(
|
|
9956
10300
|
`For a full list of changes, please check our migration guide: ${CLI_COLORS4.cta("https://storybook.js.org/docs/releases/migration-guide?ref=upgrade")}`
|
|
9957
10301
|
);
|
|
9958
10302
|
}
|
|
@@ -9984,7 +10328,7 @@ async function sendMultiUpgradeTelemetry(options) {
|
|
|
9984
10328
|
hasUserInterrupted
|
|
9985
10329
|
});
|
|
9986
10330
|
} catch (error) {
|
|
9987
|
-
|
|
10331
|
+
logger25.debug(`Failed to send multi-upgrade telemetry: ${String(error)}`);
|
|
9988
10332
|
}
|
|
9989
10333
|
}
|
|
9990
10334
|
async function upgrade(options) {
|
|
@@ -9992,13 +10336,13 @@ async function upgrade(options) {
|
|
|
9992
10336
|
if (projectsResult === void 0 || projectsResult.selectedProjects.length === 0)
|
|
9993
10337
|
return;
|
|
9994
10338
|
let { allProjects, selectedProjects: storybookProjects } = projectsResult;
|
|
9995
|
-
storybookProjects.length > 1 ?
|
|
9996
|
-
${storybookProjects.map((p) => `${
|
|
9997
|
-
`)}`) :
|
|
9998
|
-
`Upgrading from ${
|
|
10339
|
+
storybookProjects.length > 1 ? logger25.info(`Upgrading the following projects:
|
|
10340
|
+
${storybookProjects.map((p) => `${import_picocolors17.default.cyan(shortenPath(p.configDir))}: ${import_picocolors17.default.bold(p.beforeVersion)} -> ${import_picocolors17.default.bold(p.currentCLIVersion)}`).join(`
|
|
10341
|
+
`)}`) : logger25.info(
|
|
10342
|
+
`Upgrading from ${import_picocolors17.default.bold(storybookProjects[0].beforeVersion)} to ${import_picocolors17.default.bold(storybookProjects[0].currentCLIVersion)}`
|
|
9999
10343
|
);
|
|
10000
10344
|
let automigrationResults = {}, doctorResults = {}, handleInterruption = async () => {
|
|
10001
|
-
throw
|
|
10345
|
+
throw logger25.log(`
|
|
10002
10346
|
|
|
10003
10347
|
Upgrade interrupted by user.`), allProjects.length > 1 && await sendMultiUpgradeTelemetry({
|
|
10004
10348
|
allProjects,
|
|
@@ -10011,7 +10355,7 @@ Upgrade interrupted by user.`), allProjects.length > 1 && await sendMultiUpgrade
|
|
|
10011
10355
|
process.on("SIGINT", handleInterruption), process.on("SIGTERM", handleInterruption);
|
|
10012
10356
|
try {
|
|
10013
10357
|
if (processAutoblockerResults(storybookProjects, (message) => {
|
|
10014
|
-
|
|
10358
|
+
logger25.error(dedent19`Blockers detected\n\n${message}`);
|
|
10015
10359
|
}))
|
|
10016
10360
|
throw new HandledError2("Blockers detected");
|
|
10017
10361
|
if (storybookProjects.some((project) => {
|
|
@@ -10023,14 +10367,14 @@ Upgrade interrupted by user.`), allProjects.length > 1 && await sendMultiUpgrade
|
|
|
10023
10367
|
if (!project.beforeVersion)
|
|
10024
10368
|
throw new UpgradeStorybookUnknownCurrentVersionError();
|
|
10025
10369
|
}), !options.dryRun) {
|
|
10026
|
-
let task =
|
|
10370
|
+
let task = prompt7.taskLog({
|
|
10027
10371
|
id: "upgrade-dependencies",
|
|
10028
10372
|
title: "Fetching versions to update package.json files.."
|
|
10029
10373
|
});
|
|
10030
10374
|
try {
|
|
10031
10375
|
let loggedPaths = [];
|
|
10032
10376
|
for (let project of storybookProjects) {
|
|
10033
|
-
|
|
10377
|
+
logger25.debug(`Updating dependencies in ${shortenPath(project.configDir)}...`);
|
|
10034
10378
|
let newPaths = project.packageManager.packageJsonPaths.map(shortenPath).filter((path4) => !loggedPaths.includes(path4));
|
|
10035
10379
|
newPaths.length > 0 && (task.message(newPaths.join(`
|
|
10036
10380
|
`)), loggedPaths.push(...newPaths)), await upgradeStorybookDependencies({
|
|
@@ -10048,17 +10392,17 @@ Upgrade interrupted by user.`), allProjects.length > 1 && await sendMultiUpgrade
|
|
|
10048
10392
|
}
|
|
10049
10393
|
}
|
|
10050
10394
|
let automigrationResults2 = {}, detectedAutomigrations = [];
|
|
10051
|
-
options.skipAutomigrations ?
|
|
10395
|
+
options.skipAutomigrations ? logger25.log("Skipping automigrations (--skip-automigrations).") : { automigrationResults: automigrationResults2, detectedAutomigrations } = await runAutomigrations(
|
|
10052
10396
|
storybookProjects,
|
|
10053
10397
|
options
|
|
10054
10398
|
);
|
|
10055
10399
|
let rootPackageManager = storybookProjects.length > 1 ? JsPackageManagerFactory2.getPackageManager({ force: options.packageManager }) : storybookProjects[0].packageManager;
|
|
10056
|
-
rootPackageManager.type === "npm" ? await rootPackageManager.installDependencies({ force: !0 }) : await rootPackageManager.installDependencies(), rootPackageManager.type !== PackageManagerName2.YARN1 && rootPackageManager.isStorybookInMonorepo() && (
|
|
10400
|
+
rootPackageManager.type === "npm" ? await rootPackageManager.installDependencies({ force: !0 }) : await rootPackageManager.installDependencies(), rootPackageManager.type !== PackageManagerName2.YARN1 && rootPackageManager.isStorybookInMonorepo() && (logger25.warn(
|
|
10057
10401
|
"Since you are in a monorepo, we advise you to deduplicate your dependencies. We can do this for you but it might take some time."
|
|
10058
|
-
), options.yes || await
|
|
10402
|
+
), options.yes || await prompt7.confirm({
|
|
10059
10403
|
message: `Execute ${rootPackageManager.getRunCommand("dedupe")}?`,
|
|
10060
10404
|
initialValue: !0
|
|
10061
|
-
}) ? rootPackageManager.type === "npm" ? await rootPackageManager.dedupeDependencies({ force: !0 }) : await rootPackageManager.dedupeDependencies() :
|
|
10405
|
+
}) ? rootPackageManager.type === "npm" ? await rootPackageManager.dedupeDependencies({ force: !0 }) : await rootPackageManager.dedupeDependencies() : logger25.log(
|
|
10062
10406
|
`If you find any issues running Storybook, you can run ${rootPackageManager.getRunCommand("dedupe")} manually to deduplicate your dependencies and try again.`
|
|
10063
10407
|
));
|
|
10064
10408
|
let doctorProjects = storybookProjects.map((project) => ({
|
|
@@ -10067,7 +10411,7 @@ Upgrade interrupted by user.`), allProjects.length > 1 && await sendMultiUpgrade
|
|
|
10067
10411
|
storybookVersion: project.currentCLIVersion,
|
|
10068
10412
|
mainConfig: project.mainConfig
|
|
10069
10413
|
}));
|
|
10070
|
-
|
|
10414
|
+
logger25.step("Checking the health of your project(s).."), doctorResults = await runMultiProjectDoctor(doctorProjects), displayDoctorResults(doctorResults) && logTracker3.enableLogWriting(), logUpgradeResults(automigrationResults2, detectedAutomigrations, doctorResults);
|
|
10071
10415
|
for (let project of storybookProjects) {
|
|
10072
10416
|
let resultData = automigrationResults2[project.configDir] || {
|
|
10073
10417
|
automigrationStatuses: {},
|
|
@@ -10103,13 +10447,13 @@ Upgrade interrupted by user.`), allProjects.length > 1 && await sendMultiUpgrade
|
|
|
10103
10447
|
// src/bin/run.ts
|
|
10104
10448
|
addToGlobalContext("cliVersion", versions5.storybook);
|
|
10105
10449
|
var handleCommandFailure = (logFilePath) => async (error) => {
|
|
10106
|
-
error instanceof HandledError3 ||
|
|
10450
|
+
error instanceof HandledError3 || logger26.error(String(error));
|
|
10107
10451
|
try {
|
|
10108
10452
|
let logFile = await logTracker4.writeToFile(logFilePath);
|
|
10109
|
-
|
|
10453
|
+
logger26.log(`Debug logs are written to: ${logFile}`);
|
|
10110
10454
|
} catch {
|
|
10111
10455
|
}
|
|
10112
|
-
|
|
10456
|
+
logger26.outro(""), process.exit(1);
|
|
10113
10457
|
}, command = (name) => program.command(name).option(
|
|
10114
10458
|
"--disable-telemetry",
|
|
10115
10459
|
"Disable sending telemetry data",
|
|
@@ -10119,21 +10463,21 @@ var handleCommandFailure = (logFilePath) => async (error) => {
|
|
|
10119
10463
|
"Write all debug logs to the specified file at the end of the run. Defaults to debug-storybook.log when [path] is not provided"
|
|
10120
10464
|
).option("--loglevel <trace | debug | info | warn | error | silent>", "Define log level", "info").hook("preAction", async (self2) => {
|
|
10121
10465
|
let options = self2.opts();
|
|
10122
|
-
options.debug &&
|
|
10466
|
+
options.debug && logger26.setLogLevel("debug"), options.loglevel && logger26.setLogLevel(options.loglevel), options.logfile && logTracker4.enableLogWriting();
|
|
10123
10467
|
try {
|
|
10124
10468
|
await globalSettings();
|
|
10125
10469
|
} catch (e) {
|
|
10126
|
-
|
|
10470
|
+
logger26.error(`Error loading global settings:
|
|
10127
10471
|
` + String(e));
|
|
10128
10472
|
}
|
|
10129
10473
|
}).hook("postAction", async (command2) => {
|
|
10130
10474
|
if (logTracker4.shouldWriteLogsToFile) {
|
|
10131
10475
|
try {
|
|
10132
10476
|
let logFile = await logTracker4.writeToFile(command2.getOptionValue("logfile"));
|
|
10133
|
-
|
|
10477
|
+
logger26.log(`Debug logs are written to: ${logFile}`);
|
|
10134
10478
|
} catch {
|
|
10135
10479
|
}
|
|
10136
|
-
|
|
10480
|
+
logger26.outro(CLI_COLORS5.success("Done!"));
|
|
10137
10481
|
}
|
|
10138
10482
|
});
|
|
10139
10483
|
command("init").description("Initialize Storybook into your project").option("-f --force", "Force add Storybook").option("-s --skip-install", "Skip installing deps").addOption(
|
|
@@ -10150,7 +10494,7 @@ command("add <addon>").description("Add an addon to your Storybook").addOption(
|
|
|
10150
10494
|
)
|
|
10151
10495
|
).option("-c, --config-dir <dir-name>", "Directory where to load Storybook configurations from").option("--skip-install", "Skip installing deps").option("-s --skip-postinstall", "Skip package specific postinstall config modifications").option("-y --yes", "Skip prompting the user").option("--skip-doctor", "Skip doctor check").action((addonName, options) => {
|
|
10152
10496
|
withTelemetry("add", { cliOptions: options }, async () => {
|
|
10153
|
-
|
|
10497
|
+
logger26.intro(`Setting up your project for ${addonName}`), await add(addonName, options), await telemetry3("add", { addon: addonName, source: "cli" }), logger26.outro("Done!");
|
|
10154
10498
|
}).catch(handleCommandFailure);
|
|
10155
10499
|
});
|
|
10156
10500
|
command("remove <addon>").description("Remove an addon from your Storybook").addOption(
|
|
@@ -10159,7 +10503,7 @@ command("remove <addon>").description("Remove an addon from your Storybook").add
|
|
|
10159
10503
|
)
|
|
10160
10504
|
).option("-c, --config-dir <dir-name>", "Directory where to load Storybook configurations from").option("-s --skip-install", "Skip installing deps").action(
|
|
10161
10505
|
(addonName, options) => withTelemetry("remove", { cliOptions: options }, async () => {
|
|
10162
|
-
|
|
10506
|
+
logger26.intro(`Removing ${addonName} from your Storybook`);
|
|
10163
10507
|
let packageManager = JsPackageManagerFactory3.getPackageManager({
|
|
10164
10508
|
configDir: options.configDir,
|
|
10165
10509
|
force: options.packageManager
|
|
@@ -10168,7 +10512,7 @@ command("remove <addon>").description("Remove an addon from your Storybook").add
|
|
|
10168
10512
|
configDir: options.configDir,
|
|
10169
10513
|
packageManager,
|
|
10170
10514
|
skipInstall: options.skipInstall
|
|
10171
|
-
}), await telemetry3("remove", { addon: addonName, source: "cli" }),
|
|
10515
|
+
}), await telemetry3("remove", { addon: addonName, source: "cli" }), logger26.outro("Done!");
|
|
10172
10516
|
}).catch(handleCommandFailure(options.logfile))
|
|
10173
10517
|
);
|
|
10174
10518
|
command("upgrade").description(`Upgrade your Storybook packages to v${versions5.storybook}`).addOption(
|
|
@@ -10186,12 +10530,12 @@ command("upgrade").description(`Upgrade your Storybook packages to v${versions5.
|
|
|
10186
10530
|
"upgrade",
|
|
10187
10531
|
{ cliOptions: { ...options, configDir: options.configDir?.[0] } },
|
|
10188
10532
|
async () => {
|
|
10189
|
-
|
|
10533
|
+
logger26.intro(`Storybook upgrade - v${versions5.storybook}`), await upgrade(options), logger26.outro("Storybook upgrade completed!");
|
|
10190
10534
|
}
|
|
10191
10535
|
).catch(handleCommandFailure(options.logfile));
|
|
10192
10536
|
});
|
|
10193
10537
|
command("info").description("Prints debugging information about the local environment").action(async () => {
|
|
10194
|
-
|
|
10538
|
+
logger26.log(import_picocolors18.default.bold(`
|
|
10195
10539
|
Storybook Environment Info:`));
|
|
10196
10540
|
let activePackageManager = JsPackageManagerFactory3.getPackageManager().type.replace(/\d/, ""), output = await import_envinfo.default.run({
|
|
10197
10541
|
System: ["OS", "CPU", "Shell"],
|
|
@@ -10200,10 +10544,10 @@ Storybook Environment Info:`));
|
|
|
10200
10544
|
npmPackages: "{@storybook/*,*storybook*,sb,chromatic}",
|
|
10201
10545
|
npmGlobalPackages: "{@storybook/*,*storybook*,sb,chromatic}"
|
|
10202
10546
|
}), activePackageManagerLine = output.match(new RegExp(`${activePackageManager}:.*`, "i"));
|
|
10203
|
-
|
|
10547
|
+
logger26.log(
|
|
10204
10548
|
output.replace(
|
|
10205
10549
|
activePackageManagerLine,
|
|
10206
|
-
|
|
10550
|
+
import_picocolors18.default.bold(`${activePackageManagerLine} <----- active`)
|
|
10207
10551
|
)
|
|
10208
10552
|
);
|
|
10209
10553
|
});
|
|
@@ -10215,12 +10559,12 @@ command("migrate [migration]").description("Run a Storybook codemod migration on
|
|
|
10215
10559
|
'Rename suffix of matching files after codemod has been applied, e.g. ".js:.ts"'
|
|
10216
10560
|
).action((migration, options) => {
|
|
10217
10561
|
withTelemetry("migrate", { cliOptions: options }, async () => {
|
|
10218
|
-
|
|
10562
|
+
logger26.intro(`Running ${migration} migration`), await migrate(migration, options), logger26.outro("Migration completed");
|
|
10219
10563
|
}).catch(handleCommandFailure(options.logfile));
|
|
10220
10564
|
});
|
|
10221
10565
|
command("sandbox [filterValue]").alias("repro").description("Create a sandbox from a set of possible templates").option("-o --output <outDir>", "Define an output directory").option("--no-init", "Whether to download a template without an initialized Storybook", !1).action((filterValue, options) => {
|
|
10222
|
-
|
|
10223
|
-
|
|
10566
|
+
logger26.intro("Creating a Storybook sandbox..."), sandbox({ filterValue, ...options }).catch(handleCommandFailure).finally(() => {
|
|
10567
|
+
logger26.outro("Done!");
|
|
10224
10568
|
});
|
|
10225
10569
|
});
|
|
10226
10570
|
command("link <repo-url-or-directory>").description("Pull down a repro from a URL (or a local directory), link it, and run storybook").option("--local", "Link a local directory already in your file system").option("--no-start", "Start the storybook", !0).action(
|
|
@@ -10235,7 +10579,7 @@ command("automigrate [fixId]").description("Check storybook for incompatibilitie
|
|
|
10235
10579
|
"The renderer package for the framework Storybook is using."
|
|
10236
10580
|
).option("--skip-doctor", "Skip doctor check").option("--glob <pattern>", "Glob pattern for story files (for csf-factories codemod)").action(async (fixId, options) => {
|
|
10237
10581
|
withTelemetry("automigrate", { cliOptions: options }, async () => {
|
|
10238
|
-
|
|
10582
|
+
logger26.intro(fixId ? `Running ${fixId} automigration` : "Running automigrations"), await doAutomigrate({ fixId, ...options }), logger26.outro("Done");
|
|
10239
10583
|
}).catch(handleCommandFailure(options.logfile));
|
|
10240
10584
|
});
|
|
10241
10585
|
command("doctor").description("Check Storybook for known problems and provide suggestions or fixes").addOption(
|
|
@@ -10244,7 +10588,7 @@ command("doctor").description("Check Storybook for known problems and provide su
|
|
|
10244
10588
|
)
|
|
10245
10589
|
).option("-c, --config-dir <dir-name>", "Directory of Storybook configuration").action(async (options) => {
|
|
10246
10590
|
withTelemetry("doctor", { cliOptions: options }, async () => {
|
|
10247
|
-
|
|
10591
|
+
logger26.intro("Doctoring Storybook"), await doctor(options), logger26.outro("Done");
|
|
10248
10592
|
}).catch(handleCommandFailure(options.logfile));
|
|
10249
10593
|
});
|
|
10250
10594
|
var aiCommand = command("ai").description("AI agent helpers for Storybook").option(
|
|
@@ -10256,7 +10600,7 @@ aiCommand.command("setup").description("Generate setup instructions to write sto
|
|
|
10256
10600
|
Object.values(PackageManagerName3)
|
|
10257
10601
|
)
|
|
10258
10602
|
).option("-c, --config-dir <dir-name>", "Directory of Storybook configuration").action(async (options, cmd) => {
|
|
10259
|
-
let
|
|
10603
|
+
let parentOptions = cmd.parent?.opts() ?? {}, runId = Math.random().toString(36), mergedOptions = { ...parentOptions, ...options, runId };
|
|
10260
10604
|
await withTelemetry("ai-setup", { cliOptions: mergedOptions }, async () => {
|
|
10261
10605
|
await aiSetup(mergedOptions);
|
|
10262
10606
|
}).catch(handleCommandFailure(mergedOptions.logfile));
|
|
@@ -10265,9 +10609,9 @@ aiCommand.action(() => {
|
|
|
10265
10609
|
aiCommand.outputHelp();
|
|
10266
10610
|
});
|
|
10267
10611
|
program.on("command:*", ([invalidCmd]) => {
|
|
10268
|
-
let errorMessage = ` Invalid command: ${
|
|
10612
|
+
let errorMessage = ` Invalid command: ${import_picocolors18.default.bold(invalidCmd)}.
|
|
10269
10613
|
See --help for a list of available commands.`, suggestion = program.commands.map((cmd) => cmd.name()).find((cmd) => leven(cmd, invalidCmd) < 3);
|
|
10270
10614
|
suggestion && (errorMessage += `
|
|
10271
|
-
Did you mean ${
|
|
10615
|
+
Did you mean ${import_picocolors18.default.yellow(suggestion)}?`), logger26.error(errorMessage), process.exit(1);
|
|
10272
10616
|
});
|
|
10273
10617
|
program.usage("<command> [options]").version(String(version)).parse(process.argv);
|