@storybook/cli 10.4.0-alpha.16 → 10.4.0-alpha.18
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-S3TJGYC2.js → block-dependencies-versions-QNRY6J2G.js} +11 -11
- package/dist/_node-chunks/{block-experimental-addon-test-WWZCXLB2.js → block-experimental-addon-test-PVMAM5F5.js} +9 -9
- package/dist/_node-chunks/{block-major-version-JNM4ZAKB.js → block-major-version-B4U62UGS.js} +9 -9
- package/dist/_node-chunks/{block-node-version-HDPTJUPH.js → block-node-version-7C63VYY4.js} +9 -9
- package/dist/_node-chunks/{block-webpack5-frameworks-TETWAJLZ.js → block-webpack5-frameworks-RODOEXCR.js} +11 -11
- package/dist/_node-chunks/{optimized-tests-MJI5NXQA.js → chunk-3VND4UGR.js} +25 -16
- package/dist/_node-chunks/chunk-4IHT72QP.js +11 -0
- package/dist/_node-chunks/{chunk-UKVJ7RQN.js → chunk-7GFZ5XLA.js} +7 -7
- package/dist/_node-chunks/{chunk-NDN75UAD.js → chunk-DZENT53U.js} +7 -7
- package/dist/_node-chunks/{chunk-QBNIQBHH.js → chunk-E7VJSF4M.js} +6 -6
- package/dist/_node-chunks/{chunk-TZ336D6R.js → chunk-F7HPRHMF.js} +6 -6
- package/dist/_node-chunks/{chunk-QQ7E4GEX.js → chunk-NMHZMXV5.js} +15 -15
- package/dist/_node-chunks/{chunk-7BQI2DK6.js → chunk-QRIT645X.js} +6 -6
- package/dist/_node-chunks/{chunk-7H4XHFS5.js → chunk-XXTFAID7.js} +120 -9
- package/dist/_node-chunks/{globby-5IGUGWE7.js → globby-V7VJJXY6.js} +8 -8
- package/dist/_node-chunks/{monorepo-4B4ULRGC.js → monorepo-TKU4OK5Y.js} +25 -16
- package/dist/_node-chunks/monorepo-optimized-tests-relaxed-limits-no-story-deletion-XF53WCEF.js +119 -0
- package/dist/_node-chunks/optimized-tests-PTOYROOU.js +20 -0
- package/dist/_node-chunks/{p-limit-VO6RWWBJ.js → p-limit-G7HGHMQY.js} +7 -7
- package/dist/_node-chunks/{chunk-JYLYIY6L.js → pattern-copy-play-Y43OOQWS.js} +11 -11
- package/dist/_node-chunks/{relaxed-limits-MKAIPGR2.js → relaxed-limits-IFYEA3SD.js} +25 -16
- package/dist/_node-chunks/{run-EJWCFREQ.js → run-7AY5NI5G.js} +645 -260
- package/dist/_node-chunks/{setup-PUNMMEGI.js → setup-N65V6RFL.js} +8 -8
- package/dist/bin/index.js +7 -7
- package/package.json +5 -4
- package/dist/_node-chunks/chunk-TSPB5MCI.js +0 -11
- package/dist/_node-chunks/pattern-copy-play-JNOATHUQ.js +0 -20
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_x95a390k9yf from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_x95a390k9yf from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_x95a390k9yf from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_x95a390k9yf.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_x95a390k9yf.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_x95a390k9yf.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-3VND4UGR.js";
|
|
15
|
+
import "./chunk-XXTFAID7.js";
|
|
16
|
+
import "./chunk-E7VJSF4M.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-NMHZMXV5.js";
|
|
35
35
|
import {
|
|
36
36
|
slash
|
|
37
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-7GFZ5XLA.js";
|
|
38
38
|
import {
|
|
39
39
|
require_semver
|
|
40
|
-
} from "./chunk-
|
|
40
|
+
} from "./chunk-DZENT53U.js";
|
|
41
41
|
import {
|
|
42
42
|
__commonJS,
|
|
43
43
|
__require,
|
|
44
44
|
__toESM
|
|
45
|
-
} from "./chunk-
|
|
45
|
+
} from "./chunk-F7HPRHMF.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.18";
|
|
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-V7VJJXY6.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-G7HGHMQY.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-G7HGHMQY.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-G7HGHMQY.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-G7HGHMQY.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-V7VJJXY6.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-V7VJJXY6.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-V7VJJXY6.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-V7VJJXY6.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 ? !1 : 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-G7HGHMQY.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-V7VJJXY6.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-V7VJJXY6.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-V7VJJXY6.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
|
},
|
|
@@ -8552,6 +8884,46 @@ var baseTemplates = {
|
|
|
8552
8884
|
},
|
|
8553
8885
|
skipTasks: ["e2e-tests", "e2e-tests-dev", "bench", "vitest-integration"]
|
|
8554
8886
|
},
|
|
8887
|
+
"tanstack-react-router/default-ts": {
|
|
8888
|
+
name: "TanStack React Router Latest (Vite | TypeScript)",
|
|
8889
|
+
script: "npx @tanstack/cli@latest create {{beforeDir}} --tailwind --router-only",
|
|
8890
|
+
expected: {
|
|
8891
|
+
framework: "@storybook/tanstack-react",
|
|
8892
|
+
renderer: "@storybook/react",
|
|
8893
|
+
builder: "@storybook/builder-vite"
|
|
8894
|
+
},
|
|
8895
|
+
modifications: {
|
|
8896
|
+
useCsfFactory: !0,
|
|
8897
|
+
extraDependencies: ["prop-types"],
|
|
8898
|
+
mainConfig: {
|
|
8899
|
+
framework: "@storybook/tanstack-react",
|
|
8900
|
+
features: {
|
|
8901
|
+
experimentalTestSyntax: !0
|
|
8902
|
+
}
|
|
8903
|
+
}
|
|
8904
|
+
},
|
|
8905
|
+
skipTasks: ["bench"]
|
|
8906
|
+
},
|
|
8907
|
+
"tanstack-react-start/default-ts": {
|
|
8908
|
+
name: "TanStack React Start Latest (Vite | TypeScript)",
|
|
8909
|
+
script: "npx @tanstack/cli@latest create {{beforeDir}} --tailwind",
|
|
8910
|
+
expected: {
|
|
8911
|
+
framework: "@storybook/tanstack-react",
|
|
8912
|
+
renderer: "@storybook/react",
|
|
8913
|
+
builder: "@storybook/builder-vite"
|
|
8914
|
+
},
|
|
8915
|
+
modifications: {
|
|
8916
|
+
useCsfFactory: !0,
|
|
8917
|
+
extraDependencies: ["prop-types"],
|
|
8918
|
+
mainConfig: {
|
|
8919
|
+
framework: "@storybook/tanstack-react",
|
|
8920
|
+
features: {
|
|
8921
|
+
experimentalTestSyntax: !0
|
|
8922
|
+
}
|
|
8923
|
+
}
|
|
8924
|
+
},
|
|
8925
|
+
skipTasks: ["bench"]
|
|
8926
|
+
},
|
|
8555
8927
|
"vue3-vite/default-js": {
|
|
8556
8928
|
name: "Vue v3 (Vite | JavaScript)",
|
|
8557
8929
|
script: "npm create vite --yes {{beforeDir}} -- --template vue",
|
|
@@ -9035,7 +9407,9 @@ var baseTemplates = {
|
|
|
9035
9407
|
"bench/react-vite-default-ts-test-build",
|
|
9036
9408
|
"bench/react-webpack-18-ts-test-build",
|
|
9037
9409
|
// 'ember/default-js',
|
|
9038
|
-
"react-rsbuild/default-ts"
|
|
9410
|
+
"react-rsbuild/default-ts",
|
|
9411
|
+
"tanstack-react-router/default-ts",
|
|
9412
|
+
"tanstack-react-start/default-ts"
|
|
9039
9413
|
], merged = [
|
|
9040
9414
|
...normal,
|
|
9041
9415
|
"react-webpack/18-ts",
|
|
@@ -9081,20 +9455,20 @@ var toChoices = (c) => ({ label: allTemplates[c].name, value: c }), sandbox = as
|
|
|
9081
9455
|
let selectedConfig = allTemplates[filterValue], templateId = selectedConfig ? filterValue : null, packageManager = JsPackageManagerFactory.getPackageManager({
|
|
9082
9456
|
force: PackageManagerName.NPM
|
|
9083
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 = {
|
|
9084
|
-
welcome: `Creating a Storybook ${
|
|
9085
|
-
notLatest:
|
|
9086
|
-
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)}!
|
|
9087
9461
|
You likely ran the init command through npx, which can use a locally cached version, to get the latest please run:
|
|
9088
|
-
${
|
|
9462
|
+
${import_picocolors16.default.bold("npx storybook@latest sandbox")}
|
|
9089
9463
|
|
|
9090
9464
|
You may want to CTRL+C to stop, and run with the latest version instead.
|
|
9091
9465
|
`),
|
|
9092
|
-
longInitTime:
|
|
9466
|
+
longInitTime: import_picocolors16.default.yellow(
|
|
9093
9467
|
"The creation of the sandbox will take longer, because we will need to run init."
|
|
9094
9468
|
),
|
|
9095
|
-
prerelease:
|
|
9469
|
+
prerelease: import_picocolors16.default.yellow("This is a pre-release version.")
|
|
9096
9470
|
};
|
|
9097
|
-
if (
|
|
9471
|
+
if (logger21.logBox(
|
|
9098
9472
|
[messages2.welcome].concat(isOutdated && !isPrerelease ? [messages2.notLatest] : []).concat(init && (isOutdated || isPrerelease) ? [messages2.longInitTime] : []).concat(isPrerelease ? [messages2.prerelease] : []).join(`
|
|
9099
9473
|
`),
|
|
9100
9474
|
{
|
|
@@ -9105,24 +9479,24 @@ var toChoices = (c) => ({ label: allTemplates[c].name, value: c }), sandbox = as
|
|
|
9105
9479
|
let current = allTemplates[group];
|
|
9106
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;
|
|
9107
9481
|
}, []);
|
|
9108
|
-
if (choices.length === 0 && (
|
|
9109
|
-
|
|
9482
|
+
if (choices.length === 0 && (logger21.logBox(
|
|
9483
|
+
dedent16`
|
|
9110
9484
|
🔎 You filtered out all templates. 🔍
|
|
9111
9485
|
|
|
9112
|
-
After filtering all the templates with "${
|
|
9486
|
+
After filtering all the templates with "${import_picocolors16.default.yellow(
|
|
9113
9487
|
filterValue
|
|
9114
9488
|
)}", we found no results. Please try again with a different filter.
|
|
9115
9489
|
|
|
9116
9490
|
Available templates:
|
|
9117
|
-
${keys.map((key) =>
|
|
9491
|
+
${keys.map((key) => import_picocolors16.default.blue(`- ${key}`)).join(`
|
|
9118
9492
|
`)}
|
|
9119
9493
|
`.trim(),
|
|
9120
9494
|
{ borderStyle: "round", padding: 1, borderColor: "#F1618C" }
|
|
9121
|
-
), process.exit(1)), choices.length === 1 ? [templateId] = choices : (
|
|
9122
|
-
|
|
9123
|
-
🤗 Welcome to ${
|
|
9495
|
+
), process.exit(1)), choices.length === 1 ? [templateId] = choices : (logger21.logBox(
|
|
9496
|
+
dedent16`
|
|
9497
|
+
🤗 Welcome to ${import_picocolors16.default.yellow("sb sandbox")}! 🤗
|
|
9124
9498
|
|
|
9125
|
-
Create a ${
|
|
9499
|
+
Create a ${import_picocolors16.default.green("new project")} to minimally reproduce Storybook issues.
|
|
9126
9500
|
|
|
9127
9501
|
1. select an environment that most closely matches your project setup.
|
|
9128
9502
|
2. select a location for the reproduction, outside of your project.
|
|
@@ -9131,14 +9505,14 @@ var toChoices = (c) => ({ label: allTemplates[c].name, value: c }), sandbox = as
|
|
|
9131
9505
|
`.trim(),
|
|
9132
9506
|
{ borderStyle: "round", padding: 1, borderColor: "#F1618C" }
|
|
9133
9507
|
), templateId = await promptSelectedTemplate(choices)), !!!(templateId ?? null)) {
|
|
9134
|
-
|
|
9508
|
+
logger21.error("Somehow we got no templates. Please rerun this command!");
|
|
9135
9509
|
return;
|
|
9136
9510
|
}
|
|
9137
9511
|
if (selectedConfig = templateId ? allTemplates[templateId] : void 0, !selectedConfig)
|
|
9138
9512
|
throw new Error("\u{1F6A8} Sandbox: please specify a valid template type");
|
|
9139
9513
|
}
|
|
9140
9514
|
let selectedDirectory = outputDirectory, outputDirectoryName = outputDirectory || templateId;
|
|
9141
|
-
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(
|
|
9142
9516
|
{
|
|
9143
9517
|
message: "Enter the output directory",
|
|
9144
9518
|
initialValue: outputDirectoryName ?? void 0,
|
|
@@ -9146,21 +9520,21 @@ var toChoices = (c) => ({ label: allTemplates[c].name, value: c }), sandbox = as
|
|
|
9146
9520
|
},
|
|
9147
9521
|
{
|
|
9148
9522
|
onCancel: () => {
|
|
9149
|
-
|
|
9523
|
+
logger21.log("Command cancelled by the user. Exiting..."), process.exit(1);
|
|
9150
9524
|
}
|
|
9151
9525
|
}
|
|
9152
9526
|
)), invariant(selectedDirectory);
|
|
9153
9527
|
try {
|
|
9154
9528
|
let templateDestination = isAbsolute3(selectedDirectory) ? selectedDirectory : join(process.cwd(), selectedDirectory);
|
|
9155
|
-
|
|
9529
|
+
logger21.log(`\u{1F3C3} Adding ${selectedConfig.name} into ${templateDestination}`), logger21.log(`\u{1F4E6} Downloading sandbox template (${import_picocolors16.default.bold(downloadType)})...`);
|
|
9156
9530
|
try {
|
|
9157
9531
|
let gitPath = `storybookjs/sandboxes/tree/${branch}/${templateId}/${downloadType}`;
|
|
9158
9532
|
if (await mkdir2(templateDestination, { recursive: !0 }), (0, import_cross_spawn2.sync)("npx", ["gitpick@4.12.4", gitPath, templateDestination, "-o"], {
|
|
9159
9533
|
stdio: "inherit"
|
|
9160
9534
|
}), (await readdir(templateDestination)).length === 0) {
|
|
9161
|
-
let selected =
|
|
9162
|
-
throw new Error(
|
|
9163
|
-
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.
|
|
9164
9538
|
Are you use it exists? Or did you want to set ${selected} to inDevelopment first?
|
|
9165
9539
|
`);
|
|
9166
9540
|
}
|
|
@@ -9176,22 +9550,22 @@ var toChoices = (c) => ({ label: allTemplates[c].name, value: c }), sandbox = as
|
|
|
9176
9550
|
}), process.chdir(before);
|
|
9177
9551
|
}
|
|
9178
9552
|
} catch (err) {
|
|
9179
|
-
throw
|
|
9553
|
+
throw logger21.error(`\u{1F6A8} Failed to download sandbox template: ${String(err)}`), err;
|
|
9180
9554
|
}
|
|
9181
|
-
let initMessage = init ?
|
|
9555
|
+
let initMessage = init ? import_picocolors16.default.yellow(dedent16`
|
|
9182
9556
|
yarn install
|
|
9183
9557
|
yarn storybook
|
|
9184
|
-
`) : `Recreate your setup, then ${
|
|
9185
|
-
|
|
9186
|
-
|
|
9558
|
+
`) : `Recreate your setup, then ${import_picocolors16.default.yellow("npx storybook@latest init")}`;
|
|
9559
|
+
logger21.logBox(
|
|
9560
|
+
dedent16`
|
|
9187
9561
|
🎉 Your Storybook reproduction project is ready to use! 🎉
|
|
9188
9562
|
|
|
9189
|
-
${
|
|
9563
|
+
${import_picocolors16.default.yellow(`cd ${selectedDirectory}`)}
|
|
9190
9564
|
${initMessage}
|
|
9191
9565
|
|
|
9192
9566
|
Once you've recreated the problem you're experiencing, please:
|
|
9193
9567
|
|
|
9194
|
-
1. Document any additional steps in ${
|
|
9568
|
+
1. Document any additional steps in ${import_picocolors16.default.cyan("README.md")}
|
|
9195
9569
|
2. Publish the repository to github
|
|
9196
9570
|
3. Link to the repro repository in your issue
|
|
9197
9571
|
|
|
@@ -9200,21 +9574,21 @@ var toChoices = (c) => ({ label: allTemplates[c].name, value: c }), sandbox = as
|
|
|
9200
9574
|
{ rounded: !0 }
|
|
9201
9575
|
);
|
|
9202
9576
|
} catch (error) {
|
|
9203
|
-
throw
|
|
9577
|
+
throw logger21.error("\u{1F6A8} Failed to create sandbox"), error;
|
|
9204
9578
|
}
|
|
9205
9579
|
};
|
|
9206
9580
|
async function promptSelectedTemplate(choices) {
|
|
9207
|
-
return await
|
|
9581
|
+
return await prompt5.select({
|
|
9208
9582
|
message: "Select a template",
|
|
9209
9583
|
options: choices.map(toChoices)
|
|
9210
9584
|
});
|
|
9211
9585
|
}
|
|
9212
9586
|
|
|
9213
9587
|
// src/ai/index.ts
|
|
9214
|
-
import { writeFile as
|
|
9588
|
+
import { writeFile as writeFile10 } from "node:fs/promises";
|
|
9215
9589
|
import { resolve as resolve4 } from "node:path";
|
|
9216
|
-
import { getPrettyPackageManagerName } from "storybook/internal/common";
|
|
9217
|
-
import { logger as
|
|
9590
|
+
import { cache, getPrettyPackageManagerName } from "storybook/internal/common";
|
|
9591
|
+
import { logger as logger23 } from "storybook/internal/node-logger";
|
|
9218
9592
|
import { telemetry } from "storybook/internal/telemetry";
|
|
9219
9593
|
import { SupportedLanguage as SupportedLanguage2 } from "storybook/internal/types";
|
|
9220
9594
|
|
|
@@ -9223,7 +9597,7 @@ import { existsSync as existsSync6 } from "node:fs";
|
|
|
9223
9597
|
import { resolve as resolve3 } from "node:path";
|
|
9224
9598
|
import { ProjectType as ProjectType2 } from "storybook/internal/cli";
|
|
9225
9599
|
import { HandledError, getProjectRoot } from "storybook/internal/common";
|
|
9226
|
-
import { logger as
|
|
9600
|
+
import { logger as logger22 } from "storybook/internal/node-logger";
|
|
9227
9601
|
import { NxProjectDetectedError } from "storybook/internal/server-errors";
|
|
9228
9602
|
import { SupportedLanguage } from "storybook/internal/types";
|
|
9229
9603
|
|
|
@@ -9238,7 +9612,7 @@ function up2(name, options) {
|
|
|
9238
9612
|
|
|
9239
9613
|
// ../create-storybook/src/services/ProjectTypeService.ts
|
|
9240
9614
|
var import_semver7 = __toESM(require_semver(), 1);
|
|
9241
|
-
import { dedent as
|
|
9615
|
+
import { dedent as dedent17 } from "ts-dedent";
|
|
9242
9616
|
var ProjectTypeService = class {
|
|
9243
9617
|
constructor(jsPackageManager) {
|
|
9244
9618
|
this.jsPackageManager = jsPackageManager;
|
|
@@ -9251,6 +9625,11 @@ var ProjectTypeService = class {
|
|
|
9251
9625
|
dependencies: ["nuxt"],
|
|
9252
9626
|
matcherFunction: ({ dependencies }) => dependencies?.every(Boolean) ?? !0
|
|
9253
9627
|
},
|
|
9628
|
+
{
|
|
9629
|
+
preset: ProjectType2.TANSTACK_REACT,
|
|
9630
|
+
dependencies: ["@tanstack/start", "@tanstack/react-start", "@tanstack/react-router"],
|
|
9631
|
+
matcherFunction: ({ dependencies }) => dependencies?.some(Boolean) ?? !1
|
|
9632
|
+
},
|
|
9254
9633
|
{
|
|
9255
9634
|
preset: ProjectType2.VUE3,
|
|
9256
9635
|
dependencies: {
|
|
@@ -9276,7 +9655,7 @@ var ProjectTypeService = class {
|
|
|
9276
9655
|
},
|
|
9277
9656
|
{
|
|
9278
9657
|
preset: ProjectType2.REACT_NATIVE,
|
|
9279
|
-
dependencies: ["react-native", "react-native-scripts"],
|
|
9658
|
+
dependencies: ["react-native", "react-native-scripts", "expo"],
|
|
9280
9659
|
matcherFunction: ({ dependencies }) => dependencies?.some(Boolean) ?? !1
|
|
9281
9660
|
},
|
|
9282
9661
|
{
|
|
@@ -9335,7 +9714,7 @@ var ProjectTypeService = class {
|
|
|
9335
9714
|
(t10) => !["undetected", "unsupported", "nx"].includes(String(t10))
|
|
9336
9715
|
).includes(projectTypeProvided))
|
|
9337
9716
|
return projectTypeProvided;
|
|
9338
|
-
throw
|
|
9717
|
+
throw logger22.error(
|
|
9339
9718
|
`The provided project type ${projectTypeProvided} was not recognized by Storybook`
|
|
9340
9719
|
), new HandledError(`Unknown project type supplied: ${projectTypeProvided}`);
|
|
9341
9720
|
}
|
|
@@ -9343,7 +9722,7 @@ var ProjectTypeService = class {
|
|
|
9343
9722
|
try {
|
|
9344
9723
|
let detectedType = await this.detectProjectType(options);
|
|
9345
9724
|
if (detectedType === ProjectType2.UNDETECTED || detectedType === null)
|
|
9346
|
-
throw
|
|
9725
|
+
throw logger22.error(dedent17`
|
|
9347
9726
|
Unable to initialize Storybook in this directory.
|
|
9348
9727
|
|
|
9349
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.
|
|
@@ -9356,7 +9735,7 @@ var ProjectTypeService = class {
|
|
|
9356
9735
|
throw new NxProjectDetectedError();
|
|
9357
9736
|
return detectedType;
|
|
9358
9737
|
} catch (err) {
|
|
9359
|
-
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)));
|
|
9360
9739
|
}
|
|
9361
9740
|
}
|
|
9362
9741
|
async detectLanguage() {
|
|
@@ -9376,7 +9755,7 @@ var ProjectTypeService = class {
|
|
|
9376
9755
|
getModulePackageJSONVersion("@typescript-eslint/parser"),
|
|
9377
9756
|
getModulePackageJSONVersion("eslint-plugin-storybook")
|
|
9378
9757
|
]), satisfies = (version2, range) => version2 ? import_semver7.default.satisfies(version2, range, { includePrerelease: !0 }) : !1;
|
|
9379
|
-
return isTypescriptDirectDependency && typescriptVersion ? satisfies(typescriptVersion, ">=4.9.0") && (!prettierVersion || import_semver7.default.gte(prettierVersion, "2.8.0")) && (!babelPluginTransformTypescriptVersion || satisfies(babelPluginTransformTypescriptVersion, ">=7.20.0")) && (!typescriptEslintParserVersion || satisfies(typescriptEslintParserVersion, ">=5.44.0")) && (!eslintPluginStorybookVersion || satisfies(eslintPluginStorybookVersion, ">=0.6.8")) ? language = SupportedLanguage.TYPESCRIPT :
|
|
9758
|
+
return isTypescriptDirectDependency && typescriptVersion ? satisfies(typescriptVersion, ">=4.9.0") && (!prettierVersion || import_semver7.default.gte(prettierVersion, "2.8.0")) && (!babelPluginTransformTypescriptVersion || satisfies(babelPluginTransformTypescriptVersion, ">=7.20.0")) && (!typescriptEslintParserVersion || satisfies(typescriptEslintParserVersion, ">=5.44.0")) && (!eslintPluginStorybookVersion || satisfies(eslintPluginStorybookVersion, ">=0.6.8")) ? language = SupportedLanguage.TYPESCRIPT : logger22.warn(
|
|
9380
9759
|
"Detected TypeScript < 4.9 or incompatible tooling, populating with JavaScript examples"
|
|
9381
9760
|
) : existsSync6("tsconfig.json") && (language = SupportedLanguage.TYPESCRIPT), language;
|
|
9382
9761
|
}
|
|
@@ -9437,7 +9816,7 @@ var ProjectTypeService = class {
|
|
|
9437
9816
|
};
|
|
9438
9817
|
|
|
9439
9818
|
// src/ai/setup-prompts/index.ts
|
|
9440
|
-
import { dedent as
|
|
9819
|
+
import { dedent as dedent18 } from "ts-dedent";
|
|
9441
9820
|
|
|
9442
9821
|
// src/ai/utils/project-overview.ts
|
|
9443
9822
|
function getProjectOverview(projectInfo) {
|
|
@@ -9457,14 +9836,15 @@ function getProjectOverview(projectInfo) {
|
|
|
9457
9836
|
}
|
|
9458
9837
|
|
|
9459
9838
|
// src/ai/setup-prompts/index.ts
|
|
9460
|
-
var DEFAULT_PROMPT_NAME = "
|
|
9839
|
+
var DEFAULT_PROMPT_NAME = "optimized-tests", CURRENTLY_USED_PROMPT = {
|
|
9461
9840
|
[DEFAULT_PROMPT_NAME]: instructions
|
|
9462
9841
|
}, FORMERLY_USED_PROMPTS = {
|
|
9463
|
-
monorepo: async () => (await import("./monorepo-
|
|
9464
|
-
"optimized-tests": async () => (await import("./optimized-tests-
|
|
9465
|
-
"relaxed-limits": async () => (await import("./relaxed-limits-
|
|
9466
|
-
setup: async () => (await import("./setup-
|
|
9467
|
-
"pattern-copy-play": async () => (await import("./pattern-copy-play-
|
|
9842
|
+
monorepo: async () => (await import("./monorepo-TKU4OK5Y.js")).instructions,
|
|
9843
|
+
"optimized-tests": async () => (await import("./optimized-tests-PTOYROOU.js")).instructions,
|
|
9844
|
+
"relaxed-limits": async () => (await import("./relaxed-limits-IFYEA3SD.js")).instructions,
|
|
9845
|
+
setup: async () => (await import("./setup-N65V6RFL.js")).instructions,
|
|
9846
|
+
"pattern-copy-play": async () => (await import("./pattern-copy-play-Y43OOQWS.js")).instructions,
|
|
9847
|
+
"monorepo-optimized-tests-relaxed-limits-no-story-deletion": async () => (await import("./monorepo-optimized-tests-relaxed-limits-no-story-deletion-XF53WCEF.js")).instructions
|
|
9468
9848
|
}, PROMPT_NAMES = [
|
|
9469
9849
|
...Object.keys(CURRENTLY_USED_PROMPT),
|
|
9470
9850
|
...Object.keys(FORMERLY_USED_PROMPTS)
|
|
@@ -9479,7 +9859,7 @@ async function getAiSetupPrompt(projectInfo) {
|
|
|
9479
9859
|
}
|
|
9480
9860
|
async function getAiSetupMarkdownOutput(projectInfo) {
|
|
9481
9861
|
return {
|
|
9482
|
-
markdown:
|
|
9862
|
+
markdown: dedent18`
|
|
9483
9863
|
# Storybook Setup
|
|
9484
9864
|
|
|
9485
9865
|
${getProjectOverview(projectInfo)}
|
|
@@ -9498,12 +9878,12 @@ async function aiSetup(options) {
|
|
|
9498
9878
|
packageManagerName: packageManager
|
|
9499
9879
|
});
|
|
9500
9880
|
if (!data.frameworkPackage || !data.rendererPackage || !data.builderPackage) {
|
|
9501
|
-
|
|
9881
|
+
logger23.error(
|
|
9502
9882
|
"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."
|
|
9503
9883
|
);
|
|
9504
9884
|
return;
|
|
9505
9885
|
}
|
|
9506
|
-
let majorVersion = data.versionInstalled ? parseMajorVersion(data.versionInstalled) : void 0, language = await new ProjectTypeService(data.packageManager).detectLanguage() === SupportedLanguage2.TYPESCRIPT ? "ts" : "js";
|
|
9886
|
+
let majorVersion = data.versionInstalled ? parseMajorVersion(data.versionInstalled) : void 0, language = await new ProjectTypeService(data.packageManager).detectLanguage() === SupportedLanguage2.TYPESCRIPT ? "ts" : "js", needsUserOnboarding = await cache.get("onboarding-pending", !1);
|
|
9507
9887
|
projectInfo = {
|
|
9508
9888
|
storybookVersion: data.versionInstalled,
|
|
9509
9889
|
majorVersion,
|
|
@@ -9517,24 +9897,29 @@ async function aiSetup(options) {
|
|
|
9517
9897
|
packageManager: data.packageManager,
|
|
9518
9898
|
packageManagerName: getPrettyPackageManagerName(data.packageManager.type),
|
|
9519
9899
|
language,
|
|
9520
|
-
hasCsfFactoryPreview: data.hasCsfFactoryPreview
|
|
9900
|
+
hasCsfFactoryPreview: data.hasCsfFactoryPreview,
|
|
9901
|
+
needsUserOnboarding
|
|
9521
9902
|
};
|
|
9522
9903
|
} catch (err) {
|
|
9523
|
-
|
|
9904
|
+
logger23.error(
|
|
9524
9905
|
`Failed to read Storybook configuration: ${err instanceof Error ? err.message : String(err)}`
|
|
9525
|
-
),
|
|
9906
|
+
), logger23.log(
|
|
9526
9907
|
"Make sure you are running this command from your project root, or specify --config-dir."
|
|
9527
9908
|
);
|
|
9528
9909
|
return;
|
|
9529
9910
|
}
|
|
9530
9911
|
if (projectInfo.rendererPackage !== "@storybook/react" || projectInfo.builderPackage !== "@storybook/builder-vite") {
|
|
9531
|
-
|
|
9912
|
+
logger23.log(
|
|
9532
9913
|
"AI-assisted setup is currently only available for projects using the React renderer with Vite builder. Detected renderer: " + projectInfo.rendererPackage + ", builder: " + projectInfo.builderPackage
|
|
9533
9914
|
);
|
|
9534
9915
|
return;
|
|
9535
9916
|
}
|
|
9536
9917
|
let markdownOutput = (await getAiSetupMarkdownOutput(projectInfo)).markdown;
|
|
9537
|
-
if (await
|
|
9918
|
+
if (await cache.set("ai-setup-ran", {
|
|
9919
|
+
timestamp: Date.now(),
|
|
9920
|
+
configDir: resolve4(projectInfo.configDir)
|
|
9921
|
+
}).catch(() => {
|
|
9922
|
+
}), await telemetry("ai-setup", {
|
|
9538
9923
|
cliOptions: {
|
|
9539
9924
|
output: output ? "file" : void 0,
|
|
9540
9925
|
configDir: projectInfo.configDir,
|
|
@@ -9548,7 +9933,7 @@ async function aiSetup(options) {
|
|
|
9548
9933
|
}
|
|
9549
9934
|
}), output) {
|
|
9550
9935
|
let outputPath = resolve4(output);
|
|
9551
|
-
await
|
|
9936
|
+
await writeFile10(outputPath, markdownOutput, "utf-8"), logger23.log(`Prompt written to ${outputPath}`);
|
|
9552
9937
|
} else
|
|
9553
9938
|
process.stdout.write(`${markdownOutput}
|
|
9554
9939
|
`);
|
|
@@ -9559,29 +9944,29 @@ function parseMajorVersion(version2) {
|
|
|
9559
9944
|
}
|
|
9560
9945
|
|
|
9561
9946
|
// src/upgrade.ts
|
|
9562
|
-
var import_cross_spawn3 = __toESM(require_cross_spawn(), 1),
|
|
9947
|
+
var import_cross_spawn3 = __toESM(require_cross_spawn(), 1), import_picocolors17 = __toESM(require_picocolors(), 1), import_semver8 = __toESM(require_semver(), 1);
|
|
9563
9948
|
import { PackageManagerName as PackageManagerName2 } from "storybook/internal/common";
|
|
9564
9949
|
import { HandledError as HandledError2, JsPackageManagerFactory as JsPackageManagerFactory2, isCorePackage as isCorePackage2 } from "storybook/internal/common";
|
|
9565
9950
|
import {
|
|
9566
9951
|
CLI_COLORS as CLI_COLORS4,
|
|
9567
9952
|
createHyperlink,
|
|
9568
9953
|
logTracker as logTracker3,
|
|
9569
|
-
logger as
|
|
9570
|
-
prompt as
|
|
9954
|
+
logger as logger25,
|
|
9955
|
+
prompt as prompt7
|
|
9571
9956
|
} from "storybook/internal/node-logger";
|
|
9572
9957
|
import {
|
|
9573
9958
|
UpgradeStorybookToLowerVersionError,
|
|
9574
9959
|
UpgradeStorybookUnknownCurrentVersionError
|
|
9575
9960
|
} from "storybook/internal/server-errors";
|
|
9576
9961
|
import { telemetry as telemetry2 } from "storybook/internal/telemetry";
|
|
9577
|
-
import { dedent as
|
|
9962
|
+
import { dedent as dedent19 } from "ts-dedent";
|
|
9578
9963
|
|
|
9579
9964
|
// src/automigrate/multi-project.ts
|
|
9580
|
-
import { CLI_COLORS as CLI_COLORS3, logger as
|
|
9965
|
+
import { CLI_COLORS as CLI_COLORS3, logger as logger24, prompt as prompt6 } from "storybook/internal/node-logger";
|
|
9581
9966
|
import { ErrorCollector, sanitizeError } from "storybook/internal/telemetry";
|
|
9582
9967
|
async function collectAutomigrationsAcrossProjects(options) {
|
|
9583
9968
|
let { fixes, projects, taskLog } = options, automigrationMap = /* @__PURE__ */ new Map();
|
|
9584
|
-
|
|
9969
|
+
logger24.debug(
|
|
9585
9970
|
`Starting automigration collection across ${projects.length} projects and ${fixes.length} fixes...`
|
|
9586
9971
|
);
|
|
9587
9972
|
function collectResult(fix, project, status, result) {
|
|
@@ -9603,10 +9988,10 @@ async function collectAutomigrationsAcrossProjects(options) {
|
|
|
9603
9988
|
}
|
|
9604
9989
|
for (let project of projects) {
|
|
9605
9990
|
let projectName = shortenPath(project.configDir);
|
|
9606
|
-
taskLog.message(`Checking automigrations for ${projectName}...`),
|
|
9991
|
+
taskLog.message(`Checking automigrations for ${projectName}...`), logger24.debug(`Processing project: ${projectName}`);
|
|
9607
9992
|
for (let fix of fixes)
|
|
9608
9993
|
try {
|
|
9609
|
-
|
|
9994
|
+
logger24.debug(`Checking fix ${fix.id} for project ${projectName}...`);
|
|
9610
9995
|
let checkOptions = {
|
|
9611
9996
|
packageManager: project.packageManager,
|
|
9612
9997
|
configDir: project.configDir,
|
|
@@ -9619,9 +10004,9 @@ async function collectAutomigrationsAcrossProjects(options) {
|
|
|
9619
10004
|
}, result = await fix.check(checkOptions);
|
|
9620
10005
|
result !== null ? collectResult(fix, project, "check_succeeded", result) : collectResult(fix, project, "not_applicable");
|
|
9621
10006
|
} catch (error) {
|
|
9622
|
-
collectResult(fix, project, "check_failed"),
|
|
10007
|
+
collectResult(fix, project, "check_failed"), logger24.debug(
|
|
9623
10008
|
`Failed to check fix ${fix.id} for project ${shortenPath(project.configDir)}.`
|
|
9624
|
-
),
|
|
10009
|
+
), logger24.debug(`${error instanceof Error ? error.stack : String(error)}`), ErrorCollector.addError(error);
|
|
9625
10010
|
}
|
|
9626
10011
|
}
|
|
9627
10012
|
let allAutomigrations = Array.from(automigrationMap.values()), applicableAutomigrations = allAutomigrations.filter(
|
|
@@ -9635,9 +10020,9 @@ async function collectAutomigrationsAcrossProjects(options) {
|
|
|
9635
10020
|
);
|
|
9636
10021
|
return taskLog.message(`
|
|
9637
10022
|
Automigrations detected:`), successAutomigrations.forEach((fixId) => {
|
|
9638
|
-
taskLog.message(`${CLI_COLORS3.success(`${
|
|
10023
|
+
taskLog.message(`${CLI_COLORS3.success(`${logger24.SYMBOLS.success} ${fixId}`)}`);
|
|
9639
10024
|
}), failedAutomigrations.forEach((fixId) => {
|
|
9640
|
-
taskLog.message(`${CLI_COLORS3.error(`${
|
|
10025
|
+
taskLog.message(`${CLI_COLORS3.error(`${logger24.SYMBOLS.error} ${fixId}`)}`);
|
|
9641
10026
|
}), failedAutomigrations.length > 0 ? taskLog.error(
|
|
9642
10027
|
`${failedAutomigrations.length} automigration ${failedAutomigrations.length > 1 ? "checks" : "check"} failed`
|
|
9643
10028
|
) : taskLog.success(
|
|
@@ -9655,12 +10040,12 @@ async function promptForAutomigrations(automigrations, options) {
|
|
|
9655
10040
|
if (automigrations.length === 0)
|
|
9656
10041
|
return [];
|
|
9657
10042
|
if (options.dryRun)
|
|
9658
|
-
return
|
|
9659
|
-
|
|
10043
|
+
return logger24.log("Detected automigrations (dry run - no changes will be made):"), automigrations.forEach(({ fix, reports: list }) => {
|
|
10044
|
+
logger24.log(` - ${fix.id} (${formatProjectDirs(list)})`);
|
|
9660
10045
|
}), [];
|
|
9661
10046
|
if (options.yes)
|
|
9662
|
-
return
|
|
9663
|
-
|
|
10047
|
+
return logger24.log("Running all detected automigrations:"), automigrations.forEach(({ fix, reports: list }) => {
|
|
10048
|
+
logger24.log(` - ${fix.id} (${formatProjectDirs(list)})`);
|
|
9664
10049
|
}), automigrations;
|
|
9665
10050
|
let choices = automigrations.map((am) => {
|
|
9666
10051
|
let hint = [];
|
|
@@ -9673,7 +10058,7 @@ async function promptForAutomigrations(automigrations, options) {
|
|
|
9673
10058
|
`),
|
|
9674
10059
|
defaultSelected: am.fix.defaultSelected ?? !0
|
|
9675
10060
|
};
|
|
9676
|
-
}), selectedIds = await
|
|
10061
|
+
}), selectedIds = await prompt6.multiselect({
|
|
9677
10062
|
message: "Select automigrations to run",
|
|
9678
10063
|
options: choices,
|
|
9679
10064
|
initialValues: choices.filter((c) => c.defaultSelected).map((c) => c.value),
|
|
@@ -9704,18 +10089,18 @@ async function runAutomigrationsForProjects(selectedAutomigrations, options) {
|
|
|
9704
10089
|
}
|
|
9705
10090
|
let projectIndex = 0;
|
|
9706
10091
|
for (let [configDir, projectAutomigration] of projectAutomigrationResults) {
|
|
9707
|
-
let countPrefix = projectAutomigrationResults.size > 1 ? `(${++projectIndex}/${projectAutomigrationResults.size}) ` : "", { project } = projectAutomigration[0], projectName = shortenPath(project.configDir), taskLog = applicableAutomigrations.length > 0 ?
|
|
10092
|
+
let countPrefix = projectAutomigrationResults.size > 1 ? `(${++projectIndex}/${projectAutomigrationResults.size}) ` : "", { project } = projectAutomigration[0], projectName = shortenPath(project.configDir), taskLog = applicableAutomigrations.length > 0 ? prompt6.taskLog({
|
|
9708
10093
|
id: `automigrate-${projectName}`,
|
|
9709
10094
|
title: `${countPrefix}Running automigrations for ${projectName}`
|
|
9710
10095
|
}) : {
|
|
9711
10096
|
message: (message) => {
|
|
9712
|
-
|
|
10097
|
+
logger24.debug(`${message}`);
|
|
9713
10098
|
},
|
|
9714
10099
|
error: (message) => {
|
|
9715
|
-
|
|
10100
|
+
logger24.debug(`${message}`);
|
|
9716
10101
|
},
|
|
9717
10102
|
success: (message) => {
|
|
9718
|
-
|
|
10103
|
+
logger24.debug(`${message}`);
|
|
9719
10104
|
}
|
|
9720
10105
|
}, fixResults = {}, fixFailures = {};
|
|
9721
10106
|
for (let automigration of projectAutomigration) {
|
|
@@ -9749,11 +10134,11 @@ async function runAutomigrationsForProjects(selectedAutomigrations, options) {
|
|
|
9749
10134
|
storiesPaths: project2.storiesPaths,
|
|
9750
10135
|
yes
|
|
9751
10136
|
};
|
|
9752
|
-
await fix.run(runOptions), fixResults[fix.id] = "succeeded" /* SUCCEEDED */, taskLog.message(CLI_COLORS3.success(`${
|
|
10137
|
+
await fix.run(runOptions), fixResults[fix.id] = "succeeded" /* SUCCEEDED */, taskLog.message(CLI_COLORS3.success(`${logger24.SYMBOLS.success} ${fix.id}`));
|
|
9753
10138
|
}
|
|
9754
10139
|
} catch (error) {
|
|
9755
10140
|
let errorMessage = (error instanceof Error ? error.stack : String(error)) ?? "Unknown error";
|
|
9756
|
-
fixResults[fix.id] = "failed" /* FAILED */, fixFailures[fix.id] = sanitizeError(error), taskLog.message(CLI_COLORS3.error(`${
|
|
10141
|
+
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);
|
|
9757
10142
|
}
|
|
9758
10143
|
}
|
|
9759
10144
|
let automigrationsWithErrors = Object.values(fixResults).filter(
|
|
@@ -9782,7 +10167,7 @@ async function runAutomigrations(projects, options) {
|
|
|
9782
10167
|
beforeVersion: project.beforeVersion,
|
|
9783
10168
|
storiesPaths: project.storiesPaths,
|
|
9784
10169
|
hasCsfFactoryPreview: project.hasCsfFactoryPreview
|
|
9785
|
-
})), detectingAutomigrationTask =
|
|
10170
|
+
})), detectingAutomigrationTask = prompt6.taskLog({
|
|
9786
10171
|
id: "detect-automigrations",
|
|
9787
10172
|
title: projectAutomigrationData.length > 1 ? `Detecting automigrations for ${projectAutomigrationData.length} projects...` : "Detecting automigrations..."
|
|
9788
10173
|
}), detectedAutomigrations = await collectAutomigrationsAcrossProjects({
|
|
@@ -9863,29 +10248,29 @@ function logUpgradeResults(projectResults, detectedAutomigrations, doctorResults
|
|
|
9863
10248
|
doctorResults
|
|
9864
10249
|
);
|
|
9865
10250
|
if (failedProjects.length > 0) {
|
|
9866
|
-
if (logTracker3.enableLogWriting(),
|
|
10251
|
+
if (logTracker3.enableLogWriting(), logger25.step(
|
|
9867
10252
|
"The upgrade is complete, but some projects failed to upgrade or migrate completely. Please see the debug logs for more details."
|
|
9868
10253
|
), successfulProjects.length > 0) {
|
|
9869
10254
|
let successfulProjectsList = successfulProjects.map((dir) => ` \u2022 ${shortenPath(dir)}`).join(`
|
|
9870
10255
|
`);
|
|
9871
|
-
|
|
10256
|
+
logger25.log(`${CLI_COLORS4.success("Successfully upgraded:")}
|
|
9872
10257
|
${successfulProjectsList}`);
|
|
9873
10258
|
}
|
|
9874
10259
|
let failedProjectsList = failedProjects.map((dir) => ` \u2022 ${shortenPath(dir)}`).join(`
|
|
9875
10260
|
`);
|
|
9876
|
-
if (
|
|
10261
|
+
if (logger25.log(
|
|
9877
10262
|
`${CLI_COLORS4.error("Failed to upgrade:")}
|
|
9878
10263
|
Some automigrations failed, please check the logs in the log file for more details.
|
|
9879
10264
|
${failedProjectsList}`
|
|
9880
10265
|
), projectsWithNoFixes.length > 0) {
|
|
9881
10266
|
let projectList = projectsWithNoFixes.map((dir) => ` \u2022 ${shortenPath(dir)}`).join(`
|
|
9882
10267
|
`);
|
|
9883
|
-
|
|
10268
|
+
logger25.log(`${CLI_COLORS4.info("No applicable migrations:")}
|
|
9884
10269
|
${projectList}`);
|
|
9885
10270
|
}
|
|
9886
10271
|
} else
|
|
9887
|
-
Object.values(doctorResults).every((result) => result.status === "healthy") ?
|
|
9888
|
-
`${
|
|
10272
|
+
Object.values(doctorResults).every((result) => result.status === "healthy") ? logger25.step(`${CLI_COLORS4.success("Your project(s) have been upgraded successfully! \u{1F389}")}`) : logger25.step(
|
|
10273
|
+
`${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.")}`
|
|
9889
10274
|
);
|
|
9890
10275
|
let automigrationLinks = detectedAutomigrations.filter(
|
|
9891
10276
|
(am) => Object.entries(projectResults).some(
|
|
@@ -9898,9 +10283,9 @@ ${projectList}`);
|
|
|
9898
10283
|
...automigrationLinks
|
|
9899
10284
|
].join(`
|
|
9900
10285
|
`);
|
|
9901
|
-
|
|
10286
|
+
logger25.log(automigrationLinksMessage);
|
|
9902
10287
|
}
|
|
9903
|
-
|
|
10288
|
+
logger25.log(
|
|
9904
10289
|
`For a full list of changes, please check our migration guide: ${CLI_COLORS4.cta("https://storybook.js.org/docs/releases/migration-guide?ref=upgrade")}`
|
|
9905
10290
|
);
|
|
9906
10291
|
}
|
|
@@ -9932,7 +10317,7 @@ async function sendMultiUpgradeTelemetry(options) {
|
|
|
9932
10317
|
hasUserInterrupted
|
|
9933
10318
|
});
|
|
9934
10319
|
} catch (error) {
|
|
9935
|
-
|
|
10320
|
+
logger25.debug(`Failed to send multi-upgrade telemetry: ${String(error)}`);
|
|
9936
10321
|
}
|
|
9937
10322
|
}
|
|
9938
10323
|
async function upgrade(options) {
|
|
@@ -9940,13 +10325,13 @@ async function upgrade(options) {
|
|
|
9940
10325
|
if (projectsResult === void 0 || projectsResult.selectedProjects.length === 0)
|
|
9941
10326
|
return;
|
|
9942
10327
|
let { allProjects, selectedProjects: storybookProjects } = projectsResult;
|
|
9943
|
-
storybookProjects.length > 1 ?
|
|
9944
|
-
${storybookProjects.map((p) => `${
|
|
9945
|
-
`)}`) :
|
|
9946
|
-
`Upgrading from ${
|
|
10328
|
+
storybookProjects.length > 1 ? logger25.info(`Upgrading the following projects:
|
|
10329
|
+
${storybookProjects.map((p) => `${import_picocolors17.default.cyan(shortenPath(p.configDir))}: ${import_picocolors17.default.bold(p.beforeVersion)} -> ${import_picocolors17.default.bold(p.currentCLIVersion)}`).join(`
|
|
10330
|
+
`)}`) : logger25.info(
|
|
10331
|
+
`Upgrading from ${import_picocolors17.default.bold(storybookProjects[0].beforeVersion)} to ${import_picocolors17.default.bold(storybookProjects[0].currentCLIVersion)}`
|
|
9947
10332
|
);
|
|
9948
10333
|
let automigrationResults = {}, doctorResults = {}, handleInterruption = async () => {
|
|
9949
|
-
throw
|
|
10334
|
+
throw logger25.log(`
|
|
9950
10335
|
|
|
9951
10336
|
Upgrade interrupted by user.`), allProjects.length > 1 && await sendMultiUpgradeTelemetry({
|
|
9952
10337
|
allProjects,
|
|
@@ -9959,7 +10344,7 @@ Upgrade interrupted by user.`), allProjects.length > 1 && await sendMultiUpgrade
|
|
|
9959
10344
|
process.on("SIGINT", handleInterruption), process.on("SIGTERM", handleInterruption);
|
|
9960
10345
|
try {
|
|
9961
10346
|
if (processAutoblockerResults(storybookProjects, (message) => {
|
|
9962
|
-
|
|
10347
|
+
logger25.error(dedent19`Blockers detected\n\n${message}`);
|
|
9963
10348
|
}))
|
|
9964
10349
|
throw new HandledError2("Blockers detected");
|
|
9965
10350
|
if (storybookProjects.some((project) => {
|
|
@@ -9971,14 +10356,14 @@ Upgrade interrupted by user.`), allProjects.length > 1 && await sendMultiUpgrade
|
|
|
9971
10356
|
if (!project.beforeVersion)
|
|
9972
10357
|
throw new UpgradeStorybookUnknownCurrentVersionError();
|
|
9973
10358
|
}), !options.dryRun) {
|
|
9974
|
-
let task =
|
|
10359
|
+
let task = prompt7.taskLog({
|
|
9975
10360
|
id: "upgrade-dependencies",
|
|
9976
10361
|
title: "Fetching versions to update package.json files.."
|
|
9977
10362
|
});
|
|
9978
10363
|
try {
|
|
9979
10364
|
let loggedPaths = [];
|
|
9980
10365
|
for (let project of storybookProjects) {
|
|
9981
|
-
|
|
10366
|
+
logger25.debug(`Updating dependencies in ${shortenPath(project.configDir)}...`);
|
|
9982
10367
|
let newPaths = project.packageManager.packageJsonPaths.map(shortenPath).filter((path4) => !loggedPaths.includes(path4));
|
|
9983
10368
|
newPaths.length > 0 && (task.message(newPaths.join(`
|
|
9984
10369
|
`)), loggedPaths.push(...newPaths)), await upgradeStorybookDependencies({
|
|
@@ -9996,17 +10381,17 @@ Upgrade interrupted by user.`), allProjects.length > 1 && await sendMultiUpgrade
|
|
|
9996
10381
|
}
|
|
9997
10382
|
}
|
|
9998
10383
|
let automigrationResults2 = {}, detectedAutomigrations = [];
|
|
9999
|
-
options.skipAutomigrations ?
|
|
10384
|
+
options.skipAutomigrations ? logger25.log("Skipping automigrations (--skip-automigrations).") : { automigrationResults: automigrationResults2, detectedAutomigrations } = await runAutomigrations(
|
|
10000
10385
|
storybookProjects,
|
|
10001
10386
|
options
|
|
10002
10387
|
);
|
|
10003
10388
|
let rootPackageManager = storybookProjects.length > 1 ? JsPackageManagerFactory2.getPackageManager({ force: options.packageManager }) : storybookProjects[0].packageManager;
|
|
10004
|
-
rootPackageManager.type === "npm" ? await rootPackageManager.installDependencies({ force: !0 }) : await rootPackageManager.installDependencies(), rootPackageManager.type !== PackageManagerName2.YARN1 && rootPackageManager.isStorybookInMonorepo() && (
|
|
10389
|
+
rootPackageManager.type === "npm" ? await rootPackageManager.installDependencies({ force: !0 }) : await rootPackageManager.installDependencies(), rootPackageManager.type !== PackageManagerName2.YARN1 && rootPackageManager.isStorybookInMonorepo() && (logger25.warn(
|
|
10005
10390
|
"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."
|
|
10006
|
-
), options.yes || await
|
|
10391
|
+
), options.yes || await prompt7.confirm({
|
|
10007
10392
|
message: `Execute ${rootPackageManager.getRunCommand("dedupe")}?`,
|
|
10008
10393
|
initialValue: !0
|
|
10009
|
-
}) ? rootPackageManager.type === "npm" ? await rootPackageManager.dedupeDependencies({ force: !0 }) : await rootPackageManager.dedupeDependencies() :
|
|
10394
|
+
}) ? rootPackageManager.type === "npm" ? await rootPackageManager.dedupeDependencies({ force: !0 }) : await rootPackageManager.dedupeDependencies() : logger25.log(
|
|
10010
10395
|
`If you find any issues running Storybook, you can run ${rootPackageManager.getRunCommand("dedupe")} manually to deduplicate your dependencies and try again.`
|
|
10011
10396
|
));
|
|
10012
10397
|
let doctorProjects = storybookProjects.map((project) => ({
|
|
@@ -10015,7 +10400,7 @@ Upgrade interrupted by user.`), allProjects.length > 1 && await sendMultiUpgrade
|
|
|
10015
10400
|
storybookVersion: project.currentCLIVersion,
|
|
10016
10401
|
mainConfig: project.mainConfig
|
|
10017
10402
|
}));
|
|
10018
|
-
|
|
10403
|
+
logger25.step("Checking the health of your project(s).."), doctorResults = await runMultiProjectDoctor(doctorProjects), displayDoctorResults(doctorResults) && logTracker3.enableLogWriting(), logUpgradeResults(automigrationResults2, detectedAutomigrations, doctorResults);
|
|
10019
10404
|
for (let project of storybookProjects) {
|
|
10020
10405
|
let resultData = automigrationResults2[project.configDir] || {
|
|
10021
10406
|
automigrationStatuses: {},
|
|
@@ -10051,13 +10436,13 @@ Upgrade interrupted by user.`), allProjects.length > 1 && await sendMultiUpgrade
|
|
|
10051
10436
|
// src/bin/run.ts
|
|
10052
10437
|
addToGlobalContext("cliVersion", versions5.storybook);
|
|
10053
10438
|
var handleCommandFailure = (logFilePath) => async (error) => {
|
|
10054
|
-
error instanceof HandledError3 ||
|
|
10439
|
+
error instanceof HandledError3 || logger26.error(String(error));
|
|
10055
10440
|
try {
|
|
10056
10441
|
let logFile = await logTracker4.writeToFile(logFilePath);
|
|
10057
|
-
|
|
10442
|
+
logger26.log(`Debug logs are written to: ${logFile}`);
|
|
10058
10443
|
} catch {
|
|
10059
10444
|
}
|
|
10060
|
-
|
|
10445
|
+
logger26.outro(""), process.exit(1);
|
|
10061
10446
|
}, command = (name) => program.command(name).option(
|
|
10062
10447
|
"--disable-telemetry",
|
|
10063
10448
|
"Disable sending telemetry data",
|
|
@@ -10067,21 +10452,21 @@ var handleCommandFailure = (logFilePath) => async (error) => {
|
|
|
10067
10452
|
"Write all debug logs to the specified file at the end of the run. Defaults to debug-storybook.log when [path] is not provided"
|
|
10068
10453
|
).option("--loglevel <trace | debug | info | warn | error | silent>", "Define log level", "info").hook("preAction", async (self2) => {
|
|
10069
10454
|
let options = self2.opts();
|
|
10070
|
-
options.debug &&
|
|
10455
|
+
options.debug && logger26.setLogLevel("debug"), options.loglevel && logger26.setLogLevel(options.loglevel), options.logfile && logTracker4.enableLogWriting();
|
|
10071
10456
|
try {
|
|
10072
10457
|
await globalSettings();
|
|
10073
10458
|
} catch (e) {
|
|
10074
|
-
|
|
10459
|
+
logger26.error(`Error loading global settings:
|
|
10075
10460
|
` + String(e));
|
|
10076
10461
|
}
|
|
10077
10462
|
}).hook("postAction", async (command2) => {
|
|
10078
10463
|
if (logTracker4.shouldWriteLogsToFile) {
|
|
10079
10464
|
try {
|
|
10080
10465
|
let logFile = await logTracker4.writeToFile(command2.getOptionValue("logfile"));
|
|
10081
|
-
|
|
10466
|
+
logger26.log(`Debug logs are written to: ${logFile}`);
|
|
10082
10467
|
} catch {
|
|
10083
10468
|
}
|
|
10084
|
-
|
|
10469
|
+
logger26.outro(CLI_COLORS5.success("Done!"));
|
|
10085
10470
|
}
|
|
10086
10471
|
});
|
|
10087
10472
|
command("init").description("Initialize Storybook into your project").option("-f --force", "Force add Storybook").option("-s --skip-install", "Skip installing deps").addOption(
|
|
@@ -10098,7 +10483,7 @@ command("add <addon>").description("Add an addon to your Storybook").addOption(
|
|
|
10098
10483
|
)
|
|
10099
10484
|
).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) => {
|
|
10100
10485
|
withTelemetry("add", { cliOptions: options }, async () => {
|
|
10101
|
-
|
|
10486
|
+
logger26.intro(`Setting up your project for ${addonName}`), await add(addonName, options), await telemetry3("add", { addon: addonName, source: "cli" }), logger26.outro("Done!");
|
|
10102
10487
|
}).catch(handleCommandFailure);
|
|
10103
10488
|
});
|
|
10104
10489
|
command("remove <addon>").description("Remove an addon from your Storybook").addOption(
|
|
@@ -10107,7 +10492,7 @@ command("remove <addon>").description("Remove an addon from your Storybook").add
|
|
|
10107
10492
|
)
|
|
10108
10493
|
).option("-c, --config-dir <dir-name>", "Directory where to load Storybook configurations from").option("-s --skip-install", "Skip installing deps").action(
|
|
10109
10494
|
(addonName, options) => withTelemetry("remove", { cliOptions: options }, async () => {
|
|
10110
|
-
|
|
10495
|
+
logger26.intro(`Removing ${addonName} from your Storybook`);
|
|
10111
10496
|
let packageManager = JsPackageManagerFactory3.getPackageManager({
|
|
10112
10497
|
configDir: options.configDir,
|
|
10113
10498
|
force: options.packageManager
|
|
@@ -10116,7 +10501,7 @@ command("remove <addon>").description("Remove an addon from your Storybook").add
|
|
|
10116
10501
|
configDir: options.configDir,
|
|
10117
10502
|
packageManager,
|
|
10118
10503
|
skipInstall: options.skipInstall
|
|
10119
|
-
}), await telemetry3("remove", { addon: addonName, source: "cli" }),
|
|
10504
|
+
}), await telemetry3("remove", { addon: addonName, source: "cli" }), logger26.outro("Done!");
|
|
10120
10505
|
}).catch(handleCommandFailure(options.logfile))
|
|
10121
10506
|
);
|
|
10122
10507
|
command("upgrade").description(`Upgrade your Storybook packages to v${versions5.storybook}`).addOption(
|
|
@@ -10134,12 +10519,12 @@ command("upgrade").description(`Upgrade your Storybook packages to v${versions5.
|
|
|
10134
10519
|
"upgrade",
|
|
10135
10520
|
{ cliOptions: { ...options, configDir: options.configDir?.[0] } },
|
|
10136
10521
|
async () => {
|
|
10137
|
-
|
|
10522
|
+
logger26.intro(`Storybook upgrade - v${versions5.storybook}`), await upgrade(options), logger26.outro("Storybook upgrade completed!");
|
|
10138
10523
|
}
|
|
10139
10524
|
).catch(handleCommandFailure(options.logfile));
|
|
10140
10525
|
});
|
|
10141
10526
|
command("info").description("Prints debugging information about the local environment").action(async () => {
|
|
10142
|
-
|
|
10527
|
+
logger26.log(import_picocolors18.default.bold(`
|
|
10143
10528
|
Storybook Environment Info:`));
|
|
10144
10529
|
let activePackageManager = JsPackageManagerFactory3.getPackageManager().type.replace(/\d/, ""), output = await import_envinfo.default.run({
|
|
10145
10530
|
System: ["OS", "CPU", "Shell"],
|
|
@@ -10148,10 +10533,10 @@ Storybook Environment Info:`));
|
|
|
10148
10533
|
npmPackages: "{@storybook/*,*storybook*,sb,chromatic}",
|
|
10149
10534
|
npmGlobalPackages: "{@storybook/*,*storybook*,sb,chromatic}"
|
|
10150
10535
|
}), activePackageManagerLine = output.match(new RegExp(`${activePackageManager}:.*`, "i"));
|
|
10151
|
-
|
|
10536
|
+
logger26.log(
|
|
10152
10537
|
output.replace(
|
|
10153
10538
|
activePackageManagerLine,
|
|
10154
|
-
|
|
10539
|
+
import_picocolors18.default.bold(`${activePackageManagerLine} <----- active`)
|
|
10155
10540
|
)
|
|
10156
10541
|
);
|
|
10157
10542
|
});
|
|
@@ -10163,12 +10548,12 @@ command("migrate [migration]").description("Run a Storybook codemod migration on
|
|
|
10163
10548
|
'Rename suffix of matching files after codemod has been applied, e.g. ".js:.ts"'
|
|
10164
10549
|
).action((migration, options) => {
|
|
10165
10550
|
withTelemetry("migrate", { cliOptions: options }, async () => {
|
|
10166
|
-
|
|
10551
|
+
logger26.intro(`Running ${migration} migration`), await migrate(migration, options), logger26.outro("Migration completed");
|
|
10167
10552
|
}).catch(handleCommandFailure(options.logfile));
|
|
10168
10553
|
});
|
|
10169
10554
|
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) => {
|
|
10170
|
-
|
|
10171
|
-
|
|
10555
|
+
logger26.intro("Creating a Storybook sandbox..."), sandbox({ filterValue, ...options }).catch(handleCommandFailure).finally(() => {
|
|
10556
|
+
logger26.outro("Done!");
|
|
10172
10557
|
});
|
|
10173
10558
|
});
|
|
10174
10559
|
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(
|
|
@@ -10183,7 +10568,7 @@ command("automigrate [fixId]").description("Check storybook for incompatibilitie
|
|
|
10183
10568
|
"The renderer package for the framework Storybook is using."
|
|
10184
10569
|
).option("--skip-doctor", "Skip doctor check").option("--glob <pattern>", "Glob pattern for story files (for csf-factories codemod)").action(async (fixId, options) => {
|
|
10185
10570
|
withTelemetry("automigrate", { cliOptions: options }, async () => {
|
|
10186
|
-
|
|
10571
|
+
logger26.intro(fixId ? `Running ${fixId} automigration` : "Running automigrations"), await doAutomigrate({ fixId, ...options }), logger26.outro("Done");
|
|
10187
10572
|
}).catch(handleCommandFailure(options.logfile));
|
|
10188
10573
|
});
|
|
10189
10574
|
command("doctor").description("Check Storybook for known problems and provide suggestions or fixes").addOption(
|
|
@@ -10192,7 +10577,7 @@ command("doctor").description("Check Storybook for known problems and provide su
|
|
|
10192
10577
|
)
|
|
10193
10578
|
).option("-c, --config-dir <dir-name>", "Directory of Storybook configuration").action(async (options) => {
|
|
10194
10579
|
withTelemetry("doctor", { cliOptions: options }, async () => {
|
|
10195
|
-
|
|
10580
|
+
logger26.intro("Doctoring Storybook"), await doctor(options), logger26.outro("Done");
|
|
10196
10581
|
}).catch(handleCommandFailure(options.logfile));
|
|
10197
10582
|
});
|
|
10198
10583
|
var aiCommand = command("ai").description("AI agent helpers for Storybook").option(
|
|
@@ -10213,9 +10598,9 @@ aiCommand.action(() => {
|
|
|
10213
10598
|
aiCommand.outputHelp();
|
|
10214
10599
|
});
|
|
10215
10600
|
program.on("command:*", ([invalidCmd]) => {
|
|
10216
|
-
let errorMessage = ` Invalid command: ${
|
|
10601
|
+
let errorMessage = ` Invalid command: ${import_picocolors18.default.bold(invalidCmd)}.
|
|
10217
10602
|
See --help for a list of available commands.`, suggestion = program.commands.map((cmd) => cmd.name()).find((cmd) => leven(cmd, invalidCmd) < 3);
|
|
10218
10603
|
suggestion && (errorMessage += `
|
|
10219
|
-
Did you mean ${
|
|
10604
|
+
Did you mean ${import_picocolors18.default.yellow(suggestion)}?`), logger26.error(errorMessage), process.exit(1);
|
|
10220
10605
|
});
|
|
10221
10606
|
program.usage("<command> [options]").version(String(version)).parse(process.argv);
|