@storybook/cli 11.0.0-alpha.6 → 11.0.0-alpha.7

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-WKHHADM4.js → block-create-react-app-JZMA2YOZ.js} +8 -8
  2. package/dist/_node-chunks/{block-dependencies-versions-27KW67SX.js → block-dependencies-versions-DK7SMZVB.js} +21 -12
  3. package/dist/_node-chunks/{block-experimental-addon-test-N7KCMWRE.js → block-experimental-addon-test-OHELLNGW.js} +9 -9
  4. package/dist/_node-chunks/{block-major-version-J6AVFJZW.js → block-major-version-TLNUEUXK.js} +9 -9
  5. package/dist/_node-chunks/{block-node-version-C2L5XHUW.js → block-node-version-XGQ3ERJM.js} +8 -8
  6. package/dist/_node-chunks/{block-react-legacy-root-api-ICQ6ZL4I.js → block-react-legacy-root-api-4X7CYH5Z.js} +8 -8
  7. package/dist/_node-chunks/{block-webpack5-frameworks-FIWTCLDF.js → block-webpack5-frameworks-CEUKFXUN.js} +11 -11
  8. package/dist/_node-chunks/{chunk-TN7W2H4Z.js → chunk-CDHABZNR.js} +25 -23
  9. package/dist/_node-chunks/chunk-DDSAGSQ7.js +11 -0
  10. package/dist/_node-chunks/{chunk-FWESDDOE.js → chunk-FBYVJBVM.js} +6 -6
  11. package/dist/_node-chunks/{chunk-XI7I7UPG.js → chunk-JBUBLTQC.js} +7 -7
  12. package/dist/_node-chunks/{chunk-ZSKFJUTC.js → chunk-XSI7LGHC.js} +7 -7
  13. package/dist/_node-chunks/{globby-QGVHATI2.js → globby-CUVQMT7O.js} +8 -8
  14. package/dist/_node-chunks/{p-limit-TRSAPTRX.js → p-limit-L37OAZTF.js} +7 -7
  15. package/dist/_node-chunks/{run-CCGS4PIS.js → run-2YDTDDJT.js} +416 -193
  16. package/dist/bin/index.js +7 -7
  17. package/package.json +5 -5
  18. package/dist/_node-chunks/chunk-4ENQP5RB.js +0 -11
@@ -1,10 +1,10 @@
1
- import CJS_COMPAT_NODE_URL_vxh3qha62y from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_vxh3qha62y from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_vxh3qha62y from "node:module";
1
+ import CJS_COMPAT_NODE_URL_zn481lvwxa from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_zn481lvwxa from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_zn481lvwxa from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_vxh3qha62y.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_vxh3qha62y.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_vxh3qha62y.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_zn481lvwxa.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_zn481lvwxa.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_zn481lvwxa.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-TN7W2H4Z.js";
23
+ } from "./chunk-CDHABZNR.js";
24
24
  import {
25
25
  slash
26
- } from "./chunk-ZSKFJUTC.js";
26
+ } from "./chunk-XSI7LGHC.js";
27
27
  import {
28
28
  require_semver
29
- } from "./chunk-XI7I7UPG.js";
29
+ } from "./chunk-JBUBLTQC.js";
30
30
  import {
31
31
  __commonJS,
32
32
  __require,
33
33
  __toESM
34
- } from "./chunk-FWESDDOE.js";
34
+ } from "./chunk-FBYVJBVM.js";
35
35
 
36
36
  // ../../../node_modules/envinfo/dist/envinfo.js
37
37
  var require_envinfo = __commonJS({
@@ -4517,7 +4517,7 @@ var require_resolveCommand = __commonJS({
4517
4517
  "use strict";
4518
4518
  var path4 = __require("path"), which = require_which(), getPathKey = require_path_key();
4519
4519
  function resolveCommandAttempt(parsed, withoutPathExt) {
4520
- let env = parsed.options.env || process.env, cwd2 = process.cwd(), hasCustomCwd = parsed.options.cwd != null, shouldSwitchCwd = hasCustomCwd && process.chdir !== void 0 && !process.chdir.disabled;
4520
+ let env = parsed.options.env || process.env, cwd3 = process.cwd(), hasCustomCwd = parsed.options.cwd != null, shouldSwitchCwd = hasCustomCwd && process.chdir !== void 0 && !process.chdir.disabled;
4521
4521
  if (shouldSwitchCwd)
4522
4522
  try {
4523
4523
  process.chdir(parsed.options.cwd);
@@ -4531,7 +4531,7 @@ var require_resolveCommand = __commonJS({
4531
4531
  });
4532
4532
  } catch {
4533
4533
  } finally {
4534
- shouldSwitchCwd && process.chdir(cwd2);
4534
+ shouldSwitchCwd && process.chdir(cwd3);
4535
4535
  }
4536
4536
  return resolved && (resolved = path4.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved)), resolved;
4537
4537
  }
@@ -4755,7 +4755,7 @@ function leven(first, second, options) {
4755
4755
  var import_picocolors22 = __toESM(require_picocolors(), 1);
4756
4756
 
4757
4757
  // package.json
4758
- var version = "11.0.0-alpha.6";
4758
+ var version = "11.0.0-alpha.7";
4759
4759
 
4760
4760
  // src/add.ts
4761
4761
  var import_semver2 = __toESM(require_semver(), 1);
@@ -4902,6 +4902,103 @@ var isWindows = process.platform === "win32", globalCache = globalThis.__EXSOLVE
4902
4902
 
4903
4903
  // ../../core/src/shared/utils/module.ts
4904
4904
  var import_semver = __toESM(require_semver(), 1);
4905
+
4906
+ // ../../core/node_modules/pathe/dist/shared/pathe.ff20891b.mjs
4907
+ var _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
4908
+ function normalizeWindowsPath(input = "") {
4909
+ return input && input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
4910
+ }
4911
+ var _UNC_REGEX = /^[/\\]{2}/, _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/, _DRIVE_LETTER_RE = /^[A-Za-z]:$/, _ROOT_FOLDER_RE = /^\/([A-Za-z]:)?$/;
4912
+ var normalize = function(path4) {
4913
+ if (path4.length === 0)
4914
+ return ".";
4915
+ path4 = normalizeWindowsPath(path4);
4916
+ let isUNCPath = path4.match(_UNC_REGEX), isPathAbsolute = isAbsolute(path4), trailingSeparator = path4[path4.length - 1] === "/";
4917
+ return path4 = normalizeString(path4, !isPathAbsolute), path4.length === 0 ? isPathAbsolute ? "/" : trailingSeparator ? "./" : "." : (trailingSeparator && (path4 += "/"), _DRIVE_LETTER_RE.test(path4) && (path4 += "/"), isUNCPath ? isPathAbsolute ? `//${path4}` : `//./${path4}` : isPathAbsolute && !isAbsolute(path4) ? `/${path4}` : path4);
4918
+ }, join = function(...arguments_) {
4919
+ if (arguments_.length === 0)
4920
+ return ".";
4921
+ let joined;
4922
+ for (let argument of arguments_)
4923
+ argument && argument.length > 0 && (joined === void 0 ? joined = argument : joined += `/${argument}`);
4924
+ return joined === void 0 ? "." : normalize(joined.replace(/\/\/+/g, "/"));
4925
+ };
4926
+ function cwd() {
4927
+ return typeof process < "u" && typeof process.cwd == "function" ? process.cwd().replace(/\\/g, "/") : "/";
4928
+ }
4929
+ var resolve = function(...arguments_) {
4930
+ arguments_ = arguments_.map((argument) => normalizeWindowsPath(argument));
4931
+ let resolvedPath = "", resolvedAbsolute = !1;
4932
+ for (let index = arguments_.length - 1; index >= -1 && !resolvedAbsolute; index--) {
4933
+ let path4 = index >= 0 ? arguments_[index] : cwd();
4934
+ !path4 || path4.length === 0 || (resolvedPath = `${path4}/${resolvedPath}`, resolvedAbsolute = isAbsolute(path4));
4935
+ }
4936
+ return resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute), resolvedAbsolute && !isAbsolute(resolvedPath) ? `/${resolvedPath}` : resolvedPath.length > 0 ? resolvedPath : ".";
4937
+ };
4938
+ function normalizeString(path4, allowAboveRoot) {
4939
+ let res = "", lastSegmentLength = 0, lastSlash = -1, dots = 0, char = null;
4940
+ for (let index = 0; index <= path4.length; ++index) {
4941
+ if (index < path4.length)
4942
+ char = path4[index];
4943
+ else {
4944
+ if (char === "/")
4945
+ break;
4946
+ char = "/";
4947
+ }
4948
+ if (char === "/") {
4949
+ if (!(lastSlash === index - 1 || dots === 1)) if (dots === 2) {
4950
+ if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
4951
+ if (res.length > 2) {
4952
+ let lastSlashIndex = res.lastIndexOf("/");
4953
+ lastSlashIndex === -1 ? (res = "", lastSegmentLength = 0) : (res = res.slice(0, lastSlashIndex), lastSegmentLength = res.length - 1 - res.lastIndexOf("/")), lastSlash = index, dots = 0;
4954
+ continue;
4955
+ } else if (res.length > 0) {
4956
+ res = "", lastSegmentLength = 0, lastSlash = index, dots = 0;
4957
+ continue;
4958
+ }
4959
+ }
4960
+ allowAboveRoot && (res += res.length > 0 ? "/.." : "..", lastSegmentLength = 2);
4961
+ } else
4962
+ res.length > 0 ? res += `/${path4.slice(lastSlash + 1, index)}` : res = path4.slice(lastSlash + 1, index), lastSegmentLength = index - lastSlash - 1;
4963
+ lastSlash = index, dots = 0;
4964
+ } else char === "." && dots !== -1 ? ++dots : dots = -1;
4965
+ }
4966
+ return res;
4967
+ }
4968
+ var isAbsolute = function(p) {
4969
+ return _IS_ABSOLUTE_RE.test(p);
4970
+ };
4971
+ var relative = function(from, to) {
4972
+ let _from = resolve(from).replace(_ROOT_FOLDER_RE, "$1").split("/"), _to = resolve(to).replace(_ROOT_FOLDER_RE, "$1").split("/");
4973
+ if (_to[0][1] === ":" && _from[0][1] === ":" && _from[0] !== _to[0])
4974
+ return _to.join("/");
4975
+ let _fromCopy = [..._from];
4976
+ for (let segment of _fromCopy) {
4977
+ if (_to[0] !== segment)
4978
+ break;
4979
+ _from.shift(), _to.shift();
4980
+ }
4981
+ return [..._from.map(() => ".."), ..._to].join("/");
4982
+ }, dirname = function(p) {
4983
+ let segments = normalizeWindowsPath(p).replace(/\/$/, "").split("/").slice(0, -1);
4984
+ return segments.length === 1 && _DRIVE_LETTER_RE.test(segments[0]) && (segments[0] += "/"), segments.join("/") || (isAbsolute(p) ? "/" : ".");
4985
+ };
4986
+
4987
+ // ../../core/src/shared/constants/extensions.ts
4988
+ var storybookConfigExtensions = [
4989
+ ".js",
4990
+ ".ts",
4991
+ ".jsx",
4992
+ ".tsx",
4993
+ ".mjs",
4994
+ ".mts",
4995
+ ".mtsx",
4996
+ ".cjs",
4997
+ ".cts",
4998
+ ".ctsx"
4999
+ ];
5000
+
5001
+ // ../../core/src/shared/utils/module.ts
4905
5002
  var importMetaResolve = (...args) => typeof import.meta.resolve != "function" && process.env.VITEST === "true" ? (console.warn(
4906
5003
  "importMetaResolve from within Storybook is being used in a Vitest test, but it shouldn't be. Please report this at https://github.com/storybookjs/storybook/issues/new?template=bug_report.yml"
4907
5004
  ), pathToFileURL(args[0]).href) : import.meta.resolve(...args);
@@ -5087,7 +5184,7 @@ function invariant(condition, message) {
5087
5184
  }
5088
5185
 
5089
5186
  // src/automigrate/index.ts
5090
- import { dedent as dedent13 } from "ts-dedent";
5187
+ import { dedent as dedent14 } from "ts-dedent";
5091
5188
 
5092
5189
  // src/doctor/index.ts
5093
5190
  var import_picocolors4 = __toESM(require_picocolors(), 1);
@@ -5753,7 +5850,7 @@ var KIND_ORDER = ["main", "preview", "manager", "config", "story"], parse2 = (co
5753
5850
  project.mainConfigPath && claim(project.mainConfigPath, "main"), project.previewConfigPath && claim(project.previewConfigPath, "preview");
5754
5851
  let managerConfigPath = project.configDir && findConfigFile("manager", project.configDir);
5755
5852
  if (managerConfigPath && claim(managerConfigPath, "manager"), project.storiesPaths.forEach((id) => claim(id, "story")), kinds.has("config")) {
5756
- let { globby } = await import("./globby-QGVHATI2.js");
5853
+ let { globby } = await import("./globby-CUVQMT7O.js");
5757
5854
  (await globby("**/*.{js,jsx,ts,tsx,mjs,cjs,mts,cts}", {
5758
5855
  cwd: project.configDir,
5759
5856
  absolute: !0,
@@ -5918,6 +6015,8 @@ var KIND_ORDER = ["main", "preview", "manager", "config", "story"], parse2 = (co
5918
6015
 
5919
6016
  // src/codemod/csf-factories.ts
5920
6017
  var import_picocolors8 = __toESM(require_picocolors(), 1);
6018
+ import { existsSync } from "node:fs";
6019
+ import { join as join4 } from "node:path";
5921
6020
  import {
5922
6021
  optionalEnvToBoolean,
5923
6022
  syncStorybookAddons
@@ -5925,6 +6024,42 @@ import {
5925
6024
  import { logger as logger7, prompt as prompt2 } from "storybook/internal/node-logger";
5926
6025
  import { dedent as dedent3 } from "ts-dedent";
5927
6026
 
6027
+ // ../../core/src/shared/constants/config-folder.ts
6028
+ var RN_STORYBOOK_DIR = ".rnstorybook", DOCUMENTED_PREVIEW_IMPORT = "#.storybook/preview";
6029
+ function isReactNativeStorybookPath(fileOrDir) {
6030
+ if (!fileOrDir)
6031
+ return !1;
6032
+ let normalized = normalize(fileOrDir);
6033
+ return normalized === RN_STORYBOOK_DIR || normalized.startsWith(`${RN_STORYBOOK_DIR}/`) || normalized.endsWith(`/${RN_STORYBOOK_DIR}`) || normalized.includes(`/${RN_STORYBOOK_DIR}/`);
6034
+ }
6035
+ function webPreviewCandidates(nativeConfigPath) {
6036
+ let parts = resolve(nativeConfigPath).split("/"), index = parts.lastIndexOf(RN_STORYBOOK_DIR);
6037
+ if (index <= 0)
6038
+ return [];
6039
+ let projectDir = parts.slice(0, index).join("/");
6040
+ return storybookConfigExtensions.map(
6041
+ (extension) => join(projectDir, ".storybook", `preview${extension}`)
6042
+ );
6043
+ }
6044
+ function hasSiblingReactNativeConfig(configDir, exists) {
6045
+ return configDir ? exists(join(dirname(resolve(configDir)), RN_STORYBOOK_DIR)) : !1;
6046
+ }
6047
+ function previewFileForImports(nativeConfigPath, exists) {
6048
+ return webPreviewCandidates(nativeConfigPath).find((candidate) => exists(candidate)) ?? nativeConfigPath;
6049
+ }
6050
+ function previewImportTarget(previewFile, fromDirectory) {
6051
+ let relativePath = relative(resolve(fromDirectory), resolve(previewFile));
6052
+ if (!(relativePath === ".." || relativePath.startsWith("../")))
6053
+ return relativePath.startsWith("./") ? relativePath : `./${relativePath}`;
6054
+ }
6055
+ function applyPreviewImportsMap(packageJson, previewFile, fromDirectory) {
6056
+ let target = previewImportTarget(previewFile, fromDirectory), current = packageJson.imports ?? {};
6057
+ return !target || current[DOCUMENTED_PREVIEW_IMPORT] === target ? !1 : (packageJson.imports = {
6058
+ ...current,
6059
+ [DOCUMENTED_PREVIEW_IMPORT]: target
6060
+ }, !0);
6061
+ }
6062
+
5928
6063
  // src/automigrate/codemod.ts
5929
6064
  var import_picocolors6 = __toESM(require_picocolors(), 1);
5930
6065
  import os from "node:os";
@@ -5933,7 +6068,7 @@ import { logger as logger4 } from "storybook/internal/node-logger";
5933
6068
  import { promises as fs } from "fs";
5934
6069
  var maxConcurrentTasks = Math.max(1, os.cpus().length - 1);
5935
6070
  async function runCodemod(globPattern = "**/*.{stories,story}.{js,jsx,ts,tsx,mjs,mjsx,mts,mtsx}", transform, { dryRun = !1, skipFormatting = !1 } = {}) {
5936
- let modifiedCount = 0, unmodifiedCount = 0, errorCount = 0, { globby } = await import("./globby-QGVHATI2.js"), files = await globby(slash(globPattern), {
6071
+ let modifiedCount = 0, unmodifiedCount = 0, errorCount = 0, { globby } = await import("./globby-CUVQMT7O.js"), files = await globby(slash(globPattern), {
5937
6072
  followSymbolicLinks: !0,
5938
6073
  ignore: ["**/node_modules/**", "**/dist/**", "**/storybook-static/**", "**/build/**"]
5939
6074
  });
@@ -5944,7 +6079,7 @@ Please try a different pattern.
5944
6079
  `
5945
6080
  ), new Error("No files matched");
5946
6081
  try {
5947
- let pLimit = (await import("./p-limit-TRSAPTRX.js")).default, limit = pLimit(maxConcurrentTasks);
6082
+ let pLimit = (await import("./p-limit-L37OAZTF.js")).default, limit = pLimit(maxConcurrentTasks);
5948
6083
  await Promise.all(
5949
6084
  files.map(
5950
6085
  (file) => limit(async () => {
@@ -6414,7 +6549,7 @@ ${err}`), info.source;
6414
6549
  }
6415
6550
  let detectedStoryNames = csf.stories.map((story) => story.name), transformedStoryExports = /* @__PURE__ */ new Set(), metaVariableName = csf._metaVariableName ?? "meta", programNode = csf._ast.program, previewImport, hasRootLevelConfig = programNode.body.some(
6416
6551
  (n) => t6.isVariableDeclaration(n) && n.declarations.some((declaration) => t6.isIdentifier(declaration.id, { name: "preview" }))
6417
- ), previewPath = "#.storybook/preview";
6552
+ ), previewPath = DOCUMENTED_PREVIEW_IMPORT;
6418
6553
  if (!useSubPathImports) {
6419
6554
  let relativePath = path2.relative(path2.dirname(info.path), previewConfigPath), { dir, name } = path2.parse(relativePath);
6420
6555
  previewPath = `${dir ? `${dir}/` : ""}${name}`, previewPath.startsWith(".") || (previewPath = `./${previewPath}`), previewPath = previewPath.replace(/\\/g, "/");
@@ -6616,8 +6751,8 @@ var csfFactories = {
6616
6751
  yes,
6617
6752
  glob
6618
6753
  }) {
6619
- let inSandbox = optionalEnvToBoolean(process.env.IN_STORYBOOK_SANDBOX) ?? !1, useSubPathImports = inSandbox;
6620
- !yes && !inSandbox && (logger7.logBox(dedent3`
6754
+ let inSandbox = optionalEnvToBoolean(process.env.IN_STORYBOOK_SANDBOX) ?? !1, isReactNativePreview = isReactNativeStorybookPath(previewConfigPath) || isReactNativeStorybookPath(configDir) || hasSiblingReactNativeConfig(configDir, existsSync), useSubPathImports = inSandbox || isReactNativePreview;
6755
+ !yes && !inSandbox && !isReactNativePreview && (logger7.logBox(dedent3`
6621
6756
  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.
6622
6757
 
6623
6758
  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.
@@ -6633,13 +6768,19 @@ var csfFactories = {
6633
6768
  { label: "Subpath imports (import preview from '#.storybook/preview')", value: !0 }
6634
6769
  ]
6635
6770
  }));
6636
- let { packageJson } = packageManager.primaryPackageJson;
6637
- useSubPathImports && !packageJson.imports?.["#*"] && (logger7.step(
6771
+ let { packageJson, operationDir } = packageManager.primaryPackageJson;
6772
+ if (isReactNativePreview) {
6773
+ let nativePreviewFile = previewConfigPath ?? join4(configDir, "preview.tsx"), previewFile = previewFileForImports(nativePreviewFile, existsSync);
6774
+ previewImportTarget(previewFile, operationDir) == null ? useSubPathImports = !1 : applyPreviewImportsMap(packageJson, previewFile, operationDir) && (logger7.step(
6775
+ `Adding imports map in ${import_picocolors8.default.cyan(packageManager.primaryPackageJson.packageJsonPath)}`
6776
+ ), packageManager.writePackageJson(packageJson, operationDir));
6777
+ } else useSubPathImports && !packageJson.imports?.["#*"] && (logger7.step(
6638
6778
  `Adding imports map in ${import_picocolors8.default.cyan(packageManager.primaryPackageJson.packageJsonPath)}`
6639
6779
  ), packageJson.imports = {
6640
6780
  ...packageJson.imports,
6641
6781
  "#*": ["./*", "./*.ts", "./*.tsx", "./*.js", "./*.jsx"]
6642
- }, packageManager.writePackageJson(packageJson)), await runStoriesCodemod({
6782
+ }, packageManager.writePackageJson(packageJson, operationDir));
6783
+ await runStoriesCodemod({
6643
6784
  dryRun,
6644
6785
  packageManager,
6645
6786
  useSubPathImports,
@@ -6682,18 +6823,18 @@ import {
6682
6823
  import { logger as logger10, prompt as prompt3 } from "storybook/internal/node-logger";
6683
6824
 
6684
6825
  // ../../../node_modules/empathic/find.mjs
6685
- import { join as join4 } from "node:path";
6686
- import { existsSync, statSync } from "node:fs";
6826
+ import { join as join5 } from "node:path";
6827
+ import { existsSync as existsSync2, statSync } from "node:fs";
6687
6828
  function any(names, options) {
6688
6829
  let dir, start = options && options.cwd || "", j = 0, len = names.length, tmp, stats, type = options?.type, kind = type ? type === "dir" ? 1 : -1 : 0;
6689
6830
  for (dir of up(start, options))
6690
6831
  for (j = 0; j < len; j++)
6691
- if (tmp = join4(dir, names[j]), kind)
6832
+ if (tmp = join5(dir, names[j]), kind)
6692
6833
  try {
6693
6834
  if (stats = statSync(tmp), kind === 1 ? stats.isDirectory() : stats.isFile()) return tmp;
6694
6835
  } catch {
6695
6836
  }
6696
- else if (existsSync(tmp))
6837
+ else if (existsSync2(tmp))
6697
6838
  return tmp;
6698
6839
  }
6699
6840
 
@@ -6851,17 +6992,17 @@ var _lazyMatch = () => {
6851
6992
  return J(w);
6852
6993
  })();
6853
6994
  return __lib__.default || __lib__;
6854
- }, _match, zeptomatch = (path4, pattern) => (_match || (_match = _lazyMatch(), _lazyMatch = null), _match(path4, pattern)), _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
6855
- function normalizeWindowsPath(input = "") {
6856
- return input && input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
6995
+ }, _match, zeptomatch = (path4, pattern) => (_match || (_match = _lazyMatch(), _lazyMatch = null), _match(path4, pattern)), _DRIVE_LETTER_START_RE2 = /^[A-Za-z]:\//;
6996
+ function normalizeWindowsPath2(input = "") {
6997
+ return input && input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE2, (r) => r.toUpperCase());
6857
6998
  }
6858
- var _UNC_REGEX = /^[/\\]{2}/, _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/, _DRIVE_LETTER_RE = /^[A-Za-z]:$/, _ROOT_FOLDER_RE = /^\/([A-Za-z]:)?$/, _EXTNAME_RE = /.(\.[^./]+|\.)$/, _PATH_ROOT_RE = /^[/\\]|^[a-zA-Z]:[/\\]/, sep2 = "/", normalize2 = function(path4) {
6999
+ var _UNC_REGEX2 = /^[/\\]{2}/, _IS_ABSOLUTE_RE2 = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/, _DRIVE_LETTER_RE2 = /^[A-Za-z]:$/, _ROOT_FOLDER_RE2 = /^\/([A-Za-z]:)?$/, _EXTNAME_RE = /.(\.[^./]+|\.)$/, _PATH_ROOT_RE = /^[/\\]|^[a-zA-Z]:[/\\]/, sep2 = "/", normalize2 = function(path4) {
6859
7000
  if (path4.length === 0)
6860
7001
  return ".";
6861
- path4 = normalizeWindowsPath(path4);
6862
- let isUNCPath = path4.match(_UNC_REGEX), isPathAbsolute = isAbsolute2(path4), trailingSeparator = path4[path4.length - 1] === "/";
6863
- return path4 = normalizeString2(path4, !isPathAbsolute), path4.length === 0 ? isPathAbsolute ? "/" : trailingSeparator ? "./" : "." : (trailingSeparator && (path4 += "/"), _DRIVE_LETTER_RE.test(path4) && (path4 += "/"), isUNCPath ? isPathAbsolute ? `//${path4}` : `//./${path4}` : isPathAbsolute && !isAbsolute2(path4) ? `/${path4}` : path4);
6864
- }, join5 = function(...segments) {
7002
+ path4 = normalizeWindowsPath2(path4);
7003
+ let isUNCPath = path4.match(_UNC_REGEX2), isPathAbsolute = isAbsolute2(path4), trailingSeparator = path4[path4.length - 1] === "/";
7004
+ return path4 = normalizeString2(path4, !isPathAbsolute), path4.length === 0 ? isPathAbsolute ? "/" : trailingSeparator ? "./" : "." : (trailingSeparator && (path4 += "/"), _DRIVE_LETTER_RE2.test(path4) && (path4 += "/"), isUNCPath ? isPathAbsolute ? `//${path4}` : `//./${path4}` : isPathAbsolute && !isAbsolute2(path4) ? `/${path4}` : path4);
7005
+ }, join6 = function(...segments) {
6865
7006
  let path4 = "";
6866
7007
  for (let seg of segments)
6867
7008
  if (seg)
@@ -6872,14 +7013,14 @@ var _UNC_REGEX = /^[/\\]{2}/, _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)
6872
7013
  path4 += seg;
6873
7014
  return normalize2(path4);
6874
7015
  };
6875
- function cwd() {
7016
+ function cwd2() {
6876
7017
  return typeof process < "u" && typeof process.cwd == "function" ? process.cwd().replace(/\\/g, "/") : "/";
6877
7018
  }
6878
7019
  var resolve4 = function(...arguments_) {
6879
- arguments_ = arguments_.map((argument) => normalizeWindowsPath(argument));
7020
+ arguments_ = arguments_.map((argument) => normalizeWindowsPath2(argument));
6880
7021
  let resolvedPath = "", resolvedAbsolute = !1;
6881
7022
  for (let index = arguments_.length - 1; index >= -1 && !resolvedAbsolute; index--) {
6882
- let path4 = index >= 0 ? arguments_[index] : cwd();
7023
+ let path4 = index >= 0 ? arguments_[index] : cwd2();
6883
7024
  !path4 || path4.length === 0 || (resolvedPath = `${path4}/${resolvedPath}`, resolvedAbsolute = isAbsolute2(path4));
6884
7025
  }
6885
7026
  return resolvedPath = normalizeString2(resolvedPath, !resolvedAbsolute), resolvedAbsolute && !isAbsolute2(resolvedPath) ? `/${resolvedPath}` : resolvedPath.length > 0 ? resolvedPath : ".";
@@ -6915,15 +7056,15 @@ function normalizeString2(path4, allowAboveRoot) {
6915
7056
  return res;
6916
7057
  }
6917
7058
  var isAbsolute2 = function(p) {
6918
- return _IS_ABSOLUTE_RE.test(p);
7059
+ return _IS_ABSOLUTE_RE2.test(p);
6919
7060
  }, toNamespacedPath2 = function(p) {
6920
- return normalizeWindowsPath(p);
7061
+ return normalizeWindowsPath2(p);
6921
7062
  }, extname2 = function(p) {
6922
7063
  if (p === "..") return "";
6923
- let match = _EXTNAME_RE.exec(normalizeWindowsPath(p));
7064
+ let match = _EXTNAME_RE.exec(normalizeWindowsPath2(p));
6924
7065
  return match && match[1] || "";
6925
7066
  }, relative4 = function(from, to) {
6926
- let _from = resolve4(from).replace(_ROOT_FOLDER_RE, "$1").split("/"), _to = resolve4(to).replace(_ROOT_FOLDER_RE, "$1").split("/");
7067
+ let _from = resolve4(from).replace(_ROOT_FOLDER_RE2, "$1").split("/"), _to = resolve4(to).replace(_ROOT_FOLDER_RE2, "$1").split("/");
6927
7068
  if (_to[0][1] === ":" && _from[0][1] === ":" && _from[0] !== _to[0])
6928
7069
  return _to.join("/");
6929
7070
  let _fromCopy = [..._from];
@@ -6934,17 +7075,17 @@ var isAbsolute2 = function(p) {
6934
7075
  }
6935
7076
  return [..._from.map(() => ".."), ..._to].join("/");
6936
7077
  }, dirname2 = function(p) {
6937
- let segments = normalizeWindowsPath(p).replace(/\/$/, "").split("/").slice(0, -1);
6938
- return segments.length === 1 && _DRIVE_LETTER_RE.test(segments[0]) && (segments[0] += "/"), segments.join("/") || (isAbsolute2(p) ? "/" : ".");
7078
+ let segments = normalizeWindowsPath2(p).replace(/\/$/, "").split("/").slice(0, -1);
7079
+ return segments.length === 1 && _DRIVE_LETTER_RE2.test(segments[0]) && (segments[0] += "/"), segments.join("/") || (isAbsolute2(p) ? "/" : ".");
6939
7080
  }, format3 = function(p) {
6940
7081
  let ext = p.ext ? p.ext.startsWith(".") ? p.ext : `.${p.ext}` : "", segments = [p.root, p.dir, p.base ?? (p.name ?? "") + ext].filter(
6941
7082
  Boolean
6942
7083
  );
6943
- return normalizeWindowsPath(
7084
+ return normalizeWindowsPath2(
6944
7085
  p.root ? resolve4(...segments) : segments.join("/")
6945
7086
  );
6946
7087
  }, basename2 = function(p, extension) {
6947
- let segments = normalizeWindowsPath(p).split("/"), lastSegment = "";
7088
+ let segments = normalizeWindowsPath2(p).split("/"), lastSegment = "";
6948
7089
  for (let i = segments.length - 1; i >= 0; i--) {
6949
7090
  let val = segments[i];
6950
7091
  if (val) {
@@ -6969,7 +7110,7 @@ var isAbsolute2 = function(p) {
6969
7110
  extname: extname2,
6970
7111
  format: format3,
6971
7112
  isAbsolute: isAbsolute2,
6972
- join: join5,
7113
+ join: join6,
6973
7114
  matchesGlob,
6974
7115
  normalize: normalize2,
6975
7116
  normalizeString: normalizeString2,
@@ -7017,7 +7158,7 @@ var readJsonFile = async (files, path4) => {
7017
7158
  return null;
7018
7159
  }
7019
7160
  }, findWorkspaceFiles = async (basename5) => {
7020
- let { globby } = await import("./globby-QGVHATI2.js");
7161
+ let { globby } = await import("./globby-CUVQMT7O.js");
7021
7162
  return globby([`**/${basename5}`], {
7022
7163
  cwd: getProjectRoot2(),
7023
7164
  ignore: ["**/node_modules/**", "**/dist/**", "**/storybook-static/**"],
@@ -7026,7 +7167,7 @@ var readJsonFile = async (files, path4) => {
7026
7167
  };
7027
7168
 
7028
7169
  // src/automigrate/fixes/angular-workspace.ts
7029
- import { existsSync as existsSync2 } from "node:fs";
7170
+ import { existsSync as existsSync3 } from "node:fs";
7030
7171
  var asObject = (value) => typeof value == "object" && value !== null && !Array.isArray(value) ? value : void 0, getTargetGroups = (json) => {
7031
7172
  let root = asObject(json), groups = [];
7032
7173
  for (let [projectName, projectValue] of Object.entries(asObject(root?.projects) ?? {})) {
@@ -7039,7 +7180,7 @@ var asObject = (value) => typeof value == "object" && value !== null && !Array.i
7039
7180
  let targets = asObject(root?.targets);
7040
7181
  return targets && groups.push({ pathPrefix: ["targets"], targets }), groups;
7041
7182
  }, findWorkspaceJsonFiles = async (packageJsonPaths, siblings) => [
7042
- ...packageJsonPaths.flatMap((path4) => siblings.map((name) => path4.replace(/[/\\]package\.json$/, `/${name}`))).filter((path4) => existsSync2(path4)),
7183
+ ...packageJsonPaths.flatMap((path4) => siblings.map((name) => path4.replace(/[/\\]package\.json$/, `/${name}`))).filter((path4) => existsSync3(path4)),
7043
7184
  ...await findWorkspaceFiles("project.json")
7044
7185
  ];
7045
7186
 
@@ -7051,33 +7192,44 @@ import { dedent as dedent5 } from "ts-dedent";
7051
7192
 
7052
7193
  // src/automigrate/helpers/preview-call.ts
7053
7194
  import { traverse as traverse5, types as t7 } from "storybook/internal/babel";
7054
- var topLevelCalls = (program2, callee) => program2.body.filter(
7055
- (node) => t7.isExpressionStatement(node) && t7.isCallExpression(node.expression) && t7.isIdentifier(node.expression.callee, { name: callee })
7056
- ), countReferences = (program2, name) => {
7057
- let references = 0;
7195
+ var isTopLevelCall = (node, callee) => t7.isExpressionStatement(node) && t7.isCallExpression(node.expression) && t7.isIdentifier(node.expression.callee, { name: callee }), topLevelCalls = (program2, callee) => program2.body.filter((node) => isTopLevelCall(node, callee)), referencePaths = (program2, name) => {
7196
+ let paths = [];
7058
7197
  return traverse5(t7.file(program2), {
7059
7198
  Identifier(path4) {
7060
- path4.node.name !== name || path4.parentPath?.isImportDefaultSpecifier() || path4.isReferencedIdentifier() && (references += 1);
7061
- }
7062
- }), references;
7199
+ if (path4.node.name !== name || path4.parentPath?.isImportDefaultSpecifier() || !path4.isReferencedIdentifier())
7200
+ return;
7201
+ let binding = path4.scope.getBinding(name);
7202
+ binding && binding.scope !== path4.scope.getProgramParent() || paths.push(path4);
7203
+ }
7204
+ }), paths;
7205
+ }, countReferences = (program2, name) => referencePaths(program2, name).length, topLevelReaders = (program2, name) => {
7206
+ let readers = new Set(
7207
+ referencePaths(program2, name).flatMap((path4) => {
7208
+ let statement = path4.find((parent) => parent.parentPath?.isProgram() ?? !1);
7209
+ return statement ? [statement.node] : [];
7210
+ })
7211
+ );
7212
+ return program2.body.filter((node) => readers.has(node));
7063
7213
  }, removeTopLevelCall = (program2, { callee, calleeSources }) => {
7064
7214
  let callsToDrop = topLevelCalls(program2, callee);
7065
7215
  if (callsToDrop.length === 0)
7066
- return `${callee} is not called at the top level`;
7216
+ return { removed: !1, reason: `${callee} is not called at the top level` };
7067
7217
  let dropped = new Set(callsToDrop), withoutCalls = t7.program(program2.body.filter((node) => !dropped.has(node)));
7068
7218
  if (countReferences(withoutCalls, callee) > 0)
7069
- return `${callee} is still used elsewhere`;
7070
- let droppableImportNames = new Set(
7219
+ return { removed: !1, reason: `${callee} is still used elsewhere` };
7220
+ let argumentNames = new Set(
7071
7221
  callsToDrop.flatMap((node) => {
7072
7222
  let [argument] = node.expression.arguments;
7073
- return t7.isIdentifier(argument) && countReferences(withoutCalls, argument.name) === 0 ? [argument.name] : [];
7223
+ return t7.isIdentifier(argument) ? [argument.name] : [];
7074
7224
  })
7225
+ ), keptArguments = [...argumentNames].filter(
7226
+ (name) => countReferences(withoutCalls, name) > 0
7075
7227
  ), remaining = [];
7076
7228
  for (let node of withoutCalls.body)
7077
7229
  t7.isImportDeclaration(node) && node.specifiers.length > 0 && (node.specifiers = node.specifiers.filter(
7078
- (specifier) => !(calleeSources.has(node.source.value) && specifier.local.name === callee || droppableImportNames.has(specifier.local.name))
7230
+ (specifier) => !(calleeSources.has(node.source.value) && specifier.local.name === callee || argumentNames.has(specifier.local.name) && !keptArguments.includes(specifier.local.name))
7079
7231
  ), node.specifiers.length === 0) || remaining.push(node);
7080
- return program2.body = remaining, null;
7232
+ return program2.body = remaining, { removed: !0, keptArguments };
7081
7233
  };
7082
7234
 
7083
7235
  // src/automigrate/fixes/angular-vite-remove-compodoc.ts
@@ -7245,14 +7397,14 @@ var findCompodocSetup = async ({
7245
7397
  }, manualRemovalHint = (previewConfigPath, reason) => logger9.warn(
7246
7398
  `Left the Compodoc wiring in ${previewConfigPath} alone: ${reason}. Compodoc has no effect anymore, so remove what is left there by hand when convenient: a documentation.json import on its own still ships in your bundle.`
7247
7399
  ), removePreviewWiring = (preview, previewConfigPath) => {
7248
- let reason = removeTopLevelCall(preview._ast.program, {
7400
+ let result = removeTopLevelCall(preview._ast.program, {
7249
7401
  callee: SET_COMPODOC_JSON,
7250
7402
  calleeSources: /* @__PURE__ */ new Set([ADDON_DOCS_ANGULAR])
7251
7403
  });
7252
- if (reason) {
7404
+ if (!result.removed) {
7253
7405
  manualRemovalHint(
7254
7406
  previewConfigPath,
7255
- countReferences(preview._ast.program, SET_COMPODOC_JSON) > 0 ? reason : `no ${SET_COMPODOC_JSON} call is visible here, only a documentation.json import`
7407
+ countReferences(preview._ast.program, SET_COMPODOC_JSON) > 0 ? result.reason : `no ${SET_COMPODOC_JSON} call is visible here, only a documentation.json import`
7256
7408
  );
7257
7409
  return;
7258
7410
  }
@@ -7535,14 +7687,15 @@ export default defineConfig({
7535
7687
  };
7536
7688
 
7537
7689
  // src/automigrate/fixes/web-components-runtime-manifest.ts
7538
- import { babelParse as babelParse3, types as t10 } from "storybook/internal/babel";
7690
+ import { babelParse as babelParse3, generate as generate2, types as t10 } from "storybook/internal/babel";
7539
7691
  import { findFilesUp as findFilesUp2 } from "storybook/internal/common";
7540
7692
  import { logger as logger11 } from "storybook/internal/node-logger";
7541
7693
  import { SupportedRenderer } from "storybook/internal/types";
7694
+ import { dedent as dedent7 } from "ts-dedent";
7542
7695
  var SETTER_NAMES = ["setCustomElementsManifest", "setCustomElements"], WEB_COMPONENTS_PACKAGES = /* @__PURE__ */ new Set([
7543
7696
  "@storybook/web-components",
7544
7697
  "@storybook/web-components-vite"
7545
- ]), AUTOMIGRATE_COMMAND = "storybook automigrate web-components-runtime-manifest", webComponentsRuntimeManifest = {
7698
+ ]), AUTOMIGRATE_COMMAND = "storybook automigrate web-components-runtime-manifest", MAX_STATEMENT_LENGTH = 80, webComponentsRuntimeManifest = {
7546
7699
  id: "web-components-runtime-manifest",
7547
7700
  link: "https://storybook.js.org/docs/get-started/frameworks/web-components-vite",
7548
7701
  async check({
@@ -7568,7 +7721,8 @@ var SETTER_NAMES = ["setCustomElementsManifest", "setCustomElements"], WEB_COMPO
7568
7721
  let manifestPath = source.from === "file" ? relative4(configDir, source.path) : null;
7569
7722
  return {
7570
7723
  setterNames,
7571
- manifestPath
7724
+ manifestPath,
7725
+ manifestFiles: manifestPaths
7572
7726
  };
7573
7727
  },
7574
7728
  prompt: () => "The @storybook/web-components runtime manifest API is deprecated. We'll remove the runtime calls and add the manifest path to your main config.",
@@ -7588,7 +7742,7 @@ var SETTER_NAMES = ["setCustomElementsManifest", "setCustomElements"], WEB_COMPO
7588
7742
  {
7589
7743
  filter: { kind: ["preview"], code: "setCustomElements" },
7590
7744
  editConfig: (preview, { id }) => {
7591
- removePreviewWiring2(preview, id, result.setterNames);
7745
+ removePreviewWiring2(preview, id, result);
7592
7746
  }
7593
7747
  }
7594
7748
  ]
@@ -7629,29 +7783,62 @@ var SETTER_NAMES = ["setCustomElementsManifest", "setCustomElements"], WEB_COMPO
7629
7783
  if (!isCustomElementsManifest(await readJsonFile(files, path4)))
7630
7784
  return path4;
7631
7785
  return null;
7632
- }, logInvalidManifestWarning = (previewConfigPath, setterName, path4) => logger11.warn(
7633
- `Left the ${setterName}() call in ${previewConfigPath} alone: ${path4} is not a readable Custom Elements Manifest. Generate one with @custom-elements-manifest/analyzer, then rerun "${AUTOMIGRATE_COMMAND}".`
7634
- ), findDefaultJsonImportSpecifier = (program2, name) => {
7786
+ }, logInvalidManifestWarning = (previewConfigPath, setterName, path4) => logger11.warn(dedent7`
7787
+ Left the ${setterName}() call in ${previewConfigPath} alone: ${path4} is not a readable Custom Elements Manifest.
7788
+ Generate one with @custom-elements-manifest/analyzer, then rerun "${AUTOMIGRATE_COMMAND}".
7789
+ `), findDefaultJsonImportSpecifier = (program2, name) => {
7635
7790
  for (let node of program2.body)
7636
7791
  if (!(!t10.isImportDeclaration(node) || !isRelativeJsonSpecifier(node.source.value)) && node.specifiers.some(
7637
7792
  (specifier) => t10.isImportDefaultSpecifier(specifier) && specifier.local.name === name
7638
7793
  ))
7639
7794
  return node.source.value;
7640
7795
  return null;
7641
- }, isRelativeJsonSpecifier = (specifier) => specifier.endsWith(".json") && (specifier.startsWith("./") || specifier.startsWith("../")), logManualRemovalHint = (previewConfigPath, setterName, reason) => logger11.warn(
7642
- `Left the ${setterName} wiring in ${previewConfigPath} alone: ${reason}. Remove the runtime call by hand when convenient.`
7643
- ), removePreviewWiring2 = (preview, previewConfigPath, setterNames) => {
7796
+ }, isRelativeJsonSpecifier = (specifier) => specifier.endsWith(".json") && (specifier.startsWith("./") || specifier.startsWith("../")), logManualRemovalHint = (previewConfigPath, setterName, reason) => logger11.warn(dedent7`
7797
+ Left the ${setterName} wiring in ${previewConfigPath} alone: ${reason}.
7798
+ Remove the runtime call by hand when convenient.
7799
+ `), printStatement = (node) => {
7800
+ let [firstLine] = generate2(node, { comments: !1 }).code.split(`
7801
+ `), line = firstLine.replace(/;$/, "");
7802
+ return line.length > MAX_STATEMENT_LENGTH ? `${line.slice(0, MAX_STATEMENT_LENGTH)}...` : line;
7803
+ }, logSurvivingManifestImport = (previewConfigPath, specifier, readers) => logger11.warn(dedent7`
7804
+ ${previewConfigPath} still imports ${specifier} for: ${readers.map((node) => `\`${printStatement(node)}\``).join(", ")}.
7805
+ Docgen now reads the manifest from disk, so changes made to it in the preview no longer apply, and the import makes the preview build fail when the manifest is invalid.
7806
+ Move manifest transforms into your manifest generator (for example an analyzer plugin), then remove the import.
7807
+ `), findManifestImports = (program2, previewDir, manifestFiles) => {
7808
+ let imports = /* @__PURE__ */ new Map();
7809
+ for (let node of program2.body)
7810
+ if (!(!t10.isImportDeclaration(node) || !isRelativeJsonSpecifier(node.source.value) || !manifestFiles.includes(resolve4(previewDir, node.source.value))))
7811
+ for (let specifier of node.specifiers)
7812
+ t10.isImportDefaultSpecifier(specifier) && imports.set(specifier.local.name, node.source.value);
7813
+ return imports;
7814
+ }, removeDefaultImport = (program2, name) => {
7815
+ program2.body = program2.body.filter((node) => t10.isImportDeclaration(node) ? (node.specifiers = node.specifiers.filter(
7816
+ (specifier) => !(t10.isImportDefaultSpecifier(specifier) && specifier.local.name === name)
7817
+ ), node.specifiers.length > 0) : !0);
7818
+ }, removePreviewWiring2 = (preview, previewConfigPath, { setterNames, manifestFiles }) => {
7819
+ let { program: program2 } = preview._ast, manifestImports = findManifestImports(program2, dirname2(previewConfigPath), manifestFiles), keptImports = new Map(manifestImports), removedAnySetter = !1;
7644
7820
  for (let setterName of setterNames) {
7645
- let reason = removeTopLevelCall(preview._ast.program, {
7821
+ let result = removeTopLevelCall(program2, {
7646
7822
  callee: setterName,
7647
7823
  calleeSources: WEB_COMPONENTS_PACKAGES
7648
7824
  });
7649
- if (reason) {
7650
- logManualRemovalHint(previewConfigPath, setterName, reason);
7825
+ if (!result.removed) {
7826
+ logManualRemovalHint(previewConfigPath, setterName, result.reason);
7651
7827
  continue;
7652
7828
  }
7653
- logger11.debug(`Removed the ${setterName} wiring from ${previewConfigPath}`);
7829
+ removedAnySetter = !0, logger11.debug(`Removed the ${setterName} wiring from ${previewConfigPath}`);
7830
+ for (let name of result.keptArguments) {
7831
+ let specifier = findDefaultJsonImportSpecifier(program2, name);
7832
+ specifier && keptImports.set(name, specifier);
7833
+ }
7654
7834
  }
7835
+ if (removedAnySetter)
7836
+ for (let [name, specifier] of keptImports) {
7837
+ let readers = topLevelReaders(program2, name).filter(
7838
+ (node) => !SETTER_NAMES.some((setterName) => isTopLevelCall(node, setterName))
7839
+ );
7840
+ readers.length > 0 ? logSurvivingManifestImport(previewConfigPath, specifier, readers) : manifestImports.has(name) && countReferences(program2, name) === 0 && removeDefaultImport(program2, name);
7841
+ }
7655
7842
  };
7656
7843
 
7657
7844
  // src/automigrate/helpers/versionBoundary.ts
@@ -7686,7 +7873,7 @@ var import_picocolors9 = __toESM(require_picocolors(), 1);
7686
7873
  import { relative as relative5, resolve as resolve5 } from "node:path";
7687
7874
  import { parser, traverse as traverse7, types as t11 } from "storybook/internal/babel";
7688
7875
  import { getProjectRoot as getProjectRoot4, normalizeAddonName, removeAddon } from "storybook/internal/common";
7689
- import { dedent as dedent7 } from "ts-dedent";
7876
+ import { dedent as dedent8 } from "ts-dedent";
7690
7877
  var ADDON_SVELTE_CSF = "@storybook/addon-svelte-csf", SVELTE_CSF_FRAMEWORKS = ["@storybook/svelte-vite", "@storybook/sveltekit"], MIGRATION_GUIDE = "https://github.com/storybookjs/storybook/blob/next/MIGRATION.md", LEGACY_SYNTAX_LINK = `${MIGRATION_GUIDE}#svelte-csf-legacy-story-syntax-removed`, ADDON_IMPORT = /(\bfrom\s*|\bimport\s*\(\s*|\bimport\s+)(['"`])@storybook\/addon-svelte-csf\2/g, COMMENT_IMPORT = /(\bimport\s*\(\s*)(['"`])@storybook\/addon-svelte-csf\2/g, SCRIPT_BLOCK = /(<script\b(?:[^>"']|"[^"]*"|'[^']*')*>)([\s\S]*?)(<\/script>)/g, REWRITTEN_KINDS = ["main", "preview", "manager", "config", "story"], isAddonSvelteCsf = (addon) => normalizeAddonName(addon) === ADDON_SVELTE_CSF, needsLegacyWarning = (result) => result.legacyStoryFiles.length > 0 || Object.keys(result.legacySyntax).length > 0, LEGACY_STORY_ATTRIBUTES = ["let:args", "let:context", "id", "autodocs", "source"], storyTagAttributes = (markup, start) => {
7691
7878
  let names = [], name = "", quote = "", depth = 0, expression = "", shorthand = !1, afterEquals = !1;
7692
7879
  for (let index = start; index < markup.length; index++) {
@@ -7812,7 +7999,7 @@ var ADDON_SVELTE_CSF = "@storybook/addon-svelte-csf", SVELTE_CSF_FRAMEWORKS = ["
7812
7999
  ...legacyStoryFiles.map((path4) => [path4, "no defineMeta"]),
7813
8000
  ...Object.entries(legacySyntax).map(([path4, syntax]) => [path4, syntax.join(", ")])
7814
8001
  ]);
7815
- return dedent7`
8002
+ return dedent8`
7816
8003
  Storybook 11 removes the legacy Svelte CSF syntax, such as ${import_picocolors9.default.cyan("<Meta>")}, ${import_picocolors9.default.cyan("<Template>")}, ${import_picocolors9.default.cyan("let:args")} and the ${import_picocolors9.default.cyan("id")}, ${import_picocolors9.default.cyan("autodocs")} and ${import_picocolors9.default.cyan("source")} props on ${import_picocolors9.default.cyan("<Story>")}. Migrate these stories by hand:
7817
8004
  ${fileList(Object.keys(notes), notes)}
7818
8005
 
@@ -7951,7 +8138,7 @@ import {
7951
8138
  extractEslintInfo
7952
8139
  } from "storybook/internal/cli";
7953
8140
  import { logger as logger12 } from "storybook/internal/node-logger";
7954
- import { dedent as dedent8 } from "ts-dedent";
8141
+ import { dedent as dedent9 } from "ts-dedent";
7955
8142
  var eslintPlugin = {
7956
8143
  id: "eslintPlugin",
7957
8144
  link: "https://storybook.js.org/docs/configure/integration/eslint-plugin",
@@ -7976,7 +8163,7 @@ var eslintPlugin = {
7976
8163
  if (await packageManager.addDependencies({ type: "devDependencies", skipInstall: !0 }, [
7977
8164
  `eslint-plugin-storybook@${storybookVersion}`
7978
8165
  ]), unsupportedExtension) {
7979
- logger12.warn(dedent8`
8166
+ logger12.warn(dedent9`
7980
8167
  The plugin was successfully installed but failed to be configured.
7981
8168
 
7982
8169
  Found an eslint config file with an unsupported automigration format: .eslintrc.${unsupportedExtension}.
@@ -8084,7 +8271,7 @@ function writeText(text) {
8084
8271
 
8085
8272
  // src/automigrate/fixes/react-vite-to-tanstack-react.ts
8086
8273
  var import_picocolors12 = __toESM(require_picocolors(), 1);
8087
- import { dedent as dedent9 } from "ts-dedent";
8274
+ import { dedent as dedent10 } from "ts-dedent";
8088
8275
  var REACT_VITE_PACKAGE = "@storybook/react-vite", TANSTACK_REACT_PACKAGE = "@storybook/tanstack-react", DOCS_URL = "https://storybook.js.org/docs/get-started/frameworks/tanstack-react", TANSTACK_ROUTER_PACKAGES = [
8089
8276
  "@tanstack/react-router",
8090
8277
  "@tanstack/router-core",
@@ -8097,7 +8284,7 @@ var REACT_VITE_PACKAGE = "@storybook/react-vite", TANSTACK_REACT_PACKAGE = "@sto
8097
8284
  "createRootRoute",
8098
8285
  "createRouter",
8099
8286
  "RouterProvider"
8100
- ], scriptFile = /\.[cm]?[jt]sx?$/, buildAiMigrationPrompt = (previewConfigPath) => dedent9`
8287
+ ], scriptFile = /\.[cm]?[jt]sx?$/, buildAiMigrationPrompt = (previewConfigPath) => dedent10`
8101
8288
  You are migrating a Storybook project from the "${REACT_VITE_PACKAGE}" framework to the
8102
8289
  "${TANSTACK_REACT_PACKAGE}" framework. The framework swap in .storybook/main.* and the
8103
8290
  package.json dependency change have already been performed by the Storybook automigration
@@ -8300,7 +8487,7 @@ var REACT_VITE_PACKAGE = "@storybook/react-vite", TANSTACK_REACT_PACKAGE = "@sto
8300
8487
  }), logger13.step(`Migrating from ${REACT_VITE_PACKAGE} to ${TANSTACK_REACT_PACKAGE}...`), await packageManager.removeDependencies([REACT_VITE_PACKAGE]), await packageManager.addDependencies({ type: "devDependencies", skipInstall: !0 }, [
8301
8488
  `${TANSTACK_REACT_PACKAGE}@${storybookVersion}`
8302
8489
  ]), result.hasTanstackRouterDecorator && (logger13.logBox(
8303
- dedent9`
8490
+ dedent10`
8304
8491
  We detected what looks like a manual TanStack Router decorator in
8305
8492
  ${import_picocolors12.default.cyan(previewConfigPath ?? ".storybook/preview")}.
8306
8493
 
@@ -8316,7 +8503,7 @@ var REACT_VITE_PACKAGE = "@storybook/react-vite", TANSTACK_REACT_PACKAGE = "@sto
8316
8503
  () => !1
8317
8504
  );
8318
8505
  logger13.logBox(
8319
- dedent9`${copied ? "AI migration prompt copied to clipboard. Full prompt below:" : "Clipboard not available in this environment. Copy the AI migration prompt below manually:"}
8506
+ dedent10`${copied ? "AI migration prompt copied to clipboard. Full prompt below:" : "Clipboard not available in this environment. Copy the AI migration prompt below manually:"}
8320
8507
 
8321
8508
  ${separator}
8322
8509
  ${aiPrompt}
@@ -8361,15 +8548,10 @@ var removeExperimentalReview = {
8361
8548
  };
8362
8549
 
8363
8550
  // src/automigrate/fixes/rn-ondevice-addons-to-device-addons.ts
8364
- import { existsSync as existsSync3 } from "node:fs";
8365
- import { basename as basename3, dirname as dirname3, join as join6, resolve as resolve6 } from "node:path";
8551
+ import { existsSync as existsSync4 } from "node:fs";
8552
+ import { basename as basename3, dirname as dirname3, join as join7, resolve as resolve6 } from "node:path";
8366
8553
  import { findConfigFile as findConfigFile2, loadMainConfig } from "storybook/internal/common";
8367
8554
  import { logger as logger14 } from "storybook/internal/node-logger";
8368
-
8369
- // ../../core/src/shared/constants/config-folder.ts
8370
- var RN_STORYBOOK_DIR = ".rnstorybook";
8371
-
8372
- // src/automigrate/fixes/rn-ondevice-addons-to-device-addons.ts
8373
8555
  var SIBLING_CONFIG_DIR = {
8374
8556
  ".storybook": RN_STORYBOOK_DIR,
8375
8557
  [RN_STORYBOOK_DIR]: ".storybook"
@@ -8381,7 +8563,7 @@ var SIBLING_CONFIG_DIR = {
8381
8563
  return null;
8382
8564
  let targets = [];
8383
8565
  if (configDir) {
8384
- let absConfigDir = resolve6(configDir), siblingName = SIBLING_CONFIG_DIR[basename3(absConfigDir)], siblingDir = siblingName && join6(dirname3(absConfigDir), siblingName), candidateDirs = siblingDir && existsSync3(siblingDir) ? [absConfigDir, siblingDir] : [absConfigDir];
8566
+ let absConfigDir = resolve6(configDir), siblingName = SIBLING_CONFIG_DIR[basename3(absConfigDir)], siblingDir = siblingName && join7(dirname3(absConfigDir), siblingName), candidateDirs = siblingDir && existsSync4(siblingDir) ? [absConfigDir, siblingDir] : [absConfigDir];
8385
8567
  for (let dir of candidateDirs) {
8386
8568
  let mainPath = findConfigFile2("main", dir);
8387
8569
  if (!mainPath)
@@ -8412,7 +8594,7 @@ var SIBLING_CONFIG_DIR = {
8412
8594
 
8413
8595
  // src/automigrate/fixes/storybook-package-name-conflict.ts
8414
8596
  var import_picocolors13 = __toESM(require_picocolors(), 1);
8415
- import { dedent as dedent10 } from "ts-dedent";
8597
+ import { dedent as dedent11 } from "ts-dedent";
8416
8598
  var storybookPackageNameConflict = {
8417
8599
  id: "storybookPackageNameConflict",
8418
8600
  promptType: "notification",
@@ -8421,7 +8603,7 @@ var storybookPackageNameConflict = {
8421
8603
  return packageManager.primaryPackageJson.packageJson.name === "storybook" ? {} : null;
8422
8604
  },
8423
8605
  prompt() {
8424
- return dedent10`
8606
+ return dedent11`
8425
8607
  Your package.json ${import_picocolors13.default.cyan('"name"')} field is set to ${import_picocolors13.default.cyan('"storybook"')}.
8426
8608
 
8427
8609
  In npm, pnpm, or yarn workspaces this creates a symlink at
@@ -8471,8 +8653,15 @@ var storySortPath = ["parameters", "options", "storySort"], fail = (reason) => {
8471
8653
  ]
8472
8654
  };
8473
8655
 
8656
+ // src/automigrate/helpers/manager-api-packages.ts
8657
+ var managerApiPackages = /* @__PURE__ */ new Set([
8658
+ "storybook/manager-api",
8659
+ "storybook/internal/manager-api",
8660
+ "@storybook/manager-api"
8661
+ ]);
8662
+
8474
8663
  // src/automigrate/fixes/set-config-layout.ts
8475
- var managerApiPackages = /* @__PURE__ */ new Set(["storybook/manager-api", "@storybook/manager-api"]), optionGroups = {
8664
+ var optionGroups = {
8476
8665
  layout: [
8477
8666
  "initialActive",
8478
8667
  "navSize",
@@ -8511,7 +8700,7 @@ var managerApiPackages = /* @__PURE__ */ new Set(["storybook/manager-api", "@sto
8511
8700
  var import_picocolors15 = __toESM(require_picocolors(), 1);
8512
8701
  import { findConfigFile as findConfigFile3 } from "storybook/internal/common";
8513
8702
  import { loadConfig as loadConfig5 } from "storybook/internal/csf-tools";
8514
- var managerApiPackages2 = ["storybook/manager-api", "@storybook/manager-api"], sidebarFilters = {
8703
+ var sidebarFilters = {
8515
8704
  id: "sidebar-filters",
8516
8705
  promptType: "notification",
8517
8706
  link: "https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#tag-filtering-api",
@@ -8538,7 +8727,7 @@ var managerApiPackages2 = ["storybook/manager-api", "@storybook/manager-api"], s
8538
8727
  return manager.callArguments({
8539
8728
  importedName: "addons",
8540
8729
  methodName: "setConfig",
8541
- moduleNames: managerApiPackages2
8730
+ moduleNames: managerApiPackages
8542
8731
  }).some((object) => object.get(["sidebar", "filters"]) !== void 0) ? {} : null;
8543
8732
  },
8544
8733
  prompt() {
@@ -8553,7 +8742,7 @@ import { logger as logger15 } from "storybook/internal/node-logger";
8553
8742
  var introducedIn2 = "11.0.0", skills = {
8554
8743
  id: "skills",
8555
8744
  link: "https://github.com/storybookjs/skills",
8556
- prompt: () => "Install the official Storybook skills for AI agents into this project",
8745
+ prompt: () => "Install the official Storybook skills for AI agents into this project, and add a section to AGENTS.md that tells agents when to use them",
8557
8746
  async check({ packageManager, mainConfig, beforeVersion, storybookVersion, requested }) {
8558
8747
  if (isCI() || !requested && !(beforeVersion && crossesVersionBoundary(beforeVersion, storybookVersion, introducedIn2)) || await hasStorybookSkills())
8559
8748
  return null;
@@ -8654,7 +8843,9 @@ var import_semver8 = __toESM(require_semver(), 1);
8654
8843
  import { dirname as dirname4 } from "node:path";
8655
8844
  import { JsPackageManager as JsPackageManager2, isCorePackage, isSatelliteAddon } from "storybook/internal/common";
8656
8845
  import { logger as logger16 } from "storybook/internal/node-logger";
8657
- var NON_REGISTRY_SPECIFIER = /^(patch|file|link|portal|git|http|https|workspace):|^git\+/, LOCKSTEP_SCOPES = /* @__PURE__ */ new Set(["@nx"]), scopeOf = (packageName) => packageName.startsWith("@") ? packageName.slice(0, packageName.indexOf("/")) : null, upgradeStorybookRelatedDependencies = {
8846
+ var NON_REGISTRY_SPECIFIER = /^(patch|file|link|portal|git|http|https|workspace):|^git\+/, LOCKSTEP_SCOPES = /* @__PURE__ */ new Set(["@nx"]), VERSION_CEILINGS = {
8847
+ "msw-storybook-addon": "3.0.0"
8848
+ }, scopeOf = (packageName) => packageName.startsWith("@") ? packageName.slice(0, packageName.indexOf("/")) : null, upgradeStorybookRelatedDependencies = {
8658
8849
  id: "upgrade-storybook-related-dependencies",
8659
8850
  promptType: "auto",
8660
8851
  defaultSelected: !1,
@@ -8675,14 +8866,11 @@ var NON_REGISTRY_SPECIFIER = /^(patch|file|link|portal|git|http|https|workspace)
8675
8866
  Object.keys(allDependencies).filter((dependency) => !packageNames.has(dependency)).map(scopeOf).filter((scope) => scope !== null && LOCKSTEP_SCOPES.has(scope))
8676
8867
  ), upgradable = (await Promise.all(
8677
8868
  [...packageNames].map(async (packageName) => {
8678
- let beforeVersion = await packageManager.getInstalledVersion(packageName), keepMajor = !!beforeVersion && scopesStayingBehind.has(scopeOf(packageName));
8869
+ let beforeVersion = await packageManager.getInstalledVersion(packageName), keepMajor = !!beforeVersion && scopesStayingBehind.has(scopeOf(packageName)), ceiling = VERSION_CEILINGS[packageName], belowCeiling = !!beforeVersion && !!ceiling && !isAtOrPastVersion(beforeVersion, ceiling), constraint = [keepMajor && `^${beforeVersion}`, belowCeiling && `<${ceiling}`].filter(Boolean).join(" ");
8679
8870
  return {
8680
8871
  packageName,
8681
8872
  beforeVersion,
8682
- afterVersion: await packageManager.latestVersion(
8683
- packageName,
8684
- keepMajor ? `^${beforeVersion}` : void 0
8685
- )
8873
+ afterVersion: await packageManager.latestVersion(packageName, constraint || void 0)
8686
8874
  };
8687
8875
  })
8688
8876
  )).filter(
@@ -8706,7 +8894,7 @@ var NON_REGISTRY_SPECIFIER = /^(patch|file|link|portal|git|http|https|workspace)
8706
8894
 
8707
8895
  // src/automigrate/fixes/vitest-setup-file.ts
8708
8896
  var import_picocolors17 = __toESM(require_picocolors(), 1), import_semver9 = __toESM(require_semver(), 1);
8709
- import { existsSync as existsSync4 } from "fs";
8897
+ import { existsSync as existsSync5 } from "fs";
8710
8898
  import {
8711
8899
  formatExistingFile as formatExistingFile2,
8712
8900
  frameworkPackages as frameworkPackages4,
@@ -8715,7 +8903,7 @@ import {
8715
8903
  } from "storybook/internal/common";
8716
8904
  import jscodeshift from "jscodeshift";
8717
8905
  import path3 from "path";
8718
- import { dedent as dedent11 } from "ts-dedent";
8906
+ import { dedent as dedent12 } from "ts-dedent";
8719
8907
  import { getHeaderComments } from "storybook/internal/csf-tools";
8720
8908
  var VITEST_ADDON_NAME = "@storybook/addon-vitest", VITEST_PLUGIN_MODULE = "@storybook/addon-vitest/vitest-plugin", A11Y_ADDON_NAME = "@storybook/addon-a11y", A11Y_PREVIEW_MODULE = "@storybook/addon-a11y/preview", PRINT_OPTIONS = { lineTerminator: `
8721
8909
  ` }, SETUP_FILE_EXTENSIONS = [".ts", ".tsx", ".js", ".jsx", ".cts", ".mts", ".cjs", ".mjs"], CONFIG_FILE_PATTERNS = [
@@ -8743,7 +8931,7 @@ var VITEST_ADDON_NAME = "@storybook/addon-vitest", VITEST_PLUGIN_MODULE = "@stor
8743
8931
  let vitestVersion = await packageManager.getInstalledVersion("vitest"), inheritsRootByDefault = vitestVersion === null ? "unknown" : import_semver9.default.major(vitestVersion) >= 5, candidateSetupFiles = new Set(
8744
8932
  SETUP_FILE_EXTENSIONS.map(
8745
8933
  (extension) => path3.join(configDir, `vitest.setup${extension}`)
8746
- ).filter((filePath) => existsSync4(filePath))
8934
+ ).filter((filePath) => existsSync5(filePath))
8747
8935
  ), unresolvedEntries = [], referencesBySetupFile = /* @__PURE__ */ new Map();
8748
8936
  for (let [configFile, source] of configSources) {
8749
8937
  let entries;
@@ -8757,7 +8945,7 @@ var VITEST_ADDON_NAME = "@storybook/addon-vitest", VITEST_PLUGIN_MODULE = "@stor
8757
8945
  configFile,
8758
8946
  expression: entry.expression,
8759
8947
  project: entry.project
8760
- }) : existsSync4(entry.path) && (candidateSetupFiles.add(entry.path), referencesBySetupFile.set(entry.path, [
8948
+ }) : existsSync5(entry.path) && (candidateSetupFiles.add(entry.path), referencesBySetupFile.set(entry.path, [
8761
8949
  ...referencesBySetupFile.get(entry.path) ?? [],
8762
8950
  { configFile, project: entry.project }
8763
8951
  ]));
@@ -8822,7 +9010,7 @@ var VITEST_ADDON_NAME = "@storybook/addon-vitest", VITEST_PLUGIN_MODULE = "@stor
8822
9010
  }
8823
9011
  if (problems.length > 0)
8824
9012
  throw new Error(
8825
- dedent11`
9013
+ dedent12`
8826
9014
  The ${this.id} automigration couldn't migrate your Vitest setup file(s) automatically, but here are instructions for doing it yourself:
8827
9015
 
8828
9016
  ${problems.map((problem, index) => `${index + 1}) ${problem}`).join(`
@@ -9211,7 +9399,7 @@ var allFixes = [
9211
9399
  // src/automigrate/helpers/logMigrationSummary.ts
9212
9400
  var import_picocolors18 = __toESM(require_picocolors(), 1);
9213
9401
  import { CLI_COLORS as CLI_COLORS2, logger as logger17 } from "storybook/internal/node-logger";
9214
- import { dedent as dedent12 } from "ts-dedent";
9402
+ import { dedent as dedent13 } from "ts-dedent";
9215
9403
  var messageDivider2 = `
9216
9404
 
9217
9405
  `, segmentDivider = `
@@ -9242,7 +9430,7 @@ function logMigrationSummary({
9242
9430
  dryRun = !1
9243
9431
  }) {
9244
9432
  let messages2 = [];
9245
- messages2.push(getGlossaryMessages(fixSummary, fixResults, dryRun).join(messageDivider2)), messages2.push(dedent12`If you'd like to run the migrations again, you can do so by running
9433
+ 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
9246
9434
  ${import_picocolors18.default.cyan("npx storybook automigrate")}
9247
9435
 
9248
9436
  The automigrations try to migrate common patterns in your project, but might not contain everything needed to migrate to the latest version of Storybook.
@@ -9263,7 +9451,7 @@ function logMigrationSummary({
9263
9451
  var logAvailableMigrations = () => {
9264
9452
  let availableFixes = [...allFixes, ...commandFixes].map((f) => import_picocolors19.default.yellow(f.id)).map((x) => `- ${x}`).join(`
9265
9453
  `);
9266
- logger18.log(dedent13`
9454
+ logger18.log(dedent14`
9267
9455
  The following migrations are available:
9268
9456
  ${availableFixes}
9269
9457
  `);
@@ -9532,7 +9720,7 @@ var FEATURE_FLAG_FIXES = {}, resolveRequestedFeatures = (features) => {
9532
9720
  // src/link.ts
9533
9721
  var import_cross_spawn = __toESM(require_cross_spawn(), 1);
9534
9722
  import { mkdir, readFile as readFile4, writeFile as writeFile4 } from "node:fs/promises";
9535
- import { basename as basename4, extname as extname3, join as join7 } from "node:path";
9723
+ import { basename as basename4, extname as extname3, join as join8 } from "node:path";
9536
9724
  import { executeCommand } from "storybook/internal/common";
9537
9725
  import { logger as logger19 } from "storybook/internal/node-logger";
9538
9726
  var link = async ({ target, local, start }) => {
@@ -9545,12 +9733,12 @@ var link = async ({ target, local, start }) => {
9545
9733
  }
9546
9734
  let reproDir = target, reproName = basename4(target);
9547
9735
  if (!local) {
9548
- let reprosDir = join7(storybookDir, "../storybook-repros");
9736
+ let reprosDir = join8(storybookDir, "../storybook-repros");
9549
9737
  logger19.info(`Ensuring directory ${reprosDir}`), await mkdir(reprosDir, { recursive: !0 }), logger19.info(`Cloning ${target}`), await executeCommand({
9550
9738
  command: "git",
9551
9739
  args: ["clone", target],
9552
9740
  cwd: reprosDir
9553
- }), reproName = basename4(target, extname3(target)), reproDir = join7(reprosDir, reproName);
9741
+ }), reproName = basename4(target, extname3(target)), reproDir = join8(reprosDir, reproName);
9554
9742
  }
9555
9743
  let version2 = (0, import_cross_spawn.sync)("yarn", ["--version"], {
9556
9744
  cwd: reproDir,
@@ -9567,7 +9755,7 @@ var link = async ({ target, local, start }) => {
9567
9755
  cwd: reproDir
9568
9756
  }), logger19.info(`Installing ${reproName}`);
9569
9757
  let reproPackageJson = JSON.parse(
9570
- await readFile4(join7(reproDir, "package.json"), { encoding: "utf8" })
9758
+ await readFile4(join8(reproDir, "package.json"), { encoding: "utf8" })
9571
9759
  );
9572
9760
  reproPackageJson.devDependencies?.vite || (reproPackageJson.devDependencies = {
9573
9761
  ...reproPackageJson.devDependencies,
@@ -9575,7 +9763,7 @@ var link = async ({ target, local, start }) => {
9575
9763
  }), reproPackageJson.devDependencies = {
9576
9764
  ...reproPackageJson.devDependencies,
9577
9765
  "@types/node": "^22"
9578
- }, await writeFile4(join7(reproDir, "package.json"), JSON.stringify(reproPackageJson, null, 2)), await executeCommand({
9766
+ }, await writeFile4(join8(reproDir, "package.json"), JSON.stringify(reproPackageJson, null, 2)), await executeCommand({
9579
9767
  command: "yarn",
9580
9768
  args: ["install"],
9581
9769
  cwd: reproDir
@@ -9600,7 +9788,7 @@ async function migrate2(migration, { glob, dryRun, list, rename, parser: parser2
9600
9788
 
9601
9789
  // src/sandbox.ts
9602
9790
  var import_cross_spawn2 = __toESM(require_cross_spawn(), 1);
9603
- import { existsSync as existsSync5 } from "node:fs";
9791
+ import { existsSync as existsSync6 } from "node:fs";
9604
9792
  import { mkdir as mkdir2, readdir, rm as rm2 } from "node:fs/promises";
9605
9793
  import { isAbsolute as isAbsolute3 } from "node:path";
9606
9794
  import { PackageManagerName } from "storybook/internal/common";
@@ -9612,7 +9800,7 @@ import {
9612
9800
  } from "storybook/internal/common";
9613
9801
  import { logger as logger21, prompt as prompt6 } from "storybook/internal/node-logger";
9614
9802
  var import_picocolors20 = __toESM(require_picocolors(), 1), import_semver10 = __toESM(require_semver(), 1);
9615
- import { dedent as dedent14 } from "ts-dedent";
9803
+ import { dedent as dedent15 } from "ts-dedent";
9616
9804
 
9617
9805
  // src/sandbox-templates.ts
9618
9806
  var baseTemplates = {
@@ -9785,15 +9973,12 @@ var baseTemplates = {
9785
9973
  },
9786
9974
  "react-vite/prerelease-ts": {
9787
9975
  name: "React Prerelease (Vite | TypeScript)",
9788
- /**
9789
- * Create a Vite project with the React template. The beta React, React-DOM and @types packages,
9790
- * see https://react.dev/blog/2024/04/25/react-19-upgrade-guide#installing
9791
- */
9792
9976
  script: "npm create vite --yes {{beforeDir}} -- --template react-ts",
9793
- // Beta React is applied after scaffold (extraDependencies / resolutions). The allowlist
9977
+ // Canary React is applied after scaffold (extraDependencies / resolutions). The allowlist
9794
9978
  // still has to live on before-storybook so later installs under the 7-day gate can
9795
- // resolve those packages. `scheduler` ships in lockstep with React releases.
9796
- minAgeGateExemptions: ["react", "react-dom", "types-react", "types-react-dom", "scheduler"],
9979
+ // resolve those packages. `@types/react` has no canary dist-tag, so types stay on
9980
+ // `@latest`. `scheduler` ships in lockstep with React releases.
9981
+ minAgeGateExemptions: ["react", "react-dom", "scheduler"],
9797
9982
  expected: {
9798
9983
  framework: "@storybook/react-vite",
9799
9984
  renderer: "@storybook/react",
@@ -9801,17 +9986,13 @@ var baseTemplates = {
9801
9986
  },
9802
9987
  modifications: {
9803
9988
  useCsfFactory: !0,
9804
- extraDependencies: ["react@beta", "react-dom@beta"],
9805
- extraDevDependencies: [
9806
- "prop-types",
9807
- "@types/react@npm:types-react@beta",
9808
- "@types/react-dom@npm:types-react-dom@beta"
9809
- ],
9989
+ extraDependencies: ["react@canary", "react-dom@canary"],
9990
+ extraDevDependencies: ["prop-types", "@types/react@latest", "@types/react-dom@latest"],
9810
9991
  resolutions: {
9811
- "@types/react": "npm:types-react@beta",
9812
- "@types/react-dom": "npm:types-react-dom@beta",
9813
- react: "npm:react@beta",
9814
- "react-dom": "npm:react-dom@beta"
9992
+ "@types/react": "npm:@types/react@latest",
9993
+ "@types/react-dom": "npm:@types/react-dom@latest",
9994
+ react: "npm:react@canary",
9995
+ "react-dom": "npm:react-dom@canary"
9815
9996
  },
9816
9997
  mainConfig: {
9817
9998
  features: {
@@ -9844,16 +10025,11 @@ var baseTemplates = {
9844
10025
  },
9845
10026
  "react-webpack/prerelease-ts": {
9846
10027
  name: "React Prerelease (Webpack | TypeScript)",
9847
- /**
9848
- * Create a Webpack project with React beta versions.
9849
- * See https://react.dev/blog/2024/04/25/react-19-upgrade-guide#installing
9850
- */
9851
- script: 'npx create-webpack5-react {{beforeDir}} --version-react="beta" --version-react-dom="beta"',
9852
- // create-webpack5-react pins react@beta at scaffold time, so refresh must allow the
9853
- // React beta family or the 7-day gate quarantines them. `types-react*` are the
9854
- // packages behind the `@types/react@npm:types-react@beta` aliases; `scheduler`
9855
- // ships in lockstep with React releases.
9856
- minAgeGateExemptions: ["react", "react-dom", "types-react", "types-react-dom", "scheduler"],
10028
+ script: 'npx create-webpack5-react {{beforeDir}} --version-react="canary" --version-react-dom="canary"',
10029
+ // create-webpack5-react pins react@canary at scaffold time, so refresh must allow the
10030
+ // React canary family or the 7-day gate quarantines them. `@types/react` has no canary
10031
+ // dist-tag, so types stay on `@latest`. `scheduler` ships in lockstep with React releases.
10032
+ minAgeGateExemptions: ["react", "react-dom", "scheduler"],
9857
10033
  expected: {
9858
10034
  framework: "@storybook/react-webpack5",
9859
10035
  renderer: "@storybook/react",
@@ -9861,14 +10037,10 @@ var baseTemplates = {
9861
10037
  },
9862
10038
  modifications: {
9863
10039
  useCsfFactory: !0,
9864
- extraDevDependencies: [
9865
- "prop-types",
9866
- "@types/react@npm:types-react@beta",
9867
- "@types/react-dom@npm:types-react-dom@beta"
9868
- ],
10040
+ extraDevDependencies: ["prop-types", "@types/react@latest", "@types/react-dom@latest"],
9869
10041
  resolutions: {
9870
- "@types/react": "npm:types-react@beta",
9871
- "@types/react-dom": "npm:types-react-dom@beta"
10042
+ "@types/react": "npm:@types/react@latest",
10043
+ "@types/react-dom": "npm:@types/react-dom@latest"
9872
10044
  },
9873
10045
  mainConfig: {
9874
10046
  swc: { swcrc: !1 },
@@ -9985,6 +10157,22 @@ var baseTemplates = {
9985
10157
  },
9986
10158
  skipTasks: ["bench"]
9987
10159
  },
10160
+ "vue3-vite/prerelease-ts": {
10161
+ name: "Vue v3 Prerelease (Vite | TypeScript)",
10162
+ script: "npm create vite --yes {{beforeDir}} -- --template vue-ts",
10163
+ // `vue` pins its `@vue/*` packages to the same release.
10164
+ minAgeGateExemptions: ["vue", "@vue/*", "vue-component-meta"],
10165
+ expected: {
10166
+ framework: "@storybook/vue3-vite",
10167
+ renderer: "@storybook/vue3",
10168
+ builder: "@storybook/builder-vite"
10169
+ },
10170
+ modifications: {
10171
+ useCsfFactory: !0,
10172
+ extraDependencies: ["vue@rc"]
10173
+ },
10174
+ skipTasks: ["e2e-tests", "bench"]
10175
+ },
9988
10176
  "vue3-rsbuild/default-ts": {
9989
10177
  name: "Vue Latest (RsBuild | TypeScript)",
9990
10178
  script: "npx create-rsbuild -d {{beforeDir}} -t vue-ts --tools eslint",
@@ -10079,12 +10267,7 @@ var baseTemplates = {
10079
10267
  },
10080
10268
  "svelte-kit/skeleton-ts": {
10081
10269
  name: "SvelteKit Latest (Vite | TypeScript)",
10082
- // TODO: Remove `--min-release-age=0`, `minAgeGateExemptions` and `inDevelopment` once the
10083
- // published sandbox has SvelteKit 3. SvelteKit 3 and the `sv` release that scaffolds it are
10084
- // younger than the sandbox age gate, and npx ignores `minAgeGateExemptions`.
10085
- script: "npx --min-release-age=0 sv@latest create --template minimal --types ts --no-add-ons --no-install {{beforeDir}}",
10086
- minAgeGateExemptions: ["@sveltejs/kit", "@sveltejs/adapter-auto"],
10087
- inDevelopment: !0,
10270
+ script: "npx sv@latest create --template minimal --types ts --no-add-ons --no-install {{beforeDir}}",
10088
10271
  expected: {
10089
10272
  framework: "@storybook/sveltekit",
10090
10273
  renderer: "@storybook/svelte",
@@ -10179,13 +10362,25 @@ var baseTemplates = {
10179
10362
  "lit-vite/default-js": {
10180
10363
  name: "Lit Latest (Vite | JavaScript)",
10181
10364
  script: 'npm create vite --yes {{beforeDir}} -- --template lit && cd {{beforeDir}} && echo "export default {}" > vite.config.js',
10365
+ // TODO: remove after oct 21 2026
10366
+ minAgeGateExemptions: ["@wc-toolkit/*"],
10182
10367
  expected: {
10183
10368
  framework: "@storybook/web-components-vite",
10184
10369
  renderer: "@storybook/web-components",
10185
10370
  builder: "@storybook/builder-vite"
10186
10371
  },
10187
10372
  modifications: {
10188
- useCsfFactory: !0
10373
+ useCsfFactory: !0,
10374
+ mainConfig: {
10375
+ framework: {
10376
+ name: "@storybook/web-components-vite",
10377
+ options: {
10378
+ customElementsManifest: [
10379
+ "../src/stories/renderers/web-components/custom-elements.json"
10380
+ ]
10381
+ }
10382
+ }
10383
+ }
10189
10384
  },
10190
10385
  // Remove smoke-test from the list once https://github.com/storybookjs/storybook/issues/19351 is fixed.
10191
10386
  skipTasks: ["smoke-test", "e2e-tests", "bench"]
@@ -10193,13 +10388,30 @@ var baseTemplates = {
10193
10388
  "lit-vite/default-ts": {
10194
10389
  name: "Lit Latest (Vite | TypeScript)",
10195
10390
  script: 'npm create vite --yes {{beforeDir}} -- --template lit-ts && cd {{beforeDir}} && echo "export default {}" > vite.config.js',
10391
+ minAgeGateExemptions: ["@wc-toolkit/*"],
10196
10392
  expected: {
10197
10393
  framework: "@storybook/web-components-vite",
10198
10394
  renderer: "@storybook/web-components",
10199
10395
  builder: "@storybook/builder-vite"
10200
10396
  },
10201
10397
  modifications: {
10202
- useCsfFactory: !0
10398
+ useCsfFactory: !0,
10399
+ // The renderer turns the docgen server on by default; the components manifest brings this
10400
+ // template into docgen baseline coverage, see `docgenServerTemplates`.
10401
+ mainConfig: {
10402
+ framework: {
10403
+ name: "@storybook/web-components-vite",
10404
+ options: {
10405
+ customElementsManifest: [
10406
+ "../src/stories/renderers/web-components/custom-elements.json",
10407
+ "../src/stories/renderers/web-components_lit-vite-default-ts/custom-elements.json"
10408
+ ]
10409
+ }
10410
+ },
10411
+ features: {
10412
+ componentsManifest: !0
10413
+ }
10414
+ }
10203
10415
  },
10204
10416
  // Remove smoke-test from the list once https://github.com/storybookjs/storybook/issues/19351 is fixed.
10205
10417
  skipTasks: ["smoke-test", "e2e-tests", "bench"]
@@ -10207,6 +10419,7 @@ var baseTemplates = {
10207
10419
  "lit-rsbuild/default-ts": {
10208
10420
  name: "Web Components Latest (RsBuild | TypeScript)",
10209
10421
  script: "npx create-rsbuild -d {{beforeDir}} -t lit-ts --tools eslint",
10422
+ minAgeGateExemptions: ["@wc-toolkit/*"],
10210
10423
  expected: {
10211
10424
  framework: "storybook-web-components-rsbuild",
10212
10425
  renderer: "@storybook/web-components",
@@ -10498,6 +10711,7 @@ var baseTemplates = {
10498
10711
  "react-vite/prerelease-ts",
10499
10712
  "react-webpack/prerelease-ts",
10500
10713
  "vue3-vite/default-js",
10714
+ "vue3-vite/prerelease-ts",
10501
10715
  "lit-vite/default-js",
10502
10716
  "svelte-vite/default-js",
10503
10717
  "nextjs/prerelease",
@@ -10522,7 +10736,7 @@ var toChoices = (c) => ({ label: allTemplates[c].name, value: c }), sandbox = as
10522
10736
  force: PackageManagerName.NPM
10523
10737
  }), 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 = {
10524
10738
  welcome: `Creating a Storybook ${import_picocolors20.default.bold(currentVersion)} sandbox..`,
10525
- notLatest: import_picocolors20.default.red(dedent14`
10739
+ notLatest: import_picocolors20.default.red(dedent15`
10526
10740
  This version is behind the latest release, which is: ${import_picocolors20.default.bold(latestVersion)}!
10527
10741
  You likely ran the init command through npx, which can use a locally cached version, to get the latest please run:
10528
10742
  ${import_picocolors20.default.bold("npx storybook@latest sandbox")}
@@ -10546,7 +10760,7 @@ var toChoices = (c) => ({ label: allTemplates[c].name, value: c }), sandbox = as
10546
10760
  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;
10547
10761
  }, []);
10548
10762
  if (choices.length === 0 && (logger21.logBox(
10549
- dedent14`
10763
+ dedent15`
10550
10764
  🔎 You filtered out all templates. 🔍
10551
10765
 
10552
10766
  After filtering all the templates with "${import_picocolors20.default.yellow(
@@ -10559,7 +10773,7 @@ var toChoices = (c) => ({ label: allTemplates[c].name, value: c }), sandbox = as
10559
10773
  `.trim(),
10560
10774
  { borderStyle: "round", padding: 1, borderColor: "#F1618C" }
10561
10775
  ), process.exit(1)), choices.length === 1 ? [templateId] = choices : (logger21.logBox(
10562
- dedent14`
10776
+ dedent15`
10563
10777
  🤗 Welcome to ${import_picocolors20.default.yellow("sb sandbox")}! 🤗
10564
10778
 
10565
10779
  Create a ${import_picocolors20.default.green("new project")} to minimally reproduce Storybook issues.
@@ -10578,11 +10792,11 @@ var toChoices = (c) => ({ label: allTemplates[c].name, value: c }), sandbox = as
10578
10792
  throw new Error("\u{1F6A8} Sandbox: please specify a valid template type");
10579
10793
  }
10580
10794
  let selectedDirectory = outputDirectory, outputDirectoryName = outputDirectory || templateId;
10581
- selectedDirectory && existsSync5(`${selectedDirectory}`) && (logger21.log(`\u26A0\uFE0F ${selectedDirectory} already exists! Overwriting...`), await rm2(selectedDirectory, { recursive: !0, force: !0 })), selectedDirectory || (selectedDirectory = await prompt6.text(
10795
+ selectedDirectory && existsSync6(`${selectedDirectory}`) && (logger21.log(`\u26A0\uFE0F ${selectedDirectory} already exists! Overwriting...`), await rm2(selectedDirectory, { recursive: !0, force: !0 })), selectedDirectory || (selectedDirectory = await prompt6.text(
10582
10796
  {
10583
10797
  message: "Enter the output directory",
10584
10798
  initialValue: outputDirectoryName ?? void 0,
10585
- validate: (directoryName) => directoryName && existsSync5(directoryName) ? `${directoryName} already exists. Please choose another name.` : void 0
10799
+ validate: (directoryName) => directoryName && existsSync6(directoryName) ? `${directoryName} already exists. Please choose another name.` : void 0
10586
10800
  },
10587
10801
  {
10588
10802
  onCancel: () => {
@@ -10591,7 +10805,7 @@ var toChoices = (c) => ({ label: allTemplates[c].name, value: c }), sandbox = as
10591
10805
  }
10592
10806
  )), invariant(selectedDirectory);
10593
10807
  try {
10594
- let templateDestination = isAbsolute3(selectedDirectory) ? selectedDirectory : join5(process.cwd(), selectedDirectory);
10808
+ let templateDestination = isAbsolute3(selectedDirectory) ? selectedDirectory : join6(process.cwd(), selectedDirectory);
10595
10809
  logger21.log(`\u{1F3C3} Adding ${selectedConfig.name} into ${templateDestination}`), logger21.log(`\u{1F4E6} Downloading sandbox template (${import_picocolors20.default.bold(downloadType)})...`);
10596
10810
  try {
10597
10811
  let gitPath = `storybookjs/sandboxes/tree/${branch}/${templateId}/${downloadType}`;
@@ -10599,7 +10813,7 @@ var toChoices = (c) => ({ label: allTemplates[c].name, value: c }), sandbox = as
10599
10813
  stdio: "inherit"
10600
10814
  }), (await readdir(templateDestination)).length === 0) {
10601
10815
  let selected = import_picocolors20.default.yellow(templateId);
10602
- throw new Error(dedent14`
10816
+ throw new Error(dedent15`
10603
10817
  Template downloaded from ${import_picocolors20.default.blue(gitPath)} is empty.
10604
10818
  Are you use it exists? Or did you want to set ${selected} to inDevelopment first?
10605
10819
  `);
@@ -10618,12 +10832,12 @@ var toChoices = (c) => ({ label: allTemplates[c].name, value: c }), sandbox = as
10618
10832
  } catch (err) {
10619
10833
  throw logger21.error(`\u{1F6A8} Failed to download sandbox template: ${String(err)}`), err;
10620
10834
  }
10621
- let initMessage = init ? import_picocolors20.default.yellow(dedent14`
10835
+ let initMessage = init ? import_picocolors20.default.yellow(dedent15`
10622
10836
  yarn install
10623
10837
  yarn storybook
10624
10838
  `) : `Recreate your setup, then ${import_picocolors20.default.yellow("npx storybook@latest init")}`;
10625
10839
  logger21.logBox(
10626
- dedent14`
10840
+ dedent15`
10627
10841
  🎉 Your Storybook reproduction project is ready to use! 🎉
10628
10842
 
10629
10843
  ${import_picocolors20.default.yellow(`cd ${selectedDirectory}`)}
@@ -10652,7 +10866,11 @@ async function promptSelectedTemplate(choices) {
10652
10866
 
10653
10867
  // src/upgrade.ts
10654
10868
  var import_cross_spawn3 = __toESM(require_cross_spawn(), 1), import_picocolors21 = __toESM(require_picocolors(), 1), import_semver11 = __toESM(require_semver(), 1);
10655
- import { hasStorybookSkills as hasStorybookSkills2, installSkills as installSkills2 } from "storybook/internal/cli";
10869
+ import {
10870
+ hasStorybookSkills as hasStorybookSkills2,
10871
+ installSkills as installSkills2,
10872
+ refreshAgentInstructions
10873
+ } from "storybook/internal/cli";
10656
10874
  import { PackageManagerName as PackageManagerName2 } from "storybook/internal/common";
10657
10875
  import {
10658
10876
  HandledError as HandledError5,
@@ -10675,7 +10893,7 @@ import {
10675
10893
  UpgradeStorybookUnknownCurrentVersionError
10676
10894
  } from "storybook/internal/server-errors";
10677
10895
  import { telemetry } from "storybook/internal/telemetry";
10678
- import { dedent as dedent15 } from "ts-dedent";
10896
+ import { dedent as dedent16 } from "ts-dedent";
10679
10897
 
10680
10898
  // src/automigrate/multi-project.ts
10681
10899
  import { CLI_COLORS as CLI_COLORS3, logger as logger22, prompt as prompt7 } from "storybook/internal/node-logger";
@@ -10962,7 +11180,7 @@ function getUpgradeResults(projectResults, doctorResults) {
10962
11180
  }
10963
11181
  ), hasFailures2 = automigrationResults.some(
10964
11182
  (fix) => fix.status === "failed" /* FAILED */ || fix.status === "check_failed" /* CHECK_FAILED */
10965
- ), hasSuccessfulFixes = automigrationResults.some(
11183
+ ) || resultData.fileFailures.length > 0, hasSuccessfulFixes = automigrationResults.some(
10966
11184
  (fix) => fix.status === "succeeded" /* SUCCEEDED */ || fix.status === "manual_succeeded" /* MANUAL_SUCCEEDED */
10967
11185
  ), noFixesNeeded = Object.keys(resultData.automigrationStatuses).length === 0, migratedSuccessfully = hasSuccessfulFixes && !hasFailures2, hasDoctorReport = !!doctorResults[configDir];
10968
11186
  return hasFailures2 ? failedProjects.push(configDir) : migratedSuccessfully ? successfulProjects.push(configDir) : noFixesNeeded && projectsWithNoFixes.push(configDir), {
@@ -11004,7 +11222,7 @@ ${successfulProjectsList}`);
11004
11222
  `);
11005
11223
  if (logger23.log(
11006
11224
  `${CLI_COLORS4.error("Failed to upgrade:")}
11007
- Some automigrations failed, please check the logs in the log file for more details.
11225
+ Some automigrations failed or skipped files. Review the upgrade output for details.
11008
11226
  ${failedProjectsList}`
11009
11227
  ), projectsWithNoFixes.length > 0) {
11010
11228
  let projectList = projectsWithNoFixes.map((dir) => ` \u2022 ${shortenPath(dir)}`).join(`
@@ -11092,7 +11310,7 @@ Upgrade interrupted by user.`), allProjects.length > 1 && await sendMultiUpgrade
11092
11310
  process.on("SIGINT", handleInterruption), process.on("SIGTERM", handleInterruption);
11093
11311
  try {
11094
11312
  if (processAutoblockerResults(storybookProjects, (message) => {
11095
- logger23.error(dedent15`Blockers detected\n\n${message}`);
11313
+ logger23.error(dedent16`Blockers detected\n\n${message}`);
11096
11314
  }))
11097
11315
  throw new HandledError5("Blockers detected");
11098
11316
  if (storybookProjects.some((project) => {
@@ -11178,7 +11396,9 @@ Upgrade interrupted by user.`), allProjects.length > 1 && await sendMultiUpgrade
11178
11396
  }
11179
11397
  }
11180
11398
  }
11181
- let skills2 = !options.dryRun && hadSkills ? await installSkills2({ packageManager: rootPackageManager, source: "refresh" }) : void 0, doctorProjects = storybookProjects.map((project) => ({
11399
+ let skills2 = !options.dryRun && hadSkills ? await installSkills2({ packageManager: rootPackageManager, source: "refresh" }) : void 0;
11400
+ !options.dryRun && !hadSkills && await refreshAgentInstructions();
11401
+ let doctorProjects = storybookProjects.map((project) => ({
11182
11402
  configDir: project.configDir,
11183
11403
  packageManager: project.packageManager,
11184
11404
  storybookVersion: project.currentCLIVersion,
@@ -11207,12 +11427,15 @@ Upgrade interrupted by user.`), allProjects.length > 1 && await sendMultiUpgrade
11207
11427
  skills: skills2
11208
11428
  });
11209
11429
  }
11210
- await sendMultiUpgradeTelemetry({
11430
+ if (await sendMultiUpgradeTelemetry({
11211
11431
  allProjects,
11212
11432
  selectedProjects: storybookProjects,
11213
11433
  projectResults: automigrationResults2,
11214
11434
  doctorResults
11215
- });
11435
+ }), getUpgradeResults(automigrationResults2, doctorResults).failedProjects.length > 0)
11436
+ throw new HandledError5(
11437
+ "Some automigrations failed or skipped files. Review the upgrade output."
11438
+ );
11216
11439
  } finally {
11217
11440
  process.removeListener("SIGINT", handleInterruption), process.removeListener("SIGTERM", handleInterruption);
11218
11441
  }
@@ -11266,11 +11489,9 @@ command("add <addon>").description("Add an addon to your Storybook").addOption(
11266
11489
  new Option("--package-manager <type>", "Force package manager for installing deps").choices(
11267
11490
  Object.values(PackageManagerName3)
11268
11491
  )
11269
- ).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) => {
11270
- withTelemetry("add", { cliOptions: options }, async () => {
11271
- logger24.intro(`Setting up your project for ${addonName}`), await add(addonName, options), await telemetry2("add", { addon: addonName, source: "cli" }), logger24.outro("Done!");
11272
- }).catch(handleCommandFailure);
11273
- });
11492
+ ).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) => withTelemetry("add", { cliOptions: options }, async () => {
11493
+ logger24.intro(`Setting up your project for ${addonName}`), await add(addonName, options), await telemetry2("add", { addon: addonName, source: "cli" }), logger24.outro("Done!");
11494
+ }).catch(handleCommandFailure(options.logfile)));
11274
11495
  command("remove <addon>").description("Remove an addon from your Storybook").addOption(
11275
11496
  new Option("--package-manager <type>", "Force package manager for installing deps").choices(
11276
11497
  Object.values(PackageManagerName3)
@@ -11348,11 +11569,9 @@ command("migrate [migration]").description("Run a Storybook codemod migration on
11348
11569
  logger24.intro(`Running ${migration} migration`), await migrate2(migration, options), logger24.outro("Migration completed");
11349
11570
  }).catch(handleCommandFailure(options.logfile));
11350
11571
  });
11351
- command("sandbox [filterValue]").alias("repro").description("Create a sandbox from a set of possible templates").option("-o --output <outDir>", "Define an output directory").option("--no-init", "Whether to download a template without an initialized Storybook", !1).action((filterValue, options) => {
11352
- logger24.intro("Creating a Storybook sandbox..."), sandbox({ filterValue, ...options }).catch(handleCommandFailure).finally(() => {
11353
- logger24.outro("Done!");
11354
- });
11355
- });
11572
+ command("sandbox [filterValue]").alias("repro").description("Create a sandbox from a set of possible templates").option("-o --output <outDir>", "Define an output directory").option("--no-init", "Whether to download a template without an initialized Storybook", !1).action((filterValue, options) => (logger24.intro("Creating a Storybook sandbox..."), sandbox({ filterValue, ...options }).catch(handleCommandFailure(options.logfile)).finally(() => {
11573
+ logger24.outro("Done!");
11574
+ })));
11356
11575
  command("link <repo-url-or-directory>").description("Pull down a repro from a URL (or a local directory), link it, and run storybook").option("--local", "Link a local directory already in your file system").option("--no-start", "Start the storybook", !0).action(
11357
11576
  (target, { local, start, logfile }) => link({ target, local, start }).catch(handleCommandFailure(logfile))
11358
11577
  );
@@ -11380,4 +11599,8 @@ program.on("command:*", ([invalidCmd]) => {
11380
11599
  suggestion && (errorMessage += `
11381
11600
  Did you mean ${import_picocolors22.default.yellow(suggestion)}?`), logger24.error(errorMessage), process.exit(1);
11382
11601
  });
11383
- program.usage("<command> [options]").version(String(version)).parse(process.argv);
11602
+ program.usage("<command> [options]").version(String(version));
11603
+ var run = (argv = process.argv) => program.parseAsync(argv);
11604
+ export {
11605
+ run
11606
+ };