storybook 10.0.0-rc.2 → 10.0.0-rc.3

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 (69) hide show
  1. package/dist/_node-chunks/{builder-manager-ZNPRP22E.js → builder-manager-NIOGGLFD.js} +12 -12
  2. package/dist/_node-chunks/camelcase-CTANPQBN.js +18 -0
  3. package/dist/_node-chunks/{chunk-ZZMPRSOL.js → chunk-34ZACDOC.js} +10 -10
  4. package/dist/_node-chunks/{chunk-VHPYGR5X.js → chunk-3SEBVSWT.js} +7 -7
  5. package/dist/_node-chunks/{chunk-DOCRBDQH.js → chunk-5WPK6ACG.js} +7 -7
  6. package/dist/_node-chunks/{chunk-X35XJZ7G.js → chunk-5ZVI7NBO.js} +7 -7
  7. package/dist/_node-chunks/{chunk-BPYW7SFB.js → chunk-6PQVBT5D.js} +7 -7
  8. package/dist/_node-chunks/{chunk-QD4TA2GK.js → chunk-AF3TJ6R5.js} +7 -7
  9. package/dist/_node-chunks/{chunk-VSPERFYF.js → chunk-AZH4HEPP.js} +15 -15
  10. package/dist/_node-chunks/{chunk-54MOKOMZ.js → chunk-CTMEFFNW.js} +8 -8
  11. package/dist/_node-chunks/{chunk-H6J6LJQQ.js → chunk-CUEWGHOL.js} +6 -6
  12. package/dist/_node-chunks/{chunk-D5WSRTEX.js → chunk-EDGA22VS.js} +7 -7
  13. package/dist/_node-chunks/chunk-EOW64HJZ.js +1518 -0
  14. package/dist/_node-chunks/{chunk-J34Y4L4Q.js → chunk-FUCVPILC.js} +9 -9
  15. package/dist/_node-chunks/{chunk-AFW3U6QG.js → chunk-G5VN3ASC.js} +7 -7
  16. package/dist/_node-chunks/{chunk-OCPCEJ7D.js → chunk-HGZID3CI.js} +7 -7
  17. package/dist/_node-chunks/{chunk-FWBLOTP7.js → chunk-I37OZGFX.js} +7 -7
  18. package/dist/_node-chunks/{chunk-XJRUDTSD.js → chunk-JYCXWPO6.js} +7 -7
  19. package/dist/_node-chunks/{chunk-SSK6CTPD.js → chunk-KUXWX4RV.js} +12 -12
  20. package/dist/_node-chunks/{chunk-6VEWXDI5.js → chunk-ML3GTXPM.js} +6 -6
  21. package/dist/_node-chunks/{chunk-K5GJVTVF.js → chunk-NSYINCG4.js} +7 -7
  22. package/dist/_node-chunks/{chunk-6SGQF6CF.js → chunk-OAP27YU5.js} +8 -8
  23. package/dist/_node-chunks/{chunk-MTIN3LKM.js → chunk-QPB4P2Q3.js} +7 -7
  24. package/dist/_node-chunks/{chunk-2IEV7XG2.js → chunk-R2FDNWFD.js} +9 -9
  25. package/dist/_node-chunks/{chunk-VDCU2LFF.js → chunk-SZ6FXTRU.js} +7 -7
  26. package/dist/_node-chunks/{chunk-LR47LSEQ.js → chunk-TLUDPMLR.js} +8 -8
  27. package/dist/_node-chunks/chunk-UQKRSNK7.js +61 -0
  28. package/dist/_node-chunks/{chunk-WD2QJDGV.js → chunk-VDVDOBNV.js} +7 -7
  29. package/dist/_node-chunks/{chunk-M2Y5JVSX.js → chunk-VHDA7UQR.js} +8 -8
  30. package/dist/_node-chunks/{chunk-SF4YWMS2.js → chunk-WE7755VW.js} +24 -21
  31. package/dist/_node-chunks/{chunk-62KDMWXX.js → chunk-WRCI3EYU.js} +7 -7
  32. package/dist/_node-chunks/{chunk-FXGD2HHQ.js → chunk-WSINFVEL.js} +7 -7
  33. package/dist/_node-chunks/{chunk-TR7IYGK4.js → chunk-XA5ZNWSM.js} +7 -7
  34. package/dist/_node-chunks/chunk-XC2HC4KH.js +18 -0
  35. package/dist/_node-chunks/{chunk-LUDM5RD2.js → chunk-XFBFSXFJ.js} +8 -8
  36. package/dist/_node-chunks/{dist-47EE2CMC.js → dist-SXAIWZGI.js} +9 -9
  37. package/dist/_node-chunks/{globby-ZEUQ6QPC.js → globby-W4JFDHUY.js} +9 -9
  38. package/dist/_node-chunks/{lib-LCU5VXJS.js → lib-PMWBRG3N.js} +7 -7
  39. package/dist/_node-chunks/{mdx-N42X6CFJ-7LUZM4HR.js → mdx-N42X6CFJ-IVVYYMYF.js} +8 -8
  40. package/dist/_node-chunks/{p-limit-XJGTO6H5.js → p-limit-PE5BWDZH.js} +7 -7
  41. package/dist/_node-chunks/{plugin-ZN5KCYM2.js → plugin-OGRBN4O7.js} +10 -10
  42. package/dist/_node-chunks/{plugin-YZRPWYO5.js → plugin-ZVWKMXMK.js} +10 -10
  43. package/dist/_node-chunks/{webpack-inject-mocker-runtime-plugin-CRH6N7YZ.js → webpack-inject-mocker-runtime-plugin-SXMOGYNE.js} +10 -10
  44. package/dist/_node-chunks/{webpack-mock-plugin-NQXGMVTF.js → webpack-mock-plugin-X64FENVZ.js} +9 -9
  45. package/dist/babel/index.js +11 -11
  46. package/dist/bin/core.js +11 -11
  47. package/dist/bin/dispatcher.js +11 -11
  48. package/dist/bin/loader.js +9 -9
  49. package/dist/cli/index.js +136 -1561
  50. package/dist/common/index.js +20 -20
  51. package/dist/core-server/index.js +47 -35
  52. package/dist/core-server/presets/common-manager.js +1 -0
  53. package/dist/core-server/presets/common-override-preset.js +9 -9
  54. package/dist/core-server/presets/common-preset.js +23 -23
  55. package/dist/core-server/presets/webpack/loaders/storybook-mock-transform-loader.js +9 -9
  56. package/dist/core-server/presets/webpack/loaders/webpack-automock-loader.js +10 -10
  57. package/dist/csf-tools/index.js +9 -9
  58. package/dist/manager/globals-runtime.js +8 -5
  59. package/dist/manager-api/index.js +1 -1
  60. package/dist/node-logger/index.js +14 -14
  61. package/dist/preview/runtime.js +7 -4
  62. package/dist/server-errors.js +10 -10
  63. package/dist/telemetry/index.js +24 -24
  64. package/dist/test/index.js +7 -4
  65. package/dist/types/index.d.ts +1 -0
  66. package/package.json +1 -1
  67. package/dist/_node-chunks/camelcase-EY6MYFU4.js +0 -18
  68. package/dist/_node-chunks/chunk-JT5JXOKC.js +0 -61
  69. package/dist/_node-chunks/chunk-N4S7XZKB.js +0 -18
package/dist/cli/index.js CHANGED
@@ -1,57 +1,86 @@
1
- import CJS_COMPAT_NODE_URL_oali8g6joqi from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_oali8g6joqi from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_oali8g6joqi from "node:module";
1
+ import CJS_COMPAT_NODE_URL_gf85phjy0t from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_gf85phjy0t from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_gf85phjy0t from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_oali8g6joqi.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_oali8g6joqi.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_oali8g6joqi.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_gf85phjy0t.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_gf85phjy0t.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_gf85phjy0t.createRequire(import.meta.url);
8
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration
11
11
  // ------------------------------------------------------------
12
+ import {
13
+ CommunityBuilder,
14
+ CoreBuilder,
15
+ CoreWebpackCompilers,
16
+ ProjectType,
17
+ SUPPORTED_RENDERERS,
18
+ SupportedLanguage,
19
+ addToDevDependenciesIfNotPresent,
20
+ adjustTemplate,
21
+ builderNameToCoreBuilder,
22
+ cliStoriesTargetPath,
23
+ coerceSemver,
24
+ compilerNameToCoreCompiler,
25
+ copyTemplate,
26
+ copyTemplateFiles,
27
+ detect,
28
+ detectBuilder,
29
+ detectFrameworkPreset,
30
+ detectLanguage,
31
+ detectPnp,
32
+ externalFrameworks,
33
+ frameworkToDefaultBuilder,
34
+ getBabelDependencies,
35
+ getRendererDir,
36
+ getVersionSafe,
37
+ hasStorybookDependencies,
38
+ installableProjectTypes,
39
+ isNxProject,
40
+ isStorybookInstantiated,
41
+ readFileAsJson,
42
+ supportedTemplates,
43
+ unsupportedTemplate,
44
+ writeFileAsJson
45
+ } from "../_node-chunks/chunk-EOW64HJZ.js";
12
46
  import {
13
47
  boxen
14
- } from "../_node-chunks/chunk-LUDM5RD2.js";
15
- import "../_node-chunks/chunk-BPYW7SFB.js";
48
+ } from "../_node-chunks/chunk-XFBFSXFJ.js";
49
+ import "../_node-chunks/chunk-6PQVBT5D.js";
16
50
  import {
17
51
  Settings,
18
52
  _clearGlobalSettings,
19
53
  globalSettings
20
- } from "../_node-chunks/chunk-LR47LSEQ.js";
54
+ } from "../_node-chunks/chunk-TLUDPMLR.js";
21
55
  import {
22
- any,
23
56
  up2 as up
24
- } from "../_node-chunks/chunk-FXGD2HHQ.js";
25
- import {
26
- invariant
27
- } from "../_node-chunks/chunk-X35XJZ7G.js";
28
- import {
29
- resolvePackageDir
30
- } from "../_node-chunks/chunk-6SGQF6CF.js";
31
- import "../_node-chunks/chunk-QD4TA2GK.js";
57
+ } from "../_node-chunks/chunk-WSINFVEL.js";
58
+ import "../_node-chunks/chunk-5ZVI7NBO.js";
59
+ import "../_node-chunks/chunk-OAP27YU5.js";
60
+ import "../_node-chunks/chunk-AF3TJ6R5.js";
32
61
  import {
33
62
  require_prompts
34
- } from "../_node-chunks/chunk-AFW3U6QG.js";
63
+ } from "../_node-chunks/chunk-G5VN3ASC.js";
35
64
  import {
36
65
  require_dist
37
- } from "../_node-chunks/chunk-VHPYGR5X.js";
66
+ } from "../_node-chunks/chunk-3SEBVSWT.js";
38
67
  import {
39
68
  babelParse,
40
69
  recast,
41
70
  traverse,
42
71
  types
43
- } from "../_node-chunks/chunk-ZZMPRSOL.js";
44
- import "../_node-chunks/chunk-D5WSRTEX.js";
45
- import "../_node-chunks/chunk-K5GJVTVF.js";
72
+ } from "../_node-chunks/chunk-34ZACDOC.js";
73
+ import "../_node-chunks/chunk-EDGA22VS.js";
74
+ import "../_node-chunks/chunk-NSYINCG4.js";
46
75
  import {
47
76
  require_picocolors
48
- } from "../_node-chunks/chunk-DOCRBDQH.js";
77
+ } from "../_node-chunks/chunk-5WPK6ACG.js";
49
78
  import {
50
79
  __commonJS,
51
80
  __name,
52
81
  __require,
53
82
  __toESM
54
- } from "../_node-chunks/chunk-H6J6LJQQ.js";
83
+ } from "../_node-chunks/chunk-CUEWGHOL.js";
55
84
 
56
85
  // ../node_modules/esprima/dist/esprima.js
57
86
  var require_esprima = __commonJS({
@@ -556,8 +585,8 @@ var require_esprima = __commonJS({
556
585
  return result;
557
586
  };
558
587
  JSXParser2.prototype.lexJSX = function() {
559
- var cp2 = this.scanner.source.charCodeAt(this.scanner.index);
560
- if (cp2 === 60 || cp2 === 62 || cp2 === 47 || cp2 === 58 || cp2 === 61 || cp2 === 123 || cp2 === 125) {
588
+ var cp = this.scanner.source.charCodeAt(this.scanner.index);
589
+ if (cp === 60 || cp === 62 || cp === 47 || cp === 58 || cp === 61 || cp === 123 || cp === 125) {
561
590
  var value = this.scanner.source[this.scanner.index++];
562
591
  return {
563
592
  type: 7,
@@ -568,7 +597,7 @@ var require_esprima = __commonJS({
568
597
  end: this.scanner.index
569
598
  };
570
599
  }
571
- if (cp2 === 34 || cp2 === 39) {
600
+ if (cp === 34 || cp === 39) {
572
601
  var start = this.scanner.index;
573
602
  var quote = this.scanner.source[this.scanner.index++];
574
603
  var str = "";
@@ -591,7 +620,7 @@ var require_esprima = __commonJS({
591
620
  end: this.scanner.index
592
621
  };
593
622
  }
594
- if (cp2 === 46) {
623
+ if (cp === 46) {
595
624
  var n1 = this.scanner.source.charCodeAt(this.scanner.index + 1);
596
625
  var n2 = this.scanner.source.charCodeAt(this.scanner.index + 2);
597
626
  var value = n1 === 46 && n2 === 46 ? "..." : ".";
@@ -606,7 +635,7 @@ var require_esprima = __commonJS({
606
635
  end: this.scanner.index
607
636
  };
608
637
  }
609
- if (cp2 === 96) {
638
+ if (cp === 96) {
610
639
  return {
611
640
  type: 10,
612
641
  value: "",
@@ -616,7 +645,7 @@ var require_esprima = __commonJS({
616
645
  end: this.scanner.index
617
646
  };
618
647
  }
619
- if (character_1.Character.isIdentifierStart(cp2) && cp2 !== 92) {
648
+ if (character_1.Character.isIdentifierStart(cp) && cp !== 92) {
620
649
  var start = this.scanner.index;
621
650
  ++this.scanner.index;
622
651
  while (!this.scanner.eof()) {
@@ -946,33 +975,33 @@ var require_esprima = __commonJS({
946
975
  };
947
976
  exports2.Character = {
948
977
  /* tslint:disable:no-bitwise */
949
- fromCodePoint: /* @__PURE__ */ __name(function(cp2) {
950
- return cp2 < 65536 ? String.fromCharCode(cp2) : String.fromCharCode(55296 + (cp2 - 65536 >> 10)) + String.fromCharCode(56320 + (cp2 - 65536 & 1023));
978
+ fromCodePoint: /* @__PURE__ */ __name(function(cp) {
979
+ return cp < 65536 ? String.fromCharCode(cp) : String.fromCharCode(55296 + (cp - 65536 >> 10)) + String.fromCharCode(56320 + (cp - 65536 & 1023));
951
980
  }, "fromCodePoint"),
952
981
  // https://tc39.github.io/ecma262/#sec-white-space
953
- isWhiteSpace: /* @__PURE__ */ __name(function(cp2) {
954
- return cp2 === 32 || cp2 === 9 || cp2 === 11 || cp2 === 12 || cp2 === 160 || cp2 >= 5760 && [5760, 8192, 8193, 8194, 8195, 8196, 8197, 8198, 8199, 8200, 8201, 8202, 8239, 8287, 12288, 65279].indexOf(cp2) >= 0;
982
+ isWhiteSpace: /* @__PURE__ */ __name(function(cp) {
983
+ return cp === 32 || cp === 9 || cp === 11 || cp === 12 || cp === 160 || cp >= 5760 && [5760, 8192, 8193, 8194, 8195, 8196, 8197, 8198, 8199, 8200, 8201, 8202, 8239, 8287, 12288, 65279].indexOf(cp) >= 0;
955
984
  }, "isWhiteSpace"),
956
985
  // https://tc39.github.io/ecma262/#sec-line-terminators
957
- isLineTerminator: /* @__PURE__ */ __name(function(cp2) {
958
- return cp2 === 10 || cp2 === 13 || cp2 === 8232 || cp2 === 8233;
986
+ isLineTerminator: /* @__PURE__ */ __name(function(cp) {
987
+ return cp === 10 || cp === 13 || cp === 8232 || cp === 8233;
959
988
  }, "isLineTerminator"),
960
989
  // https://tc39.github.io/ecma262/#sec-names-and-keywords
961
- isIdentifierStart: /* @__PURE__ */ __name(function(cp2) {
962
- return cp2 === 36 || cp2 === 95 || cp2 >= 65 && cp2 <= 90 || cp2 >= 97 && cp2 <= 122 || cp2 === 92 || cp2 >= 128 && Regex.NonAsciiIdentifierStart.test(exports2.Character.fromCodePoint(cp2));
990
+ isIdentifierStart: /* @__PURE__ */ __name(function(cp) {
991
+ return cp === 36 || cp === 95 || cp >= 65 && cp <= 90 || cp >= 97 && cp <= 122 || cp === 92 || cp >= 128 && Regex.NonAsciiIdentifierStart.test(exports2.Character.fromCodePoint(cp));
963
992
  }, "isIdentifierStart"),
964
- isIdentifierPart: /* @__PURE__ */ __name(function(cp2) {
965
- return cp2 === 36 || cp2 === 95 || cp2 >= 65 && cp2 <= 90 || cp2 >= 97 && cp2 <= 122 || cp2 >= 48 && cp2 <= 57 || cp2 === 92 || cp2 >= 128 && Regex.NonAsciiIdentifierPart.test(exports2.Character.fromCodePoint(cp2));
993
+ isIdentifierPart: /* @__PURE__ */ __name(function(cp) {
994
+ return cp === 36 || cp === 95 || cp >= 65 && cp <= 90 || cp >= 97 && cp <= 122 || cp >= 48 && cp <= 57 || cp === 92 || cp >= 128 && Regex.NonAsciiIdentifierPart.test(exports2.Character.fromCodePoint(cp));
966
995
  }, "isIdentifierPart"),
967
996
  // https://tc39.github.io/ecma262/#sec-literals-numeric-literals
968
- isDecimalDigit: /* @__PURE__ */ __name(function(cp2) {
969
- return cp2 >= 48 && cp2 <= 57;
997
+ isDecimalDigit: /* @__PURE__ */ __name(function(cp) {
998
+ return cp >= 48 && cp <= 57;
970
999
  }, "isDecimalDigit"),
971
- isHexDigit: /* @__PURE__ */ __name(function(cp2) {
972
- return cp2 >= 48 && cp2 <= 57 || cp2 >= 65 && cp2 <= 70 || cp2 >= 97 && cp2 <= 102;
1000
+ isHexDigit: /* @__PURE__ */ __name(function(cp) {
1001
+ return cp >= 48 && cp <= 57 || cp >= 65 && cp <= 70 || cp >= 97 && cp <= 102;
973
1002
  }, "isHexDigit"),
974
- isOctalDigit: /* @__PURE__ */ __name(function(cp2) {
975
- return cp2 >= 48 && cp2 <= 55;
1003
+ isOctalDigit: /* @__PURE__ */ __name(function(cp) {
1004
+ return cp >= 48 && cp <= 55;
976
1005
  }, "isOctalDigit")
977
1006
  };
978
1007
  },
@@ -5135,15 +5164,15 @@ var require_esprima = __commonJS({
5135
5164
  }
5136
5165
  };
5137
5166
  Scanner2.prototype.codePointAt = function(i) {
5138
- var cp2 = this.source.charCodeAt(i);
5139
- if (cp2 >= 55296 && cp2 <= 56319) {
5167
+ var cp = this.source.charCodeAt(i);
5168
+ if (cp >= 55296 && cp <= 56319) {
5140
5169
  var second = this.source.charCodeAt(i + 1);
5141
5170
  if (second >= 56320 && second <= 57343) {
5142
- var first = cp2;
5143
- cp2 = (first - 55296) * 1024 + second - 56320 + 65536;
5171
+ var first = cp;
5172
+ cp = (first - 55296) * 1024 + second - 56320 + 65536;
5144
5173
  }
5145
5174
  }
5146
- return cp2;
5175
+ return cp;
5147
5176
  };
5148
5177
  Scanner2.prototype.scanHexEscape = function(prefix) {
5149
5178
  var len = prefix === "u" ? 4 : 2;
@@ -5195,11 +5224,11 @@ var require_esprima = __commonJS({
5195
5224
  return this.source.slice(start, this.index);
5196
5225
  };
5197
5226
  Scanner2.prototype.getComplexIdentifier = function() {
5198
- var cp2 = this.codePointAt(this.index);
5199
- var id = character_1.Character.fromCodePoint(cp2);
5227
+ var cp = this.codePointAt(this.index);
5228
+ var id = character_1.Character.fromCodePoint(cp);
5200
5229
  this.index += id.length;
5201
5230
  var ch;
5202
- if (cp2 === 92) {
5231
+ if (cp === 92) {
5203
5232
  if (this.source.charCodeAt(this.index) !== 117) {
5204
5233
  this.throwUnexpectedToken();
5205
5234
  }
@@ -5216,14 +5245,14 @@ var require_esprima = __commonJS({
5216
5245
  id = ch;
5217
5246
  }
5218
5247
  while (!this.eof()) {
5219
- cp2 = this.codePointAt(this.index);
5220
- if (!character_1.Character.isIdentifierPart(cp2)) {
5248
+ cp = this.codePointAt(this.index);
5249
+ if (!character_1.Character.isIdentifierPart(cp)) {
5221
5250
  break;
5222
5251
  }
5223
- ch = character_1.Character.fromCodePoint(cp2);
5252
+ ch = character_1.Character.fromCodePoint(cp);
5224
5253
  id += ch;
5225
5254
  this.index += ch.length;
5226
- if (cp2 === 92) {
5255
+ if (cp === 92) {
5227
5256
  id = id.substr(0, id.length - 1);
5228
5257
  if (this.source.charCodeAt(this.index) !== 117) {
5229
5258
  this.throwUnexpectedToken();
@@ -5849,29 +5878,29 @@ var require_esprima = __commonJS({
5849
5878
  end: this.index
5850
5879
  };
5851
5880
  }
5852
- var cp2 = this.source.charCodeAt(this.index);
5853
- if (character_1.Character.isIdentifierStart(cp2)) {
5881
+ var cp = this.source.charCodeAt(this.index);
5882
+ if (character_1.Character.isIdentifierStart(cp)) {
5854
5883
  return this.scanIdentifier();
5855
5884
  }
5856
- if (cp2 === 40 || cp2 === 41 || cp2 === 59) {
5885
+ if (cp === 40 || cp === 41 || cp === 59) {
5857
5886
  return this.scanPunctuator();
5858
5887
  }
5859
- if (cp2 === 39 || cp2 === 34) {
5888
+ if (cp === 39 || cp === 34) {
5860
5889
  return this.scanStringLiteral();
5861
5890
  }
5862
- if (cp2 === 46) {
5891
+ if (cp === 46) {
5863
5892
  if (character_1.Character.isDecimalDigit(this.source.charCodeAt(this.index + 1))) {
5864
5893
  return this.scanNumericLiteral();
5865
5894
  }
5866
5895
  return this.scanPunctuator();
5867
5896
  }
5868
- if (character_1.Character.isDecimalDigit(cp2)) {
5897
+ if (character_1.Character.isDecimalDigit(cp)) {
5869
5898
  return this.scanNumericLiteral();
5870
5899
  }
5871
- if (cp2 === 96 || cp2 === 125 && this.curlyStack[this.curlyStack.length - 1] === "${") {
5900
+ if (cp === 96 || cp === 125 && this.curlyStack[this.curlyStack.length - 1] === "${") {
5872
5901
  return this.scanTemplate();
5873
5902
  }
5874
- if (cp2 >= 55296 && cp2 < 57343) {
5903
+ if (cp >= 55296 && cp < 57343) {
5875
5904
  if (character_1.Character.isIdentifierStart(this.codePointAt(this.index))) {
5876
5905
  return this.scanIdentifier();
5877
5906
  }
@@ -7944,10 +7973,10 @@ var require_stringify = __commonJS({
7944
7973
  replacer = null;
7945
7974
  indent = EMPTY;
7946
7975
  }, "clean");
7947
- var join5 = /* @__PURE__ */ __name((one, two, gap) => one ? two ? one + two.trim() + LF + gap : one.trimRight() + LF + gap : two ? two.trimRight() + LF + gap : EMPTY, "join");
7976
+ var join2 = /* @__PURE__ */ __name((one, two, gap) => one ? two ? one + two.trim() + LF + gap : one.trimRight() + LF + gap : two ? two.trimRight() + LF + gap : EMPTY, "join");
7948
7977
  var join_content = /* @__PURE__ */ __name((inside, value, gap) => {
7949
7978
  const comment = process_comments(value, PREFIX_BEFORE, gap + indent, true);
7950
- return join5(comment, inside, gap);
7979
+ return join2(comment, inside, gap);
7951
7980
  }, "join_content");
7952
7981
  var array_stringify = /* @__PURE__ */ __name((value, gap) => {
7953
7982
  const deeper_gap = gap + indent;
@@ -7958,7 +7987,7 @@ var require_stringify = __commonJS({
7958
7987
  if (i !== 0) {
7959
7988
  inside += COMMA;
7960
7989
  }
7961
- const before = join5(
7990
+ const before = join2(
7962
7991
  after_comma,
7963
7992
  process_comments(value, BEFORE(i), deeper_gap),
7964
7993
  deeper_gap
@@ -7968,7 +7997,7 @@ var require_stringify = __commonJS({
7968
7997
  inside += process_comments(value, AFTER_VALUE(i), deeper_gap);
7969
7998
  after_comma = process_comments(value, AFTER(i), deeper_gap);
7970
7999
  }
7971
- inside += join5(
8000
+ inside += join2(
7972
8001
  after_comma,
7973
8002
  process_comments(value, PREFIX_AFTER, deeper_gap),
7974
8003
  deeper_gap
@@ -7993,7 +8022,7 @@ var require_stringify = __commonJS({
7993
8022
  inside += COMMA;
7994
8023
  }
7995
8024
  first = false;
7996
- const before = join5(
8025
+ const before = join2(
7997
8026
  after_comma,
7998
8027
  process_comments(value, BEFORE(key), deeper_gap),
7999
8028
  deeper_gap
@@ -8003,7 +8032,7 @@ var require_stringify = __commonJS({
8003
8032
  after_comma = process_comments(value, AFTER(key), deeper_gap);
8004
8033
  }, "iteratee");
8005
8034
  keys.forEach(iteratee);
8006
- inside += join5(
8035
+ inside += join2(
8007
8036
  after_comma,
8008
8037
  process_comments(value, PREFIX_AFTER, deeper_gap),
8009
8038
  deeper_gap
@@ -8083,1466 +8112,12 @@ var require_src2 = __commonJS({
8083
8112
  }
8084
8113
  });
8085
8114
 
8086
- // src/cli/detect.ts
8087
- import { existsSync as existsSync2 } from "node:fs";
8088
- import { resolve as resolve3 } from "node:path";
8089
- import { HandledError, commandLog, getProjectRoot as getProjectRoot2 } from "storybook/internal/common";
8090
- import { logger as logger2 } from "storybook/internal/node-logger";
8091
- var import_prompts = __toESM(require_prompts(), 1);
8092
- import semver from "semver";
8093
-
8094
- // src/cli/helpers.ts
8095
- import { cpSync, existsSync, readFileSync, writeFileSync } from "node:fs";
8096
- import { cp, readFile as readFile2, writeFile } from "node:fs/promises";
8097
- import { join as join3, resolve as resolve2 } from "node:path";
8098
- import {
8099
- frameworkToRenderer,
8100
- getProjectRoot
8101
- } from "storybook/internal/common";
8102
- import { logger } from "storybook/internal/node-logger";
8103
- var import_picocolors = __toESM(require_picocolors(), 1);
8104
- import { coerce, satisfies } from "semver";
8105
-
8106
- // ../node_modules/strip-json-comments/index.js
8107
- var singleComment = Symbol("singleComment");
8108
- var multiComment = Symbol("multiComment");
8109
- var stripWithoutWhitespace = /* @__PURE__ */ __name(() => "", "stripWithoutWhitespace");
8110
- var stripWithWhitespace = /* @__PURE__ */ __name((string, start, end) => string.slice(start, end).replace(/[^ \t\r\n]/g, " "), "stripWithWhitespace");
8111
- var isEscaped = /* @__PURE__ */ __name((jsonString, quotePosition) => {
8112
- let index = quotePosition - 1;
8113
- let backslashCount = 0;
8114
- while (jsonString[index] === "\\") {
8115
- index -= 1;
8116
- backslashCount += 1;
8117
- }
8118
- return Boolean(backslashCount % 2);
8119
- }, "isEscaped");
8120
- function stripJsonComments(jsonString, { whitespace = true, trailingCommas = false } = {}) {
8121
- if (typeof jsonString !== "string") {
8122
- throw new TypeError(`Expected argument \`jsonString\` to be a \`string\`, got \`${typeof jsonString}\``);
8123
- }
8124
- const strip = whitespace ? stripWithWhitespace : stripWithoutWhitespace;
8125
- let isInsideString = false;
8126
- let isInsideComment = false;
8127
- let offset = 0;
8128
- let buffer = "";
8129
- let result = "";
8130
- let commaIndex = -1;
8131
- for (let index = 0; index < jsonString.length; index++) {
8132
- const currentCharacter = jsonString[index];
8133
- const nextCharacter = jsonString[index + 1];
8134
- if (!isInsideComment && currentCharacter === '"') {
8135
- const escaped = isEscaped(jsonString, index);
8136
- if (!escaped) {
8137
- isInsideString = !isInsideString;
8138
- }
8139
- }
8140
- if (isInsideString) {
8141
- continue;
8142
- }
8143
- if (!isInsideComment && currentCharacter + nextCharacter === "//") {
8144
- buffer += jsonString.slice(offset, index);
8145
- offset = index;
8146
- isInsideComment = singleComment;
8147
- index++;
8148
- } else if (isInsideComment === singleComment && currentCharacter + nextCharacter === "\r\n") {
8149
- index++;
8150
- isInsideComment = false;
8151
- buffer += strip(jsonString, offset, index);
8152
- offset = index;
8153
- continue;
8154
- } else if (isInsideComment === singleComment && currentCharacter === "\n") {
8155
- isInsideComment = false;
8156
- buffer += strip(jsonString, offset, index);
8157
- offset = index;
8158
- } else if (!isInsideComment && currentCharacter + nextCharacter === "/*") {
8159
- buffer += jsonString.slice(offset, index);
8160
- offset = index;
8161
- isInsideComment = multiComment;
8162
- index++;
8163
- continue;
8164
- } else if (isInsideComment === multiComment && currentCharacter + nextCharacter === "*/") {
8165
- index++;
8166
- isInsideComment = false;
8167
- buffer += strip(jsonString, offset, index + 1);
8168
- offset = index + 1;
8169
- continue;
8170
- } else if (trailingCommas && !isInsideComment) {
8171
- if (commaIndex !== -1) {
8172
- if (currentCharacter === "}" || currentCharacter === "]") {
8173
- buffer += jsonString.slice(offset, index);
8174
- result += strip(buffer, 0, 1) + buffer.slice(1);
8175
- buffer = "";
8176
- offset = index;
8177
- commaIndex = -1;
8178
- } else if (currentCharacter !== " " && currentCharacter !== " " && currentCharacter !== "\r" && currentCharacter !== "\n") {
8179
- buffer += jsonString.slice(offset, index);
8180
- offset = index;
8181
- commaIndex = -1;
8182
- }
8183
- } else if (currentCharacter === ",") {
8184
- result += buffer + jsonString.slice(offset, index);
8185
- buffer = "";
8186
- offset = index;
8187
- commaIndex = index;
8188
- }
8189
- }
8190
- }
8191
- const remaining = isInsideComment === singleComment ? strip(jsonString, offset) : jsonString.slice(offset);
8192
- return result + buffer + remaining;
8193
- }
8194
- __name(stripJsonComments, "stripJsonComments");
8195
-
8196
- // src/cli/dirs.ts
8197
- import { join as join2 } from "node:path";
8198
- import { Readable as Readable2 } from "node:stream";
8199
- import { pipeline as pipeline2 } from "node:stream/promises";
8200
- import { createGunzip } from "node:zlib";
8201
- import { temporaryDirectory, versions } from "storybook/internal/common";
8202
-
8203
- // ../node_modules/get-npm-tarball-url/lib/index.mjs
8204
- function src_default(pkgName, pkgVersion, opts) {
8205
- let registry;
8206
- if (opts == null ? void 0 : opts.registry) {
8207
- registry = opts.registry.endsWith("/") ? opts.registry : `${opts.registry}/`;
8208
- } else {
8209
- registry = "https://registry.npmjs.org/";
8210
- }
8211
- const scopelessName = getScopelessName(pkgName);
8212
- return `${registry}${pkgName}/-/${scopelessName}-${removeBuildMetadataFromVersion(pkgVersion)}.tgz`;
8213
- }
8214
- __name(src_default, "src_default");
8215
- function removeBuildMetadataFromVersion(version) {
8216
- const plusPos = version.indexOf("+");
8217
- if (plusPos === -1)
8218
- return version;
8219
- return version.substring(0, plusPos);
8220
- }
8221
- __name(removeBuildMetadataFromVersion, "removeBuildMetadataFromVersion");
8222
- function getScopelessName(name) {
8223
- if (name[0] !== "@") {
8224
- return name;
8225
- }
8226
- return name.split("/")[1];
8227
- }
8228
- __name(getScopelessName, "getScopelessName");
8229
-
8230
- // ../node_modules/modern-tar/dist/unpacker-BKKRRs7i.js
8231
- var BLOCK_SIZE = 512;
8232
- var BLOCK_SIZE_MASK = 511;
8233
- var USTAR_NAME_OFFSET = 0;
8234
- var USTAR_NAME_SIZE = 100;
8235
- var USTAR_MODE_OFFSET = 100;
8236
- var USTAR_MODE_SIZE = 8;
8237
- var USTAR_UID_OFFSET = 108;
8238
- var USTAR_UID_SIZE = 8;
8239
- var USTAR_GID_OFFSET = 116;
8240
- var USTAR_GID_SIZE = 8;
8241
- var USTAR_SIZE_OFFSET = 124;
8242
- var USTAR_SIZE_SIZE = 12;
8243
- var USTAR_MTIME_OFFSET = 136;
8244
- var USTAR_MTIME_SIZE = 12;
8245
- var USTAR_CHECKSUM_OFFSET = 148;
8246
- var USTAR_CHECKSUM_SIZE = 8;
8247
- var USTAR_TYPEFLAG_OFFSET = 156;
8248
- var USTAR_TYPEFLAG_SIZE = 1;
8249
- var USTAR_LINKNAME_OFFSET = 157;
8250
- var USTAR_LINKNAME_SIZE = 100;
8251
- var USTAR_MAGIC_OFFSET = 257;
8252
- var USTAR_MAGIC_SIZE = 6;
8253
- var USTAR_UNAME_OFFSET = 265;
8254
- var USTAR_UNAME_SIZE = 32;
8255
- var USTAR_GNAME_OFFSET = 297;
8256
- var USTAR_GNAME_SIZE = 32;
8257
- var USTAR_PREFIX_OFFSET = 345;
8258
- var USTAR_PREFIX_SIZE = 155;
8259
- var FLAGTYPE = {
8260
- "0": "file",
8261
- "1": "link",
8262
- "2": "symlink",
8263
- "3": "character-device",
8264
- "4": "block-device",
8265
- "5": "directory",
8266
- "6": "fifo",
8267
- x: "pax-header",
8268
- g: "pax-global-header",
8269
- L: "gnu-long-name",
8270
- K: "gnu-long-link-name"
8271
- };
8272
- var ZERO_BLOCK = new Uint8Array(BLOCK_SIZE);
8273
- var encoder = new TextEncoder();
8274
- var decoder = new TextDecoder();
8275
- function readString(view, offset, size) {
8276
- const end = view.indexOf(0, offset);
8277
- const sliceEnd = end === -1 || end > offset + size ? offset + size : end;
8278
- return decoder.decode(view.subarray(offset, sliceEnd));
8279
- }
8280
- __name(readString, "readString");
8281
- function readOctal(view, offset, size) {
8282
- let value = 0;
8283
- const end = offset + size;
8284
- for (let i = offset; i < end; i++) {
8285
- const charCode = view[i];
8286
- if (charCode === 0) break;
8287
- if (charCode === 32) continue;
8288
- value = (value << 3) + (charCode - 48);
8289
- }
8290
- return value;
8291
- }
8292
- __name(readOctal, "readOctal");
8293
- function readNumeric(view, offset, size) {
8294
- if (view[offset] & 128) {
8295
- let result = 0;
8296
- result = view[offset] & 127;
8297
- for (let i = 1; i < size; i++) result = result * 256 + view[offset + i];
8298
- if (!Number.isSafeInteger(result)) throw new Error("TAR number too large");
8299
- return result;
8300
- }
8301
- return readOctal(view, offset, size);
8302
- }
8303
- __name(readNumeric, "readNumeric");
8304
- var CHECKSUM_SPACE = 32;
8305
- function validateChecksum(block) {
8306
- const stored = readOctal(block, USTAR_CHECKSUM_OFFSET, USTAR_CHECKSUM_SIZE);
8307
- let sum = 0;
8308
- for (let i = 0; i < block.length; i++) if (i >= USTAR_CHECKSUM_OFFSET && i < USTAR_CHECKSUM_OFFSET + USTAR_CHECKSUM_SIZE) sum += CHECKSUM_SPACE;
8309
- else sum += block[i];
8310
- return stored === sum;
8311
- }
8312
- __name(validateChecksum, "validateChecksum");
8313
- function parseUstarHeader(block, strict) {
8314
- if (strict && !validateChecksum(block)) throw new Error("Invalid tar header checksum.");
8315
- const typeflag = readString(block, USTAR_TYPEFLAG_OFFSET, USTAR_TYPEFLAG_SIZE);
8316
- const header = {
8317
- name: readString(block, USTAR_NAME_OFFSET, USTAR_NAME_SIZE),
8318
- mode: readOctal(block, USTAR_MODE_OFFSET, USTAR_MODE_SIZE),
8319
- uid: readNumeric(block, USTAR_UID_OFFSET, USTAR_UID_SIZE),
8320
- gid: readNumeric(block, USTAR_GID_OFFSET, USTAR_GID_SIZE),
8321
- size: readNumeric(block, USTAR_SIZE_OFFSET, USTAR_SIZE_SIZE),
8322
- mtime: new Date(readNumeric(block, USTAR_MTIME_OFFSET, USTAR_MTIME_SIZE) * 1e3),
8323
- type: FLAGTYPE[typeflag] || "file",
8324
- linkname: readString(block, USTAR_LINKNAME_OFFSET, USTAR_LINKNAME_SIZE)
8325
- };
8326
- const magic = readString(block, USTAR_MAGIC_OFFSET, USTAR_MAGIC_SIZE);
8327
- if (magic.trim() === "ustar") {
8328
- header.uname = readString(block, USTAR_UNAME_OFFSET, USTAR_UNAME_SIZE);
8329
- header.gname = readString(block, USTAR_GNAME_OFFSET, USTAR_GNAME_SIZE);
8330
- }
8331
- if (magic === "ustar") header.prefix = readString(block, USTAR_PREFIX_OFFSET, USTAR_PREFIX_SIZE);
8332
- return header;
8333
- }
8334
- __name(parseUstarHeader, "parseUstarHeader");
8335
- var PAX_MAPPING = {
8336
- path: ["name", (v) => v],
8337
- linkpath: ["linkname", (v) => v],
8338
- size: ["size", (v) => parseInt(v, 10)],
8339
- mtime: ["mtime", parseFloat],
8340
- uid: ["uid", (v) => parseInt(v, 10)],
8341
- gid: ["gid", (v) => parseInt(v, 10)],
8342
- uname: ["uname", (v) => v],
8343
- gname: ["gname", (v) => v]
8344
- };
8345
- function parsePax(buffer) {
8346
- const decoder$1 = new TextDecoder("utf-8");
8347
- const overrides = {};
8348
- const pax = {};
8349
- let offset = 0;
8350
- while (offset < buffer.length) {
8351
- const spaceIndex = buffer.indexOf(32, offset);
8352
- if (spaceIndex === -1) break;
8353
- const length = parseInt(decoder$1.decode(buffer.subarray(offset, spaceIndex)), 10);
8354
- if (Number.isNaN(length) || length === 0) break;
8355
- const recordEnd = offset + length;
8356
- const [key, value] = decoder$1.decode(buffer.subarray(spaceIndex + 1, recordEnd - 1)).split("=", 2);
8357
- if (key && value !== void 0) {
8358
- pax[key] = value;
8359
- const mapping = PAX_MAPPING[key];
8360
- if (mapping) {
8361
- const [targetKey, parser] = mapping;
8362
- const parsedValue = parser(value);
8363
- if (typeof parsedValue === "string" || !Number.isNaN(parsedValue)) overrides[targetKey] = parsedValue;
8364
- }
8365
- }
8366
- offset = recordEnd;
8367
- }
8368
- if (Object.keys(pax).length > 0) overrides.pax = pax;
8369
- return overrides;
8370
- }
8371
- __name(parsePax, "parsePax");
8372
- function applyOverrides(header, overrides) {
8373
- if (overrides.name !== void 0) header.name = overrides.name;
8374
- if (overrides.linkname !== void 0) header.linkname = overrides.linkname;
8375
- if (overrides.size !== void 0) header.size = overrides.size;
8376
- if (overrides.mtime !== void 0) header.mtime = new Date(overrides.mtime * 1e3);
8377
- if (overrides.uid !== void 0) header.uid = overrides.uid;
8378
- if (overrides.gid !== void 0) header.gid = overrides.gid;
8379
- if (overrides.uname !== void 0) header.uname = overrides.uname;
8380
- if (overrides.gname !== void 0) header.gname = overrides.gname;
8381
- if (overrides.pax) header.pax = Object.assign({}, header.pax ?? {}, overrides.pax);
8382
- }
8383
- __name(applyOverrides, "applyOverrides");
8384
- function getMetaParser(type) {
8385
- switch (type) {
8386
- case "pax-global-header":
8387
- case "pax-header":
8388
- return parsePax;
8389
- case "gnu-long-name":
8390
- return (data) => ({ name: readString(data, 0, data.length) });
8391
- case "gnu-long-link-name":
8392
- return (data) => ({ linkname: readString(data, 0, data.length) });
8393
- default:
8394
- return;
8395
- }
8396
- }
8397
- __name(getMetaParser, "getMetaParser");
8398
- var EOF_BUFFER = new Uint8Array(BLOCK_SIZE * 2);
8399
- function transformHeader(header, options) {
8400
- const { strip, filter, map } = options;
8401
- if (!strip && !filter && !map) return header;
8402
- const h = { ...header };
8403
- if (strip && strip > 0) {
8404
- const components = h.name.split("/").filter(Boolean);
8405
- if (strip >= components.length) return null;
8406
- const newName = components.slice(strip).join("/");
8407
- h.name = h.type === "directory" && !newName.endsWith("/") ? `${newName}/` : newName;
8408
- if (h.linkname?.startsWith("/")) {
8409
- const linkComponents = h.linkname.split("/").filter(Boolean);
8410
- h.linkname = strip >= linkComponents.length ? "/" : `/${linkComponents.slice(strip).join("/")}`;
8411
- }
8412
- }
8413
- if (filter?.(h) === false) return null;
8414
- const result = map ? map(h) : h;
8415
- if (result && (!result.name || !result.name.trim() || result.name === "." || result.name === "/")) return null;
8416
- return result;
8417
- }
8418
- __name(transformHeader, "transformHeader");
8419
- var STATE_HEADER = 0;
8420
- var STATE_BODY = 1;
8421
- var STATE_PADDING = 2;
8422
- var STATE_AWAIT_EOF = 3;
8423
- function createTarUnpacker(handler, options = {}) {
8424
- const strict = options.strict ?? false;
8425
- const chunkQueue = [];
8426
- let totalAvailable = 0;
8427
- let state = STATE_HEADER;
8428
- let waitingForData = false;
8429
- let currentEntry = null;
8430
- const paxGlobals = {};
8431
- let nextEntryOverrides = {};
8432
- function consume(size, callback) {
8433
- let remaining = Math.min(size, totalAvailable);
8434
- const initialRemaining = remaining;
8435
- while (remaining > 0 && chunkQueue.length > 0) {
8436
- const chunkNode = chunkQueue[0];
8437
- const available = chunkNode.data.length - chunkNode.consumed;
8438
- const toProcess = Math.min(remaining, available);
8439
- if (callback) callback(chunkNode.data.subarray(chunkNode.consumed, chunkNode.consumed + toProcess));
8440
- chunkNode.consumed += toProcess;
8441
- remaining -= toProcess;
8442
- if (chunkNode.consumed >= chunkNode.data.length) chunkQueue.shift();
8443
- }
8444
- totalAvailable -= initialRemaining - remaining;
8445
- return initialRemaining - remaining;
8446
- }
8447
- __name(consume, "consume");
8448
- function read(size) {
8449
- const toRead = Math.min(size, totalAvailable);
8450
- if (toRead === 0) return null;
8451
- const chunk = chunkQueue[0];
8452
- if (chunk) {
8453
- if (chunk.data.length - chunk.consumed >= toRead) {
8454
- const result$1 = chunk.data.subarray(chunk.consumed, chunk.consumed + toRead);
8455
- chunk.consumed += toRead;
8456
- totalAvailable -= toRead;
8457
- if (chunk.consumed >= chunk.data.length) chunkQueue.shift();
8458
- return result$1;
8459
- }
8460
- }
8461
- const result = new Uint8Array(toRead);
8462
- let offset = 0;
8463
- consume(toRead, (data) => {
8464
- result.set(data, offset);
8465
- offset += data.length;
8466
- });
8467
- return result;
8468
- }
8469
- __name(read, "read");
8470
- function process2() {
8471
- while (true) switch (state) {
8472
- case STATE_HEADER: {
8473
- if (totalAvailable < BLOCK_SIZE) {
8474
- waitingForData = true;
8475
- return;
8476
- }
8477
- const headerBlock = read(BLOCK_SIZE);
8478
- if (!headerBlock) {
8479
- waitingForData = true;
8480
- return;
8481
- }
8482
- if (isZeroBlock(headerBlock)) {
8483
- state = STATE_AWAIT_EOF;
8484
- continue;
8485
- }
8486
- waitingForData = false;
8487
- try {
8488
- const internalHeader = parseUstarHeader(headerBlock, strict);
8489
- const header = {
8490
- ...internalHeader,
8491
- name: internalHeader.name
8492
- };
8493
- const metaParser = getMetaParser(header.type);
8494
- if (metaParser) {
8495
- const paddedSize = header.size + BLOCK_SIZE_MASK & ~BLOCK_SIZE_MASK;
8496
- if (totalAvailable < paddedSize) {
8497
- waitingForData = true;
8498
- chunkQueue.unshift({
8499
- data: headerBlock,
8500
- consumed: 0
8501
- });
8502
- totalAvailable += BLOCK_SIZE;
8503
- return;
8504
- }
8505
- const metaBlock = read(paddedSize);
8506
- if (!metaBlock) {
8507
- waitingForData = true;
8508
- return;
8509
- }
8510
- const overrides = metaParser(metaBlock.subarray(0, header.size));
8511
- if (header.type === "pax-global-header") Object.assign(paxGlobals, overrides);
8512
- else Object.assign(nextEntryOverrides, overrides);
8513
- continue;
8514
- }
8515
- if (internalHeader.prefix) header.name = `${internalHeader.prefix}/${header.name}`;
8516
- applyOverrides(header, paxGlobals);
8517
- applyOverrides(header, nextEntryOverrides);
8518
- nextEntryOverrides = {};
8519
- handler.onHeader(header);
8520
- if (header.size > 0) {
8521
- currentEntry = {
8522
- remaining: header.size,
8523
- padding: -header.size & BLOCK_SIZE_MASK
8524
- };
8525
- state = STATE_BODY;
8526
- } else handler.onEndEntry();
8527
- } catch (error) {
8528
- handler.onError(error);
8529
- return;
8530
- }
8531
- continue;
8532
- }
8533
- case STATE_BODY: {
8534
- if (!currentEntry) throw new Error("No current entry for body");
8535
- const toForward = Math.min(currentEntry.remaining, totalAvailable);
8536
- if (toForward > 0) {
8537
- const consumed = consume(toForward, handler.onData);
8538
- currentEntry.remaining -= consumed;
8539
- }
8540
- if (currentEntry.remaining === 0) {
8541
- state = currentEntry.padding > 0 ? STATE_PADDING : STATE_HEADER;
8542
- if (state === STATE_HEADER) {
8543
- handler.onEndEntry();
8544
- currentEntry = null;
8545
- }
8546
- } else if (totalAvailable === 0) {
8547
- waitingForData = true;
8548
- return;
8549
- }
8550
- continue;
8551
- }
8552
- case STATE_PADDING:
8553
- if (!currentEntry) throw new Error("No current entry for padding");
8554
- if (totalAvailable < currentEntry.padding) {
8555
- waitingForData = true;
8556
- return;
8557
- }
8558
- if (currentEntry.padding > 0) consume(currentEntry.padding);
8559
- handler.onEndEntry();
8560
- currentEntry = null;
8561
- state = STATE_HEADER;
8562
- continue;
8563
- case STATE_AWAIT_EOF: {
8564
- if (totalAvailable < BLOCK_SIZE) {
8565
- waitingForData = true;
8566
- return;
8567
- }
8568
- const secondBlock = read(BLOCK_SIZE);
8569
- if (!secondBlock) {
8570
- waitingForData = true;
8571
- return;
8572
- }
8573
- if (isZeroBlock(secondBlock)) return;
8574
- if (strict) {
8575
- handler.onError(new Error("Invalid EOF"));
8576
- return;
8577
- }
8578
- chunkQueue.unshift({
8579
- data: secondBlock,
8580
- consumed: 0
8581
- });
8582
- totalAvailable += BLOCK_SIZE;
8583
- state = STATE_HEADER;
8584
- continue;
8585
- }
8586
- default:
8587
- throw new Error("Invalid state in tar unpacker.");
8588
- }
8589
- }
8590
- __name(process2, "process");
8591
- return {
8592
- write(chunk) {
8593
- if (chunk.length === 0) return;
8594
- chunkQueue.push({
8595
- data: chunk,
8596
- consumed: 0
8597
- });
8598
- totalAvailable += chunk.length;
8599
- if (waitingForData) {
8600
- waitingForData = false;
8601
- try {
8602
- process2();
8603
- } catch (error) {
8604
- handler.onError(error);
8605
- }
8606
- }
8607
- },
8608
- end() {
8609
- try {
8610
- if (!waitingForData) process2();
8611
- if (strict) {
8612
- if (currentEntry && currentEntry.remaining > 0) {
8613
- const error = new Error("Tar archive is truncated.");
8614
- handler.onError(error);
8615
- throw error;
8616
- }
8617
- if (totalAvailable > 0) {
8618
- if (read(totalAvailable)?.some((b) => b !== 0)) {
8619
- const error = new Error("Invalid EOF.");
8620
- handler.onError(error);
8621
- throw error;
8622
- }
8623
- }
8624
- if (waitingForData) {
8625
- const error = new Error("Tar archive is truncated.");
8626
- handler.onError(error);
8627
- throw error;
8628
- }
8629
- } else if (currentEntry) {
8630
- handler.onEndEntry();
8631
- currentEntry = null;
8632
- }
8633
- } catch (error) {
8634
- handler.onError(error);
8635
- }
8636
- }
8637
- };
8638
- }
8639
- __name(createTarUnpacker, "createTarUnpacker");
8640
- function isZeroBlock(block) {
8641
- if (block.byteOffset % 8 === 0) {
8642
- const view = new BigUint64Array(block.buffer, block.byteOffset, block.length / 8);
8643
- for (let i = 0; i < view.length; i++) if (view[i] !== 0n) return false;
8644
- return true;
8645
- }
8646
- for (let i = 0; i < block.length; i++) if (block[i] !== 0) return false;
8647
- return true;
8648
- }
8649
- __name(isZeroBlock, "isZeroBlock");
8650
-
8651
- // ../node_modules/modern-tar/dist/fs/index.js
8652
- import * as fs from "node:fs/promises";
8653
- import { cpus } from "node:os";
8654
- import * as path from "node:path";
8655
- import { PassThrough, Readable, Writable } from "node:stream";
8656
- import { createWriteStream } from "node:fs";
8657
- import { pipeline } from "node:stream/promises";
8658
- var unicodeCache = /* @__PURE__ */ new Map();
8659
- var normalizeUnicode = /* @__PURE__ */ __name((s) => {
8660
- let result = unicodeCache.get(s);
8661
- if (result !== void 0) unicodeCache.delete(s);
8662
- result = result ?? s.normalize("NFD");
8663
- unicodeCache.set(s, result);
8664
- if (unicodeCache.size > 1e4) unicodeCache.delete(unicodeCache.keys().next().value);
8665
- return result;
8666
- }, "normalizeUnicode");
8667
- function validateBounds(targetPath, destDir, errorMessage) {
8668
- const target = normalizeUnicode(path.resolve(targetPath));
8669
- const dest = path.resolve(destDir);
8670
- if (target !== dest && !target.startsWith(dest + path.sep)) throw new Error(errorMessage);
8671
- }
8672
- __name(validateBounds, "validateBounds");
8673
- var win32Reserved = {
8674
- ":": "\uF03A",
8675
- "<": "\uF03C",
8676
- ">": "\uF03E",
8677
- "|": "\uF07C",
8678
- "?": "\uF03F",
8679
- "*": "\uF02A",
8680
- '"': "\uF022"
8681
- };
8682
- function normalizeName(name) {
8683
- const path$1 = name.replace(/\\/g, "/");
8684
- if (path$1.split("/").includes("..") || /^[a-zA-Z]:\.\./.test(path$1)) throw new Error(`${name} points outside extraction directory`);
8685
- let relative = path$1;
8686
- if (/^[a-zA-Z]:/.test(relative)) relative = relative.replace(/^[a-zA-Z]:[/\\]?/, "");
8687
- else if (relative.startsWith("/")) relative = relative.replace(/^\/+/, "");
8688
- if (process.platform === "win32") return relative.replace(/[<>:"|?*]/g, (char) => win32Reserved[char]);
8689
- return relative;
8690
- }
8691
- __name(normalizeName, "normalizeName");
8692
- var normalizeHeaderName = /* @__PURE__ */ __name((s) => normalizeUnicode(normalizeName(s.replace(/\/+$/, ""))), "normalizeHeaderName");
8693
- function unpackTar(directoryPath, options = {}) {
8694
- const { streamTimeout = 5e3, ...fsOptions } = options;
8695
- let timeoutId = null;
8696
- const { handler, signal } = createFSHandler(directoryPath, fsOptions);
8697
- const unpacker = createTarUnpacker(handler, fsOptions);
8698
- let stream;
8699
- function resetTimeout() {
8700
- if (timeoutId) clearTimeout(timeoutId);
8701
- if (streamTimeout !== Infinity && streamTimeout > 0) timeoutId = setTimeout(() => {
8702
- const err = new Error(`Stream timed out after ${streamTimeout}ms of inactivity.`);
8703
- stream.destroy(err);
8704
- }, streamTimeout);
8705
- }
8706
- __name(resetTimeout, "resetTimeout");
8707
- stream = new Writable({
8708
- write(chunk, _, callback) {
8709
- resetTimeout();
8710
- if (signal.aborted) return callback(signal.reason);
8711
- try {
8712
- unpacker.write(chunk);
8713
- callback();
8714
- } catch (writeErr) {
8715
- callback(writeErr);
8716
- }
8717
- },
8718
- async final(callback) {
8719
- if (timeoutId) clearTimeout(timeoutId);
8720
- try {
8721
- if (signal.aborted) return callback(signal.reason);
8722
- unpacker.end();
8723
- await handler.process();
8724
- callback();
8725
- } catch (finalErr) {
8726
- callback(finalErr);
8727
- }
8728
- }
8729
- });
8730
- stream.on("close", () => {
8731
- if (timeoutId) clearTimeout(timeoutId);
8732
- });
8733
- resetTimeout();
8734
- return stream;
8735
- }
8736
- __name(unpackTar, "unpackTar");
8737
- function createFSHandler(directoryPath, options) {
8738
- const { maxDepth = 1024, dmode, fmode, concurrency = cpus().length || 8 } = options;
8739
- const abortController = new AbortController();
8740
- const { signal } = abortController;
8741
- const opQueue = [];
8742
- let activeOps = 0;
8743
- const pathPromises = /* @__PURE__ */ new Map();
8744
- let activeEntryStream = null;
8745
- let processingEnded = false;
8746
- let resolveDrain;
8747
- const drainPromise = new Promise((resolve4) => {
8748
- resolveDrain = resolve4;
8749
- });
8750
- const processQueue = /* @__PURE__ */ __name(() => {
8751
- if (signal.aborted) opQueue.length = 0;
8752
- while (activeOps < concurrency && opQueue.length > 0) {
8753
- activeOps++;
8754
- const op = opQueue.shift();
8755
- if (!op) break;
8756
- op();
8757
- }
8758
- if (processingEnded && activeOps === 0 && opQueue.length === 0) resolveDrain();
8759
- }, "processQueue");
8760
- const destDirPromise = (async () => {
8761
- const symbolic = normalizeUnicode(path.resolve(directoryPath));
8762
- await fs.mkdir(symbolic, { recursive: true });
8763
- try {
8764
- const real = await fs.realpath(symbolic);
8765
- return {
8766
- symbolic,
8767
- real
8768
- };
8769
- } catch (err) {
8770
- if (signal.aborted) throw signal.reason;
8771
- throw err;
8772
- }
8773
- })();
8774
- destDirPromise.catch((err) => {
8775
- if (!signal.aborted) abortController.abort(err);
8776
- });
8777
- const ensureDirectoryExists = /* @__PURE__ */ __name((dirPath) => {
8778
- let promise = pathPromises.get(dirPath);
8779
- if (promise) return promise;
8780
- promise = (async () => {
8781
- if (signal.aborted) throw signal.reason;
8782
- const destDir = await destDirPromise;
8783
- if (dirPath === destDir.symbolic) return "directory";
8784
- await ensureDirectoryExists(path.dirname(dirPath));
8785
- if (signal.aborted) throw signal.reason;
8786
- try {
8787
- const stat2 = await fs.lstat(dirPath);
8788
- if (stat2.isDirectory()) return "directory";
8789
- if (stat2.isSymbolicLink()) {
8790
- const realPath = await fs.realpath(dirPath);
8791
- validateBounds(realPath, destDir.real, `Symlink "${dirPath}" points outside the extraction directory.`);
8792
- if ((await fs.stat(realPath)).isDirectory()) return "directory";
8793
- }
8794
- throw new Error(`"${dirPath}" is not a valid directory component.`);
8795
- } catch (err) {
8796
- if (err.code === "ENOENT") {
8797
- await fs.mkdir(dirPath, { mode: dmode });
8798
- return "directory";
8799
- }
8800
- throw err;
8801
- }
8802
- })();
8803
- pathPromises.set(dirPath, promise);
8804
- return promise;
8805
- }, "ensureDirectoryExists");
8806
- return {
8807
- handler: {
8808
- onHeader(header) {
8809
- if (signal.aborted) return;
8810
- activeEntryStream = new PassThrough({ highWaterMark: header.size > 1048576 ? 524288 : void 0 });
8811
- const entryStream = activeEntryStream;
8812
- const startOperation = /* @__PURE__ */ __name(() => {
8813
- let opPromise;
8814
- try {
8815
- const transformed = transformHeader(header, options);
8816
- if (!transformed) {
8817
- entryStream.resume();
8818
- activeOps--;
8819
- processQueue();
8820
- return;
8821
- }
8822
- const name = normalizeHeaderName(transformed.name);
8823
- const target = path.join(path.resolve(directoryPath), name);
8824
- opPromise = (pathPromises.get(target) || Promise.resolve(void 0)).then(async (priorOp) => {
8825
- if (signal.aborted) throw signal.reason;
8826
- if (priorOp) {
8827
- if (priorOp === "directory" && transformed.type !== "directory" || priorOp !== "directory" && transformed.type === "directory") throw new Error(`Path conflict ${transformed.type} over existing ${priorOp} at "${transformed.name}"`);
8828
- }
8829
- try {
8830
- const destDir = await destDirPromise;
8831
- if (maxDepth !== Infinity && name.split("/").length > maxDepth) throw new Error("Tar exceeds max specified depth.");
8832
- const outPath = path.join(destDir.symbolic, name);
8833
- validateBounds(outPath, destDir.symbolic, `Entry "${transformed.name}" points outside the extraction directory.`);
8834
- const parentDir = path.dirname(outPath);
8835
- await ensureDirectoryExists(parentDir);
8836
- switch (transformed.type) {
8837
- case "directory":
8838
- await fs.mkdir(outPath, {
8839
- recursive: true,
8840
- mode: dmode ?? transformed.mode
8841
- });
8842
- break;
8843
- case "file": {
8844
- const fileStream = createWriteStream(outPath, {
8845
- mode: fmode ?? transformed.mode,
8846
- highWaterMark: transformed.size > 1048576 ? 524288 : void 0
8847
- });
8848
- await pipeline(entryStream, fileStream);
8849
- break;
8850
- }
8851
- case "symlink": {
8852
- const { linkname } = transformed;
8853
- if (!linkname) return transformed.type;
8854
- const target$1 = path.resolve(parentDir, linkname);
8855
- validateBounds(target$1, destDir.symbolic, `Symlink "${linkname}" points outside the extraction directory.`);
8856
- await fs.symlink(linkname, outPath);
8857
- break;
8858
- }
8859
- case "link": {
8860
- const { linkname } = transformed;
8861
- if (!linkname) return transformed.type;
8862
- const normalizedLink = normalizeUnicode(linkname);
8863
- if (path.isAbsolute(normalizedLink)) throw new Error(`Hardlink "${linkname}" points outside the extraction directory.`);
8864
- const linkTarget = path.join(destDir.symbolic, normalizedLink);
8865
- validateBounds(linkTarget, destDir.symbolic, `Hardlink "${linkname}" points outside the extraction directory.`);
8866
- await ensureDirectoryExists(path.dirname(linkTarget));
8867
- const realTargetParent = await fs.realpath(path.dirname(linkTarget));
8868
- const realLinkTarget = path.join(realTargetParent, path.basename(linkTarget));
8869
- validateBounds(realLinkTarget, destDir.real, `Hardlink "${linkname}" points outside the extraction directory.`);
8870
- if (linkTarget === outPath) return transformed.type;
8871
- const targetPromise = pathPromises.get(linkTarget);
8872
- if (targetPromise) await targetPromise;
8873
- await fs.link(linkTarget, outPath);
8874
- break;
8875
- }
8876
- default:
8877
- return transformed.type;
8878
- }
8879
- if (transformed.mtime) await (transformed.type === "symlink" ? fs.lutimes : fs.utimes)(outPath, transformed.mtime, transformed.mtime).catch(() => {
8880
- });
8881
- return transformed.type;
8882
- } finally {
8883
- if (!entryStream.readableEnded) entryStream.resume();
8884
- }
8885
- });
8886
- pathPromises.set(target, opPromise);
8887
- } catch (err) {
8888
- opPromise = Promise.reject(err);
8889
- abortController.abort(err);
8890
- }
8891
- opPromise.catch((err) => abortController.abort(err)).finally(() => {
8892
- activeOps--;
8893
- processQueue();
8894
- });
8895
- }, "startOperation");
8896
- opQueue.push(startOperation);
8897
- processQueue();
8898
- },
8899
- onData(chunk) {
8900
- if (!signal.aborted) activeEntryStream?.write(chunk);
8901
- },
8902
- onEndEntry() {
8903
- activeEntryStream?.end();
8904
- activeEntryStream = null;
8905
- },
8906
- onError(error) {
8907
- abortController.abort(error);
8908
- },
8909
- async process() {
8910
- processingEnded = true;
8911
- processQueue();
8912
- await drainPromise;
8913
- if (signal.aborted) throw signal.reason;
8914
- }
8915
- },
8916
- signal
8917
- };
8918
- }
8919
- __name(createFSHandler, "createFSHandler");
8920
-
8921
- // src/cli/project_types.ts
8922
- import { minVersion, validRange } from "semver";
8923
- function eqMajor(versionRange, major) {
8924
- if (validRange(versionRange)) {
8925
- return minVersion(versionRange)?.major === major;
8926
- }
8927
- return false;
8928
- }
8929
- __name(eqMajor, "eqMajor");
8930
- var externalFrameworks = [
8931
- { name: "qwik", packageName: "storybook-framework-qwik" },
8932
- {
8933
- name: "solid",
8934
- packageName: "storybook-solidjs-vite",
8935
- frameworks: ["storybook-solidjs-vite"],
8936
- renderer: "storybook-solidjs-vite"
8937
- },
8938
- {
8939
- name: "nuxt",
8940
- packageName: "@storybook-vue/nuxt",
8941
- frameworks: ["@storybook-vue/nuxt"],
8942
- renderer: "@storybook/vue3"
8943
- }
8944
- ];
8945
- var SUPPORTED_RENDERERS = [
8946
- "react",
8947
- "react-native",
8948
- "vue3",
8949
- "angular",
8950
- "ember",
8951
- "preact",
8952
- "svelte",
8953
- "qwik",
8954
- "solid"
8955
- ];
8956
- var ProjectType = /* @__PURE__ */ ((ProjectType2) => {
8957
- ProjectType2["UNDETECTED"] = "UNDETECTED";
8958
- ProjectType2["UNSUPPORTED"] = "UNSUPPORTED";
8959
- ProjectType2["REACT"] = "REACT";
8960
- ProjectType2["REACT_SCRIPTS"] = "REACT_SCRIPTS";
8961
- ProjectType2["REACT_NATIVE"] = "REACT_NATIVE";
8962
- ProjectType2["REACT_NATIVE_WEB"] = "REACT_NATIVE_WEB";
8963
- ProjectType2["REACT_NATIVE_AND_RNW"] = "REACT_NATIVE_AND_RNW";
8964
- ProjectType2["REACT_PROJECT"] = "REACT_PROJECT";
8965
- ProjectType2["WEBPACK_REACT"] = "WEBPACK_REACT";
8966
- ProjectType2["NEXTJS"] = "NEXTJS";
8967
- ProjectType2["VUE3"] = "VUE3";
8968
- ProjectType2["NUXT"] = "NUXT";
8969
- ProjectType2["ANGULAR"] = "ANGULAR";
8970
- ProjectType2["EMBER"] = "EMBER";
8971
- ProjectType2["WEB_COMPONENTS"] = "WEB_COMPONENTS";
8972
- ProjectType2["HTML"] = "HTML";
8973
- ProjectType2["QWIK"] = "QWIK";
8974
- ProjectType2["PREACT"] = "PREACT";
8975
- ProjectType2["SVELTE"] = "SVELTE";
8976
- ProjectType2["SVELTEKIT"] = "SVELTEKIT";
8977
- ProjectType2["SERVER"] = "SERVER";
8978
- ProjectType2["NX"] = "NX";
8979
- ProjectType2["SOLID"] = "SOLID";
8980
- return ProjectType2;
8981
- })(ProjectType || {});
8982
- var CoreBuilder = /* @__PURE__ */ ((CoreBuilder2) => {
8983
- CoreBuilder2["Webpack5"] = "webpack5";
8984
- CoreBuilder2["Vite"] = "vite";
8985
- return CoreBuilder2;
8986
- })(CoreBuilder || {});
8987
- var CoreWebpackCompilers = /* @__PURE__ */ ((CoreWebpackCompilers2) => {
8988
- CoreWebpackCompilers2["Babel"] = "babel";
8989
- CoreWebpackCompilers2["SWC"] = "swc";
8990
- return CoreWebpackCompilers2;
8991
- })(CoreWebpackCompilers || {});
8992
- var CommunityBuilder = /* @__PURE__ */ ((CommunityBuilder2) => {
8993
- CommunityBuilder2["Rsbuild"] = "rsbuild";
8994
- return CommunityBuilder2;
8995
- })(CommunityBuilder || {});
8996
- var compilerNameToCoreCompiler = {
8997
- "@storybook/addon-webpack5-compiler-babel": "babel" /* Babel */,
8998
- "@storybook/addon-webpack5-compiler-swc": "swc" /* SWC */
8999
- };
9000
- var builderNameToCoreBuilder = {
9001
- "@storybook/builder-webpack5": "webpack5" /* Webpack5 */,
9002
- "@storybook/builder-vite": "vite" /* Vite */
9003
- };
9004
- var SupportedLanguage = /* @__PURE__ */ ((SupportedLanguage2) => {
9005
- SupportedLanguage2["JAVASCRIPT"] = "javascript";
9006
- SupportedLanguage2["TYPESCRIPT"] = "typescript";
9007
- return SupportedLanguage2;
9008
- })(SupportedLanguage || {});
9009
- var supportedTemplates = [
9010
- {
9011
- preset: "NUXT" /* NUXT */,
9012
- dependencies: ["nuxt"],
9013
- matcherFunction: /* @__PURE__ */ __name(({ dependencies }) => {
9014
- return dependencies?.every(Boolean) ?? true;
9015
- }, "matcherFunction")
9016
- },
9017
- {
9018
- preset: "VUE3" /* VUE3 */,
9019
- dependencies: {
9020
- // This Vue template works with Vue 3
9021
- vue: /* @__PURE__ */ __name((versionRange) => versionRange === "next" || eqMajor(versionRange, 3), "vue")
9022
- },
9023
- matcherFunction: /* @__PURE__ */ __name(({ dependencies }) => {
9024
- return dependencies?.some(Boolean) ?? false;
9025
- }, "matcherFunction")
9026
- },
9027
- {
9028
- preset: "EMBER" /* EMBER */,
9029
- dependencies: ["ember-cli"],
9030
- matcherFunction: /* @__PURE__ */ __name(({ dependencies }) => {
9031
- return dependencies?.every(Boolean) ?? true;
9032
- }, "matcherFunction")
9033
- },
9034
- {
9035
- preset: "NEXTJS" /* NEXTJS */,
9036
- dependencies: ["next"],
9037
- matcherFunction: /* @__PURE__ */ __name(({ dependencies }) => {
9038
- return dependencies?.every(Boolean) ?? true;
9039
- }, "matcherFunction")
9040
- },
9041
- {
9042
- preset: "QWIK" /* QWIK */,
9043
- dependencies: ["@builder.io/qwik"],
9044
- matcherFunction: /* @__PURE__ */ __name(({ dependencies }) => {
9045
- return dependencies?.every(Boolean) ?? true;
9046
- }, "matcherFunction")
9047
- },
9048
- {
9049
- preset: "REACT_PROJECT" /* REACT_PROJECT */,
9050
- peerDependencies: ["react"],
9051
- matcherFunction: /* @__PURE__ */ __name(({ peerDependencies }) => {
9052
- return peerDependencies?.every(Boolean) ?? true;
9053
- }, "matcherFunction")
9054
- },
9055
- {
9056
- preset: "REACT_NATIVE" /* REACT_NATIVE */,
9057
- dependencies: ["react-native", "react-native-scripts"],
9058
- matcherFunction: /* @__PURE__ */ __name(({ dependencies }) => {
9059
- return dependencies?.some(Boolean) ?? false;
9060
- }, "matcherFunction")
9061
- },
9062
- {
9063
- preset: "REACT_SCRIPTS" /* REACT_SCRIPTS */,
9064
- // For projects using a custom/forked `react-scripts` package.
9065
- files: ["/node_modules/.bin/react-scripts"],
9066
- // For standard CRA projects
9067
- dependencies: ["react-scripts"],
9068
- matcherFunction: /* @__PURE__ */ __name(({ dependencies, files }) => {
9069
- return (dependencies?.every(Boolean) || files?.every(Boolean)) ?? false;
9070
- }, "matcherFunction")
9071
- },
9072
- {
9073
- preset: "ANGULAR" /* ANGULAR */,
9074
- dependencies: ["@angular/core"],
9075
- matcherFunction: /* @__PURE__ */ __name(({ dependencies }) => {
9076
- return dependencies?.every(Boolean) ?? true;
9077
- }, "matcherFunction")
9078
- },
9079
- {
9080
- preset: "WEB_COMPONENTS" /* WEB_COMPONENTS */,
9081
- dependencies: ["lit-element", "lit-html", "lit"],
9082
- matcherFunction: /* @__PURE__ */ __name(({ dependencies }) => {
9083
- return dependencies?.some(Boolean) ?? false;
9084
- }, "matcherFunction")
9085
- },
9086
- {
9087
- preset: "PREACT" /* PREACT */,
9088
- dependencies: ["preact"],
9089
- matcherFunction: /* @__PURE__ */ __name(({ dependencies }) => {
9090
- return dependencies?.every(Boolean) ?? true;
9091
- }, "matcherFunction")
9092
- },
9093
- {
9094
- // TODO: This only works because it is before the SVELTE template. could be more explicit
9095
- preset: "SVELTEKIT" /* SVELTEKIT */,
9096
- dependencies: ["@sveltejs/kit"],
9097
- matcherFunction: /* @__PURE__ */ __name(({ dependencies }) => {
9098
- return dependencies?.every(Boolean) ?? true;
9099
- }, "matcherFunction")
9100
- },
9101
- {
9102
- preset: "SVELTE" /* SVELTE */,
9103
- dependencies: ["svelte"],
9104
- matcherFunction: /* @__PURE__ */ __name(({ dependencies }) => {
9105
- return dependencies?.every(Boolean) ?? true;
9106
- }, "matcherFunction")
9107
- },
9108
- {
9109
- preset: "SOLID" /* SOLID */,
9110
- dependencies: ["solid-js"],
9111
- matcherFunction: /* @__PURE__ */ __name(({ dependencies }) => {
9112
- return dependencies?.every(Boolean) ?? true;
9113
- }, "matcherFunction")
9114
- },
9115
- // DO NOT MOVE ANY TEMPLATES BELOW THIS LINE
9116
- // React is part of every Template, after Storybook is initialized once
9117
- {
9118
- preset: "WEBPACK_REACT" /* WEBPACK_REACT */,
9119
- dependencies: ["react", "webpack"],
9120
- matcherFunction: /* @__PURE__ */ __name(({ dependencies }) => {
9121
- return dependencies?.every(Boolean) ?? true;
9122
- }, "matcherFunction")
9123
- },
9124
- {
9125
- preset: "REACT" /* REACT */,
9126
- dependencies: ["react"],
9127
- matcherFunction: /* @__PURE__ */ __name(({ dependencies }) => {
9128
- return dependencies?.every(Boolean) ?? true;
9129
- }, "matcherFunction")
9130
- }
9131
- ];
9132
- var unsupportedTemplate = {
9133
- preset: "UNSUPPORTED" /* UNSUPPORTED */,
9134
- dependencies: {},
9135
- matcherFunction: /* @__PURE__ */ __name(({ dependencies }) => {
9136
- return dependencies?.some(Boolean) ?? false;
9137
- }, "matcherFunction")
9138
- };
9139
- var notInstallableProjectTypes = [
9140
- "UNDETECTED" /* UNDETECTED */,
9141
- "UNSUPPORTED" /* UNSUPPORTED */,
9142
- "NX" /* NX */
9143
- ];
9144
- var installableProjectTypes = Object.values(ProjectType).filter((type) => !notInstallableProjectTypes.includes(type)).map((type) => type.toLowerCase());
9145
-
9146
- // src/cli/dirs.ts
9147
- var resolveUsingBranchInstall = /* @__PURE__ */ __name(async (packageManager, request) => {
9148
- const tempDirectory = await temporaryDirectory();
9149
- const name = request;
9150
- const version = versions[name] || await packageManager.latestVersion(request);
9151
- const getNpmTarballUrl = src_default.default || src_default;
9152
- const url = getNpmTarballUrl(request, version, {
9153
- registry: await packageManager.getRegistryURL()
9154
- });
9155
- const response = await fetch(url);
9156
- if (!response.ok || !response.body) {
9157
- throw new Error(`Failed to download tarball from ${url}`);
9158
- }
9159
- await pipeline2(
9160
- Readable2.fromWeb(response.body),
9161
- createGunzip(),
9162
- unpackTar(tempDirectory)
9163
- );
9164
- return join2(tempDirectory, "package");
9165
- }, "resolveUsingBranchInstall");
9166
- async function getRendererDir(packageManager, renderer) {
9167
- const externalFramework = externalFrameworks.find((framework) => framework.name === renderer);
9168
- const frameworkPackageName = externalFramework?.packageName || externalFramework?.renderer || `@storybook/${renderer}`;
9169
- const packageJsonPath = join2(frameworkPackageName, "package.json");
9170
- const errors = [];
9171
- try {
9172
- return resolvePackageDir(frameworkPackageName, process.cwd());
9173
- } catch (e) {
9174
- invariant(e instanceof Error);
9175
- errors.push(e);
9176
- }
9177
- try {
9178
- return await resolveUsingBranchInstall(packageManager, frameworkPackageName);
9179
- } catch (e) {
9180
- invariant(e instanceof Error);
9181
- errors.push(e);
9182
- }
9183
- throw new Error(`Cannot find ${packageJsonPath}, ${errors.map((e) => e.stack).join("\n\n")}`);
9184
- }
9185
- __name(getRendererDir, "getRendererDir");
9186
-
9187
- // src/cli/helpers.ts
9188
- function readFileAsJson(jsonPath, allowComments) {
9189
- const filePath = resolve2(jsonPath);
9190
- if (!existsSync(filePath)) {
9191
- return false;
9192
- }
9193
- const fileContent = readFileSync(filePath, "utf8");
9194
- const jsonContent = allowComments ? stripJsonComments(fileContent) : fileContent;
9195
- try {
9196
- return JSON.parse(jsonContent);
9197
- } catch (e) {
9198
- logger.error(import_picocolors.default.red(`Invalid json in file: ${filePath}`));
9199
- throw e;
9200
- }
9201
- }
9202
- __name(readFileAsJson, "readFileAsJson");
9203
- var writeFileAsJson = /* @__PURE__ */ __name((jsonPath, content) => {
9204
- const filePath = resolve2(jsonPath);
9205
- if (!existsSync(filePath)) {
9206
- return false;
9207
- }
9208
- writeFileSync(filePath, `${JSON.stringify(content, null, 2)}
9209
- `);
9210
- return true;
9211
- }, "writeFileAsJson");
9212
- async function getBabelDependencies(packageManager) {
9213
- const dependenciesToAdd = [];
9214
- let babelLoaderVersion = "^8.0.0-0";
9215
- const babelCoreVersion = packageManager.getDependencyVersion("babel-core");
9216
- if (!babelCoreVersion) {
9217
- if (!packageManager.getDependencyVersion("@babel/core")) {
9218
- const babelCoreInstallVersion = await packageManager.getVersion("@babel/core");
9219
- dependenciesToAdd.push(`@babel/core@${babelCoreInstallVersion}`);
9220
- }
9221
- } else {
9222
- const latestCompatibleBabelVersion = await packageManager.latestVersion(
9223
- "babel-core",
9224
- babelCoreVersion
9225
- );
9226
- if (latestCompatibleBabelVersion && satisfies(latestCompatibleBabelVersion, "^6.0.0")) {
9227
- babelLoaderVersion = "^7.0.0";
9228
- }
9229
- }
9230
- if (!packageManager.getDependencyVersion("babel-loader")) {
9231
- const babelLoaderInstallVersion = await packageManager.getVersion(
9232
- "babel-loader",
9233
- babelLoaderVersion
9234
- );
9235
- dependenciesToAdd.push(`babel-loader@${babelLoaderInstallVersion}`);
9236
- }
9237
- return dependenciesToAdd;
9238
- }
9239
- __name(getBabelDependencies, "getBabelDependencies");
9240
- function addToDevDependenciesIfNotPresent(packageJson, name, packageVersion) {
9241
- if (!packageJson.dependencies?.[name] && !packageJson.devDependencies?.[name]) {
9242
- if (packageJson.devDependencies) {
9243
- packageJson.devDependencies[name] = packageVersion;
9244
- } else {
9245
- packageJson.devDependencies = {
9246
- [name]: packageVersion
9247
- };
9248
- }
9249
- }
9250
- }
9251
- __name(addToDevDependenciesIfNotPresent, "addToDevDependenciesIfNotPresent");
9252
- function copyTemplate(templateRoot, destination = ".") {
9253
- const templateDir = resolve2(templateRoot, `template-csf/`);
9254
- if (!existsSync(templateDir)) {
9255
- throw new Error(`Couldn't find template dir`);
9256
- }
9257
- cpSync(templateDir, destination, { recursive: true });
9258
- }
9259
- __name(copyTemplate, "copyTemplate");
9260
- var frameworkToDefaultBuilder = {
9261
- angular: "webpack5" /* Webpack5 */,
9262
- ember: "webpack5" /* Webpack5 */,
9263
- "html-vite": "vite" /* Vite */,
9264
- nextjs: "webpack5" /* Webpack5 */,
9265
- nuxt: "vite" /* Vite */,
9266
- "nextjs-vite": "vite" /* Vite */,
9267
- "preact-vite": "vite" /* Vite */,
9268
- qwik: "vite" /* Vite */,
9269
- "react-native-web-vite": "vite" /* Vite */,
9270
- "react-vite": "vite" /* Vite */,
9271
- "react-webpack5": "webpack5" /* Webpack5 */,
9272
- "server-webpack5": "webpack5" /* Webpack5 */,
9273
- solid: "vite" /* Vite */,
9274
- "svelte-vite": "vite" /* Vite */,
9275
- sveltekit: "vite" /* Vite */,
9276
- "vue3-vite": "vite" /* Vite */,
9277
- "web-components-vite": "vite" /* Vite */,
9278
- // Only to pass type checking, will never be used
9279
- "react-rsbuild": "rsbuild" /* Rsbuild */,
9280
- "vue3-rsbuild": "rsbuild" /* Rsbuild */
9281
- };
9282
- async function getVersionSafe(packageManager, packageName) {
9283
- try {
9284
- let version = await packageManager.getInstalledVersion(packageName);
9285
- if (!version) {
9286
- const deps = packageManager.getAllDependencies();
9287
- const versionSpecifier = deps[packageName];
9288
- version = versionSpecifier ?? "";
9289
- }
9290
- const coerced = coerce(version, { includePrerelease: true });
9291
- return coerced?.toString();
9292
- } catch (err) {
9293
- }
9294
- return void 0;
9295
- }
9296
- __name(getVersionSafe, "getVersionSafe");
9297
- var cliStoriesTargetPath = /* @__PURE__ */ __name(async () => {
9298
- if (existsSync("./src")) {
9299
- return "./src/stories";
9300
- }
9301
- return "./stories";
9302
- }, "cliStoriesTargetPath");
9303
- async function copyTemplateFiles({
9304
- packageManager,
9305
- templateLocation,
9306
- language,
9307
- destination,
9308
- commonAssetsDir,
9309
- features
9310
- }) {
9311
- const languageFolderMapping = {
9312
- ["javascript" /* JAVASCRIPT */]: "js",
9313
- ["typescript" /* TYPESCRIPT */]: "ts"
9314
- };
9315
- const templatePath = /* @__PURE__ */ __name(async () => {
9316
- const baseDir = await getRendererDir(packageManager, templateLocation);
9317
- const assetsDir = join3(baseDir, "template", "cli");
9318
- const assetsLanguage = join3(assetsDir, languageFolderMapping[language]);
9319
- const assetsJS = join3(assetsDir, languageFolderMapping["javascript" /* JAVASCRIPT */]);
9320
- const assetsTS = join3(assetsDir, languageFolderMapping.typescript);
9321
- if (existsSync(assetsLanguage)) {
9322
- return assetsLanguage;
9323
- }
9324
- if (existsSync(assetsTS)) {
9325
- return assetsTS;
9326
- }
9327
- if (existsSync(assetsJS)) {
9328
- return assetsJS;
9329
- }
9330
- if (existsSync(assetsDir)) {
9331
- return assetsDir;
9332
- }
9333
- throw new Error(`Unsupported renderer: ${templateLocation} (${baseDir})`);
9334
- }, "templatePath");
9335
- const destinationPath = destination ?? await cliStoriesTargetPath();
9336
- const filter = /* @__PURE__ */ __name((file) => features.includes("docs") || !file.endsWith(".mdx"), "filter");
9337
- if (commonAssetsDir) {
9338
- await cp(commonAssetsDir, destinationPath, { recursive: true, filter });
9339
- }
9340
- await cp(await templatePath(), destinationPath, { recursive: true, filter });
9341
- if (commonAssetsDir && features.includes("docs")) {
9342
- let rendererType = frameworkToRenderer[templateLocation] || "react";
9343
- if (rendererType === "vue3") {
9344
- rendererType = "vue";
9345
- }
9346
- await adjustTemplate(join3(destinationPath, "Configure.mdx"), { renderer: rendererType });
9347
- }
9348
- }
9349
- __name(copyTemplateFiles, "copyTemplateFiles");
9350
- async function adjustTemplate(templatePath, templateData) {
9351
- let template = await readFile2(templatePath, { encoding: "utf8" });
9352
- Object.keys(templateData).forEach((key) => {
9353
- template = template.replaceAll(`{{${key}}}`, `${templateData[key]}`);
9354
- });
9355
- await writeFile(templatePath, template);
9356
- }
9357
- __name(adjustTemplate, "adjustTemplate");
9358
- async function isNxProject() {
9359
- return up("nx.json", { last: getProjectRoot() });
9360
- }
9361
- __name(isNxProject, "isNxProject");
9362
- function coerceSemver(version) {
9363
- const coercedSemver = coerce(version);
9364
- invariant(coercedSemver != null, `Could not coerce ${version} into a semver.`);
9365
- return coercedSemver;
9366
- }
9367
- __name(coerceSemver, "coerceSemver");
9368
- function hasStorybookDependencies(packageManager) {
9369
- const currentPackageDeps = packageManager.getAllDependencies();
9370
- return Object.keys(currentPackageDeps).some((dep) => dep.includes("storybook"));
9371
- }
9372
- __name(hasStorybookDependencies, "hasStorybookDependencies");
9373
-
9374
- // src/cli/detect.ts
9375
- var viteConfigFiles = ["vite.config.ts", "vite.config.js", "vite.config.mjs"];
9376
- var webpackConfigFiles = ["webpack.config.js"];
9377
- var hasDependency = /* @__PURE__ */ __name((packageJson, name, matcher) => {
9378
- const version = packageJson.dependencies?.[name] || packageJson.devDependencies?.[name];
9379
- if (version && typeof matcher === "function") {
9380
- return matcher(version);
9381
- }
9382
- return !!version;
9383
- }, "hasDependency");
9384
- var hasPeerDependency = /* @__PURE__ */ __name((packageJson, name, matcher) => {
9385
- const version = packageJson.peerDependencies?.[name];
9386
- if (version && typeof matcher === "function") {
9387
- return matcher(version);
9388
- }
9389
- return !!version;
9390
- }, "hasPeerDependency");
9391
- var getFrameworkPreset = /* @__PURE__ */ __name((packageJson, framework) => {
9392
- const matcher = {
9393
- dependencies: [false],
9394
- peerDependencies: [false],
9395
- files: [false]
9396
- };
9397
- const { preset, files, dependencies, peerDependencies, matcherFunction } = framework;
9398
- let dependencySearches = [];
9399
- if (Array.isArray(dependencies)) {
9400
- dependencySearches = dependencies.map((name) => [name, void 0]);
9401
- } else if (typeof dependencies === "object") {
9402
- dependencySearches = Object.entries(dependencies);
9403
- }
9404
- if (dependencySearches.length > 0) {
9405
- matcher.dependencies = dependencySearches.map(
9406
- ([name, matchFn]) => hasDependency(packageJson, name, matchFn)
9407
- );
9408
- }
9409
- let peerDependencySearches = [];
9410
- if (Array.isArray(peerDependencies)) {
9411
- peerDependencySearches = peerDependencies.map((name) => [name, void 0]);
9412
- } else if (typeof peerDependencies === "object") {
9413
- peerDependencySearches = Object.entries(peerDependencies);
9414
- }
9415
- if (peerDependencySearches.length > 0) {
9416
- matcher.peerDependencies = peerDependencySearches.map(
9417
- ([name, matchFn]) => hasPeerDependency(packageJson, name, matchFn)
9418
- );
9419
- }
9420
- if (Array.isArray(files) && files.length > 0) {
9421
- matcher.files = files.map((name) => existsSync2(name));
9422
- }
9423
- return matcherFunction(matcher) ? preset : null;
9424
- }, "getFrameworkPreset");
9425
- function detectFrameworkPreset(packageJson = {}) {
9426
- const result = [...supportedTemplates, unsupportedTemplate].find((framework) => {
9427
- return getFrameworkPreset(packageJson, framework) !== null;
9428
- });
9429
- return result ? result.preset : "UNDETECTED" /* UNDETECTED */;
9430
- }
9431
- __name(detectFrameworkPreset, "detectFrameworkPreset");
9432
- async function detectBuilder(packageManager, projectType) {
9433
- const viteConfig = any(viteConfigFiles, { last: getProjectRoot2() });
9434
- const webpackConfig = any(webpackConfigFiles, { last: getProjectRoot2() });
9435
- const dependencies = packageManager.getAllDependencies();
9436
- if (viteConfig || dependencies.vite && dependencies.webpack === void 0) {
9437
- commandLog("Detected Vite project. Setting builder to Vite")();
9438
- return "vite" /* Vite */;
9439
- }
9440
- if (webpackConfig || (dependencies.webpack || dependencies["@nuxt/webpack-builder"]) && dependencies.vite !== void 0) {
9441
- commandLog("Detected webpack project. Setting builder to webpack")();
9442
- return "webpack5" /* Webpack5 */;
9443
- }
9444
- switch (projectType) {
9445
- case "REACT_NATIVE_AND_RNW" /* REACT_NATIVE_AND_RNW */:
9446
- case "REACT_NATIVE_WEB" /* REACT_NATIVE_WEB */:
9447
- return "vite" /* Vite */;
9448
- case "REACT_SCRIPTS" /* REACT_SCRIPTS */:
9449
- case "ANGULAR" /* ANGULAR */:
9450
- case "REACT_NATIVE" /* REACT_NATIVE */:
9451
- // technically react native doesn't use webpack, we just want to set something
9452
- case "NEXTJS" /* NEXTJS */:
9453
- case "EMBER" /* EMBER */:
9454
- return "webpack5" /* Webpack5 */;
9455
- case "NUXT" /* NUXT */:
9456
- return "vite" /* Vite */;
9457
- default:
9458
- const { builder } = await (0, import_prompts.default)(
9459
- {
9460
- type: "select",
9461
- name: "builder",
9462
- message: "\nWe were not able to detect the right builder for your project. Please select one:",
9463
- choices: [
9464
- { title: "Vite", value: "vite" /* Vite */ },
9465
- { title: "Webpack 5", value: "webpack5" /* Webpack5 */ }
9466
- ]
9467
- },
9468
- {
9469
- onCancel: /* @__PURE__ */ __name(() => {
9470
- throw new HandledError("Canceled by the user");
9471
- }, "onCancel")
9472
- }
9473
- );
9474
- return builder;
9475
- }
9476
- }
9477
- __name(detectBuilder, "detectBuilder");
9478
- function isStorybookInstantiated(configDir = resolve3(process.cwd(), ".storybook")) {
9479
- return existsSync2(configDir);
9480
- }
9481
- __name(isStorybookInstantiated, "isStorybookInstantiated");
9482
- async function detectPnp() {
9483
- return !!any([".pnp.js", ".pnp.cjs"]);
9484
- }
9485
- __name(detectPnp, "detectPnp");
9486
- async function detectLanguage(packageManager) {
9487
- let language = "javascript" /* JAVASCRIPT */;
9488
- if (existsSync2("jsconfig.json")) {
9489
- return language;
9490
- }
9491
- const isTypescriptDirectDependency = !!packageManager.getAllDependencies().typescript;
9492
- const getModulePackageJSONVersion = /* @__PURE__ */ __name(async (pkg) => {
9493
- return (await packageManager.getModulePackageJSON(pkg))?.version ?? null;
9494
- }, "getModulePackageJSONVersion");
9495
- const [
9496
- typescriptVersion,
9497
- prettierVersion,
9498
- babelPluginTransformTypescriptVersion,
9499
- typescriptEslintParserVersion,
9500
- eslintPluginStorybookVersion
9501
- ] = await Promise.all([
9502
- getModulePackageJSONVersion("typescript"),
9503
- getModulePackageJSONVersion("prettier"),
9504
- getModulePackageJSONVersion("@babel/plugin-transform-typescript"),
9505
- getModulePackageJSONVersion("@typescript-eslint/parser"),
9506
- getModulePackageJSONVersion("eslint-plugin-storybook")
9507
- ]);
9508
- if (isTypescriptDirectDependency && typescriptVersion) {
9509
- if (semver.gte(typescriptVersion, "4.9.0") && (!prettierVersion || semver.gte(prettierVersion, "2.8.0")) && (!babelPluginTransformTypescriptVersion || semver.gte(babelPluginTransformTypescriptVersion, "7.20.0")) && (!typescriptEslintParserVersion || semver.gte(typescriptEslintParserVersion, "5.44.0")) && (!eslintPluginStorybookVersion || semver.gte(eslintPluginStorybookVersion, "0.6.8"))) {
9510
- language = "typescript" /* TYPESCRIPT */;
9511
- } else {
9512
- logger2.warn(
9513
- "Detected TypeScript < 4.9 or incompatible tooling, populating with JavaScript examples"
9514
- );
9515
- }
9516
- } else {
9517
- if (existsSync2("tsconfig.json")) {
9518
- language = "typescript" /* TYPESCRIPT */;
9519
- }
9520
- }
9521
- return language;
9522
- }
9523
- __name(detectLanguage, "detectLanguage");
9524
- async function detect(packageManager, options = {}) {
9525
- try {
9526
- if (await isNxProject()) {
9527
- return "NX" /* NX */;
9528
- }
9529
- if (options.html) {
9530
- return "HTML" /* HTML */;
9531
- }
9532
- const { packageJson } = packageManager.primaryPackageJson;
9533
- return detectFrameworkPreset(packageJson);
9534
- } catch (e) {
9535
- return "UNDETECTED" /* UNDETECTED */;
9536
- }
9537
- }
9538
- __name(detect, "detect");
9539
-
9540
8115
  // src/cli/angular/helpers.ts
9541
- import { existsSync as existsSync3, readFileSync as readFileSync2, writeFileSync as writeFileSync2 } from "node:fs";
9542
- import { join as join4 } from "node:path";
9543
- import { logger as logger3 } from "storybook/internal/node-logger";
8116
+ import { existsSync, readFileSync, writeFileSync } from "node:fs";
8117
+ import { join } from "node:path";
8118
+ import { logger } from "storybook/internal/node-logger";
9544
8119
  import { MissingAngularJsonError } from "storybook/internal/server-errors";
9545
- var import_prompts2 = __toESM(require_prompts(), 1);
8120
+ var import_prompts = __toESM(require_prompts(), 1);
9546
8121
  var import_ts_dedent = __toESM(require_dist(), 1);
9547
8122
  var ANGULAR_JSON_PATH = "angular.json";
9548
8123
  var compoDocPreviewPrefix = import_ts_dedent.dedent`
@@ -9551,7 +8126,7 @@ var compoDocPreviewPrefix = import_ts_dedent.dedent`
9551
8126
  setCompodocJson(docJson);
9552
8127
  `.trimStart();
9553
8128
  var promptForCompoDocs = /* @__PURE__ */ __name(async () => {
9554
- logger3.plain(
8129
+ logger.plain(
9555
8130
  // Create a text which explains the user why compodoc is necessary
9556
8131
  boxen(
9557
8132
  import_ts_dedent.dedent`
@@ -9563,7 +8138,7 @@ var promptForCompoDocs = /* @__PURE__ */ __name(async () => {
9563
8138
  { title: "Compodoc", borderStyle: "round", padding: 1, borderColor: "#F1618C" }
9564
8139
  )
9565
8140
  );
9566
- const { useCompoDoc } = await (0, import_prompts2.default)({
8141
+ const { useCompoDoc } = await (0, import_prompts.default)({
9567
8142
  type: "confirm",
9568
8143
  name: "useCompoDoc",
9569
8144
  message: "Do you want to use Compodoc for documentation?"
@@ -9575,10 +8150,10 @@ var AngularJSON = class {
9575
8150
  __name(this, "AngularJSON");
9576
8151
  }
9577
8152
  constructor() {
9578
- if (!existsSync3(ANGULAR_JSON_PATH)) {
9579
- throw new MissingAngularJsonError({ path: join4(process.cwd(), ANGULAR_JSON_PATH) });
8153
+ if (!existsSync(ANGULAR_JSON_PATH)) {
8154
+ throw new MissingAngularJsonError({ path: join(process.cwd(), ANGULAR_JSON_PATH) });
9580
8155
  }
9581
- const jsonContent = readFileSync2(ANGULAR_JSON_PATH, "utf8");
8156
+ const jsonContent = readFileSync(ANGULAR_JSON_PATH, "utf8");
9582
8157
  this.json = JSON.parse(jsonContent);
9583
8158
  }
9584
8159
  get projects() {
@@ -9610,7 +8185,7 @@ var AngularJSON = class {
9610
8185
  }
9611
8186
  async getProjectName() {
9612
8187
  if (this.projectsWithoutStorybook.length > 1) {
9613
- const { projectName } = await (0, import_prompts2.default)({
8188
+ const { projectName } = await (0, import_prompts.default)({
9614
8189
  type: "select",
9615
8190
  name: "projectName",
9616
8191
  message: "For which project do you want to generate Storybook configuration?",
@@ -9656,16 +8231,16 @@ var AngularJSON = class {
9656
8231
  }
9657
8232
  }
9658
8233
  write() {
9659
- writeFileSync2(ANGULAR_JSON_PATH, JSON.stringify(this.json, null, 2));
8234
+ writeFileSync(ANGULAR_JSON_PATH, JSON.stringify(this.json, null, 2));
9660
8235
  }
9661
8236
  };
9662
8237
 
9663
8238
  // src/cli/eslintPlugin.ts
9664
8239
  var import_comment_json = __toESM(require_src2(), 1);
9665
- import { readFile as readFile3, writeFile as writeFile2 } from "node:fs/promises";
9666
- import { getProjectRoot as getProjectRoot3 } from "storybook/internal/common";
8240
+ import { readFile, writeFile } from "node:fs/promises";
8241
+ import { getProjectRoot } from "storybook/internal/common";
9667
8242
  import { readConfig, writeConfig } from "storybook/internal/csf-tools";
9668
- import { logger as logger4, prompt } from "storybook/internal/node-logger";
8243
+ import { logger as logger2, prompt } from "storybook/internal/node-logger";
9669
8244
 
9670
8245
  // ../node_modules/detect-indent/index.js
9671
8246
  var INDENT_REGEX = /^(?:( )+|\t+)/;
@@ -9775,7 +8350,7 @@ function detectIndent(string) {
9775
8350
  __name(detectIndent, "detectIndent");
9776
8351
 
9777
8352
  // src/cli/eslintPlugin.ts
9778
- var import_picocolors2 = __toESM(require_picocolors(), 1);
8353
+ var import_picocolors = __toESM(require_picocolors(), 1);
9779
8354
  var import_ts_dedent2 = __toESM(require_dist(), 1);
9780
8355
  var SUPPORTED_ESLINT_EXTENSIONS = ["ts", "mts", "cts", "mjs", "js", "cjs", "json"];
9781
8356
  var UNSUPPORTED_ESLINT_EXTENSIONS = ["yaml", "yml"];
@@ -9783,7 +8358,7 @@ var findEslintFile = /* @__PURE__ */ __name((instanceDir) => {
9783
8358
  const filePrefixes = ["eslint.config", ".eslintrc"];
9784
8359
  for (const prefix of filePrefixes) {
9785
8360
  for (const ext of UNSUPPORTED_ESLINT_EXTENSIONS) {
9786
- const file = up(`${prefix}.${ext}`, { cwd: instanceDir, last: getProjectRoot3() });
8361
+ const file = up(`${prefix}.${ext}`, { cwd: instanceDir, last: getProjectRoot() });
9787
8362
  if (file) {
9788
8363
  throw new Error(`Unsupported ESLint config extension: .${ext}`);
9789
8364
  }
@@ -9791,7 +8366,7 @@ var findEslintFile = /* @__PURE__ */ __name((instanceDir) => {
9791
8366
  }
9792
8367
  for (const prefix of filePrefixes) {
9793
8368
  for (const ext of SUPPORTED_ESLINT_EXTENSIONS) {
9794
- const file = up(`${prefix}.${ext}`, { cwd: instanceDir, last: getProjectRoot3() });
8369
+ const file = up(`${prefix}.${ext}`, { cwd: instanceDir, last: getProjectRoot() });
9795
8370
  if (file) {
9796
8371
  return file;
9797
8372
  }
@@ -9814,16 +8389,16 @@ var configureFlatConfig = /* @__PURE__ */ __name(async (code) => {
9814
8389
  let tsEslintLocalName = "";
9815
8390
  let eslintConfigExpression = null;
9816
8391
  traverse(ast, {
9817
- ImportDeclaration(path2) {
9818
- if (path2.node.source.value === "typescript-eslint") {
9819
- const defaultSpecifier = path2.node.specifiers.find((s) => types.isImportDefaultSpecifier(s));
8392
+ ImportDeclaration(path) {
8393
+ if (path.node.source.value === "typescript-eslint") {
8394
+ const defaultSpecifier = path.node.specifiers.find((s) => types.isImportDefaultSpecifier(s));
9820
8395
  if (defaultSpecifier) {
9821
8396
  tsEslintLocalName = defaultSpecifier.local.name;
9822
8397
  }
9823
8398
  }
9824
8399
  },
9825
- ExportDefaultDeclaration(path2) {
9826
- const node = path2.node;
8400
+ ExportDefaultDeclaration(path) {
8401
+ const node = path.node;
9827
8402
  eslintConfigExpression = unwrapTSExpression(node.declaration);
9828
8403
  const storybookConfig = types.memberExpression(
9829
8404
  types.memberExpression(types.identifier("storybook"), types.identifier("configs")),
@@ -9837,7 +8412,7 @@ var configureFlatConfig = /* @__PURE__ */ __name(async (code) => {
9837
8412
  eslintConfigExpression.arguments.push(storybookConfig);
9838
8413
  }
9839
8414
  if (types.isIdentifier(eslintConfigExpression)) {
9840
- const binding = path2.scope.getBinding(eslintConfigExpression.name);
8415
+ const binding = path.scope.getBinding(eslintConfigExpression.name);
9841
8416
  if (binding && types.isVariableDeclarator(binding.path.node)) {
9842
8417
  const init = unwrapTSExpression(binding.path.node.init);
9843
8418
  if (types.isArrayExpression(init)) {
@@ -9846,8 +8421,8 @@ var configureFlatConfig = /* @__PURE__ */ __name(async (code) => {
9846
8421
  }
9847
8422
  }
9848
8423
  },
9849
- Program(path2) {
9850
- const alreadyImported = path2.node.body.some(
8424
+ Program(path) {
8425
+ const alreadyImported = path.node.body.some(
9851
8426
  (node) => types.isImportDeclaration(node) && node.source.value === "eslint-plugin-storybook"
9852
8427
  );
9853
8428
  if (!alreadyImported) {
@@ -9861,7 +8436,7 @@ var configureFlatConfig = /* @__PURE__ */ __name(async (code) => {
9861
8436
  value: " For more info, see https://github.com/storybookjs/eslint-plugin-storybook#configuration-flat-config-format"
9862
8437
  }
9863
8438
  ];
9864
- path2.node.body.unshift(importDecl);
8439
+ path.node.body.unshift(importDecl);
9865
8440
  }
9866
8441
  }
9867
8442
  });
@@ -9911,8 +8486,8 @@ async function configureEslintPlugin({
9911
8486
  }) {
9912
8487
  if (eslintConfigFile) {
9913
8488
  if (eslintConfigFile.endsWith("json")) {
9914
- logger4.debug(`Detected JSON config at ${eslintConfigFile}`);
9915
- const eslintFileContents = await readFile3(eslintConfigFile, { encoding: "utf8" });
8489
+ logger2.debug(`Detected JSON config at ${eslintConfigFile}`);
8490
+ const eslintFileContents = await readFile(eslintConfigFile, { encoding: "utf8" });
9916
8491
  const eslintConfig = import_comment_json.default.parse(eslintFileContents);
9917
8492
  const existingExtends = normalizeExtends(eslintConfig.extends).filter(Boolean);
9918
8493
  if (existingExtends.includes("plugin:storybook/recommended")) {
@@ -9923,13 +8498,13 @@ async function configureEslintPlugin({
9923
8498
  }
9924
8499
  eslintConfig.extends.push("plugin:storybook/recommended");
9925
8500
  const spaces = detectIndent(eslintFileContents).amount || 2;
9926
- await writeFile2(eslintConfigFile, import_comment_json.default.stringify(eslintConfig, null, spaces));
8501
+ await writeFile(eslintConfigFile, import_comment_json.default.stringify(eslintConfig, null, spaces));
9927
8502
  } else {
9928
8503
  if (isFlatConfig) {
9929
- logger4.debug(`Detected flat config at ${eslintConfigFile}`);
9930
- const code = await readFile3(eslintConfigFile, { encoding: "utf8" });
8504
+ logger2.debug(`Detected flat config at ${eslintConfigFile}`);
8505
+ const code = await readFile(eslintConfigFile, { encoding: "utf8" });
9931
8506
  const output = await configureFlatConfig(code);
9932
- await writeFile2(eslintConfigFile, output);
8507
+ await writeFile(eslintConfigFile, output);
9933
8508
  } else {
9934
8509
  const eslint = await readConfig(eslintConfigFile);
9935
8510
  const existingExtends = normalizeExtends(eslint.getFieldValue(["extends"])).filter(Boolean);
@@ -9941,7 +8516,7 @@ async function configureEslintPlugin({
9941
8516
  }
9942
8517
  }
9943
8518
  } else {
9944
- logger4.debug("No ESLint config file found, configuring in package.json instead");
8519
+ logger2.debug("No ESLint config file found, configuring in package.json instead");
9945
8520
  const { packageJson } = packageManager.primaryPackageJson;
9946
8521
  const existingExtends = normalizeExtends(packageJson.eslintConfig?.extends).filter(Boolean);
9947
8522
  packageManager.writePackageJson({
@@ -9957,7 +8532,7 @@ __name(configureEslintPlugin, "configureEslintPlugin");
9957
8532
  var suggestESLintPlugin = /* @__PURE__ */ __name(async () => {
9958
8533
  const shouldInstall = await prompt.confirm({
9959
8534
  message: import_ts_dedent2.dedent`
9960
- We have detected that you're using ESLint. Storybook provides a plugin that gives the best experience with Storybook and helps follow best practices: ${import_picocolors2.default.yellow(
8535
+ We have detected that you're using ESLint. Storybook provides a plugin that gives the best experience with Storybook and helps follow best practices: ${import_picocolors.default.yellow(
9961
8536
  "https://storybook.js.org/docs/9/configure/integration/eslint-plugin"
9962
8537
  )}
9963
8538