@storybook/cli 10.4.0-alpha.0 → 10.4.0-alpha.10

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.
@@ -1,10 +1,10 @@
1
- import CJS_COMPAT_NODE_URL_454o0s7yfiq from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_454o0s7yfiq from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_454o0s7yfiq from "node:module";
1
+ import CJS_COMPAT_NODE_URL_vl98w42lhjj from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_vl98w42lhjj from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_vl98w42lhjj from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_454o0s7yfiq.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_454o0s7yfiq.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_454o0s7yfiq.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_vl98w42lhjj.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_vl98w42lhjj.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_vl98w42lhjj.createRequire(import.meta.url);
8
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration
@@ -25,18 +25,18 @@ import {
25
25
  shortenPath,
26
26
  updateMainConfig,
27
27
  upgradeStorybookDependencies
28
- } from "./chunk-RSE7Z5BU.js";
28
+ } from "./chunk-KJSPRU43.js";
29
29
  import {
30
30
  slash
31
- } from "./chunk-MJ4QENEU.js";
31
+ } from "./chunk-UU2X4GAG.js";
32
32
  import {
33
33
  require_semver
34
- } from "./chunk-NTQYSBFL.js";
34
+ } from "./chunk-LCTYEE6A.js";
35
35
  import {
36
36
  __commonJS,
37
37
  __require,
38
38
  __toESM
39
- } from "./chunk-6FNCJEJC.js";
39
+ } from "./chunk-T6WBTCLX.js";
40
40
 
41
41
  // ../../../node_modules/envinfo/dist/envinfo.js
42
42
  var require_envinfo = __commonJS({
@@ -4712,7 +4712,7 @@ import { globalSettings } from "storybook/internal/cli";
4712
4712
  import {
4713
4713
  HandledError as HandledError2,
4714
4714
  JsPackageManagerFactory as JsPackageManagerFactory3,
4715
- PackageManagerName as PackageManagerName2,
4715
+ PackageManagerName as PackageManagerName3,
4716
4716
  isCI as isCI2,
4717
4717
  optionalEnvToBoolean as optionalEnvToBoolean3,
4718
4718
  removeAddon as remove,
@@ -4758,10 +4758,10 @@ function leven(first, second, options) {
4758
4758
  }
4759
4759
 
4760
4760
  // src/bin/run.ts
4761
- var import_picocolors16 = __toESM(require_picocolors(), 1);
4761
+ var import_picocolors17 = __toESM(require_picocolors(), 1);
4762
4762
 
4763
4763
  // package.json
4764
- var version = "10.4.0-alpha.0";
4764
+ var version = "10.4.0-alpha.10";
4765
4765
 
4766
4766
  // src/add.ts
4767
4767
  var import_semver = __toESM(require_semver(), 1);
@@ -5078,7 +5078,7 @@ function isValidVersion(version2) {
5078
5078
  }
5079
5079
 
5080
5080
  // src/automigrate/index.ts
5081
- var import_picocolors13 = __toESM(require_picocolors(), 1);
5081
+ var import_picocolors14 = __toESM(require_picocolors(), 1);
5082
5082
  import { versions as versions3 } from "storybook/internal/common";
5083
5083
  import { logTracker as logTracker2, logger as logger16, prompt as prompt3 } from "storybook/internal/node-logger";
5084
5084
  import { AutomigrateError } from "storybook/internal/server-errors";
@@ -5095,7 +5095,7 @@ function invariant(condition, message) {
5095
5095
  }
5096
5096
 
5097
5097
  // src/automigrate/index.ts
5098
- import { dedent as dedent13 } from "ts-dedent";
5098
+ import { dedent as dedent14 } from "ts-dedent";
5099
5099
 
5100
5100
  // src/doctor/index.ts
5101
5101
  var import_picocolors4 = __toESM(require_picocolors(), 1);
@@ -5625,7 +5625,7 @@ import { logger as logger3 } from "storybook/internal/node-logger";
5625
5625
  import { promises as fs } from "fs";
5626
5626
  var maxConcurrentTasks = Math.max(1, os.cpus().length - 1);
5627
5627
  async function runCodemod(globPattern = "**/*.{stories,story}.{js,jsx,ts,tsx,mjs,mjsx,mts,mtsx}", transform, { dryRun = !1, skipFormatting = !1 } = {}) {
5628
- let modifiedCount = 0, unmodifiedCount = 0, errorCount = 0, { globby } = await import("./globby-AEQ5KH3V.js"), files = await globby(slash(globPattern), {
5628
+ let modifiedCount = 0, unmodifiedCount = 0, errorCount = 0, { globby } = await import("./globby-DPMWXMIG.js"), files = await globby(slash(globPattern), {
5629
5629
  followSymbolicLinks: !0,
5630
5630
  ignore: ["**/node_modules/**", "**/dist/**", "**/storybook-static/**", "**/build/**"]
5631
5631
  });
@@ -5636,7 +5636,7 @@ Please try a different pattern.
5636
5636
  `
5637
5637
  ), new Error("No files matched");
5638
5638
  try {
5639
- let pLimit = (await import("./p-limit-UKL2YCV7.js")).default, limit = pLimit(maxConcurrentTasks);
5639
+ let pLimit = (await import("./p-limit-S7WF4364.js")).default, limit = pLimit(maxConcurrentTasks);
5640
5640
  await Promise.all(
5641
5641
  files.map(
5642
5642
  (file) => limit(async () => {
@@ -5766,7 +5766,17 @@ async function configToCsfFactory(info, { configType, frameworkPackage }, { dryR
5766
5766
  return logger4.log(`Error when parsing ${info.path}, skipping:
5767
5767
  ${err}`), info.source;
5768
5768
  }
5769
- let methodName = configType === "main" ? "defineMain" : "definePreview", programNode = config._ast.program, exportDecls = config._exportDecls, defineConfigProps = getConfigProperties(exportDecls, { configType }), hasNamedExports = defineConfigProps.length > 0;
5769
+ let methodName = configType === "main" ? "defineMain" : "definePreview", programNode = config._ast.program, exportDecls = config._exportDecls, defineConfigProps = getConfigProperties(exportDecls, { configType }), hasNamedExports = defineConfigProps.length > 0, isAlreadyTransformed = programNode.body.some((node) => {
5770
+ if (!t2.isExportDefaultDeclaration(node)) return !1;
5771
+ let declaration = typeof config._unwrap == "function" ? config._unwrap(node.declaration) : node.declaration;
5772
+ return t2.isCallExpression(declaration) && t2.isIdentifier(declaration.callee) && declaration.callee.name === methodName;
5773
+ }), expectedImportSource = frameworkPackage + (configType === "main" ? "/node" : ""), hasCorrectImport = programNode.body.some(
5774
+ (node) => t2.isImportDeclaration(node) && node.importKind !== "type" && node.source.value === expectedImportSource && node.specifiers.some(
5775
+ (spec) => t2.isImportSpecifier(spec) && t2.isIdentifier(spec.imported) && spec.imported.name === methodName
5776
+ )
5777
+ ), shouldSkipTransform = configType === "main" ? isAlreadyTransformed : isAlreadyTransformed && !hasNamedExports;
5778
+ if (shouldSkipTransform && hasCorrectImport)
5779
+ return info.source;
5770
5780
  function findDeclarationNodeIndex(declarationName) {
5771
5781
  return programNode.body.findIndex(
5772
5782
  (n) => t2.isVariableDeclaration(n) && n.declarations.some((d) => {
@@ -5775,46 +5785,48 @@ ${err}`), info.source;
5775
5785
  })
5776
5786
  );
5777
5787
  }
5778
- if (config._exportsObject && hasNamedExports) {
5779
- config._exportsObject.properties = [...defineConfigProps, ...config._exportsObject.properties], programNode.body = removeExportDeclarations(programNode, exportDecls);
5780
- let defineConfigCall = t2.callExpression(t2.identifier(methodName), [config._exportsObject]), exportDefaultNode = null, declarationNodeIndex = -1;
5781
- programNode.body.forEach((node) => {
5782
- if (t2.isExportDefaultDeclaration(node) && t2.isIdentifier(node.declaration)) {
5783
- let declarationName = node.declaration.name;
5784
- if (declarationNodeIndex = findDeclarationNodeIndex(declarationName), declarationNodeIndex !== -1) {
5785
- exportDefaultNode = node;
5786
- let declarationNode = programNode.body[declarationNodeIndex];
5787
- if (t2.isVariableDeclaration(declarationNode)) {
5788
- let id = declarationNode.declarations[0].id;
5789
- t2.isIdentifier(id) && id.name && programNode.body.splice(declarationNodeIndex, 1);
5790
- }
5791
- }
5792
- } else t2.isExportDefaultDeclaration(node) && t2.isObjectExpression(node.declaration) && (exportDefaultNode = node);
5793
- }), exportDefaultNode !== null && (exportDefaultNode.declaration = defineConfigCall);
5794
- } else if (config._exportsObject) {
5795
- let defineConfigCall = t2.callExpression(t2.identifier(methodName), [config._exportsObject]), exportDefaultNode = null, declarationNodeIndex = -1;
5796
- programNode.body.forEach((node) => {
5797
- let declaration = t2.isExportDefaultDeclaration(node) && config._unwrap(node.declaration);
5798
- if (t2.isExportDefaultDeclaration(node) && t2.isIdentifier(declaration)) {
5799
- let declarationName = declaration.name;
5800
- if (declarationNodeIndex = findDeclarationNodeIndex(declarationName), declarationNodeIndex !== -1) {
5801
- exportDefaultNode = node;
5802
- let declarationNode = programNode.body[declarationNodeIndex];
5803
- if (t2.isVariableDeclaration(declarationNode)) {
5804
- let id = declarationNode.declarations[0].id;
5805
- t2.isIdentifier(id) && id.name && programNode.body.splice(declarationNodeIndex, 1);
5806
- }
5807
- }
5808
- } else t2.isExportDefaultDeclaration(node) && t2.isObjectExpression(node.declaration) && (exportDefaultNode = node);
5809
- }), exportDefaultNode !== null && (exportDefaultNode.declaration = defineConfigCall);
5810
- } else if (hasNamedExports) {
5811
- let defineConfigCall = t2.callExpression(t2.identifier(methodName), [
5812
- t2.objectExpression(defineConfigProps)
5813
- ]);
5814
- programNode.body = removeExportDeclarations(programNode, exportDecls), programNode.body.push(t2.exportDefaultDeclaration(defineConfigCall));
5815
- } else if (configType === "preview") {
5816
- let defineConfigCall = t2.callExpression(t2.identifier(methodName), [t2.objectExpression([])]);
5817
- programNode.body.push(t2.exportDefaultDeclaration(defineConfigCall));
5788
+ if (!shouldSkipTransform) {
5789
+ if (config._exportsObject && hasNamedExports) {
5790
+ config._exportsObject.properties = [...defineConfigProps, ...config._exportsObject.properties], programNode.body = removeExportDeclarations(programNode, exportDecls);
5791
+ let defineConfigCall = t2.callExpression(t2.identifier(methodName), [config._exportsObject]), exportDefaultNode = null, declarationNodeIndex = -1;
5792
+ programNode.body.forEach((node) => {
5793
+ if (t2.isExportDefaultDeclaration(node) && t2.isIdentifier(node.declaration)) {
5794
+ let declarationName = node.declaration.name;
5795
+ if (declarationNodeIndex = findDeclarationNodeIndex(declarationName), declarationNodeIndex !== -1) {
5796
+ exportDefaultNode = node;
5797
+ let declarationNode = programNode.body[declarationNodeIndex];
5798
+ if (t2.isVariableDeclaration(declarationNode)) {
5799
+ let id = declarationNode.declarations[0].id;
5800
+ t2.isIdentifier(id) && id.name && programNode.body.splice(declarationNodeIndex, 1);
5801
+ }
5802
+ }
5803
+ } else t2.isExportDefaultDeclaration(node) && t2.isObjectExpression(node.declaration) && (exportDefaultNode = node);
5804
+ }), exportDefaultNode !== null && (exportDefaultNode.declaration = defineConfigCall);
5805
+ } else if (config._exportsObject) {
5806
+ let defineConfigCall = t2.callExpression(t2.identifier(methodName), [config._exportsObject]), exportDefaultNode = null, declarationNodeIndex = -1;
5807
+ programNode.body.forEach((node) => {
5808
+ let declaration = t2.isExportDefaultDeclaration(node) && config._unwrap(node.declaration);
5809
+ if (t2.isExportDefaultDeclaration(node) && t2.isIdentifier(declaration)) {
5810
+ let declarationName = declaration.name;
5811
+ if (declarationNodeIndex = findDeclarationNodeIndex(declarationName), declarationNodeIndex !== -1) {
5812
+ exportDefaultNode = node;
5813
+ let declarationNode = programNode.body[declarationNodeIndex];
5814
+ if (t2.isVariableDeclaration(declarationNode)) {
5815
+ let id = declarationNode.declarations[0].id;
5816
+ t2.isIdentifier(id) && id.name && programNode.body.splice(declarationNodeIndex, 1);
5817
+ }
5818
+ }
5819
+ } else t2.isExportDefaultDeclaration(node) && t2.isObjectExpression(node.declaration) && (exportDefaultNode = node);
5820
+ }), exportDefaultNode !== null && (exportDefaultNode.declaration = defineConfigCall);
5821
+ } else if (hasNamedExports) {
5822
+ let defineConfigCall = t2.callExpression(t2.identifier(methodName), [
5823
+ t2.objectExpression(defineConfigProps)
5824
+ ]);
5825
+ programNode.body = removeExportDeclarations(programNode, exportDecls), programNode.body.push(t2.exportDefaultDeclaration(defineConfigCall));
5826
+ } else if (configType === "preview") {
5827
+ let defineConfigCall = t2.callExpression(t2.identifier(methodName), [t2.objectExpression([])]);
5828
+ programNode.body.push(t2.exportDefaultDeclaration(defineConfigCall));
5829
+ }
5818
5830
  }
5819
5831
  let configImport = t2.importDeclaration(
5820
5832
  [t2.importSpecifier(t2.identifier(methodName), t2.identifier(methodName))],
@@ -6467,7 +6479,7 @@ var addonA11yParameters = {
6467
6479
  errors.push({ file: previewFileToUpdate, error });
6468
6480
  }
6469
6481
  }
6470
- let { default: pLimit } = await import("./p-limit-UKL2YCV7.js"), limit = pLimit(10);
6482
+ let { default: pLimit } = await import("./p-limit-S7WF4364.js"), limit = pLimit(10);
6471
6483
  if (await Promise.all(
6472
6484
  storyFilesToUpdate.map(
6473
6485
  (file) => limit(async () => {
@@ -6621,7 +6633,7 @@ var addonGlobalsApi = {
6621
6633
  }
6622
6634
  };
6623
6635
  async function transformStoryFiles(files, options, dryRun) {
6624
- let errors = [], { default: pLimit } = await import("./p-limit-UKL2YCV7.js"), limit = pLimit(10);
6636
+ let errors = [], { default: pLimit } = await import("./p-limit-S7WF4364.js"), limit = pLimit(10);
6625
6637
  return await Promise.all(
6626
6638
  files.map(
6627
6639
  (file) => limit(async () => {
@@ -6813,7 +6825,7 @@ function transformPackageJson(content) {
6813
6825
  return hasChanges ? JSON.stringify(packageJson, null, 2) : null;
6814
6826
  }
6815
6827
  var transformPackageJsonFiles = async (files, dryRun) => {
6816
- let errors = [], { default: pLimit } = await import("./p-limit-UKL2YCV7.js"), limit = pLimit(10);
6828
+ let errors = [], { default: pLimit } = await import("./p-limit-S7WF4364.js"), limit = pLimit(10);
6817
6829
  return await Promise.all(
6818
6830
  files.map(
6819
6831
  (file) => limit(async () => {
@@ -6852,7 +6864,7 @@ var transformPackageJsonFiles = async (files, dryRun) => {
6852
6864
  dryRun
6853
6865
  );
6854
6866
  errors.push(...packageJsonErrors);
6855
- let { globby } = await import("./globby-AEQ5KH3V.js"), configFiles = await globby([`${configDir}/**/*`]), importErrors = await transformImportFiles(
6867
+ let { globby } = await import("./globby-DPMWXMIG.js"), configFiles = await globby([`${configDir}/**/*`]), importErrors = await transformImportFiles(
6856
6868
  [...storiesPaths, ...configFiles].filter(Boolean),
6857
6869
  {
6858
6870
  ...consolidatedPackages,
@@ -7151,7 +7163,10 @@ var VITE_DEFAULT_VERSION = "^7.0.0", transformMainConfig = async (mainConfigPath
7151
7163
  let content = await readFile6(mainConfigPath, "utf-8");
7152
7164
  if (!content.includes("@storybook/nextjs"))
7153
7165
  return !1;
7154
- let transformedContent = content.replace(/@storybook\/nextjs/g, "@storybook/nextjs-vite");
7166
+ let transformedContent = content.replace(
7167
+ /@storybook\/nextjs(?!-vite)/g,
7168
+ "@storybook/nextjs-vite"
7169
+ );
7155
7170
  return transformedContent !== content && !dryRun && await writeFile5(mainConfigPath, transformedContent), transformedContent !== content;
7156
7171
  } catch (error) {
7157
7172
  return logger11.error(`Failed to update main config at ${mainConfigPath}: ${error}`), !1;
@@ -7205,7 +7220,7 @@ var VITE_DEFAULT_VERSION = "^7.0.0", transformMainConfig = async (mainConfigPath
7205
7220
  ]);
7206
7221
  }
7207
7222
  mainConfigPath && (logger11.debug("Updating main config file..."), await transformMainConfig(mainConfigPath, dryRun)), logger11.debug("Scanning and updating import statements...");
7208
- let { globby } = await import("./globby-AEQ5KH3V.js"), configFiles = await globby([`${configDir}/**/*`]), allFiles = [...storiesPaths, ...configFiles].filter(Boolean), transformErrors = await transformImportFiles2(
7223
+ let { globby } = await import("./globby-DPMWXMIG.js"), configFiles = await globby([`${configDir}/**/*`]), allFiles = [...storiesPaths, ...configFiles].filter(Boolean), transformErrors = await transformImportFiles2(
7209
7224
  allFiles,
7210
7225
  {
7211
7226
  "@storybook/nextjs": "@storybook/nextjs-vite"
@@ -7415,7 +7430,7 @@ var getAllDependencies = (packageJson) => Object.keys({
7415
7430
  let regex = new RegExp(`(['"])${renderer}(['"])`, "g");
7416
7431
  return regex.test(source) ? source.replace(regex, `$1${framework}$2`) : null;
7417
7432
  }, transformSourceFiles = async (files, renderer, framework, dryRun) => {
7418
- let errors = [], { default: pLimit } = await import("./p-limit-UKL2YCV7.js"), limit = pLimit(10);
7433
+ let errors = [], { default: pLimit } = await import("./p-limit-S7WF4364.js"), limit = pLimit(10);
7419
7434
  return await Promise.all(
7420
7435
  files.map(
7421
7436
  (file) => limit(async () => {
@@ -7482,7 +7497,7 @@ var getAllDependencies = (packageJson) => Object.keys({
7482
7497
  continue;
7483
7498
  logger13.debug(`
7484
7499
  Migrating ${rendererPackage} to ${selectedFramework}`);
7485
- let { globby } = await import("./globby-AEQ5KH3V.js"), configFiles = await globby([`${configDir}/**/*`]);
7500
+ let { globby } = await import("./globby-DPMWXMIG.js"), configFiles = await globby([`${configDir}/**/*`]);
7486
7501
  await transformSourceFiles(
7487
7502
  [...storiesPaths, ...configFiles].filter(Boolean),
7488
7503
  rendererPackage,
@@ -7512,7 +7527,7 @@ async function renameInFile(filePath, oldText, newText) {
7512
7527
  }
7513
7528
  var getDotStorybookReferences = async (searchDir) => {
7514
7529
  try {
7515
- let { globby } = await import("./globby-AEQ5KH3V.js"), { readFile: readFile10 } = await import("node:fs/promises"), files = await globby(`${searchDir}/**/*`, {
7530
+ let { globby } = await import("./globby-DPMWXMIG.js"), { readFile: readFile10 } = await import("node:fs/promises"), files = await globby(`${searchDir}/**/*`, {
7516
7531
  onlyFiles: !0,
7517
7532
  gitignore: !0
7518
7533
  }), referencedFiles = [];
@@ -7533,7 +7548,7 @@ var getDotStorybookReferences = async (searchDir) => {
7533
7548
  async check({ packageManager, mainConfigPath }) {
7534
7549
  if (!packageManager.getAllDependencies()["@storybook/react-native"])
7535
7550
  return null;
7536
- let projectDir = mainConfigPath ? join2(mainConfigPath, "..", "..") : process.cwd(), storybookDir = join2(projectDir, ".storybook"), rnStorybookDir = join2(projectDir, ".rnstorybook"), { globby } = await import("./globby-AEQ5KH3V.js"), requiresFiles = await globby(join2(storybookDir, "storybook.requires.*"));
7551
+ let projectDir = mainConfigPath ? join2(mainConfigPath, "..", "..") : process.cwd(), storybookDir = join2(projectDir, ".storybook"), rnStorybookDir = join2(projectDir, ".rnstorybook"), { globby } = await import("./globby-DPMWXMIG.js"), requiresFiles = await globby(join2(storybookDir, "storybook.requires.*"));
7537
7552
  return existsSync2(storybookDir) && requiresFiles.length > 0 && !existsSync2(rnStorybookDir) ? { storybookDir, rnStorybookDir } : null;
7538
7553
  },
7539
7554
  prompt() {
@@ -7549,13 +7564,38 @@ var getDotStorybookReferences = async (searchDir) => {
7549
7564
  }
7550
7565
  };
7551
7566
 
7567
+ // src/automigrate/fixes/storybook-package-name-conflict.ts
7568
+ var import_picocolors12 = __toESM(require_picocolors(), 1);
7569
+ import { dedent as dedent10 } from "ts-dedent";
7570
+ var storybookPackageNameConflict = {
7571
+ id: "storybookPackageNameConflict",
7572
+ promptType: "notification",
7573
+ link: "https://github.com/storybookjs/storybook/issues/28725",
7574
+ async check({ packageManager }) {
7575
+ let packageName = packageManager.primaryPackageJson.packageJson.name;
7576
+ return packageName === "storybook" ? { packageName } : null;
7577
+ },
7578
+ prompt() {
7579
+ return dedent10`
7580
+ Your package.json ${import_picocolors12.default.cyan('"name"')} field is set to ${import_picocolors12.default.cyan('"storybook"')}.
7581
+
7582
+ In npm, pnpm, or yarn workspaces this creates a symlink at
7583
+ ${import_picocolors12.default.yellow("node_modules/storybook")} that shadows the real Storybook
7584
+ package, causing ${import_picocolors12.default.red('"Cannot find module storybook/internal/..."')} errors.
7585
+
7586
+ To fix this, rename the ${import_picocolors12.default.cyan('"name"')} field in your package.json
7587
+ to something other than ${import_picocolors12.default.cyan('"storybook"')} (e.g. "my-storybook", "docs", "@myorg/storybook").
7588
+ `;
7589
+ }
7590
+ };
7591
+
7552
7592
  // src/automigrate/fixes/upgrade-storybook-related-dependencies.ts
7553
7593
  var import_semver5 = __toESM(require_semver(), 1);
7554
7594
  import { readFileSync as readFileSync4 } from "node:fs";
7555
7595
  import { dirname as dirname2 } from "node:path";
7556
7596
  import { isCorePackage, isSatelliteAddon } from "storybook/internal/common";
7557
7597
  import { logger as logger14 } from "storybook/internal/node-logger";
7558
- import { dedent as dedent10 } from "ts-dedent";
7598
+ import { dedent as dedent11 } from "ts-dedent";
7559
7599
  async function getLatestVersions(packageManager, packages) {
7560
7600
  return Promise.all(
7561
7601
  packages.map(async ([packageName]) => ({
@@ -7594,7 +7634,7 @@ var upgradeStorybookRelatedDependencies = {
7594
7634
  },
7595
7635
  async run({ result: { upgradable }, packageManager, dryRun }) {
7596
7636
  if (dryRun) {
7597
- logger14.log(dedent10`
7637
+ logger14.log(dedent11`
7598
7638
  The following would have been upgraded:
7599
7639
  ${upgradable.map(
7600
7640
  ({ packageName, afterVersion, beforeVersion }) => `${packageName}: ${beforeVersion} => ${afterVersion}`
@@ -7626,7 +7666,7 @@ import {
7626
7666
  } from "storybook/internal/common";
7627
7667
  import { readConfig as readConfig3 } from "storybook/internal/csf-tools";
7628
7668
  import { CommonJsConfigNotSupportedError } from "storybook/internal/server-errors";
7629
- import { dedent as dedent11 } from "ts-dedent";
7669
+ import { dedent as dedent12 } from "ts-dedent";
7630
7670
  var wrapGetAbsolutePath = {
7631
7671
  id: "wrap-getAbsolutePath",
7632
7672
  link: "https://storybook.js.org/docs/faq#how-do-i-fix-module-resolution-in-special-environments",
@@ -7643,7 +7683,7 @@ var wrapGetAbsolutePath = {
7643
7683
  return { storybookVersion, isStorybookInMonorepo, isPnp, isConfigTypescript };
7644
7684
  },
7645
7685
  prompt() {
7646
- return dedent11`We have detected that you're using Storybook in a monorepo or PnP project. Some fields in your main config must be updated.`;
7686
+ return dedent12`We have detected that you're using Storybook in a monorepo or PnP project. Some fields in your main config must be updated.`;
7647
7687
  },
7648
7688
  async run({ dryRun, mainConfigPath, result }) {
7649
7689
  await updateMainConfig({ dryRun: !!dryRun, mainConfigPath }, (mainConfig) => {
@@ -7680,14 +7720,15 @@ var allFixes = [
7680
7720
  addonA11yParameters,
7681
7721
  removeDocsAutodocs,
7682
7722
  wrapGetAbsolutePath,
7683
- fixFauxEsmRequire
7723
+ fixFauxEsmRequire,
7724
+ storybookPackageNameConflict
7684
7725
  ];
7685
7726
  var commandFixes = [csfFactories];
7686
7727
 
7687
7728
  // src/automigrate/helpers/logMigrationSummary.ts
7688
- var import_picocolors12 = __toESM(require_picocolors(), 1);
7729
+ var import_picocolors13 = __toESM(require_picocolors(), 1);
7689
7730
  import { CLI_COLORS as CLI_COLORS2, logger as logger15 } from "storybook/internal/node-logger";
7690
- import { dedent as dedent12 } from "ts-dedent";
7731
+ import { dedent as dedent13 } from "ts-dedent";
7691
7732
  var messageDivider2 = `
7692
7733
 
7693
7734
  `, segmentDivider = `
@@ -7697,23 +7738,23 @@ var messageDivider2 = `
7697
7738
  `;
7698
7739
  function getGlossaryMessages(fixSummary, fixResults) {
7699
7740
  let messages2 = [];
7700
- return fixSummary.succeeded.length > 0 && (messages2.push(import_picocolors12.default.bold("Successful migrations:")), messages2.push(fixSummary.succeeded.map((m) => import_picocolors12.default.green(m)).join(", "))), Object.keys(fixSummary.failed).length > 0 && (messages2.push(import_picocolors12.default.bold("Failed migrations:")), messages2.push(
7701
- Object.entries(fixSummary.failed).map(([id, error]) => `${import_picocolors12.default.bold(import_picocolors12.default.red(id))}:
7741
+ return fixSummary.succeeded.length > 0 && (messages2.push(import_picocolors13.default.bold("Successful migrations:")), messages2.push(fixSummary.succeeded.map((m) => import_picocolors13.default.green(m)).join(", "))), Object.keys(fixSummary.failed).length > 0 && (messages2.push(import_picocolors13.default.bold("Failed migrations:")), messages2.push(
7742
+ Object.entries(fixSummary.failed).map(([id, error]) => `${import_picocolors13.default.bold(import_picocolors13.default.red(id))}:
7702
7743
  ${error}`).join(`
7703
7744
  `)
7704
- )), fixSummary.manual.length > 0 && (messages2.push(import_picocolors12.default.bold("Manual migrations:")), messages2.push(
7745
+ )), fixSummary.manual.length > 0 && (messages2.push(import_picocolors13.default.bold("Manual migrations:")), messages2.push(
7705
7746
  fixSummary.manual.map(
7706
- (m) => fixResults[m] === "manual_succeeded" /* MANUAL_SUCCEEDED */ ? import_picocolors12.default.green(m) : import_picocolors12.default.blue(m)
7747
+ (m) => fixResults[m] === "manual_succeeded" /* MANUAL_SUCCEEDED */ ? import_picocolors13.default.green(m) : import_picocolors13.default.blue(m)
7707
7748
  ).join(", ")
7708
- )), fixSummary.skipped.length > 0 && (messages2.push(import_picocolors12.default.bold("Skipped migrations:")), messages2.push(fixSummary.skipped.map((m) => import_picocolors12.default.cyan(m)).join(", "))), messages2;
7749
+ )), fixSummary.skipped.length > 0 && (messages2.push(import_picocolors13.default.bold("Skipped migrations:")), messages2.push(fixSummary.skipped.map((m) => import_picocolors13.default.cyan(m)).join(", "))), messages2;
7709
7750
  }
7710
7751
  function logMigrationSummary({
7711
7752
  fixResults,
7712
7753
  fixSummary
7713
7754
  }) {
7714
7755
  let messages2 = [];
7715
- messages2.push(getGlossaryMessages(fixSummary, fixResults).join(messageDivider2)), messages2.push(dedent12`If you'd like to run the migrations again, you can do so by running
7716
- ${import_picocolors12.default.cyan("npx storybook automigrate")}
7756
+ messages2.push(getGlossaryMessages(fixSummary, fixResults).join(messageDivider2)), messages2.push(dedent13`If you'd like to run the migrations again, you can do so by running
7757
+ ${import_picocolors13.default.cyan("npx storybook automigrate")}
7717
7758
 
7718
7759
  The automigrations try to migrate common patterns in your project, but might not contain everything needed to migrate to the latest version of Storybook.
7719
7760
 
@@ -7729,9 +7770,9 @@ function logMigrationSummary({
7729
7770
 
7730
7771
  // src/automigrate/index.ts
7731
7772
  var logAvailableMigrations = () => {
7732
- let availableFixes = [...allFixes, ...commandFixes].map((f) => import_picocolors13.default.yellow(f.id)).map((x) => `- ${x}`).join(`
7773
+ let availableFixes = [...allFixes, ...commandFixes].map((f) => import_picocolors14.default.yellow(f.id)).map((x) => `- ${x}`).join(`
7733
7774
  `);
7734
- logger16.log(dedent13`
7775
+ logger16.log(dedent14`
7735
7776
  The following migrations are available:
7736
7777
  ${availableFixes}
7737
7778
  `);
@@ -7772,7 +7813,7 @@ var logAvailableMigrations = () => {
7772
7813
  ) && !options.skipInstall && await packageManager.installDependencies(), outcome && !options.skipDoctor && await doctor({ configDir, packageManager: options.packageManager }), hasFailures(outcome?.fixResults)) {
7773
7814
  let failedMigrations = Object.entries(outcome?.fixResults ?? {}).filter(([, status]) => status === "failed" /* FAILED */ || status === "check_failed" /* CHECK_FAILED */).map(([id, status]) => {
7774
7815
  let statusLabel = status === "check_failed" /* CHECK_FAILED */ ? "check failed" : "failed";
7775
- return `${import_picocolors13.default.cyan(id)} (${statusLabel})`;
7816
+ return `${import_picocolors14.default.cyan(id)} (${statusLabel})`;
7776
7817
  });
7777
7818
  throw new AutomigrateError({ errors: failedMigrations });
7778
7819
  }
@@ -7801,7 +7842,7 @@ var logAvailableMigrations = () => {
7801
7842
  return logAvailableMigrations(), null;
7802
7843
  let commandFix = commandFixes.find((f) => f.id === fixId);
7803
7844
  if (commandFix)
7804
- return logger16.step(`Running migration ${import_picocolors13.default.magenta(fixId)}..`), await commandFix.run({
7845
+ return logger16.step(`Running migration ${import_picocolors14.default.magenta(fixId)}..`), await commandFix.run({
7805
7846
  mainConfigPath,
7806
7847
  previewConfigPath,
7807
7848
  packageManager,
@@ -7816,7 +7857,7 @@ var logAvailableMigrations = () => {
7816
7857
  }), null;
7817
7858
  let selectedFixes = inputFixes || allFixes.filter((fix) => !(fix.id === upgradeStorybookRelatedDependencies.id && isLatest === !1 && fixId !== upgradeStorybookRelatedDependencies.id)), fixes = fixId ? selectedFixes.filter((f) => f.id === fixId) : selectedFixes;
7818
7859
  if (fixId && fixes.length === 0)
7819
- return logger16.log(`\u{1F4ED} No migrations found for ${import_picocolors13.default.magenta(fixId)}.`), logAvailableMigrations(), null;
7860
+ return logger16.log(`\u{1F4ED} No migrations found for ${import_picocolors14.default.magenta(fixId)}.`), logAvailableMigrations(), null;
7820
7861
  logger16.step("Checking possible migrations..");
7821
7862
  let { fixResults, fixSummary, preCheckFailure } = await runFixes({
7822
7863
  fixes,
@@ -7858,7 +7899,7 @@ async function runFixes({
7858
7899
  for (let i = 0; i < fixes.length; i += 1) {
7859
7900
  let f = fixes[i], result;
7860
7901
  try {
7861
- logger16.debug(`Running ${import_picocolors13.default.cyan(f.id)} migration checks`), result = await f.check({
7902
+ logger16.debug(`Running ${import_picocolors14.default.cyan(f.id)} migration checks`), result = await f.check({
7862
7903
  packageManager,
7863
7904
  configDir,
7864
7905
  rendererPackage,
@@ -7868,14 +7909,14 @@ async function runFixes({
7868
7909
  mainConfigPath,
7869
7910
  storiesPaths,
7870
7911
  hasCsfFactoryPreview
7871
- }), logger16.debug(`End of ${import_picocolors13.default.cyan(f.id)} migration checks`);
7912
+ }), logger16.debug(`End of ${import_picocolors14.default.cyan(f.id)} migration checks`);
7872
7913
  } catch (error) {
7873
- logger16.warn(`\u26A0\uFE0F failed to check fix ${import_picocolors13.default.bold(f.id)}`), error instanceof Error && (logger16.error(`
7914
+ logger16.warn(`\u26A0\uFE0F failed to check fix ${import_picocolors14.default.bold(f.id)}`), error instanceof Error && (logger16.error(`
7874
7915
  ${error.stack}`), fixSummary.failed[f.id] = error.message), fixResults[f.id] = "check_failed" /* CHECK_FAILED */;
7875
7916
  }
7876
7917
  if (result) {
7877
7918
  let promptType = typeof f.promptType == "function" ? await f.promptType(result) : f.promptType ?? "auto";
7878
- logger16.log(`\u{1F50E} found a '${import_picocolors13.default.cyan(f.id)}' migration:`);
7919
+ logger16.log(`\u{1F50E} found a '${import_picocolors14.default.cyan(f.id)}' migration:`);
7879
7920
  let getTitle = () => {
7880
7921
  switch (promptType) {
7881
7922
  case "auto":
@@ -7887,7 +7928,7 @@ ${error.stack}`), fixSummary.failed[f.id] = error.message), fixResults[f.id] = "
7887
7928
  }
7888
7929
  }, currentTaskLogger = prompt3.taskLog({
7889
7930
  id: `automigrate-task-${f.id}`,
7890
- title: `${getTitle()}: ${import_picocolors13.default.cyan(f.id)}`
7931
+ title: `${getTitle()}: ${import_picocolors14.default.cyan(f.id)}`
7891
7932
  });
7892
7933
  logger16.logBox(f.prompt());
7893
7934
  let runAnswer;
@@ -7915,7 +7956,7 @@ ${error.stack}`), fixSummary.failed[f.id] = error.message), fixResults[f.id] = "
7915
7956
  }
7916
7957
  } else promptType === "auto" ? runAnswer = { fix: yes ? !0 : await prompt3.confirm(
7917
7958
  {
7918
- message: `Do you want to run the '${import_picocolors13.default.cyan(f.id)}' migration on your project?`,
7959
+ message: `Do you want to run the '${import_picocolors14.default.cyan(f.id)}' migration on your project?`,
7919
7960
  initialValue: f.defaultSelected ?? !0
7920
7961
  },
7921
7962
  {
@@ -7951,14 +7992,14 @@ ${error.stack}`), fixSummary.failed[f.id] = error.message), fixResults[f.id] = "
7951
7992
  storybookVersion,
7952
7993
  storiesPaths,
7953
7994
  yes
7954
- }), logger16.log(`\u2705 ran ${import_picocolors13.default.cyan(f.id)} migration`), fixResults[f.id] = "succeeded" /* SUCCEEDED */, fixSummary.succeeded.push(f.id), currentTaskLogger.success(`Ran ${import_picocolors13.default.cyan(f.id)} migration`);
7995
+ }), logger16.log(`\u2705 ran ${import_picocolors14.default.cyan(f.id)} migration`), fixResults[f.id] = "succeeded" /* SUCCEEDED */, fixSummary.succeeded.push(f.id), currentTaskLogger.success(`Ran ${import_picocolors14.default.cyan(f.id)} migration`);
7955
7996
  } catch (error) {
7956
7997
  fixResults[f.id] = "failed" /* FAILED */;
7957
7998
  let errorMessage = error instanceof Error ? error.message : "Failed to run migration";
7958
- fixSummary.failed[f.id] = errorMessage, currentTaskLogger.error(`Error when running ${import_picocolors13.default.cyan(f.id)} migration`);
7999
+ fixSummary.failed[f.id] = errorMessage, currentTaskLogger.error(`Error when running ${import_picocolors14.default.cyan(f.id)} migration`);
7959
8000
  }
7960
8001
  else
7961
- fixResults[f.id] = "skipped" /* SKIPPED */, fixSummary.skipped.push(f.id), currentTaskLogger.success(`Skipped ${import_picocolors13.default.cyan(f.id)} migration`);
8002
+ fixResults[f.id] = "skipped" /* SKIPPED */, fixSummary.skipped.push(f.id), currentTaskLogger.success(`Skipped ${import_picocolors14.default.cyan(f.id)} migration`);
7962
8003
  } else
7963
8004
  fixResults[f.id] = fixResults[f.id] || "unnecessary" /* UNNECESSARY */;
7964
8005
  }
@@ -8039,6 +8080,7 @@ var import_cross_spawn2 = __toESM(require_cross_spawn(), 1);
8039
8080
  import { existsSync as existsSync3 } from "node:fs";
8040
8081
  import { mkdir as mkdir2, readdir, rm } from "node:fs/promises";
8041
8082
  import { isAbsolute as isAbsolute2 } from "node:path";
8083
+ import { PackageManagerName } from "storybook/internal/common";
8042
8084
  import {
8043
8085
  JsPackageManagerFactory,
8044
8086
  isCI,
@@ -8046,8 +8088,8 @@ import {
8046
8088
  versions as versions4
8047
8089
  } from "storybook/internal/common";
8048
8090
  import { logger as logger19, prompt as prompt4 } from "storybook/internal/node-logger";
8049
- var import_picocolors14 = __toESM(require_picocolors(), 1), import_semver6 = __toESM(require_semver(), 1);
8050
- import { dedent as dedent14 } from "ts-dedent";
8091
+ var import_picocolors15 = __toESM(require_picocolors(), 1), import_semver6 = __toESM(require_semver(), 1);
8092
+ import { dedent as dedent15 } from "ts-dedent";
8051
8093
 
8052
8094
  // src/sandbox-templates.ts
8053
8095
  var baseTemplates = {
@@ -8954,21 +8996,21 @@ var toChoices = (c) => ({ label: allTemplates[c].name, value: c }), sandbox = as
8954
8996
  init,
8955
8997
  ...options
8956
8998
  }) => {
8957
- let selectedConfig = allTemplates[filterValue], templateId = selectedConfig ? filterValue : null, { packageManager: pkgMgr } = options, packageManager = JsPackageManagerFactory.getPackageManager({
8958
- force: pkgMgr
8999
+ let selectedConfig = allTemplates[filterValue], templateId = selectedConfig ? filterValue : null, packageManager = JsPackageManagerFactory.getPackageManager({
9000
+ force: PackageManagerName.NPM
8959
9001
  }), 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 = {
8960
- welcome: `Creating a Storybook ${import_picocolors14.default.bold(currentVersion)} sandbox..`,
8961
- notLatest: import_picocolors14.default.red(dedent14`
8962
- This version is behind the latest release, which is: ${import_picocolors14.default.bold(latestVersion)}!
9002
+ welcome: `Creating a Storybook ${import_picocolors15.default.bold(currentVersion)} sandbox..`,
9003
+ notLatest: import_picocolors15.default.red(dedent15`
9004
+ This version is behind the latest release, which is: ${import_picocolors15.default.bold(latestVersion)}!
8963
9005
  You likely ran the init command through npx, which can use a locally cached version, to get the latest please run:
8964
- ${import_picocolors14.default.bold("npx storybook@latest sandbox")}
9006
+ ${import_picocolors15.default.bold("npx storybook@latest sandbox")}
8965
9007
 
8966
9008
  You may want to CTRL+C to stop, and run with the latest version instead.
8967
9009
  `),
8968
- longInitTime: import_picocolors14.default.yellow(
9010
+ longInitTime: import_picocolors15.default.yellow(
8969
9011
  "The creation of the sandbox will take longer, because we will need to run init."
8970
9012
  ),
8971
- prerelease: import_picocolors14.default.yellow("This is a pre-release version.")
9013
+ prerelease: import_picocolors15.default.yellow("This is a pre-release version.")
8972
9014
  };
8973
9015
  if (logger19.logBox(
8974
9016
  [messages2.welcome].concat(isOutdated && !isPrerelease ? [messages2.notLatest] : []).concat(init && (isOutdated || isPrerelease) ? [messages2.longInitTime] : []).concat(isPrerelease ? [messages2.prerelease] : []).join(`
@@ -8982,23 +9024,23 @@ var toChoices = (c) => ({ label: allTemplates[c].name, value: c }), sandbox = as
8982
9024
  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;
8983
9025
  }, []);
8984
9026
  if (choices.length === 0 && (logger19.logBox(
8985
- dedent14`
9027
+ dedent15`
8986
9028
  🔎 You filtered out all templates. 🔍
8987
9029
 
8988
- After filtering all the templates with "${import_picocolors14.default.yellow(
9030
+ After filtering all the templates with "${import_picocolors15.default.yellow(
8989
9031
  filterValue
8990
9032
  )}", we found no results. Please try again with a different filter.
8991
9033
 
8992
9034
  Available templates:
8993
- ${keys.map((key) => import_picocolors14.default.blue(`- ${key}`)).join(`
9035
+ ${keys.map((key) => import_picocolors15.default.blue(`- ${key}`)).join(`
8994
9036
  `)}
8995
9037
  `.trim(),
8996
9038
  { borderStyle: "round", padding: 1, borderColor: "#F1618C" }
8997
9039
  ), process.exit(1)), choices.length === 1 ? [templateId] = choices : (logger19.logBox(
8998
- dedent14`
8999
- 🤗 Welcome to ${import_picocolors14.default.yellow("sb sandbox")}! 🤗
9040
+ dedent15`
9041
+ 🤗 Welcome to ${import_picocolors15.default.yellow("sb sandbox")}! 🤗
9000
9042
 
9001
- Create a ${import_picocolors14.default.green("new project")} to minimally reproduce Storybook issues.
9043
+ Create a ${import_picocolors15.default.green("new project")} to minimally reproduce Storybook issues.
9002
9044
 
9003
9045
  1. select an environment that most closely matches your project setup.
9004
9046
  2. select a location for the reproduction, outside of your project.
@@ -9028,15 +9070,15 @@ var toChoices = (c) => ({ label: allTemplates[c].name, value: c }), sandbox = as
9028
9070
  )), invariant(selectedDirectory);
9029
9071
  try {
9030
9072
  let templateDestination = isAbsolute2(selectedDirectory) ? selectedDirectory : join(process.cwd(), selectedDirectory);
9031
- logger19.log(`\u{1F3C3} Adding ${selectedConfig.name} into ${templateDestination}`), logger19.log(`\u{1F4E6} Downloading sandbox template (${import_picocolors14.default.bold(downloadType)})...`);
9073
+ logger19.log(`\u{1F3C3} Adding ${selectedConfig.name} into ${templateDestination}`), logger19.log(`\u{1F4E6} Downloading sandbox template (${import_picocolors15.default.bold(downloadType)})...`);
9032
9074
  try {
9033
9075
  let gitPath = `storybookjs/sandboxes/tree/${branch}/${templateId}/${downloadType}`;
9034
9076
  if (await mkdir2(templateDestination, { recursive: !0 }), (0, import_cross_spawn2.sync)("npx", ["gitpick@4.12.4", gitPath, templateDestination, "-o"], {
9035
9077
  stdio: "inherit"
9036
9078
  }), (await readdir(templateDestination)).length === 0) {
9037
- let selected = import_picocolors14.default.yellow(templateId);
9038
- throw new Error(dedent14`
9039
- Template downloaded from ${import_picocolors14.default.blue(gitPath)} is empty.
9079
+ let selected = import_picocolors15.default.yellow(templateId);
9080
+ throw new Error(dedent15`
9081
+ Template downloaded from ${import_picocolors15.default.blue(gitPath)} is empty.
9040
9082
  Are you use it exists? Or did you want to set ${selected} to inDevelopment first?
9041
9083
  `);
9042
9084
  }
@@ -9054,20 +9096,20 @@ var toChoices = (c) => ({ label: allTemplates[c].name, value: c }), sandbox = as
9054
9096
  } catch (err) {
9055
9097
  throw logger19.error(`\u{1F6A8} Failed to download sandbox template: ${String(err)}`), err;
9056
9098
  }
9057
- let initMessage = init ? import_picocolors14.default.yellow(dedent14`
9099
+ let initMessage = init ? import_picocolors15.default.yellow(dedent15`
9058
9100
  yarn install
9059
9101
  yarn storybook
9060
- `) : `Recreate your setup, then ${import_picocolors14.default.yellow("npx storybook@latest init")}`;
9102
+ `) : `Recreate your setup, then ${import_picocolors15.default.yellow("npx storybook@latest init")}`;
9061
9103
  logger19.logBox(
9062
- dedent14`
9104
+ dedent15`
9063
9105
  🎉 Your Storybook reproduction project is ready to use! 🎉
9064
9106
 
9065
- ${import_picocolors14.default.yellow(`cd ${selectedDirectory}`)}
9107
+ ${import_picocolors15.default.yellow(`cd ${selectedDirectory}`)}
9066
9108
  ${initMessage}
9067
9109
 
9068
9110
  Once you've recreated the problem you're experiencing, please:
9069
9111
 
9070
- 1. Document any additional steps in ${import_picocolors14.default.cyan("README.md")}
9112
+ 1. Document any additional steps in ${import_picocolors15.default.cyan("README.md")}
9071
9113
  2. Publish the repository to github
9072
9114
  3. Link to the repro repository in your issue
9073
9115
 
@@ -9087,8 +9129,8 @@ async function promptSelectedTemplate(choices) {
9087
9129
  }
9088
9130
 
9089
9131
  // src/upgrade.ts
9090
- var import_cross_spawn3 = __toESM(require_cross_spawn(), 1), import_picocolors15 = __toESM(require_picocolors(), 1), import_semver7 = __toESM(require_semver(), 1);
9091
- import { PackageManagerName } from "storybook/internal/common";
9132
+ var import_cross_spawn3 = __toESM(require_cross_spawn(), 1), import_picocolors16 = __toESM(require_picocolors(), 1), import_semver7 = __toESM(require_semver(), 1);
9133
+ import { PackageManagerName as PackageManagerName2 } from "storybook/internal/common";
9092
9134
  import { HandledError, JsPackageManagerFactory as JsPackageManagerFactory2, isCorePackage as isCorePackage2 } from "storybook/internal/common";
9093
9135
  import {
9094
9136
  CLI_COLORS as CLI_COLORS4,
@@ -9102,7 +9144,7 @@ import {
9102
9144
  UpgradeStorybookUnknownCurrentVersionError
9103
9145
  } from "storybook/internal/server-errors";
9104
9146
  import { telemetry } from "storybook/internal/telemetry";
9105
- import { dedent as dedent15 } from "ts-dedent";
9147
+ import { dedent as dedent16 } from "ts-dedent";
9106
9148
 
9107
9149
  // src/automigrate/multi-project.ts
9108
9150
  import { CLI_COLORS as CLI_COLORS3, logger as logger20, prompt as prompt5 } from "storybook/internal/node-logger";
@@ -9413,7 +9455,7 @@ ${projectList}`);
9413
9455
  }
9414
9456
  } else
9415
9457
  Object.values(doctorResults).every((result) => result.status === "healthy") ? logger21.step(`${CLI_COLORS4.success("Your project(s) have been upgraded successfully! \u{1F389}")}`) : logger21.step(
9416
- `${import_picocolors15.default.yellow("Your project(s) have been upgraded successfully, but some issues were found which need your attention, please check Storybook doctor logs above.")}`
9458
+ `${import_picocolors16.default.yellow("Your project(s) have been upgraded successfully, but some issues were found which need your attention, please check Storybook doctor logs above.")}`
9417
9459
  );
9418
9460
  let automigrationLinks = detectedAutomigrations.filter(
9419
9461
  (am) => Object.entries(projectResults).some(
@@ -9469,9 +9511,9 @@ async function upgrade(options) {
9469
9511
  return;
9470
9512
  let { allProjects, selectedProjects: storybookProjects } = projectsResult;
9471
9513
  storybookProjects.length > 1 ? logger21.info(`Upgrading the following projects:
9472
- ${storybookProjects.map((p) => `${import_picocolors15.default.cyan(shortenPath(p.configDir))}: ${import_picocolors15.default.bold(p.beforeVersion)} -> ${import_picocolors15.default.bold(p.currentCLIVersion)}`).join(`
9514
+ ${storybookProjects.map((p) => `${import_picocolors16.default.cyan(shortenPath(p.configDir))}: ${import_picocolors16.default.bold(p.beforeVersion)} -> ${import_picocolors16.default.bold(p.currentCLIVersion)}`).join(`
9473
9515
  `)}`) : logger21.info(
9474
- `Upgrading from ${import_picocolors15.default.bold(storybookProjects[0].beforeVersion)} to ${import_picocolors15.default.bold(storybookProjects[0].currentCLIVersion)}`
9516
+ `Upgrading from ${import_picocolors16.default.bold(storybookProjects[0].beforeVersion)} to ${import_picocolors16.default.bold(storybookProjects[0].currentCLIVersion)}`
9475
9517
  );
9476
9518
  let automigrationResults = {}, doctorResults = {}, handleInterruption = async () => {
9477
9519
  throw logger21.log(`
@@ -9487,7 +9529,7 @@ Upgrade interrupted by user.`), allProjects.length > 1 && await sendMultiUpgrade
9487
9529
  process.on("SIGINT", handleInterruption), process.on("SIGTERM", handleInterruption);
9488
9530
  try {
9489
9531
  if (processAutoblockerResults(storybookProjects, (message) => {
9490
- logger21.error(dedent15`Blockers detected\n\n${message}`);
9532
+ logger21.error(dedent16`Blockers detected\n\n${message}`);
9491
9533
  }))
9492
9534
  throw new HandledError("Blockers detected");
9493
9535
  if (storybookProjects.some((project) => {
@@ -9527,7 +9569,7 @@ Upgrade interrupted by user.`), allProjects.length > 1 && await sendMultiUpgrade
9527
9569
  storybookProjects,
9528
9570
  options
9529
9571
  ), rootPackageManager = storybookProjects.length > 1 ? JsPackageManagerFactory2.getPackageManager({ force: options.packageManager }) : storybookProjects[0].packageManager;
9530
- rootPackageManager.type === "npm" ? await rootPackageManager.installDependencies({ force: !0 }) : await rootPackageManager.installDependencies(), rootPackageManager.type !== PackageManagerName.YARN1 && rootPackageManager.isStorybookInMonorepo() && (logger21.warn(
9572
+ rootPackageManager.type === "npm" ? await rootPackageManager.installDependencies({ force: !0 }) : await rootPackageManager.installDependencies(), rootPackageManager.type !== PackageManagerName2.YARN1 && rootPackageManager.isStorybookInMonorepo() && (logger21.warn(
9531
9573
  "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."
9532
9574
  ), options.yes || await prompt6.confirm({
9533
9575
  message: `Execute ${rootPackageManager.getRunCommand("dedupe")}?`,
@@ -9541,35 +9583,34 @@ Upgrade interrupted by user.`), allProjects.length > 1 && await sendMultiUpgrade
9541
9583
  storybookVersion: project.currentCLIVersion,
9542
9584
  mainConfig: project.mainConfig
9543
9585
  }));
9544
- if (logger21.step("Checking the health of your project(s).."), doctorResults = await runMultiProjectDoctor(doctorProjects), displayDoctorResults(doctorResults) && logTracker3.enableLogWriting(), logUpgradeResults(automigrationResults2, detectedAutomigrations, doctorResults), !options.disableTelemetry) {
9545
- for (let project of storybookProjects) {
9546
- let resultData = automigrationResults2[project.configDir] || {
9547
- automigrationStatuses: {},
9548
- automigrationErrors: {}
9549
- }, doctorFailureCount = 0, doctorErrorCount = 0;
9550
- Object.values(doctorResults[project.configDir]?.diagnostics || {}).forEach((status) => {
9551
- status === "has_issues" && doctorFailureCount++, status === "check_error" && doctorErrorCount++;
9552
- });
9553
- let automigrationFailureCount = Object.keys(resultData.automigrationErrors).length, automigrationPreCheckFailure = project.autoblockerCheckResults && project.autoblockerCheckResults.length > 0 ? project.autoblockerCheckResults?.map((result) => result.result !== null ? result.blocker.id : null).filter(Boolean) : null;
9554
- await telemetry("upgrade", {
9555
- beforeVersion: project.beforeVersion,
9556
- afterVersion: project.currentCLIVersion,
9557
- automigrationResults: resultData.automigrationStatuses,
9558
- automigrationErrors: resultData.automigrationErrors,
9559
- automigrationFailureCount,
9560
- automigrationPreCheckFailure,
9561
- doctorResults: doctorResults[project.configDir]?.diagnostics || {},
9562
- doctorFailureCount,
9563
- doctorErrorCount
9564
- });
9565
- }
9566
- await sendMultiUpgradeTelemetry({
9567
- allProjects,
9568
- selectedProjects: storybookProjects,
9569
- projectResults: automigrationResults2,
9570
- doctorResults
9586
+ logger21.step("Checking the health of your project(s).."), doctorResults = await runMultiProjectDoctor(doctorProjects), displayDoctorResults(doctorResults) && logTracker3.enableLogWriting(), logUpgradeResults(automigrationResults2, detectedAutomigrations, doctorResults);
9587
+ for (let project of storybookProjects) {
9588
+ let resultData = automigrationResults2[project.configDir] || {
9589
+ automigrationStatuses: {},
9590
+ automigrationErrors: {}
9591
+ }, doctorFailureCount = 0, doctorErrorCount = 0;
9592
+ Object.values(doctorResults[project.configDir]?.diagnostics || {}).forEach((status) => {
9593
+ status === "has_issues" && doctorFailureCount++, status === "check_error" && doctorErrorCount++;
9594
+ });
9595
+ let automigrationFailureCount = Object.keys(resultData.automigrationErrors).length, automigrationPreCheckFailure = project.autoblockerCheckResults && project.autoblockerCheckResults.length > 0 ? project.autoblockerCheckResults?.map((result) => result.result !== null ? result.blocker.id : null).filter(Boolean) : null;
9596
+ await telemetry("upgrade", {
9597
+ beforeVersion: project.beforeVersion,
9598
+ afterVersion: project.currentCLIVersion,
9599
+ automigrationResults: resultData.automigrationStatuses,
9600
+ automigrationErrors: resultData.automigrationErrors,
9601
+ automigrationFailureCount,
9602
+ automigrationPreCheckFailure,
9603
+ doctorResults: doctorResults[project.configDir]?.diagnostics || {},
9604
+ doctorFailureCount,
9605
+ doctorErrorCount
9571
9606
  });
9572
9607
  }
9608
+ await sendMultiUpgradeTelemetry({
9609
+ allProjects,
9610
+ selectedProjects: storybookProjects,
9611
+ projectResults: automigrationResults2,
9612
+ doctorResults
9613
+ });
9573
9614
  } finally {
9574
9615
  process.removeListener("SIGINT", handleInterruption), process.removeListener("SIGTERM", handleInterruption);
9575
9616
  }
@@ -9613,7 +9654,7 @@ var handleCommandFailure = (logFilePath) => async (error) => {
9613
9654
  });
9614
9655
  command("init").description("Initialize Storybook into your project").option("-f --force", "Force add Storybook").option("-s --skip-install", "Skip installing deps").addOption(
9615
9656
  new Option("--package-manager <type>", "Force package manager for installing deps").choices(
9616
- Object.values(PackageManagerName2)
9657
+ Object.values(PackageManagerName3)
9617
9658
  )
9618
9659
  ).option("--use-pnp", "Enable PnP mode for Yarn 2+").option("-p --parser <babel | babylon | flow | ts | tsx>", "jscodeshift parser").option("-t --type <type>", "Add Storybook for a specific project type").option("-y --yes", "Answer yes to all prompts").option("-b --builder <webpack5 | vite>", "Builder library").option("-l --linkable", "Prepare installation for link (contributor helper)").option(
9619
9660
  "--dev",
@@ -9625,16 +9666,16 @@ command("init").description("Initialize Storybook into your project").option("-f
9625
9666
  );
9626
9667
  command("add <addon>").description("Add an addon to your Storybook").addOption(
9627
9668
  new Option("--package-manager <type>", "Force package manager for installing deps").choices(
9628
- Object.values(PackageManagerName2)
9669
+ Object.values(PackageManagerName3)
9629
9670
  )
9630
9671
  ).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) => {
9631
9672
  withTelemetry("add", { cliOptions: options }, async () => {
9632
- logger22.intro(`Setting up your project for ${addonName}`), await add(addonName, options), options.disableTelemetry || await telemetry2("add", { addon: addonName, source: "cli" }), logger22.outro("Done!");
9673
+ logger22.intro(`Setting up your project for ${addonName}`), await add(addonName, options), await telemetry2("add", { addon: addonName, source: "cli" }), logger22.outro("Done!");
9633
9674
  }).catch(handleCommandFailure);
9634
9675
  });
9635
9676
  command("remove <addon>").description("Remove an addon from your Storybook").addOption(
9636
9677
  new Option("--package-manager <type>", "Force package manager for installing deps").choices(
9637
- Object.values(PackageManagerName2)
9678
+ Object.values(PackageManagerName3)
9638
9679
  )
9639
9680
  ).option("-c, --config-dir <dir-name>", "Directory where to load Storybook configurations from").option("-s --skip-install", "Skip installing deps").action(
9640
9681
  (addonName, options) => withTelemetry("remove", { cliOptions: options }, async () => {
@@ -9647,12 +9688,12 @@ command("remove <addon>").description("Remove an addon from your Storybook").add
9647
9688
  configDir: options.configDir,
9648
9689
  packageManager,
9649
9690
  skipInstall: options.skipInstall
9650
- }), options.disableTelemetry || await telemetry2("remove", { addon: addonName, source: "cli" }), logger22.outro("Done!");
9691
+ }), await telemetry2("remove", { addon: addonName, source: "cli" }), logger22.outro("Done!");
9651
9692
  }).catch(handleCommandFailure(options.logfile))
9652
9693
  );
9653
9694
  command("upgrade").description(`Upgrade your Storybook packages to v${versions5.storybook}`).addOption(
9654
9695
  new Option("--package-manager <type>", "Force package manager for installing deps").choices(
9655
- Object.values(PackageManagerName2)
9696
+ Object.values(PackageManagerName3)
9656
9697
  )
9657
9698
  ).option("-y --yes", "Skip prompting the user").option("-f --force", "force the upgrade, skipping autoblockers").option("-n --dry-run", "Only check for upgrades, do not install").option("-s --skip-check", "Skip postinstall version and automigration checks").option(
9658
9699
  "-c, --config-dir <dir-name...>",
@@ -9667,7 +9708,7 @@ command("upgrade").description(`Upgrade your Storybook packages to v${versions5.
9667
9708
  ).catch(handleCommandFailure(options.logfile));
9668
9709
  });
9669
9710
  command("info").description("Prints debugging information about the local environment").action(async () => {
9670
- logger22.log(import_picocolors16.default.bold(`
9711
+ logger22.log(import_picocolors17.default.bold(`
9671
9712
  Storybook Environment Info:`));
9672
9713
  let activePackageManager = JsPackageManagerFactory3.getPackageManager().type.replace(/\d/, ""), output = await import_envinfo.default.run({
9673
9714
  System: ["OS", "CPU", "Shell"],
@@ -9679,7 +9720,7 @@ Storybook Environment Info:`));
9679
9720
  logger22.log(
9680
9721
  output.replace(
9681
9722
  activePackageManagerLine,
9682
- import_picocolors16.default.bold(`${activePackageManagerLine} <----- active`)
9723
+ import_picocolors17.default.bold(`${activePackageManagerLine} <----- active`)
9683
9724
  )
9684
9725
  );
9685
9726
  });
@@ -9704,7 +9745,7 @@ command("link <repo-url-or-directory>").description("Pull down a repro from a UR
9704
9745
  );
9705
9746
  command("automigrate [fixId]").description("Check storybook for incompatibilities or migrations and apply fixes").option("-y --yes", "Skip prompting the user").option("-n --dry-run", "Only check for fixes, do not actually run them").addOption(
9706
9747
  new Option("--package-manager <type>", "Force package manager for installing deps").choices(
9707
- Object.values(PackageManagerName2)
9748
+ Object.values(PackageManagerName3)
9708
9749
  )
9709
9750
  ).option("-l --list", "List available migrations").option("-c, --config-dir <dir-name>", "Directory of Storybook configurations to migrate").option("-s --skip-install", "Skip installing deps").option(
9710
9751
  "--renderer <renderer-pkg-name>",
@@ -9716,7 +9757,7 @@ command("automigrate [fixId]").description("Check storybook for incompatibilitie
9716
9757
  });
9717
9758
  command("doctor").description("Check Storybook for known problems and provide suggestions or fixes").addOption(
9718
9759
  new Option("--package-manager <type>", "Force package manager for installing deps").choices(
9719
- Object.values(PackageManagerName2)
9760
+ Object.values(PackageManagerName3)
9720
9761
  )
9721
9762
  ).option("-c, --config-dir <dir-name>", "Directory of Storybook configuration").action(async (options) => {
9722
9763
  withTelemetry("doctor", { cliOptions: options }, async () => {
@@ -9724,9 +9765,9 @@ command("doctor").description("Check Storybook for known problems and provide su
9724
9765
  }).catch(handleCommandFailure(options.logfile));
9725
9766
  });
9726
9767
  program.on("command:*", ([invalidCmd]) => {
9727
- let errorMessage = ` Invalid command: ${import_picocolors16.default.bold(invalidCmd)}.
9768
+ let errorMessage = ` Invalid command: ${import_picocolors17.default.bold(invalidCmd)}.
9728
9769
  See --help for a list of available commands.`, suggestion = program.commands.map((cmd) => cmd.name()).find((cmd) => leven(cmd, invalidCmd) < 3);
9729
9770
  suggestion && (errorMessage += `
9730
- Did you mean ${import_picocolors16.default.yellow(suggestion)}?`), logger22.error(errorMessage), process.exit(1);
9771
+ Did you mean ${import_picocolors17.default.yellow(suggestion)}?`), logger22.error(errorMessage), process.exit(1);
9731
9772
  });
9732
9773
  program.usage("<command> [options]").version(String(version)).parse(process.argv);