@lynx-js/rspeedy 0.8.7 → 0.9.1

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 (163) hide show
  1. package/CHANGELOG.md +51 -0
  2. package/bin/rspeedy.js +2 -2
  3. package/dist/cli/main.js +414 -0
  4. package/dist/cli/start.js +171 -0
  5. package/dist/index.d.ts +2971 -0
  6. package/dist/index.js +39556 -0
  7. package/dist/register/hooks.js +552 -0
  8. package/dist/register/index.js +22 -0
  9. package/dist/src_cli_build_ts.js +47 -0
  10. package/dist/src_cli_commands_ts.js +60 -0
  11. package/dist/src_cli_dev_ts.js +87 -0
  12. package/dist/src_cli_exit_ts.js +111 -0
  13. package/dist/src_cli_inspect_ts.js +42 -0
  14. package/dist/src_cli_preview_ts.js +49 -0
  15. package/dist/src_config_loadConfig_ts-src_create-rspeedy_ts.js +39311 -0
  16. package/dist/src_plugins_api_plugin_ts.js +32 -0
  17. package/dist/src_plugins_chunkLoading_plugin_ts.js +35 -0
  18. package/dist/src_plugins_dev_plugin_ts.js +141 -0
  19. package/dist/src_plugins_index_ts.js +60 -0
  20. package/dist/src_plugins_inspect_plugin_ts.js +48 -0
  21. package/dist/src_plugins_minify_plugin_ts.js +85 -0
  22. package/dist/src_plugins_optimization_plugin_ts.js +25 -0
  23. package/dist/src_plugins_output_plugin_ts.js +46 -0
  24. package/dist/src_plugins_resolve_plugin_ts.js +21 -0
  25. package/dist/src_plugins_rsdoctor_plugin_ts.js +59 -0
  26. package/dist/src_plugins_sourcemap_plugin_ts.js +99 -0
  27. package/dist/src_plugins_stats_plugin_ts.js +26 -0
  28. package/dist/src_plugins_swc_plugin_ts.js +36 -0
  29. package/dist/src_plugins_target_plugin_ts.js +45 -0
  30. package/dist/src_version_ts.js +18 -0
  31. package/dist/vendors-node_modules_pnpm_chokidar_4_0_3_node_modules_chokidar_esm_index_js.js +1435 -0
  32. package/dist/vendors-node_modules_pnpm_chokidar_4_0_3_node_modules_chokidar_esm_index_js.js.LICENSE.txt +1 -0
  33. package/dist/vendors-node_modules_pnpm_commander_13_1_0_node_modules_commander_esm_mjs.js +1761 -0
  34. package/dist/vendors-node_modules_pnpm_ipaddr_js_2_2_0_node_modules_ipaddr_js_lib_ipaddr_js.js +1067 -0
  35. package/dist/vendors-node_modules_pnpm_javascript-stringify_2_1_0_node_modules_javascript-stringify_dist_i-b558be.js +416 -0
  36. package/package.json +36 -23
  37. package/LICENSE +0 -202
  38. package/lib/api.d.ts +0 -46
  39. package/lib/api.js +0 -2
  40. package/lib/cli/build.d.ts +0 -4
  41. package/lib/cli/build.js +0 -32
  42. package/lib/cli/commands.d.ts +0 -5
  43. package/lib/cli/commands.js +0 -45
  44. package/lib/cli/dev.d.ts +0 -4
  45. package/lib/cli/dev.js +0 -75
  46. package/lib/cli/exit.d.ts +0 -1
  47. package/lib/cli/exit.js +0 -51
  48. package/lib/cli/inspect.d.ts +0 -8
  49. package/lib/cli/inspect.js +0 -30
  50. package/lib/cli/main.d.ts +0 -1
  51. package/lib/cli/main.js +0 -39
  52. package/lib/cli/preview.d.ts +0 -4
  53. package/lib/cli/preview.js +0 -31
  54. package/lib/cli/start.d.ts +0 -6
  55. package/lib/cli/start.js +0 -88
  56. package/lib/config/defaults.d.ts +0 -2
  57. package/lib/config/defaults.js +0 -32
  58. package/lib/config/defineConfig.d.ts +0 -22
  59. package/lib/config/defineConfig.js +0 -24
  60. package/lib/config/dev/client.d.ts +0 -15
  61. package/lib/config/dev/client.js +0 -2
  62. package/lib/config/dev/index.d.ts +0 -173
  63. package/lib/config/dev/index.js +0 -2
  64. package/lib/config/index.d.ts +0 -172
  65. package/lib/config/index.js +0 -2
  66. package/lib/config/loadConfig.d.ts +0 -50
  67. package/lib/config/loadConfig.js +0 -98
  68. package/lib/config/mergeRspeedyConfig.d.ts +0 -36
  69. package/lib/config/mergeRspeedyConfig.js +0 -42
  70. package/lib/config/output/css-modules.d.ts +0 -84
  71. package/lib/config/output/css-modules.js +0 -2
  72. package/lib/config/output/dist-path.d.ts +0 -19
  73. package/lib/config/output/dist-path.js +0 -2
  74. package/lib/config/output/filename.d.ts +0 -167
  75. package/lib/config/output/filename.js +0 -2
  76. package/lib/config/output/index.d.ts +0 -324
  77. package/lib/config/output/index.js +0 -2
  78. package/lib/config/output/minify.d.ts +0 -80
  79. package/lib/config/output/minify.js +0 -2
  80. package/lib/config/output/source-map.d.ts +0 -68
  81. package/lib/config/output/source-map.js +0 -2
  82. package/lib/config/performance/chunk-split.d.ts +0 -192
  83. package/lib/config/performance/chunk-split.js +0 -2
  84. package/lib/config/performance/index.d.ts +0 -165
  85. package/lib/config/performance/index.js +0 -2
  86. package/lib/config/rsbuild/entry.d.ts +0 -3
  87. package/lib/config/rsbuild/entry.js +0 -31
  88. package/lib/config/rsbuild/index.d.ts +0 -4
  89. package/lib/config/rsbuild/index.js +0 -75
  90. package/lib/config/server/index.d.ts +0 -91
  91. package/lib/config/server/index.js +0 -2
  92. package/lib/config/source/decorators.d.ts +0 -43
  93. package/lib/config/source/decorators.js +0 -2
  94. package/lib/config/source/entry.d.ts +0 -84
  95. package/lib/config/source/entry.js +0 -2
  96. package/lib/config/source/index.d.ts +0 -474
  97. package/lib/config/source/index.js +0 -2
  98. package/lib/config/source/transformImport.d.ts +0 -106
  99. package/lib/config/source/transformImport.js +0 -2
  100. package/lib/config/tools/css-extract.d.ts +0 -72
  101. package/lib/config/tools/css-extract.js +0 -2
  102. package/lib/config/tools/css-loader.d.ts +0 -130
  103. package/lib/config/tools/css-loader.js +0 -2
  104. package/lib/config/tools/index.d.ts +0 -170
  105. package/lib/config/tools/index.js +0 -2
  106. package/lib/config/validate.d.ts +0 -4
  107. package/lib/config/validate.js +0 -28877
  108. package/lib/create-rspeedy.d.ts +0 -52
  109. package/lib/create-rspeedy.js +0 -49
  110. package/lib/debug.d.ts +0 -3
  111. package/lib/debug.js +0 -25
  112. package/lib/index.d.ts +0 -46
  113. package/lib/index.js +0 -11
  114. package/lib/plugins/api.plugin.d.ts +0 -3
  115. package/lib/plugins/api.plugin.js +0 -25
  116. package/lib/plugins/chunkLoading.plugin.d.ts +0 -2
  117. package/lib/plugins/chunkLoading.plugin.js +0 -43
  118. package/lib/plugins/dev.plugin.d.ts +0 -5
  119. package/lib/plugins/dev.plugin.js +0 -137
  120. package/lib/plugins/index.d.ts +0 -3
  121. package/lib/plugins/index.js +0 -49
  122. package/lib/plugins/inspect.plugin.d.ts +0 -4
  123. package/lib/plugins/inspect.plugin.js +0 -39
  124. package/lib/plugins/minify.plugin.d.ts +0 -3
  125. package/lib/plugins/minify.plugin.js +0 -89
  126. package/lib/plugins/optimization.plugin.d.ts +0 -2
  127. package/lib/plugins/optimization.plugin.js +0 -31
  128. package/lib/plugins/output.plugin.d.ts +0 -3
  129. package/lib/plugins/output.plugin.js +0 -34
  130. package/lib/plugins/resolve.plugin.d.ts +0 -2
  131. package/lib/plugins/resolve.plugin.js +0 -38
  132. package/lib/plugins/rsdoctor.plugin.d.ts +0 -3
  133. package/lib/plugins/rsdoctor.plugin.js +0 -48
  134. package/lib/plugins/sourcemap.plugin.d.ts +0 -2
  135. package/lib/plugins/sourcemap.plugin.js +0 -86
  136. package/lib/plugins/stats.plugin.d.ts +0 -2
  137. package/lib/plugins/stats.plugin.js +0 -20
  138. package/lib/plugins/swc.plugin.d.ts +0 -2
  139. package/lib/plugins/swc.plugin.js +0 -21
  140. package/lib/plugins/target.plugin.d.ts +0 -2
  141. package/lib/plugins/target.plugin.js +0 -22
  142. package/lib/utils/getESVersionTarget.d.ts +0 -1
  143. package/lib/utils/getESVersionTarget.js +0 -7
  144. package/lib/utils/is-ci.d.ts +0 -1
  145. package/lib/utils/is-ci.js +0 -7
  146. package/lib/utils/is-lynx.d.ts +0 -2
  147. package/lib/utils/is-lynx.js +0 -6
  148. package/lib/utils/is-web.d.ts +0 -2
  149. package/lib/utils/is-web.js +0 -6
  150. package/lib/version.d.ts +0 -4
  151. package/lib/version.js +0 -15
  152. package/lib/webpack/CompilationIdPlugin.d.ts +0 -4
  153. package/lib/webpack/CompilationIdPlugin.js +0 -20
  154. package/lib/webpack/EvalSourceMapDevToolPlugin.d.ts +0 -9
  155. package/lib/webpack/EvalSourceMapDevToolPlugin.js +0 -15
  156. package/lib/webpack/ProvidePlugin.d.ts +0 -9
  157. package/lib/webpack/ProvidePlugin.js +0 -15
  158. package/lib/webpack/SourceMapDevToolPlugin.d.ts +0 -9
  159. package/lib/webpack/SourceMapDevToolPlugin.js +0 -15
  160. package/register/data.d.ts +0 -9
  161. package/register/hooks.js +0 -146
  162. package/register/index.js +0 -47
  163. /package/{register → dist/register}/index.d.ts +0 -0
@@ -0,0 +1,1761 @@
1
+ export const __webpack_ids__ = [
2
+ 'vendors-node_modules_pnpm_commander_13_1_0_node_modules_commander_esm_mjs'
3
+ ];
4
+ export const __webpack_modules__ = {
5
+ "../../../node_modules/.pnpm/commander@13.1.0/node_modules/commander/index.js": function(__unused_webpack_module, exports, __webpack_require__) {
6
+ const { Argument } = __webpack_require__("../../../node_modules/.pnpm/commander@13.1.0/node_modules/commander/lib/argument.js");
7
+ const { Command } = __webpack_require__("../../../node_modules/.pnpm/commander@13.1.0/node_modules/commander/lib/command.js");
8
+ const { CommanderError, InvalidArgumentError } = __webpack_require__("../../../node_modules/.pnpm/commander@13.1.0/node_modules/commander/lib/error.js");
9
+ const { Help } = __webpack_require__("../../../node_modules/.pnpm/commander@13.1.0/node_modules/commander/lib/help.js");
10
+ const { Option } = __webpack_require__("../../../node_modules/.pnpm/commander@13.1.0/node_modules/commander/lib/option.js");
11
+ exports.program = new Command();
12
+ exports.createCommand = (name)=>new Command(name);
13
+ exports.createOption = (flags, description)=>new Option(flags, description);
14
+ exports.createArgument = (name, description)=>new Argument(name, description);
15
+ exports.Command = Command;
16
+ exports.Option = Option;
17
+ exports.Argument = Argument;
18
+ exports.Help = Help;
19
+ exports.CommanderError = CommanderError;
20
+ exports.InvalidArgumentError = InvalidArgumentError;
21
+ exports.InvalidOptionArgumentError = InvalidArgumentError;
22
+ },
23
+ "../../../node_modules/.pnpm/commander@13.1.0/node_modules/commander/lib/argument.js": function(__unused_webpack_module, exports, __webpack_require__) {
24
+ const { InvalidArgumentError } = __webpack_require__("../../../node_modules/.pnpm/commander@13.1.0/node_modules/commander/lib/error.js");
25
+ class Argument {
26
+ constructor(name, description){
27
+ this.description = description || '';
28
+ this.variadic = false;
29
+ this.parseArg = void 0;
30
+ this.defaultValue = void 0;
31
+ this.defaultValueDescription = void 0;
32
+ this.argChoices = void 0;
33
+ switch(name[0]){
34
+ case '<':
35
+ this.required = true;
36
+ this._name = name.slice(1, -1);
37
+ break;
38
+ case '[':
39
+ this.required = false;
40
+ this._name = name.slice(1, -1);
41
+ break;
42
+ default:
43
+ this.required = true;
44
+ this._name = name;
45
+ break;
46
+ }
47
+ if (this._name.length > 3 && '...' === this._name.slice(-3)) {
48
+ this.variadic = true;
49
+ this._name = this._name.slice(0, -3);
50
+ }
51
+ }
52
+ name() {
53
+ return this._name;
54
+ }
55
+ _concatValue(value, previous) {
56
+ if (previous === this.defaultValue || !Array.isArray(previous)) return [
57
+ value
58
+ ];
59
+ return previous.concat(value);
60
+ }
61
+ default(value, description) {
62
+ this.defaultValue = value;
63
+ this.defaultValueDescription = description;
64
+ return this;
65
+ }
66
+ argParser(fn) {
67
+ this.parseArg = fn;
68
+ return this;
69
+ }
70
+ choices(values) {
71
+ this.argChoices = values.slice();
72
+ this.parseArg = (arg, previous)=>{
73
+ if (!this.argChoices.includes(arg)) throw new InvalidArgumentError(`Allowed choices are ${this.argChoices.join(', ')}.`);
74
+ if (this.variadic) return this._concatValue(arg, previous);
75
+ return arg;
76
+ };
77
+ return this;
78
+ }
79
+ argRequired() {
80
+ this.required = true;
81
+ return this;
82
+ }
83
+ argOptional() {
84
+ this.required = false;
85
+ return this;
86
+ }
87
+ }
88
+ function humanReadableArgName(arg) {
89
+ const nameOutput = arg.name() + (true === arg.variadic ? '...' : '');
90
+ return arg.required ? '<' + nameOutput + '>' : '[' + nameOutput + ']';
91
+ }
92
+ exports.Argument = Argument;
93
+ exports.humanReadableArgName = humanReadableArgName;
94
+ },
95
+ "../../../node_modules/.pnpm/commander@13.1.0/node_modules/commander/lib/command.js": function(__unused_webpack_module, exports, __webpack_require__) {
96
+ const EventEmitter = __webpack_require__("node:events").EventEmitter;
97
+ const childProcess = __webpack_require__("node:child_process");
98
+ const path = __webpack_require__("node:path");
99
+ const fs = __webpack_require__("node:fs");
100
+ const process = __webpack_require__("node:process");
101
+ const { Argument, humanReadableArgName } = __webpack_require__("../../../node_modules/.pnpm/commander@13.1.0/node_modules/commander/lib/argument.js");
102
+ const { CommanderError } = __webpack_require__("../../../node_modules/.pnpm/commander@13.1.0/node_modules/commander/lib/error.js");
103
+ const { Help, stripColor } = __webpack_require__("../../../node_modules/.pnpm/commander@13.1.0/node_modules/commander/lib/help.js");
104
+ const { Option, DualOptions } = __webpack_require__("../../../node_modules/.pnpm/commander@13.1.0/node_modules/commander/lib/option.js");
105
+ const { suggestSimilar } = __webpack_require__("../../../node_modules/.pnpm/commander@13.1.0/node_modules/commander/lib/suggestSimilar.js");
106
+ class Command extends EventEmitter {
107
+ constructor(name){
108
+ super();
109
+ this.commands = [];
110
+ this.options = [];
111
+ this.parent = null;
112
+ this._allowUnknownOption = false;
113
+ this._allowExcessArguments = false;
114
+ this.registeredArguments = [];
115
+ this._args = this.registeredArguments;
116
+ this.args = [];
117
+ this.rawArgs = [];
118
+ this.processedArgs = [];
119
+ this._scriptPath = null;
120
+ this._name = name || '';
121
+ this._optionValues = {};
122
+ this._optionValueSources = {};
123
+ this._storeOptionsAsProperties = false;
124
+ this._actionHandler = null;
125
+ this._executableHandler = false;
126
+ this._executableFile = null;
127
+ this._executableDir = null;
128
+ this._defaultCommandName = null;
129
+ this._exitCallback = null;
130
+ this._aliases = [];
131
+ this._combineFlagAndOptionalValue = true;
132
+ this._description = '';
133
+ this._summary = '';
134
+ this._argsDescription = void 0;
135
+ this._enablePositionalOptions = false;
136
+ this._passThroughOptions = false;
137
+ this._lifeCycleHooks = {};
138
+ this._showHelpAfterError = false;
139
+ this._showSuggestionAfterError = true;
140
+ this._savedState = null;
141
+ this._outputConfiguration = {
142
+ writeOut: (str)=>process.stdout.write(str),
143
+ writeErr: (str)=>process.stderr.write(str),
144
+ outputError: (str, write)=>write(str),
145
+ getOutHelpWidth: ()=>process.stdout.isTTY ? process.stdout.columns : void 0,
146
+ getErrHelpWidth: ()=>process.stderr.isTTY ? process.stderr.columns : void 0,
147
+ getOutHasColors: ()=>useColor() ?? (process.stdout.isTTY && process.stdout.hasColors?.()),
148
+ getErrHasColors: ()=>useColor() ?? (process.stderr.isTTY && process.stderr.hasColors?.()),
149
+ stripColor: (str)=>stripColor(str)
150
+ };
151
+ this._hidden = false;
152
+ this._helpOption = void 0;
153
+ this._addImplicitHelpCommand = void 0;
154
+ this._helpCommand = void 0;
155
+ this._helpConfiguration = {};
156
+ }
157
+ copyInheritedSettings(sourceCommand) {
158
+ this._outputConfiguration = sourceCommand._outputConfiguration;
159
+ this._helpOption = sourceCommand._helpOption;
160
+ this._helpCommand = sourceCommand._helpCommand;
161
+ this._helpConfiguration = sourceCommand._helpConfiguration;
162
+ this._exitCallback = sourceCommand._exitCallback;
163
+ this._storeOptionsAsProperties = sourceCommand._storeOptionsAsProperties;
164
+ this._combineFlagAndOptionalValue = sourceCommand._combineFlagAndOptionalValue;
165
+ this._allowExcessArguments = sourceCommand._allowExcessArguments;
166
+ this._enablePositionalOptions = sourceCommand._enablePositionalOptions;
167
+ this._showHelpAfterError = sourceCommand._showHelpAfterError;
168
+ this._showSuggestionAfterError = sourceCommand._showSuggestionAfterError;
169
+ return this;
170
+ }
171
+ _getCommandAndAncestors() {
172
+ const result = [];
173
+ for(let command = this; command; command = command.parent)result.push(command);
174
+ return result;
175
+ }
176
+ command(nameAndArgs, actionOptsOrExecDesc, execOpts) {
177
+ let desc = actionOptsOrExecDesc;
178
+ let opts = execOpts;
179
+ if ('object' == typeof desc && null !== desc) {
180
+ opts = desc;
181
+ desc = null;
182
+ }
183
+ opts = opts || {};
184
+ const [, name, args] = nameAndArgs.match(/([^ ]+) *(.*)/);
185
+ const cmd = this.createCommand(name);
186
+ if (desc) {
187
+ cmd.description(desc);
188
+ cmd._executableHandler = true;
189
+ }
190
+ if (opts.isDefault) this._defaultCommandName = cmd._name;
191
+ cmd._hidden = !!(opts.noHelp || opts.hidden);
192
+ cmd._executableFile = opts.executableFile || null;
193
+ if (args) cmd.arguments(args);
194
+ this._registerCommand(cmd);
195
+ cmd.parent = this;
196
+ cmd.copyInheritedSettings(this);
197
+ if (desc) return this;
198
+ return cmd;
199
+ }
200
+ createCommand(name) {
201
+ return new Command(name);
202
+ }
203
+ createHelp() {
204
+ return Object.assign(new Help(), this.configureHelp());
205
+ }
206
+ configureHelp(configuration) {
207
+ if (void 0 === configuration) return this._helpConfiguration;
208
+ this._helpConfiguration = configuration;
209
+ return this;
210
+ }
211
+ configureOutput(configuration) {
212
+ if (void 0 === configuration) return this._outputConfiguration;
213
+ Object.assign(this._outputConfiguration, configuration);
214
+ return this;
215
+ }
216
+ showHelpAfterError(displayHelp = true) {
217
+ if ('string' != typeof displayHelp) displayHelp = !!displayHelp;
218
+ this._showHelpAfterError = displayHelp;
219
+ return this;
220
+ }
221
+ showSuggestionAfterError(displaySuggestion = true) {
222
+ this._showSuggestionAfterError = !!displaySuggestion;
223
+ return this;
224
+ }
225
+ addCommand(cmd, opts) {
226
+ if (!cmd._name) throw new Error(`Command passed to .addCommand() must have a name
227
+ - specify the name in Command constructor or using .name()`);
228
+ opts = opts || {};
229
+ if (opts.isDefault) this._defaultCommandName = cmd._name;
230
+ if (opts.noHelp || opts.hidden) cmd._hidden = true;
231
+ this._registerCommand(cmd);
232
+ cmd.parent = this;
233
+ cmd._checkForBrokenPassThrough();
234
+ return this;
235
+ }
236
+ createArgument(name, description) {
237
+ return new Argument(name, description);
238
+ }
239
+ argument(name, description, fn, defaultValue) {
240
+ const argument = this.createArgument(name, description);
241
+ if ('function' == typeof fn) argument.default(defaultValue).argParser(fn);
242
+ else argument.default(fn);
243
+ this.addArgument(argument);
244
+ return this;
245
+ }
246
+ arguments(names) {
247
+ names.trim().split(/ +/).forEach((detail)=>{
248
+ this.argument(detail);
249
+ });
250
+ return this;
251
+ }
252
+ addArgument(argument) {
253
+ const previousArgument = this.registeredArguments.slice(-1)[0];
254
+ if (previousArgument && previousArgument.variadic) throw new Error(`only the last argument can be variadic '${previousArgument.name()}'`);
255
+ if (argument.required && void 0 !== argument.defaultValue && void 0 === argument.parseArg) throw new Error(`a default value for a required argument is never used: '${argument.name()}'`);
256
+ this.registeredArguments.push(argument);
257
+ return this;
258
+ }
259
+ helpCommand(enableOrNameAndArgs, description) {
260
+ if ('boolean' == typeof enableOrNameAndArgs) {
261
+ this._addImplicitHelpCommand = enableOrNameAndArgs;
262
+ return this;
263
+ }
264
+ enableOrNameAndArgs = enableOrNameAndArgs ?? 'help [command]';
265
+ const [, helpName, helpArgs] = enableOrNameAndArgs.match(/([^ ]+) *(.*)/);
266
+ const helpDescription = description ?? 'display help for command';
267
+ const helpCommand = this.createCommand(helpName);
268
+ helpCommand.helpOption(false);
269
+ if (helpArgs) helpCommand.arguments(helpArgs);
270
+ if (helpDescription) helpCommand.description(helpDescription);
271
+ this._addImplicitHelpCommand = true;
272
+ this._helpCommand = helpCommand;
273
+ return this;
274
+ }
275
+ addHelpCommand(helpCommand, deprecatedDescription) {
276
+ if ('object' != typeof helpCommand) {
277
+ this.helpCommand(helpCommand, deprecatedDescription);
278
+ return this;
279
+ }
280
+ this._addImplicitHelpCommand = true;
281
+ this._helpCommand = helpCommand;
282
+ return this;
283
+ }
284
+ _getHelpCommand() {
285
+ const hasImplicitHelpCommand = this._addImplicitHelpCommand ?? (this.commands.length && !this._actionHandler && !this._findCommand('help'));
286
+ if (hasImplicitHelpCommand) {
287
+ if (void 0 === this._helpCommand) this.helpCommand(void 0, void 0);
288
+ return this._helpCommand;
289
+ }
290
+ return null;
291
+ }
292
+ hook(event, listener) {
293
+ const allowedValues = [
294
+ 'preSubcommand',
295
+ 'preAction',
296
+ 'postAction'
297
+ ];
298
+ if (!allowedValues.includes(event)) throw new Error(`Unexpected value for event passed to hook : '${event}'.
299
+ Expecting one of '${allowedValues.join("', '")}'`);
300
+ if (this._lifeCycleHooks[event]) this._lifeCycleHooks[event].push(listener);
301
+ else this._lifeCycleHooks[event] = [
302
+ listener
303
+ ];
304
+ return this;
305
+ }
306
+ exitOverride(fn) {
307
+ if (fn) this._exitCallback = fn;
308
+ else this._exitCallback = (err)=>{
309
+ if ('commander.executeSubCommandAsync' !== err.code) throw err;
310
+ };
311
+ return this;
312
+ }
313
+ _exit(exitCode, code, message) {
314
+ if (this._exitCallback) this._exitCallback(new CommanderError(exitCode, code, message));
315
+ process.exit(exitCode);
316
+ }
317
+ action(fn) {
318
+ const listener = (args)=>{
319
+ const expectedArgsCount = this.registeredArguments.length;
320
+ const actionArgs = args.slice(0, expectedArgsCount);
321
+ if (this._storeOptionsAsProperties) actionArgs[expectedArgsCount] = this;
322
+ else actionArgs[expectedArgsCount] = this.opts();
323
+ actionArgs.push(this);
324
+ return fn.apply(this, actionArgs);
325
+ };
326
+ this._actionHandler = listener;
327
+ return this;
328
+ }
329
+ createOption(flags, description) {
330
+ return new Option(flags, description);
331
+ }
332
+ _callParseArg(target, value, previous, invalidArgumentMessage) {
333
+ try {
334
+ return target.parseArg(value, previous);
335
+ } catch (err) {
336
+ if ('commander.invalidArgument' === err.code) {
337
+ const message = `${invalidArgumentMessage} ${err.message}`;
338
+ this.error(message, {
339
+ exitCode: err.exitCode,
340
+ code: err.code
341
+ });
342
+ }
343
+ throw err;
344
+ }
345
+ }
346
+ _registerOption(option) {
347
+ const matchingOption = option.short && this._findOption(option.short) || option.long && this._findOption(option.long);
348
+ if (matchingOption) {
349
+ const matchingFlag = option.long && this._findOption(option.long) ? option.long : option.short;
350
+ throw new Error(`Cannot add option '${option.flags}'${this._name && ` to command '${this._name}'`} due to conflicting flag '${matchingFlag}'
351
+ - already used by option '${matchingOption.flags}'`);
352
+ }
353
+ this.options.push(option);
354
+ }
355
+ _registerCommand(command) {
356
+ const knownBy = (cmd)=>[
357
+ cmd.name()
358
+ ].concat(cmd.aliases());
359
+ const alreadyUsed = knownBy(command).find((name)=>this._findCommand(name));
360
+ if (alreadyUsed) {
361
+ const existingCmd = knownBy(this._findCommand(alreadyUsed)).join('|');
362
+ const newCmd = knownBy(command).join('|');
363
+ throw new Error(`cannot add command '${newCmd}' as already have command '${existingCmd}'`);
364
+ }
365
+ this.commands.push(command);
366
+ }
367
+ addOption(option) {
368
+ this._registerOption(option);
369
+ const oname = option.name();
370
+ const name = option.attributeName();
371
+ if (option.negate) {
372
+ const positiveLongFlag = option.long.replace(/^--no-/, '--');
373
+ if (!this._findOption(positiveLongFlag)) this.setOptionValueWithSource(name, void 0 === option.defaultValue ? true : option.defaultValue, 'default');
374
+ } else if (void 0 !== option.defaultValue) this.setOptionValueWithSource(name, option.defaultValue, 'default');
375
+ const handleOptionValue = (val, invalidValueMessage, valueSource)=>{
376
+ if (null == val && void 0 !== option.presetArg) val = option.presetArg;
377
+ const oldValue = this.getOptionValue(name);
378
+ if (null !== val && option.parseArg) val = this._callParseArg(option, val, oldValue, invalidValueMessage);
379
+ else if (null !== val && option.variadic) val = option._concatValue(val, oldValue);
380
+ if (null == val) val = option.negate ? false : option.isBoolean() || option.optional ? true : '';
381
+ this.setOptionValueWithSource(name, val, valueSource);
382
+ };
383
+ this.on('option:' + oname, (val)=>{
384
+ const invalidValueMessage = `error: option '${option.flags}' argument '${val}' is invalid.`;
385
+ handleOptionValue(val, invalidValueMessage, 'cli');
386
+ });
387
+ if (option.envVar) this.on('optionEnv:' + oname, (val)=>{
388
+ const invalidValueMessage = `error: option '${option.flags}' value '${val}' from env '${option.envVar}' is invalid.`;
389
+ handleOptionValue(val, invalidValueMessage, 'env');
390
+ });
391
+ return this;
392
+ }
393
+ _optionEx(config, flags, description, fn, defaultValue) {
394
+ if ('object' == typeof flags && flags instanceof Option) throw new Error('To add an Option object use addOption() instead of option() or requiredOption()');
395
+ const option = this.createOption(flags, description);
396
+ option.makeOptionMandatory(!!config.mandatory);
397
+ if ('function' == typeof fn) option.default(defaultValue).argParser(fn);
398
+ else if (fn instanceof RegExp) {
399
+ const regex = fn;
400
+ fn = (val, def)=>{
401
+ const m = regex.exec(val);
402
+ return m ? m[0] : def;
403
+ };
404
+ option.default(defaultValue).argParser(fn);
405
+ } else option.default(fn);
406
+ return this.addOption(option);
407
+ }
408
+ option(flags, description, parseArg, defaultValue) {
409
+ return this._optionEx({}, flags, description, parseArg, defaultValue);
410
+ }
411
+ requiredOption(flags, description, parseArg, defaultValue) {
412
+ return this._optionEx({
413
+ mandatory: true
414
+ }, flags, description, parseArg, defaultValue);
415
+ }
416
+ combineFlagAndOptionalValue(combine = true) {
417
+ this._combineFlagAndOptionalValue = !!combine;
418
+ return this;
419
+ }
420
+ allowUnknownOption(allowUnknown = true) {
421
+ this._allowUnknownOption = !!allowUnknown;
422
+ return this;
423
+ }
424
+ allowExcessArguments(allowExcess = true) {
425
+ this._allowExcessArguments = !!allowExcess;
426
+ return this;
427
+ }
428
+ enablePositionalOptions(positional = true) {
429
+ this._enablePositionalOptions = !!positional;
430
+ return this;
431
+ }
432
+ passThroughOptions(passThrough = true) {
433
+ this._passThroughOptions = !!passThrough;
434
+ this._checkForBrokenPassThrough();
435
+ return this;
436
+ }
437
+ _checkForBrokenPassThrough() {
438
+ if (this.parent && this._passThroughOptions && !this.parent._enablePositionalOptions) throw new Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`);
439
+ }
440
+ storeOptionsAsProperties(storeAsProperties = true) {
441
+ if (this.options.length) throw new Error('call .storeOptionsAsProperties() before adding options');
442
+ if (Object.keys(this._optionValues).length) throw new Error('call .storeOptionsAsProperties() before setting option values');
443
+ this._storeOptionsAsProperties = !!storeAsProperties;
444
+ return this;
445
+ }
446
+ getOptionValue(key) {
447
+ if (this._storeOptionsAsProperties) return this[key];
448
+ return this._optionValues[key];
449
+ }
450
+ setOptionValue(key, value) {
451
+ return this.setOptionValueWithSource(key, value, void 0);
452
+ }
453
+ setOptionValueWithSource(key, value, source) {
454
+ if (this._storeOptionsAsProperties) this[key] = value;
455
+ else this._optionValues[key] = value;
456
+ this._optionValueSources[key] = source;
457
+ return this;
458
+ }
459
+ getOptionValueSource(key) {
460
+ return this._optionValueSources[key];
461
+ }
462
+ getOptionValueSourceWithGlobals(key) {
463
+ let source;
464
+ this._getCommandAndAncestors().forEach((cmd)=>{
465
+ if (void 0 !== cmd.getOptionValueSource(key)) source = cmd.getOptionValueSource(key);
466
+ });
467
+ return source;
468
+ }
469
+ _prepareUserArgs(argv, parseOptions) {
470
+ if (void 0 !== argv && !Array.isArray(argv)) throw new Error('first parameter to parse must be array or undefined');
471
+ parseOptions = parseOptions || {};
472
+ if (void 0 === argv && void 0 === parseOptions.from) {
473
+ if (process.versions?.electron) parseOptions.from = 'electron';
474
+ const execArgv = process.execArgv ?? [];
475
+ if (execArgv.includes('-e') || execArgv.includes('--eval') || execArgv.includes('-p') || execArgv.includes('--print')) parseOptions.from = 'eval';
476
+ }
477
+ if (void 0 === argv) argv = process.argv;
478
+ this.rawArgs = argv.slice();
479
+ let userArgs;
480
+ switch(parseOptions.from){
481
+ case void 0:
482
+ case 'node':
483
+ this._scriptPath = argv[1];
484
+ userArgs = argv.slice(2);
485
+ break;
486
+ case 'electron':
487
+ if (process.defaultApp) {
488
+ this._scriptPath = argv[1];
489
+ userArgs = argv.slice(2);
490
+ } else userArgs = argv.slice(1);
491
+ break;
492
+ case 'user':
493
+ userArgs = argv.slice(0);
494
+ break;
495
+ case 'eval':
496
+ userArgs = argv.slice(1);
497
+ break;
498
+ default:
499
+ throw new Error(`unexpected parse option { from: '${parseOptions.from}' }`);
500
+ }
501
+ if (!this._name && this._scriptPath) this.nameFromFilename(this._scriptPath);
502
+ this._name = this._name || 'program';
503
+ return userArgs;
504
+ }
505
+ parse(argv, parseOptions) {
506
+ this._prepareForParse();
507
+ const userArgs = this._prepareUserArgs(argv, parseOptions);
508
+ this._parseCommand([], userArgs);
509
+ return this;
510
+ }
511
+ async parseAsync(argv, parseOptions) {
512
+ this._prepareForParse();
513
+ const userArgs = this._prepareUserArgs(argv, parseOptions);
514
+ await this._parseCommand([], userArgs);
515
+ return this;
516
+ }
517
+ _prepareForParse() {
518
+ if (null === this._savedState) this.saveStateBeforeParse();
519
+ else this.restoreStateBeforeParse();
520
+ }
521
+ saveStateBeforeParse() {
522
+ this._savedState = {
523
+ _name: this._name,
524
+ _optionValues: {
525
+ ...this._optionValues
526
+ },
527
+ _optionValueSources: {
528
+ ...this._optionValueSources
529
+ }
530
+ };
531
+ }
532
+ restoreStateBeforeParse() {
533
+ if (this._storeOptionsAsProperties) throw new Error(`Can not call parse again when storeOptionsAsProperties is true.
534
+ - either make a new Command for each call to parse, or stop storing options as properties`);
535
+ this._name = this._savedState._name;
536
+ this._scriptPath = null;
537
+ this.rawArgs = [];
538
+ this._optionValues = {
539
+ ...this._savedState._optionValues
540
+ };
541
+ this._optionValueSources = {
542
+ ...this._savedState._optionValueSources
543
+ };
544
+ this.args = [];
545
+ this.processedArgs = [];
546
+ }
547
+ _checkForMissingExecutable(executableFile, executableDir, subcommandName) {
548
+ if (fs.existsSync(executableFile)) return;
549
+ 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';
550
+ const executableMissing = `'${executableFile}' does not exist
551
+ - if '${subcommandName}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
552
+ - if the default executable name is not suitable, use the executableFile option to supply a custom name or path
553
+ - ${executableDirMessage}`;
554
+ throw new Error(executableMissing);
555
+ }
556
+ _executeSubCommand(subcommand, args) {
557
+ args = args.slice();
558
+ let launchWithNode = false;
559
+ const sourceExt = [
560
+ '.js',
561
+ '.ts',
562
+ '.tsx',
563
+ '.mjs',
564
+ '.cjs'
565
+ ];
566
+ function findFile(baseDir, baseName) {
567
+ const localBin = path.resolve(baseDir, baseName);
568
+ if (fs.existsSync(localBin)) return localBin;
569
+ if (sourceExt.includes(path.extname(baseName))) return;
570
+ const foundExt = sourceExt.find((ext)=>fs.existsSync(`${localBin}${ext}`));
571
+ if (foundExt) return `${localBin}${foundExt}`;
572
+ }
573
+ this._checkForMissingMandatoryOptions();
574
+ this._checkForConflictingOptions();
575
+ let executableFile = subcommand._executableFile || `${this._name}-${subcommand._name}`;
576
+ let executableDir = this._executableDir || '';
577
+ if (this._scriptPath) {
578
+ let resolvedScriptPath;
579
+ try {
580
+ resolvedScriptPath = fs.realpathSync(this._scriptPath);
581
+ } catch {
582
+ resolvedScriptPath = this._scriptPath;
583
+ }
584
+ executableDir = path.resolve(path.dirname(resolvedScriptPath), executableDir);
585
+ }
586
+ if (executableDir) {
587
+ let localFile = findFile(executableDir, executableFile);
588
+ if (!localFile && !subcommand._executableFile && this._scriptPath) {
589
+ const legacyName = path.basename(this._scriptPath, path.extname(this._scriptPath));
590
+ if (legacyName !== this._name) localFile = findFile(executableDir, `${legacyName}-${subcommand._name}`);
591
+ }
592
+ executableFile = localFile || executableFile;
593
+ }
594
+ launchWithNode = sourceExt.includes(path.extname(executableFile));
595
+ let proc;
596
+ if ('win32' !== process.platform) if (launchWithNode) {
597
+ args.unshift(executableFile);
598
+ args = incrementNodeInspectorPort(process.execArgv).concat(args);
599
+ proc = childProcess.spawn(process.argv[0], args, {
600
+ stdio: 'inherit'
601
+ });
602
+ } else proc = childProcess.spawn(executableFile, args, {
603
+ stdio: 'inherit'
604
+ });
605
+ else {
606
+ this._checkForMissingExecutable(executableFile, executableDir, subcommand._name);
607
+ args.unshift(executableFile);
608
+ args = incrementNodeInspectorPort(process.execArgv).concat(args);
609
+ proc = childProcess.spawn(process.execPath, args, {
610
+ stdio: 'inherit'
611
+ });
612
+ }
613
+ if (!proc.killed) {
614
+ const signals = [
615
+ 'SIGUSR1',
616
+ 'SIGUSR2',
617
+ 'SIGTERM',
618
+ 'SIGINT',
619
+ 'SIGHUP'
620
+ ];
621
+ signals.forEach((signal)=>{
622
+ process.on(signal, ()=>{
623
+ if (false === proc.killed && null === proc.exitCode) proc.kill(signal);
624
+ });
625
+ });
626
+ }
627
+ const exitCallback = this._exitCallback;
628
+ proc.on('close', (code)=>{
629
+ code = code ?? 1;
630
+ if (exitCallback) exitCallback(new CommanderError(code, 'commander.executeSubCommandAsync', '(close)'));
631
+ else process.exit(code);
632
+ });
633
+ proc.on('error', (err)=>{
634
+ if ('ENOENT' === err.code) this._checkForMissingExecutable(executableFile, executableDir, subcommand._name);
635
+ else if ('EACCES' === err.code) throw new Error(`'${executableFile}' not executable`);
636
+ if (exitCallback) {
637
+ const wrappedError = new CommanderError(1, 'commander.executeSubCommandAsync', '(error)');
638
+ wrappedError.nestedError = err;
639
+ exitCallback(wrappedError);
640
+ } else process.exit(1);
641
+ });
642
+ this.runningCommand = proc;
643
+ }
644
+ _dispatchSubcommand(commandName, operands, unknown) {
645
+ const subCommand = this._findCommand(commandName);
646
+ if (!subCommand) this.help({
647
+ error: true
648
+ });
649
+ subCommand._prepareForParse();
650
+ let promiseChain;
651
+ promiseChain = this._chainOrCallSubCommandHook(promiseChain, subCommand, 'preSubcommand');
652
+ promiseChain = this._chainOrCall(promiseChain, ()=>{
653
+ if (!subCommand._executableHandler) return subCommand._parseCommand(operands, unknown);
654
+ this._executeSubCommand(subCommand, operands.concat(unknown));
655
+ });
656
+ return promiseChain;
657
+ }
658
+ _dispatchHelpCommand(subcommandName) {
659
+ if (!subcommandName) this.help();
660
+ const subCommand = this._findCommand(subcommandName);
661
+ if (subCommand && !subCommand._executableHandler) subCommand.help();
662
+ return this._dispatchSubcommand(subcommandName, [], [
663
+ this._getHelpOption()?.long ?? this._getHelpOption()?.short ?? '--help'
664
+ ]);
665
+ }
666
+ _checkNumberOfArguments() {
667
+ this.registeredArguments.forEach((arg, i)=>{
668
+ if (arg.required && null == this.args[i]) this.missingArgument(arg.name());
669
+ });
670
+ if (this.registeredArguments.length > 0 && this.registeredArguments[this.registeredArguments.length - 1].variadic) return;
671
+ if (this.args.length > this.registeredArguments.length) this._excessArguments(this.args);
672
+ }
673
+ _processArguments() {
674
+ const myParseArg = (argument, value, previous)=>{
675
+ let parsedValue = value;
676
+ if (null !== value && argument.parseArg) {
677
+ const invalidValueMessage = `error: command-argument value '${value}' is invalid for argument '${argument.name()}'.`;
678
+ parsedValue = this._callParseArg(argument, value, previous, invalidValueMessage);
679
+ }
680
+ return parsedValue;
681
+ };
682
+ this._checkNumberOfArguments();
683
+ const processedArgs = [];
684
+ this.registeredArguments.forEach((declaredArg, index)=>{
685
+ let value = declaredArg.defaultValue;
686
+ if (declaredArg.variadic) {
687
+ if (index < this.args.length) {
688
+ value = this.args.slice(index);
689
+ if (declaredArg.parseArg) value = value.reduce((processed, v)=>myParseArg(declaredArg, v, processed), declaredArg.defaultValue);
690
+ } else if (void 0 === value) value = [];
691
+ } else if (index < this.args.length) {
692
+ value = this.args[index];
693
+ if (declaredArg.parseArg) value = myParseArg(declaredArg, value, declaredArg.defaultValue);
694
+ }
695
+ processedArgs[index] = value;
696
+ });
697
+ this.processedArgs = processedArgs;
698
+ }
699
+ _chainOrCall(promise, fn) {
700
+ if (promise && promise.then && 'function' == typeof promise.then) return promise.then(()=>fn());
701
+ return fn();
702
+ }
703
+ _chainOrCallHooks(promise, event) {
704
+ let result = promise;
705
+ const hooks = [];
706
+ this._getCommandAndAncestors().reverse().filter((cmd)=>void 0 !== cmd._lifeCycleHooks[event]).forEach((hookedCommand)=>{
707
+ hookedCommand._lifeCycleHooks[event].forEach((callback)=>{
708
+ hooks.push({
709
+ hookedCommand,
710
+ callback
711
+ });
712
+ });
713
+ });
714
+ if ('postAction' === event) hooks.reverse();
715
+ hooks.forEach((hookDetail)=>{
716
+ result = this._chainOrCall(result, ()=>hookDetail.callback(hookDetail.hookedCommand, this));
717
+ });
718
+ return result;
719
+ }
720
+ _chainOrCallSubCommandHook(promise, subCommand, event) {
721
+ let result = promise;
722
+ if (void 0 !== this._lifeCycleHooks[event]) this._lifeCycleHooks[event].forEach((hook)=>{
723
+ result = this._chainOrCall(result, ()=>hook(this, subCommand));
724
+ });
725
+ return result;
726
+ }
727
+ _parseCommand(operands, unknown) {
728
+ const parsed = this.parseOptions(unknown);
729
+ this._parseOptionsEnv();
730
+ this._parseOptionsImplied();
731
+ operands = operands.concat(parsed.operands);
732
+ unknown = parsed.unknown;
733
+ this.args = operands.concat(unknown);
734
+ if (operands && this._findCommand(operands[0])) return this._dispatchSubcommand(operands[0], operands.slice(1), unknown);
735
+ if (this._getHelpCommand() && operands[0] === this._getHelpCommand().name()) return this._dispatchHelpCommand(operands[1]);
736
+ if (this._defaultCommandName) {
737
+ this._outputHelpIfRequested(unknown);
738
+ return this._dispatchSubcommand(this._defaultCommandName, operands, unknown);
739
+ }
740
+ if (this.commands.length && 0 === this.args.length && !this._actionHandler && !this._defaultCommandName) this.help({
741
+ error: true
742
+ });
743
+ this._outputHelpIfRequested(parsed.unknown);
744
+ this._checkForMissingMandatoryOptions();
745
+ this._checkForConflictingOptions();
746
+ const checkForUnknownOptions = ()=>{
747
+ if (parsed.unknown.length > 0) this.unknownOption(parsed.unknown[0]);
748
+ };
749
+ const commandEvent = `command:${this.name()}`;
750
+ if (this._actionHandler) {
751
+ checkForUnknownOptions();
752
+ this._processArguments();
753
+ let promiseChain;
754
+ promiseChain = this._chainOrCallHooks(promiseChain, 'preAction');
755
+ promiseChain = this._chainOrCall(promiseChain, ()=>this._actionHandler(this.processedArgs));
756
+ if (this.parent) promiseChain = this._chainOrCall(promiseChain, ()=>{
757
+ this.parent.emit(commandEvent, operands, unknown);
758
+ });
759
+ promiseChain = this._chainOrCallHooks(promiseChain, 'postAction');
760
+ return promiseChain;
761
+ }
762
+ if (this.parent && this.parent.listenerCount(commandEvent)) {
763
+ checkForUnknownOptions();
764
+ this._processArguments();
765
+ this.parent.emit(commandEvent, operands, unknown);
766
+ } else if (operands.length) {
767
+ if (this._findCommand('*')) return this._dispatchSubcommand('*', operands, unknown);
768
+ if (this.listenerCount('command:*')) this.emit('command:*', operands, unknown);
769
+ else if (this.commands.length) this.unknownCommand();
770
+ else {
771
+ checkForUnknownOptions();
772
+ this._processArguments();
773
+ }
774
+ } else if (this.commands.length) {
775
+ checkForUnknownOptions();
776
+ this.help({
777
+ error: true
778
+ });
779
+ } else {
780
+ checkForUnknownOptions();
781
+ this._processArguments();
782
+ }
783
+ }
784
+ _findCommand(name) {
785
+ if (!name) return;
786
+ return this.commands.find((cmd)=>cmd._name === name || cmd._aliases.includes(name));
787
+ }
788
+ _findOption(arg) {
789
+ return this.options.find((option)=>option.is(arg));
790
+ }
791
+ _checkForMissingMandatoryOptions() {
792
+ this._getCommandAndAncestors().forEach((cmd)=>{
793
+ cmd.options.forEach((anOption)=>{
794
+ if (anOption.mandatory && void 0 === cmd.getOptionValue(anOption.attributeName())) cmd.missingMandatoryOptionValue(anOption);
795
+ });
796
+ });
797
+ }
798
+ _checkForConflictingLocalOptions() {
799
+ const definedNonDefaultOptions = this.options.filter((option)=>{
800
+ const optionKey = option.attributeName();
801
+ if (void 0 === this.getOptionValue(optionKey)) return false;
802
+ return 'default' !== this.getOptionValueSource(optionKey);
803
+ });
804
+ const optionsWithConflicting = definedNonDefaultOptions.filter((option)=>option.conflictsWith.length > 0);
805
+ optionsWithConflicting.forEach((option)=>{
806
+ const conflictingAndDefined = definedNonDefaultOptions.find((defined)=>option.conflictsWith.includes(defined.attributeName()));
807
+ if (conflictingAndDefined) this._conflictingOption(option, conflictingAndDefined);
808
+ });
809
+ }
810
+ _checkForConflictingOptions() {
811
+ this._getCommandAndAncestors().forEach((cmd)=>{
812
+ cmd._checkForConflictingLocalOptions();
813
+ });
814
+ }
815
+ parseOptions(argv) {
816
+ const operands = [];
817
+ const unknown = [];
818
+ let dest = operands;
819
+ const args = argv.slice();
820
+ function maybeOption(arg) {
821
+ return arg.length > 1 && '-' === arg[0];
822
+ }
823
+ let activeVariadicOption = null;
824
+ while(args.length){
825
+ const arg = args.shift();
826
+ if ('--' === arg) {
827
+ if (dest === unknown) dest.push(arg);
828
+ dest.push(...args);
829
+ break;
830
+ }
831
+ if (activeVariadicOption && !maybeOption(arg)) {
832
+ this.emit(`option:${activeVariadicOption.name()}`, arg);
833
+ continue;
834
+ }
835
+ activeVariadicOption = null;
836
+ if (maybeOption(arg)) {
837
+ const option = this._findOption(arg);
838
+ if (option) {
839
+ if (option.required) {
840
+ const value = args.shift();
841
+ if (void 0 === value) this.optionMissingArgument(option);
842
+ this.emit(`option:${option.name()}`, value);
843
+ } else if (option.optional) {
844
+ let value = null;
845
+ if (args.length > 0 && !maybeOption(args[0])) value = args.shift();
846
+ this.emit(`option:${option.name()}`, value);
847
+ } else this.emit(`option:${option.name()}`);
848
+ activeVariadicOption = option.variadic ? option : null;
849
+ continue;
850
+ }
851
+ }
852
+ if (arg.length > 2 && '-' === arg[0] && '-' !== arg[1]) {
853
+ const option = this._findOption(`-${arg[1]}`);
854
+ if (option) {
855
+ if (option.required || option.optional && this._combineFlagAndOptionalValue) this.emit(`option:${option.name()}`, arg.slice(2));
856
+ else {
857
+ this.emit(`option:${option.name()}`);
858
+ args.unshift(`-${arg.slice(2)}`);
859
+ }
860
+ continue;
861
+ }
862
+ }
863
+ if (/^--[^=]+=/.test(arg)) {
864
+ const index = arg.indexOf('=');
865
+ const option = this._findOption(arg.slice(0, index));
866
+ if (option && (option.required || option.optional)) {
867
+ this.emit(`option:${option.name()}`, arg.slice(index + 1));
868
+ continue;
869
+ }
870
+ }
871
+ if (maybeOption(arg)) dest = unknown;
872
+ if ((this._enablePositionalOptions || this._passThroughOptions) && 0 === operands.length && 0 === unknown.length) {
873
+ if (this._findCommand(arg)) {
874
+ operands.push(arg);
875
+ if (args.length > 0) unknown.push(...args);
876
+ break;
877
+ } else if (this._getHelpCommand() && arg === this._getHelpCommand().name()) {
878
+ operands.push(arg);
879
+ if (args.length > 0) operands.push(...args);
880
+ break;
881
+ } else if (this._defaultCommandName) {
882
+ unknown.push(arg);
883
+ if (args.length > 0) unknown.push(...args);
884
+ break;
885
+ }
886
+ }
887
+ if (this._passThroughOptions) {
888
+ dest.push(arg);
889
+ if (args.length > 0) dest.push(...args);
890
+ break;
891
+ }
892
+ dest.push(arg);
893
+ }
894
+ return {
895
+ operands,
896
+ unknown
897
+ };
898
+ }
899
+ opts() {
900
+ if (this._storeOptionsAsProperties) {
901
+ const result = {};
902
+ const len = this.options.length;
903
+ for(let i = 0; i < len; i++){
904
+ const key = this.options[i].attributeName();
905
+ result[key] = key === this._versionOptionName ? this._version : this[key];
906
+ }
907
+ return result;
908
+ }
909
+ return this._optionValues;
910
+ }
911
+ optsWithGlobals() {
912
+ return this._getCommandAndAncestors().reduce((combinedOptions, cmd)=>Object.assign(combinedOptions, cmd.opts()), {});
913
+ }
914
+ error(message, errorOptions) {
915
+ this._outputConfiguration.outputError(`${message}\n`, this._outputConfiguration.writeErr);
916
+ if ('string' == typeof this._showHelpAfterError) this._outputConfiguration.writeErr(`${this._showHelpAfterError}\n`);
917
+ else if (this._showHelpAfterError) {
918
+ this._outputConfiguration.writeErr('\n');
919
+ this.outputHelp({
920
+ error: true
921
+ });
922
+ }
923
+ const config = errorOptions || {};
924
+ const exitCode = config.exitCode || 1;
925
+ const code = config.code || 'commander.error';
926
+ this._exit(exitCode, code, message);
927
+ }
928
+ _parseOptionsEnv() {
929
+ this.options.forEach((option)=>{
930
+ if (option.envVar && option.envVar in process.env) {
931
+ const optionKey = option.attributeName();
932
+ if (void 0 === this.getOptionValue(optionKey) || [
933
+ 'default',
934
+ 'config',
935
+ 'env'
936
+ ].includes(this.getOptionValueSource(optionKey))) if (option.required || option.optional) this.emit(`optionEnv:${option.name()}`, process.env[option.envVar]);
937
+ else this.emit(`optionEnv:${option.name()}`);
938
+ }
939
+ });
940
+ }
941
+ _parseOptionsImplied() {
942
+ const dualHelper = new DualOptions(this.options);
943
+ const hasCustomOptionValue = (optionKey)=>void 0 !== this.getOptionValue(optionKey) && ![
944
+ 'default',
945
+ 'implied'
946
+ ].includes(this.getOptionValueSource(optionKey));
947
+ this.options.filter((option)=>void 0 !== option.implied && hasCustomOptionValue(option.attributeName()) && dualHelper.valueFromOption(this.getOptionValue(option.attributeName()), option)).forEach((option)=>{
948
+ Object.keys(option.implied).filter((impliedKey)=>!hasCustomOptionValue(impliedKey)).forEach((impliedKey)=>{
949
+ this.setOptionValueWithSource(impliedKey, option.implied[impliedKey], 'implied');
950
+ });
951
+ });
952
+ }
953
+ missingArgument(name) {
954
+ const message = `error: missing required argument '${name}'`;
955
+ this.error(message, {
956
+ code: 'commander.missingArgument'
957
+ });
958
+ }
959
+ optionMissingArgument(option) {
960
+ const message = `error: option '${option.flags}' argument missing`;
961
+ this.error(message, {
962
+ code: 'commander.optionMissingArgument'
963
+ });
964
+ }
965
+ missingMandatoryOptionValue(option) {
966
+ const message = `error: required option '${option.flags}' not specified`;
967
+ this.error(message, {
968
+ code: 'commander.missingMandatoryOptionValue'
969
+ });
970
+ }
971
+ _conflictingOption(option, conflictingOption) {
972
+ const findBestOptionFromValue = (option)=>{
973
+ const optionKey = option.attributeName();
974
+ const optionValue = this.getOptionValue(optionKey);
975
+ const negativeOption = this.options.find((target)=>target.negate && optionKey === target.attributeName());
976
+ const positiveOption = this.options.find((target)=>!target.negate && optionKey === target.attributeName());
977
+ if (negativeOption && (void 0 === negativeOption.presetArg && false === optionValue || void 0 !== negativeOption.presetArg && optionValue === negativeOption.presetArg)) return negativeOption;
978
+ return positiveOption || option;
979
+ };
980
+ const getErrorMessage = (option)=>{
981
+ const bestOption = findBestOptionFromValue(option);
982
+ const optionKey = bestOption.attributeName();
983
+ const source = this.getOptionValueSource(optionKey);
984
+ if ('env' === source) return `environment variable '${bestOption.envVar}'`;
985
+ return `option '${bestOption.flags}'`;
986
+ };
987
+ const message = `error: ${getErrorMessage(option)} cannot be used with ${getErrorMessage(conflictingOption)}`;
988
+ this.error(message, {
989
+ code: 'commander.conflictingOption'
990
+ });
991
+ }
992
+ unknownOption(flag) {
993
+ if (this._allowUnknownOption) return;
994
+ let suggestion = '';
995
+ if (flag.startsWith('--') && this._showSuggestionAfterError) {
996
+ let candidateFlags = [];
997
+ let command = this;
998
+ do {
999
+ const moreFlags = command.createHelp().visibleOptions(command).filter((option)=>option.long).map((option)=>option.long);
1000
+ candidateFlags = candidateFlags.concat(moreFlags);
1001
+ command = command.parent;
1002
+ }while (command && !command._enablePositionalOptions);
1003
+ suggestion = suggestSimilar(flag, candidateFlags);
1004
+ }
1005
+ const message = `error: unknown option '${flag}'${suggestion}`;
1006
+ this.error(message, {
1007
+ code: 'commander.unknownOption'
1008
+ });
1009
+ }
1010
+ _excessArguments(receivedArgs) {
1011
+ if (this._allowExcessArguments) return;
1012
+ const expected = this.registeredArguments.length;
1013
+ const s = 1 === expected ? '' : 's';
1014
+ const forSubcommand = this.parent ? ` for '${this.name()}'` : '';
1015
+ const message = `error: too many arguments${forSubcommand}. Expected ${expected} argument${s} but got ${receivedArgs.length}.`;
1016
+ this.error(message, {
1017
+ code: 'commander.excessArguments'
1018
+ });
1019
+ }
1020
+ unknownCommand() {
1021
+ const unknownName = this.args[0];
1022
+ let suggestion = '';
1023
+ if (this._showSuggestionAfterError) {
1024
+ const candidateNames = [];
1025
+ this.createHelp().visibleCommands(this).forEach((command)=>{
1026
+ candidateNames.push(command.name());
1027
+ if (command.alias()) candidateNames.push(command.alias());
1028
+ });
1029
+ suggestion = suggestSimilar(unknownName, candidateNames);
1030
+ }
1031
+ const message = `error: unknown command '${unknownName}'${suggestion}`;
1032
+ this.error(message, {
1033
+ code: 'commander.unknownCommand'
1034
+ });
1035
+ }
1036
+ version(str, flags, description) {
1037
+ if (void 0 === str) return this._version;
1038
+ this._version = str;
1039
+ flags = flags || '-V, --version';
1040
+ description = description || 'output the version number';
1041
+ const versionOption = this.createOption(flags, description);
1042
+ this._versionOptionName = versionOption.attributeName();
1043
+ this._registerOption(versionOption);
1044
+ this.on('option:' + versionOption.name(), ()=>{
1045
+ this._outputConfiguration.writeOut(`${str}\n`);
1046
+ this._exit(0, 'commander.version', str);
1047
+ });
1048
+ return this;
1049
+ }
1050
+ description(str, argsDescription) {
1051
+ if (void 0 === str && void 0 === argsDescription) return this._description;
1052
+ this._description = str;
1053
+ if (argsDescription) this._argsDescription = argsDescription;
1054
+ return this;
1055
+ }
1056
+ summary(str) {
1057
+ if (void 0 === str) return this._summary;
1058
+ this._summary = str;
1059
+ return this;
1060
+ }
1061
+ alias(alias) {
1062
+ if (void 0 === alias) return this._aliases[0];
1063
+ let command = this;
1064
+ if (0 !== this.commands.length && this.commands[this.commands.length - 1]._executableHandler) command = this.commands[this.commands.length - 1];
1065
+ if (alias === command._name) throw new Error("Command alias can't be the same as its name");
1066
+ const matchingCommand = this.parent?._findCommand(alias);
1067
+ if (matchingCommand) {
1068
+ const existingCmd = [
1069
+ matchingCommand.name()
1070
+ ].concat(matchingCommand.aliases()).join('|');
1071
+ throw new Error(`cannot add alias '${alias}' to command '${this.name()}' as already have command '${existingCmd}'`);
1072
+ }
1073
+ command._aliases.push(alias);
1074
+ return this;
1075
+ }
1076
+ aliases(aliases) {
1077
+ if (void 0 === aliases) return this._aliases;
1078
+ aliases.forEach((alias)=>this.alias(alias));
1079
+ return this;
1080
+ }
1081
+ usage(str) {
1082
+ if (void 0 === str) {
1083
+ if (this._usage) return this._usage;
1084
+ const args = this.registeredArguments.map((arg)=>humanReadableArgName(arg));
1085
+ return [].concat(this.options.length || null !== this._helpOption ? '[options]' : [], this.commands.length ? '[command]' : [], this.registeredArguments.length ? args : []).join(' ');
1086
+ }
1087
+ this._usage = str;
1088
+ return this;
1089
+ }
1090
+ name(str) {
1091
+ if (void 0 === str) return this._name;
1092
+ this._name = str;
1093
+ return this;
1094
+ }
1095
+ nameFromFilename(filename) {
1096
+ this._name = path.basename(filename, path.extname(filename));
1097
+ return this;
1098
+ }
1099
+ executableDir(path) {
1100
+ if (void 0 === path) return this._executableDir;
1101
+ this._executableDir = path;
1102
+ return this;
1103
+ }
1104
+ helpInformation(contextOptions) {
1105
+ const helper = this.createHelp();
1106
+ const context = this._getOutputContext(contextOptions);
1107
+ helper.prepareContext({
1108
+ error: context.error,
1109
+ helpWidth: context.helpWidth,
1110
+ outputHasColors: context.hasColors
1111
+ });
1112
+ const text = helper.formatHelp(this, helper);
1113
+ if (context.hasColors) return text;
1114
+ return this._outputConfiguration.stripColor(text);
1115
+ }
1116
+ _getOutputContext(contextOptions) {
1117
+ contextOptions = contextOptions || {};
1118
+ const error = !!contextOptions.error;
1119
+ let baseWrite;
1120
+ let hasColors;
1121
+ let helpWidth;
1122
+ if (error) {
1123
+ baseWrite = (str)=>this._outputConfiguration.writeErr(str);
1124
+ hasColors = this._outputConfiguration.getErrHasColors();
1125
+ helpWidth = this._outputConfiguration.getErrHelpWidth();
1126
+ } else {
1127
+ baseWrite = (str)=>this._outputConfiguration.writeOut(str);
1128
+ hasColors = this._outputConfiguration.getOutHasColors();
1129
+ helpWidth = this._outputConfiguration.getOutHelpWidth();
1130
+ }
1131
+ const write = (str)=>{
1132
+ if (!hasColors) str = this._outputConfiguration.stripColor(str);
1133
+ return baseWrite(str);
1134
+ };
1135
+ return {
1136
+ error,
1137
+ write,
1138
+ hasColors,
1139
+ helpWidth
1140
+ };
1141
+ }
1142
+ outputHelp(contextOptions) {
1143
+ let deprecatedCallback;
1144
+ if ('function' == typeof contextOptions) {
1145
+ deprecatedCallback = contextOptions;
1146
+ contextOptions = void 0;
1147
+ }
1148
+ const outputContext = this._getOutputContext(contextOptions);
1149
+ const eventContext = {
1150
+ error: outputContext.error,
1151
+ write: outputContext.write,
1152
+ command: this
1153
+ };
1154
+ this._getCommandAndAncestors().reverse().forEach((command)=>command.emit('beforeAllHelp', eventContext));
1155
+ this.emit('beforeHelp', eventContext);
1156
+ let helpInformation = this.helpInformation({
1157
+ error: outputContext.error
1158
+ });
1159
+ if (deprecatedCallback) {
1160
+ helpInformation = deprecatedCallback(helpInformation);
1161
+ if ('string' != typeof helpInformation && !Buffer.isBuffer(helpInformation)) throw new Error('outputHelp callback must return a string or a Buffer');
1162
+ }
1163
+ outputContext.write(helpInformation);
1164
+ if (this._getHelpOption()?.long) this.emit(this._getHelpOption().long);
1165
+ this.emit('afterHelp', eventContext);
1166
+ this._getCommandAndAncestors().forEach((command)=>command.emit('afterAllHelp', eventContext));
1167
+ }
1168
+ helpOption(flags, description) {
1169
+ if ('boolean' == typeof flags) {
1170
+ if (flags) this._helpOption = this._helpOption ?? void 0;
1171
+ else this._helpOption = null;
1172
+ return this;
1173
+ }
1174
+ flags = flags ?? '-h, --help';
1175
+ description = description ?? 'display help for command';
1176
+ this._helpOption = this.createOption(flags, description);
1177
+ return this;
1178
+ }
1179
+ _getHelpOption() {
1180
+ if (void 0 === this._helpOption) this.helpOption(void 0, void 0);
1181
+ return this._helpOption;
1182
+ }
1183
+ addHelpOption(option) {
1184
+ this._helpOption = option;
1185
+ return this;
1186
+ }
1187
+ help(contextOptions) {
1188
+ this.outputHelp(contextOptions);
1189
+ let exitCode = Number(process.exitCode ?? 0);
1190
+ if (0 === exitCode && contextOptions && 'function' != typeof contextOptions && contextOptions.error) exitCode = 1;
1191
+ this._exit(exitCode, 'commander.help', '(outputHelp)');
1192
+ }
1193
+ addHelpText(position, text) {
1194
+ const allowedValues = [
1195
+ 'beforeAll',
1196
+ 'before',
1197
+ 'after',
1198
+ 'afterAll'
1199
+ ];
1200
+ if (!allowedValues.includes(position)) throw new Error(`Unexpected value for position to addHelpText.
1201
+ Expecting one of '${allowedValues.join("', '")}'`);
1202
+ const helpEvent = `${position}Help`;
1203
+ this.on(helpEvent, (context)=>{
1204
+ let helpStr;
1205
+ helpStr = 'function' == typeof text ? text({
1206
+ error: context.error,
1207
+ command: context.command
1208
+ }) : text;
1209
+ if (helpStr) context.write(`${helpStr}\n`);
1210
+ });
1211
+ return this;
1212
+ }
1213
+ _outputHelpIfRequested(args) {
1214
+ const helpOption = this._getHelpOption();
1215
+ const helpRequested = helpOption && args.find((arg)=>helpOption.is(arg));
1216
+ if (helpRequested) {
1217
+ this.outputHelp();
1218
+ this._exit(0, 'commander.helpDisplayed', '(outputHelp)');
1219
+ }
1220
+ }
1221
+ }
1222
+ function incrementNodeInspectorPort(args) {
1223
+ return args.map((arg)=>{
1224
+ if (!arg.startsWith('--inspect')) return arg;
1225
+ let debugOption;
1226
+ let debugHost = '127.0.0.1';
1227
+ let debugPort = '9229';
1228
+ let match;
1229
+ if (null !== (match = arg.match(/^(--inspect(-brk)?)$/))) debugOption = match[1];
1230
+ else if (null !== (match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))) {
1231
+ debugOption = match[1];
1232
+ if (/^\d+$/.test(match[3])) debugPort = match[3];
1233
+ else debugHost = match[3];
1234
+ } else if (null !== (match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))) {
1235
+ debugOption = match[1];
1236
+ debugHost = match[3];
1237
+ debugPort = match[4];
1238
+ }
1239
+ if (debugOption && '0' !== debugPort) return `${debugOption}=${debugHost}:${parseInt(debugPort) + 1}`;
1240
+ return arg;
1241
+ });
1242
+ }
1243
+ function useColor() {
1244
+ if (process.env.NO_COLOR || '0' === process.env.FORCE_COLOR || 'false' === process.env.FORCE_COLOR) return false;
1245
+ if (process.env.FORCE_COLOR || void 0 !== process.env.CLICOLOR_FORCE) return true;
1246
+ }
1247
+ exports.Command = Command;
1248
+ exports.useColor = useColor;
1249
+ },
1250
+ "../../../node_modules/.pnpm/commander@13.1.0/node_modules/commander/lib/error.js": function(__unused_webpack_module, exports) {
1251
+ class CommanderError extends Error {
1252
+ constructor(exitCode, code, message){
1253
+ super(message);
1254
+ Error.captureStackTrace(this, this.constructor);
1255
+ this.name = this.constructor.name;
1256
+ this.code = code;
1257
+ this.exitCode = exitCode;
1258
+ this.nestedError = void 0;
1259
+ }
1260
+ }
1261
+ class InvalidArgumentError extends CommanderError {
1262
+ constructor(message){
1263
+ super(1, 'commander.invalidArgument', message);
1264
+ Error.captureStackTrace(this, this.constructor);
1265
+ this.name = this.constructor.name;
1266
+ }
1267
+ }
1268
+ exports.CommanderError = CommanderError;
1269
+ exports.InvalidArgumentError = InvalidArgumentError;
1270
+ },
1271
+ "../../../node_modules/.pnpm/commander@13.1.0/node_modules/commander/lib/help.js": function(__unused_webpack_module, exports, __webpack_require__) {
1272
+ const { humanReadableArgName } = __webpack_require__("../../../node_modules/.pnpm/commander@13.1.0/node_modules/commander/lib/argument.js");
1273
+ class Help {
1274
+ constructor(){
1275
+ this.helpWidth = void 0;
1276
+ this.minWidthToWrap = 40;
1277
+ this.sortSubcommands = false;
1278
+ this.sortOptions = false;
1279
+ this.showGlobalOptions = false;
1280
+ }
1281
+ prepareContext(contextOptions) {
1282
+ this.helpWidth = this.helpWidth ?? contextOptions.helpWidth ?? 80;
1283
+ }
1284
+ visibleCommands(cmd) {
1285
+ const visibleCommands = cmd.commands.filter((cmd)=>!cmd._hidden);
1286
+ const helpCommand = cmd._getHelpCommand();
1287
+ if (helpCommand && !helpCommand._hidden) visibleCommands.push(helpCommand);
1288
+ if (this.sortSubcommands) visibleCommands.sort((a, b)=>a.name().localeCompare(b.name()));
1289
+ return visibleCommands;
1290
+ }
1291
+ compareOptions(a, b) {
1292
+ const getSortKey = (option)=>option.short ? option.short.replace(/^-/, '') : option.long.replace(/^--/, '');
1293
+ return getSortKey(a).localeCompare(getSortKey(b));
1294
+ }
1295
+ visibleOptions(cmd) {
1296
+ const visibleOptions = cmd.options.filter((option)=>!option.hidden);
1297
+ const helpOption = cmd._getHelpOption();
1298
+ if (helpOption && !helpOption.hidden) {
1299
+ const removeShort = helpOption.short && cmd._findOption(helpOption.short);
1300
+ const removeLong = helpOption.long && cmd._findOption(helpOption.long);
1301
+ if (removeShort || removeLong) {
1302
+ if (helpOption.long && !removeLong) visibleOptions.push(cmd.createOption(helpOption.long, helpOption.description));
1303
+ else if (helpOption.short && !removeShort) visibleOptions.push(cmd.createOption(helpOption.short, helpOption.description));
1304
+ } else visibleOptions.push(helpOption);
1305
+ }
1306
+ if (this.sortOptions) visibleOptions.sort(this.compareOptions);
1307
+ return visibleOptions;
1308
+ }
1309
+ visibleGlobalOptions(cmd) {
1310
+ if (!this.showGlobalOptions) return [];
1311
+ const globalOptions = [];
1312
+ for(let ancestorCmd = cmd.parent; ancestorCmd; ancestorCmd = ancestorCmd.parent){
1313
+ const visibleOptions = ancestorCmd.options.filter((option)=>!option.hidden);
1314
+ globalOptions.push(...visibleOptions);
1315
+ }
1316
+ if (this.sortOptions) globalOptions.sort(this.compareOptions);
1317
+ return globalOptions;
1318
+ }
1319
+ visibleArguments(cmd) {
1320
+ if (cmd._argsDescription) cmd.registeredArguments.forEach((argument)=>{
1321
+ argument.description = argument.description || cmd._argsDescription[argument.name()] || '';
1322
+ });
1323
+ if (cmd.registeredArguments.find((argument)=>argument.description)) return cmd.registeredArguments;
1324
+ return [];
1325
+ }
1326
+ subcommandTerm(cmd) {
1327
+ const args = cmd.registeredArguments.map((arg)=>humanReadableArgName(arg)).join(' ');
1328
+ return cmd._name + (cmd._aliases[0] ? '|' + cmd._aliases[0] : '') + (cmd.options.length ? ' [options]' : '') + (args ? ' ' + args : '');
1329
+ }
1330
+ optionTerm(option) {
1331
+ return option.flags;
1332
+ }
1333
+ argumentTerm(argument) {
1334
+ return argument.name();
1335
+ }
1336
+ longestSubcommandTermLength(cmd, helper) {
1337
+ return helper.visibleCommands(cmd).reduce((max, command)=>Math.max(max, this.displayWidth(helper.styleSubcommandTerm(helper.subcommandTerm(command)))), 0);
1338
+ }
1339
+ longestOptionTermLength(cmd, helper) {
1340
+ return helper.visibleOptions(cmd).reduce((max, option)=>Math.max(max, this.displayWidth(helper.styleOptionTerm(helper.optionTerm(option)))), 0);
1341
+ }
1342
+ longestGlobalOptionTermLength(cmd, helper) {
1343
+ return helper.visibleGlobalOptions(cmd).reduce((max, option)=>Math.max(max, this.displayWidth(helper.styleOptionTerm(helper.optionTerm(option)))), 0);
1344
+ }
1345
+ longestArgumentTermLength(cmd, helper) {
1346
+ return helper.visibleArguments(cmd).reduce((max, argument)=>Math.max(max, this.displayWidth(helper.styleArgumentTerm(helper.argumentTerm(argument)))), 0);
1347
+ }
1348
+ commandUsage(cmd) {
1349
+ let cmdName = cmd._name;
1350
+ if (cmd._aliases[0]) cmdName = cmdName + '|' + cmd._aliases[0];
1351
+ let ancestorCmdNames = '';
1352
+ for(let ancestorCmd = cmd.parent; ancestorCmd; ancestorCmd = ancestorCmd.parent)ancestorCmdNames = ancestorCmd.name() + ' ' + ancestorCmdNames;
1353
+ return ancestorCmdNames + cmdName + ' ' + cmd.usage();
1354
+ }
1355
+ commandDescription(cmd) {
1356
+ return cmd.description();
1357
+ }
1358
+ subcommandDescription(cmd) {
1359
+ return cmd.summary() || cmd.description();
1360
+ }
1361
+ optionDescription(option) {
1362
+ const extraInfo = [];
1363
+ if (option.argChoices) extraInfo.push(`choices: ${option.argChoices.map((choice)=>JSON.stringify(choice)).join(', ')}`);
1364
+ if (void 0 !== option.defaultValue) {
1365
+ const showDefault = option.required || option.optional || option.isBoolean() && 'boolean' == typeof option.defaultValue;
1366
+ if (showDefault) extraInfo.push(`default: ${option.defaultValueDescription || JSON.stringify(option.defaultValue)}`);
1367
+ }
1368
+ if (void 0 !== option.presetArg && option.optional) extraInfo.push(`preset: ${JSON.stringify(option.presetArg)}`);
1369
+ if (void 0 !== option.envVar) extraInfo.push(`env: ${option.envVar}`);
1370
+ if (extraInfo.length > 0) return `${option.description} (${extraInfo.join(', ')})`;
1371
+ return option.description;
1372
+ }
1373
+ argumentDescription(argument) {
1374
+ const extraInfo = [];
1375
+ if (argument.argChoices) extraInfo.push(`choices: ${argument.argChoices.map((choice)=>JSON.stringify(choice)).join(', ')}`);
1376
+ if (void 0 !== argument.defaultValue) extraInfo.push(`default: ${argument.defaultValueDescription || JSON.stringify(argument.defaultValue)}`);
1377
+ if (extraInfo.length > 0) {
1378
+ const extraDescription = `(${extraInfo.join(', ')})`;
1379
+ if (argument.description) return `${argument.description} ${extraDescription}`;
1380
+ return extraDescription;
1381
+ }
1382
+ return argument.description;
1383
+ }
1384
+ formatHelp(cmd, helper) {
1385
+ const termWidth = helper.padWidth(cmd, helper);
1386
+ const helpWidth = helper.helpWidth ?? 80;
1387
+ function callFormatItem(term, description) {
1388
+ return helper.formatItem(term, termWidth, description, helper);
1389
+ }
1390
+ let output = [
1391
+ `${helper.styleTitle('Usage:')} ${helper.styleUsage(helper.commandUsage(cmd))}`,
1392
+ ''
1393
+ ];
1394
+ const commandDescription = helper.commandDescription(cmd);
1395
+ if (commandDescription.length > 0) output = output.concat([
1396
+ helper.boxWrap(helper.styleCommandDescription(commandDescription), helpWidth),
1397
+ ''
1398
+ ]);
1399
+ const argumentList = helper.visibleArguments(cmd).map((argument)=>callFormatItem(helper.styleArgumentTerm(helper.argumentTerm(argument)), helper.styleArgumentDescription(helper.argumentDescription(argument))));
1400
+ if (argumentList.length > 0) output = output.concat([
1401
+ helper.styleTitle('Arguments:'),
1402
+ ...argumentList,
1403
+ ''
1404
+ ]);
1405
+ const optionList = helper.visibleOptions(cmd).map((option)=>callFormatItem(helper.styleOptionTerm(helper.optionTerm(option)), helper.styleOptionDescription(helper.optionDescription(option))));
1406
+ if (optionList.length > 0) output = output.concat([
1407
+ helper.styleTitle('Options:'),
1408
+ ...optionList,
1409
+ ''
1410
+ ]);
1411
+ if (helper.showGlobalOptions) {
1412
+ const globalOptionList = helper.visibleGlobalOptions(cmd).map((option)=>callFormatItem(helper.styleOptionTerm(helper.optionTerm(option)), helper.styleOptionDescription(helper.optionDescription(option))));
1413
+ if (globalOptionList.length > 0) output = output.concat([
1414
+ helper.styleTitle('Global Options:'),
1415
+ ...globalOptionList,
1416
+ ''
1417
+ ]);
1418
+ }
1419
+ const commandList = helper.visibleCommands(cmd).map((cmd)=>callFormatItem(helper.styleSubcommandTerm(helper.subcommandTerm(cmd)), helper.styleSubcommandDescription(helper.subcommandDescription(cmd))));
1420
+ if (commandList.length > 0) output = output.concat([
1421
+ helper.styleTitle('Commands:'),
1422
+ ...commandList,
1423
+ ''
1424
+ ]);
1425
+ return output.join('\n');
1426
+ }
1427
+ displayWidth(str) {
1428
+ return stripColor(str).length;
1429
+ }
1430
+ styleTitle(str) {
1431
+ return str;
1432
+ }
1433
+ styleUsage(str) {
1434
+ return str.split(' ').map((word)=>{
1435
+ if ('[options]' === word) return this.styleOptionText(word);
1436
+ if ('[command]' === word) return this.styleSubcommandText(word);
1437
+ if ('[' === word[0] || '<' === word[0]) return this.styleArgumentText(word);
1438
+ return this.styleCommandText(word);
1439
+ }).join(' ');
1440
+ }
1441
+ styleCommandDescription(str) {
1442
+ return this.styleDescriptionText(str);
1443
+ }
1444
+ styleOptionDescription(str) {
1445
+ return this.styleDescriptionText(str);
1446
+ }
1447
+ styleSubcommandDescription(str) {
1448
+ return this.styleDescriptionText(str);
1449
+ }
1450
+ styleArgumentDescription(str) {
1451
+ return this.styleDescriptionText(str);
1452
+ }
1453
+ styleDescriptionText(str) {
1454
+ return str;
1455
+ }
1456
+ styleOptionTerm(str) {
1457
+ return this.styleOptionText(str);
1458
+ }
1459
+ styleSubcommandTerm(str) {
1460
+ return str.split(' ').map((word)=>{
1461
+ if ('[options]' === word) return this.styleOptionText(word);
1462
+ if ('[' === word[0] || '<' === word[0]) return this.styleArgumentText(word);
1463
+ return this.styleSubcommandText(word);
1464
+ }).join(' ');
1465
+ }
1466
+ styleArgumentTerm(str) {
1467
+ return this.styleArgumentText(str);
1468
+ }
1469
+ styleOptionText(str) {
1470
+ return str;
1471
+ }
1472
+ styleArgumentText(str) {
1473
+ return str;
1474
+ }
1475
+ styleSubcommandText(str) {
1476
+ return str;
1477
+ }
1478
+ styleCommandText(str) {
1479
+ return str;
1480
+ }
1481
+ padWidth(cmd, helper) {
1482
+ return Math.max(helper.longestOptionTermLength(cmd, helper), helper.longestGlobalOptionTermLength(cmd, helper), helper.longestSubcommandTermLength(cmd, helper), helper.longestArgumentTermLength(cmd, helper));
1483
+ }
1484
+ preformatted(str) {
1485
+ return /\n[^\S\r\n]/.test(str);
1486
+ }
1487
+ formatItem(term, termWidth, description, helper) {
1488
+ const itemIndent = 2;
1489
+ const itemIndentStr = ' '.repeat(itemIndent);
1490
+ if (!description) return itemIndentStr + term;
1491
+ const paddedTerm = term.padEnd(termWidth + term.length - helper.displayWidth(term));
1492
+ const spacerWidth = 2;
1493
+ const helpWidth = this.helpWidth ?? 80;
1494
+ const remainingWidth = helpWidth - termWidth - spacerWidth - itemIndent;
1495
+ let formattedDescription;
1496
+ if (remainingWidth < this.minWidthToWrap || helper.preformatted(description)) formattedDescription = description;
1497
+ else {
1498
+ const wrappedDescription = helper.boxWrap(description, remainingWidth);
1499
+ formattedDescription = wrappedDescription.replace(/\n/g, '\n' + ' '.repeat(termWidth + spacerWidth));
1500
+ }
1501
+ return itemIndentStr + paddedTerm + ' '.repeat(spacerWidth) + formattedDescription.replace(/\n/g, `\n${itemIndentStr}`);
1502
+ }
1503
+ boxWrap(str, width) {
1504
+ if (width < this.minWidthToWrap) return str;
1505
+ const rawLines = str.split(/\r\n|\n/);
1506
+ const chunkPattern = /[\s]*[^\s]+/g;
1507
+ const wrappedLines = [];
1508
+ rawLines.forEach((line)=>{
1509
+ const chunks = line.match(chunkPattern);
1510
+ if (null === chunks) return void wrappedLines.push('');
1511
+ let sumChunks = [
1512
+ chunks.shift()
1513
+ ];
1514
+ let sumWidth = this.displayWidth(sumChunks[0]);
1515
+ chunks.forEach((chunk)=>{
1516
+ const visibleWidth = this.displayWidth(chunk);
1517
+ if (sumWidth + visibleWidth <= width) {
1518
+ sumChunks.push(chunk);
1519
+ sumWidth += visibleWidth;
1520
+ return;
1521
+ }
1522
+ wrappedLines.push(sumChunks.join(''));
1523
+ const nextChunk = chunk.trimStart();
1524
+ sumChunks = [
1525
+ nextChunk
1526
+ ];
1527
+ sumWidth = this.displayWidth(nextChunk);
1528
+ });
1529
+ wrappedLines.push(sumChunks.join(''));
1530
+ });
1531
+ return wrappedLines.join('\n');
1532
+ }
1533
+ }
1534
+ function stripColor(str) {
1535
+ const sgrPattern = /\x1b\[\d*(;\d*)*m/g;
1536
+ return str.replace(sgrPattern, '');
1537
+ }
1538
+ exports.Help = Help;
1539
+ exports.stripColor = stripColor;
1540
+ },
1541
+ "../../../node_modules/.pnpm/commander@13.1.0/node_modules/commander/lib/option.js": function(__unused_webpack_module, exports, __webpack_require__) {
1542
+ const { InvalidArgumentError } = __webpack_require__("../../../node_modules/.pnpm/commander@13.1.0/node_modules/commander/lib/error.js");
1543
+ class Option {
1544
+ constructor(flags, description){
1545
+ this.flags = flags;
1546
+ this.description = description || '';
1547
+ this.required = flags.includes('<');
1548
+ this.optional = flags.includes('[');
1549
+ this.variadic = /\w\.\.\.[>\]]$/.test(flags);
1550
+ this.mandatory = false;
1551
+ const optionFlags = splitOptionFlags(flags);
1552
+ this.short = optionFlags.shortFlag;
1553
+ this.long = optionFlags.longFlag;
1554
+ this.negate = false;
1555
+ if (this.long) this.negate = this.long.startsWith('--no-');
1556
+ this.defaultValue = void 0;
1557
+ this.defaultValueDescription = void 0;
1558
+ this.presetArg = void 0;
1559
+ this.envVar = void 0;
1560
+ this.parseArg = void 0;
1561
+ this.hidden = false;
1562
+ this.argChoices = void 0;
1563
+ this.conflictsWith = [];
1564
+ this.implied = void 0;
1565
+ }
1566
+ default(value, description) {
1567
+ this.defaultValue = value;
1568
+ this.defaultValueDescription = description;
1569
+ return this;
1570
+ }
1571
+ preset(arg) {
1572
+ this.presetArg = arg;
1573
+ return this;
1574
+ }
1575
+ conflicts(names) {
1576
+ this.conflictsWith = this.conflictsWith.concat(names);
1577
+ return this;
1578
+ }
1579
+ implies(impliedOptionValues) {
1580
+ let newImplied = impliedOptionValues;
1581
+ if ('string' == typeof impliedOptionValues) newImplied = {
1582
+ [impliedOptionValues]: true
1583
+ };
1584
+ this.implied = Object.assign(this.implied || {}, newImplied);
1585
+ return this;
1586
+ }
1587
+ env(name) {
1588
+ this.envVar = name;
1589
+ return this;
1590
+ }
1591
+ argParser(fn) {
1592
+ this.parseArg = fn;
1593
+ return this;
1594
+ }
1595
+ makeOptionMandatory(mandatory = true) {
1596
+ this.mandatory = !!mandatory;
1597
+ return this;
1598
+ }
1599
+ hideHelp(hide = true) {
1600
+ this.hidden = !!hide;
1601
+ return this;
1602
+ }
1603
+ _concatValue(value, previous) {
1604
+ if (previous === this.defaultValue || !Array.isArray(previous)) return [
1605
+ value
1606
+ ];
1607
+ return previous.concat(value);
1608
+ }
1609
+ choices(values) {
1610
+ this.argChoices = values.slice();
1611
+ this.parseArg = (arg, previous)=>{
1612
+ if (!this.argChoices.includes(arg)) throw new InvalidArgumentError(`Allowed choices are ${this.argChoices.join(', ')}.`);
1613
+ if (this.variadic) return this._concatValue(arg, previous);
1614
+ return arg;
1615
+ };
1616
+ return this;
1617
+ }
1618
+ name() {
1619
+ if (this.long) return this.long.replace(/^--/, '');
1620
+ return this.short.replace(/^-/, '');
1621
+ }
1622
+ attributeName() {
1623
+ if (this.negate) return camelcase(this.name().replace(/^no-/, ''));
1624
+ return camelcase(this.name());
1625
+ }
1626
+ is(arg) {
1627
+ return this.short === arg || this.long === arg;
1628
+ }
1629
+ isBoolean() {
1630
+ return !this.required && !this.optional && !this.negate;
1631
+ }
1632
+ }
1633
+ class DualOptions {
1634
+ constructor(options){
1635
+ this.positiveOptions = new Map();
1636
+ this.negativeOptions = new Map();
1637
+ this.dualOptions = new Set();
1638
+ options.forEach((option)=>{
1639
+ if (option.negate) this.negativeOptions.set(option.attributeName(), option);
1640
+ else this.positiveOptions.set(option.attributeName(), option);
1641
+ });
1642
+ this.negativeOptions.forEach((value, key)=>{
1643
+ if (this.positiveOptions.has(key)) this.dualOptions.add(key);
1644
+ });
1645
+ }
1646
+ valueFromOption(value, option) {
1647
+ const optionKey = option.attributeName();
1648
+ if (!this.dualOptions.has(optionKey)) return true;
1649
+ const preset = this.negativeOptions.get(optionKey).presetArg;
1650
+ const negativeValue = void 0 !== preset ? preset : false;
1651
+ return option.negate === (negativeValue === value);
1652
+ }
1653
+ }
1654
+ function camelcase(str) {
1655
+ return str.split('-').reduce((str, word)=>str + word[0].toUpperCase() + word.slice(1));
1656
+ }
1657
+ function splitOptionFlags(flags) {
1658
+ let shortFlag;
1659
+ let longFlag;
1660
+ const shortFlagExp = /^-[^-]$/;
1661
+ const longFlagExp = /^--[^-]/;
1662
+ const flagParts = flags.split(/[ |,]+/).concat('guard');
1663
+ if (shortFlagExp.test(flagParts[0])) shortFlag = flagParts.shift();
1664
+ if (longFlagExp.test(flagParts[0])) longFlag = flagParts.shift();
1665
+ if (!shortFlag && shortFlagExp.test(flagParts[0])) shortFlag = flagParts.shift();
1666
+ if (!shortFlag && longFlagExp.test(flagParts[0])) {
1667
+ shortFlag = longFlag;
1668
+ longFlag = flagParts.shift();
1669
+ }
1670
+ if (flagParts[0].startsWith('-')) {
1671
+ const unsupportedFlag = flagParts[0];
1672
+ const baseError = `option creation failed due to '${unsupportedFlag}' in option flags '${flags}'`;
1673
+ if (/^-[^-][^-]/.test(unsupportedFlag)) throw new Error(`${baseError}
1674
+ - a short flag is a single dash and a single character
1675
+ - either use a single dash and a single character (for a short flag)
1676
+ - or use a double dash for a long option (and can have two, like '--ws, --workspace')`);
1677
+ if (shortFlagExp.test(unsupportedFlag)) throw new Error(`${baseError}
1678
+ - too many short flags`);
1679
+ if (longFlagExp.test(unsupportedFlag)) throw new Error(`${baseError}
1680
+ - too many long flags`);
1681
+ throw new Error(`${baseError}
1682
+ - unrecognised flag format`);
1683
+ }
1684
+ if (void 0 === shortFlag && void 0 === longFlag) throw new Error(`option creation failed due to no flags found in '${flags}'.`);
1685
+ return {
1686
+ shortFlag,
1687
+ longFlag
1688
+ };
1689
+ }
1690
+ exports.Option = Option;
1691
+ exports.DualOptions = DualOptions;
1692
+ },
1693
+ "../../../node_modules/.pnpm/commander@13.1.0/node_modules/commander/lib/suggestSimilar.js": function(__unused_webpack_module, exports) {
1694
+ const maxDistance = 3;
1695
+ function editDistance(a, b) {
1696
+ if (Math.abs(a.length - b.length) > maxDistance) return Math.max(a.length, b.length);
1697
+ const d = [];
1698
+ for(let i = 0; i <= a.length; i++)d[i] = [
1699
+ i
1700
+ ];
1701
+ for(let j = 0; j <= b.length; j++)d[0][j] = j;
1702
+ for(let j = 1; j <= b.length; j++)for(let i = 1; i <= a.length; i++){
1703
+ let cost = 1;
1704
+ cost = a[i - 1] === b[j - 1] ? 0 : 1;
1705
+ d[i][j] = Math.min(d[i - 1][j] + 1, d[i][j - 1] + 1, d[i - 1][j - 1] + cost);
1706
+ if (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);
1707
+ }
1708
+ return d[a.length][b.length];
1709
+ }
1710
+ function suggestSimilar(word, candidates) {
1711
+ if (!candidates || 0 === candidates.length) return '';
1712
+ candidates = Array.from(new Set(candidates));
1713
+ const searchingOptions = word.startsWith('--');
1714
+ if (searchingOptions) {
1715
+ word = word.slice(2);
1716
+ candidates = candidates.map((candidate)=>candidate.slice(2));
1717
+ }
1718
+ let similar = [];
1719
+ let bestDistance = maxDistance;
1720
+ const minSimilarity = 0.4;
1721
+ candidates.forEach((candidate)=>{
1722
+ if (candidate.length <= 1) return;
1723
+ const distance = editDistance(word, candidate);
1724
+ const length = Math.max(word.length, candidate.length);
1725
+ const similarity = (length - distance) / length;
1726
+ if (similarity > minSimilarity) {
1727
+ if (distance < bestDistance) {
1728
+ bestDistance = distance;
1729
+ similar = [
1730
+ candidate
1731
+ ];
1732
+ } else if (distance === bestDistance) similar.push(candidate);
1733
+ }
1734
+ });
1735
+ similar.sort((a, b)=>a.localeCompare(b));
1736
+ if (searchingOptions) similar = similar.map((candidate)=>`--${candidate}`);
1737
+ if (similar.length > 1) return `\n(Did you mean one of ${similar.join(', ')}?)`;
1738
+ if (1 === similar.length) return `\n(Did you mean ${similar[0]}?)`;
1739
+ return '';
1740
+ }
1741
+ exports.suggestSimilar = suggestSimilar;
1742
+ },
1743
+ "../../../node_modules/.pnpm/commander@13.1.0/node_modules/commander/esm.mjs": function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
1744
+ __webpack_require__.r(__webpack_exports__);
1745
+ __webpack_require__.d(__webpack_exports__, {
1746
+ Argument: ()=>Argument,
1747
+ Command: ()=>Command,
1748
+ CommanderError: ()=>CommanderError,
1749
+ Help: ()=>Help,
1750
+ InvalidArgumentError: ()=>InvalidArgumentError,
1751
+ InvalidOptionArgumentError: ()=>InvalidOptionArgumentError,
1752
+ Option: ()=>Option,
1753
+ createArgument: ()=>createArgument,
1754
+ createCommand: ()=>createCommand,
1755
+ createOption: ()=>createOption,
1756
+ program: ()=>program
1757
+ });
1758
+ var _index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("../../../node_modules/.pnpm/commander@13.1.0/node_modules/commander/index.js");
1759
+ const { program, createCommand, createArgument, createOption, CommanderError, InvalidArgumentError, InvalidOptionArgumentError, Command, Argument, Option, Help } = _index_js__WEBPACK_IMPORTED_MODULE_0__;
1760
+ }
1761
+ };