@storybook/cli 11.0.0-alpha.8 → 11.0.0-beta.0

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.
Files changed (18) hide show
  1. package/dist/_node-chunks/{block-create-react-app-7FNU4CBM.js → block-create-react-app-55SCV5HS.js} +8 -8
  2. package/dist/_node-chunks/{block-dependencies-versions-3HIVYTAD.js → block-dependencies-versions-X3UXQKXS.js} +13 -13
  3. package/dist/_node-chunks/{block-experimental-addon-test-2NBRKH5B.js → block-experimental-addon-test-ZCNN3AY5.js} +9 -9
  4. package/dist/_node-chunks/{block-major-version-K2Y53V3L.js → block-major-version-GL7Y4MJM.js} +9 -9
  5. package/dist/_node-chunks/{block-node-version-PUUM26IQ.js → block-node-version-GQKR7KYD.js} +8 -8
  6. package/dist/_node-chunks/{block-react-legacy-root-api-ESXDCB2N.js → block-react-legacy-root-api-L42GIMIJ.js} +8 -8
  7. package/dist/_node-chunks/{block-webpack5-frameworks-M3L7NMZH.js → block-webpack5-frameworks-PPD62WAL.js} +11 -11
  8. package/dist/_node-chunks/chunk-265TYWHA.js +11 -0
  9. package/dist/_node-chunks/{chunk-5F2NM7VF.js → chunk-32EZTKOD.js} +6 -6
  10. package/dist/_node-chunks/{chunk-IC37BRUZ.js → chunk-LK3ZGBEB.js} +17 -17
  11. package/dist/_node-chunks/{chunk-J5HVJRFW.js → chunk-LUBSYZGT.js} +7 -7
  12. package/dist/_node-chunks/{chunk-WMRVFXLT.js → chunk-ZDYT6VJJ.js} +7 -7
  13. package/dist/_node-chunks/{globby-7OAS3ZTU.js → globby-UPXDPS6W.js} +8 -8
  14. package/dist/_node-chunks/{p-limit-BO6YVIDZ.js → p-limit-TGWAHTUF.js} +7 -7
  15. package/dist/_node-chunks/{run-FR35DMP3.js → run-6MV3DMOK.js} +264 -263
  16. package/dist/bin/index.js +7 -7
  17. package/package.json +4 -4
  18. package/dist/_node-chunks/chunk-VW3ZGBUF.js +0 -11
@@ -1,10 +1,10 @@
1
- import CJS_COMPAT_NODE_URL_kwozah22xdi from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_kwozah22xdi from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_kwozah22xdi from "node:module";
1
+ import CJS_COMPAT_NODE_URL_jfk48wh4278 from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_jfk48wh4278 from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_jfk48wh4278 from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_kwozah22xdi.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_kwozah22xdi.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_kwozah22xdi.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_jfk48wh4278.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_jfk48wh4278.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_jfk48wh4278.createRequire(import.meta.url);
8
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration
@@ -20,18 +20,18 @@ import {
20
20
  shortenPath,
21
21
  up,
22
22
  upgradeStorybookDependencies
23
- } from "./chunk-IC37BRUZ.js";
23
+ } from "./chunk-LK3ZGBEB.js";
24
24
  import {
25
25
  slash
26
- } from "./chunk-WMRVFXLT.js";
26
+ } from "./chunk-ZDYT6VJJ.js";
27
27
  import {
28
28
  require_semver
29
- } from "./chunk-J5HVJRFW.js";
29
+ } from "./chunk-LUBSYZGT.js";
30
30
  import {
31
31
  __commonJS,
32
32
  __require,
33
33
  __toESM
34
- } from "./chunk-5F2NM7VF.js";
34
+ } from "./chunk-32EZTKOD.js";
35
35
 
36
36
  // ../../../node_modules/envinfo/dist/envinfo.js
37
37
  var require_envinfo = __commonJS({
@@ -4752,10 +4752,10 @@ function leven(first, second, options) {
4752
4752
  }
4753
4753
 
4754
4754
  // src/bin/run.ts
4755
- var import_picocolors22 = __toESM(require_picocolors(), 1);
4755
+ var import_picocolors23 = __toESM(require_picocolors(), 1);
4756
4756
 
4757
4757
  // package.json
4758
- var version = "11.0.0-alpha.8";
4758
+ var version = "11.0.0-beta.0";
4759
4759
 
4760
4760
  // src/add.ts
4761
4761
  var import_semver2 = __toESM(require_semver(), 1);
@@ -5166,7 +5166,7 @@ function isValidVersion(version2) {
5166
5166
  }
5167
5167
 
5168
5168
  // src/automigrate/index.ts
5169
- var import_picocolors19 = __toESM(require_picocolors(), 1);
5169
+ var import_picocolors20 = __toESM(require_picocolors(), 1);
5170
5170
  import { versions as versions2 } from "storybook/internal/common";
5171
5171
  import { logTracker as logTracker2, logger as logger19, prompt as prompt5 } from "storybook/internal/node-logger";
5172
5172
  import { AutomigrateError } from "storybook/internal/server-errors";
@@ -5767,13 +5767,10 @@ import {
5767
5767
 
5768
5768
  // src/automigrate/helpers/edit-parsed-file.ts
5769
5769
  import { HandledError } from "storybook/internal/common";
5770
- import {
5771
- unwrapExpression
5772
- } from "storybook/internal/csf-tools";
5773
- var covered = /* @__PURE__ */ new WeakSet(), describeDiagnostic = ({ message, loc }) => loc ? `line ${loc.start.line}: ${message}` : message, editParsedFile = async (file, edit2) => {
5770
+ var describeDiagnostic = ({ message, loc }) => loc ? `line ${loc.start.line}: ${message}` : message, editParsedFile = async (file, edit2) => {
5774
5771
  let diagnosticsBefore = file.mutationDiagnostics.length;
5775
5772
  await edit2(file);
5776
- let diagnostics = file.mutationDiagnostics.slice(diagnosticsBefore).filter((diagnostic) => !covered.has(diagnostic));
5773
+ let diagnostics = file.mutationDiagnostics.slice(diagnosticsBefore).filter(({ code }) => code !== "aliased-story");
5777
5774
  if (diagnostics.length > 0)
5778
5775
  throw new HandledError([...new Set(diagnostics.map(describeDiagnostic))].join("; "));
5779
5776
  }, readForEdit = (object, path4) => {
@@ -5781,31 +5778,6 @@ var covered = /* @__PURE__ */ new WeakSet(), describeDiagnostic = ({ message, lo
5781
5778
  if (found.kind === "unreadable")
5782
5779
  throw new HandledError(describeDiagnostic(found.diagnostic));
5783
5780
  return found.kind === "value" ? found.node : void 0;
5784
- }, constInitializer = (csf, name) => {
5785
- for (let statement of csf.program.body) {
5786
- let declaration = statement.type === "ExportNamedDeclaration" ? statement.declaration : statement;
5787
- if (!(declaration?.type !== "VariableDeclaration" || declaration.kind !== "const")) {
5788
- for (let declarator of declaration.declarations)
5789
- if (declarator.id.type === "Identifier" && declarator.id.name === name)
5790
- return declarator.init ? unwrapExpression(declarator.init) : void 0;
5791
- }
5792
- }
5793
- }, everyCsfObject = (csf) => {
5794
- let diagnosticsBefore = csf.mutationDiagnostics.length, objects = csf.objects(), edited = new Set(
5795
- objects.flatMap(({ target }) => target.kind === "story" ? [target.localName] : [])
5796
- ), aliases = csf.mutationDiagnostics.slice(diagnosticsBefore).flatMap((diagnostic) => {
5797
- let { code, path: path4, target } = diagnostic;
5798
- if (code !== "unsupported-initializer" || path4.length > 0 || target.kind !== "story")
5799
- return [];
5800
- let init = constInitializer(csf, target.localName);
5801
- return init?.type === "Identifier" ? [{ diagnostic, name: target.localName, of: init.name }] : [];
5802
- });
5803
- for (let found = !0; found; ) {
5804
- found = !1;
5805
- for (let { diagnostic, name, of } of aliases)
5806
- !covered.has(diagnostic) && edited.has(of) && (covered.add(diagnostic), edited.add(name), found = !0);
5807
- }
5808
- return objects;
5809
5781
  };
5810
5782
 
5811
5783
  // src/automigrate/fix-files.ts
@@ -5887,7 +5859,7 @@ var KIND_ORDER = ["main", "preview", "manager", "config", "story"], parse2 = (co
5887
5859
  project.mainConfigPath && claim(project.mainConfigPath, "main"), project.previewConfigPath && claim(project.previewConfigPath, "preview");
5888
5860
  let managerConfigPath = project.configDir && findConfigFile("manager", project.configDir);
5889
5861
  if (managerConfigPath && claim(managerConfigPath, "manager"), project.storiesPaths.forEach((id) => claim(id, "story")), kinds.has("config")) {
5890
- let { globby } = await import("./globby-7OAS3ZTU.js");
5862
+ let { globby } = await import("./globby-UPXDPS6W.js");
5891
5863
  (await globby("**/*.{js,jsx,ts,tsx,mjs,cjs,mts,cts}", {
5892
5864
  cwd: project.configDir,
5893
5865
  absolute: !0,
@@ -6102,7 +6074,7 @@ import { logger as logger4 } from "storybook/internal/node-logger";
6102
6074
  import { promises as fs } from "fs";
6103
6075
  var maxConcurrentTasks = Math.max(1, os.cpus().length - 1);
6104
6076
  async function runCodemod(globPattern = "**/*.{stories,story}.{js,jsx,ts,tsx,mjs,mjsx,mts,mtsx}", transform, { dryRun = !1, skipFormatting = !1 } = {}) {
6105
- let modifiedCount = 0, unmodifiedCount = 0, errorCount = 0, { globby } = await import("./globby-7OAS3ZTU.js"), files = await globby(slash(globPattern), {
6077
+ let modifiedCount = 0, unmodifiedCount = 0, errorCount = 0, { globby } = await import("./globby-UPXDPS6W.js"), files = await globby(slash(globPattern), {
6106
6078
  followSymbolicLinks: !0,
6107
6079
  ignore: ["**/node_modules/**", "**/dist/**", "**/storybook-static/**", "**/build/**"]
6108
6080
  });
@@ -6113,7 +6085,7 @@ Please try a different pattern.
6113
6085
  `
6114
6086
  ), new Error("No files matched");
6115
6087
  try {
6116
- let pLimit = (await import("./p-limit-BO6YVIDZ.js")).default, limit = pLimit(maxConcurrentTasks);
6088
+ let pLimit = (await import("./p-limit-TGWAHTUF.js")).default, limit = pLimit(maxConcurrentTasks);
6117
6089
  await Promise.all(
6118
6090
  files.map(
6119
6091
  (file) => limit(async () => {
@@ -6163,7 +6135,7 @@ import {
6163
6135
  removeStatements as removeStatements2,
6164
6136
  setImportSpecifiers as setImportSpecifiers2,
6165
6137
  prependStatement,
6166
- unwrapExpression as unwrapExpression2
6138
+ unwrapExpression
6167
6139
  } from "storybook/internal/csf-tools";
6168
6140
  import { logger as logger5 } from "storybook/internal/node-logger";
6169
6141
 
@@ -6257,7 +6229,7 @@ ${err}`), info.source;
6257
6229
  let methodName = configType === "main" ? "defineMain" : "definePreview", editor = config.editor, exportDecls = config._exportDecls, defineConfigProps = getConfigProperties(editor, exportDecls, { configType }), hasNamedExports = defineConfigProps.length > 0, isAlreadyTransformed = config.program.body.some((node) => {
6258
6230
  if (node.type !== "ExportDefaultDeclaration")
6259
6231
  return !1;
6260
- let declaration = unwrapExpression2(node.declaration);
6232
+ let declaration = unwrapExpression(node.declaration);
6261
6233
  return declaration?.type === "CallExpression" && declaration.callee.type === "Identifier" && declaration.callee.name === methodName;
6262
6234
  }), expectedImportSource = frameworkPackage + (configType === "main" ? "/node" : ""), findFrameworkImport = () => config.program.body.find(
6263
6235
  (node) => node.type === "ImportDeclaration" && node.importKind !== "type" && node.source.value === expectedImportSource
@@ -6268,7 +6240,7 @@ ${err}`), info.source;
6268
6240
  return info.source;
6269
6241
  let findObjectDeclaration = (declarationName) => config.program.body.find(
6270
6242
  (n) => n.type === "VariableDeclaration" && n.declarations.some(
6271
- (d) => d.id.type === "Identifier" && d.id.name === declarationName && unwrapExpression2(d.init)?.type === "ObjectExpression"
6243
+ (d) => d.id.type === "Identifier" && d.id.name === declarationName && unwrapExpression(d.init)?.type === "ObjectExpression"
6272
6244
  )
6273
6245
  ), wrapDefaultExport = (unwrapIdentifier) => {
6274
6246
  let exportsObject = config._exportsObject;
@@ -6278,7 +6250,7 @@ ${err}`), info.source;
6278
6250
  for (let node of config.program.body) {
6279
6251
  if (node.type !== "ExportDefaultDeclaration")
6280
6252
  continue;
6281
- let declaration = unwrapIdentifier ? unwrapExpression2(node.declaration) : node.declaration;
6253
+ let declaration = unwrapIdentifier ? unwrapExpression(node.declaration) : node.declaration;
6282
6254
  if (declaration?.type === "Identifier") {
6283
6255
  let declarationNode = findObjectDeclaration(declaration.name);
6284
6256
  if (!declarationNode)
@@ -6837,7 +6809,7 @@ import {
6837
6809
  walk as walk4,
6838
6810
  setImportSpecifiers as setImportSpecifiers3,
6839
6811
  staticKey,
6840
- unwrapExpression as unwrapExpression3,
6812
+ unwrapExpression as unwrapExpression2,
6841
6813
  wrapExpression
6842
6814
  } from "storybook/internal/csf-tools";
6843
6815
  var mockMembers = [
@@ -6882,7 +6854,7 @@ function wrapArgsMocks(editor) {
6882
6854
  let binding = bindingOf(node);
6883
6855
  binding && bindings.add(binding);
6884
6856
  }, isArgsObject = (expression) => {
6885
- let node = unwrapExpression3(expression);
6857
+ let node = unwrapExpression2(expression);
6886
6858
  return isBoundIn(argsObjects, node) || isMember(node) && nameOf(node.property) === "args";
6887
6859
  }, addArgs = (pattern) => {
6888
6860
  let target = withoutDefault(pattern);
@@ -6897,7 +6869,7 @@ function wrapArgsMocks(editor) {
6897
6869
  }, collectTarget = (node) => {
6898
6870
  if (!isMember(node) || !mockMembers.includes(nameOf(node.property) ?? "") || node.object.type === "TSAsExpression")
6899
6871
  return;
6900
- let object = unwrapExpression3(node.object);
6872
+ let object = unwrapExpression2(node.object);
6901
6873
  (isBoundIn(argValues, object) || isMember(object) && isArgsObject(object.object)) && targets.push(node.object);
6902
6874
  };
6903
6875
  if (walk4(program2, (node) => {
@@ -6906,7 +6878,7 @@ function wrapArgsMocks(editor) {
6906
6878
  index === 0 && isRender(editor, node) ? addArgs(param) : addContext(param);
6907
6879
  });
6908
6880
  else if (node.type === "VariableDeclarator") {
6909
- let { id, init } = node, value = init && unwrapExpression3(init);
6881
+ let { id, init } = node, value = init && unwrapExpression2(init);
6910
6882
  init && isArgsObject(init) ? addArgs(id) : value && isMember(value) && isArgsObject(value.object) ? bind(argValues, id) : addContext(id);
6911
6883
  } else node.type === "MemberExpression" && collectTarget(node);
6912
6884
  }), targets.length === 0)
@@ -7140,11 +7112,11 @@ var csfFactories = {
7140
7112
  }) {
7141
7113
  let inSandbox = optionalEnvToBoolean(process.env.IN_STORYBOOK_SANDBOX) ?? !1, isReactNativePreview = isReactNativeStorybookPath(previewConfigPath) || isReactNativeStorybookPath(configDir) || hasSiblingReactNativeConfig(configDir, existsSync), useSubPathImports = inSandbox || isReactNativePreview;
7142
7114
  !yes && !inSandbox && !isReactNativePreview && (logger8.logBox(dedent3`
7143
- The CSF Factories format can benefit from using absolute imports of your ${import_picocolors8.default.cyan(previewConfigPath)} file. We can configure that for you, using subpath imports (a node standard), by adjusting the imports property of your package.json.
7115
+ The CSF 4 format can benefit from using absolute imports of your ${import_picocolors8.default.cyan(previewConfigPath)} file. We can configure that for you, using subpath imports (a node standard), by adjusting the imports property of your package.json.
7144
7116
 
7145
7117
  However, we cannot broadly recommend it for all projects, because it might not work in some monorepo setups or if you have an outdated tsconfig, use custom paths, or have type alias plugins configured in your project. You can always rerun this codemod and select another option to update your code later.
7146
7118
 
7147
- More info: ${import_picocolors8.default.yellow("https://storybook.js.org/docs/api/csf/csf-next?ref=upgrade#previewmeta")}
7119
+ More info: ${import_picocolors8.default.yellow("https://storybook.js.org/docs/writing-stories/csf/?ref=upgrade#subpath-imports")}
7148
7120
  `), useSubPathImports = await prompt2.select({
7149
7121
  message: "Which import type would you like to use for your story files?",
7150
7122
  options: [
@@ -7184,10 +7156,10 @@ var csfFactories = {
7184
7156
  (fileInfo) => configToCsfFactory(fileInfo, { configType: "preview", frameworkPackage }, { dryRun })
7185
7157
  ), await syncStorybookAddons(mainConfig, previewConfigPath, configDir), logger8.logBox(
7186
7158
  dedent3`
7187
- You can now run Storybook with the new CSF factories format.
7159
+ You can now run Storybook with the new CSF 4 format.
7188
7160
 
7189
7161
  For more info, check out the docs:
7190
- ${import_picocolors8.default.yellow("https://storybook.js.org/docs/api/csf/csf-next?ref=upgrade")}
7162
+ ${import_picocolors8.default.yellow("https://storybook.js.org/docs/writing-stories/csf/upgrade?ref=upgrade")}
7191
7163
  `
7192
7164
  );
7193
7165
  }
@@ -7254,7 +7226,7 @@ var readJsonFile = async (files, path4) => {
7254
7226
  return null;
7255
7227
  }
7256
7228
  }, findWorkspaceFiles = async (basename5) => {
7257
- let { globby } = await import("./globby-7OAS3ZTU.js");
7229
+ let { globby } = await import("./globby-UPXDPS6W.js");
7258
7230
  return globby([`**/${basename5}`], {
7259
7231
  cwd: getProjectRoot2(),
7260
7232
  ignore: ["**/node_modules/**", "**/dist/**", "**/storybook-static/**"],
@@ -7954,12 +7926,12 @@ var SETTER_NAMES = ["setCustomElementsManifest", "setCustomElements"], WEB_COMPO
7954
7926
  };
7955
7927
 
7956
7928
  // src/automigrate/helpers/versionBoundary.ts
7957
- var import_semver7 = __toESM(require_semver(), 1), crossesVersionBoundary = (beforeVersion, targetVersion, introducedIn3) => {
7929
+ var import_semver7 = __toESM(require_semver(), 1), crossesVersionBoundary = (beforeVersion, targetVersion, introducedIn4) => {
7958
7930
  let before = import_semver7.default.coerce(beforeVersion), target = import_semver7.default.coerce(targetVersion);
7959
- return !before || !target ? !1 : import_semver7.default.lt(before, introducedIn3) && import_semver7.default.gte(target, introducedIn3);
7960
- }, isAtOrPastVersion = (version2, introducedIn3) => {
7931
+ return !before || !target ? !1 : import_semver7.default.lt(before, introducedIn4) && import_semver7.default.gte(target, introducedIn4);
7932
+ }, isAtOrPastVersion = (version2, introducedIn4) => {
7961
7933
  let coerced = import_semver7.default.coerce(version2);
7962
- return coerced !== null && import_semver7.default.gte(coerced, introducedIn3);
7934
+ return coerced !== null && import_semver7.default.gte(coerced, introducedIn4);
7963
7935
  };
7964
7936
 
7965
7937
  // src/automigrate/fixes/csf-next-mocked-args.ts
@@ -8207,7 +8179,7 @@ var argName = (property) => {
8207
8179
  filter: { kind: ["preview", "story"], code: "defaultValue" },
8208
8180
  editConfig: strip,
8209
8181
  editCsf: (csf) => {
8210
- everyCsfObject(csf).forEach(strip);
8182
+ csf.objects().forEach(strip);
8211
8183
  }
8212
8184
  }
8213
8185
  ]
@@ -8633,6 +8605,28 @@ var removeChangeDetectionFlag = {
8633
8605
  ]
8634
8606
  };
8635
8607
 
8608
+ // src/automigrate/fixes/remove-legacy-feature-flags.ts
8609
+ var removeLegacyFeatureFlags = {
8610
+ id: "remove-legacy-feature-flags",
8611
+ link: "https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#argtypetargetsv7-feature-flag-removed",
8612
+ prompt: () => "Remove features.argTypeTargetsV7 and features.disallowImplicitActionsInRenderV8. Both flags are always on in Storybook 11.",
8613
+ check: async ({ storybookVersion, mainConfig }) => {
8614
+ if (!isAtOrPastVersion(storybookVersion, "11.0.0"))
8615
+ return null;
8616
+ let features = mainConfig.features ?? {};
8617
+ return "argTypeTargetsV7" in features || "disallowImplicitActionsInRenderV8" in features ? {} : null;
8618
+ },
8619
+ transform: () => [
8620
+ {
8621
+ filter: { kind: ["main"], code: /argTypeTargetsV7|disallowImplicitActionsInRenderV8/ },
8622
+ // `remove` fails on a spread in `features`, even when the flag is only mentioned in a comment.
8623
+ editConfig: (main) => {
8624
+ main.getFieldNode(["features", "argTypeTargetsV7"]) && main.remove(["features", "argTypeTargetsV7"]), main.getFieldNode(["features", "disallowImplicitActionsInRenderV8"]) && main.remove(["features", "disallowImplicitActionsInRenderV8"]);
8625
+ }
8626
+ }
8627
+ ]
8628
+ };
8629
+
8636
8630
  // src/automigrate/fixes/remove-experimental-review.ts
8637
8631
  var removeExperimentalReview = {
8638
8632
  id: "remove-experimental-review",
@@ -8933,8 +8927,57 @@ var tagOptionRenames = {
8933
8927
  ]
8934
8928
  };
8935
8929
 
8930
+ // src/automigrate/fixes/typescript-dependency.ts
8931
+ var import_picocolors17 = __toESM(require_picocolors(), 1), import_semver8 = __toESM(require_semver(), 1);
8932
+ import {
8933
+ RENDERERS_WITH_TYPESCRIPT_DOCGEN,
8934
+ TYPESCRIPT_FOR_DOCGEN_PACKAGE,
8935
+ hasTypeScriptCompilerApi
8936
+ } from "storybook/internal/common";
8937
+ import { SupportedRenderer as SupportedRenderer2 } from "storybook/internal/types";
8938
+ var introducedIn3 = "11.0.0", upgradesAcrossPeerChange = ({ beforeVersion, storybookVersion, requested }) => requested || !!beforeVersion && crossesVersionBoundary(beforeVersion, storybookVersion, introducedIn3), typescriptDependency = {
8939
+ id: "typescript-dependency",
8940
+ link: "https://storybook.js.org/docs/configure/integration/typescript",
8941
+ async check(options) {
8942
+ let { mainConfig, packageManager } = options;
8943
+ if (!upgradesAcrossPeerChange(options))
8944
+ return null;
8945
+ let renderer = getRendererName(mainConfig);
8946
+ return !!renderer && RENDERERS_WITH_TYPESCRIPT_DOCGEN.includes(renderer) && !packageManager.isDependencyInstalled("typescript") ? !0 : null;
8947
+ },
8948
+ prompt() {
8949
+ return `Add ${TYPESCRIPT_FOR_DOCGEN_PACKAGE} to devDependencies, so Storybook can read your component types for Controls and the Docs args table`;
8950
+ },
8951
+ async run({ packageManager }) {
8952
+ await packageManager.addDependencies({ type: "devDependencies", skipInstall: !0 }, [
8953
+ TYPESCRIPT_FOR_DOCGEN_PACKAGE
8954
+ ]);
8955
+ }
8956
+ }, typescriptCompilerApi = {
8957
+ id: "typescript-compiler-api",
8958
+ promptType: "notification",
8959
+ link: "https://storybook.js.org/docs/configure/integration/typescript#typescript-7",
8960
+ async check(options) {
8961
+ let { mainConfig, packageManager } = options;
8962
+ if (!upgradesAcrossPeerChange(options))
8963
+ return null;
8964
+ let renderer = getRendererName(mainConfig);
8965
+ if (!renderer || ![...RENDERERS_WITH_TYPESCRIPT_DOCGEN, SupportedRenderer2.ANGULAR].includes(renderer))
8966
+ return null;
8967
+ let version2 = (0, import_semver8.coerce)(await packageManager.getDeclaredVersionSpecifier("typescript"))?.version;
8968
+ return version2 && !hasTypeScriptCompilerApi(version2) ? { version: version2 } : null;
8969
+ },
8970
+ // The upgrade prints the full prompt only when it differs from the one-line hint without a result.
8971
+ prompt(result) {
8972
+ if (!result)
8973
+ return "TypeScript 7 has no compiler API, so Storybook cannot read your component types. Install TypeScript 6 side by side.";
8974
+ let native = `"@typescript/native": "npm:typescript@^${result.version}"`;
8975
+ return `TypeScript 7 has no compiler API, so Storybook cannot read your component types. In package.json, replace the ${import_picocolors17.default.cyan("typescript")} devDependency with ${import_picocolors17.default.cyan(native)} and ${import_picocolors17.default.cyan('"typescript": "npm:@typescript/typescript6@^6.0.2"')}. This is not automigrated.`;
8976
+ }
8977
+ };
8978
+
8936
8979
  // src/automigrate/fixes/upgrade-storybook-related-dependencies.ts
8937
- var import_semver8 = __toESM(require_semver(), 1);
8980
+ var import_semver9 = __toESM(require_semver(), 1);
8938
8981
  import { dirname as dirname4 } from "node:path";
8939
8982
  import { JsPackageManager as JsPackageManager2, isCorePackage, isSatelliteAddon } from "storybook/internal/common";
8940
8983
  import { logger as logger17 } from "storybook/internal/node-logger";
@@ -8969,7 +9012,7 @@ var NON_REGISTRY_SPECIFIER = /^(patch|file|link|portal|git|http|https|workspace)
8969
9012
  };
8970
9013
  })
8971
9014
  )).filter(
8972
- (pkg) => pkg.beforeVersion !== null && pkg.afterVersion !== null && (0, import_semver8.gt)(pkg.afterVersion, pkg.beforeVersion)
9015
+ (pkg) => pkg.beforeVersion !== null && pkg.afterVersion !== null && (0, import_semver9.gt)(pkg.afterVersion, pkg.beforeVersion)
8973
9016
  );
8974
9017
  return upgradable.length > 0 ? { upgradable } : null;
8975
9018
  },
@@ -8988,7 +9031,7 @@ var NON_REGISTRY_SPECIFIER = /^(patch|file|link|portal|git|http|https|workspace)
8988
9031
  };
8989
9032
 
8990
9033
  // src/automigrate/fixes/vitest-setup-file.ts
8991
- var import_picocolors17 = __toESM(require_picocolors(), 1), import_semver9 = __toESM(require_semver(), 1);
9034
+ var import_picocolors18 = __toESM(require_picocolors(), 1), import_semver10 = __toESM(require_semver(), 1);
8992
9035
  import { existsSync as existsSync5 } from "fs";
8993
9036
  import {
8994
9037
  formatExistingFile as formatExistingFile2,
@@ -9028,7 +9071,7 @@ var VITEST_ADDON_NAME = "@storybook/addon-vitest", VITEST_PLUGIN_MODULE = "@stor
9028
9071
  (source) => source.includes(VITEST_PLUGIN_MODULE)
9029
9072
  ) && !addons.some((addon) => addon.includes(VITEST_ADDON_NAME)))
9030
9073
  return null;
9031
- let vitestVersion = await packageManager.getInstalledVersion("vitest"), inheritsRootByDefault = vitestVersion === null ? "unknown" : import_semver9.default.major(vitestVersion) >= 5, candidateSetupFiles = new Set(
9074
+ let vitestVersion = await packageManager.getInstalledVersion("vitest"), inheritsRootByDefault = vitestVersion === null ? "unknown" : import_semver10.default.major(vitestVersion) >= 5, candidateSetupFiles = new Set(
9032
9075
  SETUP_FILE_EXTENSIONS.map(
9033
9076
  (extension) => path3.join(configDir, `vitest.setup${extension}`)
9034
9077
  ).filter((filePath) => existsSync5(filePath))
@@ -9098,14 +9141,14 @@ var VITEST_ADDON_NAME = "@storybook/addon-vitest", VITEST_PLUGIN_MODULE = "@stor
9098
9141
  (setupFile) => setupFile.transform.kind === "empty" ? [setupFile.path] : []
9099
9142
  )
9100
9143
  ), rewritesAny = setupFiles.some((setupFile) => setupFile.transform.kind === "rewritten"), problems = setupFiles.flatMap(
9101
- (setupFile) => setupFile.transform.kind === "manual" ? [`${import_picocolors17.default.cyan(setupFile.path)}: ${setupFile.transform.reason}`] : []
9144
+ (setupFile) => setupFile.transform.kind === "manual" ? [`${import_picocolors18.default.cyan(setupFile.path)}: ${setupFile.transform.reason}`] : []
9102
9145
  );
9103
9146
  for (let entry of unresolvedEntries) {
9104
- let location = `${import_picocolors17.default.cyan(entry.configFile)}: ${import_picocolors17.default.gray(entry.expression)} is computed at runtime`;
9147
+ let location = `${import_picocolors18.default.cyan(entry.configFile)}: ${import_picocolors18.default.gray(entry.expression)} is computed at runtime`;
9105
9148
  deletedPaths.size > 0 ? problems.push(
9106
- `${location}, so the ${import_picocolors17.default.cyan("setupFiles")} it selects can't be matched without executing your config`
9149
+ `${location}, so the ${import_picocolors18.default.cyan("setupFiles")} it selects can't be matched without executing your config`
9107
9150
  ) : rewritesAny && entry.project !== "storybook" && configFiles.includes(entry.configFile) && problems.push(
9108
- `${location} in a Vitest project without the Storybook plugin, so it may select a setup file whose ${import_picocolors17.default.cyan("setProjectAnnotations")} call is still needed there`
9151
+ `${location} in a Vitest project without the Storybook plugin, so it may select a setup file whose ${import_picocolors18.default.cyan("setProjectAnnotations")} call is still needed there`
9109
9152
  );
9110
9153
  }
9111
9154
  if (problems.length > 0)
@@ -9117,12 +9160,12 @@ var VITEST_ADDON_NAME = "@storybook/addon-vitest", VITEST_PLUGIN_MODULE = "@stor
9117
9160
 
9118
9161
  `)}
9119
9162
 
9120
- ${import_picocolors17.default.cyan(VITEST_ADDON_NAME)} applies your project annotations itself: your ${import_picocolors17.default.cyan(".storybook/preview")} file and the previews of the addons registered in ${import_picocolors17.default.cyan(".storybook/main")}. ${import_picocolors17.default.cyan("setProjectAnnotations")} replaces those annotations, so it must not be called from a Vitest setup file. For each file listed above:
9121
- 1. If the call only passes your ${import_picocolors17.default.cyan(".storybook/preview")} annotations, delete the call.
9122
- 2. If it passes an addon's annotations, register that addon in the ${import_picocolors17.default.cyan("addons")} field of ${import_picocolors17.default.cyan(".storybook/main")} and delete the call.
9123
- 3. If it passes custom annotations, move them into ${import_picocolors17.default.cyan(".storybook/preview")} and delete the call.
9124
- 4. If nothing else remains in the file, delete it and remove its entry from ${import_picocolors17.default.cyan("setupFiles")} in your Vitest config.
9125
- 5. If the file is shared with a Vitest project that uses portable stories directly, list it only in that project's ${import_picocolors17.default.cyan("setupFiles")}.
9163
+ ${import_picocolors18.default.cyan(VITEST_ADDON_NAME)} applies your project annotations itself: your ${import_picocolors18.default.cyan(".storybook/preview")} file and the previews of the addons registered in ${import_picocolors18.default.cyan(".storybook/main")}. ${import_picocolors18.default.cyan("setProjectAnnotations")} replaces those annotations, so it must not be called from a Vitest setup file. For each file listed above:
9164
+ 1. If the call only passes your ${import_picocolors18.default.cyan(".storybook/preview")} annotations, delete the call.
9165
+ 2. If it passes an addon's annotations, register that addon in the ${import_picocolors18.default.cyan("addons")} field of ${import_picocolors18.default.cyan(".storybook/main")} and delete the call.
9166
+ 3. If it passes custom annotations, move them into ${import_picocolors18.default.cyan(".storybook/preview")} and delete the call.
9167
+ 4. If nothing else remains in the file, delete it and remove its entry from ${import_picocolors18.default.cyan("setupFiles")} in your Vitest config.
9168
+ 5. If the file is shared with a Vitest project that uses portable stories directly, list it only in that project's ${import_picocolors18.default.cyan("setupFiles")}.
9126
9169
 
9127
9170
  Read more: ${this.link}
9128
9171
  `
@@ -9494,12 +9537,15 @@ var allFixes = [
9494
9537
  csfNextMockedArgs,
9495
9538
  removeExperimentalReview,
9496
9539
  removeChangeDetectionFlag,
9540
+ removeLegacyFeatureFlags,
9497
9541
  skills,
9498
- docgenServer
9542
+ docgenServer,
9543
+ typescriptDependency,
9544
+ typescriptCompilerApi
9499
9545
  ], commandFixes = [csfFactories];
9500
9546
 
9501
9547
  // src/automigrate/helpers/logMigrationSummary.ts
9502
- var import_picocolors18 = __toESM(require_picocolors(), 1);
9548
+ var import_picocolors19 = __toESM(require_picocolors(), 1);
9503
9549
  import { CLI_COLORS as CLI_COLORS2, logger as logger18 } from "storybook/internal/node-logger";
9504
9550
  import { dedent as dedent13 } from "ts-dedent";
9505
9551
  var messageDivider2 = `
@@ -9511,19 +9557,19 @@ var messageDivider2 = `
9511
9557
  `;
9512
9558
  function getGlossaryMessages(fixSummary, fixResults, dryRun) {
9513
9559
  let messages2 = [];
9514
- return fixSummary.succeeded.length > 0 && (messages2.push(import_picocolors18.default.bold("Successful migrations:")), messages2.push(fixSummary.succeeded.map((m) => import_picocolors18.default.green(m)).join(", "))), Object.keys(fixSummary.failed).length > 0 && (messages2.push(import_picocolors18.default.bold("Failed migrations:")), messages2.push(
9515
- Object.entries(fixSummary.failed).map(([id, error]) => `${import_picocolors18.default.bold(import_picocolors18.default.red(id))}:
9560
+ return fixSummary.succeeded.length > 0 && (messages2.push(import_picocolors19.default.bold("Successful migrations:")), messages2.push(fixSummary.succeeded.map((m) => import_picocolors19.default.green(m)).join(", "))), Object.keys(fixSummary.failed).length > 0 && (messages2.push(import_picocolors19.default.bold("Failed migrations:")), messages2.push(
9561
+ Object.entries(fixSummary.failed).map(([id, error]) => `${import_picocolors19.default.bold(import_picocolors19.default.red(id))}:
9516
9562
  ${error}`).join(`
9517
9563
  `)
9518
- )), fixSummary.manual.length > 0 && (messages2.push(import_picocolors18.default.bold("Manual migrations:")), messages2.push(
9564
+ )), fixSummary.manual.length > 0 && (messages2.push(import_picocolors19.default.bold("Manual migrations:")), messages2.push(
9519
9565
  fixSummary.manual.map(
9520
- (m) => fixResults[m] === "manual_succeeded" /* MANUAL_SUCCEEDED */ ? import_picocolors18.default.green(m) : import_picocolors18.default.blue(m)
9566
+ (m) => fixResults[m] === "manual_succeeded" /* MANUAL_SUCCEEDED */ ? import_picocolors19.default.green(m) : import_picocolors19.default.blue(m)
9521
9567
  ).join(", ")
9522
9568
  )), fixSummary.skipped.length > 0 && (messages2.push(
9523
- import_picocolors18.default.bold(
9569
+ import_picocolors19.default.bold(
9524
9570
  dryRun ? "Migrations that a run would apply (dry run, no files changed):" : "Skipped migrations:"
9525
9571
  )
9526
- ), messages2.push(fixSummary.skipped.map((m) => import_picocolors18.default.cyan(m)).join(", "))), messages2;
9572
+ ), messages2.push(fixSummary.skipped.map((m) => import_picocolors19.default.cyan(m)).join(", "))), messages2;
9527
9573
  }
9528
9574
  function logMigrationSummary({
9529
9575
  fixResults,
@@ -9533,7 +9579,7 @@ function logMigrationSummary({
9533
9579
  }) {
9534
9580
  let messages2 = [];
9535
9581
  messages2.push(getGlossaryMessages(fixSummary, fixResults, dryRun).join(messageDivider2)), messages2.push(dedent13`If you'd like to run the migrations again, you can do so by running
9536
- ${import_picocolors18.default.cyan("npx storybook automigrate")}
9582
+ ${import_picocolors19.default.cyan("npx storybook automigrate")}
9537
9583
 
9538
9584
  The automigrations try to migrate common patterns in your project, but might not contain everything needed to migrate to the latest version of Storybook.
9539
9585
 
@@ -9551,7 +9597,7 @@ function logMigrationSummary({
9551
9597
 
9552
9598
  // src/automigrate/index.ts
9553
9599
  var logAvailableMigrations = () => {
9554
- let availableFixes = [...allFixes, ...commandFixes].map((f) => import_picocolors19.default.yellow(f.id)).map((x) => `- ${x}`).join(`
9600
+ let availableFixes = [...allFixes, ...commandFixes].map((f) => import_picocolors20.default.yellow(f.id)).map((x) => `- ${x}`).join(`
9555
9601
  `);
9556
9602
  logger19.log(dedent14`
9557
9603
  The following migrations are available:
@@ -9598,8 +9644,8 @@ var logAvailableMigrations = () => {
9598
9644
  })), outcome && !options.skipDoctor && await doctor({ configDir, packageManager: options.packageManager });
9599
9645
  let failedMigrations = Object.entries(outcome?.fixResults ?? {}).filter(([, status]) => status === "failed" /* FAILED */ || status === "check_failed" /* CHECK_FAILED */).map(([id, status]) => {
9600
9646
  let statusLabel = status === "check_failed" /* CHECK_FAILED */ ? "check failed" : "failed";
9601
- return `${import_picocolors19.default.cyan(id)} (${statusLabel})`;
9602
- }), skippedFiles = [...Map.groupBy(outcome?.fileFailures ?? [], ({ fixId }) => fixId)].filter(([id]) => outcome?.fixResults[id] === "succeeded" /* SUCCEEDED */).map(([id, failures]) => `${import_picocolors19.default.cyan(id)} (${pluralFiles(failures.length)} skipped)`);
9647
+ return `${import_picocolors20.default.cyan(id)} (${statusLabel})`;
9648
+ }), skippedFiles = [...Map.groupBy(outcome?.fileFailures ?? [], ({ fixId }) => fixId)].filter(([id]) => outcome?.fixResults[id] === "succeeded" /* SUCCEEDED */).map(([id, failures]) => `${import_picocolors20.default.cyan(id)} (${pluralFiles(failures.length)} skipped)`);
9603
9649
  if (failedMigrations.length > 0 || skippedFiles.length > 0)
9604
9650
  throw new AutomigrateError({ errors: [...failedMigrations, ...skippedFiles] });
9605
9651
  }, automigrate = async ({
@@ -9625,7 +9671,7 @@ var logAvailableMigrations = () => {
9625
9671
  return logAvailableMigrations(), null;
9626
9672
  let commandFix = commandFixes.find((f) => f.id === fixId);
9627
9673
  if (commandFix)
9628
- return logger19.step(`Running migration ${import_picocolors19.default.magenta(fixId)}..`), await commandFix.run({
9674
+ return logger19.step(`Running migration ${import_picocolors20.default.magenta(fixId)}..`), await commandFix.run({
9629
9675
  mainConfigPath,
9630
9676
  previewConfigPath,
9631
9677
  packageManager,
@@ -9640,7 +9686,7 @@ var logAvailableMigrations = () => {
9640
9686
  }), null;
9641
9687
  let selectedFixes = inputFixes || allFixes.filter((fix) => !(fix.id === upgradeStorybookRelatedDependencies.id && isLatest === !1 && fixId !== upgradeStorybookRelatedDependencies.id)), fixes = fixId ? selectedFixes.filter((f) => f.id === fixId) : selectedFixes;
9642
9688
  if (fixId && fixes.length === 0)
9643
- return logger19.log(`\u{1F4ED} No migrations found for ${import_picocolors19.default.magenta(fixId)}.`), logAvailableMigrations(), null;
9689
+ return logger19.log(`\u{1F4ED} No migrations found for ${import_picocolors20.default.magenta(fixId)}.`), logAvailableMigrations(), null;
9644
9690
  logger19.step("Checking possible migrations..");
9645
9691
  let { fixResults, fixSummary, preCheckFailure, addonsToPostinstall, fileFailures, verified } = await runFixes({
9646
9692
  fixes,
@@ -9694,7 +9740,7 @@ async function runFixes({
9694
9740
  for (let f of fixes) {
9695
9741
  let check;
9696
9742
  try {
9697
- logger19.debug(`Running ${import_picocolors19.default.cyan(f.id)} migration checks`), check = await runCheck(f, {
9743
+ logger19.debug(`Running ${import_picocolors20.default.cyan(f.id)} migration checks`), check = await runCheck(f, {
9698
9744
  packageManager,
9699
9745
  configDir,
9700
9746
  mainConfig,
@@ -9703,9 +9749,9 @@ async function runFixes({
9703
9749
  mainConfigPath,
9704
9750
  storiesPaths,
9705
9751
  requested: fixId === f.id
9706
- }), logger19.debug(`End of ${import_picocolors19.default.cyan(f.id)} migration checks`);
9752
+ }), logger19.debug(`End of ${import_picocolors20.default.cyan(f.id)} migration checks`);
9707
9753
  } catch (error) {
9708
- logger19.warn(`\u26A0\uFE0F failed to check fix ${import_picocolors19.default.bold(f.id)}`), error instanceof Error && (logger19.error(`
9754
+ logger19.warn(`\u26A0\uFE0F failed to check fix ${import_picocolors20.default.bold(f.id)}`), error instanceof Error && (logger19.error(`
9709
9755
  ${error.stack}`), fixSummary.failed[f.id] = error.message), fixResults[f.id] = "check_failed" /* CHECK_FAILED */;
9710
9756
  }
9711
9757
  check?.result ? checked.push(check) : fixResults[f.id] = fixResults[f.id] || "unnecessary" /* UNNECESSARY */;
@@ -9716,7 +9762,7 @@ ${error.stack}`), fixSummary.failed[f.id] = error.message), fixResults[f.id] = "
9716
9762
  let selected = [];
9717
9763
  for (let check of applicable) {
9718
9764
  let { fix: f, result } = check, promptType = typeof f.promptType == "function" ? await f.promptType(result) : f.promptType ?? "auto";
9719
- logger19.log(`\u{1F50E} found a '${import_picocolors19.default.cyan(f.id)}' migration:`);
9765
+ logger19.log(`\u{1F50E} found a '${import_picocolors20.default.cyan(f.id)}' migration:`);
9720
9766
  let getTitle = () => {
9721
9767
  switch (promptType) {
9722
9768
  case "auto":
@@ -9727,7 +9773,7 @@ ${error.stack}`), fixSummary.failed[f.id] = error.message), fixResults[f.id] = "
9727
9773
  return "Migration notification";
9728
9774
  }
9729
9775
  };
9730
- logger19.step(`${getTitle()}: ${import_picocolors19.default.cyan(f.id)}`), logger19.logBox(f.prompt(result));
9776
+ logger19.step(`${getTitle()}: ${import_picocolors20.default.cyan(f.id)}`), logger19.logBox(f.prompt(result));
9731
9777
  let runAnswer;
9732
9778
  try {
9733
9779
  if (dryRun)
@@ -9755,7 +9801,7 @@ ${error.stack}`), fixSummary.failed[f.id] = error.message), fixResults[f.id] = "
9755
9801
  }
9756
9802
  } else promptType === "auto" ? runAnswer = { fix: yes ? !0 : await prompt5.confirm(
9757
9803
  {
9758
- message: `Do you want to run the '${import_picocolors19.default.cyan(f.id)}' migration on your project?`,
9804
+ message: `Do you want to run the '${import_picocolors20.default.cyan(f.id)}' migration on your project?`,
9759
9805
  initialValue: f.defaultSelected ?? !0
9760
9806
  },
9761
9807
  {
@@ -9776,33 +9822,33 @@ ${error.stack}`), fixSummary.failed[f.id] = error.message), fixResults[f.id] = "
9776
9822
  } catch {
9777
9823
  break;
9778
9824
  }
9779
- promptType === "auto" && (invariant(runAnswer, "runAnswer must be defined if not promptOnly"), runAnswer.fix ? selected.push(check) : (fixResults[f.id] = "skipped" /* SKIPPED */, fixSummary.skipped.push(f.id), logger19.log(`Skipped ${import_picocolors19.default.cyan(f.id)} migration`)));
9825
+ promptType === "auto" && (invariant(runAnswer, "runAnswer must be defined if not promptOnly"), runAnswer.fix ? selected.push(check) : (fixResults[f.id] = "skipped" /* SKIPPED */, fixSummary.skipped.push(f.id), logger19.log(`Skipped ${import_picocolors20.default.cyan(f.id)} migration`)));
9780
9826
  }
9781
9827
  if (selected.length === 0)
9782
9828
  return { fixResults, fixSummary, addonsToPostinstall, fileFailures, verified };
9783
9829
  let taskLog = prompt5.taskLog({
9784
9830
  id: "automigrate-run",
9785
- title: selected.length === 1 ? `Running ${import_picocolors19.default.cyan(selected[0].fix.id)} migration` : "Running automigrations"
9831
+ title: selected.length === 1 ? `Running ${import_picocolors20.default.cyan(selected[0].fix.id)} migration` : "Running automigrations"
9786
9832
  }), outcomes = await applyFixes(
9787
9833
  { ...project, skipInstall, yes, addonsToPostinstall },
9788
9834
  selected
9789
9835
  );
9790
9836
  for (let [fixId2, outcome] of outcomes) {
9791
9837
  if (outcome.status === "skipped") {
9792
- fixResults[fixId2] = "skipped" /* SKIPPED */, fixSummary.skipped.push(fixId2), taskLog.message(`Skipped ${import_picocolors19.default.cyan(fixId2)} migration`);
9838
+ fixResults[fixId2] = "skipped" /* SKIPPED */, fixSummary.skipped.push(fixId2), taskLog.message(`Skipped ${import_picocolors20.default.cyan(fixId2)} migration`);
9793
9839
  continue;
9794
9840
  }
9795
9841
  if (fileFailures.push(...outcome.fileFailures.map((failure) => ({ ...failure, fixId: fixId2 }))), outcome.status === "failed")
9796
- fixResults[fixId2] = "failed" /* FAILED */, fixSummary.failed[fixId2] = outcome.error instanceof Error ? outcome.error.message : "Failed to run migration", taskLog.message(`${logger19.SYMBOLS.error} ${import_picocolors19.default.cyan(fixId2)}`);
9842
+ fixResults[fixId2] = "failed" /* FAILED */, fixSummary.failed[fixId2] = outcome.error instanceof Error ? outcome.error.message : "Failed to run migration", taskLog.message(`${logger19.SYMBOLS.error} ${import_picocolors20.default.cyan(fixId2)}`);
9797
9843
  else {
9798
9844
  fixResults[fixId2] = "succeeded" /* SUCCEEDED */, fixSummary.succeeded.push(fixId2);
9799
9845
  let skipped = outcome.fileFailures.length;
9800
9846
  taskLog.message(
9801
- `${logger19.SYMBOLS.success} ${import_picocolors19.default.cyan(fixId2)}${skipped > 0 ? ` (${pluralFiles(skipped)} skipped)` : ""}`
9847
+ `${logger19.SYMBOLS.success} ${import_picocolors20.default.cyan(fixId2)}${skipped > 0 ? ` (${pluralFiles(skipped)} skipped)` : ""}`
9802
9848
  );
9803
9849
  }
9804
9850
  }
9805
- let ran = selected.length === 1 ? `${import_picocolors19.default.cyan(selected[0].fix.id)} migration` : "automigrations";
9851
+ let ran = selected.length === 1 ? `${import_picocolors20.default.cyan(selected[0].fix.id)} migration` : "automigrations";
9806
9852
  return Object.values(fixResults).includes("failed" /* FAILED */) ? taskLog.error(selected.length === 1 ? `Could not run ${ran}` : "Some automigrations failed") : taskLog.success(`Ran ${ran}`), { fixResults, fixSummary, addonsToPostinstall, fileFailures, verified };
9807
9853
  }
9808
9854
 
@@ -9825,6 +9871,10 @@ import { mkdir, readFile as readFile4, writeFile as writeFile4 } from "node:fs/p
9825
9871
  import { basename as basename4, extname as extname3, join as join8 } from "node:path";
9826
9872
  import { executeCommand } from "storybook/internal/common";
9827
9873
  import { logger as logger20 } from "storybook/internal/node-logger";
9874
+ function isYarnBerryVersion(version2) {
9875
+ let major = Number.parseInt(version2, 10);
9876
+ return Number.isInteger(major) && major >= 2;
9877
+ }
9828
9878
  var link = async ({ target, local, start }) => {
9829
9879
  let storybookDir = process.cwd();
9830
9880
  try {
@@ -9847,7 +9897,7 @@ var link = async ({ target, local, start }) => {
9847
9897
  stdio: "pipe",
9848
9898
  shell: !0
9849
9899
  }).stdout.toString();
9850
- if (!/^[2-4]\./.test(version2)) {
9900
+ if (!isYarnBerryVersion(version2)) {
9851
9901
  logger20.warn(`\u{1F6A8} Expected yarn 2 or higher in ${reproDir}!`), logger20.warn(""), logger20.warn("Please set it up with `yarn set version berry`,"), logger20.warn(`then link '${reproDir}' with the '--local' flag.`);
9852
9902
  return;
9853
9903
  }
@@ -9901,7 +9951,7 @@ import {
9901
9951
  versions as versions3
9902
9952
  } from "storybook/internal/common";
9903
9953
  import { logger as logger22, prompt as prompt6 } from "storybook/internal/node-logger";
9904
- var import_picocolors20 = __toESM(require_picocolors(), 1), import_semver10 = __toESM(require_semver(), 1);
9954
+ var import_picocolors21 = __toESM(require_picocolors(), 1), import_semver11 = __toESM(require_semver(), 1);
9905
9955
  import { dedent as dedent15 } from "ts-dedent";
9906
9956
 
9907
9957
  // src/sandbox-templates.ts
@@ -10061,7 +10111,17 @@ var baseTemplates = {
10061
10111
  },
10062
10112
  modifications: {
10063
10113
  useCsfFactory: !0,
10064
- extraDevDependencies: ["prop-types", "@types/prop-types", "@storybook/addon-mcp"],
10114
+ // create-vite >= 9.3.3 scaffolds TypeScript 7.0, which Storybook's TS docgen cannot use
10115
+ // (TS 7.0 has no compiler API; #37004 supports 7.1+). Keep this pin until docgen supports
10116
+ // the TypeScript version that create-vite scaffolds (#36987, #37004). Overwrite the
10117
+ // scaffold's own devDependencies range; pinning via devDependencies avoids a conflicting
10118
+ // duplicate entry.
10119
+ extraDevDependencies: [
10120
+ "prop-types",
10121
+ "@types/prop-types",
10122
+ "@storybook/addon-mcp",
10123
+ "typescript@^6"
10124
+ ],
10065
10125
  editAddons: (addons) => [...addons, "@storybook/addon-mcp"],
10066
10126
  mainConfig: {
10067
10127
  features: {
@@ -10089,7 +10149,13 @@ var baseTemplates = {
10089
10149
  modifications: {
10090
10150
  useCsfFactory: !0,
10091
10151
  extraDependencies: ["react@canary", "react-dom@canary"],
10092
- extraDevDependencies: ["prop-types", "@types/react@latest", "@types/react-dom@latest"],
10152
+ extraDevDependencies: [
10153
+ "prop-types",
10154
+ "@types/react@latest",
10155
+ "@types/react-dom@latest",
10156
+ // See `react-vite/default-ts` for why TypeScript is pinned to 6.
10157
+ "typescript@^6"
10158
+ ],
10093
10159
  resolutions: {
10094
10160
  "@types/react": "npm:@types/react@latest",
10095
10161
  "@types/react-dom": "npm:@types/react-dom@latest",
@@ -10189,6 +10255,18 @@ var baseTemplates = {
10189
10255
  // Re-enable once storybook-solidjs-vite releases a version that works with Storybook 11.
10190
10256
  skipTasks: ["e2e-tests", "e2e-tests-dev", "bench", "vitest-integration", "chromatic"]
10191
10257
  },
10258
+ "astro-vite/default-ts": {
10259
+ name: "Astro Latest (Vite | TypeScript)",
10260
+ script: "npx create-astro@latest {{beforeDir}} --template minimal --no-install --no-git --no-ai --skip-houston --yes",
10261
+ expected: {
10262
+ framework: "@storybook-astro/framework",
10263
+ renderer: "@storybook-astro/renderer",
10264
+ builder: "@storybook/builder-vite"
10265
+ },
10266
+ // TODO: remove `inDevelopment` once the nightly sandbox generation has published this template.
10267
+ inDevelopment: !0,
10268
+ skipTasks: ["e2e-tests", "e2e-tests-dev", "bench", "vitest-integration", "chromatic"]
10269
+ },
10192
10270
  "tanstack-react-router/default-ts": {
10193
10271
  name: "TanStack React Router Latest (Vite | TypeScript)",
10194
10272
  script: "npx @tanstack/cli@latest create {{beforeDir}} --no-install --tailwind --router-only",
@@ -10229,21 +10307,6 @@ var baseTemplates = {
10229
10307
  },
10230
10308
  skipTasks: ["bench"]
10231
10309
  },
10232
- "vue3-vite/default-js": {
10233
- name: "Vue v3 (Vite | JavaScript)",
10234
- script: "npm create vite --yes {{beforeDir}} -- --template vue",
10235
- // vue-component-meta@^3.3.9 pins @vue/language-core; both are inside the age gate.
10236
- minAgeGateExemptions: ["vue-component-meta", "@vue/language-core"],
10237
- expected: {
10238
- framework: "@storybook/vue3-vite",
10239
- renderer: "@storybook/vue3",
10240
- builder: "@storybook/builder-vite"
10241
- },
10242
- modifications: {
10243
- useCsfFactory: !0
10244
- },
10245
- skipTasks: ["e2e-tests", "bench"]
10246
- },
10247
10310
  "vue3-vite/default-ts": {
10248
10311
  name: "Vue v3 (Vite | TypeScript)",
10249
10312
  script: "npm create vite --yes {{beforeDir}} -- --template vue-ts",
@@ -10310,19 +10373,6 @@ var baseTemplates = {
10310
10373
  // },
10311
10374
  // skipTasks: ['e2e-tests', 'bench', 'vitest-integration'],
10312
10375
  // },
10313
- "html-vite/default-js": {
10314
- name: "HTML Latest (Vite | JavaScript)",
10315
- script: 'npm create vite --yes {{beforeDir}} -- --template vanilla && cd {{beforeDir}} && echo "export default {}" > vite.config.js',
10316
- expected: {
10317
- framework: "@storybook/html-vite",
10318
- renderer: "@storybook/html",
10319
- builder: "@storybook/builder-vite"
10320
- },
10321
- skipTasks: ["e2e-tests", "bench"],
10322
- initOptions: {
10323
- type: "html" /* HTML */
10324
- }
10325
- },
10326
10376
  "html-vite/default-ts": {
10327
10377
  name: "HTML Latest (Vite | TypeScript)",
10328
10378
  script: 'npm create vite --yes {{beforeDir}} -- --template vanilla-ts && cd {{beforeDir}} && echo "export default {}" > vite.config.js',
@@ -10352,19 +10402,6 @@ var baseTemplates = {
10352
10402
  type: "html" /* HTML */
10353
10403
  }
10354
10404
  },
10355
- "svelte-vite/default-js": {
10356
- name: "Svelte Latest (Vite | JavaScript)",
10357
- script: "npm create vite --yes {{beforeDir}} -- --template svelte",
10358
- expected: {
10359
- framework: "@storybook/svelte-vite",
10360
- renderer: "@storybook/svelte",
10361
- builder: "@storybook/builder-vite"
10362
- },
10363
- modifications: {
10364
- useCsfFactory: !0
10365
- },
10366
- skipTasks: ["e2e-tests", "bench"]
10367
- },
10368
10405
  "svelte-vite/default-ts": {
10369
10406
  name: "Svelte Latest (Vite | TypeScript)",
10370
10407
  script: "npm create vite --yes {{beforeDir}} -- --template svelte-ts",
@@ -10374,7 +10411,8 @@ var baseTemplates = {
10374
10411
  builder: "@storybook/builder-vite"
10375
10412
  },
10376
10413
  modifications: {
10377
- useCsfFactory: !0
10414
+ useCsfFactory: !0,
10415
+ mainConfig: { features: { componentsManifest: !0 } }
10378
10416
  },
10379
10417
  // Remove smoke-test from the list once https://github.com/storybookjs/storybook/issues/19351 is fixed.
10380
10418
  skipTasks: ["smoke-test", "bench"]
@@ -10401,9 +10439,6 @@ var baseTemplates = {
10401
10439
  // the `^22` major `ng new` uses for the other @angular packages so every @angular/* aligns.
10402
10440
  // Also, Angular 22 needs TypeScript 6 or more recent.
10403
10441
  extraDependencies: ["@angular/forms@^22", "@angular/animations@^22", "typescript@^6"],
10404
- resolutions: {
10405
- webpack: "5.107.2"
10406
- },
10407
10442
  useCsfFactory: !0
10408
10443
  },
10409
10444
  extraCiSteps: {
@@ -10476,32 +10511,6 @@ var baseTemplates = {
10476
10511
  skipTasks: ["bench"],
10477
10512
  initOptions: { builder: "vite" /* VITE */ }
10478
10513
  },
10479
- "lit-vite/default-js": {
10480
- name: "Lit Latest (Vite | JavaScript)",
10481
- script: 'npm create vite --yes {{beforeDir}} -- --template lit && cd {{beforeDir}} && echo "export default {}" > vite.config.js',
10482
- // TODO: remove after oct 21 2026
10483
- minAgeGateExemptions: ["@wc-toolkit/*"],
10484
- expected: {
10485
- framework: "@storybook/web-components-vite",
10486
- renderer: "@storybook/web-components",
10487
- builder: "@storybook/builder-vite"
10488
- },
10489
- modifications: {
10490
- useCsfFactory: !0,
10491
- mainConfig: {
10492
- framework: {
10493
- name: "@storybook/web-components-vite",
10494
- options: {
10495
- customElementsManifest: [
10496
- "../src/stories/renderers/web-components/custom-elements.json"
10497
- ]
10498
- }
10499
- }
10500
- }
10501
- },
10502
- // Remove smoke-test from the list once https://github.com/storybookjs/storybook/issues/19351 is fixed.
10503
- skipTasks: ["smoke-test", "e2e-tests", "bench"]
10504
- },
10505
10514
  "lit-vite/default-ts": {
10506
10515
  name: "Lit Latest (Vite | TypeScript)",
10507
10516
  script: 'npm create vite --yes {{beforeDir}} -- --template lit-ts && cd {{beforeDir}} && echo "export default {}" > vite.config.js',
@@ -10547,9 +10556,9 @@ var baseTemplates = {
10547
10556
  },
10548
10557
  skipTasks: ["e2e-tests", "e2e-tests-dev", "bench", "vitest-integration"]
10549
10558
  },
10550
- "preact-vite/default-js": {
10551
- name: "Preact Latest (Vite | JavaScript)",
10552
- script: "npm create vite --yes {{beforeDir}} -- --template preact",
10559
+ "preact-vite/default-ts": {
10560
+ name: "Preact Latest (Vite | TypeScript)",
10561
+ script: "npm create vite --yes {{beforeDir}} -- --template preact-ts",
10553
10562
  preferNoLink: !0,
10554
10563
  expected: {
10555
10564
  framework: "@storybook/preact-vite",
@@ -10565,8 +10574,8 @@ var baseTemplates = {
10565
10574
  },
10566
10575
  skipTasks: ["e2e-tests", "bench"]
10567
10576
  },
10568
- "preact-vite/default-ts": {
10569
- name: "Preact Latest (Vite | TypeScript)",
10577
+ "preact-vite/10-ts": {
10578
+ name: "Preact v10 (Vite | TypeScript)",
10570
10579
  script: "npm create vite --yes {{beforeDir}} -- --template preact-ts",
10571
10580
  preferNoLink: !0,
10572
10581
  expected: {
@@ -10575,10 +10584,9 @@ var baseTemplates = {
10575
10584
  builder: "@storybook/builder-vite"
10576
10585
  },
10577
10586
  modifications: {
10578
- // create-vite still scaffolds Preact 10.
10579
- extraDependencies: ["preact-render-to-string", "preact@^11"],
10587
+ extraDependencies: ["preact-render-to-string", "preact@^10"],
10580
10588
  resolutions: {
10581
- preact: "npm:preact@^11"
10589
+ preact: "npm:preact@^10"
10582
10590
  }
10583
10591
  },
10584
10592
  skipTasks: ["e2e-tests", "bench"]
@@ -10597,26 +10605,6 @@ var baseTemplates = {
10597
10605
  // // TODO: The community template does not provide standard stories, which is required for e2e tests.
10598
10606
  // skipTasks: ['e2e-tests-dev', 'e2e-tests', 'bench', 'vitest-integration', 'chromatic'],
10599
10607
  // },
10600
- "ember/3-js": {
10601
- name: "Ember v3 (Webpack | JavaScript)",
10602
- script: "npx --package ember-cli@3.28.1 ember new {{beforeDir}} --skip-install",
10603
- inDevelopment: !0,
10604
- expected: {
10605
- framework: "@storybook/ember",
10606
- renderer: "@storybook/ember",
10607
- builder: "@storybook/builder-webpack5"
10608
- }
10609
- },
10610
- "ember/default-js": {
10611
- name: "Ember v4 (Webpack | JavaScript)",
10612
- script: "npx --package ember-cli@4.12.1 ember new {{beforeDir}} --yarn && cd {{beforeDir}} && yarn add --dev @storybook/ember-cli-storybook && yarn build",
10613
- inDevelopment: !0,
10614
- expected: {
10615
- framework: "@storybook/ember",
10616
- renderer: "@storybook/ember",
10617
- builder: "@storybook/builder-webpack5"
10618
- }
10619
- },
10620
10608
  "react-native-web-vite/expo-ts": {
10621
10609
  // NOTE: create-expo-app installs React 18.2.0. But yarn portal
10622
10610
  // expects 18.3.1 (dunno why). Therefore to run this in dev you
@@ -10628,19 +10616,6 @@ var baseTemplates = {
10628
10616
  // yarn portals.
10629
10617
  name: "React Native Expo Latest (Vite | TypeScript)",
10630
10618
  script: "npx create-expo-app -y --no-install {{beforeDir}}",
10631
- // create-expo-app pins the current SDK, whose packages are released
10632
- // together and are routinely younger than the gate window.
10633
- // `babel-preset-expo` is part of that set despite not matching `expo-*`.
10634
- // `multitars` is pulled in transitively by the Expo CLI toolchain.
10635
- minAgeGateExemptions: [
10636
- "expo",
10637
- "expo-*",
10638
- "@expo/*",
10639
- "babel-preset-expo",
10640
- "multitars",
10641
- "react-native",
10642
- "@react-native/*"
10643
- ],
10644
10619
  expected: {
10645
10620
  framework: "@storybook/react-native-web-vite",
10646
10621
  renderer: "@storybook/react",
@@ -10738,7 +10713,10 @@ var baseTemplates = {
10738
10713
  isInternal: !0,
10739
10714
  modifications: {
10740
10715
  skipTemplateStories: !0,
10741
- skipMocking: !0
10716
+ skipMocking: !0,
10717
+ // This modifications block replaces the base template's, so the pin must be repeated here.
10718
+ // See `react-vite/default-ts` for why TypeScript is pinned to 6.
10719
+ extraDevDependencies: ["typescript@^6"]
10742
10720
  },
10743
10721
  skipTasks: ["e2e-tests", "e2e-tests-dev", "chromatic", "vitest-integration"],
10744
10722
  typeCheck: !1
@@ -10760,7 +10738,10 @@ var baseTemplates = {
10760
10738
  modifications: {
10761
10739
  skipTemplateStories: !0,
10762
10740
  disableDocs: !0,
10763
- skipMocking: !0
10741
+ skipMocking: !0,
10742
+ // This modifications block replaces the base template's, so the pin must be repeated here.
10743
+ // See `react-vite/default-ts` for why TypeScript is pinned to 6.
10744
+ extraDevDependencies: ["typescript@^6"]
10764
10745
  },
10765
10746
  skipTasks: ["e2e-tests", "e2e-tests-dev", "chromatic", "vitest-integration"],
10766
10747
  typeCheck: !1
@@ -10772,7 +10753,10 @@ var baseTemplates = {
10772
10753
  modifications: {
10773
10754
  skipTemplateStories: !0,
10774
10755
  testBuild: !0,
10775
- skipMocking: !0
10756
+ skipMocking: !0,
10757
+ // This modifications block replaces the base template's, so the pin must be repeated here.
10758
+ // See `react-vite/default-ts` for why TypeScript is pinned to 6.
10759
+ extraDevDependencies: ["typescript@^6"]
10776
10760
  },
10777
10761
  skipTasks: ["e2e-tests", "e2e-tests-dev", "vitest-integration"],
10778
10762
  typeCheck: !1
@@ -10808,7 +10792,6 @@ var baseTemplates = {
10808
10792
  "bench/react-vite-default-ts-nodocs",
10809
10793
  "bench/react-vite-default-ts-test-build",
10810
10794
  "bench/react-webpack-18-ts-test-build",
10811
- // 'ember/default-js',
10812
10795
  // Disabled in CI: the published storybook-builder-rsbuild imports `babelParser` from
10813
10796
  // `storybook/internal/mocking-utils`, which Storybook 11 removed, so the sandbox cannot be
10814
10797
  // created. Fix: https://github.com/rstackjs/storybook-rsbuild/pull/603
@@ -10816,33 +10799,28 @@ var baseTemplates = {
10816
10799
  // 'react-rsbuild/default-ts',
10817
10800
  "tanstack-react-router/default-ts",
10818
10801
  "tanstack-react-start/default-ts"
10819
- ], merged = [
10802
+ ], daily = [
10820
10803
  ...normal,
10821
10804
  "react-webpack/18-ts",
10822
10805
  "nextjs/15-ts",
10823
10806
  "nextjs-vite/15-ts",
10824
10807
  "preact-vite/default-ts",
10825
10808
  "html-vite/default-ts",
10826
- "solid-vite/default-ts"
10809
+ "solid-vite/default-ts",
10810
+ "astro-vite/default-ts",
10827
10811
  // Disabled in CI: the published storybook-builder-rsbuild imports `babelParser` from
10828
10812
  // `storybook/internal/mocking-utils`, which Storybook 11 removed, so the sandbox cannot be
10829
10813
  // created. Fix: https://github.com/rstackjs/storybook-rsbuild/pull/603
10830
10814
  // Re-enable once storybook-builder-rsbuild releases a version that works with Storybook 11.
10831
10815
  // 'vue3-rsbuild/default-ts',
10832
- ], daily = [
10833
- ...merged,
10834
10816
  "angular-vite/21-ts",
10835
10817
  "react-vite/default-js",
10836
10818
  "react-vite/prerelease-ts",
10837
10819
  "react-webpack/prerelease-ts",
10838
- "vue3-vite/default-js",
10839
10820
  "vue3-vite/prerelease-ts",
10840
- "lit-vite/default-js",
10841
- "svelte-vite/default-js",
10842
10821
  "nextjs/prerelease",
10843
10822
  // 'qwik-vite/default-ts',
10844
- "preact-vite/default-js",
10845
- "html-vite/default-js",
10823
+ "preact-vite/10-ts",
10846
10824
  "internal/react18-webpack-babel",
10847
10825
  "react-native-web-vite/expo-ts"
10848
10826
  // Disabled in CI: the published storybook-builder-rsbuild imports `babelParser` from
@@ -10863,19 +10841,19 @@ var toChoices = (c) => ({ label: allTemplates[c].name, value: c }), sandbox = as
10863
10841
  }) => {
10864
10842
  let selectedConfig = allTemplates[filterValue], templateId = selectedConfig ? filterValue : null, packageManager = JsPackageManagerFactory.getPackageManager({
10865
10843
  force: PackageManagerName.NPM
10866
- }), latestVersion = await packageManager.latestVersion("storybook"), nextVersion = await packageManager.latestVersion("storybook@next") ?? "0.0.0", currentVersion = versions3.storybook, isPrerelease = (0, import_semver10.prerelease)(currentVersion), isOutdated = (0, import_semver10.lt)(currentVersion, isPrerelease ? nextVersion : latestVersion), downloadType = !isOutdated && init ? "after-storybook" : "before-storybook", branch = isPrerelease ? "next" : "main", messages2 = {
10867
- welcome: `Creating a Storybook ${import_picocolors20.default.bold(currentVersion)} sandbox..`,
10868
- notLatest: import_picocolors20.default.red(dedent15`
10869
- This version is behind the latest release, which is: ${import_picocolors20.default.bold(latestVersion)}!
10844
+ }), latestVersion = await packageManager.latestVersion("storybook"), nextVersion = await packageManager.latestVersion("storybook@next") ?? "0.0.0", currentVersion = versions3.storybook, isPrerelease = (0, import_semver11.prerelease)(currentVersion), isOutdated = (0, import_semver11.lt)(currentVersion, isPrerelease ? nextVersion : latestVersion), downloadType = !isOutdated && init ? "after-storybook" : "before-storybook", branch = isPrerelease ? "next" : "main", messages2 = {
10845
+ welcome: `Creating a Storybook ${import_picocolors21.default.bold(currentVersion)} sandbox..`,
10846
+ notLatest: import_picocolors21.default.red(dedent15`
10847
+ This version is behind the latest release, which is: ${import_picocolors21.default.bold(latestVersion)}!
10870
10848
  You likely ran the init command through npx, which can use a locally cached version, to get the latest please run:
10871
- ${import_picocolors20.default.bold("npx storybook@latest sandbox")}
10849
+ ${import_picocolors21.default.bold("npx storybook@latest sandbox")}
10872
10850
 
10873
10851
  You may want to CTRL+C to stop, and run with the latest version instead.
10874
10852
  `),
10875
- longInitTime: import_picocolors20.default.yellow(
10853
+ longInitTime: import_picocolors21.default.yellow(
10876
10854
  "The creation of the sandbox will take longer, because we will need to run init."
10877
10855
  ),
10878
- prerelease: import_picocolors20.default.yellow("This is a pre-release version.")
10856
+ prerelease: import_picocolors21.default.yellow("This is a pre-release version.")
10879
10857
  };
10880
10858
  if (logger22.logBox(
10881
10859
  [messages2.welcome].concat(isOutdated && !isPrerelease ? [messages2.notLatest] : []).concat(init && (isOutdated || isPrerelease) ? [messages2.longInitTime] : []).concat(isPrerelease ? [messages2.prerelease] : []).join(`
@@ -10892,20 +10870,20 @@ var toChoices = (c) => ({ label: allTemplates[c].name, value: c }), sandbox = as
10892
10870
  dedent15`
10893
10871
  🔎 You filtered out all templates. 🔍
10894
10872
 
10895
- After filtering all the templates with "${import_picocolors20.default.yellow(
10873
+ After filtering all the templates with "${import_picocolors21.default.yellow(
10896
10874
  filterValue
10897
10875
  )}", we found no results. Please try again with a different filter.
10898
10876
 
10899
10877
  Available templates:
10900
- ${keys.map((key) => import_picocolors20.default.blue(`- ${key}`)).join(`
10878
+ ${keys.map((key) => import_picocolors21.default.blue(`- ${key}`)).join(`
10901
10879
  `)}
10902
10880
  `.trim(),
10903
10881
  { borderStyle: "round", padding: 1, borderColor: "#F1618C" }
10904
10882
  ), process.exit(1)), choices.length === 1 ? [templateId] = choices : (logger22.logBox(
10905
10883
  dedent15`
10906
- 🤗 Welcome to ${import_picocolors20.default.yellow("sb sandbox")}! 🤗
10884
+ 🤗 Welcome to ${import_picocolors21.default.yellow("sb sandbox")}! 🤗
10907
10885
 
10908
- Create a ${import_picocolors20.default.green("new project")} to minimally reproduce Storybook issues.
10886
+ Create a ${import_picocolors21.default.green("new project")} to minimally reproduce Storybook issues.
10909
10887
 
10910
10888
  1. select an environment that most closely matches your project setup.
10911
10889
  2. select a location for the reproduction, outside of your project.
@@ -10935,15 +10913,15 @@ var toChoices = (c) => ({ label: allTemplates[c].name, value: c }), sandbox = as
10935
10913
  )), invariant(selectedDirectory);
10936
10914
  try {
10937
10915
  let templateDestination = isAbsolute3(selectedDirectory) ? selectedDirectory : join4(process.cwd(), selectedDirectory);
10938
- logger22.log(`\u{1F3C3} Adding ${selectedConfig.name} into ${templateDestination}`), logger22.log(`\u{1F4E6} Downloading sandbox template (${import_picocolors20.default.bold(downloadType)})...`);
10916
+ logger22.log(`\u{1F3C3} Adding ${selectedConfig.name} into ${templateDestination}`), logger22.log(`\u{1F4E6} Downloading sandbox template (${import_picocolors21.default.bold(downloadType)})...`);
10939
10917
  try {
10940
10918
  let gitPath = `storybookjs/sandboxes/tree/${branch}/${templateId}/${downloadType}`;
10941
10919
  if (await mkdir2(templateDestination, { recursive: !0 }), (0, import_cross_spawn2.sync)("npx", ["gitpick@4.12.4", gitPath, templateDestination, "-o"], {
10942
10920
  stdio: "inherit"
10943
10921
  }), (await readdir(templateDestination)).length === 0) {
10944
- let selected = import_picocolors20.default.yellow(templateId);
10922
+ let selected = import_picocolors21.default.yellow(templateId);
10945
10923
  throw new Error(dedent15`
10946
- Template downloaded from ${import_picocolors20.default.blue(gitPath)} is empty.
10924
+ Template downloaded from ${import_picocolors21.default.blue(gitPath)} is empty.
10947
10925
  Are you use it exists? Or did you want to set ${selected} to inDevelopment first?
10948
10926
  `);
10949
10927
  }
@@ -10961,20 +10939,20 @@ var toChoices = (c) => ({ label: allTemplates[c].name, value: c }), sandbox = as
10961
10939
  } catch (err) {
10962
10940
  throw logger22.error(`\u{1F6A8} Failed to download sandbox template: ${String(err)}`), err;
10963
10941
  }
10964
- let initMessage = init ? import_picocolors20.default.yellow(dedent15`
10942
+ let initMessage = init ? import_picocolors21.default.yellow(dedent15`
10965
10943
  yarn install
10966
10944
  yarn storybook
10967
- `) : `Recreate your setup, then ${import_picocolors20.default.yellow("npx storybook@latest init")}`;
10945
+ `) : `Recreate your setup, then ${import_picocolors21.default.yellow("npx storybook@latest init")}`;
10968
10946
  logger22.logBox(
10969
10947
  dedent15`
10970
10948
  🎉 Your Storybook reproduction project is ready to use! 🎉
10971
10949
 
10972
- ${import_picocolors20.default.yellow(`cd ${selectedDirectory}`)}
10950
+ ${import_picocolors21.default.yellow(`cd ${selectedDirectory}`)}
10973
10951
  ${initMessage}
10974
10952
 
10975
10953
  Once you've recreated the problem you're experiencing, please:
10976
10954
 
10977
- 1. Document any additional steps in ${import_picocolors20.default.cyan("README.md")}
10955
+ 1. Document any additional steps in ${import_picocolors21.default.cyan("README.md")}
10978
10956
  2. Publish the repository to github
10979
10957
  3. Link to the repro repository in your issue
10980
10958
 
@@ -10994,7 +10972,7 @@ async function promptSelectedTemplate(choices) {
10994
10972
  }
10995
10973
 
10996
10974
  // src/upgrade.ts
10997
- var import_cross_spawn3 = __toESM(require_cross_spawn(), 1), import_picocolors21 = __toESM(require_picocolors(), 1), import_semver11 = __toESM(require_semver(), 1);
10975
+ var import_cross_spawn3 = __toESM(require_cross_spawn(), 1), import_picocolors22 = __toESM(require_picocolors(), 1), import_semver12 = __toESM(require_semver(), 1);
10998
10976
  import {
10999
10977
  hasStorybookSkills as hasStorybookSkills2,
11000
10978
  installSkills as installSkills2,
@@ -11006,6 +10984,7 @@ import {
11006
10984
  JsPackageManagerFactory as JsPackageManagerFactory2,
11007
10985
  isCI as isCI3,
11008
10986
  isCorePackage as isCorePackage2,
10987
+ isNpmPeerResolutionError,
11009
10988
  resolveStorybookVersionSpecifier,
11010
10989
  getProcessAncestry
11011
10990
  } from "storybook/internal/common";
@@ -11361,7 +11340,7 @@ ${projectList}`);
11361
11340
  }
11362
11341
  } else
11363
11342
  Object.values(doctorResults).every((result) => result.status === "healthy") ? logger24.step(`${CLI_COLORS4.success("Your project(s) have been upgraded successfully! \u{1F389}")}`) : logger24.step(
11364
- `${import_picocolors21.default.yellow("Your project(s) have been upgraded successfully, but some issues were found which need your attention, please check Storybook doctor logs above.")}`
11343
+ `${import_picocolors22.default.yellow("Your project(s) have been upgraded successfully, but some issues were found which need your attention, please check Storybook doctor logs above.")}`
11365
11344
  );
11366
11345
  let automigrationLinks = detectedAutomigrations.filter(
11367
11346
  (am) => Object.entries(projectResults).some(
@@ -11421,9 +11400,9 @@ async function upgrade(options) {
11421
11400
  return;
11422
11401
  let { allProjects, selectedProjects: storybookProjects } = projectsResult;
11423
11402
  storybookProjects.length > 1 ? logger24.info(`Upgrading the following projects:
11424
- ${storybookProjects.map((p) => `${import_picocolors21.default.cyan(shortenPath(p.configDir))}: ${import_picocolors21.default.bold(p.beforeVersion)} -> ${import_picocolors21.default.bold(p.currentCLIVersion)}`).join(`
11403
+ ${storybookProjects.map((p) => `${import_picocolors22.default.cyan(shortenPath(p.configDir))}: ${import_picocolors22.default.bold(p.beforeVersion)} -> ${import_picocolors22.default.bold(p.currentCLIVersion)}`).join(`
11425
11404
  `)}`) : logger24.info(
11426
- `Upgrading from ${import_picocolors21.default.bold(storybookProjects[0].beforeVersion)} to ${import_picocolors21.default.bold(storybookProjects[0].currentCLIVersion)}`
11405
+ `Upgrading from ${import_picocolors22.default.bold(storybookProjects[0].beforeVersion)} to ${import_picocolors22.default.bold(storybookProjects[0].currentCLIVersion)}`
11427
11406
  );
11428
11407
  let automigrationResults = {}, doctorResults = {}, handleInterruption = async () => {
11429
11408
  throw logger24.log(`
@@ -11443,7 +11422,7 @@ Upgrade interrupted by user.`), allProjects.length > 1 && await sendMultiUpgrade
11443
11422
  }))
11444
11423
  throw new HandledError5("Blockers detected");
11445
11424
  if (storybookProjects.some((project) => {
11446
- if (!project.isCanary && (0, import_semver11.lt)(project.currentCLIVersion, project.beforeVersion))
11425
+ if (!project.isCanary && (0, import_semver12.lt)(project.currentCLIVersion, project.beforeVersion))
11447
11426
  throw new UpgradeStorybookToLowerVersionError({
11448
11427
  beforeVersion: project.beforeVersion,
11449
11428
  currentVersion: project.currentCLIVersion
@@ -11496,12 +11475,18 @@ Upgrade interrupted by user.`), allProjects.length > 1 && await sendMultiUpgrade
11496
11475
  options
11497
11476
  );
11498
11477
  let rootPackageManager = storybookProjects.length > 1 ? JsPackageManagerFactory2.getPackageManager({ force: options.packageManager }) : storybookProjects[0].packageManager;
11499
- if (rootPackageManager.type === "npm" ? await rootPackageManager.installDependencies({ force: !0 }) : await rootPackageManager.installDependencies(), rootPackageManager.type !== PackageManagerName2.YARN1 && rootPackageManager.isStorybookInMonorepo() && (logger24.warn(
11478
+ if (await withNpmForceFallback(
11479
+ rootPackageManager,
11480
+ (installOptions) => rootPackageManager.installDependencies(installOptions)
11481
+ ), rootPackageManager.type !== PackageManagerName2.YARN1 && rootPackageManager.isStorybookInMonorepo() && (logger24.warn(
11500
11482
  "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."
11501
11483
  ), options.yes || await prompt8.confirm({
11502
11484
  message: `Execute ${rootPackageManager.getRunCommand("dedupe")}?`,
11503
11485
  initialValue: !0
11504
- }) ? rootPackageManager.type === "npm" ? await rootPackageManager.dedupeDependencies({ force: !0 }) : await rootPackageManager.dedupeDependencies() : logger24.log(
11486
+ }) ? await withNpmForceFallback(
11487
+ rootPackageManager,
11488
+ (dedupeOptions) => rootPackageManager.dedupeDependencies(dedupeOptions)
11489
+ ) : logger24.log(
11505
11490
  `If you find any issues running Storybook, you can run ${rootPackageManager.getRunCommand("dedupe")} manually to deduplicate your dependencies and try again.`
11506
11491
  )), !options.dryRun && !options.skipInstall)
11507
11492
  for (let project of storybookProjects) {
@@ -11569,6 +11554,19 @@ Upgrade interrupted by user.`), allProjects.length > 1 && await sendMultiUpgrade
11569
11554
  process.removeListener("SIGINT", handleInterruption), process.removeListener("SIGTERM", handleInterruption);
11570
11555
  }
11571
11556
  }
11557
+ var withNpmForceFallback = async (packageManager, operation) => {
11558
+ try {
11559
+ await operation();
11560
+ } catch (error) {
11561
+ if (error instanceof HandledError5 || packageManager.type !== PackageManagerName2.NPM || !isNpmPeerResolutionError(error))
11562
+ throw error;
11563
+ try {
11564
+ logger24.warn("Peer dependency conflict detected; retrying with --legacy-peer-deps"), await operation({ legacyPeerDeps: !0 });
11565
+ } catch {
11566
+ logger24.warn("Retry with --legacy-peer-deps failed; retrying with --force"), await operation({ force: !0 });
11567
+ }
11568
+ }
11569
+ };
11572
11570
 
11573
11571
  // src/bin/run.ts
11574
11572
  addToGlobalContext("cliVersion", versions4.storybook);
@@ -11606,7 +11604,10 @@ var handleCommandFailure = (logFilePath) => async (error) => {
11606
11604
  logger25.outro(CLI_COLORS5.success("Done!"));
11607
11605
  }
11608
11606
  });
11609
- command("init").description("Initialize Storybook into your project").option("-f --force", "Force add Storybook").option("-s --skip-install", "Skip installing deps").addOption(
11607
+ command("init").description("Initialize Storybook into your project").option("-f --force", "Force add Storybook").option("-s --skip-install", "Skip installing deps").option(
11608
+ "--install-typescript",
11609
+ "Add TypeScript, which docgen needs, when the project has none, without asking"
11610
+ ).option("--no-install-typescript", "Do not add TypeScript when the project has none").addOption(
11610
11611
  new Option("--package-manager <type>", "Force package manager for installing deps").choices(
11611
11612
  Object.values(PackageManagerName3)
11612
11613
  )
@@ -11671,7 +11672,7 @@ command("upgrade").description(`Upgrade your Storybook packages to v${versions4.
11671
11672
  ).catch(handleCommandFailure(options.logfile));
11672
11673
  });
11673
11674
  command("info").description("Prints debugging information about the local environment").action(async () => {
11674
- logger25.log(import_picocolors22.default.bold(`
11675
+ logger25.log(import_picocolors23.default.bold(`
11675
11676
  Storybook Environment Info:`));
11676
11677
  let activePackageManager = JsPackageManagerFactory3.getPackageManager().type.replace(/\d/, ""), output = await import_envinfo.default.run({
11677
11678
  System: ["OS", "CPU", "Shell"],
@@ -11683,7 +11684,7 @@ Storybook Environment Info:`));
11683
11684
  logger25.log(
11684
11685
  output.replace(
11685
11686
  activePackageManagerLine,
11686
- import_picocolors22.default.bold(`${activePackageManagerLine} <----- active`)
11687
+ import_picocolors23.default.bold(`${activePackageManagerLine} <----- active`)
11687
11688
  )
11688
11689
  );
11689
11690
  });
@@ -11723,10 +11724,10 @@ command("doctor").description("Check Storybook for known problems and provide su
11723
11724
  }).catch(handleCommandFailure(options.logfile));
11724
11725
  });
11725
11726
  program.on("command:*", ([invalidCmd]) => {
11726
- let errorMessage = ` Invalid command: ${import_picocolors22.default.bold(invalidCmd)}.
11727
+ let errorMessage = ` Invalid command: ${import_picocolors23.default.bold(invalidCmd)}.
11727
11728
  See --help for a list of available commands.`, suggestion = program.commands.map((cmd) => cmd.name()).find((cmd) => leven(cmd, invalidCmd) < 3);
11728
11729
  suggestion && (errorMessage += `
11729
- Did you mean ${import_picocolors22.default.yellow(suggestion)}?`), logger25.error(errorMessage), process.exit(1);
11730
+ Did you mean ${import_picocolors23.default.yellow(suggestion)}?`), logger25.error(errorMessage), process.exit(1);
11730
11731
  });
11731
11732
  program.usage("<command> [options]").version(String(version));
11732
11733
  var run = (argv = process.argv) => program.parseAsync(argv);