storybook 10.1.0-alpha.9 → 10.1.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (198) hide show
  1. package/dist/_browser-chunks/Color-FTG7SQDA.js +1097 -0
  2. package/dist/_browser-chunks/WithTooltip-LMROHDUP.js +1651 -0
  3. package/dist/_browser-chunks/chunk-2FRVAXCZ.js +7 -0
  4. package/dist/_browser-chunks/{chunk-FDWKXLBI.js → chunk-2XZMBGTA.js} +44 -109
  5. package/dist/_browser-chunks/chunk-3IAH5M2U.js +171 -0
  6. package/dist/_browser-chunks/chunk-3OXGAGBE.js +779 -0
  7. package/dist/_browser-chunks/{chunk-TMDZCWME.js → chunk-3PJE6VLG.js} +1 -3
  8. package/dist/_browser-chunks/{chunk-VAMFPZY3.js → chunk-45UGUKRX.js} +2 -7
  9. package/dist/_browser-chunks/chunk-6XWLIJQL.js +11 -0
  10. package/dist/_browser-chunks/{chunk-MM7DTO55.js → chunk-A242L54C.js} +10 -16
  11. package/dist/_browser-chunks/chunk-AIOS4NGK.js +252 -0
  12. package/dist/_browser-chunks/chunk-AS2HQEYC.js +14 -0
  13. package/dist/_browser-chunks/chunk-AXG2BOBL.js +836 -0
  14. package/dist/_browser-chunks/{chunk-MH6AXFXB.js → chunk-CHUV5WSW.js} +0 -5
  15. package/dist/_browser-chunks/chunk-EUVGDK4H.js +93 -0
  16. package/dist/_browser-chunks/chunk-EZSQOHRI.js +18 -0
  17. package/dist/_browser-chunks/{chunk-CADGRH3P.js → chunk-FNXWN6IK.js} +3 -8
  18. package/dist/_browser-chunks/chunk-FQ7SLVLR.js +66 -0
  19. package/dist/_browser-chunks/chunk-GFLS4VP3.js +64 -0
  20. package/dist/_browser-chunks/chunk-GFY5R5EY.js +47 -0
  21. package/dist/_browser-chunks/{chunk-L2D73C6Z.js → chunk-H6XK3RSC.js} +13 -21
  22. package/dist/_browser-chunks/chunk-IPA5A322.js +71 -0
  23. package/dist/_browser-chunks/chunk-JP7NCOJX.js +37 -0
  24. package/dist/_browser-chunks/chunk-KJHJLCBK.js +11 -0
  25. package/dist/_browser-chunks/{chunk-OWPZQM2D.js → chunk-L4RMQ7D7.js} +60 -110
  26. package/dist/_browser-chunks/chunk-P4F4UVXX.js +951 -0
  27. package/dist/_browser-chunks/{chunk-AB7OOPUX.js → chunk-QKODTO7K.js} +0 -5
  28. package/dist/_browser-chunks/chunk-RP5RXKFU.js +2491 -0
  29. package/dist/_browser-chunks/chunk-SL75JR6Y.js +9 -0
  30. package/dist/_browser-chunks/chunk-SS2NHR7W.js +2969 -0
  31. package/dist/_browser-chunks/chunk-UD6FQLAF.js +1481 -0
  32. package/dist/_browser-chunks/chunk-VYJQ7RU5.js +2853 -0
  33. package/dist/_browser-chunks/chunk-WJYERY3R.js +136 -0
  34. package/dist/_browser-chunks/chunk-XJNX76GA.js +85 -0
  35. package/dist/_browser-chunks/{chunk-F4Q6SGTB.js → chunk-YKE5S47A.js} +177 -399
  36. package/dist/_browser-chunks/{chunk-SN4J4IQ3.js → chunk-ZUWEVLDX.js} +1 -7
  37. package/dist/_browser-chunks/{formatter-OMEEQ6HG.js → formatter-QJ4M4OGQ.js} +4 -9
  38. package/dist/_browser-chunks/{syntaxhighlighter-CAVLW7PM.js → syntaxhighlighter-IQDEPFLK.js} +704 -1848
  39. package/dist/_node-chunks/{builder-manager-SM3UWERX.js → builder-manager-BDAQHXFI.js} +510 -1019
  40. package/dist/_node-chunks/camelcase-3C7DZZPX.js +37 -0
  41. package/dist/_node-chunks/chunk-2IIQTGNE.js +6024 -0
  42. package/dist/_node-chunks/chunk-56U5LEMP.js +3043 -0
  43. package/dist/_node-chunks/chunk-7LIRCAQE.js +20 -0
  44. package/dist/_node-chunks/chunk-7RN6TXKP.js +603 -0
  45. package/dist/_node-chunks/chunk-7SJ7PZNL.js +4523 -0
  46. package/dist/_node-chunks/{chunk-HHSTA6QS.js → chunk-BG4RDXG7.js} +8 -10
  47. package/dist/_node-chunks/chunk-CBQKMXLQ.js +18 -0
  48. package/dist/_node-chunks/chunk-CN2IW2KQ.js +1564 -0
  49. package/dist/_node-chunks/chunk-CQMAU6UQ.js +943 -0
  50. package/dist/_node-chunks/{chunk-EBUEXRH5.js → chunk-D6ND3TVY.js} +116 -276
  51. package/dist/_node-chunks/chunk-DC355CYB.js +61 -0
  52. package/dist/_node-chunks/{chunk-SGM3ZCCT.js → chunk-EVK2SBW5.js} +292 -688
  53. package/dist/_node-chunks/chunk-IXWEUXJ2.js +119 -0
  54. package/dist/_node-chunks/{chunk-F6EFOEC7.js → chunk-KVRF22SH.js} +469 -983
  55. package/dist/_node-chunks/chunk-LEDP4QQW.js +919 -0
  56. package/dist/_node-chunks/{chunk-GHIBZRKD.js → chunk-MMVV6DGG.js} +8133 -8887
  57. package/dist/_node-chunks/chunk-O5CGEVRI.js +29 -0
  58. package/dist/_node-chunks/chunk-OZZO56XN.js +299 -0
  59. package/dist/_node-chunks/chunk-POT2EVGD.js +78 -0
  60. package/dist/_node-chunks/chunk-R5YGFSTV.js +3781 -0
  61. package/dist/_node-chunks/chunk-SQCTM2OS.js +23 -0
  62. package/dist/_node-chunks/chunk-UFOFO5H7.js +54 -0
  63. package/dist/_node-chunks/chunk-VBF7ALJF.js +72 -0
  64. package/dist/_node-chunks/chunk-W6MAMTUF.js +70 -0
  65. package/dist/_node-chunks/chunk-WURL4XOT.js +46662 -0
  66. package/dist/_node-chunks/chunk-XGK6MVKR.js +61 -0
  67. package/dist/_node-chunks/chunk-YV3GDSDT.js +765 -0
  68. package/dist/_node-chunks/{chunk-ATDHMMIZ.js → chunk-YWV55YW3.js} +15 -24
  69. package/dist/_node-chunks/dist-KEP4IFRN.js +121 -0
  70. package/dist/_node-chunks/globby-4WUBTDCN.js +3452 -0
  71. package/dist/_node-chunks/lib-JVOEKTYM.js +366 -0
  72. package/dist/_node-chunks/mdx-N42X6CFJ-C5WFYYXR.js +14329 -0
  73. package/dist/_node-chunks/p-limit-LDY632RS.js +116 -0
  74. package/dist/actions/decorator.js +21 -42
  75. package/dist/actions/index.js +3 -3
  76. package/dist/babel/index.d.ts +671 -335
  77. package/dist/babel/index.js +10 -11
  78. package/dist/bin/core.js +601 -1548
  79. package/dist/bin/dispatcher.js +36 -36
  80. package/dist/bin/loader.js +24 -38
  81. package/dist/channels/index.js +98 -234
  82. package/dist/cli/index.d.ts +1479 -133
  83. package/dist/cli/index.js +30 -8540
  84. package/dist/client-logger/index.js +31 -61
  85. package/dist/common/index.d.ts +139 -62
  86. package/dist/common/index.js +66 -51
  87. package/dist/components/index.d.ts +575 -273
  88. package/dist/components/index.js +14863 -4313
  89. package/dist/core-events/index.js +2 -66
  90. package/dist/core-server/index.d.ts +3 -2
  91. package/dist/core-server/index.js +2908 -8518
  92. package/dist/core-server/presets/common-manager.css +2 -2
  93. package/dist/core-server/presets/common-manager.js +2521 -5233
  94. package/dist/core-server/presets/common-override-preset.js +31 -60
  95. package/dist/core-server/presets/common-preset.js +663 -962
  96. package/dist/csf/index.js +534 -1179
  97. package/dist/csf-tools/index.js +9 -9
  98. package/dist/docs-tools/index.js +6 -6
  99. package/dist/highlight/index.js +2 -2
  100. package/dist/instrumenter/index.js +199 -415
  101. package/dist/manager/globals-runtime.js +59044 -67141
  102. package/dist/manager/globals.js +2 -3
  103. package/dist/manager/manager-stores.d.ts +1 -0
  104. package/dist/manager/manager-stores.js +23 -0
  105. package/dist/manager/runtime.js +11511 -10953
  106. package/dist/manager-api/index.d.ts +1811 -2
  107. package/dist/manager-api/index.js +1348 -2401
  108. package/dist/manager-errors.d.ts +9 -0
  109. package/dist/manager-errors.js +3 -3
  110. package/dist/mocking-utils/index.d.ts +1126 -0
  111. package/dist/mocking-utils/index.js +1181 -0
  112. package/dist/node-logger/index.d.ts +192 -24
  113. package/dist/node-logger/index.js +23 -4471
  114. package/dist/preview/globals.js +2 -3
  115. package/dist/preview/runtime.js +10799 -22393
  116. package/dist/preview-api/index.d.ts +68 -69
  117. package/dist/preview-api/index.js +13 -13
  118. package/dist/preview-errors.d.ts +9 -0
  119. package/dist/preview-errors.js +4 -4
  120. package/dist/router/index.js +347 -899
  121. package/dist/server-errors.d.ts +34 -1
  122. package/dist/server-errors.js +17 -10
  123. package/dist/telemetry/index.d.ts +24 -3
  124. package/dist/telemetry/index.js +25 -24
  125. package/dist/test/index.js +6131 -11916
  126. package/dist/theming/create.d.ts +1 -0
  127. package/dist/theming/create.js +4 -4
  128. package/dist/theming/index.d.ts +3366 -2599
  129. package/dist/theming/index.js +501 -1091
  130. package/dist/types/index.d.ts +72 -8
  131. package/dist/types/index.js +27 -12
  132. package/dist/viewport/index.js +3 -3
  133. package/package.json +26 -17
  134. package/dist/_browser-chunks/Color-7ZNS6F6B.js +0 -1676
  135. package/dist/_browser-chunks/WithTooltip-SK46ZJ2J.js +0 -13
  136. package/dist/_browser-chunks/chunk-6A7OIVEL.js +0 -66
  137. package/dist/_browser-chunks/chunk-B4A3ADP3.js +0 -3816
  138. package/dist/_browser-chunks/chunk-BOOOPFZF.js +0 -2335
  139. package/dist/_browser-chunks/chunk-FSBVR7H5.js +0 -106
  140. package/dist/_browser-chunks/chunk-FUOHXXZT.js +0 -23
  141. package/dist/_browser-chunks/chunk-GTKOCWCT.js +0 -17
  142. package/dist/_browser-chunks/chunk-HHW4FUMO.js +0 -12
  143. package/dist/_browser-chunks/chunk-JVSKG4YS.js +0 -4052
  144. package/dist/_browser-chunks/chunk-LASUB7TL.js +0 -76
  145. package/dist/_browser-chunks/chunk-LYCSRYYR.js +0 -101
  146. package/dist/_browser-chunks/chunk-NVV6MIOE.js +0 -243
  147. package/dist/_browser-chunks/chunk-OBXWFEPB.js +0 -852
  148. package/dist/_browser-chunks/chunk-OPCDBBL3.js +0 -48
  149. package/dist/_browser-chunks/chunk-PB6FZ3WE.js +0 -130
  150. package/dist/_browser-chunks/chunk-RNE2IUTB.js +0 -1300
  151. package/dist/_browser-chunks/chunk-RW5PKMWM.js +0 -4182
  152. package/dist/_browser-chunks/chunk-SYS437NN.js +0 -122
  153. package/dist/_browser-chunks/chunk-U46RQHA4.js +0 -12
  154. package/dist/_browser-chunks/chunk-UTNZYD2N.js +0 -311
  155. package/dist/_browser-chunks/chunk-VUAFL5XK.js +0 -20
  156. package/dist/_browser-chunks/chunk-XDGMHOV7.js +0 -2197
  157. package/dist/_browser-chunks/chunk-XW6KSYKF.js +0 -16
  158. package/dist/_browser-chunks/chunk-Y3M7TW6K.js +0 -1041
  159. package/dist/_browser-chunks/chunk-ZNRFDIVA.js +0 -233
  160. package/dist/_node-chunks/camelcase-H5QSGQLK.js +0 -18
  161. package/dist/_node-chunks/chunk-3THWHQOC.js +0 -61
  162. package/dist/_node-chunks/chunk-45YUOLTU.js +0 -69
  163. package/dist/_node-chunks/chunk-4QSNCPAU.js +0 -64656
  164. package/dist/_node-chunks/chunk-744PQSOU.js +0 -79
  165. package/dist/_node-chunks/chunk-74Z2U7QG.js +0 -1544
  166. package/dist/_node-chunks/chunk-7MB7TFPO.js +0 -1198
  167. package/dist/_node-chunks/chunk-A7GS4RFT.js +0 -697
  168. package/dist/_node-chunks/chunk-BIA3A5UM.js +0 -61
  169. package/dist/_node-chunks/chunk-C5G7CLWX.js +0 -1657
  170. package/dist/_node-chunks/chunk-DLFUKMYJ.js +0 -1531
  171. package/dist/_node-chunks/chunk-EMRGRXKT.js +0 -111
  172. package/dist/_node-chunks/chunk-EX46EHHY.js +0 -420
  173. package/dist/_node-chunks/chunk-F76QKNOJ.js +0 -304
  174. package/dist/_node-chunks/chunk-HDCRUTEF.js +0 -220
  175. package/dist/_node-chunks/chunk-HUYAOIPH.js +0 -90
  176. package/dist/_node-chunks/chunk-IBJZQZJC.js +0 -101
  177. package/dist/_node-chunks/chunk-KZN2RDDT.js +0 -6712
  178. package/dist/_node-chunks/chunk-LYUNFU3F.js +0 -4741
  179. package/dist/_node-chunks/chunk-N44SIS6K.js +0 -28
  180. package/dist/_node-chunks/chunk-NILZM6KR.js +0 -18
  181. package/dist/_node-chunks/chunk-PC4ZRP6W.js +0 -34
  182. package/dist/_node-chunks/chunk-TJNGOQUH.js +0 -4272
  183. package/dist/_node-chunks/chunk-UBSYLHIL.js +0 -1250
  184. package/dist/_node-chunks/chunk-UTCLXPOC.js +0 -1518
  185. package/dist/_node-chunks/chunk-WOXXODXP.js +0 -5029
  186. package/dist/_node-chunks/chunk-XC4MEUA6.js +0 -1586
  187. package/dist/_node-chunks/chunk-YRXXMKRR.js +0 -2256
  188. package/dist/_node-chunks/dist-SL73W244.js +0 -175
  189. package/dist/_node-chunks/globby-ZSHAUQZ5.js +0 -5222
  190. package/dist/_node-chunks/lib-U2VIPUTI.js +0 -518
  191. package/dist/_node-chunks/mdx-N42X6CFJ-ZLHD33JK.js +0 -22017
  192. package/dist/_node-chunks/p-limit-K5BS5MSV.js +0 -168
  193. package/dist/_node-chunks/plugin-5PD4YIUH.js +0 -129
  194. package/dist/_node-chunks/plugin-MONDT2WL.js +0 -159
  195. package/dist/_node-chunks/webpack-inject-mocker-runtime-plugin-EUZJRG3W.js +0 -69102
  196. package/dist/_node-chunks/webpack-mock-plugin-T4LDXEHE.js +0 -124
  197. package/dist/core-server/presets/webpack/loaders/storybook-mock-transform-loader.js +0 -36
  198. package/dist/core-server/presets/webpack/loaders/webpack-automock-loader.js +0 -33
package/dist/bin/core.js CHANGED
@@ -1,40 +1,37 @@
1
- import CJS_COMPAT_NODE_URL_jpweijb0qqj from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_jpweijb0qqj from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_jpweijb0qqj from "node:module";
1
+ import CJS_COMPAT_NODE_URL_hjmvusgt1gv from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_hjmvusgt1gv from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_hjmvusgt1gv from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_jpweijb0qqj.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_jpweijb0qqj.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_jpweijb0qqj.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_hjmvusgt1gv.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_hjmvusgt1gv.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_hjmvusgt1gv.createRequire(import.meta.url);
8
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration
11
11
  // ------------------------------------------------------------
12
12
  import {
13
13
  version
14
- } from "../_node-chunks/chunk-NILZM6KR.js";
14
+ } from "../_node-chunks/chunk-CBQKMXLQ.js";
15
15
  import {
16
16
  globalSettings
17
- } from "../_node-chunks/chunk-TJNGOQUH.js";
17
+ } from "../_node-chunks/chunk-56U5LEMP.js";
18
+ import "../_node-chunks/chunk-O5CGEVRI.js";
18
19
  import {
19
20
  require_dist
20
- } from "../_node-chunks/chunk-45YUOLTU.js";
21
+ } from "../_node-chunks/chunk-XGK6MVKR.js";
21
22
  import {
22
23
  require_picocolors
23
- } from "../_node-chunks/chunk-ATDHMMIZ.js";
24
+ } from "../_node-chunks/chunk-YWV55YW3.js";
24
25
  import {
25
26
  __commonJS,
26
- __name,
27
27
  __require,
28
28
  __toESM
29
- } from "../_node-chunks/chunk-3THWHQOC.js";
29
+ } from "../_node-chunks/chunk-UFOFO5H7.js";
30
30
 
31
31
  // ../node_modules/commander/lib/error.js
32
32
  var require_error = __commonJS({
33
33
  "../node_modules/commander/lib/error.js"(exports) {
34
34
  var CommanderError2 = class extends Error {
35
- static {
36
- __name(this, "CommanderError");
37
- }
38
35
  /**
39
36
  * Constructs the CommanderError class
40
37
  * @param {number} exitCode suggested exit code which could be used with process.exit
@@ -42,26 +39,15 @@ var require_error = __commonJS({
42
39
  * @param {string} message human-readable description of the error
43
40
  */
44
41
  constructor(exitCode, code, message) {
45
- super(message);
46
- Error.captureStackTrace(this, this.constructor);
47
- this.name = this.constructor.name;
48
- this.code = code;
49
- this.exitCode = exitCode;
50
- this.nestedError = void 0;
51
- }
52
- };
53
- var InvalidArgumentError2 = class extends CommanderError2 {
54
- static {
55
- __name(this, "InvalidArgumentError");
42
+ super(message), Error.captureStackTrace(this, this.constructor), this.name = this.constructor.name, this.code = code, this.exitCode = exitCode, this.nestedError = void 0;
56
43
  }
44
+ }, InvalidArgumentError2 = class extends CommanderError2 {
57
45
  /**
58
46
  * Constructs the InvalidArgumentError class
59
47
  * @param {string} [message] explanation of why argument is invalid
60
48
  */
61
49
  constructor(message) {
62
- super(1, "commander.invalidArgument", message);
63
- Error.captureStackTrace(this, this.constructor);
64
- this.name = this.constructor.name;
50
+ super(1, "commander.invalidArgument", message), Error.captureStackTrace(this, this.constructor), this.name = this.constructor.name;
65
51
  }
66
52
  };
67
53
  exports.CommanderError = CommanderError2;
@@ -72,11 +58,7 @@ var require_error = __commonJS({
72
58
  // ../node_modules/commander/lib/argument.js
73
59
  var require_argument = __commonJS({
74
60
  "../node_modules/commander/lib/argument.js"(exports) {
75
- var { InvalidArgumentError: InvalidArgumentError2 } = require_error();
76
- var Argument2 = class {
77
- static {
78
- __name(this, "Argument");
79
- }
61
+ var { InvalidArgumentError: InvalidArgumentError2 } = require_error(), Argument2 = class {
80
62
  /**
81
63
  * Initialize a new command argument with the given name and description.
82
64
  * The default is that the argument is required, and you can explicitly
@@ -86,30 +68,18 @@ var require_argument = __commonJS({
86
68
  * @param {string} [description]
87
69
  */
88
70
  constructor(name, description) {
89
- this.description = description || "";
90
- this.variadic = false;
91
- this.parseArg = void 0;
92
- this.defaultValue = void 0;
93
- this.defaultValueDescription = void 0;
94
- this.argChoices = void 0;
95
- switch (name[0]) {
71
+ switch (this.description = description || "", this.variadic = !1, this.parseArg = void 0, this.defaultValue = void 0, this.defaultValueDescription = void 0, this.argChoices = void 0, name[0]) {
96
72
  case "<":
97
- this.required = true;
98
- this._name = name.slice(1, -1);
73
+ this.required = !0, this._name = name.slice(1, -1);
99
74
  break;
100
75
  case "[":
101
- this.required = false;
102
- this._name = name.slice(1, -1);
76
+ this.required = !1, this._name = name.slice(1, -1);
103
77
  break;
104
78
  default:
105
- this.required = true;
106
- this._name = name;
79
+ this.required = !0, this._name = name;
107
80
  break;
108
81
  }
109
- if (this._name.endsWith("...")) {
110
- this.variadic = true;
111
- this._name = this._name.slice(0, -3);
112
- }
82
+ this._name.endsWith("...") && (this.variadic = !0, this._name = this._name.slice(0, -3));
113
83
  }
114
84
  /**
115
85
  * Return argument name.
@@ -123,11 +93,7 @@ var require_argument = __commonJS({
123
93
  * @package
124
94
  */
125
95
  _collectValue(value, previous) {
126
- if (previous === this.defaultValue || !Array.isArray(previous)) {
127
- return [value];
128
- }
129
- previous.push(value);
130
- return previous;
96
+ return previous === this.defaultValue || !Array.isArray(previous) ? [value] : (previous.push(value), previous);
131
97
  }
132
98
  /**
133
99
  * Set the default value, and optionally supply the description to be displayed in the help.
@@ -137,9 +103,7 @@ var require_argument = __commonJS({
137
103
  * @return {Argument}
138
104
  */
139
105
  default(value, description) {
140
- this.defaultValue = value;
141
- this.defaultValueDescription = description;
142
- return this;
106
+ return this.defaultValue = value, this.defaultValueDescription = description, this;
143
107
  }
144
108
  /**
145
109
  * Set the custom handler for processing CLI command arguments into argument values.
@@ -148,8 +112,7 @@ var require_argument = __commonJS({
148
112
  * @return {Argument}
149
113
  */
150
114
  argParser(fn) {
151
- this.parseArg = fn;
152
- return this;
115
+ return this.parseArg = fn, this;
153
116
  }
154
117
  /**
155
118
  * Only allow argument value to be one of choices.
@@ -158,19 +121,13 @@ var require_argument = __commonJS({
158
121
  * @return {Argument}
159
122
  */
160
123
  choices(values) {
161
- this.argChoices = values.slice();
162
- this.parseArg = (arg, previous) => {
163
- if (!this.argChoices.includes(arg)) {
124
+ return this.argChoices = values.slice(), this.parseArg = (arg, previous) => {
125
+ if (!this.argChoices.includes(arg))
164
126
  throw new InvalidArgumentError2(
165
127
  `Allowed choices are ${this.argChoices.join(", ")}.`
166
128
  );
167
- }
168
- if (this.variadic) {
169
- return this._collectValue(arg, previous);
170
- }
171
- return arg;
172
- };
173
- return this;
129
+ return this.variadic ? this._collectValue(arg, previous) : arg;
130
+ }, this;
174
131
  }
175
132
  /**
176
133
  * Make argument required.
@@ -178,8 +135,7 @@ var require_argument = __commonJS({
178
135
  * @returns {Argument}
179
136
  */
180
137
  argRequired() {
181
- this.required = true;
182
- return this;
138
+ return this.required = !0, this;
183
139
  }
184
140
  /**
185
141
  * Make argument optional.
@@ -187,15 +143,13 @@ var require_argument = __commonJS({
187
143
  * @returns {Argument}
188
144
  */
189
145
  argOptional() {
190
- this.required = false;
191
- return this;
146
+ return this.required = !1, this;
192
147
  }
193
148
  };
194
149
  function humanReadableArgName(arg) {
195
- const nameOutput = arg.name() + (arg.variadic === true ? "..." : "");
150
+ let nameOutput = arg.name() + (arg.variadic === !0 ? "..." : "");
196
151
  return arg.required ? "<" + nameOutput + ">" : "[" + nameOutput + "]";
197
152
  }
198
- __name(humanReadableArgName, "humanReadableArgName");
199
153
  exports.Argument = Argument2;
200
154
  exports.humanReadableArgName = humanReadableArgName;
201
155
  }
@@ -204,17 +158,9 @@ var require_argument = __commonJS({
204
158
  // ../node_modules/commander/lib/help.js
205
159
  var require_help = __commonJS({
206
160
  "../node_modules/commander/lib/help.js"(exports) {
207
- var { humanReadableArgName } = require_argument();
208
- var Help2 = class {
209
- static {
210
- __name(this, "Help");
211
- }
161
+ var { humanReadableArgName } = require_argument(), Help2 = class {
212
162
  constructor() {
213
- this.helpWidth = void 0;
214
- this.minWidthToWrap = 40;
215
- this.sortSubcommands = false;
216
- this.sortOptions = false;
217
- this.showGlobalOptions = false;
163
+ this.helpWidth = void 0, this.minWidthToWrap = 40, this.sortSubcommands = !1, this.sortOptions = !1, this.showGlobalOptions = !1;
218
164
  }
219
165
  /**
220
166
  * prepareContext is called by Commander after applying overrides from `Command.configureHelp()`
@@ -234,17 +180,8 @@ var require_help = __commonJS({
234
180
  * @returns {Command[]}
235
181
  */
236
182
  visibleCommands(cmd) {
237
- const visibleCommands = cmd.commands.filter((cmd2) => !cmd2._hidden);
238
- const helpCommand = cmd._getHelpCommand();
239
- if (helpCommand && !helpCommand._hidden) {
240
- visibleCommands.push(helpCommand);
241
- }
242
- if (this.sortSubcommands) {
243
- visibleCommands.sort((a, b) => {
244
- return a.name().localeCompare(b.name());
245
- });
246
- }
247
- return visibleCommands;
183
+ let visibleCommands = cmd.commands.filter((cmd2) => !cmd2._hidden), helpCommand = cmd._getHelpCommand();
184
+ return helpCommand && !helpCommand._hidden && visibleCommands.push(helpCommand), this.sortSubcommands && visibleCommands.sort((a, b) => a.name().localeCompare(b.name())), visibleCommands;
248
185
  }
249
186
  /**
250
187
  * Compare options for sort.
@@ -254,9 +191,7 @@ var require_help = __commonJS({
254
191
  * @returns {number}
255
192
  */
256
193
  compareOptions(a, b) {
257
- const getSortKey = /* @__PURE__ */ __name((option) => {
258
- return option.short ? option.short.replace(/^-/, "") : option.long.replace(/^--/, "");
259
- }, "getSortKey");
194
+ let getSortKey = (option) => option.short ? option.short.replace(/^-/, "") : option.long.replace(/^--/, "");
260
195
  return getSortKey(a).localeCompare(getSortKey(b));
261
196
  }
262
197
  /**
@@ -266,27 +201,16 @@ var require_help = __commonJS({
266
201
  * @returns {Option[]}
267
202
  */
268
203
  visibleOptions(cmd) {
269
- const visibleOptions = cmd.options.filter((option) => !option.hidden);
270
- const helpOption = cmd._getHelpOption();
204
+ let visibleOptions = cmd.options.filter((option) => !option.hidden), helpOption = cmd._getHelpOption();
271
205
  if (helpOption && !helpOption.hidden) {
272
- const removeShort = helpOption.short && cmd._findOption(helpOption.short);
273
- const removeLong = helpOption.long && cmd._findOption(helpOption.long);
274
- if (!removeShort && !removeLong) {
275
- visibleOptions.push(helpOption);
276
- } else if (helpOption.long && !removeLong) {
277
- visibleOptions.push(
278
- cmd.createOption(helpOption.long, helpOption.description)
279
- );
280
- } else if (helpOption.short && !removeShort) {
281
- visibleOptions.push(
282
- cmd.createOption(helpOption.short, helpOption.description)
283
- );
284
- }
285
- }
286
- if (this.sortOptions) {
287
- visibleOptions.sort(this.compareOptions);
206
+ let removeShort = helpOption.short && cmd._findOption(helpOption.short), removeLong = helpOption.long && cmd._findOption(helpOption.long);
207
+ !removeShort && !removeLong ? visibleOptions.push(helpOption) : helpOption.long && !removeLong ? visibleOptions.push(
208
+ cmd.createOption(helpOption.long, helpOption.description)
209
+ ) : helpOption.short && !removeShort && visibleOptions.push(
210
+ cmd.createOption(helpOption.short, helpOption.description)
211
+ );
288
212
  }
289
- return visibleOptions;
213
+ return this.sortOptions && visibleOptions.sort(this.compareOptions), visibleOptions;
290
214
  }
291
215
  /**
292
216
  * Get an array of the visible global options. (Not including help.)
@@ -296,17 +220,14 @@ var require_help = __commonJS({
296
220
  */
297
221
  visibleGlobalOptions(cmd) {
298
222
  if (!this.showGlobalOptions) return [];
299
- const globalOptions = [];
223
+ let globalOptions = [];
300
224
  for (let ancestorCmd = cmd.parent; ancestorCmd; ancestorCmd = ancestorCmd.parent) {
301
- const visibleOptions = ancestorCmd.options.filter(
225
+ let visibleOptions = ancestorCmd.options.filter(
302
226
  (option) => !option.hidden
303
227
  );
304
228
  globalOptions.push(...visibleOptions);
305
229
  }
306
- if (this.sortOptions) {
307
- globalOptions.sort(this.compareOptions);
308
- }
309
- return globalOptions;
230
+ return this.sortOptions && globalOptions.sort(this.compareOptions), globalOptions;
310
231
  }
311
232
  /**
312
233
  * Get an array of the arguments if any have a description.
@@ -315,15 +236,9 @@ var require_help = __commonJS({
315
236
  * @returns {Argument[]}
316
237
  */
317
238
  visibleArguments(cmd) {
318
- if (cmd._argsDescription) {
319
- cmd.registeredArguments.forEach((argument) => {
320
- argument.description = argument.description || cmd._argsDescription[argument.name()] || "";
321
- });
322
- }
323
- if (cmd.registeredArguments.find((argument) => argument.description)) {
324
- return cmd.registeredArguments;
325
- }
326
- return [];
239
+ return cmd._argsDescription && cmd.registeredArguments.forEach((argument) => {
240
+ argument.description = argument.description || cmd._argsDescription[argument.name()] || "";
241
+ }), cmd.registeredArguments.find((argument) => argument.description) ? cmd.registeredArguments : [];
327
242
  }
328
243
  /**
329
244
  * Get the command term to show in the list of subcommands.
@@ -332,7 +247,7 @@ var require_help = __commonJS({
332
247
  * @returns {string}
333
248
  */
334
249
  subcommandTerm(cmd) {
335
- const args = cmd.registeredArguments.map((arg) => humanReadableArgName(arg)).join(" ");
250
+ let args = cmd.registeredArguments.map((arg) => humanReadableArgName(arg)).join(" ");
336
251
  return cmd._name + (cmd._aliases[0] ? "|" + cmd._aliases[0] : "") + (cmd.options.length ? " [options]" : "") + // simplistic check for non-help option
337
252
  (args ? " " + args : "");
338
253
  }
@@ -362,14 +277,12 @@ var require_help = __commonJS({
362
277
  * @returns {number}
363
278
  */
364
279
  longestSubcommandTermLength(cmd, helper) {
365
- return helper.visibleCommands(cmd).reduce((max, command2) => {
366
- return Math.max(
367
- max,
368
- this.displayWidth(
369
- helper.styleSubcommandTerm(helper.subcommandTerm(command2))
370
- )
371
- );
372
- }, 0);
280
+ return helper.visibleCommands(cmd).reduce((max, command2) => Math.max(
281
+ max,
282
+ this.displayWidth(
283
+ helper.styleSubcommandTerm(helper.subcommandTerm(command2))
284
+ )
285
+ ), 0);
373
286
  }
374
287
  /**
375
288
  * Get the longest option term length.
@@ -379,12 +292,10 @@ var require_help = __commonJS({
379
292
  * @returns {number}
380
293
  */
381
294
  longestOptionTermLength(cmd, helper) {
382
- return helper.visibleOptions(cmd).reduce((max, option) => {
383
- return Math.max(
384
- max,
385
- this.displayWidth(helper.styleOptionTerm(helper.optionTerm(option)))
386
- );
387
- }, 0);
295
+ return helper.visibleOptions(cmd).reduce((max, option) => Math.max(
296
+ max,
297
+ this.displayWidth(helper.styleOptionTerm(helper.optionTerm(option)))
298
+ ), 0);
388
299
  }
389
300
  /**
390
301
  * Get the longest global option term length.
@@ -394,12 +305,10 @@ var require_help = __commonJS({
394
305
  * @returns {number}
395
306
  */
396
307
  longestGlobalOptionTermLength(cmd, helper) {
397
- return helper.visibleGlobalOptions(cmd).reduce((max, option) => {
398
- return Math.max(
399
- max,
400
- this.displayWidth(helper.styleOptionTerm(helper.optionTerm(option)))
401
- );
402
- }, 0);
308
+ return helper.visibleGlobalOptions(cmd).reduce((max, option) => Math.max(
309
+ max,
310
+ this.displayWidth(helper.styleOptionTerm(helper.optionTerm(option)))
311
+ ), 0);
403
312
  }
404
313
  /**
405
314
  * Get the longest argument term length.
@@ -409,14 +318,12 @@ var require_help = __commonJS({
409
318
  * @returns {number}
410
319
  */
411
320
  longestArgumentTermLength(cmd, helper) {
412
- return helper.visibleArguments(cmd).reduce((max, argument) => {
413
- return Math.max(
414
- max,
415
- this.displayWidth(
416
- helper.styleArgumentTerm(helper.argumentTerm(argument))
417
- )
418
- );
419
- }, 0);
321
+ return helper.visibleArguments(cmd).reduce((max, argument) => Math.max(
322
+ max,
323
+ this.displayWidth(
324
+ helper.styleArgumentTerm(helper.argumentTerm(argument))
325
+ )
326
+ ), 0);
420
327
  }
421
328
  /**
422
329
  * Get the command usage to be displayed at the top of the built-in help.
@@ -426,13 +333,10 @@ var require_help = __commonJS({
426
333
  */
427
334
  commandUsage(cmd) {
428
335
  let cmdName = cmd._name;
429
- if (cmd._aliases[0]) {
430
- cmdName = cmdName + "|" + cmd._aliases[0];
431
- }
336
+ cmd._aliases[0] && (cmdName = cmdName + "|" + cmd._aliases[0]);
432
337
  let ancestorCmdNames = "";
433
- for (let ancestorCmd = cmd.parent; ancestorCmd; ancestorCmd = ancestorCmd.parent) {
338
+ for (let ancestorCmd = cmd.parent; ancestorCmd; ancestorCmd = ancestorCmd.parent)
434
339
  ancestorCmdNames = ancestorCmd.name() + " " + ancestorCmdNames;
435
- }
436
340
  return ancestorCmdNames + cmdName + " " + cmd.usage();
437
341
  }
438
342
  /**
@@ -461,33 +365,15 @@ var require_help = __commonJS({
461
365
  * @return {string}
462
366
  */
463
367
  optionDescription(option) {
464
- const extraInfo = [];
465
- if (option.argChoices) {
466
- extraInfo.push(
467
- // use stringify to match the display of the default value
468
- `choices: ${option.argChoices.map((choice) => JSON.stringify(choice)).join(", ")}`
469
- );
470
- }
471
- if (option.defaultValue !== void 0) {
472
- const showDefault = option.required || option.optional || option.isBoolean() && typeof option.defaultValue === "boolean";
473
- if (showDefault) {
474
- extraInfo.push(
475
- `default: ${option.defaultValueDescription || JSON.stringify(option.defaultValue)}`
476
- );
477
- }
478
- }
479
- if (option.presetArg !== void 0 && option.optional) {
480
- extraInfo.push(`preset: ${JSON.stringify(option.presetArg)}`);
481
- }
482
- if (option.envVar !== void 0) {
483
- extraInfo.push(`env: ${option.envVar}`);
484
- }
485
- if (extraInfo.length > 0) {
486
- const extraDescription = `(${extraInfo.join(", ")})`;
487
- if (option.description) {
488
- return `${option.description} ${extraDescription}`;
489
- }
490
- return extraDescription;
368
+ let extraInfo = [];
369
+ if (option.argChoices && extraInfo.push(
370
+ // use stringify to match the display of the default value
371
+ `choices: ${option.argChoices.map((choice) => JSON.stringify(choice)).join(", ")}`
372
+ ), option.defaultValue !== void 0 && (option.required || option.optional || option.isBoolean() && typeof option.defaultValue == "boolean") && extraInfo.push(
373
+ `default: ${option.defaultValueDescription || JSON.stringify(option.defaultValue)}`
374
+ ), option.presetArg !== void 0 && option.optional && extraInfo.push(`preset: ${JSON.stringify(option.presetArg)}`), option.envVar !== void 0 && extraInfo.push(`env: ${option.envVar}`), extraInfo.length > 0) {
375
+ let extraDescription = `(${extraInfo.join(", ")})`;
376
+ return option.description ? `${option.description} ${extraDescription}` : extraDescription;
491
377
  }
492
378
  return option.description;
493
379
  }
@@ -498,24 +384,15 @@ var require_help = __commonJS({
498
384
  * @return {string}
499
385
  */
500
386
  argumentDescription(argument) {
501
- const extraInfo = [];
502
- if (argument.argChoices) {
503
- extraInfo.push(
504
- // use stringify to match the display of the default value
505
- `choices: ${argument.argChoices.map((choice) => JSON.stringify(choice)).join(", ")}`
506
- );
507
- }
508
- if (argument.defaultValue !== void 0) {
509
- extraInfo.push(
510
- `default: ${argument.defaultValueDescription || JSON.stringify(argument.defaultValue)}`
511
- );
512
- }
513
- if (extraInfo.length > 0) {
514
- const extraDescription = `(${extraInfo.join(", ")})`;
515
- if (argument.description) {
516
- return `${argument.description} ${extraDescription}`;
517
- }
518
- return extraDescription;
387
+ let extraInfo = [];
388
+ if (argument.argChoices && extraInfo.push(
389
+ // use stringify to match the display of the default value
390
+ `choices: ${argument.argChoices.map((choice) => JSON.stringify(choice)).join(", ")}`
391
+ ), argument.defaultValue !== void 0 && extraInfo.push(
392
+ `default: ${argument.defaultValueDescription || JSON.stringify(argument.defaultValue)}`
393
+ ), extraInfo.length > 0) {
394
+ let extraDescription = `(${extraInfo.join(", ")})`;
395
+ return argument.description ? `${argument.description} ${extraDescription}` : extraDescription;
519
396
  }
520
397
  return argument.description;
521
398
  }
@@ -528,8 +405,7 @@ var require_help = __commonJS({
528
405
  * @returns string[]
529
406
  */
530
407
  formatItemList(heading, items, helper) {
531
- if (items.length === 0) return [];
532
- return [helper.styleTitle(heading), ...items, ""];
408
+ return items.length === 0 ? [] : [helper.styleTitle(heading), ...items, ""];
533
409
  }
534
410
  /**
535
411
  * Group items by their help group heading.
@@ -540,19 +416,14 @@ var require_help = __commonJS({
540
416
  * @returns {Map<string, Command[] | Option[]>}
541
417
  */
542
418
  groupItems(unsortedItems, visibleItems, getGroup) {
543
- const result = /* @__PURE__ */ new Map();
544
- unsortedItems.forEach((item) => {
545
- const group = getGroup(item);
546
- if (!result.has(group)) result.set(group, []);
547
- });
548
- visibleItems.forEach((item) => {
549
- const group = getGroup(item);
550
- if (!result.has(group)) {
551
- result.set(group, []);
552
- }
553
- result.get(group).push(item);
554
- });
555
- return result;
419
+ let result = /* @__PURE__ */ new Map();
420
+ return unsortedItems.forEach((item) => {
421
+ let group = getGroup(item);
422
+ result.has(group) || result.set(group, []);
423
+ }), visibleItems.forEach((item) => {
424
+ let group = getGroup(item);
425
+ result.has(group) || result.set(group, []), result.get(group).push(item);
426
+ }), result;
556
427
  }
557
428
  /**
558
429
  * Generate the built-in help text.
@@ -562,75 +433,58 @@ var require_help = __commonJS({
562
433
  * @returns {string}
563
434
  */
564
435
  formatHelp(cmd, helper) {
565
- const termWidth = helper.padWidth(cmd, helper);
566
- const helpWidth = helper.helpWidth ?? 80;
436
+ let termWidth = helper.padWidth(cmd, helper), helpWidth = helper.helpWidth ?? 80;
567
437
  function callFormatItem(term, description) {
568
438
  return helper.formatItem(term, termWidth, description, helper);
569
439
  }
570
- __name(callFormatItem, "callFormatItem");
571
440
  let output = [
572
441
  `${helper.styleTitle("Usage:")} ${helper.styleUsage(helper.commandUsage(cmd))}`,
573
442
  ""
574
- ];
575
- const commandDescription = helper.commandDescription(cmd);
576
- if (commandDescription.length > 0) {
577
- output = output.concat([
578
- helper.boxWrap(
579
- helper.styleCommandDescription(commandDescription),
580
- helpWidth
581
- ),
582
- ""
583
- ]);
584
- }
585
- const argumentList = helper.visibleArguments(cmd).map((argument) => {
586
- return callFormatItem(
587
- helper.styleArgumentTerm(helper.argumentTerm(argument)),
588
- helper.styleArgumentDescription(helper.argumentDescription(argument))
589
- );
590
- });
591
- output = output.concat(
443
+ ], commandDescription = helper.commandDescription(cmd);
444
+ commandDescription.length > 0 && (output = output.concat([
445
+ helper.boxWrap(
446
+ helper.styleCommandDescription(commandDescription),
447
+ helpWidth
448
+ ),
449
+ ""
450
+ ]));
451
+ let argumentList = helper.visibleArguments(cmd).map((argument) => callFormatItem(
452
+ helper.styleArgumentTerm(helper.argumentTerm(argument)),
453
+ helper.styleArgumentDescription(helper.argumentDescription(argument))
454
+ ));
455
+ if (output = output.concat(
592
456
  this.formatItemList("Arguments:", argumentList, helper)
593
- );
594
- const optionGroups = this.groupItems(
457
+ ), this.groupItems(
595
458
  cmd.options,
596
459
  helper.visibleOptions(cmd),
597
460
  (option) => option.helpGroupHeading ?? "Options:"
598
- );
599
- optionGroups.forEach((options, group) => {
600
- const optionList = options.map((option) => {
601
- return callFormatItem(
602
- helper.styleOptionTerm(helper.optionTerm(option)),
603
- helper.styleOptionDescription(helper.optionDescription(option))
604
- );
605
- });
461
+ ).forEach((options, group) => {
462
+ let optionList = options.map((option) => callFormatItem(
463
+ helper.styleOptionTerm(helper.optionTerm(option)),
464
+ helper.styleOptionDescription(helper.optionDescription(option))
465
+ ));
606
466
  output = output.concat(this.formatItemList(group, optionList, helper));
607
- });
608
- if (helper.showGlobalOptions) {
609
- const globalOptionList = helper.visibleGlobalOptions(cmd).map((option) => {
610
- return callFormatItem(
611
- helper.styleOptionTerm(helper.optionTerm(option)),
612
- helper.styleOptionDescription(helper.optionDescription(option))
613
- );
614
- });
467
+ }), helper.showGlobalOptions) {
468
+ let globalOptionList = helper.visibleGlobalOptions(cmd).map((option) => callFormatItem(
469
+ helper.styleOptionTerm(helper.optionTerm(option)),
470
+ helper.styleOptionDescription(helper.optionDescription(option))
471
+ ));
615
472
  output = output.concat(
616
473
  this.formatItemList("Global Options:", globalOptionList, helper)
617
474
  );
618
475
  }
619
- const commandGroups = this.groupItems(
476
+ return this.groupItems(
620
477
  cmd.commands,
621
478
  helper.visibleCommands(cmd),
622
479
  (sub) => sub.helpGroup() || "Commands:"
623
- );
624
- commandGroups.forEach((commands, group) => {
625
- const commandList = commands.map((sub) => {
626
- return callFormatItem(
627
- helper.styleSubcommandTerm(helper.subcommandTerm(sub)),
628
- helper.styleSubcommandDescription(helper.subcommandDescription(sub))
629
- );
630
- });
480
+ ).forEach((commands, group) => {
481
+ let commandList = commands.map((sub) => callFormatItem(
482
+ helper.styleSubcommandTerm(helper.subcommandTerm(sub)),
483
+ helper.styleSubcommandDescription(helper.subcommandDescription(sub))
484
+ ));
631
485
  output = output.concat(this.formatItemList(group, commandList, helper));
632
- });
633
- return output.join("\n");
486
+ }), output.join(`
487
+ `);
634
488
  }
635
489
  /**
636
490
  * Return display width of string, ignoring ANSI escape sequences. Used in padding and wrapping calculations.
@@ -651,13 +505,7 @@ var require_help = __commonJS({
651
505
  return str;
652
506
  }
653
507
  styleUsage(str) {
654
- return str.split(" ").map((word) => {
655
- if (word === "[options]") return this.styleOptionText(word);
656
- if (word === "[command]") return this.styleSubcommandText(word);
657
- if (word[0] === "[" || word[0] === "<")
658
- return this.styleArgumentText(word);
659
- return this.styleCommandText(word);
660
- }).join(" ");
508
+ return str.split(" ").map((word) => word === "[options]" ? this.styleOptionText(word) : word === "[command]" ? this.styleSubcommandText(word) : word[0] === "[" || word[0] === "<" ? this.styleArgumentText(word) : this.styleCommandText(word)).join(" ");
661
509
  }
662
510
  styleCommandDescription(str) {
663
511
  return this.styleDescriptionText(str);
@@ -678,12 +526,7 @@ var require_help = __commonJS({
678
526
  return this.styleOptionText(str);
679
527
  }
680
528
  styleSubcommandTerm(str) {
681
- return str.split(" ").map((word) => {
682
- if (word === "[options]") return this.styleOptionText(word);
683
- if (word[0] === "[" || word[0] === "<")
684
- return this.styleArgumentText(word);
685
- return this.styleSubcommandText(word);
686
- }).join(" ");
529
+ return str.split(" ").map((word) => word === "[options]" ? this.styleOptionText(word) : word[0] === "[" || word[0] === "<" ? this.styleArgumentText(word) : this.styleSubcommandText(word)).join(" ");
687
530
  }
688
531
  styleArgumentTerm(str) {
689
532
  return this.styleArgumentText(str);
@@ -738,26 +581,16 @@ var require_help = __commonJS({
738
581
  * @returns {string}
739
582
  */
740
583
  formatItem(term, termWidth, description, helper) {
741
- const itemIndent = 2;
742
- const itemIndentStr = " ".repeat(itemIndent);
584
+ let itemIndentStr = " ".repeat(2);
743
585
  if (!description) return itemIndentStr + term;
744
- const paddedTerm = term.padEnd(
586
+ let paddedTerm = term.padEnd(
745
587
  termWidth + term.length - helper.displayWidth(term)
746
- );
747
- const spacerWidth = 2;
748
- const helpWidth = this.helpWidth ?? 80;
749
- const remainingWidth = helpWidth - termWidth - spacerWidth - itemIndent;
750
- let formattedDescription;
751
- if (remainingWidth < this.minWidthToWrap || helper.preformatted(description)) {
752
- formattedDescription = description;
753
- } else {
754
- const wrappedDescription = helper.boxWrap(description, remainingWidth);
755
- formattedDescription = wrappedDescription.replace(
756
- /\n/g,
757
- "\n" + " ".repeat(termWidth + spacerWidth)
758
- );
759
- }
760
- return itemIndentStr + paddedTerm + " ".repeat(spacerWidth) + formattedDescription.replace(/\n/g, `
588
+ ), spacerWidth = 2, remainingWidth = (this.helpWidth ?? 80) - termWidth - spacerWidth - 2, formattedDescription;
589
+ return remainingWidth < this.minWidthToWrap || helper.preformatted(description) ? formattedDescription = description : formattedDescription = helper.boxWrap(description, remainingWidth).replace(
590
+ /\n/g,
591
+ `
592
+ ` + " ".repeat(termWidth + spacerWidth)
593
+ ), itemIndentStr + paddedTerm + " ".repeat(spacerWidth) + formattedDescription.replace(/\n/g, `
761
594
  ${itemIndentStr}`);
762
595
  }
763
596
  /**
@@ -770,39 +603,32 @@ ${itemIndentStr}`);
770
603
  */
771
604
  boxWrap(str, width) {
772
605
  if (width < this.minWidthToWrap) return str;
773
- const rawLines = str.split(/\r\n|\n/);
774
- const chunkPattern = /[\s]*[^\s]+/g;
775
- const wrappedLines = [];
776
- rawLines.forEach((line) => {
777
- const chunks = line.match(chunkPattern);
606
+ let rawLines = str.split(/\r\n|\n/), chunkPattern = /[\s]*[^\s]+/g, wrappedLines = [];
607
+ return rawLines.forEach((line) => {
608
+ let chunks = line.match(chunkPattern);
778
609
  if (chunks === null) {
779
610
  wrappedLines.push("");
780
611
  return;
781
612
  }
782
- let sumChunks = [chunks.shift()];
783
- let sumWidth = this.displayWidth(sumChunks[0]);
613
+ let sumChunks = [chunks.shift()], sumWidth = this.displayWidth(sumChunks[0]);
784
614
  chunks.forEach((chunk) => {
785
- const visibleWidth = this.displayWidth(chunk);
615
+ let visibleWidth = this.displayWidth(chunk);
786
616
  if (sumWidth + visibleWidth <= width) {
787
- sumChunks.push(chunk);
788
- sumWidth += visibleWidth;
617
+ sumChunks.push(chunk), sumWidth += visibleWidth;
789
618
  return;
790
619
  }
791
620
  wrappedLines.push(sumChunks.join(""));
792
- const nextChunk = chunk.trimStart();
793
- sumChunks = [nextChunk];
794
- sumWidth = this.displayWidth(nextChunk);
795
- });
796
- wrappedLines.push(sumChunks.join(""));
797
- });
798
- return wrappedLines.join("\n");
621
+ let nextChunk = chunk.trimStart();
622
+ sumChunks = [nextChunk], sumWidth = this.displayWidth(nextChunk);
623
+ }), wrappedLines.push(sumChunks.join(""));
624
+ }), wrappedLines.join(`
625
+ `);
799
626
  }
800
627
  };
801
628
  function stripColor(str) {
802
- const sgrPattern = /\x1b\[\d*(;\d*)*m/g;
629
+ let sgrPattern = /\x1b\[\d*(;\d*)*m/g;
803
630
  return str.replace(sgrPattern, "");
804
631
  }
805
- __name(stripColor, "stripColor");
806
632
  exports.Help = Help2;
807
633
  exports.stripColor = stripColor;
808
634
  }
@@ -811,11 +637,7 @@ ${itemIndentStr}`);
811
637
  // ../node_modules/commander/lib/option.js
812
638
  var require_option = __commonJS({
813
639
  "../node_modules/commander/lib/option.js"(exports) {
814
- var { InvalidArgumentError: InvalidArgumentError2 } = require_error();
815
- var Option2 = class {
816
- static {
817
- __name(this, "Option");
818
- }
640
+ var { InvalidArgumentError: InvalidArgumentError2 } = require_error(), Option2 = class {
819
641
  /**
820
642
  * Initialize a new `Option` with the given `flags` and `description`.
821
643
  *
@@ -823,29 +645,9 @@ var require_option = __commonJS({
823
645
  * @param {string} [description]
824
646
  */
825
647
  constructor(flags, description) {
826
- this.flags = flags;
827
- this.description = description || "";
828
- this.required = flags.includes("<");
829
- this.optional = flags.includes("[");
830
- this.variadic = /\w\.\.\.[>\]]$/.test(flags);
831
- this.mandatory = false;
832
- const optionFlags = splitOptionFlags(flags);
833
- this.short = optionFlags.shortFlag;
834
- this.long = optionFlags.longFlag;
835
- this.negate = false;
836
- if (this.long) {
837
- this.negate = this.long.startsWith("--no-");
838
- }
839
- this.defaultValue = void 0;
840
- this.defaultValueDescription = void 0;
841
- this.presetArg = void 0;
842
- this.envVar = void 0;
843
- this.parseArg = void 0;
844
- this.hidden = false;
845
- this.argChoices = void 0;
846
- this.conflictsWith = [];
847
- this.implied = void 0;
848
- this.helpGroupHeading = void 0;
648
+ this.flags = flags, this.description = description || "", this.required = flags.includes("<"), this.optional = flags.includes("["), this.variadic = /\w\.\.\.[>\]]$/.test(flags), this.mandatory = !1;
649
+ let optionFlags = splitOptionFlags(flags);
650
+ this.short = optionFlags.shortFlag, this.long = optionFlags.longFlag, this.negate = !1, this.long && (this.negate = this.long.startsWith("--no-")), this.defaultValue = void 0, this.defaultValueDescription = void 0, this.presetArg = void 0, this.envVar = void 0, this.parseArg = void 0, this.hidden = !1, this.argChoices = void 0, this.conflictsWith = [], this.implied = void 0, this.helpGroupHeading = void 0;
849
651
  }
850
652
  /**
851
653
  * Set the default value, and optionally supply the description to be displayed in the help.
@@ -855,9 +657,7 @@ var require_option = __commonJS({
855
657
  * @return {Option}
856
658
  */
857
659
  default(value, description) {
858
- this.defaultValue = value;
859
- this.defaultValueDescription = description;
860
- return this;
660
+ return this.defaultValue = value, this.defaultValueDescription = description, this;
861
661
  }
862
662
  /**
863
663
  * Preset to use when option used without option-argument, especially optional but also boolean and negated.
@@ -871,8 +671,7 @@ var require_option = __commonJS({
871
671
  * @return {Option}
872
672
  */
873
673
  preset(arg) {
874
- this.presetArg = arg;
875
- return this;
674
+ return this.presetArg = arg, this;
876
675
  }
877
676
  /**
878
677
  * Add option name(s) that conflict with this option.
@@ -886,8 +685,7 @@ var require_option = __commonJS({
886
685
  * @return {Option}
887
686
  */
888
687
  conflicts(names) {
889
- this.conflictsWith = this.conflictsWith.concat(names);
890
- return this;
688
+ return this.conflictsWith = this.conflictsWith.concat(names), this;
891
689
  }
892
690
  /**
893
691
  * Specify implied option values for when this option is set and the implied options are not.
@@ -904,11 +702,7 @@ var require_option = __commonJS({
904
702
  */
905
703
  implies(impliedOptionValues) {
906
704
  let newImplied = impliedOptionValues;
907
- if (typeof impliedOptionValues === "string") {
908
- newImplied = { [impliedOptionValues]: true };
909
- }
910
- this.implied = Object.assign(this.implied || {}, newImplied);
911
- return this;
705
+ return typeof impliedOptionValues == "string" && (newImplied = { [impliedOptionValues]: !0 }), this.implied = Object.assign(this.implied || {}, newImplied), this;
912
706
  }
913
707
  /**
914
708
  * Set environment variable to check for option value.
@@ -920,8 +714,7 @@ var require_option = __commonJS({
920
714
  * @return {Option}
921
715
  */
922
716
  env(name) {
923
- this.envVar = name;
924
- return this;
717
+ return this.envVar = name, this;
925
718
  }
926
719
  /**
927
720
  * Set the custom handler for processing CLI option arguments into option values.
@@ -930,8 +723,7 @@ var require_option = __commonJS({
930
723
  * @return {Option}
931
724
  */
932
725
  argParser(fn) {
933
- this.parseArg = fn;
934
- return this;
726
+ return this.parseArg = fn, this;
935
727
  }
936
728
  /**
937
729
  * Whether the option is mandatory and must have a value after parsing.
@@ -939,9 +731,8 @@ var require_option = __commonJS({
939
731
  * @param {boolean} [mandatory=true]
940
732
  * @return {Option}
941
733
  */
942
- makeOptionMandatory(mandatory = true) {
943
- this.mandatory = !!mandatory;
944
- return this;
734
+ makeOptionMandatory(mandatory = !0) {
735
+ return this.mandatory = !!mandatory, this;
945
736
  }
946
737
  /**
947
738
  * Hide option in help.
@@ -949,19 +740,14 @@ var require_option = __commonJS({
949
740
  * @param {boolean} [hide=true]
950
741
  * @return {Option}
951
742
  */
952
- hideHelp(hide = true) {
953
- this.hidden = !!hide;
954
- return this;
743
+ hideHelp(hide = !0) {
744
+ return this.hidden = !!hide, this;
955
745
  }
956
746
  /**
957
747
  * @package
958
748
  */
959
749
  _collectValue(value, previous) {
960
- if (previous === this.defaultValue || !Array.isArray(previous)) {
961
- return [value];
962
- }
963
- previous.push(value);
964
- return previous;
750
+ return previous === this.defaultValue || !Array.isArray(previous) ? [value] : (previous.push(value), previous);
965
751
  }
966
752
  /**
967
753
  * Only allow option value to be one of choices.
@@ -970,19 +756,13 @@ var require_option = __commonJS({
970
756
  * @return {Option}
971
757
  */
972
758
  choices(values) {
973
- this.argChoices = values.slice();
974
- this.parseArg = (arg, previous) => {
975
- if (!this.argChoices.includes(arg)) {
759
+ return this.argChoices = values.slice(), this.parseArg = (arg, previous) => {
760
+ if (!this.argChoices.includes(arg))
976
761
  throw new InvalidArgumentError2(
977
762
  `Allowed choices are ${this.argChoices.join(", ")}.`
978
763
  );
979
- }
980
- if (this.variadic) {
981
- return this._collectValue(arg, previous);
982
- }
983
- return arg;
984
- };
985
- return this;
764
+ return this.variadic ? this._collectValue(arg, previous) : arg;
765
+ }, this;
986
766
  }
987
767
  /**
988
768
  * Return option name.
@@ -990,10 +770,7 @@ var require_option = __commonJS({
990
770
  * @return {string}
991
771
  */
992
772
  name() {
993
- if (this.long) {
994
- return this.long.replace(/^--/, "");
995
- }
996
- return this.short.replace(/^-/, "");
773
+ return this.long ? this.long.replace(/^--/, "") : this.short.replace(/^-/, "");
997
774
  }
998
775
  /**
999
776
  * Return option name, in a camelcase format that can be used
@@ -1002,10 +779,7 @@ var require_option = __commonJS({
1002
779
  * @return {string}
1003
780
  */
1004
781
  attributeName() {
1005
- if (this.negate) {
1006
- return camelcase(this.name().replace(/^no-/, ""));
1007
- }
1008
- return camelcase(this.name());
782
+ return this.negate ? camelcase(this.name().replace(/^no-/, "")) : camelcase(this.name());
1009
783
  }
1010
784
  /**
1011
785
  * Set the help group heading.
@@ -1014,8 +788,7 @@ var require_option = __commonJS({
1014
788
  * @return {Option}
1015
789
  */
1016
790
  helpGroup(heading) {
1017
- this.helpGroupHeading = heading;
1018
- return this;
791
+ return this.helpGroupHeading = heading, this;
1019
792
  }
1020
793
  /**
1021
794
  * Check if `arg` matches the short or long flag.
@@ -1038,29 +811,15 @@ var require_option = __commonJS({
1038
811
  isBoolean() {
1039
812
  return !this.required && !this.optional && !this.negate;
1040
813
  }
1041
- };
1042
- var DualOptions = class {
1043
- static {
1044
- __name(this, "DualOptions");
1045
- }
814
+ }, DualOptions = class {
1046
815
  /**
1047
816
  * @param {Option[]} options
1048
817
  */
1049
818
  constructor(options) {
1050
- this.positiveOptions = /* @__PURE__ */ new Map();
1051
- this.negativeOptions = /* @__PURE__ */ new Map();
1052
- this.dualOptions = /* @__PURE__ */ new Set();
1053
- options.forEach((option) => {
1054
- if (option.negate) {
1055
- this.negativeOptions.set(option.attributeName(), option);
1056
- } else {
1057
- this.positiveOptions.set(option.attributeName(), option);
1058
- }
1059
- });
1060
- this.negativeOptions.forEach((value, key) => {
1061
- if (this.positiveOptions.has(key)) {
1062
- this.dualOptions.add(key);
1063
- }
819
+ this.positiveOptions = /* @__PURE__ */ new Map(), this.negativeOptions = /* @__PURE__ */ new Map(), this.dualOptions = /* @__PURE__ */ new Set(), options.forEach((option) => {
820
+ option.negate ? this.negativeOptions.set(option.attributeName(), option) : this.positiveOptions.set(option.attributeName(), option);
821
+ }), this.negativeOptions.forEach((value, key) => {
822
+ this.positiveOptions.has(key) && this.dualOptions.add(key);
1064
823
  });
1065
824
  }
1066
825
  /**
@@ -1071,50 +830,27 @@ var require_option = __commonJS({
1071
830
  * @returns {boolean}
1072
831
  */
1073
832
  valueFromOption(value, option) {
1074
- const optionKey = option.attributeName();
1075
- if (!this.dualOptions.has(optionKey)) return true;
1076
- const preset = this.negativeOptions.get(optionKey).presetArg;
1077
- const negativeValue = preset !== void 0 ? preset : false;
833
+ let optionKey = option.attributeName();
834
+ if (!this.dualOptions.has(optionKey)) return !0;
835
+ let preset = this.negativeOptions.get(optionKey).presetArg, negativeValue = preset !== void 0 ? preset : !1;
1078
836
  return option.negate === (negativeValue === value);
1079
837
  }
1080
838
  };
1081
839
  function camelcase(str) {
1082
- return str.split("-").reduce((str2, word) => {
1083
- return str2 + word[0].toUpperCase() + word.slice(1);
1084
- });
840
+ return str.split("-").reduce((str2, word) => str2 + word[0].toUpperCase() + word.slice(1));
1085
841
  }
1086
- __name(camelcase, "camelcase");
1087
842
  function splitOptionFlags(flags) {
1088
- let shortFlag;
1089
- let longFlag;
1090
- const shortFlagExp = /^-[^-]$/;
1091
- const longFlagExp = /^--[^-]/;
1092
- const flagParts = flags.split(/[ |,]+/).concat("guard");
1093
- if (shortFlagExp.test(flagParts[0])) shortFlag = flagParts.shift();
1094
- if (longFlagExp.test(flagParts[0])) longFlag = flagParts.shift();
1095
- if (!shortFlag && shortFlagExp.test(flagParts[0]))
1096
- shortFlag = flagParts.shift();
1097
- if (!shortFlag && longFlagExp.test(flagParts[0])) {
1098
- shortFlag = longFlag;
1099
- longFlag = flagParts.shift();
1100
- }
1101
- if (flagParts[0].startsWith("-")) {
1102
- const unsupportedFlag = flagParts[0];
1103
- const baseError = `option creation failed due to '${unsupportedFlag}' in option flags '${flags}'`;
1104
- if (/^-[^-][^-]/.test(unsupportedFlag))
1105
- throw new Error(
1106
- `${baseError}
843
+ let shortFlag, longFlag, shortFlagExp = /^-[^-]$/, longFlagExp = /^--[^-]/, flagParts = flags.split(/[ |,]+/).concat("guard");
844
+ if (shortFlagExp.test(flagParts[0]) && (shortFlag = flagParts.shift()), longFlagExp.test(flagParts[0]) && (longFlag = flagParts.shift()), !shortFlag && shortFlagExp.test(flagParts[0]) && (shortFlag = flagParts.shift()), !shortFlag && longFlagExp.test(flagParts[0]) && (shortFlag = longFlag, longFlag = flagParts.shift()), flagParts[0].startsWith("-")) {
845
+ let unsupportedFlag = flagParts[0], baseError = `option creation failed due to '${unsupportedFlag}' in option flags '${flags}'`;
846
+ throw /^-[^-][^-]/.test(unsupportedFlag) ? new Error(
847
+ `${baseError}
1107
848
  - a short flag is a single dash and a single character
1108
849
  - either use a single dash and a single character (for a short flag)
1109
850
  - or use a double dash for a long option (and can have two, like '--ws, --workspace')`
1110
- );
1111
- if (shortFlagExp.test(unsupportedFlag))
1112
- throw new Error(`${baseError}
1113
- - too many short flags`);
1114
- if (longFlagExp.test(unsupportedFlag))
1115
- throw new Error(`${baseError}
1116
- - too many long flags`);
1117
- throw new Error(`${baseError}
851
+ ) : shortFlagExp.test(unsupportedFlag) ? new Error(`${baseError}
852
+ - too many short flags`) : longFlagExp.test(unsupportedFlag) ? new Error(`${baseError}
853
+ - too many long flags`) : new Error(`${baseError}
1118
854
  - unrecognised flag format`);
1119
855
  }
1120
856
  if (shortFlag === void 0 && longFlag === void 0)
@@ -1123,7 +859,6 @@ var require_option = __commonJS({
1123
859
  );
1124
860
  return { shortFlag, longFlag };
1125
861
  }
1126
- __name(splitOptionFlags, "splitOptionFlags");
1127
862
  exports.Option = Option2;
1128
863
  exports.DualOptions = DualOptions;
1129
864
  }
@@ -1132,81 +867,42 @@ var require_option = __commonJS({
1132
867
  // ../node_modules/commander/lib/suggestSimilar.js
1133
868
  var require_suggestSimilar = __commonJS({
1134
869
  "../node_modules/commander/lib/suggestSimilar.js"(exports) {
1135
- var maxDistance = 3;
1136
870
  function editDistance(a, b) {
1137
- if (Math.abs(a.length - b.length) > maxDistance)
871
+ if (Math.abs(a.length - b.length) > 3)
1138
872
  return Math.max(a.length, b.length);
1139
- const d = [];
1140
- for (let i = 0; i <= a.length; i++) {
873
+ let d = [];
874
+ for (let i = 0; i <= a.length; i++)
1141
875
  d[i] = [i];
1142
- }
1143
- for (let j = 0; j <= b.length; j++) {
876
+ for (let j = 0; j <= b.length; j++)
1144
877
  d[0][j] = j;
1145
- }
1146
- for (let j = 1; j <= b.length; j++) {
878
+ for (let j = 1; j <= b.length; j++)
1147
879
  for (let i = 1; i <= a.length; i++) {
1148
880
  let cost = 1;
1149
- if (a[i - 1] === b[j - 1]) {
1150
- cost = 0;
1151
- } else {
1152
- cost = 1;
1153
- }
1154
- d[i][j] = Math.min(
881
+ a[i - 1] === b[j - 1] ? cost = 0 : cost = 1, d[i][j] = Math.min(
1155
882
  d[i - 1][j] + 1,
1156
883
  // deletion
1157
884
  d[i][j - 1] + 1,
1158
885
  // insertion
1159
886
  d[i - 1][j - 1] + cost
1160
887
  // substitution
1161
- );
1162
- if (i > 1 && j > 1 && a[i - 1] === b[j - 2] && a[i - 2] === b[j - 1]) {
1163
- d[i][j] = Math.min(d[i][j], d[i - 2][j - 2] + 1);
1164
- }
888
+ ), i > 1 && j > 1 && a[i - 1] === b[j - 2] && a[i - 2] === b[j - 1] && (d[i][j] = Math.min(d[i][j], d[i - 2][j - 2] + 1));
1165
889
  }
1166
- }
1167
890
  return d[a.length][b.length];
1168
891
  }
1169
- __name(editDistance, "editDistance");
1170
892
  function suggestSimilar(word, candidates) {
1171
893
  if (!candidates || candidates.length === 0) return "";
1172
894
  candidates = Array.from(new Set(candidates));
1173
- const searchingOptions = word.startsWith("--");
1174
- if (searchingOptions) {
1175
- word = word.slice(2);
1176
- candidates = candidates.map((candidate) => candidate.slice(2));
1177
- }
1178
- let similar = [];
1179
- let bestDistance = maxDistance;
1180
- const minSimilarity = 0.4;
1181
- candidates.forEach((candidate) => {
895
+ let searchingOptions = word.startsWith("--");
896
+ searchingOptions && (word = word.slice(2), candidates = candidates.map((candidate) => candidate.slice(2)));
897
+ let similar = [], bestDistance = 3, minSimilarity = 0.4;
898
+ return candidates.forEach((candidate) => {
1182
899
  if (candidate.length <= 1) return;
1183
- const distance = editDistance(word, candidate);
1184
- const length = Math.max(word.length, candidate.length);
1185
- const similarity = (length - distance) / length;
1186
- if (similarity > minSimilarity) {
1187
- if (distance < bestDistance) {
1188
- bestDistance = distance;
1189
- similar = [candidate];
1190
- } else if (distance === bestDistance) {
1191
- similar.push(candidate);
1192
- }
1193
- }
1194
- });
1195
- similar.sort((a, b) => a.localeCompare(b));
1196
- if (searchingOptions) {
1197
- similar = similar.map((candidate) => `--${candidate}`);
1198
- }
1199
- if (similar.length > 1) {
1200
- return `
1201
- (Did you mean one of ${similar.join(", ")}?)`;
1202
- }
1203
- if (similar.length === 1) {
1204
- return `
1205
- (Did you mean ${similar[0]}?)`;
1206
- }
1207
- return "";
900
+ let distance = editDistance(word, candidate), length = Math.max(word.length, candidate.length);
901
+ (length - distance) / length > minSimilarity && (distance < bestDistance ? (bestDistance = distance, similar = [candidate]) : distance === bestDistance && similar.push(candidate));
902
+ }), similar.sort((a, b) => a.localeCompare(b)), searchingOptions && (similar = similar.map((candidate) => `--${candidate}`)), similar.length > 1 ? `
903
+ (Did you mean one of ${similar.join(", ")}?)` : similar.length === 1 ? `
904
+ (Did you mean ${similar[0]}?)` : "";
1208
905
  }
1209
- __name(suggestSimilar, "suggestSimilar");
1210
906
  exports.suggestSimilar = suggestSimilar;
1211
907
  }
1212
908
  });
@@ -1214,77 +910,23 @@ var require_suggestSimilar = __commonJS({
1214
910
  // ../node_modules/commander/lib/command.js
1215
911
  var require_command = __commonJS({
1216
912
  "../node_modules/commander/lib/command.js"(exports) {
1217
- var EventEmitter = __require("node:events").EventEmitter;
1218
- var childProcess = __require("node:child_process");
1219
- var path = __require("node:path");
1220
- var fs = __require("node:fs");
1221
- var process2 = __require("node:process");
1222
- var { Argument: Argument2, humanReadableArgName } = require_argument();
1223
- var { CommanderError: CommanderError2 } = require_error();
1224
- var { Help: Help2, stripColor } = require_help();
1225
- var { Option: Option2, DualOptions } = require_option();
1226
- var { suggestSimilar } = require_suggestSimilar();
1227
- var Command2 = class _Command extends EventEmitter {
1228
- static {
1229
- __name(this, "Command");
1230
- }
913
+ var EventEmitter = __require("node:events").EventEmitter, childProcess = __require("node:child_process"), path = __require("node:path"), fs = __require("node:fs"), process2 = __require("node:process"), { Argument: Argument2, humanReadableArgName } = require_argument(), { CommanderError: CommanderError2 } = require_error(), { Help: Help2, stripColor } = require_help(), { Option: Option2, DualOptions } = require_option(), { suggestSimilar } = require_suggestSimilar(), Command2 = class _Command extends EventEmitter {
1231
914
  /**
1232
915
  * Initialize a new `Command`.
1233
916
  *
1234
917
  * @param {string} [name]
1235
918
  */
1236
919
  constructor(name) {
1237
- super();
1238
- this.commands = [];
1239
- this.options = [];
1240
- this.parent = null;
1241
- this._allowUnknownOption = false;
1242
- this._allowExcessArguments = false;
1243
- this.registeredArguments = [];
1244
- this._args = this.registeredArguments;
1245
- this.args = [];
1246
- this.rawArgs = [];
1247
- this.processedArgs = [];
1248
- this._scriptPath = null;
1249
- this._name = name || "";
1250
- this._optionValues = {};
1251
- this._optionValueSources = {};
1252
- this._storeOptionsAsProperties = false;
1253
- this._actionHandler = null;
1254
- this._executableHandler = false;
1255
- this._executableFile = null;
1256
- this._executableDir = null;
1257
- this._defaultCommandName = null;
1258
- this._exitCallback = null;
1259
- this._aliases = [];
1260
- this._combineFlagAndOptionalValue = true;
1261
- this._description = "";
1262
- this._summary = "";
1263
- this._argsDescription = void 0;
1264
- this._enablePositionalOptions = false;
1265
- this._passThroughOptions = false;
1266
- this._lifeCycleHooks = {};
1267
- this._showHelpAfterError = false;
1268
- this._showSuggestionAfterError = true;
1269
- this._savedState = null;
1270
- this._outputConfiguration = {
1271
- writeOut: /* @__PURE__ */ __name((str) => process2.stdout.write(str), "writeOut"),
1272
- writeErr: /* @__PURE__ */ __name((str) => process2.stderr.write(str), "writeErr"),
1273
- outputError: /* @__PURE__ */ __name((str, write) => write(str), "outputError"),
1274
- getOutHelpWidth: /* @__PURE__ */ __name(() => process2.stdout.isTTY ? process2.stdout.columns : void 0, "getOutHelpWidth"),
1275
- getErrHelpWidth: /* @__PURE__ */ __name(() => process2.stderr.isTTY ? process2.stderr.columns : void 0, "getErrHelpWidth"),
1276
- getOutHasColors: /* @__PURE__ */ __name(() => useColor() ?? (process2.stdout.isTTY && process2.stdout.hasColors?.()), "getOutHasColors"),
1277
- getErrHasColors: /* @__PURE__ */ __name(() => useColor() ?? (process2.stderr.isTTY && process2.stderr.hasColors?.()), "getErrHasColors"),
1278
- stripColor: /* @__PURE__ */ __name((str) => stripColor(str), "stripColor")
1279
- };
1280
- this._hidden = false;
1281
- this._helpOption = void 0;
1282
- this._addImplicitHelpCommand = void 0;
1283
- this._helpCommand = void 0;
1284
- this._helpConfiguration = {};
1285
- this._helpGroupHeading = void 0;
1286
- this._defaultCommandGroup = void 0;
1287
- this._defaultOptionGroup = void 0;
920
+ super(), this.commands = [], this.options = [], this.parent = null, this._allowUnknownOption = !1, this._allowExcessArguments = !1, this.registeredArguments = [], this._args = this.registeredArguments, this.args = [], this.rawArgs = [], this.processedArgs = [], this._scriptPath = null, this._name = name || "", this._optionValues = {}, this._optionValueSources = {}, this._storeOptionsAsProperties = !1, this._actionHandler = null, this._executableHandler = !1, this._executableFile = null, this._executableDir = null, this._defaultCommandName = null, this._exitCallback = null, this._aliases = [], this._combineFlagAndOptionalValue = !0, this._description = "", this._summary = "", this._argsDescription = void 0, this._enablePositionalOptions = !1, this._passThroughOptions = !1, this._lifeCycleHooks = {}, this._showHelpAfterError = !1, this._showSuggestionAfterError = !0, this._savedState = null, this._outputConfiguration = {
921
+ writeOut: (str) => process2.stdout.write(str),
922
+ writeErr: (str) => process2.stderr.write(str),
923
+ outputError: (str, write) => write(str),
924
+ getOutHelpWidth: () => process2.stdout.isTTY ? process2.stdout.columns : void 0,
925
+ getErrHelpWidth: () => process2.stderr.isTTY ? process2.stderr.columns : void 0,
926
+ getOutHasColors: () => useColor() ?? (process2.stdout.isTTY && process2.stdout.hasColors?.()),
927
+ getErrHasColors: () => useColor() ?? (process2.stderr.isTTY && process2.stderr.hasColors?.()),
928
+ stripColor: (str) => stripColor(str)
929
+ }, this._hidden = !1, this._helpOption = void 0, this._addImplicitHelpCommand = void 0, this._helpCommand = void 0, this._helpConfiguration = {}, this._helpGroupHeading = void 0, this._defaultCommandGroup = void 0, this._defaultOptionGroup = void 0;
1288
930
  }
1289
931
  /**
1290
932
  * Copy settings that are useful to have in common across root command and subcommands.
@@ -1295,28 +937,16 @@ var require_command = __commonJS({
1295
937
  * @return {Command} `this` command for chaining
1296
938
  */
1297
939
  copyInheritedSettings(sourceCommand) {
1298
- this._outputConfiguration = sourceCommand._outputConfiguration;
1299
- this._helpOption = sourceCommand._helpOption;
1300
- this._helpCommand = sourceCommand._helpCommand;
1301
- this._helpConfiguration = sourceCommand._helpConfiguration;
1302
- this._exitCallback = sourceCommand._exitCallback;
1303
- this._storeOptionsAsProperties = sourceCommand._storeOptionsAsProperties;
1304
- this._combineFlagAndOptionalValue = sourceCommand._combineFlagAndOptionalValue;
1305
- this._allowExcessArguments = sourceCommand._allowExcessArguments;
1306
- this._enablePositionalOptions = sourceCommand._enablePositionalOptions;
1307
- this._showHelpAfterError = sourceCommand._showHelpAfterError;
1308
- this._showSuggestionAfterError = sourceCommand._showSuggestionAfterError;
1309
- return this;
940
+ return this._outputConfiguration = sourceCommand._outputConfiguration, this._helpOption = sourceCommand._helpOption, this._helpCommand = sourceCommand._helpCommand, this._helpConfiguration = sourceCommand._helpConfiguration, this._exitCallback = sourceCommand._exitCallback, this._storeOptionsAsProperties = sourceCommand._storeOptionsAsProperties, this._combineFlagAndOptionalValue = sourceCommand._combineFlagAndOptionalValue, this._allowExcessArguments = sourceCommand._allowExcessArguments, this._enablePositionalOptions = sourceCommand._enablePositionalOptions, this._showHelpAfterError = sourceCommand._showHelpAfterError, this._showSuggestionAfterError = sourceCommand._showSuggestionAfterError, this;
1310
941
  }
1311
942
  /**
1312
943
  * @returns {Command[]}
1313
944
  * @private
1314
945
  */
1315
946
  _getCommandAndAncestors() {
1316
- const result = [];
1317
- for (let command2 = this; command2; command2 = command2.parent) {
947
+ let result = [];
948
+ for (let command2 = this; command2; command2 = command2.parent)
1318
949
  result.push(command2);
1319
- }
1320
950
  return result;
1321
951
  }
1322
952
  /**
@@ -1344,28 +974,10 @@ var require_command = __commonJS({
1344
974
  * @return {Command} returns new command for action handler, or `this` for executable command
1345
975
  */
1346
976
  command(nameAndArgs, actionOptsOrExecDesc, execOpts) {
1347
- let desc = actionOptsOrExecDesc;
1348
- let opts = execOpts;
1349
- if (typeof desc === "object" && desc !== null) {
1350
- opts = desc;
1351
- desc = null;
1352
- }
1353
- opts = opts || {};
1354
- const [, name, args] = nameAndArgs.match(/([^ ]+) *(.*)/);
1355
- const cmd = this.createCommand(name);
1356
- if (desc) {
1357
- cmd.description(desc);
1358
- cmd._executableHandler = true;
1359
- }
1360
- if (opts.isDefault) this._defaultCommandName = cmd._name;
1361
- cmd._hidden = !!(opts.noHelp || opts.hidden);
1362
- cmd._executableFile = opts.executableFile || null;
1363
- if (args) cmd.arguments(args);
1364
- this._registerCommand(cmd);
1365
- cmd.parent = this;
1366
- cmd.copyInheritedSettings(this);
1367
- if (desc) return this;
1368
- return cmd;
977
+ let desc = actionOptsOrExecDesc, opts = execOpts;
978
+ typeof desc == "object" && desc !== null && (opts = desc, desc = null), opts = opts || {};
979
+ let [, name, args] = nameAndArgs.match(/([^ ]+) *(.*)/), cmd = this.createCommand(name);
980
+ return desc && (cmd.description(desc), cmd._executableHandler = !0), opts.isDefault && (this._defaultCommandName = cmd._name), cmd._hidden = !!(opts.noHelp || opts.hidden), cmd._executableFile = opts.executableFile || null, args && cmd.arguments(args), this._registerCommand(cmd), cmd.parent = this, cmd.copyInheritedSettings(this), desc ? this : cmd;
1369
981
  }
1370
982
  /**
1371
983
  * Factory routine to create a new unattached command.
@@ -1396,9 +1008,7 @@ var require_command = __commonJS({
1396
1008
  * @return {(Command | object)} `this` command for chaining, or stored configuration
1397
1009
  */
1398
1010
  configureHelp(configuration) {
1399
- if (configuration === void 0) return this._helpConfiguration;
1400
- this._helpConfiguration = configuration;
1401
- return this;
1011
+ return configuration === void 0 ? this._helpConfiguration : (this._helpConfiguration = configuration, this);
1402
1012
  }
1403
1013
  /**
1404
1014
  * The default output goes to stdout and stderr. You can customise this for special
@@ -1423,12 +1033,10 @@ var require_command = __commonJS({
1423
1033
  * @return {(Command | object)} `this` command for chaining, or stored configuration
1424
1034
  */
1425
1035
  configureOutput(configuration) {
1426
- if (configuration === void 0) return this._outputConfiguration;
1427
- this._outputConfiguration = {
1036
+ return configuration === void 0 ? this._outputConfiguration : (this._outputConfiguration = {
1428
1037
  ...this._outputConfiguration,
1429
1038
  ...configuration
1430
- };
1431
- return this;
1039
+ }, this);
1432
1040
  }
1433
1041
  /**
1434
1042
  * Display the help or a custom message after an error occurs.
@@ -1436,10 +1044,8 @@ var require_command = __commonJS({
1436
1044
  * @param {(boolean|string)} [displayHelp]
1437
1045
  * @return {Command} `this` command for chaining
1438
1046
  */
1439
- showHelpAfterError(displayHelp = true) {
1440
- if (typeof displayHelp !== "string") displayHelp = !!displayHelp;
1441
- this._showHelpAfterError = displayHelp;
1442
- return this;
1047
+ showHelpAfterError(displayHelp = !0) {
1048
+ return typeof displayHelp != "string" && (displayHelp = !!displayHelp), this._showHelpAfterError = displayHelp, this;
1443
1049
  }
1444
1050
  /**
1445
1051
  * Display suggestion of similar commands for unknown commands, or options for unknown options.
@@ -1447,9 +1053,8 @@ var require_command = __commonJS({
1447
1053
  * @param {boolean} [displaySuggestion]
1448
1054
  * @return {Command} `this` command for chaining
1449
1055
  */
1450
- showSuggestionAfterError(displaySuggestion = true) {
1451
- this._showSuggestionAfterError = !!displaySuggestion;
1452
- return this;
1056
+ showSuggestionAfterError(displaySuggestion = !0) {
1057
+ return this._showSuggestionAfterError = !!displaySuggestion, this;
1453
1058
  }
1454
1059
  /**
1455
1060
  * Add a prepared subcommand.
@@ -1461,17 +1066,10 @@ var require_command = __commonJS({
1461
1066
  * @return {Command} `this` command for chaining
1462
1067
  */
1463
1068
  addCommand(cmd, opts) {
1464
- if (!cmd._name) {
1069
+ if (!cmd._name)
1465
1070
  throw new Error(`Command passed to .addCommand() must have a name
1466
1071
  - specify the name in Command constructor or using .name()`);
1467
- }
1468
- opts = opts || {};
1469
- if (opts.isDefault) this._defaultCommandName = cmd._name;
1470
- if (opts.noHelp || opts.hidden) cmd._hidden = true;
1471
- this._registerCommand(cmd);
1472
- cmd.parent = this;
1473
- cmd._checkForBrokenPassThrough();
1474
- return this;
1072
+ return opts = opts || {}, opts.isDefault && (this._defaultCommandName = cmd._name), (opts.noHelp || opts.hidden) && (cmd._hidden = !0), this._registerCommand(cmd), cmd.parent = this, cmd._checkForBrokenPassThrough(), this;
1475
1073
  }
1476
1074
  /**
1477
1075
  * Factory routine to create a new unattached argument.
@@ -1503,14 +1101,8 @@ var require_command = __commonJS({
1503
1101
  * @return {Command} `this` command for chaining
1504
1102
  */
1505
1103
  argument(name, description, parseArg, defaultValue) {
1506
- const argument = this.createArgument(name, description);
1507
- if (typeof parseArg === "function") {
1508
- argument.default(defaultValue).argParser(parseArg);
1509
- } else {
1510
- argument.default(parseArg);
1511
- }
1512
- this.addArgument(argument);
1513
- return this;
1104
+ let argument = this.createArgument(name, description);
1105
+ return typeof parseArg == "function" ? argument.default(defaultValue).argParser(parseArg) : argument.default(parseArg), this.addArgument(argument), this;
1514
1106
  }
1515
1107
  /**
1516
1108
  * Define argument syntax for command, adding multiple at once (without descriptions).
@@ -1524,10 +1116,9 @@ var require_command = __commonJS({
1524
1116
  * @return {Command} `this` command for chaining
1525
1117
  */
1526
1118
  arguments(names) {
1527
- names.trim().split(/ +/).forEach((detail) => {
1119
+ return names.trim().split(/ +/).forEach((detail) => {
1528
1120
  this.argument(detail);
1529
- });
1530
- return this;
1121
+ }), this;
1531
1122
  }
1532
1123
  /**
1533
1124
  * Define argument syntax for command, adding a prepared argument.
@@ -1536,19 +1127,16 @@ var require_command = __commonJS({
1536
1127
  * @return {Command} `this` command for chaining
1537
1128
  */
1538
1129
  addArgument(argument) {
1539
- const previousArgument = this.registeredArguments.slice(-1)[0];
1540
- if (previousArgument?.variadic) {
1130
+ let previousArgument = this.registeredArguments.slice(-1)[0];
1131
+ if (previousArgument?.variadic)
1541
1132
  throw new Error(
1542
1133
  `only the last argument can be variadic '${previousArgument.name()}'`
1543
1134
  );
1544
- }
1545
- if (argument.required && argument.defaultValue !== void 0 && argument.parseArg === void 0) {
1135
+ if (argument.required && argument.defaultValue !== void 0 && argument.parseArg === void 0)
1546
1136
  throw new Error(
1547
1137
  `a default value for a required argument is never used: '${argument.name()}'`
1548
1138
  );
1549
- }
1550
- this.registeredArguments.push(argument);
1551
- return this;
1139
+ return this.registeredArguments.push(argument), this;
1552
1140
  }
1553
1141
  /**
1554
1142
  * Customise or override default help command. By default a help command is automatically added if your command has subcommands.
@@ -1564,24 +1152,10 @@ var require_command = __commonJS({
1564
1152
  * @return {Command} `this` command for chaining
1565
1153
  */
1566
1154
  helpCommand(enableOrNameAndArgs, description) {
1567
- if (typeof enableOrNameAndArgs === "boolean") {
1568
- this._addImplicitHelpCommand = enableOrNameAndArgs;
1569
- if (enableOrNameAndArgs && this._defaultCommandGroup) {
1570
- this._initCommandGroup(this._getHelpCommand());
1571
- }
1572
- return this;
1573
- }
1574
- const nameAndArgs = enableOrNameAndArgs ?? "help [command]";
1575
- const [, helpName, helpArgs] = nameAndArgs.match(/([^ ]+) *(.*)/);
1576
- const helpDescription = description ?? "display help for command";
1577
- const helpCommand = this.createCommand(helpName);
1578
- helpCommand.helpOption(false);
1579
- if (helpArgs) helpCommand.arguments(helpArgs);
1580
- if (helpDescription) helpCommand.description(helpDescription);
1581
- this._addImplicitHelpCommand = true;
1582
- this._helpCommand = helpCommand;
1583
- if (enableOrNameAndArgs || description) this._initCommandGroup(helpCommand);
1584
- return this;
1155
+ if (typeof enableOrNameAndArgs == "boolean")
1156
+ return this._addImplicitHelpCommand = enableOrNameAndArgs, enableOrNameAndArgs && this._defaultCommandGroup && this._initCommandGroup(this._getHelpCommand()), this;
1157
+ let nameAndArgs = enableOrNameAndArgs ?? "help [command]", [, helpName, helpArgs] = nameAndArgs.match(/([^ ]+) *(.*)/), helpDescription = description ?? "display help for command", helpCommand = this.createCommand(helpName);
1158
+ return helpCommand.helpOption(!1), helpArgs && helpCommand.arguments(helpArgs), helpDescription && helpCommand.description(helpDescription), this._addImplicitHelpCommand = !0, this._helpCommand = helpCommand, (enableOrNameAndArgs || description) && this._initCommandGroup(helpCommand), this;
1585
1159
  }
1586
1160
  /**
1587
1161
  * Add prepared custom help command.
@@ -1591,14 +1165,7 @@ var require_command = __commonJS({
1591
1165
  * @return {Command} `this` command for chaining
1592
1166
  */
1593
1167
  addHelpCommand(helpCommand, deprecatedDescription) {
1594
- if (typeof helpCommand !== "object") {
1595
- this.helpCommand(helpCommand, deprecatedDescription);
1596
- return this;
1597
- }
1598
- this._addImplicitHelpCommand = true;
1599
- this._helpCommand = helpCommand;
1600
- this._initCommandGroup(helpCommand);
1601
- return this;
1168
+ return typeof helpCommand != "object" ? (this.helpCommand(helpCommand, deprecatedDescription), this) : (this._addImplicitHelpCommand = !0, this._helpCommand = helpCommand, this._initCommandGroup(helpCommand), this);
1602
1169
  }
1603
1170
  /**
1604
1171
  * Lazy create help command.
@@ -1607,14 +1174,7 @@ var require_command = __commonJS({
1607
1174
  * @package
1608
1175
  */
1609
1176
  _getHelpCommand() {
1610
- const hasImplicitHelpCommand = this._addImplicitHelpCommand ?? (this.commands.length && !this._actionHandler && !this._findCommand("help"));
1611
- if (hasImplicitHelpCommand) {
1612
- if (this._helpCommand === void 0) {
1613
- this.helpCommand(void 0, void 0);
1614
- }
1615
- return this._helpCommand;
1616
- }
1617
- return null;
1177
+ return this._addImplicitHelpCommand ?? (this.commands.length && !this._actionHandler && !this._findCommand("help")) ? (this._helpCommand === void 0 && this.helpCommand(void 0, void 0), this._helpCommand) : null;
1618
1178
  }
1619
1179
  /**
1620
1180
  * Add hook for life cycle event.
@@ -1624,17 +1184,11 @@ var require_command = __commonJS({
1624
1184
  * @return {Command} `this` command for chaining
1625
1185
  */
1626
1186
  hook(event, listener) {
1627
- const allowedValues = ["preSubcommand", "preAction", "postAction"];
1628
- if (!allowedValues.includes(event)) {
1187
+ let allowedValues = ["preSubcommand", "preAction", "postAction"];
1188
+ if (!allowedValues.includes(event))
1629
1189
  throw new Error(`Unexpected value for event passed to hook : '${event}'.
1630
1190
  Expecting one of '${allowedValues.join("', '")}'`);
1631
- }
1632
- if (this._lifeCycleHooks[event]) {
1633
- this._lifeCycleHooks[event].push(listener);
1634
- } else {
1635
- this._lifeCycleHooks[event] = [listener];
1636
- }
1637
- return this;
1191
+ return this._lifeCycleHooks[event] ? this._lifeCycleHooks[event].push(listener) : this._lifeCycleHooks[event] = [listener], this;
1638
1192
  }
1639
1193
  /**
1640
1194
  * Register callback to use as replacement for calling process.exit.
@@ -1643,17 +1197,10 @@ Expecting one of '${allowedValues.join("', '")}'`);
1643
1197
  * @return {Command} `this` command for chaining
1644
1198
  */
1645
1199
  exitOverride(fn) {
1646
- if (fn) {
1647
- this._exitCallback = fn;
1648
- } else {
1649
- this._exitCallback = (err) => {
1650
- if (err.code !== "commander.executeSubCommandAsync") {
1651
- throw err;
1652
- } else {
1653
- }
1654
- };
1655
- }
1656
- return this;
1200
+ return fn ? this._exitCallback = fn : this._exitCallback = (err) => {
1201
+ if (err.code !== "commander.executeSubCommandAsync")
1202
+ throw err;
1203
+ }, this;
1657
1204
  }
1658
1205
  /**
1659
1206
  * Call process.exit, and _exitCallback if defined.
@@ -1665,10 +1212,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
1665
1212
  * @private
1666
1213
  */
1667
1214
  _exit(exitCode, code, message) {
1668
- if (this._exitCallback) {
1669
- this._exitCallback(new CommanderError2(exitCode, code, message));
1670
- }
1671
- process2.exit(exitCode);
1215
+ this._exitCallback && this._exitCallback(new CommanderError2(exitCode, code, message)), process2.exit(exitCode);
1672
1216
  }
1673
1217
  /**
1674
1218
  * Register callback `fn` for the command.
@@ -1685,19 +1229,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
1685
1229
  * @return {Command} `this` command for chaining
1686
1230
  */
1687
1231
  action(fn) {
1688
- const listener = /* @__PURE__ */ __name((args) => {
1689
- const expectedArgsCount = this.registeredArguments.length;
1690
- const actionArgs = args.slice(0, expectedArgsCount);
1691
- if (this._storeOptionsAsProperties) {
1692
- actionArgs[expectedArgsCount] = this;
1693
- } else {
1694
- actionArgs[expectedArgsCount] = this.opts();
1695
- }
1696
- actionArgs.push(this);
1697
- return fn.apply(this, actionArgs);
1698
- }, "listener");
1699
- this._actionHandler = listener;
1700
- return this;
1232
+ let listener = (args) => {
1233
+ let expectedArgsCount = this.registeredArguments.length, actionArgs = args.slice(0, expectedArgsCount);
1234
+ return this._storeOptionsAsProperties ? actionArgs[expectedArgsCount] = this : actionArgs[expectedArgsCount] = this.opts(), actionArgs.push(this), fn.apply(this, actionArgs);
1235
+ };
1236
+ return this._actionHandler = listener, this;
1701
1237
  }
1702
1238
  /**
1703
1239
  * Factory routine to create a new unattached option.
@@ -1726,7 +1262,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
1726
1262
  return target.parseArg(value, previous);
1727
1263
  } catch (err) {
1728
1264
  if (err.code === "commander.invalidArgument") {
1729
- const message = `${invalidArgumentMessage} ${err.message}`;
1265
+ let message = `${invalidArgumentMessage} ${err.message}`;
1730
1266
  this.error(message, { exitCode: err.exitCode, code: err.code });
1731
1267
  }
1732
1268
  throw err;
@@ -1740,14 +1276,13 @@ Expecting one of '${allowedValues.join("', '")}'`);
1740
1276
  * @private
1741
1277
  */
1742
1278
  _registerOption(option) {
1743
- const matchingOption = option.short && this._findOption(option.short) || option.long && this._findOption(option.long);
1279
+ let matchingOption = option.short && this._findOption(option.short) || option.long && this._findOption(option.long);
1744
1280
  if (matchingOption) {
1745
- const matchingFlag = option.long && this._findOption(option.long) ? option.long : option.short;
1281
+ let matchingFlag = option.long && this._findOption(option.long) ? option.long : option.short;
1746
1282
  throw new Error(`Cannot add option '${option.flags}'${this._name && ` to command '${this._name}'`} due to conflicting flag '${matchingFlag}'
1747
1283
  - already used by option '${matchingOption.flags}'`);
1748
1284
  }
1749
- this._initOptionGroup(option);
1750
- this.options.push(option);
1285
+ this._initOptionGroup(option), this.options.push(option);
1751
1286
  }
1752
1287
  /**
1753
1288
  * Check for command name and alias conflicts with existing commands.
@@ -1757,21 +1292,16 @@ Expecting one of '${allowedValues.join("', '")}'`);
1757
1292
  * @private
1758
1293
  */
1759
1294
  _registerCommand(command2) {
1760
- const knownBy = /* @__PURE__ */ __name((cmd) => {
1761
- return [cmd.name()].concat(cmd.aliases());
1762
- }, "knownBy");
1763
- const alreadyUsed = knownBy(command2).find(
1295
+ let knownBy = (cmd) => [cmd.name()].concat(cmd.aliases()), alreadyUsed = knownBy(command2).find(
1764
1296
  (name) => this._findCommand(name)
1765
1297
  );
1766
1298
  if (alreadyUsed) {
1767
- const existingCmd = knownBy(this._findCommand(alreadyUsed)).join("|");
1768
- const newCmd = knownBy(command2).join("|");
1299
+ let existingCmd = knownBy(this._findCommand(alreadyUsed)).join("|"), newCmd = knownBy(command2).join("|");
1769
1300
  throw new Error(
1770
1301
  `cannot add command '${newCmd}' as already have command '${existingCmd}'`
1771
1302
  );
1772
1303
  }
1773
- this._initCommandGroup(command2);
1774
- this.commands.push(command2);
1304
+ this._initCommandGroup(command2), this.commands.push(command2);
1775
1305
  }
1776
1306
  /**
1777
1307
  * Add an option.
@@ -1781,52 +1311,27 @@ Expecting one of '${allowedValues.join("', '")}'`);
1781
1311
  */
1782
1312
  addOption(option) {
1783
1313
  this._registerOption(option);
1784
- const oname = option.name();
1785
- const name = option.attributeName();
1314
+ let oname = option.name(), name = option.attributeName();
1786
1315
  if (option.negate) {
1787
- const positiveLongFlag = option.long.replace(/^--no-/, "--");
1788
- if (!this._findOption(positiveLongFlag)) {
1789
- this.setOptionValueWithSource(
1790
- name,
1791
- option.defaultValue === void 0 ? true : option.defaultValue,
1792
- "default"
1793
- );
1794
- }
1795
- } else if (option.defaultValue !== void 0) {
1796
- this.setOptionValueWithSource(name, option.defaultValue, "default");
1797
- }
1798
- const handleOptionValue = /* @__PURE__ */ __name((val, invalidValueMessage, valueSource) => {
1799
- if (val == null && option.presetArg !== void 0) {
1800
- val = option.presetArg;
1801
- }
1802
- const oldValue = this.getOptionValue(name);
1803
- if (val !== null && option.parseArg) {
1804
- val = this._callParseArg(option, val, oldValue, invalidValueMessage);
1805
- } else if (val !== null && option.variadic) {
1806
- val = option._collectValue(val, oldValue);
1807
- }
1808
- if (val == null) {
1809
- if (option.negate) {
1810
- val = false;
1811
- } else if (option.isBoolean() || option.optional) {
1812
- val = true;
1813
- } else {
1814
- val = "";
1815
- }
1816
- }
1817
- this.setOptionValueWithSource(name, val, valueSource);
1818
- }, "handleOptionValue");
1819
- this.on("option:" + oname, (val) => {
1820
- const invalidValueMessage = `error: option '${option.flags}' argument '${val}' is invalid.`;
1316
+ let positiveLongFlag = option.long.replace(/^--no-/, "--");
1317
+ this._findOption(positiveLongFlag) || this.setOptionValueWithSource(
1318
+ name,
1319
+ option.defaultValue === void 0 ? !0 : option.defaultValue,
1320
+ "default"
1321
+ );
1322
+ } else option.defaultValue !== void 0 && this.setOptionValueWithSource(name, option.defaultValue, "default");
1323
+ let handleOptionValue = (val, invalidValueMessage, valueSource) => {
1324
+ val == null && option.presetArg !== void 0 && (val = option.presetArg);
1325
+ let oldValue = this.getOptionValue(name);
1326
+ val !== null && option.parseArg ? val = this._callParseArg(option, val, oldValue, invalidValueMessage) : val !== null && option.variadic && (val = option._collectValue(val, oldValue)), val == null && (option.negate ? val = !1 : option.isBoolean() || option.optional ? val = !0 : val = ""), this.setOptionValueWithSource(name, val, valueSource);
1327
+ };
1328
+ return this.on("option:" + oname, (val) => {
1329
+ let invalidValueMessage = `error: option '${option.flags}' argument '${val}' is invalid.`;
1821
1330
  handleOptionValue(val, invalidValueMessage, "cli");
1822
- });
1823
- if (option.envVar) {
1824
- this.on("optionEnv:" + oname, (val) => {
1825
- const invalidValueMessage = `error: option '${option.flags}' value '${val}' from env '${option.envVar}' is invalid.`;
1826
- handleOptionValue(val, invalidValueMessage, "env");
1827
- });
1828
- }
1829
- return this;
1331
+ }), option.envVar && this.on("optionEnv:" + oname, (val) => {
1332
+ let invalidValueMessage = `error: option '${option.flags}' value '${val}' from env '${option.envVar}' is invalid.`;
1333
+ handleOptionValue(val, invalidValueMessage, "env");
1334
+ }), this;
1830
1335
  }
1831
1336
  /**
1832
1337
  * Internal implementation shared by .option() and .requiredOption()
@@ -1835,25 +1340,21 @@ Expecting one of '${allowedValues.join("', '")}'`);
1835
1340
  * @private
1836
1341
  */
1837
1342
  _optionEx(config, flags, description, fn, defaultValue) {
1838
- if (typeof flags === "object" && flags instanceof Option2) {
1343
+ if (typeof flags == "object" && flags instanceof Option2)
1839
1344
  throw new Error(
1840
1345
  "To add an Option object use addOption() instead of option() or requiredOption()"
1841
1346
  );
1842
- }
1843
- const option = this.createOption(flags, description);
1844
- option.makeOptionMandatory(!!config.mandatory);
1845
- if (typeof fn === "function") {
1347
+ let option = this.createOption(flags, description);
1348
+ if (option.makeOptionMandatory(!!config.mandatory), typeof fn == "function")
1846
1349
  option.default(defaultValue).argParser(fn);
1847
- } else if (fn instanceof RegExp) {
1848
- const regex = fn;
1849
- fn = /* @__PURE__ */ __name((val, def) => {
1850
- const m = regex.exec(val);
1350
+ else if (fn instanceof RegExp) {
1351
+ let regex = fn;
1352
+ fn = (val, def) => {
1353
+ let m = regex.exec(val);
1851
1354
  return m ? m[0] : def;
1852
- }, "fn");
1853
- option.default(defaultValue).argParser(fn);
1854
- } else {
1355
+ }, option.default(defaultValue).argParser(fn);
1356
+ } else
1855
1357
  option.default(fn);
1856
- }
1857
1358
  return this.addOption(option);
1858
1359
  }
1859
1360
  /**
@@ -1894,7 +1395,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
1894
1395
  */
1895
1396
  requiredOption(flags, description, parseArg, defaultValue) {
1896
1397
  return this._optionEx(
1897
- { mandatory: true },
1398
+ { mandatory: !0 },
1898
1399
  flags,
1899
1400
  description,
1900
1401
  parseArg,
@@ -1912,9 +1413,8 @@ Expecting one of '${allowedValues.join("', '")}'`);
1912
1413
  * @param {boolean} [combine] - if `true` or omitted, an optional value can be specified directly after the flag.
1913
1414
  * @return {Command} `this` command for chaining
1914
1415
  */
1915
- combineFlagAndOptionalValue(combine = true) {
1916
- this._combineFlagAndOptionalValue = !!combine;
1917
- return this;
1416
+ combineFlagAndOptionalValue(combine = !0) {
1417
+ return this._combineFlagAndOptionalValue = !!combine, this;
1918
1418
  }
1919
1419
  /**
1920
1420
  * Allow unknown options on the command line.
@@ -1922,9 +1422,8 @@ Expecting one of '${allowedValues.join("', '")}'`);
1922
1422
  * @param {boolean} [allowUnknown] - if `true` or omitted, no error will be thrown for unknown options.
1923
1423
  * @return {Command} `this` command for chaining
1924
1424
  */
1925
- allowUnknownOption(allowUnknown = true) {
1926
- this._allowUnknownOption = !!allowUnknown;
1927
- return this;
1425
+ allowUnknownOption(allowUnknown = !0) {
1426
+ return this._allowUnknownOption = !!allowUnknown, this;
1928
1427
  }
1929
1428
  /**
1930
1429
  * Allow excess command-arguments on the command line. Pass false to make excess arguments an error.
@@ -1932,9 +1431,8 @@ Expecting one of '${allowedValues.join("', '")}'`);
1932
1431
  * @param {boolean} [allowExcess] - if `true` or omitted, no error will be thrown for excess arguments.
1933
1432
  * @return {Command} `this` command for chaining
1934
1433
  */
1935
- allowExcessArguments(allowExcess = true) {
1936
- this._allowExcessArguments = !!allowExcess;
1937
- return this;
1434
+ allowExcessArguments(allowExcess = !0) {
1435
+ return this._allowExcessArguments = !!allowExcess, this;
1938
1436
  }
1939
1437
  /**
1940
1438
  * Enable positional options. Positional means global options are specified before subcommands which lets
@@ -1944,9 +1442,8 @@ Expecting one of '${allowedValues.join("', '")}'`);
1944
1442
  * @param {boolean} [positional]
1945
1443
  * @return {Command} `this` command for chaining
1946
1444
  */
1947
- enablePositionalOptions(positional = true) {
1948
- this._enablePositionalOptions = !!positional;
1949
- return this;
1445
+ enablePositionalOptions(positional = !0) {
1446
+ return this._enablePositionalOptions = !!positional, this;
1950
1447
  }
1951
1448
  /**
1952
1449
  * Pass through options that come after command-arguments rather than treat them as command-options,
@@ -1957,20 +1454,17 @@ Expecting one of '${allowedValues.join("', '")}'`);
1957
1454
  * @param {boolean} [passThrough] for unknown options.
1958
1455
  * @return {Command} `this` command for chaining
1959
1456
  */
1960
- passThroughOptions(passThrough = true) {
1961
- this._passThroughOptions = !!passThrough;
1962
- this._checkForBrokenPassThrough();
1963
- return this;
1457
+ passThroughOptions(passThrough = !0) {
1458
+ return this._passThroughOptions = !!passThrough, this._checkForBrokenPassThrough(), this;
1964
1459
  }
1965
1460
  /**
1966
1461
  * @private
1967
1462
  */
1968
1463
  _checkForBrokenPassThrough() {
1969
- if (this.parent && this._passThroughOptions && !this.parent._enablePositionalOptions) {
1464
+ if (this.parent && this._passThroughOptions && !this.parent._enablePositionalOptions)
1970
1465
  throw new Error(
1971
1466
  `passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`
1972
1467
  );
1973
- }
1974
1468
  }
1975
1469
  /**
1976
1470
  * Whether to store option values as properties on command object,
@@ -1979,17 +1473,14 @@ Expecting one of '${allowedValues.join("', '")}'`);
1979
1473
  * @param {boolean} [storeAsProperties=true]
1980
1474
  * @return {Command} `this` command for chaining
1981
1475
  */
1982
- storeOptionsAsProperties(storeAsProperties = true) {
1983
- if (this.options.length) {
1476
+ storeOptionsAsProperties(storeAsProperties = !0) {
1477
+ if (this.options.length)
1984
1478
  throw new Error("call .storeOptionsAsProperties() before adding options");
1985
- }
1986
- if (Object.keys(this._optionValues).length) {
1479
+ if (Object.keys(this._optionValues).length)
1987
1480
  throw new Error(
1988
1481
  "call .storeOptionsAsProperties() before setting option values"
1989
1482
  );
1990
- }
1991
- this._storeOptionsAsProperties = !!storeAsProperties;
1992
- return this;
1483
+ return this._storeOptionsAsProperties = !!storeAsProperties, this;
1993
1484
  }
1994
1485
  /**
1995
1486
  * Retrieve option value.
@@ -1998,10 +1489,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
1998
1489
  * @return {object} value
1999
1490
  */
2000
1491
  getOptionValue(key) {
2001
- if (this._storeOptionsAsProperties) {
2002
- return this[key];
2003
- }
2004
- return this._optionValues[key];
1492
+ return this._storeOptionsAsProperties ? this[key] : this._optionValues[key];
2005
1493
  }
2006
1494
  /**
2007
1495
  * Store option value.
@@ -2022,13 +1510,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
2022
1510
  * @return {Command} `this` command for chaining
2023
1511
  */
2024
1512
  setOptionValueWithSource(key, value, source) {
2025
- if (this._storeOptionsAsProperties) {
2026
- this[key] = value;
2027
- } else {
2028
- this._optionValues[key] = value;
2029
- }
2030
- this._optionValueSources[key] = source;
2031
- return this;
1513
+ return this._storeOptionsAsProperties ? this[key] = value : this._optionValues[key] = value, this._optionValueSources[key] = source, this;
2032
1514
  }
2033
1515
  /**
2034
1516
  * Get source of option value.
@@ -2049,12 +1531,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
2049
1531
  */
2050
1532
  getOptionValueSourceWithGlobals(key) {
2051
1533
  let source;
2052
- this._getCommandAndAncestors().forEach((cmd) => {
2053
- if (cmd.getOptionValueSource(key) !== void 0) {
2054
- source = cmd.getOptionValueSource(key);
2055
- }
2056
- });
2057
- return source;
1534
+ return this._getCommandAndAncestors().forEach((cmd) => {
1535
+ cmd.getOptionValueSource(key) !== void 0 && (source = cmd.getOptionValueSource(key));
1536
+ }), source;
2058
1537
  }
2059
1538
  /**
2060
1539
  * Get user arguments from implied or explicit arguments.
@@ -2063,37 +1542,22 @@ Expecting one of '${allowedValues.join("', '")}'`);
2063
1542
  * @private
2064
1543
  */
2065
1544
  _prepareUserArgs(argv, parseOptions) {
2066
- if (argv !== void 0 && !Array.isArray(argv)) {
1545
+ if (argv !== void 0 && !Array.isArray(argv))
2067
1546
  throw new Error("first parameter to parse must be array or undefined");
1547
+ if (parseOptions = parseOptions || {}, argv === void 0 && parseOptions.from === void 0) {
1548
+ process2.versions?.electron && (parseOptions.from = "electron");
1549
+ let execArgv = process2.execArgv ?? [];
1550
+ (execArgv.includes("-e") || execArgv.includes("--eval") || execArgv.includes("-p") || execArgv.includes("--print")) && (parseOptions.from = "eval");
2068
1551
  }
2069
- parseOptions = parseOptions || {};
2070
- if (argv === void 0 && parseOptions.from === void 0) {
2071
- if (process2.versions?.electron) {
2072
- parseOptions.from = "electron";
2073
- }
2074
- const execArgv = process2.execArgv ?? [];
2075
- if (execArgv.includes("-e") || execArgv.includes("--eval") || execArgv.includes("-p") || execArgv.includes("--print")) {
2076
- parseOptions.from = "eval";
2077
- }
2078
- }
2079
- if (argv === void 0) {
2080
- argv = process2.argv;
2081
- }
2082
- this.rawArgs = argv.slice();
1552
+ argv === void 0 && (argv = process2.argv), this.rawArgs = argv.slice();
2083
1553
  let userArgs;
2084
1554
  switch (parseOptions.from) {
2085
1555
  case void 0:
2086
1556
  case "node":
2087
- this._scriptPath = argv[1];
2088
- userArgs = argv.slice(2);
1557
+ this._scriptPath = argv[1], userArgs = argv.slice(2);
2089
1558
  break;
2090
1559
  case "electron":
2091
- if (process2.defaultApp) {
2092
- this._scriptPath = argv[1];
2093
- userArgs = argv.slice(2);
2094
- } else {
2095
- userArgs = argv.slice(1);
2096
- }
1560
+ process2.defaultApp ? (this._scriptPath = argv[1], userArgs = argv.slice(2)) : userArgs = argv.slice(1);
2097
1561
  break;
2098
1562
  case "user":
2099
1563
  userArgs = argv.slice(0);
@@ -2106,10 +1570,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
2106
1570
  `unexpected parse option { from: '${parseOptions.from}' }`
2107
1571
  );
2108
1572
  }
2109
- if (!this._name && this._scriptPath)
2110
- this.nameFromFilename(this._scriptPath);
2111
- this._name = this._name || "program";
2112
- return userArgs;
1573
+ return !this._name && this._scriptPath && this.nameFromFilename(this._scriptPath), this._name = this._name || "program", userArgs;
2113
1574
  }
2114
1575
  /**
2115
1576
  * Parse `argv`, setting options and invoking commands when defined.
@@ -2135,9 +1596,8 @@ Expecting one of '${allowedValues.join("', '")}'`);
2135
1596
  */
2136
1597
  parse(argv, parseOptions) {
2137
1598
  this._prepareForParse();
2138
- const userArgs = this._prepareUserArgs(argv, parseOptions);
2139
- this._parseCommand([], userArgs);
2140
- return this;
1599
+ let userArgs = this._prepareUserArgs(argv, parseOptions);
1600
+ return this._parseCommand([], userArgs), this;
2141
1601
  }
2142
1602
  /**
2143
1603
  * Parse `argv`, setting options and invoking commands when defined.
@@ -2161,16 +1621,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
2161
1621
  */
2162
1622
  async parseAsync(argv, parseOptions) {
2163
1623
  this._prepareForParse();
2164
- const userArgs = this._prepareUserArgs(argv, parseOptions);
2165
- await this._parseCommand([], userArgs);
2166
- return this;
1624
+ let userArgs = this._prepareUserArgs(argv, parseOptions);
1625
+ return await this._parseCommand([], userArgs), this;
2167
1626
  }
2168
1627
  _prepareForParse() {
2169
- if (this._savedState === null) {
2170
- this.saveStateBeforeParse();
2171
- } else {
2172
- this.restoreStateBeforeParse();
2173
- }
1628
+ this._savedState === null ? this.saveStateBeforeParse() : this.restoreStateBeforeParse();
2174
1629
  }
2175
1630
  /**
2176
1631
  * Called the first time parse is called to save state and allow a restore before subsequent calls to parse.
@@ -2198,13 +1653,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
2198
1653
  if (this._storeOptionsAsProperties)
2199
1654
  throw new Error(`Can not call parse again when storeOptionsAsProperties is true.
2200
1655
  - either make a new Command for each call to parse, or stop storing options as properties`);
2201
- this._name = this._savedState._name;
2202
- this._scriptPath = null;
2203
- this.rawArgs = [];
2204
- this._optionValues = { ...this._savedState._optionValues };
2205
- this._optionValueSources = { ...this._savedState._optionValueSources };
2206
- this.args = [];
2207
- this.processedArgs = [];
1656
+ this._name = this._savedState._name, this._scriptPath = null, this.rawArgs = [], this._optionValues = { ...this._savedState._optionValues }, this._optionValueSources = { ...this._savedState._optionValueSources }, this.args = [], this.processedArgs = [];
2208
1657
  }
2209
1658
  /**
2210
1659
  * Throw if expected executable is missing. Add lots of help for author.
@@ -2215,8 +1664,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
2215
1664
  */
2216
1665
  _checkForMissingExecutable(executableFile, executableDir, subcommandName) {
2217
1666
  if (fs.existsSync(executableFile)) return;
2218
- const executableDirMessage = executableDir ? `searched for local subcommand relative to directory '${executableDir}'` : "no directory for search for local subcommand, use .executableDir() to supply a custom directory";
2219
- const executableMissing = `'${executableFile}' does not exist
1667
+ let executableDirMessage = executableDir ? `searched for local subcommand relative to directory '${executableDir}'` : "no directory for search for local subcommand, use .executableDir() to supply a custom directory", executableMissing = `'${executableFile}' does not exist
2220
1668
  - if '${subcommandName}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
2221
1669
  - if the default executable name is not suitable, use the executableFile option to supply a custom name or path
2222
1670
  - ${executableDirMessage}`;
@@ -2229,23 +1677,18 @@ Expecting one of '${allowedValues.join("', '")}'`);
2229
1677
  */
2230
1678
  _executeSubCommand(subcommand, args) {
2231
1679
  args = args.slice();
2232
- let launchWithNode = false;
2233
- const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
1680
+ let launchWithNode = !1, sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
2234
1681
  function findFile(baseDir, baseName) {
2235
- const localBin = path.resolve(baseDir, baseName);
1682
+ let localBin = path.resolve(baseDir, baseName);
2236
1683
  if (fs.existsSync(localBin)) return localBin;
2237
- if (sourceExt.includes(path.extname(baseName))) return void 0;
2238
- const foundExt = sourceExt.find(
1684
+ if (sourceExt.includes(path.extname(baseName))) return;
1685
+ let foundExt = sourceExt.find(
2239
1686
  (ext) => fs.existsSync(`${localBin}${ext}`)
2240
1687
  );
2241
1688
  if (foundExt) return `${localBin}${foundExt}`;
2242
- return void 0;
2243
1689
  }
2244
- __name(findFile, "findFile");
2245
- this._checkForMissingMandatoryOptions();
2246
- this._checkForConflictingOptions();
2247
- let executableFile = subcommand._executableFile || `${this._name}-${subcommand._name}`;
2248
- let executableDir = this._executableDir || "";
1690
+ this._checkForMissingMandatoryOptions(), this._checkForConflictingOptions();
1691
+ let executableFile = subcommand._executableFile || `${this._name}-${subcommand._name}`, executableDir = this._executableDir || "";
2249
1692
  if (this._scriptPath) {
2250
1693
  let resolvedScriptPath;
2251
1694
  try {
@@ -2261,109 +1704,75 @@ Expecting one of '${allowedValues.join("', '")}'`);
2261
1704
  if (executableDir) {
2262
1705
  let localFile = findFile(executableDir, executableFile);
2263
1706
  if (!localFile && !subcommand._executableFile && this._scriptPath) {
2264
- const legacyName = path.basename(
1707
+ let legacyName = path.basename(
2265
1708
  this._scriptPath,
2266
1709
  path.extname(this._scriptPath)
2267
1710
  );
2268
- if (legacyName !== this._name) {
2269
- localFile = findFile(
2270
- executableDir,
2271
- `${legacyName}-${subcommand._name}`
2272
- );
2273
- }
1711
+ legacyName !== this._name && (localFile = findFile(
1712
+ executableDir,
1713
+ `${legacyName}-${subcommand._name}`
1714
+ ));
2274
1715
  }
2275
1716
  executableFile = localFile || executableFile;
2276
1717
  }
2277
1718
  launchWithNode = sourceExt.includes(path.extname(executableFile));
2278
1719
  let proc;
2279
- if (process2.platform !== "win32") {
2280
- if (launchWithNode) {
2281
- args.unshift(executableFile);
2282
- args = incrementNodeInspectorPort(process2.execArgv).concat(args);
2283
- proc = childProcess.spawn(process2.argv[0], args, { stdio: "inherit" });
2284
- } else {
2285
- proc = childProcess.spawn(executableFile, args, { stdio: "inherit" });
2286
- }
2287
- } else {
2288
- this._checkForMissingExecutable(
2289
- executableFile,
2290
- executableDir,
2291
- subcommand._name
2292
- );
2293
- args.unshift(executableFile);
2294
- args = incrementNodeInspectorPort(process2.execArgv).concat(args);
2295
- proc = childProcess.spawn(process2.execPath, args, { stdio: "inherit" });
2296
- }
2297
- if (!proc.killed) {
2298
- const signals = ["SIGUSR1", "SIGUSR2", "SIGTERM", "SIGINT", "SIGHUP"];
2299
- signals.forEach((signal) => {
2300
- process2.on(signal, () => {
2301
- if (proc.killed === false && proc.exitCode === null) {
2302
- proc.kill(signal);
2303
- }
2304
- });
1720
+ process2.platform !== "win32" ? launchWithNode ? (args.unshift(executableFile), args = incrementNodeInspectorPort(process2.execArgv).concat(args), proc = childProcess.spawn(process2.argv[0], args, { stdio: "inherit" })) : proc = childProcess.spawn(executableFile, args, { stdio: "inherit" }) : (this._checkForMissingExecutable(
1721
+ executableFile,
1722
+ executableDir,
1723
+ subcommand._name
1724
+ ), args.unshift(executableFile), args = incrementNodeInspectorPort(process2.execArgv).concat(args), proc = childProcess.spawn(process2.execPath, args, { stdio: "inherit" })), proc.killed || ["SIGUSR1", "SIGUSR2", "SIGTERM", "SIGINT", "SIGHUP"].forEach((signal) => {
1725
+ process2.on(signal, () => {
1726
+ proc.killed === !1 && proc.exitCode === null && proc.kill(signal);
2305
1727
  });
2306
- }
2307
- const exitCallback = this._exitCallback;
2308
- proc.on("close", (code) => {
2309
- code = code ?? 1;
2310
- if (!exitCallback) {
2311
- process2.exit(code);
2312
- } else {
2313
- exitCallback(
2314
- new CommanderError2(
2315
- code,
2316
- "commander.executeSubCommandAsync",
2317
- "(close)"
2318
- )
2319
- );
2320
- }
2321
1728
  });
2322
- proc.on("error", (err) => {
2323
- if (err.code === "ENOENT") {
1729
+ let exitCallback = this._exitCallback;
1730
+ proc.on("close", (code) => {
1731
+ code = code ?? 1, exitCallback ? exitCallback(
1732
+ new CommanderError2(
1733
+ code,
1734
+ "commander.executeSubCommandAsync",
1735
+ "(close)"
1736
+ )
1737
+ ) : process2.exit(code);
1738
+ }), proc.on("error", (err) => {
1739
+ if (err.code === "ENOENT")
2324
1740
  this._checkForMissingExecutable(
2325
1741
  executableFile,
2326
1742
  executableDir,
2327
1743
  subcommand._name
2328
1744
  );
2329
- } else if (err.code === "EACCES") {
1745
+ else if (err.code === "EACCES")
2330
1746
  throw new Error(`'${executableFile}' not executable`);
2331
- }
2332
- if (!exitCallback) {
1747
+ if (!exitCallback)
2333
1748
  process2.exit(1);
2334
- } else {
2335
- const wrappedError = new CommanderError2(
1749
+ else {
1750
+ let wrappedError = new CommanderError2(
2336
1751
  1,
2337
1752
  "commander.executeSubCommandAsync",
2338
1753
  "(error)"
2339
1754
  );
2340
- wrappedError.nestedError = err;
2341
- exitCallback(wrappedError);
1755
+ wrappedError.nestedError = err, exitCallback(wrappedError);
2342
1756
  }
2343
- });
2344
- this.runningCommand = proc;
1757
+ }), this.runningCommand = proc;
2345
1758
  }
2346
1759
  /**
2347
1760
  * @private
2348
1761
  */
2349
1762
  _dispatchSubcommand(commandName, operands, unknown) {
2350
- const subCommand = this._findCommand(commandName);
2351
- if (!subCommand) this.help({ error: true });
2352
- subCommand._prepareForParse();
1763
+ let subCommand = this._findCommand(commandName);
1764
+ subCommand || this.help({ error: !0 }), subCommand._prepareForParse();
2353
1765
  let promiseChain;
2354
- promiseChain = this._chainOrCallSubCommandHook(
1766
+ return promiseChain = this._chainOrCallSubCommandHook(
2355
1767
  promiseChain,
2356
1768
  subCommand,
2357
1769
  "preSubcommand"
2358
- );
2359
- promiseChain = this._chainOrCall(promiseChain, () => {
2360
- if (subCommand._executableHandler) {
1770
+ ), promiseChain = this._chainOrCall(promiseChain, () => {
1771
+ if (subCommand._executableHandler)
2361
1772
  this._executeSubCommand(subCommand, operands.concat(unknown));
2362
- } else {
1773
+ else
2363
1774
  return subCommand._parseCommand(operands, unknown);
2364
- }
2365
- });
2366
- return promiseChain;
1775
+ }), promiseChain;
2367
1776
  }
2368
1777
  /**
2369
1778
  * Invoke help directly if possible, or dispatch if necessary.
@@ -2372,14 +1781,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
2372
1781
  * @private
2373
1782
  */
2374
1783
  _dispatchHelpCommand(subcommandName) {
2375
- if (!subcommandName) {
2376
- this.help();
2377
- }
2378
- const subCommand = this._findCommand(subcommandName);
2379
- if (subCommand && !subCommand._executableHandler) {
2380
- subCommand.help();
2381
- }
2382
- return this._dispatchSubcommand(
1784
+ subcommandName || this.help();
1785
+ let subCommand = this._findCommand(subcommandName);
1786
+ return subCommand && !subCommand._executableHandler && subCommand.help(), this._dispatchSubcommand(
2383
1787
  subcommandName,
2384
1788
  [],
2385
1789
  [this._getHelpOption()?.long ?? this._getHelpOption()?.short ?? "--help"]
@@ -2392,16 +1796,8 @@ Expecting one of '${allowedValues.join("', '")}'`);
2392
1796
  */
2393
1797
  _checkNumberOfArguments() {
2394
1798
  this.registeredArguments.forEach((arg, i) => {
2395
- if (arg.required && this.args[i] == null) {
2396
- this.missingArgument(arg.name());
2397
- }
2398
- });
2399
- if (this.registeredArguments.length > 0 && this.registeredArguments[this.registeredArguments.length - 1].variadic) {
2400
- return;
2401
- }
2402
- if (this.args.length > this.registeredArguments.length) {
2403
- this._excessArguments(this.args);
2404
- }
1799
+ arg.required && this.args[i] == null && this.missingArgument(arg.name());
1800
+ }), !(this.registeredArguments.length > 0 && this.registeredArguments[this.registeredArguments.length - 1].variadic) && this.args.length > this.registeredArguments.length && this._excessArguments(this.args);
2405
1801
  }
2406
1802
  /**
2407
1803
  * Process this.args using this.registeredArguments and save as this.processedArgs!
@@ -2409,10 +1805,10 @@ Expecting one of '${allowedValues.join("', '")}'`);
2409
1805
  * @private
2410
1806
  */
2411
1807
  _processArguments() {
2412
- const myParseArg = /* @__PURE__ */ __name((argument, value, previous) => {
1808
+ let myParseArg = (argument, value, previous) => {
2413
1809
  let parsedValue = value;
2414
1810
  if (value !== null && argument.parseArg) {
2415
- const invalidValueMessage = `error: command-argument value '${value}' is invalid for argument '${argument.name()}'.`;
1811
+ let invalidValueMessage = `error: command-argument value '${value}' is invalid for argument '${argument.name()}'.`;
2416
1812
  parsedValue = this._callParseArg(
2417
1813
  argument,
2418
1814
  value,
@@ -2421,31 +1817,13 @@ Expecting one of '${allowedValues.join("', '")}'`);
2421
1817
  );
2422
1818
  }
2423
1819
  return parsedValue;
2424
- }, "myParseArg");
1820
+ };
2425
1821
  this._checkNumberOfArguments();
2426
- const processedArgs = [];
1822
+ let processedArgs = [];
2427
1823
  this.registeredArguments.forEach((declaredArg, index) => {
2428
1824
  let value = declaredArg.defaultValue;
2429
- if (declaredArg.variadic) {
2430
- if (index < this.args.length) {
2431
- value = this.args.slice(index);
2432
- if (declaredArg.parseArg) {
2433
- value = value.reduce((processed, v) => {
2434
- return myParseArg(declaredArg, v, processed);
2435
- }, declaredArg.defaultValue);
2436
- }
2437
- } else if (value === void 0) {
2438
- value = [];
2439
- }
2440
- } else if (index < this.args.length) {
2441
- value = this.args[index];
2442
- if (declaredArg.parseArg) {
2443
- value = myParseArg(declaredArg, value, declaredArg.defaultValue);
2444
- }
2445
- }
2446
- processedArgs[index] = value;
2447
- });
2448
- this.processedArgs = processedArgs;
1825
+ declaredArg.variadic ? index < this.args.length ? (value = this.args.slice(index), declaredArg.parseArg && (value = value.reduce((processed, v) => myParseArg(declaredArg, v, processed), declaredArg.defaultValue))) : value === void 0 && (value = []) : index < this.args.length && (value = this.args[index], declaredArg.parseArg && (value = myParseArg(declaredArg, value, declaredArg.defaultValue))), processedArgs[index] = value;
1826
+ }), this.processedArgs = processedArgs;
2449
1827
  }
2450
1828
  /**
2451
1829
  * Once we have a promise we chain, but call synchronously until then.
@@ -2456,10 +1834,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
2456
1834
  * @private
2457
1835
  */
2458
1836
  _chainOrCall(promise, fn) {
2459
- if (promise?.then && typeof promise.then === "function") {
2460
- return promise.then(() => fn());
2461
- }
2462
- return fn();
1837
+ return promise?.then && typeof promise.then == "function" ? promise.then(() => fn()) : fn();
2463
1838
  }
2464
1839
  /**
2465
1840
  *
@@ -2469,22 +1844,14 @@ Expecting one of '${allowedValues.join("', '")}'`);
2469
1844
  * @private
2470
1845
  */
2471
1846
  _chainOrCallHooks(promise, event) {
2472
- let result = promise;
2473
- const hooks = [];
2474
- this._getCommandAndAncestors().reverse().filter((cmd) => cmd._lifeCycleHooks[event] !== void 0).forEach((hookedCommand) => {
1847
+ let result = promise, hooks = [];
1848
+ return this._getCommandAndAncestors().reverse().filter((cmd) => cmd._lifeCycleHooks[event] !== void 0).forEach((hookedCommand) => {
2475
1849
  hookedCommand._lifeCycleHooks[event].forEach((callback) => {
2476
1850
  hooks.push({ hookedCommand, callback });
2477
1851
  });
2478
- });
2479
- if (event === "postAction") {
2480
- hooks.reverse();
2481
- }
2482
- hooks.forEach((hookDetail) => {
2483
- result = this._chainOrCall(result, () => {
2484
- return hookDetail.callback(hookDetail.hookedCommand, this);
2485
- });
2486
- });
2487
- return result;
1852
+ }), event === "postAction" && hooks.reverse(), hooks.forEach((hookDetail) => {
1853
+ result = this._chainOrCall(result, () => hookDetail.callback(hookDetail.hookedCommand, this));
1854
+ }), result;
2488
1855
  }
2489
1856
  /**
2490
1857
  *
@@ -2496,14 +1863,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
2496
1863
  */
2497
1864
  _chainOrCallSubCommandHook(promise, subCommand, event) {
2498
1865
  let result = promise;
2499
- if (this._lifeCycleHooks[event] !== void 0) {
2500
- this._lifeCycleHooks[event].forEach((hook) => {
2501
- result = this._chainOrCall(result, () => {
2502
- return hook(this, subCommand);
2503
- });
2504
- });
2505
- }
2506
- return result;
1866
+ return this._lifeCycleHooks[event] !== void 0 && this._lifeCycleHooks[event].forEach((hook) => {
1867
+ result = this._chainOrCall(result, () => hook(this, subCommand));
1868
+ }), result;
2507
1869
  }
2508
1870
  /**
2509
1871
  * Process arguments in context of this command.
@@ -2512,78 +1874,38 @@ Expecting one of '${allowedValues.join("', '")}'`);
2512
1874
  * @private
2513
1875
  */
2514
1876
  _parseCommand(operands, unknown) {
2515
- const parsed = this.parseOptions(unknown);
2516
- this._parseOptionsEnv();
2517
- this._parseOptionsImplied();
2518
- operands = operands.concat(parsed.operands);
2519
- unknown = parsed.unknown;
2520
- this.args = operands.concat(unknown);
2521
- if (operands && this._findCommand(operands[0])) {
1877
+ let parsed = this.parseOptions(unknown);
1878
+ if (this._parseOptionsEnv(), this._parseOptionsImplied(), operands = operands.concat(parsed.operands), unknown = parsed.unknown, this.args = operands.concat(unknown), operands && this._findCommand(operands[0]))
2522
1879
  return this._dispatchSubcommand(operands[0], operands.slice(1), unknown);
2523
- }
2524
- if (this._getHelpCommand() && operands[0] === this._getHelpCommand().name()) {
1880
+ if (this._getHelpCommand() && operands[0] === this._getHelpCommand().name())
2525
1881
  return this._dispatchHelpCommand(operands[1]);
2526
- }
2527
- if (this._defaultCommandName) {
2528
- this._outputHelpIfRequested(unknown);
2529
- return this._dispatchSubcommand(
1882
+ if (this._defaultCommandName)
1883
+ return this._outputHelpIfRequested(unknown), this._dispatchSubcommand(
2530
1884
  this._defaultCommandName,
2531
1885
  operands,
2532
1886
  unknown
2533
1887
  );
2534
- }
2535
- if (this.commands.length && this.args.length === 0 && !this._actionHandler && !this._defaultCommandName) {
2536
- this.help({ error: true });
2537
- }
2538
- this._outputHelpIfRequested(parsed.unknown);
2539
- this._checkForMissingMandatoryOptions();
2540
- this._checkForConflictingOptions();
2541
- const checkForUnknownOptions = /* @__PURE__ */ __name(() => {
2542
- if (parsed.unknown.length > 0) {
2543
- this.unknownOption(parsed.unknown[0]);
2544
- }
2545
- }, "checkForUnknownOptions");
2546
- const commandEvent = `command:${this.name()}`;
1888
+ this.commands.length && this.args.length === 0 && !this._actionHandler && !this._defaultCommandName && this.help({ error: !0 }), this._outputHelpIfRequested(parsed.unknown), this._checkForMissingMandatoryOptions(), this._checkForConflictingOptions();
1889
+ let checkForUnknownOptions = () => {
1890
+ parsed.unknown.length > 0 && this.unknownOption(parsed.unknown[0]);
1891
+ }, commandEvent = `command:${this.name()}`;
2547
1892
  if (this._actionHandler) {
2548
- checkForUnknownOptions();
2549
- this._processArguments();
1893
+ checkForUnknownOptions(), this._processArguments();
2550
1894
  let promiseChain;
2551
- promiseChain = this._chainOrCallHooks(promiseChain, "preAction");
2552
- promiseChain = this._chainOrCall(
1895
+ return promiseChain = this._chainOrCallHooks(promiseChain, "preAction"), promiseChain = this._chainOrCall(
2553
1896
  promiseChain,
2554
1897
  () => this._actionHandler(this.processedArgs)
2555
- );
2556
- if (this.parent) {
2557
- promiseChain = this._chainOrCall(promiseChain, () => {
2558
- this.parent.emit(commandEvent, operands, unknown);
2559
- });
2560
- }
2561
- promiseChain = this._chainOrCallHooks(promiseChain, "postAction");
2562
- return promiseChain;
2563
- }
2564
- if (this.parent?.listenerCount(commandEvent)) {
2565
- checkForUnknownOptions();
2566
- this._processArguments();
2567
- this.parent.emit(commandEvent, operands, unknown);
2568
- } else if (operands.length) {
2569
- if (this._findCommand("*")) {
1898
+ ), this.parent && (promiseChain = this._chainOrCall(promiseChain, () => {
1899
+ this.parent.emit(commandEvent, operands, unknown);
1900
+ })), promiseChain = this._chainOrCallHooks(promiseChain, "postAction"), promiseChain;
1901
+ }
1902
+ if (this.parent?.listenerCount(commandEvent))
1903
+ checkForUnknownOptions(), this._processArguments(), this.parent.emit(commandEvent, operands, unknown);
1904
+ else if (operands.length) {
1905
+ if (this._findCommand("*"))
2570
1906
  return this._dispatchSubcommand("*", operands, unknown);
2571
- }
2572
- if (this.listenerCount("command:*")) {
2573
- this.emit("command:*", operands, unknown);
2574
- } else if (this.commands.length) {
2575
- this.unknownCommand();
2576
- } else {
2577
- checkForUnknownOptions();
2578
- this._processArguments();
2579
- }
2580
- } else if (this.commands.length) {
2581
- checkForUnknownOptions();
2582
- this.help({ error: true });
2583
- } else {
2584
- checkForUnknownOptions();
2585
- this._processArguments();
2586
- }
1907
+ this.listenerCount("command:*") ? this.emit("command:*", operands, unknown) : this.commands.length ? this.unknownCommand() : (checkForUnknownOptions(), this._processArguments());
1908
+ } else this.commands.length ? (checkForUnknownOptions(), this.help({ error: !0 })) : (checkForUnknownOptions(), this._processArguments());
2587
1909
  }
2588
1910
  /**
2589
1911
  * Find matching command.
@@ -2592,10 +1914,10 @@ Expecting one of '${allowedValues.join("', '")}'`);
2592
1914
  * @return {Command | undefined}
2593
1915
  */
2594
1916
  _findCommand(name) {
2595
- if (!name) return void 0;
2596
- return this.commands.find(
2597
- (cmd) => cmd._name === name || cmd._aliases.includes(name)
2598
- );
1917
+ if (name)
1918
+ return this.commands.find(
1919
+ (cmd) => cmd._name === name || cmd._aliases.includes(name)
1920
+ );
2599
1921
  }
2600
1922
  /**
2601
1923
  * Return an option matching `arg` if any.
@@ -2616,9 +1938,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
2616
1938
  _checkForMissingMandatoryOptions() {
2617
1939
  this._getCommandAndAncestors().forEach((cmd) => {
2618
1940
  cmd.options.forEach((anOption) => {
2619
- if (anOption.mandatory && cmd.getOptionValue(anOption.attributeName()) === void 0) {
2620
- cmd.missingMandatoryOptionValue(anOption);
2621
- }
1941
+ anOption.mandatory && cmd.getOptionValue(anOption.attributeName()) === void 0 && cmd.missingMandatoryOptionValue(anOption);
2622
1942
  });
2623
1943
  });
2624
1944
  }
@@ -2628,23 +1948,17 @@ Expecting one of '${allowedValues.join("', '")}'`);
2628
1948
  * @private
2629
1949
  */
2630
1950
  _checkForConflictingLocalOptions() {
2631
- const definedNonDefaultOptions = this.options.filter((option) => {
2632
- const optionKey = option.attributeName();
2633
- if (this.getOptionValue(optionKey) === void 0) {
2634
- return false;
2635
- }
2636
- return this.getOptionValueSource(optionKey) !== "default";
1951
+ let definedNonDefaultOptions = this.options.filter((option) => {
1952
+ let optionKey = option.attributeName();
1953
+ return this.getOptionValue(optionKey) === void 0 ? !1 : this.getOptionValueSource(optionKey) !== "default";
2637
1954
  });
2638
- const optionsWithConflicting = definedNonDefaultOptions.filter(
1955
+ definedNonDefaultOptions.filter(
2639
1956
  (option) => option.conflictsWith.length > 0
2640
- );
2641
- optionsWithConflicting.forEach((option) => {
2642
- const conflictingAndDefined = definedNonDefaultOptions.find(
1957
+ ).forEach((option) => {
1958
+ let conflictingAndDefined = definedNonDefaultOptions.find(
2643
1959
  (defined) => option.conflictsWith.includes(defined.attributeName())
2644
1960
  );
2645
- if (conflictingAndDefined) {
2646
- this._conflictingOption(option, conflictingAndDefined);
2647
- }
1961
+ conflictingAndDefined && this._conflictingOption(option, conflictingAndDefined);
2648
1962
  });
2649
1963
  }
2650
1964
  /**
@@ -2676,82 +1990,55 @@ Expecting one of '${allowedValues.join("', '")}'`);
2676
1990
  * @return {{operands: string[], unknown: string[]}}
2677
1991
  */
2678
1992
  parseOptions(args) {
2679
- const operands = [];
2680
- const unknown = [];
2681
- let dest = operands;
1993
+ let operands = [], unknown = [], dest = operands;
2682
1994
  function maybeOption(arg) {
2683
1995
  return arg.length > 1 && arg[0] === "-";
2684
1996
  }
2685
- __name(maybeOption, "maybeOption");
2686
- const negativeNumberArg = /* @__PURE__ */ __name((arg) => {
2687
- if (!/^-\d*\.?\d+(e[+-]?\d+)?$/.test(arg)) return false;
2688
- return !this._getCommandAndAncestors().some(
2689
- (cmd) => cmd.options.map((opt) => opt.short).some((short) => /^-\d$/.test(short))
2690
- );
2691
- }, "negativeNumberArg");
2692
- let activeVariadicOption = null;
2693
- let activeGroup = null;
2694
- let i = 0;
2695
- while (i < args.length || activeGroup) {
2696
- const arg = activeGroup ?? args[i++];
2697
- activeGroup = null;
2698
- if (arg === "--") {
2699
- if (dest === unknown) dest.push(arg);
2700
- dest.push(...args.slice(i));
1997
+ let negativeNumberArg = (arg) => /^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(arg) ? !this._getCommandAndAncestors().some(
1998
+ (cmd) => cmd.options.map((opt) => opt.short).some((short) => /^-\d$/.test(short))
1999
+ ) : !1, activeVariadicOption = null, activeGroup = null, i = 0;
2000
+ for (; i < args.length || activeGroup; ) {
2001
+ let arg = activeGroup ?? args[i++];
2002
+ if (activeGroup = null, arg === "--") {
2003
+ dest === unknown && dest.push(arg), dest.push(...args.slice(i));
2701
2004
  break;
2702
2005
  }
2703
2006
  if (activeVariadicOption && (!maybeOption(arg) || negativeNumberArg(arg))) {
2704
2007
  this.emit(`option:${activeVariadicOption.name()}`, arg);
2705
2008
  continue;
2706
2009
  }
2707
- activeVariadicOption = null;
2708
- if (maybeOption(arg)) {
2709
- const option = this._findOption(arg);
2010
+ if (activeVariadicOption = null, maybeOption(arg)) {
2011
+ let option = this._findOption(arg);
2710
2012
  if (option) {
2711
2013
  if (option.required) {
2712
- const value = args[i++];
2713
- if (value === void 0) this.optionMissingArgument(option);
2714
- this.emit(`option:${option.name()}`, value);
2014
+ let value = args[i++];
2015
+ value === void 0 && this.optionMissingArgument(option), this.emit(`option:${option.name()}`, value);
2715
2016
  } else if (option.optional) {
2716
2017
  let value = null;
2717
- if (i < args.length && (!maybeOption(args[i]) || negativeNumberArg(args[i]))) {
2718
- value = args[i++];
2719
- }
2720
- this.emit(`option:${option.name()}`, value);
2721
- } else {
2018
+ i < args.length && (!maybeOption(args[i]) || negativeNumberArg(args[i])) && (value = args[i++]), this.emit(`option:${option.name()}`, value);
2019
+ } else
2722
2020
  this.emit(`option:${option.name()}`);
2723
- }
2724
2021
  activeVariadicOption = option.variadic ? option : null;
2725
2022
  continue;
2726
2023
  }
2727
2024
  }
2728
2025
  if (arg.length > 2 && arg[0] === "-" && arg[1] !== "-") {
2729
- const option = this._findOption(`-${arg[1]}`);
2026
+ let option = this._findOption(`-${arg[1]}`);
2730
2027
  if (option) {
2731
- if (option.required || option.optional && this._combineFlagAndOptionalValue) {
2732
- this.emit(`option:${option.name()}`, arg.slice(2));
2733
- } else {
2734
- this.emit(`option:${option.name()}`);
2735
- activeGroup = `-${arg.slice(2)}`;
2736
- }
2028
+ option.required || option.optional && this._combineFlagAndOptionalValue ? this.emit(`option:${option.name()}`, arg.slice(2)) : (this.emit(`option:${option.name()}`), activeGroup = `-${arg.slice(2)}`);
2737
2029
  continue;
2738
2030
  }
2739
2031
  }
2740
2032
  if (/^--[^=]+=/.test(arg)) {
2741
- const index = arg.indexOf("=");
2742
- const option = this._findOption(arg.slice(0, index));
2033
+ let index = arg.indexOf("="), option = this._findOption(arg.slice(0, index));
2743
2034
  if (option && (option.required || option.optional)) {
2744
2035
  this.emit(`option:${option.name()}`, arg.slice(index + 1));
2745
2036
  continue;
2746
2037
  }
2747
2038
  }
2748
- if (dest === operands && maybeOption(arg) && !(this.commands.length === 0 && negativeNumberArg(arg))) {
2749
- dest = unknown;
2750
- }
2751
- if ((this._enablePositionalOptions || this._passThroughOptions) && operands.length === 0 && unknown.length === 0) {
2039
+ if (dest === operands && maybeOption(arg) && !(this.commands.length === 0 && negativeNumberArg(arg)) && (dest = unknown), (this._enablePositionalOptions || this._passThroughOptions) && operands.length === 0 && unknown.length === 0) {
2752
2040
  if (this._findCommand(arg)) {
2753
- operands.push(arg);
2754
- unknown.push(...args.slice(i));
2041
+ operands.push(arg), unknown.push(...args.slice(i));
2755
2042
  break;
2756
2043
  } else if (this._getHelpCommand() && arg === this._getHelpCommand().name()) {
2757
2044
  operands.push(arg, ...args.slice(i));
@@ -2776,10 +2063,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
2776
2063
  */
2777
2064
  opts() {
2778
2065
  if (this._storeOptionsAsProperties) {
2779
- const result = {};
2780
- const len = this.options.length;
2066
+ let result = {}, len = this.options.length;
2781
2067
  for (let i = 0; i < len; i++) {
2782
- const key = this.options[i].attributeName();
2068
+ let key = this.options[i].attributeName();
2783
2069
  result[key] = key === this._versionOptionName ? this._version : this[key];
2784
2070
  }
2785
2071
  return result;
@@ -2810,17 +2096,10 @@ Expecting one of '${allowedValues.join("', '")}'`);
2810
2096
  `${message}
2811
2097
  `,
2812
2098
  this._outputConfiguration.writeErr
2813
- );
2814
- if (typeof this._showHelpAfterError === "string") {
2815
- this._outputConfiguration.writeErr(`${this._showHelpAfterError}
2816
- `);
2817
- } else if (this._showHelpAfterError) {
2818
- this._outputConfiguration.writeErr("\n");
2819
- this.outputHelp({ error: true });
2820
- }
2821
- const config = errorOptions || {};
2822
- const exitCode = config.exitCode || 1;
2823
- const code = config.code || "commander.error";
2099
+ ), typeof this._showHelpAfterError == "string" ? this._outputConfiguration.writeErr(`${this._showHelpAfterError}
2100
+ `) : this._showHelpAfterError && (this._outputConfiguration.writeErr(`
2101
+ `), this.outputHelp({ error: !0 }));
2102
+ let config = errorOptions || {}, exitCode = config.exitCode || 1, code = config.code || "commander.error";
2824
2103
  this._exit(exitCode, code, message);
2825
2104
  }
2826
2105
  /**
@@ -2832,16 +2111,10 @@ Expecting one of '${allowedValues.join("', '")}'`);
2832
2111
  _parseOptionsEnv() {
2833
2112
  this.options.forEach((option) => {
2834
2113
  if (option.envVar && option.envVar in process2.env) {
2835
- const optionKey = option.attributeName();
2836
- if (this.getOptionValue(optionKey) === void 0 || ["default", "config", "env"].includes(
2114
+ let optionKey = option.attributeName();
2115
+ (this.getOptionValue(optionKey) === void 0 || ["default", "config", "env"].includes(
2837
2116
  this.getOptionValueSource(optionKey)
2838
- )) {
2839
- if (option.required || option.optional) {
2840
- this.emit(`optionEnv:${option.name()}`, process2.env[option.envVar]);
2841
- } else {
2842
- this.emit(`optionEnv:${option.name()}`);
2843
- }
2844
- }
2117
+ )) && (option.required || option.optional ? this.emit(`optionEnv:${option.name()}`, process2.env[option.envVar]) : this.emit(`optionEnv:${option.name()}`));
2845
2118
  }
2846
2119
  });
2847
2120
  }
@@ -2851,10 +2124,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
2851
2124
  * @private
2852
2125
  */
2853
2126
  _parseOptionsImplied() {
2854
- const dualHelper = new DualOptions(this.options);
2855
- const hasCustomOptionValue = /* @__PURE__ */ __name((optionKey) => {
2856
- return this.getOptionValue(optionKey) !== void 0 && !["default", "implied"].includes(this.getOptionValueSource(optionKey));
2857
- }, "hasCustomOptionValue");
2127
+ let dualHelper = new DualOptions(this.options), hasCustomOptionValue = (optionKey) => this.getOptionValue(optionKey) !== void 0 && !["default", "implied"].includes(this.getOptionValueSource(optionKey));
2858
2128
  this.options.filter(
2859
2129
  (option) => option.implied !== void 0 && hasCustomOptionValue(option.attributeName()) && dualHelper.valueFromOption(
2860
2130
  this.getOptionValue(option.attributeName()),
@@ -2877,7 +2147,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
2877
2147
  * @private
2878
2148
  */
2879
2149
  missingArgument(name) {
2880
- const message = `error: missing required argument '${name}'`;
2150
+ let message = `error: missing required argument '${name}'`;
2881
2151
  this.error(message, { code: "commander.missingArgument" });
2882
2152
  }
2883
2153
  /**
@@ -2887,7 +2157,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
2887
2157
  * @private
2888
2158
  */
2889
2159
  optionMissingArgument(option) {
2890
- const message = `error: option '${option.flags}' argument missing`;
2160
+ let message = `error: option '${option.flags}' argument missing`;
2891
2161
  this.error(message, { code: "commander.optionMissingArgument" });
2892
2162
  }
2893
2163
  /**
@@ -2897,7 +2167,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
2897
2167
  * @private
2898
2168
  */
2899
2169
  missingMandatoryOptionValue(option) {
2900
- const message = `error: required option '${option.flags}' not specified`;
2170
+ let message = `error: required option '${option.flags}' not specified`;
2901
2171
  this.error(message, { code: "commander.missingMandatoryOptionValue" });
2902
2172
  }
2903
2173
  /**
@@ -2908,30 +2178,17 @@ Expecting one of '${allowedValues.join("', '")}'`);
2908
2178
  * @private
2909
2179
  */
2910
2180
  _conflictingOption(option, conflictingOption) {
2911
- const findBestOptionFromValue = /* @__PURE__ */ __name((option2) => {
2912
- const optionKey = option2.attributeName();
2913
- const optionValue = this.getOptionValue(optionKey);
2914
- const negativeOption = this.options.find(
2181
+ let findBestOptionFromValue = (option2) => {
2182
+ let optionKey = option2.attributeName(), optionValue = this.getOptionValue(optionKey), negativeOption = this.options.find(
2915
2183
  (target) => target.negate && optionKey === target.attributeName()
2916
- );
2917
- const positiveOption = this.options.find(
2184
+ ), positiveOption = this.options.find(
2918
2185
  (target) => !target.negate && optionKey === target.attributeName()
2919
2186
  );
2920
- if (negativeOption && (negativeOption.presetArg === void 0 && optionValue === false || negativeOption.presetArg !== void 0 && optionValue === negativeOption.presetArg)) {
2921
- return negativeOption;
2922
- }
2923
- return positiveOption || option2;
2924
- }, "findBestOptionFromValue");
2925
- const getErrorMessage = /* @__PURE__ */ __name((option2) => {
2926
- const bestOption = findBestOptionFromValue(option2);
2927
- const optionKey = bestOption.attributeName();
2928
- const source = this.getOptionValueSource(optionKey);
2929
- if (source === "env") {
2930
- return `environment variable '${bestOption.envVar}'`;
2931
- }
2932
- return `option '${bestOption.flags}'`;
2933
- }, "getErrorMessage");
2934
- const message = `error: ${getErrorMessage(option)} cannot be used with ${getErrorMessage(conflictingOption)}`;
2187
+ return negativeOption && (negativeOption.presetArg === void 0 && optionValue === !1 || negativeOption.presetArg !== void 0 && optionValue === negativeOption.presetArg) ? negativeOption : positiveOption || option2;
2188
+ }, getErrorMessage = (option2) => {
2189
+ let bestOption = findBestOptionFromValue(option2), optionKey = bestOption.attributeName();
2190
+ return this.getOptionValueSource(optionKey) === "env" ? `environment variable '${bestOption.envVar}'` : `option '${bestOption.flags}'`;
2191
+ }, message = `error: ${getErrorMessage(option)} cannot be used with ${getErrorMessage(conflictingOption)}`;
2935
2192
  this.error(message, { code: "commander.conflictingOption" });
2936
2193
  }
2937
2194
  /**
@@ -2944,16 +2201,14 @@ Expecting one of '${allowedValues.join("', '")}'`);
2944
2201
  if (this._allowUnknownOption) return;
2945
2202
  let suggestion = "";
2946
2203
  if (flag.startsWith("--") && this._showSuggestionAfterError) {
2947
- let candidateFlags = [];
2948
- let command2 = this;
2204
+ let candidateFlags = [], command2 = this;
2949
2205
  do {
2950
- const moreFlags = command2.createHelp().visibleOptions(command2).filter((option) => option.long).map((option) => option.long);
2951
- candidateFlags = candidateFlags.concat(moreFlags);
2952
- command2 = command2.parent;
2206
+ let moreFlags = command2.createHelp().visibleOptions(command2).filter((option) => option.long).map((option) => option.long);
2207
+ candidateFlags = candidateFlags.concat(moreFlags), command2 = command2.parent;
2953
2208
  } while (command2 && !command2._enablePositionalOptions);
2954
2209
  suggestion = suggestSimilar(flag, candidateFlags);
2955
2210
  }
2956
- const message = `error: unknown option '${flag}'${suggestion}`;
2211
+ let message = `error: unknown option '${flag}'${suggestion}`;
2957
2212
  this.error(message, { code: "commander.unknownOption" });
2958
2213
  }
2959
2214
  /**
@@ -2964,10 +2219,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
2964
2219
  */
2965
2220
  _excessArguments(receivedArgs) {
2966
2221
  if (this._allowExcessArguments) return;
2967
- const expected = this.registeredArguments.length;
2968
- const s = expected === 1 ? "" : "s";
2969
- const forSubcommand = this.parent ? ` for '${this.name()}'` : "";
2970
- const message = `error: too many arguments${forSubcommand}. Expected ${expected} argument${s} but got ${receivedArgs.length}.`;
2222
+ let expected = this.registeredArguments.length, s = expected === 1 ? "" : "s", message = `error: too many arguments${this.parent ? ` for '${this.name()}'` : ""}. Expected ${expected} argument${s} but got ${receivedArgs.length}.`;
2971
2223
  this.error(message, { code: "commander.excessArguments" });
2972
2224
  }
2973
2225
  /**
@@ -2976,17 +2228,14 @@ Expecting one of '${allowedValues.join("', '")}'`);
2976
2228
  * @private
2977
2229
  */
2978
2230
  unknownCommand() {
2979
- const unknownName = this.args[0];
2980
- let suggestion = "";
2231
+ let unknownName = this.args[0], suggestion = "";
2981
2232
  if (this._showSuggestionAfterError) {
2982
- const candidateNames = [];
2233
+ let candidateNames = [];
2983
2234
  this.createHelp().visibleCommands(this).forEach((command2) => {
2984
- candidateNames.push(command2.name());
2985
- if (command2.alias()) candidateNames.push(command2.alias());
2986
- });
2987
- suggestion = suggestSimilar(unknownName, candidateNames);
2235
+ candidateNames.push(command2.name()), command2.alias() && candidateNames.push(command2.alias());
2236
+ }), suggestion = suggestSimilar(unknownName, candidateNames);
2988
2237
  }
2989
- const message = `error: unknown command '${unknownName}'${suggestion}`;
2238
+ let message = `error: unknown command '${unknownName}'${suggestion}`;
2990
2239
  this.error(message, { code: "commander.unknownCommand" });
2991
2240
  }
2992
2241
  /**
@@ -3003,18 +2252,12 @@ Expecting one of '${allowedValues.join("', '")}'`);
3003
2252
  */
3004
2253
  version(str, flags, description) {
3005
2254
  if (str === void 0) return this._version;
3006
- this._version = str;
3007
- flags = flags || "-V, --version";
3008
- description = description || "output the version number";
3009
- const versionOption = this.createOption(flags, description);
3010
- this._versionOptionName = versionOption.attributeName();
3011
- this._registerOption(versionOption);
3012
- this.on("option:" + versionOption.name(), () => {
2255
+ this._version = str, flags = flags || "-V, --version", description = description || "output the version number";
2256
+ let versionOption = this.createOption(flags, description);
2257
+ return this._versionOptionName = versionOption.attributeName(), this._registerOption(versionOption), this.on("option:" + versionOption.name(), () => {
3013
2258
  this._outputConfiguration.writeOut(`${str}
3014
- `);
3015
- this._exit(0, "commander.version", str);
3016
- });
3017
- return this;
2259
+ `), this._exit(0, "commander.version", str);
2260
+ }), this;
3018
2261
  }
3019
2262
  /**
3020
2263
  * Set the description.
@@ -3024,13 +2267,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
3024
2267
  * @return {(string|Command)}
3025
2268
  */
3026
2269
  description(str, argsDescription) {
3027
- if (str === void 0 && argsDescription === void 0)
3028
- return this._description;
3029
- this._description = str;
3030
- if (argsDescription) {
3031
- this._argsDescription = argsDescription;
3032
- }
3033
- return this;
2270
+ return str === void 0 && argsDescription === void 0 ? this._description : (this._description = str, argsDescription && (this._argsDescription = argsDescription), this);
3034
2271
  }
3035
2272
  /**
3036
2273
  * Set the summary. Used when listed as subcommand of parent.
@@ -3039,9 +2276,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
3039
2276
  * @return {(string|Command)}
3040
2277
  */
3041
2278
  summary(str) {
3042
- if (str === void 0) return this._summary;
3043
- this._summary = str;
3044
- return this;
2279
+ return str === void 0 ? this._summary : (this._summary = str, this);
3045
2280
  }
3046
2281
  /**
3047
2282
  * Set an alias for the command.
@@ -3054,20 +2289,16 @@ Expecting one of '${allowedValues.join("', '")}'`);
3054
2289
  alias(alias) {
3055
2290
  if (alias === void 0) return this._aliases[0];
3056
2291
  let command2 = this;
3057
- if (this.commands.length !== 0 && this.commands[this.commands.length - 1]._executableHandler) {
3058
- command2 = this.commands[this.commands.length - 1];
3059
- }
3060
- if (alias === command2._name)
2292
+ if (this.commands.length !== 0 && this.commands[this.commands.length - 1]._executableHandler && (command2 = this.commands[this.commands.length - 1]), alias === command2._name)
3061
2293
  throw new Error("Command alias can't be the same as its name");
3062
- const matchingCommand = this.parent?._findCommand(alias);
2294
+ let matchingCommand = this.parent?._findCommand(alias);
3063
2295
  if (matchingCommand) {
3064
- const existingCmd = [matchingCommand.name()].concat(matchingCommand.aliases()).join("|");
2296
+ let existingCmd = [matchingCommand.name()].concat(matchingCommand.aliases()).join("|");
3065
2297
  throw new Error(
3066
2298
  `cannot add alias '${alias}' to command '${this.name()}' as already have command '${existingCmd}'`
3067
2299
  );
3068
2300
  }
3069
- command2._aliases.push(alias);
3070
- return this;
2301
+ return command2._aliases.push(alias), this;
3071
2302
  }
3072
2303
  /**
3073
2304
  * Set aliases for the command.
@@ -3078,9 +2309,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
3078
2309
  * @return {(string[]|Command)}
3079
2310
  */
3080
2311
  aliases(aliases) {
3081
- if (aliases === void 0) return this._aliases;
3082
- aliases.forEach((alias) => this.alias(alias));
3083
- return this;
2312
+ return aliases === void 0 ? this._aliases : (aliases.forEach((alias) => this.alias(alias)), this);
3084
2313
  }
3085
2314
  /**
3086
2315
  * Set / get the command usage `str`.
@@ -3091,17 +2320,14 @@ Expecting one of '${allowedValues.join("', '")}'`);
3091
2320
  usage(str) {
3092
2321
  if (str === void 0) {
3093
2322
  if (this._usage) return this._usage;
3094
- const args = this.registeredArguments.map((arg) => {
3095
- return humanReadableArgName(arg);
3096
- });
2323
+ let args = this.registeredArguments.map((arg) => humanReadableArgName(arg));
3097
2324
  return [].concat(
3098
2325
  this.options.length || this._helpOption !== null ? "[options]" : [],
3099
2326
  this.commands.length ? "[command]" : [],
3100
2327
  this.registeredArguments.length ? args : []
3101
2328
  ).join(" ");
3102
2329
  }
3103
- this._usage = str;
3104
- return this;
2330
+ return this._usage = str, this;
3105
2331
  }
3106
2332
  /**
3107
2333
  * Get or set the name of the command.
@@ -3110,9 +2336,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
3110
2336
  * @return {(string|Command)}
3111
2337
  */
3112
2338
  name(str) {
3113
- if (str === void 0) return this._name;
3114
- this._name = str;
3115
- return this;
2339
+ return str === void 0 ? this._name : (this._name = str, this);
3116
2340
  }
3117
2341
  /**
3118
2342
  * Set/get the help group heading for this subcommand in parent command's help.
@@ -3121,9 +2345,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
3121
2345
  * @return {Command | string}
3122
2346
  */
3123
2347
  helpGroup(heading) {
3124
- if (heading === void 0) return this._helpGroupHeading ?? "";
3125
- this._helpGroupHeading = heading;
3126
- return this;
2348
+ return heading === void 0 ? this._helpGroupHeading ?? "" : (this._helpGroupHeading = heading, this);
3127
2349
  }
3128
2350
  /**
3129
2351
  * Set/get the default help group heading for subcommands added to this command.
@@ -3139,9 +2361,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
3139
2361
  * @returns {Command | string}
3140
2362
  */
3141
2363
  commandsGroup(heading) {
3142
- if (heading === void 0) return this._defaultCommandGroup ?? "";
3143
- this._defaultCommandGroup = heading;
3144
- return this;
2364
+ return heading === void 0 ? this._defaultCommandGroup ?? "" : (this._defaultCommandGroup = heading, this);
3145
2365
  }
3146
2366
  /**
3147
2367
  * Set/get the default help group heading for options added to this command.
@@ -3157,25 +2377,21 @@ Expecting one of '${allowedValues.join("', '")}'`);
3157
2377
  * @returns {Command | string}
3158
2378
  */
3159
2379
  optionsGroup(heading) {
3160
- if (heading === void 0) return this._defaultOptionGroup ?? "";
3161
- this._defaultOptionGroup = heading;
3162
- return this;
2380
+ return heading === void 0 ? this._defaultOptionGroup ?? "" : (this._defaultOptionGroup = heading, this);
3163
2381
  }
3164
2382
  /**
3165
2383
  * @param {Option} option
3166
2384
  * @private
3167
2385
  */
3168
2386
  _initOptionGroup(option) {
3169
- if (this._defaultOptionGroup && !option.helpGroupHeading)
3170
- option.helpGroup(this._defaultOptionGroup);
2387
+ this._defaultOptionGroup && !option.helpGroupHeading && option.helpGroup(this._defaultOptionGroup);
3171
2388
  }
3172
2389
  /**
3173
2390
  * @param {Command} cmd
3174
2391
  * @private
3175
2392
  */
3176
2393
  _initCommandGroup(cmd) {
3177
- if (this._defaultCommandGroup && !cmd.helpGroup())
3178
- cmd.helpGroup(this._defaultCommandGroup);
2394
+ this._defaultCommandGroup && !cmd.helpGroup() && cmd.helpGroup(this._defaultCommandGroup);
3179
2395
  }
3180
2396
  /**
3181
2397
  * Set the name of the command from script filename, such as process.argv[1],
@@ -3190,8 +2406,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
3190
2406
  * @return {Command}
3191
2407
  */
3192
2408
  nameFromFilename(filename) {
3193
- this._name = path.basename(filename, path.extname(filename));
3194
- return this;
2409
+ return this._name = path.basename(filename, path.extname(filename)), this;
3195
2410
  }
3196
2411
  /**
3197
2412
  * Get or set the directory for searching for executable subcommands of this command.
@@ -3205,9 +2420,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
3205
2420
  * @return {(string|null|Command)}
3206
2421
  */
3207
2422
  executableDir(path2) {
3208
- if (path2 === void 0) return this._executableDir;
3209
- this._executableDir = path2;
3210
- return this;
2423
+ return path2 === void 0 ? this._executableDir : (this._executableDir = path2, this);
3211
2424
  }
3212
2425
  /**
3213
2426
  * Return program help documentation.
@@ -3216,16 +2429,14 @@ Expecting one of '${allowedValues.join("', '")}'`);
3216
2429
  * @return {string}
3217
2430
  */
3218
2431
  helpInformation(contextOptions) {
3219
- const helper = this.createHelp();
3220
- const context = this._getOutputContext(contextOptions);
2432
+ let helper = this.createHelp(), context = this._getOutputContext(contextOptions);
3221
2433
  helper.prepareContext({
3222
2434
  error: context.error,
3223
2435
  helpWidth: context.helpWidth,
3224
2436
  outputHasColors: context.hasColors
3225
2437
  });
3226
- const text = helper.formatHelp(this, helper);
3227
- if (context.hasColors) return text;
3228
- return this._outputConfiguration.stripColor(text);
2438
+ let text = helper.formatHelp(this, helper);
2439
+ return context.hasColors ? text : this._outputConfiguration.stripColor(text);
3229
2440
  }
3230
2441
  /**
3231
2442
  * @typedef HelpContext
@@ -3240,24 +2451,8 @@ Expecting one of '${allowedValues.join("', '")}'`);
3240
2451
  */
3241
2452
  _getOutputContext(contextOptions) {
3242
2453
  contextOptions = contextOptions || {};
3243
- const error = !!contextOptions.error;
3244
- let baseWrite;
3245
- let hasColors;
3246
- let helpWidth;
3247
- if (error) {
3248
- baseWrite = /* @__PURE__ */ __name((str) => this._outputConfiguration.writeErr(str), "baseWrite");
3249
- hasColors = this._outputConfiguration.getErrHasColors();
3250
- helpWidth = this._outputConfiguration.getErrHelpWidth();
3251
- } else {
3252
- baseWrite = /* @__PURE__ */ __name((str) => this._outputConfiguration.writeOut(str), "baseWrite");
3253
- hasColors = this._outputConfiguration.getOutHasColors();
3254
- helpWidth = this._outputConfiguration.getOutHelpWidth();
3255
- }
3256
- const write = /* @__PURE__ */ __name((str) => {
3257
- if (!hasColors) str = this._outputConfiguration.stripColor(str);
3258
- return baseWrite(str);
3259
- }, "write");
3260
- return { error, write, hasColors, helpWidth };
2454
+ let error = !!contextOptions.error, baseWrite, hasColors, helpWidth;
2455
+ return error ? (baseWrite = (str) => this._outputConfiguration.writeErr(str), hasColors = this._outputConfiguration.getErrHasColors(), helpWidth = this._outputConfiguration.getErrHelpWidth()) : (baseWrite = (str) => this._outputConfiguration.writeOut(str), hasColors = this._outputConfiguration.getOutHasColors(), helpWidth = this._outputConfiguration.getOutHelpWidth()), { error, write: (str) => (hasColors || (str = this._outputConfiguration.stripColor(str)), baseWrite(str)), hasColors, helpWidth };
3261
2456
  }
3262
2457
  /**
3263
2458
  * Output help information for this command.
@@ -3268,31 +2463,17 @@ Expecting one of '${allowedValues.join("', '")}'`);
3268
2463
  */
3269
2464
  outputHelp(contextOptions) {
3270
2465
  let deprecatedCallback;
3271
- if (typeof contextOptions === "function") {
3272
- deprecatedCallback = contextOptions;
3273
- contextOptions = void 0;
3274
- }
3275
- const outputContext = this._getOutputContext(contextOptions);
3276
- const eventContext = {
2466
+ typeof contextOptions == "function" && (deprecatedCallback = contextOptions, contextOptions = void 0);
2467
+ let outputContext = this._getOutputContext(contextOptions), eventContext = {
3277
2468
  error: outputContext.error,
3278
2469
  write: outputContext.write,
3279
2470
  command: this
3280
2471
  };
3281
- this._getCommandAndAncestors().reverse().forEach((command2) => command2.emit("beforeAllHelp", eventContext));
3282
- this.emit("beforeHelp", eventContext);
2472
+ this._getCommandAndAncestors().reverse().forEach((command2) => command2.emit("beforeAllHelp", eventContext)), this.emit("beforeHelp", eventContext);
3283
2473
  let helpInformation = this.helpInformation({ error: outputContext.error });
3284
- if (deprecatedCallback) {
3285
- helpInformation = deprecatedCallback(helpInformation);
3286
- if (typeof helpInformation !== "string" && !Buffer.isBuffer(helpInformation)) {
3287
- throw new Error("outputHelp callback must return a string or a Buffer");
3288
- }
3289
- }
3290
- outputContext.write(helpInformation);
3291
- if (this._getHelpOption()?.long) {
3292
- this.emit(this._getHelpOption().long);
3293
- }
3294
- this.emit("afterHelp", eventContext);
3295
- this._getCommandAndAncestors().forEach(
2474
+ if (deprecatedCallback && (helpInformation = deprecatedCallback(helpInformation), typeof helpInformation != "string" && !Buffer.isBuffer(helpInformation)))
2475
+ throw new Error("outputHelp callback must return a string or a Buffer");
2476
+ outputContext.write(helpInformation), this._getHelpOption()?.long && this.emit(this._getHelpOption().long), this.emit("afterHelp", eventContext), this._getCommandAndAncestors().forEach(
3296
2477
  (command2) => command2.emit("afterAllHelp", eventContext)
3297
2478
  );
3298
2479
  }
@@ -3309,23 +2490,10 @@ Expecting one of '${allowedValues.join("', '")}'`);
3309
2490
  * @return {Command} `this` command for chaining
3310
2491
  */
3311
2492
  helpOption(flags, description) {
3312
- if (typeof flags === "boolean") {
3313
- if (flags) {
3314
- if (this._helpOption === null) this._helpOption = void 0;
3315
- if (this._defaultOptionGroup) {
3316
- this._initOptionGroup(this._getHelpOption());
3317
- }
3318
- } else {
3319
- this._helpOption = null;
3320
- }
3321
- return this;
3322
- }
3323
- this._helpOption = this.createOption(
2493
+ return typeof flags == "boolean" ? (flags ? (this._helpOption === null && (this._helpOption = void 0), this._defaultOptionGroup && this._initOptionGroup(this._getHelpOption())) : this._helpOption = null, this) : (this._helpOption = this.createOption(
3324
2494
  flags ?? "-h, --help",
3325
2495
  description ?? "display help for command"
3326
- );
3327
- if (flags || description) this._initOptionGroup(this._helpOption);
3328
- return this;
2496
+ ), (flags || description) && this._initOptionGroup(this._helpOption), this);
3329
2497
  }
3330
2498
  /**
3331
2499
  * Lazy create help option.
@@ -3335,10 +2503,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
3335
2503
  * @package
3336
2504
  */
3337
2505
  _getHelpOption() {
3338
- if (this._helpOption === void 0) {
3339
- this.helpOption(void 0, void 0);
3340
- }
3341
- return this._helpOption;
2506
+ return this._helpOption === void 0 && this.helpOption(void 0, void 0), this._helpOption;
3342
2507
  }
3343
2508
  /**
3344
2509
  * Supply your own option to use for the built-in help option.
@@ -3348,9 +2513,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
3348
2513
  * @return {Command} `this` command for chaining
3349
2514
  */
3350
2515
  addHelpOption(option) {
3351
- this._helpOption = option;
3352
- this._initOptionGroup(option);
3353
- return this;
2516
+ return this._helpOption = option, this._initOptionGroup(option), this;
3354
2517
  }
3355
2518
  /**
3356
2519
  * Output help information and exit.
@@ -3362,10 +2525,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
3362
2525
  help(contextOptions) {
3363
2526
  this.outputHelp(contextOptions);
3364
2527
  let exitCode = Number(process2.exitCode ?? 0);
3365
- if (exitCode === 0 && contextOptions && typeof contextOptions !== "function" && contextOptions.error) {
3366
- exitCode = 1;
3367
- }
3368
- this._exit(exitCode, "commander.help", "(outputHelp)");
2528
+ exitCode === 0 && contextOptions && typeof contextOptions != "function" && contextOptions.error && (exitCode = 1), this._exit(exitCode, "commander.help", "(outputHelp)");
3369
2529
  }
3370
2530
  /**
3371
2531
  * // Do a little typing to coordinate emit and listener for the help text events.
@@ -3386,25 +2546,16 @@ Expecting one of '${allowedValues.join("', '")}'`);
3386
2546
  * @return {Command} `this` command for chaining
3387
2547
  */
3388
2548
  addHelpText(position, text) {
3389
- const allowedValues = ["beforeAll", "before", "after", "afterAll"];
3390
- if (!allowedValues.includes(position)) {
2549
+ let allowedValues = ["beforeAll", "before", "after", "afterAll"];
2550
+ if (!allowedValues.includes(position))
3391
2551
  throw new Error(`Unexpected value for position to addHelpText.
3392
2552
  Expecting one of '${allowedValues.join("', '")}'`);
3393
- }
3394
- const helpEvent = `${position}Help`;
3395
- this.on(helpEvent, (context) => {
2553
+ let helpEvent = `${position}Help`;
2554
+ return this.on(helpEvent, (context) => {
3396
2555
  let helpStr;
3397
- if (typeof text === "function") {
3398
- helpStr = text({ error: context.error, command: context.command });
3399
- } else {
3400
- helpStr = text;
3401
- }
3402
- if (helpStr) {
3403
- context.write(`${helpStr}
2556
+ typeof text == "function" ? helpStr = text({ error: context.error, command: context.command }) : helpStr = text, helpStr && context.write(`${helpStr}
3404
2557
  `);
3405
- }
3406
- });
3407
- return this;
2558
+ }), this;
3408
2559
  }
3409
2560
  /**
3410
2561
  * Output help information if help flags specified
@@ -3413,52 +2564,24 @@ Expecting one of '${allowedValues.join("', '")}'`);
3413
2564
  * @private
3414
2565
  */
3415
2566
  _outputHelpIfRequested(args) {
3416
- const helpOption = this._getHelpOption();
3417
- const helpRequested = helpOption && args.find((arg) => helpOption.is(arg));
3418
- if (helpRequested) {
3419
- this.outputHelp();
3420
- this._exit(0, "commander.helpDisplayed", "(outputHelp)");
3421
- }
2567
+ let helpOption = this._getHelpOption();
2568
+ helpOption && args.find((arg) => helpOption.is(arg)) && (this.outputHelp(), this._exit(0, "commander.helpDisplayed", "(outputHelp)"));
3422
2569
  }
3423
2570
  };
3424
2571
  function incrementNodeInspectorPort(args) {
3425
2572
  return args.map((arg) => {
3426
- if (!arg.startsWith("--inspect")) {
2573
+ if (!arg.startsWith("--inspect"))
3427
2574
  return arg;
3428
- }
3429
- let debugOption;
3430
- let debugHost = "127.0.0.1";
3431
- let debugPort = "9229";
3432
- let match;
3433
- if ((match = arg.match(/^(--inspect(-brk)?)$/)) !== null) {
3434
- debugOption = match[1];
3435
- } else if ((match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+)$/)) !== null) {
3436
- debugOption = match[1];
3437
- if (/^\d+$/.test(match[3])) {
3438
- debugPort = match[3];
3439
- } else {
3440
- debugHost = match[3];
3441
- }
3442
- } else if ((match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/)) !== null) {
3443
- debugOption = match[1];
3444
- debugHost = match[3];
3445
- debugPort = match[4];
3446
- }
3447
- if (debugOption && debugPort !== "0") {
3448
- return `${debugOption}=${debugHost}:${parseInt(debugPort) + 1}`;
3449
- }
3450
- return arg;
2575
+ let debugOption, debugHost = "127.0.0.1", debugPort = "9229", match;
2576
+ return (match = arg.match(/^(--inspect(-brk)?)$/)) !== null ? debugOption = match[1] : (match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+)$/)) !== null ? (debugOption = match[1], /^\d+$/.test(match[3]) ? debugPort = match[3] : debugHost = match[3]) : (match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/)) !== null && (debugOption = match[1], debugHost = match[3], debugPort = match[4]), debugOption && debugPort !== "0" ? `${debugOption}=${debugHost}:${parseInt(debugPort) + 1}` : arg;
3451
2577
  });
3452
2578
  }
3453
- __name(incrementNodeInspectorPort, "incrementNodeInspectorPort");
3454
2579
  function useColor() {
3455
2580
  if (process2.env.NO_COLOR || process2.env.FORCE_COLOR === "0" || process2.env.FORCE_COLOR === "false")
3456
- return false;
2581
+ return !1;
3457
2582
  if (process2.env.FORCE_COLOR || process2.env.CLICOLOR_FORCE !== void 0)
3458
- return true;
3459
- return void 0;
2583
+ return !0;
3460
2584
  }
3461
- __name(useColor, "useColor");
3462
2585
  exports.Command = Command2;
3463
2586
  exports.useColor = useColor;
3464
2587
  }
@@ -3467,11 +2590,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
3467
2590
  // ../node_modules/commander/index.js
3468
2591
  var require_commander = __commonJS({
3469
2592
  "../node_modules/commander/index.js"(exports) {
3470
- var { Argument: Argument2 } = require_argument();
3471
- var { Command: Command2 } = require_command();
3472
- var { CommanderError: CommanderError2, InvalidArgumentError: InvalidArgumentError2 } = require_error();
3473
- var { Help: Help2 } = require_help();
3474
- var { Option: Option2 } = require_option();
2593
+ var { Argument: Argument2 } = require_argument(), { Command: Command2 } = require_command(), { CommanderError: CommanderError2, InvalidArgumentError: InvalidArgumentError2 } = require_error(), { Help: Help2 } = require_help(), { Option: Option2 } = require_option();
3475
2594
  exports.program = new Command2();
3476
2595
  exports.createCommand = (name) => new Command2(name);
3477
2596
  exports.createOption = (flags, description) => new Option2(flags, description);
@@ -3492,8 +2611,7 @@ import { logTracker, logger as logger2 } from "storybook/internal/node-logger";
3492
2611
  import { addToGlobalContext } from "storybook/internal/telemetry";
3493
2612
 
3494
2613
  // ../node_modules/commander/esm.mjs
3495
- var import_index = __toESM(require_commander(), 1);
3496
- var {
2614
+ var import_index = __toESM(require_commander(), 1), {
3497
2615
  program,
3498
2616
  createCommand,
3499
2617
  createArgument,
@@ -3509,72 +2627,38 @@ var {
3509
2627
  } = import_index.default;
3510
2628
 
3511
2629
  // ../node_modules/leven/index.js
3512
- var array = [];
3513
- var characterCodeCache = [];
2630
+ var array = [], characterCodeCache = [];
3514
2631
  function leven(first, second, options) {
3515
- if (first === second) {
2632
+ if (first === second)
3516
2633
  return 0;
3517
- }
3518
- const maxDistance = options?.maxDistance;
3519
- const swap = first;
3520
- if (first.length > second.length) {
3521
- first = second;
3522
- second = swap;
3523
- }
3524
- let firstLength = first.length;
3525
- let secondLength = second.length;
3526
- while (firstLength > 0 && first.charCodeAt(~-firstLength) === second.charCodeAt(~-secondLength)) {
3527
- firstLength--;
3528
- secondLength--;
3529
- }
2634
+ let maxDistance = options?.maxDistance, swap = first;
2635
+ first.length > second.length && (first = second, second = swap);
2636
+ let firstLength = first.length, secondLength = second.length;
2637
+ for (; firstLength > 0 && first.charCodeAt(~-firstLength) === second.charCodeAt(~-secondLength); )
2638
+ firstLength--, secondLength--;
3530
2639
  let start = 0;
3531
- while (start < firstLength && first.charCodeAt(start) === second.charCodeAt(start)) {
2640
+ for (; start < firstLength && first.charCodeAt(start) === second.charCodeAt(start); )
3532
2641
  start++;
3533
- }
3534
- firstLength -= start;
3535
- secondLength -= start;
3536
- if (maxDistance !== void 0 && secondLength - firstLength > maxDistance) {
2642
+ if (firstLength -= start, secondLength -= start, maxDistance !== void 0 && secondLength - firstLength > maxDistance)
3537
2643
  return maxDistance;
3538
- }
3539
- if (firstLength === 0) {
2644
+ if (firstLength === 0)
3540
2645
  return maxDistance !== void 0 && secondLength > maxDistance ? maxDistance : secondLength;
3541
- }
3542
- let bCharacterCode;
3543
- let result;
3544
- let temporary;
3545
- let temporary2;
3546
- let index = 0;
3547
- let index2 = 0;
3548
- while (index < firstLength) {
3549
- characterCodeCache[index] = first.charCodeAt(start + index);
3550
- array[index] = ++index;
3551
- }
3552
- while (index2 < secondLength) {
3553
- bCharacterCode = second.charCodeAt(start + index2);
3554
- temporary = index2++;
3555
- result = index2;
3556
- for (index = 0; index < firstLength; index++) {
3557
- temporary2 = bCharacterCode === characterCodeCache[index] ? temporary : temporary + 1;
3558
- temporary = array[index];
3559
- result = array[index] = temporary > result ? temporary2 > result ? result + 1 : temporary2 : temporary2 > temporary ? temporary + 1 : temporary2;
3560
- }
2646
+ let bCharacterCode, result, temporary, temporary2, index = 0, index2 = 0;
2647
+ for (; index < firstLength; )
2648
+ characterCodeCache[index] = first.charCodeAt(start + index), array[index] = ++index;
2649
+ for (; index2 < secondLength; ) {
2650
+ for (bCharacterCode = second.charCodeAt(start + index2), temporary = index2++, result = index2, index = 0; index < firstLength; index++)
2651
+ temporary2 = bCharacterCode === characterCodeCache[index] ? temporary : temporary + 1, temporary = array[index], result = array[index] = temporary > result ? temporary2 > result ? result + 1 : temporary2 : temporary2 > temporary ? temporary + 1 : temporary2;
3561
2652
  if (maxDistance !== void 0) {
3562
2653
  let rowMinimum = result;
3563
- for (index = 0; index < firstLength; index++) {
3564
- if (array[index] < rowMinimum) {
3565
- rowMinimum = array[index];
3566
- }
3567
- }
3568
- if (rowMinimum > maxDistance) {
2654
+ for (index = 0; index < firstLength; index++)
2655
+ array[index] < rowMinimum && (rowMinimum = array[index]);
2656
+ if (rowMinimum > maxDistance)
3569
2657
  return maxDistance;
3570
- }
3571
2658
  }
3572
2659
  }
3573
- array.length = firstLength;
3574
- characterCodeCache.length = firstLength;
3575
- return maxDistance !== void 0 && result > maxDistance ? maxDistance : result;
2660
+ return array.length = firstLength, characterCodeCache.length = firstLength, maxDistance !== void 0 && result > maxDistance ? maxDistance : result;
3576
2661
  }
3577
- __name(leven, "leven");
3578
2662
 
3579
2663
  // src/bin/core.ts
3580
2664
  var import_picocolors = __toESM(require_picocolors(), 1);
@@ -3582,9 +2666,8 @@ var import_picocolors = __toESM(require_picocolors(), 1);
3582
2666
  // src/cli/build.ts
3583
2667
  import { cache } from "storybook/internal/common";
3584
2668
  import { buildStaticStandalone, withTelemetry } from "storybook/internal/core-server";
3585
- var build = /* @__PURE__ */ __name(async (cliOptions) => {
3586
- const { default: packageJson } = await import("storybook/package.json", { with: { type: "json" } });
3587
- const options = {
2669
+ var build = async (cliOptions) => {
2670
+ let { default: packageJson } = await import("storybook/package.json", { with: { type: "json" } }), options = {
3588
2671
  ...cliOptions,
3589
2672
  configDir: cliOptions.configDir || "./.storybook",
3590
2673
  outputDir: cliOptions.outputDir || "./storybook-static",
@@ -3598,28 +2681,27 @@ var build = /* @__PURE__ */ __name(async (cliOptions) => {
3598
2681
  { cliOptions, presetOptions: options },
3599
2682
  () => buildStaticStandalone(options)
3600
2683
  );
3601
- }, "build");
2684
+ };
3602
2685
 
3603
2686
  // src/cli/buildIndex.ts
3604
2687
  import { cache as cache2 } from "storybook/internal/common";
3605
2688
  import { buildIndexStandalone, withTelemetry as withTelemetry2 } from "storybook/internal/core-server";
3606
- var buildIndex = /* @__PURE__ */ __name(async (cliOptions) => {
3607
- const options = {
2689
+ var buildIndex = async (cliOptions) => {
2690
+ let options = {
3608
2691
  ...cliOptions,
3609
2692
  configDir: cliOptions.configDir || ".storybook",
3610
2693
  outputFile: cliOptions.outputFile || "index.json",
3611
- ignorePreview: true,
2694
+ ignorePreview: !0,
3612
2695
  configType: "PRODUCTION",
3613
2696
  cache: cache2,
3614
2697
  packageJson: cliOptions.packageJson
3615
- };
3616
- const presetOptions = {
2698
+ }, presetOptions = {
3617
2699
  ...options,
3618
2700
  corePresets: [],
3619
2701
  overridePresets: []
3620
2702
  };
3621
2703
  await withTelemetry2("index", { cliOptions, presetOptions }, () => buildIndexStandalone(options));
3622
- }, "buildIndex");
2704
+ };
3623
2705
 
3624
2706
  // src/cli/dev.ts
3625
2707
  var import_ts_dedent = __toESM(require_dist(), 1);
@@ -3627,20 +2709,7 @@ import { cache as cache3 } from "storybook/internal/common";
3627
2709
  import { buildDevStandalone, withTelemetry as withTelemetry3 } from "storybook/internal/core-server";
3628
2710
  import { logger, instance as npmLog } from "storybook/internal/node-logger";
3629
2711
  function printError(error) {
3630
- npmLog.heading = "";
3631
- if (error instanceof Error) {
3632
- if (error.error) {
3633
- logger.error(error.error);
3634
- } else if (error.stats && error.stats.compilation.errors) {
3635
- error.stats.compilation.errors.forEach((e) => logger.plain(e));
3636
- } else {
3637
- logger.error(error);
3638
- }
3639
- } else if (error.compilation?.errors) {
3640
- error.compilation.errors.forEach((e) => logger.plain(e));
3641
- }
3642
- logger.line();
3643
- logger.warn(
2712
+ npmLog.heading = "", error instanceof Error ? error.error ? logger.error(error.error) : error.stats && error.stats.compilation.errors ? error.stats.compilation.errors.forEach((e) => logger.log(e)) : logger.error(error) : error.compilation?.errors && error.compilation.errors.forEach((e) => logger.log(e)), logger.warn(
3644
2713
  error.close ? import_ts_dedent.dedent`
3645
2714
  FATAL broken build!, will close the process,
3646
2715
  Fix the error below and restart storybook.
@@ -3649,14 +2718,11 @@ function printError(error) {
3649
2718
  You may need to refresh the browser.
3650
2719
  `
3651
2720
  );
3652
- logger.line();
3653
2721
  }
3654
- __name(printError, "printError");
3655
- var dev = /* @__PURE__ */ __name(async (cliOptions) => {
3656
- const { env } = process;
2722
+ var dev = async (cliOptions) => {
2723
+ let { env } = process;
3657
2724
  env.NODE_ENV = env.NODE_ENV || "development";
3658
- const { default: packageJson } = await import("storybook/package.json", { with: { type: "json" } });
3659
- const options = {
2725
+ let { default: packageJson } = await import("storybook/package.json", { with: { type: "json" } }), options = {
3660
2726
  ...cliOptions,
3661
2727
  configDir: cliOptions.configDir || "./.storybook",
3662
2728
  configType: "DEVELOPMENT",
@@ -3674,33 +2740,34 @@ var dev = /* @__PURE__ */ __name(async (cliOptions) => {
3674
2740
  },
3675
2741
  () => buildDevStandalone(options)
3676
2742
  );
3677
- }, "dev");
2743
+ };
3678
2744
 
3679
2745
  // src/bin/core.ts
3680
2746
  addToGlobalContext("cliVersion", version);
3681
- var command = /* @__PURE__ */ __name((name) => program.command(name).option(
2747
+ var handleCommandFailure = async (logFilePath) => {
2748
+ let logFile = await logTracker.writeToFile(logFilePath);
2749
+ logger2.log(`Storybook debug logs can be found at: ${logFile}`), logger2.outro("Storybook exited with an error"), process.exit(1);
2750
+ }, command = (name) => program.command(name).option(
3682
2751
  "--disable-telemetry",
3683
2752
  "Disable sending telemetry data",
3684
2753
  optionalEnvToBoolean(process.env.STORYBOOK_DISABLE_TELEMETRY)
3685
- ).option("--debug", "Get more logs in debug mode", false).option("--enable-crash-reports", "Enable sending crash reports to telemetry data").option("--loglevel <trace | debug | info | warn | error | silent>", "Define log level", "info").option("--write-logs", "Write all debug logs to a file at the end of the run").hook("preAction", async (self) => {
2754
+ ).option("--debug", "Get more logs in debug mode", !1).option("--enable-crash-reports", "Enable sending crash reports to telemetry data").option("--loglevel <trace | debug | info | warn | error | silent>", "Define log level", "info").option(
2755
+ "--logfile [path]",
2756
+ "Write all debug logs to the specified file at the end of the run. Defaults to debug-storybook.log when [path] is not provided"
2757
+ ).hook("preAction", async (self) => {
3686
2758
  try {
3687
- const options = self.opts();
3688
- if (options.loglevel) {
3689
- logger2.setLogLevel(options.loglevel);
3690
- }
3691
- if (options.writeLogs) {
3692
- logTracker.enableLogWriting();
3693
- }
3694
- await globalSettings();
2759
+ let options = self.opts();
2760
+ options.loglevel && logger2.setLogLevel(options.loglevel), options.logfile && logTracker.enableLogWriting(), await globalSettings();
3695
2761
  } catch (e) {
3696
- logger2.error("Error loading global settings:\n" + String(e));
2762
+ logger2.error(`Error loading global settings:
2763
+ ` + String(e));
3697
2764
  }
3698
- }).hook("postAction", async () => {
2765
+ }).hook("postAction", async ({ getOptionValue }) => {
3699
2766
  if (logTracker.shouldWriteLogsToFile) {
3700
- const logFile = await logTracker.writeToFile();
2767
+ let logFile = await logTracker.writeToFile(getOptionValue("logfile"));
3701
2768
  logger2.outro(`Storybook debug logs can be found at: ${logFile}`);
3702
2769
  }
3703
- }), "command");
2770
+ });
3704
2771
  command("dev").option("-p, --port <number>", "Port to run Storybook", (str) => parseInt(str, 10)).option("-h, --host <string>", "Host to run Storybook").option("-c, --config-dir <dir-name>", "Directory where to load Storybook configurations from").option(
3705
2772
  "--https",
3706
2773
  "Serve Storybook over HTTPS. Note: You must provide your own certificate information."
@@ -3708,7 +2775,7 @@ command("dev").option("-p, --port <number>", "Port to run Storybook", (str) => p
3708
2775
  "--ssl-ca <ca>",
3709
2776
  "Provide an SSL certificate authority. (Optional with --https, required if using a self-signed certificate)",
3710
2777
  parseList
3711
- ).option("--ssl-cert <cert>", "Provide an SSL certificate. (Required with --https)").option("--ssl-key <key>", "Provide an SSL key. (Required with --https)").option("--smoke-test", "Exit after successful start").option("--ci", "CI mode (skip interactive prompts, don't open browser)").option("--no-open", "Do not open Storybook automatically in the browser").option("--quiet", "Suppress verbose build output").option("--no-version-updates", "Suppress update check", true).option("--debug-webpack", "Display final webpack configurations for debugging purposes").option(
2778
+ ).option("--ssl-cert <cert>", "Provide an SSL certificate. (Required with --https)").option("--ssl-key <key>", "Provide an SSL key. (Required with --https)").option("--smoke-test", "Exit after successful start").option("--ci", "CI mode (skip interactive prompts, don't open browser)").option("--no-open", "Do not open Storybook automatically in the browser").option("--quiet", "Suppress verbose build output").option("--no-version-updates", "Suppress update check", !0).option("--debug-webpack", "Display final webpack configurations for debugging purposes").option(
3712
2779
  "--webpack-stats-json [directory]",
3713
2780
  "Write Webpack stats JSON to disk (synonym for `--stats-json`)"
3714
2781
  ).option("--stats-json [directory]", "Write stats JSON to disk").option(
@@ -3718,21 +2785,16 @@ command("dev").option("-p, --port <number>", "Port to run Storybook", (str) => p
3718
2785
  "--initial-path [path]",
3719
2786
  "URL path to be appended when visiting Storybook for the first time"
3720
2787
  ).option("--preview-only", "Use the preview without the manager UI").action(async (options) => {
3721
- const { default: packageJson } = await import("storybook/package.json", { with: { type: "json" } });
3722
- logger2.log(
3723
- import_picocolors.default.bold(`${packageJson.name} v${packageJson.version}`) + import_picocolors.default.reset("\n")
3724
- );
3725
- getEnvConfig(options, {
2788
+ let { default: packageJson } = await import("storybook/package.json", { with: { type: "json" } });
2789
+ logger2.intro(`${packageJson.name} v${packageJson.version}`), getEnvConfig(options, {
3726
2790
  port: "SBCONFIG_PORT",
3727
2791
  host: "SBCONFIG_HOSTNAME",
3728
2792
  staticDir: "SBCONFIG_STATIC_DIR",
3729
2793
  configDir: "SBCONFIG_CONFIG_DIR",
3730
2794
  ci: "CI"
2795
+ }), parseInt(`${options.port}`, 10) && (options.port = parseInt(`${options.port}`, 10)), await dev({ ...options, packageJson }).catch(() => {
2796
+ handleCommandFailure(options.logfile);
3731
2797
  });
3732
- if (parseInt(`${options.port}`, 10)) {
3733
- options.port = parseInt(`${options.port}`, 10);
3734
- }
3735
- await dev({ ...options, packageJson }).catch(() => process.exit(1));
3736
2798
  });
3737
2799
  command("build").option("-o, --output-dir <dir-name>", "Directory where to store built files").option("-c, --config-dir <dir-name>", "Directory where to load Storybook configurations from").option("--quiet", "Suppress verbose build output").option("--debug-webpack", "Display final webpack configurations for debugging purposes").option(
3738
2800
  "--webpack-stats-json [directory]",
@@ -3741,47 +2803,38 @@ command("build").option("-o, --output-dir <dir-name>", "Directory where to store
3741
2803
  "--preview-url <string>",
3742
2804
  "Disables the default storybook preview and lets your use your own"
3743
2805
  ).option("--force-build-preview", "Build the preview iframe even if you are using --preview-url").option("--docs", "Build a documentation-only site using addon-docs").option("--test", "Build stories optimized for testing purposes.").option("--preview-only", "Use the preview without the manager UI").action(async (options) => {
3744
- const { env } = process;
2806
+ let { env } = process;
3745
2807
  env.NODE_ENV = env.NODE_ENV || "production";
3746
- const { default: packageJson } = await import("storybook/package.json", { with: { type: "json" } });
3747
- logger2.log(import_picocolors.default.bold(`${packageJson.name} v${packageJson.version}
3748
- `));
3749
- getEnvConfig(options, {
2808
+ let { default: packageJson } = await import("storybook/package.json", { with: { type: "json" } });
2809
+ logger2.intro(`Building ${packageJson.name} v${packageJson.version}`), getEnvConfig(options, {
3750
2810
  staticDir: "SBCONFIG_STATIC_DIR",
3751
2811
  outputDir: "SBCONFIG_OUTPUT_DIR",
3752
2812
  configDir: "SBCONFIG_CONFIG_DIR"
3753
- });
3754
- await build({
2813
+ }), await build({
3755
2814
  ...options,
3756
2815
  packageJson,
3757
2816
  test: !!options.test || optionalEnvToBoolean(process.env.SB_TESTBUILD)
3758
- }).catch(() => process.exit(1));
2817
+ }).catch(() => {
2818
+ logger2.outro("Storybook exited with an error"), process.exit(1);
2819
+ }), logger2.outro("Storybook build completed successfully");
3759
2820
  });
3760
2821
  command("index").option("-o, --output-file <file-name>", "JSON file to output index").option("-c, --config-dir <dir-name>", "Directory where to load Storybook configurations from").option("--quiet", "Suppress verbose build output").action(async (options) => {
3761
- const { env } = process;
2822
+ let { env } = process;
3762
2823
  env.NODE_ENV = env.NODE_ENV || "production";
3763
- const { default: packageJson } = await import("storybook/package.json", { with: { type: "json" } });
2824
+ let { default: packageJson } = await import("storybook/package.json", { with: { type: "json" } });
3764
2825
  logger2.log(import_picocolors.default.bold(`${packageJson.name} v${packageJson.version}
3765
- `));
3766
- getEnvConfig(options, {
2826
+ `)), getEnvConfig(options, {
3767
2827
  configDir: "SBCONFIG_CONFIG_DIR",
3768
2828
  outputFile: "SBCONFIG_OUTPUT_FILE"
3769
- });
3770
- await buildIndex({
2829
+ }), await buildIndex({
3771
2830
  ...options,
3772
2831
  packageJson
3773
2832
  }).catch(() => process.exit(1));
3774
2833
  });
3775
2834
  program.on("command:*", ([invalidCmd]) => {
3776
2835
  let errorMessage = ` Invalid command: ${import_picocolors.default.bold(invalidCmd)}.
3777
- See --help for a list of available commands.`;
3778
- const availableCommands = program.commands.map((cmd) => cmd.name());
3779
- const suggestion = availableCommands.find((cmd) => leven(cmd, invalidCmd) < 3);
3780
- if (suggestion) {
3781
- errorMessage += `
3782
- Did you mean ${import_picocolors.default.yellow(suggestion)}?`;
3783
- }
3784
- logger2.error(errorMessage);
3785
- process.exit(1);
2836
+ See --help for a list of available commands.`, suggestion = program.commands.map((cmd) => cmd.name()).find((cmd) => leven(cmd, invalidCmd) < 3);
2837
+ suggestion && (errorMessage += `
2838
+ Did you mean ${import_picocolors.default.yellow(suggestion)}?`), logger2.error(errorMessage), process.exit(1);
3786
2839
  });
3787
2840
  program.usage("<command> [options]").version(String(version)).parse(process.argv);