@releasekit/release 0.7.15 → 0.7.16
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.
- package/dist/cli.js +79 -3537
- package/dist/dispatcher.js +88 -3546
- package/package.json +6 -6
package/dist/cli.js
CHANGED
|
@@ -40,3464 +40,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
40
40
|
mod
|
|
41
41
|
));
|
|
42
42
|
|
|
43
|
-
// ../../node_modules/.pnpm/commander@14.0.3/node_modules/commander/lib/error.js
|
|
44
|
-
var require_error = __commonJS({
|
|
45
|
-
"../../node_modules/.pnpm/commander@14.0.3/node_modules/commander/lib/error.js"(exports2) {
|
|
46
|
-
"use strict";
|
|
47
|
-
var CommanderError2 = class extends Error {
|
|
48
|
-
/**
|
|
49
|
-
* Constructs the CommanderError class
|
|
50
|
-
* @param {number} exitCode suggested exit code which could be used with process.exit
|
|
51
|
-
* @param {string} code an id string representing the error
|
|
52
|
-
* @param {string} message human-readable description of the error
|
|
53
|
-
*/
|
|
54
|
-
constructor(exitCode3, code, message) {
|
|
55
|
-
super(message);
|
|
56
|
-
Error.captureStackTrace(this, this.constructor);
|
|
57
|
-
this.name = this.constructor.name;
|
|
58
|
-
this.code = code;
|
|
59
|
-
this.exitCode = exitCode3;
|
|
60
|
-
this.nestedError = void 0;
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
var InvalidArgumentError2 = class extends CommanderError2 {
|
|
64
|
-
/**
|
|
65
|
-
* Constructs the InvalidArgumentError class
|
|
66
|
-
* @param {string} [message] explanation of why argument is invalid
|
|
67
|
-
*/
|
|
68
|
-
constructor(message) {
|
|
69
|
-
super(1, "commander.invalidArgument", message);
|
|
70
|
-
Error.captureStackTrace(this, this.constructor);
|
|
71
|
-
this.name = this.constructor.name;
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
exports2.CommanderError = CommanderError2;
|
|
75
|
-
exports2.InvalidArgumentError = InvalidArgumentError2;
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
// ../../node_modules/.pnpm/commander@14.0.3/node_modules/commander/lib/argument.js
|
|
80
|
-
var require_argument = __commonJS({
|
|
81
|
-
"../../node_modules/.pnpm/commander@14.0.3/node_modules/commander/lib/argument.js"(exports2) {
|
|
82
|
-
"use strict";
|
|
83
|
-
var { InvalidArgumentError: InvalidArgumentError2 } = require_error();
|
|
84
|
-
var Argument2 = class {
|
|
85
|
-
/**
|
|
86
|
-
* Initialize a new command argument with the given name and description.
|
|
87
|
-
* The default is that the argument is required, and you can explicitly
|
|
88
|
-
* indicate this with <> around the name. Put [] around the name for an optional argument.
|
|
89
|
-
*
|
|
90
|
-
* @param {string} name
|
|
91
|
-
* @param {string} [description]
|
|
92
|
-
*/
|
|
93
|
-
constructor(name, description) {
|
|
94
|
-
this.description = description || "";
|
|
95
|
-
this.variadic = false;
|
|
96
|
-
this.parseArg = void 0;
|
|
97
|
-
this.defaultValue = void 0;
|
|
98
|
-
this.defaultValueDescription = void 0;
|
|
99
|
-
this.argChoices = void 0;
|
|
100
|
-
switch (name[0]) {
|
|
101
|
-
case "<":
|
|
102
|
-
this.required = true;
|
|
103
|
-
this._name = name.slice(1, -1);
|
|
104
|
-
break;
|
|
105
|
-
case "[":
|
|
106
|
-
this.required = false;
|
|
107
|
-
this._name = name.slice(1, -1);
|
|
108
|
-
break;
|
|
109
|
-
default:
|
|
110
|
-
this.required = true;
|
|
111
|
-
this._name = name;
|
|
112
|
-
break;
|
|
113
|
-
}
|
|
114
|
-
if (this._name.endsWith("...")) {
|
|
115
|
-
this.variadic = true;
|
|
116
|
-
this._name = this._name.slice(0, -3);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Return argument name.
|
|
121
|
-
*
|
|
122
|
-
* @return {string}
|
|
123
|
-
*/
|
|
124
|
-
name() {
|
|
125
|
-
return this._name;
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* @package
|
|
129
|
-
*/
|
|
130
|
-
_collectValue(value, previous) {
|
|
131
|
-
if (previous === this.defaultValue || !Array.isArray(previous)) {
|
|
132
|
-
return [value];
|
|
133
|
-
}
|
|
134
|
-
previous.push(value);
|
|
135
|
-
return previous;
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Set the default value, and optionally supply the description to be displayed in the help.
|
|
139
|
-
*
|
|
140
|
-
* @param {*} value
|
|
141
|
-
* @param {string} [description]
|
|
142
|
-
* @return {Argument}
|
|
143
|
-
*/
|
|
144
|
-
default(value, description) {
|
|
145
|
-
this.defaultValue = value;
|
|
146
|
-
this.defaultValueDescription = description;
|
|
147
|
-
return this;
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* Set the custom handler for processing CLI command arguments into argument values.
|
|
151
|
-
*
|
|
152
|
-
* @param {Function} [fn]
|
|
153
|
-
* @return {Argument}
|
|
154
|
-
*/
|
|
155
|
-
argParser(fn) {
|
|
156
|
-
this.parseArg = fn;
|
|
157
|
-
return this;
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* Only allow argument value to be one of choices.
|
|
161
|
-
*
|
|
162
|
-
* @param {string[]} values
|
|
163
|
-
* @return {Argument}
|
|
164
|
-
*/
|
|
165
|
-
choices(values) {
|
|
166
|
-
this.argChoices = values.slice();
|
|
167
|
-
this.parseArg = (arg, previous) => {
|
|
168
|
-
if (!this.argChoices.includes(arg)) {
|
|
169
|
-
throw new InvalidArgumentError2(
|
|
170
|
-
`Allowed choices are ${this.argChoices.join(", ")}.`
|
|
171
|
-
);
|
|
172
|
-
}
|
|
173
|
-
if (this.variadic) {
|
|
174
|
-
return this._collectValue(arg, previous);
|
|
175
|
-
}
|
|
176
|
-
return arg;
|
|
177
|
-
};
|
|
178
|
-
return this;
|
|
179
|
-
}
|
|
180
|
-
/**
|
|
181
|
-
* Make argument required.
|
|
182
|
-
*
|
|
183
|
-
* @returns {Argument}
|
|
184
|
-
*/
|
|
185
|
-
argRequired() {
|
|
186
|
-
this.required = true;
|
|
187
|
-
return this;
|
|
188
|
-
}
|
|
189
|
-
/**
|
|
190
|
-
* Make argument optional.
|
|
191
|
-
*
|
|
192
|
-
* @returns {Argument}
|
|
193
|
-
*/
|
|
194
|
-
argOptional() {
|
|
195
|
-
this.required = false;
|
|
196
|
-
return this;
|
|
197
|
-
}
|
|
198
|
-
};
|
|
199
|
-
function humanReadableArgName(arg) {
|
|
200
|
-
const nameOutput = arg.name() + (arg.variadic === true ? "..." : "");
|
|
201
|
-
return arg.required ? "<" + nameOutput + ">" : "[" + nameOutput + "]";
|
|
202
|
-
}
|
|
203
|
-
exports2.Argument = Argument2;
|
|
204
|
-
exports2.humanReadableArgName = humanReadableArgName;
|
|
205
|
-
}
|
|
206
|
-
});
|
|
207
|
-
|
|
208
|
-
// ../../node_modules/.pnpm/commander@14.0.3/node_modules/commander/lib/help.js
|
|
209
|
-
var require_help = __commonJS({
|
|
210
|
-
"../../node_modules/.pnpm/commander@14.0.3/node_modules/commander/lib/help.js"(exports2) {
|
|
211
|
-
"use strict";
|
|
212
|
-
var { humanReadableArgName } = require_argument();
|
|
213
|
-
var Help2 = class {
|
|
214
|
-
constructor() {
|
|
215
|
-
this.helpWidth = void 0;
|
|
216
|
-
this.minWidthToWrap = 40;
|
|
217
|
-
this.sortSubcommands = false;
|
|
218
|
-
this.sortOptions = false;
|
|
219
|
-
this.showGlobalOptions = false;
|
|
220
|
-
}
|
|
221
|
-
/**
|
|
222
|
-
* prepareContext is called by Commander after applying overrides from `Command.configureHelp()`
|
|
223
|
-
* and just before calling `formatHelp()`.
|
|
224
|
-
*
|
|
225
|
-
* Commander just uses the helpWidth and the rest is provided for optional use by more complex subclasses.
|
|
226
|
-
*
|
|
227
|
-
* @param {{ error?: boolean, helpWidth?: number, outputHasColors?: boolean }} contextOptions
|
|
228
|
-
*/
|
|
229
|
-
prepareContext(contextOptions) {
|
|
230
|
-
this.helpWidth = this.helpWidth ?? contextOptions.helpWidth ?? 80;
|
|
231
|
-
}
|
|
232
|
-
/**
|
|
233
|
-
* Get an array of the visible subcommands. Includes a placeholder for the implicit help command, if there is one.
|
|
234
|
-
*
|
|
235
|
-
* @param {Command} cmd
|
|
236
|
-
* @returns {Command[]}
|
|
237
|
-
*/
|
|
238
|
-
visibleCommands(cmd) {
|
|
239
|
-
const visibleCommands = cmd.commands.filter((cmd2) => !cmd2._hidden);
|
|
240
|
-
const helpCommand = cmd._getHelpCommand();
|
|
241
|
-
if (helpCommand && !helpCommand._hidden) {
|
|
242
|
-
visibleCommands.push(helpCommand);
|
|
243
|
-
}
|
|
244
|
-
if (this.sortSubcommands) {
|
|
245
|
-
visibleCommands.sort((a, b) => {
|
|
246
|
-
return a.name().localeCompare(b.name());
|
|
247
|
-
});
|
|
248
|
-
}
|
|
249
|
-
return visibleCommands;
|
|
250
|
-
}
|
|
251
|
-
/**
|
|
252
|
-
* Compare options for sort.
|
|
253
|
-
*
|
|
254
|
-
* @param {Option} a
|
|
255
|
-
* @param {Option} b
|
|
256
|
-
* @returns {number}
|
|
257
|
-
*/
|
|
258
|
-
compareOptions(a, b) {
|
|
259
|
-
const getSortKey = (option) => {
|
|
260
|
-
return option.short ? option.short.replace(/^-/, "") : option.long.replace(/^--/, "");
|
|
261
|
-
};
|
|
262
|
-
return getSortKey(a).localeCompare(getSortKey(b));
|
|
263
|
-
}
|
|
264
|
-
/**
|
|
265
|
-
* Get an array of the visible options. Includes a placeholder for the implicit help option, if there is one.
|
|
266
|
-
*
|
|
267
|
-
* @param {Command} cmd
|
|
268
|
-
* @returns {Option[]}
|
|
269
|
-
*/
|
|
270
|
-
visibleOptions(cmd) {
|
|
271
|
-
const visibleOptions = cmd.options.filter((option) => !option.hidden);
|
|
272
|
-
const helpOption = cmd._getHelpOption();
|
|
273
|
-
if (helpOption && !helpOption.hidden) {
|
|
274
|
-
const removeShort = helpOption.short && cmd._findOption(helpOption.short);
|
|
275
|
-
const removeLong = helpOption.long && cmd._findOption(helpOption.long);
|
|
276
|
-
if (!removeShort && !removeLong) {
|
|
277
|
-
visibleOptions.push(helpOption);
|
|
278
|
-
} else if (helpOption.long && !removeLong) {
|
|
279
|
-
visibleOptions.push(
|
|
280
|
-
cmd.createOption(helpOption.long, helpOption.description)
|
|
281
|
-
);
|
|
282
|
-
} else if (helpOption.short && !removeShort) {
|
|
283
|
-
visibleOptions.push(
|
|
284
|
-
cmd.createOption(helpOption.short, helpOption.description)
|
|
285
|
-
);
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
if (this.sortOptions) {
|
|
289
|
-
visibleOptions.sort(this.compareOptions);
|
|
290
|
-
}
|
|
291
|
-
return visibleOptions;
|
|
292
|
-
}
|
|
293
|
-
/**
|
|
294
|
-
* Get an array of the visible global options. (Not including help.)
|
|
295
|
-
*
|
|
296
|
-
* @param {Command} cmd
|
|
297
|
-
* @returns {Option[]}
|
|
298
|
-
*/
|
|
299
|
-
visibleGlobalOptions(cmd) {
|
|
300
|
-
if (!this.showGlobalOptions) return [];
|
|
301
|
-
const globalOptions = [];
|
|
302
|
-
for (let ancestorCmd = cmd.parent; ancestorCmd; ancestorCmd = ancestorCmd.parent) {
|
|
303
|
-
const visibleOptions = ancestorCmd.options.filter(
|
|
304
|
-
(option) => !option.hidden
|
|
305
|
-
);
|
|
306
|
-
globalOptions.push(...visibleOptions);
|
|
307
|
-
}
|
|
308
|
-
if (this.sortOptions) {
|
|
309
|
-
globalOptions.sort(this.compareOptions);
|
|
310
|
-
}
|
|
311
|
-
return globalOptions;
|
|
312
|
-
}
|
|
313
|
-
/**
|
|
314
|
-
* Get an array of the arguments if any have a description.
|
|
315
|
-
*
|
|
316
|
-
* @param {Command} cmd
|
|
317
|
-
* @returns {Argument[]}
|
|
318
|
-
*/
|
|
319
|
-
visibleArguments(cmd) {
|
|
320
|
-
if (cmd._argsDescription) {
|
|
321
|
-
cmd.registeredArguments.forEach((argument) => {
|
|
322
|
-
argument.description = argument.description || cmd._argsDescription[argument.name()] || "";
|
|
323
|
-
});
|
|
324
|
-
}
|
|
325
|
-
if (cmd.registeredArguments.find((argument) => argument.description)) {
|
|
326
|
-
return cmd.registeredArguments;
|
|
327
|
-
}
|
|
328
|
-
return [];
|
|
329
|
-
}
|
|
330
|
-
/**
|
|
331
|
-
* Get the command term to show in the list of subcommands.
|
|
332
|
-
*
|
|
333
|
-
* @param {Command} cmd
|
|
334
|
-
* @returns {string}
|
|
335
|
-
*/
|
|
336
|
-
subcommandTerm(cmd) {
|
|
337
|
-
const args = cmd.registeredArguments.map((arg) => humanReadableArgName(arg)).join(" ");
|
|
338
|
-
return cmd._name + (cmd._aliases[0] ? "|" + cmd._aliases[0] : "") + (cmd.options.length ? " [options]" : "") + // simplistic check for non-help option
|
|
339
|
-
(args ? " " + args : "");
|
|
340
|
-
}
|
|
341
|
-
/**
|
|
342
|
-
* Get the option term to show in the list of options.
|
|
343
|
-
*
|
|
344
|
-
* @param {Option} option
|
|
345
|
-
* @returns {string}
|
|
346
|
-
*/
|
|
347
|
-
optionTerm(option) {
|
|
348
|
-
return option.flags;
|
|
349
|
-
}
|
|
350
|
-
/**
|
|
351
|
-
* Get the argument term to show in the list of arguments.
|
|
352
|
-
*
|
|
353
|
-
* @param {Argument} argument
|
|
354
|
-
* @returns {string}
|
|
355
|
-
*/
|
|
356
|
-
argumentTerm(argument) {
|
|
357
|
-
return argument.name();
|
|
358
|
-
}
|
|
359
|
-
/**
|
|
360
|
-
* Get the longest command term length.
|
|
361
|
-
*
|
|
362
|
-
* @param {Command} cmd
|
|
363
|
-
* @param {Help} helper
|
|
364
|
-
* @returns {number}
|
|
365
|
-
*/
|
|
366
|
-
longestSubcommandTermLength(cmd, helper) {
|
|
367
|
-
return helper.visibleCommands(cmd).reduce((max, command) => {
|
|
368
|
-
return Math.max(
|
|
369
|
-
max,
|
|
370
|
-
this.displayWidth(
|
|
371
|
-
helper.styleSubcommandTerm(helper.subcommandTerm(command))
|
|
372
|
-
)
|
|
373
|
-
);
|
|
374
|
-
}, 0);
|
|
375
|
-
}
|
|
376
|
-
/**
|
|
377
|
-
* Get the longest option term length.
|
|
378
|
-
*
|
|
379
|
-
* @param {Command} cmd
|
|
380
|
-
* @param {Help} helper
|
|
381
|
-
* @returns {number}
|
|
382
|
-
*/
|
|
383
|
-
longestOptionTermLength(cmd, helper) {
|
|
384
|
-
return helper.visibleOptions(cmd).reduce((max, option) => {
|
|
385
|
-
return Math.max(
|
|
386
|
-
max,
|
|
387
|
-
this.displayWidth(helper.styleOptionTerm(helper.optionTerm(option)))
|
|
388
|
-
);
|
|
389
|
-
}, 0);
|
|
390
|
-
}
|
|
391
|
-
/**
|
|
392
|
-
* Get the longest global option term length.
|
|
393
|
-
*
|
|
394
|
-
* @param {Command} cmd
|
|
395
|
-
* @param {Help} helper
|
|
396
|
-
* @returns {number}
|
|
397
|
-
*/
|
|
398
|
-
longestGlobalOptionTermLength(cmd, helper) {
|
|
399
|
-
return helper.visibleGlobalOptions(cmd).reduce((max, option) => {
|
|
400
|
-
return Math.max(
|
|
401
|
-
max,
|
|
402
|
-
this.displayWidth(helper.styleOptionTerm(helper.optionTerm(option)))
|
|
403
|
-
);
|
|
404
|
-
}, 0);
|
|
405
|
-
}
|
|
406
|
-
/**
|
|
407
|
-
* Get the longest argument term length.
|
|
408
|
-
*
|
|
409
|
-
* @param {Command} cmd
|
|
410
|
-
* @param {Help} helper
|
|
411
|
-
* @returns {number}
|
|
412
|
-
*/
|
|
413
|
-
longestArgumentTermLength(cmd, helper) {
|
|
414
|
-
return helper.visibleArguments(cmd).reduce((max, argument) => {
|
|
415
|
-
return Math.max(
|
|
416
|
-
max,
|
|
417
|
-
this.displayWidth(
|
|
418
|
-
helper.styleArgumentTerm(helper.argumentTerm(argument))
|
|
419
|
-
)
|
|
420
|
-
);
|
|
421
|
-
}, 0);
|
|
422
|
-
}
|
|
423
|
-
/**
|
|
424
|
-
* Get the command usage to be displayed at the top of the built-in help.
|
|
425
|
-
*
|
|
426
|
-
* @param {Command} cmd
|
|
427
|
-
* @returns {string}
|
|
428
|
-
*/
|
|
429
|
-
commandUsage(cmd) {
|
|
430
|
-
let cmdName = cmd._name;
|
|
431
|
-
if (cmd._aliases[0]) {
|
|
432
|
-
cmdName = cmdName + "|" + cmd._aliases[0];
|
|
433
|
-
}
|
|
434
|
-
let ancestorCmdNames = "";
|
|
435
|
-
for (let ancestorCmd = cmd.parent; ancestorCmd; ancestorCmd = ancestorCmd.parent) {
|
|
436
|
-
ancestorCmdNames = ancestorCmd.name() + " " + ancestorCmdNames;
|
|
437
|
-
}
|
|
438
|
-
return ancestorCmdNames + cmdName + " " + cmd.usage();
|
|
439
|
-
}
|
|
440
|
-
/**
|
|
441
|
-
* Get the description for the command.
|
|
442
|
-
*
|
|
443
|
-
* @param {Command} cmd
|
|
444
|
-
* @returns {string}
|
|
445
|
-
*/
|
|
446
|
-
commandDescription(cmd) {
|
|
447
|
-
return cmd.description();
|
|
448
|
-
}
|
|
449
|
-
/**
|
|
450
|
-
* Get the subcommand summary to show in the list of subcommands.
|
|
451
|
-
* (Fallback to description for backwards compatibility.)
|
|
452
|
-
*
|
|
453
|
-
* @param {Command} cmd
|
|
454
|
-
* @returns {string}
|
|
455
|
-
*/
|
|
456
|
-
subcommandDescription(cmd) {
|
|
457
|
-
return cmd.summary() || cmd.description();
|
|
458
|
-
}
|
|
459
|
-
/**
|
|
460
|
-
* Get the option description to show in the list of options.
|
|
461
|
-
*
|
|
462
|
-
* @param {Option} option
|
|
463
|
-
* @return {string}
|
|
464
|
-
*/
|
|
465
|
-
optionDescription(option) {
|
|
466
|
-
const extraInfo = [];
|
|
467
|
-
if (option.argChoices) {
|
|
468
|
-
extraInfo.push(
|
|
469
|
-
// use stringify to match the display of the default value
|
|
470
|
-
`choices: ${option.argChoices.map((choice) => JSON.stringify(choice)).join(", ")}`
|
|
471
|
-
);
|
|
472
|
-
}
|
|
473
|
-
if (option.defaultValue !== void 0) {
|
|
474
|
-
const showDefault = option.required || option.optional || option.isBoolean() && typeof option.defaultValue === "boolean";
|
|
475
|
-
if (showDefault) {
|
|
476
|
-
extraInfo.push(
|
|
477
|
-
`default: ${option.defaultValueDescription || JSON.stringify(option.defaultValue)}`
|
|
478
|
-
);
|
|
479
|
-
}
|
|
480
|
-
}
|
|
481
|
-
if (option.presetArg !== void 0 && option.optional) {
|
|
482
|
-
extraInfo.push(`preset: ${JSON.stringify(option.presetArg)}`);
|
|
483
|
-
}
|
|
484
|
-
if (option.envVar !== void 0) {
|
|
485
|
-
extraInfo.push(`env: ${option.envVar}`);
|
|
486
|
-
}
|
|
487
|
-
if (extraInfo.length > 0) {
|
|
488
|
-
const extraDescription = `(${extraInfo.join(", ")})`;
|
|
489
|
-
if (option.description) {
|
|
490
|
-
return `${option.description} ${extraDescription}`;
|
|
491
|
-
}
|
|
492
|
-
return extraDescription;
|
|
493
|
-
}
|
|
494
|
-
return option.description;
|
|
495
|
-
}
|
|
496
|
-
/**
|
|
497
|
-
* Get the argument description to show in the list of arguments.
|
|
498
|
-
*
|
|
499
|
-
* @param {Argument} argument
|
|
500
|
-
* @return {string}
|
|
501
|
-
*/
|
|
502
|
-
argumentDescription(argument) {
|
|
503
|
-
const extraInfo = [];
|
|
504
|
-
if (argument.argChoices) {
|
|
505
|
-
extraInfo.push(
|
|
506
|
-
// use stringify to match the display of the default value
|
|
507
|
-
`choices: ${argument.argChoices.map((choice) => JSON.stringify(choice)).join(", ")}`
|
|
508
|
-
);
|
|
509
|
-
}
|
|
510
|
-
if (argument.defaultValue !== void 0) {
|
|
511
|
-
extraInfo.push(
|
|
512
|
-
`default: ${argument.defaultValueDescription || JSON.stringify(argument.defaultValue)}`
|
|
513
|
-
);
|
|
514
|
-
}
|
|
515
|
-
if (extraInfo.length > 0) {
|
|
516
|
-
const extraDescription = `(${extraInfo.join(", ")})`;
|
|
517
|
-
if (argument.description) {
|
|
518
|
-
return `${argument.description} ${extraDescription}`;
|
|
519
|
-
}
|
|
520
|
-
return extraDescription;
|
|
521
|
-
}
|
|
522
|
-
return argument.description;
|
|
523
|
-
}
|
|
524
|
-
/**
|
|
525
|
-
* Format a list of items, given a heading and an array of formatted items.
|
|
526
|
-
*
|
|
527
|
-
* @param {string} heading
|
|
528
|
-
* @param {string[]} items
|
|
529
|
-
* @param {Help} helper
|
|
530
|
-
* @returns string[]
|
|
531
|
-
*/
|
|
532
|
-
formatItemList(heading, items, helper) {
|
|
533
|
-
if (items.length === 0) return [];
|
|
534
|
-
return [helper.styleTitle(heading), ...items, ""];
|
|
535
|
-
}
|
|
536
|
-
/**
|
|
537
|
-
* Group items by their help group heading.
|
|
538
|
-
*
|
|
539
|
-
* @param {Command[] | Option[]} unsortedItems
|
|
540
|
-
* @param {Command[] | Option[]} visibleItems
|
|
541
|
-
* @param {Function} getGroup
|
|
542
|
-
* @returns {Map<string, Command[] | Option[]>}
|
|
543
|
-
*/
|
|
544
|
-
groupItems(unsortedItems, visibleItems, getGroup) {
|
|
545
|
-
const result = /* @__PURE__ */ new Map();
|
|
546
|
-
unsortedItems.forEach((item) => {
|
|
547
|
-
const group = getGroup(item);
|
|
548
|
-
if (!result.has(group)) result.set(group, []);
|
|
549
|
-
});
|
|
550
|
-
visibleItems.forEach((item) => {
|
|
551
|
-
const group = getGroup(item);
|
|
552
|
-
if (!result.has(group)) {
|
|
553
|
-
result.set(group, []);
|
|
554
|
-
}
|
|
555
|
-
result.get(group).push(item);
|
|
556
|
-
});
|
|
557
|
-
return result;
|
|
558
|
-
}
|
|
559
|
-
/**
|
|
560
|
-
* Generate the built-in help text.
|
|
561
|
-
*
|
|
562
|
-
* @param {Command} cmd
|
|
563
|
-
* @param {Help} helper
|
|
564
|
-
* @returns {string}
|
|
565
|
-
*/
|
|
566
|
-
formatHelp(cmd, helper) {
|
|
567
|
-
const termWidth = helper.padWidth(cmd, helper);
|
|
568
|
-
const helpWidth = helper.helpWidth ?? 80;
|
|
569
|
-
function callFormatItem(term, description) {
|
|
570
|
-
return helper.formatItem(term, termWidth, description, helper);
|
|
571
|
-
}
|
|
572
|
-
let output3 = [
|
|
573
|
-
`${helper.styleTitle("Usage:")} ${helper.styleUsage(helper.commandUsage(cmd))}`,
|
|
574
|
-
""
|
|
575
|
-
];
|
|
576
|
-
const commandDescription = helper.commandDescription(cmd);
|
|
577
|
-
if (commandDescription.length > 0) {
|
|
578
|
-
output3 = output3.concat([
|
|
579
|
-
helper.boxWrap(
|
|
580
|
-
helper.styleCommandDescription(commandDescription),
|
|
581
|
-
helpWidth
|
|
582
|
-
),
|
|
583
|
-
""
|
|
584
|
-
]);
|
|
585
|
-
}
|
|
586
|
-
const argumentList = helper.visibleArguments(cmd).map((argument) => {
|
|
587
|
-
return callFormatItem(
|
|
588
|
-
helper.styleArgumentTerm(helper.argumentTerm(argument)),
|
|
589
|
-
helper.styleArgumentDescription(helper.argumentDescription(argument))
|
|
590
|
-
);
|
|
591
|
-
});
|
|
592
|
-
output3 = output3.concat(
|
|
593
|
-
this.formatItemList("Arguments:", argumentList, helper)
|
|
594
|
-
);
|
|
595
|
-
const optionGroups = this.groupItems(
|
|
596
|
-
cmd.options,
|
|
597
|
-
helper.visibleOptions(cmd),
|
|
598
|
-
(option) => option.helpGroupHeading ?? "Options:"
|
|
599
|
-
);
|
|
600
|
-
optionGroups.forEach((options, group) => {
|
|
601
|
-
const optionList = options.map((option) => {
|
|
602
|
-
return callFormatItem(
|
|
603
|
-
helper.styleOptionTerm(helper.optionTerm(option)),
|
|
604
|
-
helper.styleOptionDescription(helper.optionDescription(option))
|
|
605
|
-
);
|
|
606
|
-
});
|
|
607
|
-
output3 = output3.concat(this.formatItemList(group, optionList, helper));
|
|
608
|
-
});
|
|
609
|
-
if (helper.showGlobalOptions) {
|
|
610
|
-
const globalOptionList = helper.visibleGlobalOptions(cmd).map((option) => {
|
|
611
|
-
return callFormatItem(
|
|
612
|
-
helper.styleOptionTerm(helper.optionTerm(option)),
|
|
613
|
-
helper.styleOptionDescription(helper.optionDescription(option))
|
|
614
|
-
);
|
|
615
|
-
});
|
|
616
|
-
output3 = output3.concat(
|
|
617
|
-
this.formatItemList("Global Options:", globalOptionList, helper)
|
|
618
|
-
);
|
|
619
|
-
}
|
|
620
|
-
const commandGroups = this.groupItems(
|
|
621
|
-
cmd.commands,
|
|
622
|
-
helper.visibleCommands(cmd),
|
|
623
|
-
(sub) => sub.helpGroup() || "Commands:"
|
|
624
|
-
);
|
|
625
|
-
commandGroups.forEach((commands, group) => {
|
|
626
|
-
const commandList = commands.map((sub) => {
|
|
627
|
-
return callFormatItem(
|
|
628
|
-
helper.styleSubcommandTerm(helper.subcommandTerm(sub)),
|
|
629
|
-
helper.styleSubcommandDescription(helper.subcommandDescription(sub))
|
|
630
|
-
);
|
|
631
|
-
});
|
|
632
|
-
output3 = output3.concat(this.formatItemList(group, commandList, helper));
|
|
633
|
-
});
|
|
634
|
-
return output3.join("\n");
|
|
635
|
-
}
|
|
636
|
-
/**
|
|
637
|
-
* Return display width of string, ignoring ANSI escape sequences. Used in padding and wrapping calculations.
|
|
638
|
-
*
|
|
639
|
-
* @param {string} str
|
|
640
|
-
* @returns {number}
|
|
641
|
-
*/
|
|
642
|
-
displayWidth(str3) {
|
|
643
|
-
return stripColor(str3).length;
|
|
644
|
-
}
|
|
645
|
-
/**
|
|
646
|
-
* Style the title for displaying in the help. Called with 'Usage:', 'Options:', etc.
|
|
647
|
-
*
|
|
648
|
-
* @param {string} str
|
|
649
|
-
* @returns {string}
|
|
650
|
-
*/
|
|
651
|
-
styleTitle(str3) {
|
|
652
|
-
return str3;
|
|
653
|
-
}
|
|
654
|
-
styleUsage(str3) {
|
|
655
|
-
return str3.split(" ").map((word) => {
|
|
656
|
-
if (word === "[options]") return this.styleOptionText(word);
|
|
657
|
-
if (word === "[command]") return this.styleSubcommandText(word);
|
|
658
|
-
if (word[0] === "[" || word[0] === "<")
|
|
659
|
-
return this.styleArgumentText(word);
|
|
660
|
-
return this.styleCommandText(word);
|
|
661
|
-
}).join(" ");
|
|
662
|
-
}
|
|
663
|
-
styleCommandDescription(str3) {
|
|
664
|
-
return this.styleDescriptionText(str3);
|
|
665
|
-
}
|
|
666
|
-
styleOptionDescription(str3) {
|
|
667
|
-
return this.styleDescriptionText(str3);
|
|
668
|
-
}
|
|
669
|
-
styleSubcommandDescription(str3) {
|
|
670
|
-
return this.styleDescriptionText(str3);
|
|
671
|
-
}
|
|
672
|
-
styleArgumentDescription(str3) {
|
|
673
|
-
return this.styleDescriptionText(str3);
|
|
674
|
-
}
|
|
675
|
-
styleDescriptionText(str3) {
|
|
676
|
-
return str3;
|
|
677
|
-
}
|
|
678
|
-
styleOptionTerm(str3) {
|
|
679
|
-
return this.styleOptionText(str3);
|
|
680
|
-
}
|
|
681
|
-
styleSubcommandTerm(str3) {
|
|
682
|
-
return str3.split(" ").map((word) => {
|
|
683
|
-
if (word === "[options]") return this.styleOptionText(word);
|
|
684
|
-
if (word[0] === "[" || word[0] === "<")
|
|
685
|
-
return this.styleArgumentText(word);
|
|
686
|
-
return this.styleSubcommandText(word);
|
|
687
|
-
}).join(" ");
|
|
688
|
-
}
|
|
689
|
-
styleArgumentTerm(str3) {
|
|
690
|
-
return this.styleArgumentText(str3);
|
|
691
|
-
}
|
|
692
|
-
styleOptionText(str3) {
|
|
693
|
-
return str3;
|
|
694
|
-
}
|
|
695
|
-
styleArgumentText(str3) {
|
|
696
|
-
return str3;
|
|
697
|
-
}
|
|
698
|
-
styleSubcommandText(str3) {
|
|
699
|
-
return str3;
|
|
700
|
-
}
|
|
701
|
-
styleCommandText(str3) {
|
|
702
|
-
return str3;
|
|
703
|
-
}
|
|
704
|
-
/**
|
|
705
|
-
* Calculate the pad width from the maximum term length.
|
|
706
|
-
*
|
|
707
|
-
* @param {Command} cmd
|
|
708
|
-
* @param {Help} helper
|
|
709
|
-
* @returns {number}
|
|
710
|
-
*/
|
|
711
|
-
padWidth(cmd, helper) {
|
|
712
|
-
return Math.max(
|
|
713
|
-
helper.longestOptionTermLength(cmd, helper),
|
|
714
|
-
helper.longestGlobalOptionTermLength(cmd, helper),
|
|
715
|
-
helper.longestSubcommandTermLength(cmd, helper),
|
|
716
|
-
helper.longestArgumentTermLength(cmd, helper)
|
|
717
|
-
);
|
|
718
|
-
}
|
|
719
|
-
/**
|
|
720
|
-
* Detect manually wrapped and indented strings by checking for line break followed by whitespace.
|
|
721
|
-
*
|
|
722
|
-
* @param {string} str
|
|
723
|
-
* @returns {boolean}
|
|
724
|
-
*/
|
|
725
|
-
preformatted(str3) {
|
|
726
|
-
return /\n[^\S\r\n]/.test(str3);
|
|
727
|
-
}
|
|
728
|
-
/**
|
|
729
|
-
* Format the "item", which consists of a term and description. Pad the term and wrap the description, indenting the following lines.
|
|
730
|
-
*
|
|
731
|
-
* So "TTT", 5, "DDD DDDD DD DDD" might be formatted for this.helpWidth=17 like so:
|
|
732
|
-
* TTT DDD DDDD
|
|
733
|
-
* DD DDD
|
|
734
|
-
*
|
|
735
|
-
* @param {string} term
|
|
736
|
-
* @param {number} termWidth
|
|
737
|
-
* @param {string} description
|
|
738
|
-
* @param {Help} helper
|
|
739
|
-
* @returns {string}
|
|
740
|
-
*/
|
|
741
|
-
formatItem(term, termWidth, description, helper) {
|
|
742
|
-
const itemIndent = 2;
|
|
743
|
-
const itemIndentStr = " ".repeat(itemIndent);
|
|
744
|
-
if (!description) return itemIndentStr + term;
|
|
745
|
-
const paddedTerm = term.padEnd(
|
|
746
|
-
termWidth + term.length - helper.displayWidth(term)
|
|
747
|
-
);
|
|
748
|
-
const spacerWidth = 2;
|
|
749
|
-
const helpWidth = this.helpWidth ?? 80;
|
|
750
|
-
const remainingWidth = helpWidth - termWidth - spacerWidth - itemIndent;
|
|
751
|
-
let formattedDescription;
|
|
752
|
-
if (remainingWidth < this.minWidthToWrap || helper.preformatted(description)) {
|
|
753
|
-
formattedDescription = description;
|
|
754
|
-
} else {
|
|
755
|
-
const wrappedDescription = helper.boxWrap(description, remainingWidth);
|
|
756
|
-
formattedDescription = wrappedDescription.replace(
|
|
757
|
-
/\n/g,
|
|
758
|
-
"\n" + " ".repeat(termWidth + spacerWidth)
|
|
759
|
-
);
|
|
760
|
-
}
|
|
761
|
-
return itemIndentStr + paddedTerm + " ".repeat(spacerWidth) + formattedDescription.replace(/\n/g, `
|
|
762
|
-
${itemIndentStr}`);
|
|
763
|
-
}
|
|
764
|
-
/**
|
|
765
|
-
* Wrap a string at whitespace, preserving existing line breaks.
|
|
766
|
-
* Wrapping is skipped if the width is less than `minWidthToWrap`.
|
|
767
|
-
*
|
|
768
|
-
* @param {string} str
|
|
769
|
-
* @param {number} width
|
|
770
|
-
* @returns {string}
|
|
771
|
-
*/
|
|
772
|
-
boxWrap(str3, width) {
|
|
773
|
-
if (width < this.minWidthToWrap) return str3;
|
|
774
|
-
const rawLines = str3.split(/\r\n|\n/);
|
|
775
|
-
const chunkPattern = /[\s]*[^\s]+/g;
|
|
776
|
-
const wrappedLines = [];
|
|
777
|
-
rawLines.forEach((line) => {
|
|
778
|
-
const chunks = line.match(chunkPattern);
|
|
779
|
-
if (chunks === null) {
|
|
780
|
-
wrappedLines.push("");
|
|
781
|
-
return;
|
|
782
|
-
}
|
|
783
|
-
let sumChunks = [chunks.shift()];
|
|
784
|
-
let sumWidth = this.displayWidth(sumChunks[0]);
|
|
785
|
-
chunks.forEach((chunk) => {
|
|
786
|
-
const visibleWidth = this.displayWidth(chunk);
|
|
787
|
-
if (sumWidth + visibleWidth <= width) {
|
|
788
|
-
sumChunks.push(chunk);
|
|
789
|
-
sumWidth += visibleWidth;
|
|
790
|
-
return;
|
|
791
|
-
}
|
|
792
|
-
wrappedLines.push(sumChunks.join(""));
|
|
793
|
-
const nextChunk = chunk.trimStart();
|
|
794
|
-
sumChunks = [nextChunk];
|
|
795
|
-
sumWidth = this.displayWidth(nextChunk);
|
|
796
|
-
});
|
|
797
|
-
wrappedLines.push(sumChunks.join(""));
|
|
798
|
-
});
|
|
799
|
-
return wrappedLines.join("\n");
|
|
800
|
-
}
|
|
801
|
-
};
|
|
802
|
-
function stripColor(str3) {
|
|
803
|
-
const sgrPattern = /\x1b\[\d*(;\d*)*m/g;
|
|
804
|
-
return str3.replace(sgrPattern, "");
|
|
805
|
-
}
|
|
806
|
-
exports2.Help = Help2;
|
|
807
|
-
exports2.stripColor = stripColor;
|
|
808
|
-
}
|
|
809
|
-
});
|
|
810
|
-
|
|
811
|
-
// ../../node_modules/.pnpm/commander@14.0.3/node_modules/commander/lib/option.js
|
|
812
|
-
var require_option = __commonJS({
|
|
813
|
-
"../../node_modules/.pnpm/commander@14.0.3/node_modules/commander/lib/option.js"(exports2) {
|
|
814
|
-
"use strict";
|
|
815
|
-
var { InvalidArgumentError: InvalidArgumentError2 } = require_error();
|
|
816
|
-
var Option2 = class {
|
|
817
|
-
/**
|
|
818
|
-
* Initialize a new `Option` with the given `flags` and `description`.
|
|
819
|
-
*
|
|
820
|
-
* @param {string} flags
|
|
821
|
-
* @param {string} [description]
|
|
822
|
-
*/
|
|
823
|
-
constructor(flags, description) {
|
|
824
|
-
this.flags = flags;
|
|
825
|
-
this.description = description || "";
|
|
826
|
-
this.required = flags.includes("<");
|
|
827
|
-
this.optional = flags.includes("[");
|
|
828
|
-
this.variadic = /\w\.\.\.[>\]]$/.test(flags);
|
|
829
|
-
this.mandatory = false;
|
|
830
|
-
const optionFlags = splitOptionFlags(flags);
|
|
831
|
-
this.short = optionFlags.shortFlag;
|
|
832
|
-
this.long = optionFlags.longFlag;
|
|
833
|
-
this.negate = false;
|
|
834
|
-
if (this.long) {
|
|
835
|
-
this.negate = this.long.startsWith("--no-");
|
|
836
|
-
}
|
|
837
|
-
this.defaultValue = void 0;
|
|
838
|
-
this.defaultValueDescription = void 0;
|
|
839
|
-
this.presetArg = void 0;
|
|
840
|
-
this.envVar = void 0;
|
|
841
|
-
this.parseArg = void 0;
|
|
842
|
-
this.hidden = false;
|
|
843
|
-
this.argChoices = void 0;
|
|
844
|
-
this.conflictsWith = [];
|
|
845
|
-
this.implied = void 0;
|
|
846
|
-
this.helpGroupHeading = void 0;
|
|
847
|
-
}
|
|
848
|
-
/**
|
|
849
|
-
* Set the default value, and optionally supply the description to be displayed in the help.
|
|
850
|
-
*
|
|
851
|
-
* @param {*} value
|
|
852
|
-
* @param {string} [description]
|
|
853
|
-
* @return {Option}
|
|
854
|
-
*/
|
|
855
|
-
default(value, description) {
|
|
856
|
-
this.defaultValue = value;
|
|
857
|
-
this.defaultValueDescription = description;
|
|
858
|
-
return this;
|
|
859
|
-
}
|
|
860
|
-
/**
|
|
861
|
-
* Preset to use when option used without option-argument, especially optional but also boolean and negated.
|
|
862
|
-
* The custom processing (parseArg) is called.
|
|
863
|
-
*
|
|
864
|
-
* @example
|
|
865
|
-
* new Option('--color').default('GREYSCALE').preset('RGB');
|
|
866
|
-
* new Option('--donate [amount]').preset('20').argParser(parseFloat);
|
|
867
|
-
*
|
|
868
|
-
* @param {*} arg
|
|
869
|
-
* @return {Option}
|
|
870
|
-
*/
|
|
871
|
-
preset(arg) {
|
|
872
|
-
this.presetArg = arg;
|
|
873
|
-
return this;
|
|
874
|
-
}
|
|
875
|
-
/**
|
|
876
|
-
* Add option name(s) that conflict with this option.
|
|
877
|
-
* An error will be displayed if conflicting options are found during parsing.
|
|
878
|
-
*
|
|
879
|
-
* @example
|
|
880
|
-
* new Option('--rgb').conflicts('cmyk');
|
|
881
|
-
* new Option('--js').conflicts(['ts', 'jsx']);
|
|
882
|
-
*
|
|
883
|
-
* @param {(string | string[])} names
|
|
884
|
-
* @return {Option}
|
|
885
|
-
*/
|
|
886
|
-
conflicts(names) {
|
|
887
|
-
this.conflictsWith = this.conflictsWith.concat(names);
|
|
888
|
-
return this;
|
|
889
|
-
}
|
|
890
|
-
/**
|
|
891
|
-
* Specify implied option values for when this option is set and the implied options are not.
|
|
892
|
-
*
|
|
893
|
-
* The custom processing (parseArg) is not called on the implied values.
|
|
894
|
-
*
|
|
895
|
-
* @example
|
|
896
|
-
* program
|
|
897
|
-
* .addOption(new Option('--log', 'write logging information to file'))
|
|
898
|
-
* .addOption(new Option('--trace', 'log extra details').implies({ log: 'trace.txt' }));
|
|
899
|
-
*
|
|
900
|
-
* @param {object} impliedOptionValues
|
|
901
|
-
* @return {Option}
|
|
902
|
-
*/
|
|
903
|
-
implies(impliedOptionValues) {
|
|
904
|
-
let newImplied = impliedOptionValues;
|
|
905
|
-
if (typeof impliedOptionValues === "string") {
|
|
906
|
-
newImplied = { [impliedOptionValues]: true };
|
|
907
|
-
}
|
|
908
|
-
this.implied = Object.assign(this.implied || {}, newImplied);
|
|
909
|
-
return this;
|
|
910
|
-
}
|
|
911
|
-
/**
|
|
912
|
-
* Set environment variable to check for option value.
|
|
913
|
-
*
|
|
914
|
-
* An environment variable is only used if when processed the current option value is
|
|
915
|
-
* undefined, or the source of the current value is 'default' or 'config' or 'env'.
|
|
916
|
-
*
|
|
917
|
-
* @param {string} name
|
|
918
|
-
* @return {Option}
|
|
919
|
-
*/
|
|
920
|
-
env(name) {
|
|
921
|
-
this.envVar = name;
|
|
922
|
-
return this;
|
|
923
|
-
}
|
|
924
|
-
/**
|
|
925
|
-
* Set the custom handler for processing CLI option arguments into option values.
|
|
926
|
-
*
|
|
927
|
-
* @param {Function} [fn]
|
|
928
|
-
* @return {Option}
|
|
929
|
-
*/
|
|
930
|
-
argParser(fn) {
|
|
931
|
-
this.parseArg = fn;
|
|
932
|
-
return this;
|
|
933
|
-
}
|
|
934
|
-
/**
|
|
935
|
-
* Whether the option is mandatory and must have a value after parsing.
|
|
936
|
-
*
|
|
937
|
-
* @param {boolean} [mandatory=true]
|
|
938
|
-
* @return {Option}
|
|
939
|
-
*/
|
|
940
|
-
makeOptionMandatory(mandatory = true) {
|
|
941
|
-
this.mandatory = !!mandatory;
|
|
942
|
-
return this;
|
|
943
|
-
}
|
|
944
|
-
/**
|
|
945
|
-
* Hide option in help.
|
|
946
|
-
*
|
|
947
|
-
* @param {boolean} [hide=true]
|
|
948
|
-
* @return {Option}
|
|
949
|
-
*/
|
|
950
|
-
hideHelp(hide = true) {
|
|
951
|
-
this.hidden = !!hide;
|
|
952
|
-
return this;
|
|
953
|
-
}
|
|
954
|
-
/**
|
|
955
|
-
* @package
|
|
956
|
-
*/
|
|
957
|
-
_collectValue(value, previous) {
|
|
958
|
-
if (previous === this.defaultValue || !Array.isArray(previous)) {
|
|
959
|
-
return [value];
|
|
960
|
-
}
|
|
961
|
-
previous.push(value);
|
|
962
|
-
return previous;
|
|
963
|
-
}
|
|
964
|
-
/**
|
|
965
|
-
* Only allow option value to be one of choices.
|
|
966
|
-
*
|
|
967
|
-
* @param {string[]} values
|
|
968
|
-
* @return {Option}
|
|
969
|
-
*/
|
|
970
|
-
choices(values) {
|
|
971
|
-
this.argChoices = values.slice();
|
|
972
|
-
this.parseArg = (arg, previous) => {
|
|
973
|
-
if (!this.argChoices.includes(arg)) {
|
|
974
|
-
throw new InvalidArgumentError2(
|
|
975
|
-
`Allowed choices are ${this.argChoices.join(", ")}.`
|
|
976
|
-
);
|
|
977
|
-
}
|
|
978
|
-
if (this.variadic) {
|
|
979
|
-
return this._collectValue(arg, previous);
|
|
980
|
-
}
|
|
981
|
-
return arg;
|
|
982
|
-
};
|
|
983
|
-
return this;
|
|
984
|
-
}
|
|
985
|
-
/**
|
|
986
|
-
* Return option name.
|
|
987
|
-
*
|
|
988
|
-
* @return {string}
|
|
989
|
-
*/
|
|
990
|
-
name() {
|
|
991
|
-
if (this.long) {
|
|
992
|
-
return this.long.replace(/^--/, "");
|
|
993
|
-
}
|
|
994
|
-
return this.short.replace(/^-/, "");
|
|
995
|
-
}
|
|
996
|
-
/**
|
|
997
|
-
* Return option name, in a camelcase format that can be used
|
|
998
|
-
* as an object attribute key.
|
|
999
|
-
*
|
|
1000
|
-
* @return {string}
|
|
1001
|
-
*/
|
|
1002
|
-
attributeName() {
|
|
1003
|
-
if (this.negate) {
|
|
1004
|
-
return camelcase(this.name().replace(/^no-/, ""));
|
|
1005
|
-
}
|
|
1006
|
-
return camelcase(this.name());
|
|
1007
|
-
}
|
|
1008
|
-
/**
|
|
1009
|
-
* Set the help group heading.
|
|
1010
|
-
*
|
|
1011
|
-
* @param {string} heading
|
|
1012
|
-
* @return {Option}
|
|
1013
|
-
*/
|
|
1014
|
-
helpGroup(heading) {
|
|
1015
|
-
this.helpGroupHeading = heading;
|
|
1016
|
-
return this;
|
|
1017
|
-
}
|
|
1018
|
-
/**
|
|
1019
|
-
* Check if `arg` matches the short or long flag.
|
|
1020
|
-
*
|
|
1021
|
-
* @param {string} arg
|
|
1022
|
-
* @return {boolean}
|
|
1023
|
-
* @package
|
|
1024
|
-
*/
|
|
1025
|
-
is(arg) {
|
|
1026
|
-
return this.short === arg || this.long === arg;
|
|
1027
|
-
}
|
|
1028
|
-
/**
|
|
1029
|
-
* Return whether a boolean option.
|
|
1030
|
-
*
|
|
1031
|
-
* Options are one of boolean, negated, required argument, or optional argument.
|
|
1032
|
-
*
|
|
1033
|
-
* @return {boolean}
|
|
1034
|
-
* @package
|
|
1035
|
-
*/
|
|
1036
|
-
isBoolean() {
|
|
1037
|
-
return !this.required && !this.optional && !this.negate;
|
|
1038
|
-
}
|
|
1039
|
-
};
|
|
1040
|
-
var DualOptions = class {
|
|
1041
|
-
/**
|
|
1042
|
-
* @param {Option[]} options
|
|
1043
|
-
*/
|
|
1044
|
-
constructor(options) {
|
|
1045
|
-
this.positiveOptions = /* @__PURE__ */ new Map();
|
|
1046
|
-
this.negativeOptions = /* @__PURE__ */ new Map();
|
|
1047
|
-
this.dualOptions = /* @__PURE__ */ new Set();
|
|
1048
|
-
options.forEach((option) => {
|
|
1049
|
-
if (option.negate) {
|
|
1050
|
-
this.negativeOptions.set(option.attributeName(), option);
|
|
1051
|
-
} else {
|
|
1052
|
-
this.positiveOptions.set(option.attributeName(), option);
|
|
1053
|
-
}
|
|
1054
|
-
});
|
|
1055
|
-
this.negativeOptions.forEach((value, key) => {
|
|
1056
|
-
if (this.positiveOptions.has(key)) {
|
|
1057
|
-
this.dualOptions.add(key);
|
|
1058
|
-
}
|
|
1059
|
-
});
|
|
1060
|
-
}
|
|
1061
|
-
/**
|
|
1062
|
-
* Did the value come from the option, and not from possible matching dual option?
|
|
1063
|
-
*
|
|
1064
|
-
* @param {*} value
|
|
1065
|
-
* @param {Option} option
|
|
1066
|
-
* @returns {boolean}
|
|
1067
|
-
*/
|
|
1068
|
-
valueFromOption(value, option) {
|
|
1069
|
-
const optionKey = option.attributeName();
|
|
1070
|
-
if (!this.dualOptions.has(optionKey)) return true;
|
|
1071
|
-
const preset = this.negativeOptions.get(optionKey).presetArg;
|
|
1072
|
-
const negativeValue = preset !== void 0 ? preset : false;
|
|
1073
|
-
return option.negate === (negativeValue === value);
|
|
1074
|
-
}
|
|
1075
|
-
};
|
|
1076
|
-
function camelcase(str3) {
|
|
1077
|
-
return str3.split("-").reduce((str4, word) => {
|
|
1078
|
-
return str4 + word[0].toUpperCase() + word.slice(1);
|
|
1079
|
-
});
|
|
1080
|
-
}
|
|
1081
|
-
function splitOptionFlags(flags) {
|
|
1082
|
-
let shortFlag;
|
|
1083
|
-
let longFlag;
|
|
1084
|
-
const shortFlagExp = /^-[^-]$/;
|
|
1085
|
-
const longFlagExp = /^--[^-]/;
|
|
1086
|
-
const flagParts = flags.split(/[ |,]+/).concat("guard");
|
|
1087
|
-
if (shortFlagExp.test(flagParts[0])) shortFlag = flagParts.shift();
|
|
1088
|
-
if (longFlagExp.test(flagParts[0])) longFlag = flagParts.shift();
|
|
1089
|
-
if (!shortFlag && shortFlagExp.test(flagParts[0]))
|
|
1090
|
-
shortFlag = flagParts.shift();
|
|
1091
|
-
if (!shortFlag && longFlagExp.test(flagParts[0])) {
|
|
1092
|
-
shortFlag = longFlag;
|
|
1093
|
-
longFlag = flagParts.shift();
|
|
1094
|
-
}
|
|
1095
|
-
if (flagParts[0].startsWith("-")) {
|
|
1096
|
-
const unsupportedFlag = flagParts[0];
|
|
1097
|
-
const baseError = `option creation failed due to '${unsupportedFlag}' in option flags '${flags}'`;
|
|
1098
|
-
if (/^-[^-][^-]/.test(unsupportedFlag))
|
|
1099
|
-
throw new Error(
|
|
1100
|
-
`${baseError}
|
|
1101
|
-
- a short flag is a single dash and a single character
|
|
1102
|
-
- either use a single dash and a single character (for a short flag)
|
|
1103
|
-
- or use a double dash for a long option (and can have two, like '--ws, --workspace')`
|
|
1104
|
-
);
|
|
1105
|
-
if (shortFlagExp.test(unsupportedFlag))
|
|
1106
|
-
throw new Error(`${baseError}
|
|
1107
|
-
- too many short flags`);
|
|
1108
|
-
if (longFlagExp.test(unsupportedFlag))
|
|
1109
|
-
throw new Error(`${baseError}
|
|
1110
|
-
- too many long flags`);
|
|
1111
|
-
throw new Error(`${baseError}
|
|
1112
|
-
- unrecognised flag format`);
|
|
1113
|
-
}
|
|
1114
|
-
if (shortFlag === void 0 && longFlag === void 0)
|
|
1115
|
-
throw new Error(
|
|
1116
|
-
`option creation failed due to no flags found in '${flags}'.`
|
|
1117
|
-
);
|
|
1118
|
-
return { shortFlag, longFlag };
|
|
1119
|
-
}
|
|
1120
|
-
exports2.Option = Option2;
|
|
1121
|
-
exports2.DualOptions = DualOptions;
|
|
1122
|
-
}
|
|
1123
|
-
});
|
|
1124
|
-
|
|
1125
|
-
// ../../node_modules/.pnpm/commander@14.0.3/node_modules/commander/lib/suggestSimilar.js
|
|
1126
|
-
var require_suggestSimilar = __commonJS({
|
|
1127
|
-
"../../node_modules/.pnpm/commander@14.0.3/node_modules/commander/lib/suggestSimilar.js"(exports2) {
|
|
1128
|
-
"use strict";
|
|
1129
|
-
var maxDistance = 3;
|
|
1130
|
-
function editDistance(a, b) {
|
|
1131
|
-
if (Math.abs(a.length - b.length) > maxDistance)
|
|
1132
|
-
return Math.max(a.length, b.length);
|
|
1133
|
-
const d = [];
|
|
1134
|
-
for (let i = 0; i <= a.length; i++) {
|
|
1135
|
-
d[i] = [i];
|
|
1136
|
-
}
|
|
1137
|
-
for (let j = 0; j <= b.length; j++) {
|
|
1138
|
-
d[0][j] = j;
|
|
1139
|
-
}
|
|
1140
|
-
for (let j = 1; j <= b.length; j++) {
|
|
1141
|
-
for (let i = 1; i <= a.length; i++) {
|
|
1142
|
-
let cost = 1;
|
|
1143
|
-
if (a[i - 1] === b[j - 1]) {
|
|
1144
|
-
cost = 0;
|
|
1145
|
-
} else {
|
|
1146
|
-
cost = 1;
|
|
1147
|
-
}
|
|
1148
|
-
d[i][j] = Math.min(
|
|
1149
|
-
d[i - 1][j] + 1,
|
|
1150
|
-
// deletion
|
|
1151
|
-
d[i][j - 1] + 1,
|
|
1152
|
-
// insertion
|
|
1153
|
-
d[i - 1][j - 1] + cost
|
|
1154
|
-
// substitution
|
|
1155
|
-
);
|
|
1156
|
-
if (i > 1 && j > 1 && a[i - 1] === b[j - 2] && a[i - 2] === b[j - 1]) {
|
|
1157
|
-
d[i][j] = Math.min(d[i][j], d[i - 2][j - 2] + 1);
|
|
1158
|
-
}
|
|
1159
|
-
}
|
|
1160
|
-
}
|
|
1161
|
-
return d[a.length][b.length];
|
|
1162
|
-
}
|
|
1163
|
-
function suggestSimilar(word, candidates) {
|
|
1164
|
-
if (!candidates || candidates.length === 0) return "";
|
|
1165
|
-
candidates = Array.from(new Set(candidates));
|
|
1166
|
-
const searchingOptions = word.startsWith("--");
|
|
1167
|
-
if (searchingOptions) {
|
|
1168
|
-
word = word.slice(2);
|
|
1169
|
-
candidates = candidates.map((candidate) => candidate.slice(2));
|
|
1170
|
-
}
|
|
1171
|
-
let similar = [];
|
|
1172
|
-
let bestDistance = maxDistance;
|
|
1173
|
-
const minSimilarity = 0.4;
|
|
1174
|
-
candidates.forEach((candidate) => {
|
|
1175
|
-
if (candidate.length <= 1) return;
|
|
1176
|
-
const distance = editDistance(word, candidate);
|
|
1177
|
-
const length = Math.max(word.length, candidate.length);
|
|
1178
|
-
const similarity = (length - distance) / length;
|
|
1179
|
-
if (similarity > minSimilarity) {
|
|
1180
|
-
if (distance < bestDistance) {
|
|
1181
|
-
bestDistance = distance;
|
|
1182
|
-
similar = [candidate];
|
|
1183
|
-
} else if (distance === bestDistance) {
|
|
1184
|
-
similar.push(candidate);
|
|
1185
|
-
}
|
|
1186
|
-
}
|
|
1187
|
-
});
|
|
1188
|
-
similar.sort((a, b) => a.localeCompare(b));
|
|
1189
|
-
if (searchingOptions) {
|
|
1190
|
-
similar = similar.map((candidate) => `--${candidate}`);
|
|
1191
|
-
}
|
|
1192
|
-
if (similar.length > 1) {
|
|
1193
|
-
return `
|
|
1194
|
-
(Did you mean one of ${similar.join(", ")}?)`;
|
|
1195
|
-
}
|
|
1196
|
-
if (similar.length === 1) {
|
|
1197
|
-
return `
|
|
1198
|
-
(Did you mean ${similar[0]}?)`;
|
|
1199
|
-
}
|
|
1200
|
-
return "";
|
|
1201
|
-
}
|
|
1202
|
-
exports2.suggestSimilar = suggestSimilar;
|
|
1203
|
-
}
|
|
1204
|
-
});
|
|
1205
|
-
|
|
1206
|
-
// ../../node_modules/.pnpm/commander@14.0.3/node_modules/commander/lib/command.js
|
|
1207
|
-
var require_command = __commonJS({
|
|
1208
|
-
"../../node_modules/.pnpm/commander@14.0.3/node_modules/commander/lib/command.js"(exports2) {
|
|
1209
|
-
"use strict";
|
|
1210
|
-
var EventEmitter = __require("events").EventEmitter;
|
|
1211
|
-
var childProcess = __require("child_process");
|
|
1212
|
-
var path18 = __require("path");
|
|
1213
|
-
var fs15 = __require("fs");
|
|
1214
|
-
var process2 = __require("process");
|
|
1215
|
-
var { Argument: Argument2, humanReadableArgName } = require_argument();
|
|
1216
|
-
var { CommanderError: CommanderError2 } = require_error();
|
|
1217
|
-
var { Help: Help2, stripColor } = require_help();
|
|
1218
|
-
var { Option: Option2, DualOptions } = require_option();
|
|
1219
|
-
var { suggestSimilar } = require_suggestSimilar();
|
|
1220
|
-
var Command2 = class _Command extends EventEmitter {
|
|
1221
|
-
/**
|
|
1222
|
-
* Initialize a new `Command`.
|
|
1223
|
-
*
|
|
1224
|
-
* @param {string} [name]
|
|
1225
|
-
*/
|
|
1226
|
-
constructor(name) {
|
|
1227
|
-
super();
|
|
1228
|
-
this.commands = [];
|
|
1229
|
-
this.options = [];
|
|
1230
|
-
this.parent = null;
|
|
1231
|
-
this._allowUnknownOption = false;
|
|
1232
|
-
this._allowExcessArguments = false;
|
|
1233
|
-
this.registeredArguments = [];
|
|
1234
|
-
this._args = this.registeredArguments;
|
|
1235
|
-
this.args = [];
|
|
1236
|
-
this.rawArgs = [];
|
|
1237
|
-
this.processedArgs = [];
|
|
1238
|
-
this._scriptPath = null;
|
|
1239
|
-
this._name = name || "";
|
|
1240
|
-
this._optionValues = {};
|
|
1241
|
-
this._optionValueSources = {};
|
|
1242
|
-
this._storeOptionsAsProperties = false;
|
|
1243
|
-
this._actionHandler = null;
|
|
1244
|
-
this._executableHandler = false;
|
|
1245
|
-
this._executableFile = null;
|
|
1246
|
-
this._executableDir = null;
|
|
1247
|
-
this._defaultCommandName = null;
|
|
1248
|
-
this._exitCallback = null;
|
|
1249
|
-
this._aliases = [];
|
|
1250
|
-
this._combineFlagAndOptionalValue = true;
|
|
1251
|
-
this._description = "";
|
|
1252
|
-
this._summary = "";
|
|
1253
|
-
this._argsDescription = void 0;
|
|
1254
|
-
this._enablePositionalOptions = false;
|
|
1255
|
-
this._passThroughOptions = false;
|
|
1256
|
-
this._lifeCycleHooks = {};
|
|
1257
|
-
this._showHelpAfterError = false;
|
|
1258
|
-
this._showSuggestionAfterError = true;
|
|
1259
|
-
this._savedState = null;
|
|
1260
|
-
this._outputConfiguration = {
|
|
1261
|
-
writeOut: (str3) => process2.stdout.write(str3),
|
|
1262
|
-
writeErr: (str3) => process2.stderr.write(str3),
|
|
1263
|
-
outputError: (str3, write) => write(str3),
|
|
1264
|
-
getOutHelpWidth: () => process2.stdout.isTTY ? process2.stdout.columns : void 0,
|
|
1265
|
-
getErrHelpWidth: () => process2.stderr.isTTY ? process2.stderr.columns : void 0,
|
|
1266
|
-
getOutHasColors: () => useColor() ?? (process2.stdout.isTTY && process2.stdout.hasColors?.()),
|
|
1267
|
-
getErrHasColors: () => useColor() ?? (process2.stderr.isTTY && process2.stderr.hasColors?.()),
|
|
1268
|
-
stripColor: (str3) => stripColor(str3)
|
|
1269
|
-
};
|
|
1270
|
-
this._hidden = false;
|
|
1271
|
-
this._helpOption = void 0;
|
|
1272
|
-
this._addImplicitHelpCommand = void 0;
|
|
1273
|
-
this._helpCommand = void 0;
|
|
1274
|
-
this._helpConfiguration = {};
|
|
1275
|
-
this._helpGroupHeading = void 0;
|
|
1276
|
-
this._defaultCommandGroup = void 0;
|
|
1277
|
-
this._defaultOptionGroup = void 0;
|
|
1278
|
-
}
|
|
1279
|
-
/**
|
|
1280
|
-
* Copy settings that are useful to have in common across root command and subcommands.
|
|
1281
|
-
*
|
|
1282
|
-
* (Used internally when adding a command using `.command()` so subcommands inherit parent settings.)
|
|
1283
|
-
*
|
|
1284
|
-
* @param {Command} sourceCommand
|
|
1285
|
-
* @return {Command} `this` command for chaining
|
|
1286
|
-
*/
|
|
1287
|
-
copyInheritedSettings(sourceCommand) {
|
|
1288
|
-
this._outputConfiguration = sourceCommand._outputConfiguration;
|
|
1289
|
-
this._helpOption = sourceCommand._helpOption;
|
|
1290
|
-
this._helpCommand = sourceCommand._helpCommand;
|
|
1291
|
-
this._helpConfiguration = sourceCommand._helpConfiguration;
|
|
1292
|
-
this._exitCallback = sourceCommand._exitCallback;
|
|
1293
|
-
this._storeOptionsAsProperties = sourceCommand._storeOptionsAsProperties;
|
|
1294
|
-
this._combineFlagAndOptionalValue = sourceCommand._combineFlagAndOptionalValue;
|
|
1295
|
-
this._allowExcessArguments = sourceCommand._allowExcessArguments;
|
|
1296
|
-
this._enablePositionalOptions = sourceCommand._enablePositionalOptions;
|
|
1297
|
-
this._showHelpAfterError = sourceCommand._showHelpAfterError;
|
|
1298
|
-
this._showSuggestionAfterError = sourceCommand._showSuggestionAfterError;
|
|
1299
|
-
return this;
|
|
1300
|
-
}
|
|
1301
|
-
/**
|
|
1302
|
-
* @returns {Command[]}
|
|
1303
|
-
* @private
|
|
1304
|
-
*/
|
|
1305
|
-
_getCommandAndAncestors() {
|
|
1306
|
-
const result = [];
|
|
1307
|
-
for (let command = this; command; command = command.parent) {
|
|
1308
|
-
result.push(command);
|
|
1309
|
-
}
|
|
1310
|
-
return result;
|
|
1311
|
-
}
|
|
1312
|
-
/**
|
|
1313
|
-
* Define a command.
|
|
1314
|
-
*
|
|
1315
|
-
* There are two styles of command: pay attention to where to put the description.
|
|
1316
|
-
*
|
|
1317
|
-
* @example
|
|
1318
|
-
* // Command implemented using action handler (description is supplied separately to `.command`)
|
|
1319
|
-
* program
|
|
1320
|
-
* .command('clone <source> [destination]')
|
|
1321
|
-
* .description('clone a repository into a newly created directory')
|
|
1322
|
-
* .action((source, destination) => {
|
|
1323
|
-
* console.log('clone command called');
|
|
1324
|
-
* });
|
|
1325
|
-
*
|
|
1326
|
-
* // Command implemented using separate executable file (description is second parameter to `.command`)
|
|
1327
|
-
* program
|
|
1328
|
-
* .command('start <service>', 'start named service')
|
|
1329
|
-
* .command('stop [service]', 'stop named service, or all if no name supplied');
|
|
1330
|
-
*
|
|
1331
|
-
* @param {string} nameAndArgs - command name and arguments, args are `<required>` or `[optional]` and last may also be `variadic...`
|
|
1332
|
-
* @param {(object | string)} [actionOptsOrExecDesc] - configuration options (for action), or description (for executable)
|
|
1333
|
-
* @param {object} [execOpts] - configuration options (for executable)
|
|
1334
|
-
* @return {Command} returns new command for action handler, or `this` for executable command
|
|
1335
|
-
*/
|
|
1336
|
-
command(nameAndArgs, actionOptsOrExecDesc, execOpts) {
|
|
1337
|
-
let desc = actionOptsOrExecDesc;
|
|
1338
|
-
let opts = execOpts;
|
|
1339
|
-
if (typeof desc === "object" && desc !== null) {
|
|
1340
|
-
opts = desc;
|
|
1341
|
-
desc = null;
|
|
1342
|
-
}
|
|
1343
|
-
opts = opts || {};
|
|
1344
|
-
const [, name, args] = nameAndArgs.match(/([^ ]+) *(.*)/);
|
|
1345
|
-
const cmd = this.createCommand(name);
|
|
1346
|
-
if (desc) {
|
|
1347
|
-
cmd.description(desc);
|
|
1348
|
-
cmd._executableHandler = true;
|
|
1349
|
-
}
|
|
1350
|
-
if (opts.isDefault) this._defaultCommandName = cmd._name;
|
|
1351
|
-
cmd._hidden = !!(opts.noHelp || opts.hidden);
|
|
1352
|
-
cmd._executableFile = opts.executableFile || null;
|
|
1353
|
-
if (args) cmd.arguments(args);
|
|
1354
|
-
this._registerCommand(cmd);
|
|
1355
|
-
cmd.parent = this;
|
|
1356
|
-
cmd.copyInheritedSettings(this);
|
|
1357
|
-
if (desc) return this;
|
|
1358
|
-
return cmd;
|
|
1359
|
-
}
|
|
1360
|
-
/**
|
|
1361
|
-
* Factory routine to create a new unattached command.
|
|
1362
|
-
*
|
|
1363
|
-
* See .command() for creating an attached subcommand, which uses this routine to
|
|
1364
|
-
* create the command. You can override createCommand to customise subcommands.
|
|
1365
|
-
*
|
|
1366
|
-
* @param {string} [name]
|
|
1367
|
-
* @return {Command} new command
|
|
1368
|
-
*/
|
|
1369
|
-
createCommand(name) {
|
|
1370
|
-
return new _Command(name);
|
|
1371
|
-
}
|
|
1372
|
-
/**
|
|
1373
|
-
* You can customise the help with a subclass of Help by overriding createHelp,
|
|
1374
|
-
* or by overriding Help properties using configureHelp().
|
|
1375
|
-
*
|
|
1376
|
-
* @return {Help}
|
|
1377
|
-
*/
|
|
1378
|
-
createHelp() {
|
|
1379
|
-
return Object.assign(new Help2(), this.configureHelp());
|
|
1380
|
-
}
|
|
1381
|
-
/**
|
|
1382
|
-
* You can customise the help by overriding Help properties using configureHelp(),
|
|
1383
|
-
* or with a subclass of Help by overriding createHelp().
|
|
1384
|
-
*
|
|
1385
|
-
* @param {object} [configuration] - configuration options
|
|
1386
|
-
* @return {(Command | object)} `this` command for chaining, or stored configuration
|
|
1387
|
-
*/
|
|
1388
|
-
configureHelp(configuration) {
|
|
1389
|
-
if (configuration === void 0) return this._helpConfiguration;
|
|
1390
|
-
this._helpConfiguration = configuration;
|
|
1391
|
-
return this;
|
|
1392
|
-
}
|
|
1393
|
-
/**
|
|
1394
|
-
* The default output goes to stdout and stderr. You can customise this for special
|
|
1395
|
-
* applications. You can also customise the display of errors by overriding outputError.
|
|
1396
|
-
*
|
|
1397
|
-
* The configuration properties are all functions:
|
|
1398
|
-
*
|
|
1399
|
-
* // change how output being written, defaults to stdout and stderr
|
|
1400
|
-
* writeOut(str)
|
|
1401
|
-
* writeErr(str)
|
|
1402
|
-
* // change how output being written for errors, defaults to writeErr
|
|
1403
|
-
* outputError(str, write) // used for displaying errors and not used for displaying help
|
|
1404
|
-
* // specify width for wrapping help
|
|
1405
|
-
* getOutHelpWidth()
|
|
1406
|
-
* getErrHelpWidth()
|
|
1407
|
-
* // color support, currently only used with Help
|
|
1408
|
-
* getOutHasColors()
|
|
1409
|
-
* getErrHasColors()
|
|
1410
|
-
* stripColor() // used to remove ANSI escape codes if output does not have colors
|
|
1411
|
-
*
|
|
1412
|
-
* @param {object} [configuration] - configuration options
|
|
1413
|
-
* @return {(Command | object)} `this` command for chaining, or stored configuration
|
|
1414
|
-
*/
|
|
1415
|
-
configureOutput(configuration) {
|
|
1416
|
-
if (configuration === void 0) return this._outputConfiguration;
|
|
1417
|
-
this._outputConfiguration = {
|
|
1418
|
-
...this._outputConfiguration,
|
|
1419
|
-
...configuration
|
|
1420
|
-
};
|
|
1421
|
-
return this;
|
|
1422
|
-
}
|
|
1423
|
-
/**
|
|
1424
|
-
* Display the help or a custom message after an error occurs.
|
|
1425
|
-
*
|
|
1426
|
-
* @param {(boolean|string)} [displayHelp]
|
|
1427
|
-
* @return {Command} `this` command for chaining
|
|
1428
|
-
*/
|
|
1429
|
-
showHelpAfterError(displayHelp = true) {
|
|
1430
|
-
if (typeof displayHelp !== "string") displayHelp = !!displayHelp;
|
|
1431
|
-
this._showHelpAfterError = displayHelp;
|
|
1432
|
-
return this;
|
|
1433
|
-
}
|
|
1434
|
-
/**
|
|
1435
|
-
* Display suggestion of similar commands for unknown commands, or options for unknown options.
|
|
1436
|
-
*
|
|
1437
|
-
* @param {boolean} [displaySuggestion]
|
|
1438
|
-
* @return {Command} `this` command for chaining
|
|
1439
|
-
*/
|
|
1440
|
-
showSuggestionAfterError(displaySuggestion = true) {
|
|
1441
|
-
this._showSuggestionAfterError = !!displaySuggestion;
|
|
1442
|
-
return this;
|
|
1443
|
-
}
|
|
1444
|
-
/**
|
|
1445
|
-
* Add a prepared subcommand.
|
|
1446
|
-
*
|
|
1447
|
-
* See .command() for creating an attached subcommand which inherits settings from its parent.
|
|
1448
|
-
*
|
|
1449
|
-
* @param {Command} cmd - new subcommand
|
|
1450
|
-
* @param {object} [opts] - configuration options
|
|
1451
|
-
* @return {Command} `this` command for chaining
|
|
1452
|
-
*/
|
|
1453
|
-
addCommand(cmd, opts) {
|
|
1454
|
-
if (!cmd._name) {
|
|
1455
|
-
throw new Error(`Command passed to .addCommand() must have a name
|
|
1456
|
-
- specify the name in Command constructor or using .name()`);
|
|
1457
|
-
}
|
|
1458
|
-
opts = opts || {};
|
|
1459
|
-
if (opts.isDefault) this._defaultCommandName = cmd._name;
|
|
1460
|
-
if (opts.noHelp || opts.hidden) cmd._hidden = true;
|
|
1461
|
-
this._registerCommand(cmd);
|
|
1462
|
-
cmd.parent = this;
|
|
1463
|
-
cmd._checkForBrokenPassThrough();
|
|
1464
|
-
return this;
|
|
1465
|
-
}
|
|
1466
|
-
/**
|
|
1467
|
-
* Factory routine to create a new unattached argument.
|
|
1468
|
-
*
|
|
1469
|
-
* See .argument() for creating an attached argument, which uses this routine to
|
|
1470
|
-
* create the argument. You can override createArgument to return a custom argument.
|
|
1471
|
-
*
|
|
1472
|
-
* @param {string} name
|
|
1473
|
-
* @param {string} [description]
|
|
1474
|
-
* @return {Argument} new argument
|
|
1475
|
-
*/
|
|
1476
|
-
createArgument(name, description) {
|
|
1477
|
-
return new Argument2(name, description);
|
|
1478
|
-
}
|
|
1479
|
-
/**
|
|
1480
|
-
* Define argument syntax for command.
|
|
1481
|
-
*
|
|
1482
|
-
* The default is that the argument is required, and you can explicitly
|
|
1483
|
-
* indicate this with <> around the name. Put [] around the name for an optional argument.
|
|
1484
|
-
*
|
|
1485
|
-
* @example
|
|
1486
|
-
* program.argument('<input-file>');
|
|
1487
|
-
* program.argument('[output-file]');
|
|
1488
|
-
*
|
|
1489
|
-
* @param {string} name
|
|
1490
|
-
* @param {string} [description]
|
|
1491
|
-
* @param {(Function|*)} [parseArg] - custom argument processing function or default value
|
|
1492
|
-
* @param {*} [defaultValue]
|
|
1493
|
-
* @return {Command} `this` command for chaining
|
|
1494
|
-
*/
|
|
1495
|
-
argument(name, description, parseArg, defaultValue) {
|
|
1496
|
-
const argument = this.createArgument(name, description);
|
|
1497
|
-
if (typeof parseArg === "function") {
|
|
1498
|
-
argument.default(defaultValue).argParser(parseArg);
|
|
1499
|
-
} else {
|
|
1500
|
-
argument.default(parseArg);
|
|
1501
|
-
}
|
|
1502
|
-
this.addArgument(argument);
|
|
1503
|
-
return this;
|
|
1504
|
-
}
|
|
1505
|
-
/**
|
|
1506
|
-
* Define argument syntax for command, adding multiple at once (without descriptions).
|
|
1507
|
-
*
|
|
1508
|
-
* See also .argument().
|
|
1509
|
-
*
|
|
1510
|
-
* @example
|
|
1511
|
-
* program.arguments('<cmd> [env]');
|
|
1512
|
-
*
|
|
1513
|
-
* @param {string} names
|
|
1514
|
-
* @return {Command} `this` command for chaining
|
|
1515
|
-
*/
|
|
1516
|
-
arguments(names) {
|
|
1517
|
-
names.trim().split(/ +/).forEach((detail) => {
|
|
1518
|
-
this.argument(detail);
|
|
1519
|
-
});
|
|
1520
|
-
return this;
|
|
1521
|
-
}
|
|
1522
|
-
/**
|
|
1523
|
-
* Define argument syntax for command, adding a prepared argument.
|
|
1524
|
-
*
|
|
1525
|
-
* @param {Argument} argument
|
|
1526
|
-
* @return {Command} `this` command for chaining
|
|
1527
|
-
*/
|
|
1528
|
-
addArgument(argument) {
|
|
1529
|
-
const previousArgument = this.registeredArguments.slice(-1)[0];
|
|
1530
|
-
if (previousArgument?.variadic) {
|
|
1531
|
-
throw new Error(
|
|
1532
|
-
`only the last argument can be variadic '${previousArgument.name()}'`
|
|
1533
|
-
);
|
|
1534
|
-
}
|
|
1535
|
-
if (argument.required && argument.defaultValue !== void 0 && argument.parseArg === void 0) {
|
|
1536
|
-
throw new Error(
|
|
1537
|
-
`a default value for a required argument is never used: '${argument.name()}'`
|
|
1538
|
-
);
|
|
1539
|
-
}
|
|
1540
|
-
this.registeredArguments.push(argument);
|
|
1541
|
-
return this;
|
|
1542
|
-
}
|
|
1543
|
-
/**
|
|
1544
|
-
* Customise or override default help command. By default a help command is automatically added if your command has subcommands.
|
|
1545
|
-
*
|
|
1546
|
-
* @example
|
|
1547
|
-
* program.helpCommand('help [cmd]');
|
|
1548
|
-
* program.helpCommand('help [cmd]', 'show help');
|
|
1549
|
-
* program.helpCommand(false); // suppress default help command
|
|
1550
|
-
* program.helpCommand(true); // add help command even if no subcommands
|
|
1551
|
-
*
|
|
1552
|
-
* @param {string|boolean} enableOrNameAndArgs - enable with custom name and/or arguments, or boolean to override whether added
|
|
1553
|
-
* @param {string} [description] - custom description
|
|
1554
|
-
* @return {Command} `this` command for chaining
|
|
1555
|
-
*/
|
|
1556
|
-
helpCommand(enableOrNameAndArgs, description) {
|
|
1557
|
-
if (typeof enableOrNameAndArgs === "boolean") {
|
|
1558
|
-
this._addImplicitHelpCommand = enableOrNameAndArgs;
|
|
1559
|
-
if (enableOrNameAndArgs && this._defaultCommandGroup) {
|
|
1560
|
-
this._initCommandGroup(this._getHelpCommand());
|
|
1561
|
-
}
|
|
1562
|
-
return this;
|
|
1563
|
-
}
|
|
1564
|
-
const nameAndArgs = enableOrNameAndArgs ?? "help [command]";
|
|
1565
|
-
const [, helpName, helpArgs] = nameAndArgs.match(/([^ ]+) *(.*)/);
|
|
1566
|
-
const helpDescription = description ?? "display help for command";
|
|
1567
|
-
const helpCommand = this.createCommand(helpName);
|
|
1568
|
-
helpCommand.helpOption(false);
|
|
1569
|
-
if (helpArgs) helpCommand.arguments(helpArgs);
|
|
1570
|
-
if (helpDescription) helpCommand.description(helpDescription);
|
|
1571
|
-
this._addImplicitHelpCommand = true;
|
|
1572
|
-
this._helpCommand = helpCommand;
|
|
1573
|
-
if (enableOrNameAndArgs || description) this._initCommandGroup(helpCommand);
|
|
1574
|
-
return this;
|
|
1575
|
-
}
|
|
1576
|
-
/**
|
|
1577
|
-
* Add prepared custom help command.
|
|
1578
|
-
*
|
|
1579
|
-
* @param {(Command|string|boolean)} helpCommand - custom help command, or deprecated enableOrNameAndArgs as for `.helpCommand()`
|
|
1580
|
-
* @param {string} [deprecatedDescription] - deprecated custom description used with custom name only
|
|
1581
|
-
* @return {Command} `this` command for chaining
|
|
1582
|
-
*/
|
|
1583
|
-
addHelpCommand(helpCommand, deprecatedDescription) {
|
|
1584
|
-
if (typeof helpCommand !== "object") {
|
|
1585
|
-
this.helpCommand(helpCommand, deprecatedDescription);
|
|
1586
|
-
return this;
|
|
1587
|
-
}
|
|
1588
|
-
this._addImplicitHelpCommand = true;
|
|
1589
|
-
this._helpCommand = helpCommand;
|
|
1590
|
-
this._initCommandGroup(helpCommand);
|
|
1591
|
-
return this;
|
|
1592
|
-
}
|
|
1593
|
-
/**
|
|
1594
|
-
* Lazy create help command.
|
|
1595
|
-
*
|
|
1596
|
-
* @return {(Command|null)}
|
|
1597
|
-
* @package
|
|
1598
|
-
*/
|
|
1599
|
-
_getHelpCommand() {
|
|
1600
|
-
const hasImplicitHelpCommand = this._addImplicitHelpCommand ?? (this.commands.length && !this._actionHandler && !this._findCommand("help"));
|
|
1601
|
-
if (hasImplicitHelpCommand) {
|
|
1602
|
-
if (this._helpCommand === void 0) {
|
|
1603
|
-
this.helpCommand(void 0, void 0);
|
|
1604
|
-
}
|
|
1605
|
-
return this._helpCommand;
|
|
1606
|
-
}
|
|
1607
|
-
return null;
|
|
1608
|
-
}
|
|
1609
|
-
/**
|
|
1610
|
-
* Add hook for life cycle event.
|
|
1611
|
-
*
|
|
1612
|
-
* @param {string} event
|
|
1613
|
-
* @param {Function} listener
|
|
1614
|
-
* @return {Command} `this` command for chaining
|
|
1615
|
-
*/
|
|
1616
|
-
hook(event, listener) {
|
|
1617
|
-
const allowedValues = ["preSubcommand", "preAction", "postAction"];
|
|
1618
|
-
if (!allowedValues.includes(event)) {
|
|
1619
|
-
throw new Error(`Unexpected value for event passed to hook : '${event}'.
|
|
1620
|
-
Expecting one of '${allowedValues.join("', '")}'`);
|
|
1621
|
-
}
|
|
1622
|
-
if (this._lifeCycleHooks[event]) {
|
|
1623
|
-
this._lifeCycleHooks[event].push(listener);
|
|
1624
|
-
} else {
|
|
1625
|
-
this._lifeCycleHooks[event] = [listener];
|
|
1626
|
-
}
|
|
1627
|
-
return this;
|
|
1628
|
-
}
|
|
1629
|
-
/**
|
|
1630
|
-
* Register callback to use as replacement for calling process.exit.
|
|
1631
|
-
*
|
|
1632
|
-
* @param {Function} [fn] optional callback which will be passed a CommanderError, defaults to throwing
|
|
1633
|
-
* @return {Command} `this` command for chaining
|
|
1634
|
-
*/
|
|
1635
|
-
exitOverride(fn) {
|
|
1636
|
-
if (fn) {
|
|
1637
|
-
this._exitCallback = fn;
|
|
1638
|
-
} else {
|
|
1639
|
-
this._exitCallback = (err) => {
|
|
1640
|
-
if (err.code !== "commander.executeSubCommandAsync") {
|
|
1641
|
-
throw err;
|
|
1642
|
-
} else {
|
|
1643
|
-
}
|
|
1644
|
-
};
|
|
1645
|
-
}
|
|
1646
|
-
return this;
|
|
1647
|
-
}
|
|
1648
|
-
/**
|
|
1649
|
-
* Call process.exit, and _exitCallback if defined.
|
|
1650
|
-
*
|
|
1651
|
-
* @param {number} exitCode exit code for using with process.exit
|
|
1652
|
-
* @param {string} code an id string representing the error
|
|
1653
|
-
* @param {string} message human-readable description of the error
|
|
1654
|
-
* @return never
|
|
1655
|
-
* @private
|
|
1656
|
-
*/
|
|
1657
|
-
_exit(exitCode3, code, message) {
|
|
1658
|
-
if (this._exitCallback) {
|
|
1659
|
-
this._exitCallback(new CommanderError2(exitCode3, code, message));
|
|
1660
|
-
}
|
|
1661
|
-
process2.exit(exitCode3);
|
|
1662
|
-
}
|
|
1663
|
-
/**
|
|
1664
|
-
* Register callback `fn` for the command.
|
|
1665
|
-
*
|
|
1666
|
-
* @example
|
|
1667
|
-
* program
|
|
1668
|
-
* .command('serve')
|
|
1669
|
-
* .description('start service')
|
|
1670
|
-
* .action(function() {
|
|
1671
|
-
* // do work here
|
|
1672
|
-
* });
|
|
1673
|
-
*
|
|
1674
|
-
* @param {Function} fn
|
|
1675
|
-
* @return {Command} `this` command for chaining
|
|
1676
|
-
*/
|
|
1677
|
-
action(fn) {
|
|
1678
|
-
const listener = (args) => {
|
|
1679
|
-
const expectedArgsCount = this.registeredArguments.length;
|
|
1680
|
-
const actionArgs = args.slice(0, expectedArgsCount);
|
|
1681
|
-
if (this._storeOptionsAsProperties) {
|
|
1682
|
-
actionArgs[expectedArgsCount] = this;
|
|
1683
|
-
} else {
|
|
1684
|
-
actionArgs[expectedArgsCount] = this.opts();
|
|
1685
|
-
}
|
|
1686
|
-
actionArgs.push(this);
|
|
1687
|
-
return fn.apply(this, actionArgs);
|
|
1688
|
-
};
|
|
1689
|
-
this._actionHandler = listener;
|
|
1690
|
-
return this;
|
|
1691
|
-
}
|
|
1692
|
-
/**
|
|
1693
|
-
* Factory routine to create a new unattached option.
|
|
1694
|
-
*
|
|
1695
|
-
* See .option() for creating an attached option, which uses this routine to
|
|
1696
|
-
* create the option. You can override createOption to return a custom option.
|
|
1697
|
-
*
|
|
1698
|
-
* @param {string} flags
|
|
1699
|
-
* @param {string} [description]
|
|
1700
|
-
* @return {Option} new option
|
|
1701
|
-
*/
|
|
1702
|
-
createOption(flags, description) {
|
|
1703
|
-
return new Option2(flags, description);
|
|
1704
|
-
}
|
|
1705
|
-
/**
|
|
1706
|
-
* Wrap parseArgs to catch 'commander.invalidArgument'.
|
|
1707
|
-
*
|
|
1708
|
-
* @param {(Option | Argument)} target
|
|
1709
|
-
* @param {string} value
|
|
1710
|
-
* @param {*} previous
|
|
1711
|
-
* @param {string} invalidArgumentMessage
|
|
1712
|
-
* @private
|
|
1713
|
-
*/
|
|
1714
|
-
_callParseArg(target, value, previous, invalidArgumentMessage) {
|
|
1715
|
-
try {
|
|
1716
|
-
return target.parseArg(value, previous);
|
|
1717
|
-
} catch (err) {
|
|
1718
|
-
if (err.code === "commander.invalidArgument") {
|
|
1719
|
-
const message = `${invalidArgumentMessage} ${err.message}`;
|
|
1720
|
-
this.error(message, { exitCode: err.exitCode, code: err.code });
|
|
1721
|
-
}
|
|
1722
|
-
throw err;
|
|
1723
|
-
}
|
|
1724
|
-
}
|
|
1725
|
-
/**
|
|
1726
|
-
* Check for option flag conflicts.
|
|
1727
|
-
* Register option if no conflicts found, or throw on conflict.
|
|
1728
|
-
*
|
|
1729
|
-
* @param {Option} option
|
|
1730
|
-
* @private
|
|
1731
|
-
*/
|
|
1732
|
-
_registerOption(option) {
|
|
1733
|
-
const matchingOption = option.short && this._findOption(option.short) || option.long && this._findOption(option.long);
|
|
1734
|
-
if (matchingOption) {
|
|
1735
|
-
const matchingFlag = option.long && this._findOption(option.long) ? option.long : option.short;
|
|
1736
|
-
throw new Error(`Cannot add option '${option.flags}'${this._name && ` to command '${this._name}'`} due to conflicting flag '${matchingFlag}'
|
|
1737
|
-
- already used by option '${matchingOption.flags}'`);
|
|
1738
|
-
}
|
|
1739
|
-
this._initOptionGroup(option);
|
|
1740
|
-
this.options.push(option);
|
|
1741
|
-
}
|
|
1742
|
-
/**
|
|
1743
|
-
* Check for command name and alias conflicts with existing commands.
|
|
1744
|
-
* Register command if no conflicts found, or throw on conflict.
|
|
1745
|
-
*
|
|
1746
|
-
* @param {Command} command
|
|
1747
|
-
* @private
|
|
1748
|
-
*/
|
|
1749
|
-
_registerCommand(command) {
|
|
1750
|
-
const knownBy = (cmd) => {
|
|
1751
|
-
return [cmd.name()].concat(cmd.aliases());
|
|
1752
|
-
};
|
|
1753
|
-
const alreadyUsed = knownBy(command).find(
|
|
1754
|
-
(name) => this._findCommand(name)
|
|
1755
|
-
);
|
|
1756
|
-
if (alreadyUsed) {
|
|
1757
|
-
const existingCmd = knownBy(this._findCommand(alreadyUsed)).join("|");
|
|
1758
|
-
const newCmd = knownBy(command).join("|");
|
|
1759
|
-
throw new Error(
|
|
1760
|
-
`cannot add command '${newCmd}' as already have command '${existingCmd}'`
|
|
1761
|
-
);
|
|
1762
|
-
}
|
|
1763
|
-
this._initCommandGroup(command);
|
|
1764
|
-
this.commands.push(command);
|
|
1765
|
-
}
|
|
1766
|
-
/**
|
|
1767
|
-
* Add an option.
|
|
1768
|
-
*
|
|
1769
|
-
* @param {Option} option
|
|
1770
|
-
* @return {Command} `this` command for chaining
|
|
1771
|
-
*/
|
|
1772
|
-
addOption(option) {
|
|
1773
|
-
this._registerOption(option);
|
|
1774
|
-
const oname = option.name();
|
|
1775
|
-
const name = option.attributeName();
|
|
1776
|
-
if (option.negate) {
|
|
1777
|
-
const positiveLongFlag = option.long.replace(/^--no-/, "--");
|
|
1778
|
-
if (!this._findOption(positiveLongFlag)) {
|
|
1779
|
-
this.setOptionValueWithSource(
|
|
1780
|
-
name,
|
|
1781
|
-
option.defaultValue === void 0 ? true : option.defaultValue,
|
|
1782
|
-
"default"
|
|
1783
|
-
);
|
|
1784
|
-
}
|
|
1785
|
-
} else if (option.defaultValue !== void 0) {
|
|
1786
|
-
this.setOptionValueWithSource(name, option.defaultValue, "default");
|
|
1787
|
-
}
|
|
1788
|
-
const handleOptionValue = (val, invalidValueMessage, valueSource) => {
|
|
1789
|
-
if (val == null && option.presetArg !== void 0) {
|
|
1790
|
-
val = option.presetArg;
|
|
1791
|
-
}
|
|
1792
|
-
const oldValue = this.getOptionValue(name);
|
|
1793
|
-
if (val !== null && option.parseArg) {
|
|
1794
|
-
val = this._callParseArg(option, val, oldValue, invalidValueMessage);
|
|
1795
|
-
} else if (val !== null && option.variadic) {
|
|
1796
|
-
val = option._collectValue(val, oldValue);
|
|
1797
|
-
}
|
|
1798
|
-
if (val == null) {
|
|
1799
|
-
if (option.negate) {
|
|
1800
|
-
val = false;
|
|
1801
|
-
} else if (option.isBoolean() || option.optional) {
|
|
1802
|
-
val = true;
|
|
1803
|
-
} else {
|
|
1804
|
-
val = "";
|
|
1805
|
-
}
|
|
1806
|
-
}
|
|
1807
|
-
this.setOptionValueWithSource(name, val, valueSource);
|
|
1808
|
-
};
|
|
1809
|
-
this.on("option:" + oname, (val) => {
|
|
1810
|
-
const invalidValueMessage = `error: option '${option.flags}' argument '${val}' is invalid.`;
|
|
1811
|
-
handleOptionValue(val, invalidValueMessage, "cli");
|
|
1812
|
-
});
|
|
1813
|
-
if (option.envVar) {
|
|
1814
|
-
this.on("optionEnv:" + oname, (val) => {
|
|
1815
|
-
const invalidValueMessage = `error: option '${option.flags}' value '${val}' from env '${option.envVar}' is invalid.`;
|
|
1816
|
-
handleOptionValue(val, invalidValueMessage, "env");
|
|
1817
|
-
});
|
|
1818
|
-
}
|
|
1819
|
-
return this;
|
|
1820
|
-
}
|
|
1821
|
-
/**
|
|
1822
|
-
* Internal implementation shared by .option() and .requiredOption()
|
|
1823
|
-
*
|
|
1824
|
-
* @return {Command} `this` command for chaining
|
|
1825
|
-
* @private
|
|
1826
|
-
*/
|
|
1827
|
-
_optionEx(config, flags, description, fn, defaultValue) {
|
|
1828
|
-
if (typeof flags === "object" && flags instanceof Option2) {
|
|
1829
|
-
throw new Error(
|
|
1830
|
-
"To add an Option object use addOption() instead of option() or requiredOption()"
|
|
1831
|
-
);
|
|
1832
|
-
}
|
|
1833
|
-
const option = this.createOption(flags, description);
|
|
1834
|
-
option.makeOptionMandatory(!!config.mandatory);
|
|
1835
|
-
if (typeof fn === "function") {
|
|
1836
|
-
option.default(defaultValue).argParser(fn);
|
|
1837
|
-
} else if (fn instanceof RegExp) {
|
|
1838
|
-
const regex = fn;
|
|
1839
|
-
fn = (val, def) => {
|
|
1840
|
-
const m = regex.exec(val);
|
|
1841
|
-
return m ? m[0] : def;
|
|
1842
|
-
};
|
|
1843
|
-
option.default(defaultValue).argParser(fn);
|
|
1844
|
-
} else {
|
|
1845
|
-
option.default(fn);
|
|
1846
|
-
}
|
|
1847
|
-
return this.addOption(option);
|
|
1848
|
-
}
|
|
1849
|
-
/**
|
|
1850
|
-
* Define option with `flags`, `description`, and optional argument parsing function or `defaultValue` or both.
|
|
1851
|
-
*
|
|
1852
|
-
* The `flags` string contains the short and/or long flags, separated by comma, a pipe or space. A required
|
|
1853
|
-
* option-argument is indicated by `<>` and an optional option-argument by `[]`.
|
|
1854
|
-
*
|
|
1855
|
-
* See the README for more details, and see also addOption() and requiredOption().
|
|
1856
|
-
*
|
|
1857
|
-
* @example
|
|
1858
|
-
* program
|
|
1859
|
-
* .option('-p, --pepper', 'add pepper')
|
|
1860
|
-
* .option('--pt, --pizza-type <TYPE>', 'type of pizza') // required option-argument
|
|
1861
|
-
* .option('-c, --cheese [CHEESE]', 'add extra cheese', 'mozzarella') // optional option-argument with default
|
|
1862
|
-
* .option('-t, --tip <VALUE>', 'add tip to purchase cost', parseFloat) // custom parse function
|
|
1863
|
-
*
|
|
1864
|
-
* @param {string} flags
|
|
1865
|
-
* @param {string} [description]
|
|
1866
|
-
* @param {(Function|*)} [parseArg] - custom option processing function or default value
|
|
1867
|
-
* @param {*} [defaultValue]
|
|
1868
|
-
* @return {Command} `this` command for chaining
|
|
1869
|
-
*/
|
|
1870
|
-
option(flags, description, parseArg, defaultValue) {
|
|
1871
|
-
return this._optionEx({}, flags, description, parseArg, defaultValue);
|
|
1872
|
-
}
|
|
1873
|
-
/**
|
|
1874
|
-
* Add a required option which must have a value after parsing. This usually means
|
|
1875
|
-
* the option must be specified on the command line. (Otherwise the same as .option().)
|
|
1876
|
-
*
|
|
1877
|
-
* The `flags` string contains the short and/or long flags, separated by comma, a pipe or space.
|
|
1878
|
-
*
|
|
1879
|
-
* @param {string} flags
|
|
1880
|
-
* @param {string} [description]
|
|
1881
|
-
* @param {(Function|*)} [parseArg] - custom option processing function or default value
|
|
1882
|
-
* @param {*} [defaultValue]
|
|
1883
|
-
* @return {Command} `this` command for chaining
|
|
1884
|
-
*/
|
|
1885
|
-
requiredOption(flags, description, parseArg, defaultValue) {
|
|
1886
|
-
return this._optionEx(
|
|
1887
|
-
{ mandatory: true },
|
|
1888
|
-
flags,
|
|
1889
|
-
description,
|
|
1890
|
-
parseArg,
|
|
1891
|
-
defaultValue
|
|
1892
|
-
);
|
|
1893
|
-
}
|
|
1894
|
-
/**
|
|
1895
|
-
* Alter parsing of short flags with optional values.
|
|
1896
|
-
*
|
|
1897
|
-
* @example
|
|
1898
|
-
* // for `.option('-f,--flag [value]'):
|
|
1899
|
-
* program.combineFlagAndOptionalValue(true); // `-f80` is treated like `--flag=80`, this is the default behaviour
|
|
1900
|
-
* program.combineFlagAndOptionalValue(false) // `-fb` is treated like `-f -b`
|
|
1901
|
-
*
|
|
1902
|
-
* @param {boolean} [combine] - if `true` or omitted, an optional value can be specified directly after the flag.
|
|
1903
|
-
* @return {Command} `this` command for chaining
|
|
1904
|
-
*/
|
|
1905
|
-
combineFlagAndOptionalValue(combine = true) {
|
|
1906
|
-
this._combineFlagAndOptionalValue = !!combine;
|
|
1907
|
-
return this;
|
|
1908
|
-
}
|
|
1909
|
-
/**
|
|
1910
|
-
* Allow unknown options on the command line.
|
|
1911
|
-
*
|
|
1912
|
-
* @param {boolean} [allowUnknown] - if `true` or omitted, no error will be thrown for unknown options.
|
|
1913
|
-
* @return {Command} `this` command for chaining
|
|
1914
|
-
*/
|
|
1915
|
-
allowUnknownOption(allowUnknown = true) {
|
|
1916
|
-
this._allowUnknownOption = !!allowUnknown;
|
|
1917
|
-
return this;
|
|
1918
|
-
}
|
|
1919
|
-
/**
|
|
1920
|
-
* Allow excess command-arguments on the command line. Pass false to make excess arguments an error.
|
|
1921
|
-
*
|
|
1922
|
-
* @param {boolean} [allowExcess] - if `true` or omitted, no error will be thrown for excess arguments.
|
|
1923
|
-
* @return {Command} `this` command for chaining
|
|
1924
|
-
*/
|
|
1925
|
-
allowExcessArguments(allowExcess = true) {
|
|
1926
|
-
this._allowExcessArguments = !!allowExcess;
|
|
1927
|
-
return this;
|
|
1928
|
-
}
|
|
1929
|
-
/**
|
|
1930
|
-
* Enable positional options. Positional means global options are specified before subcommands which lets
|
|
1931
|
-
* subcommands reuse the same option names, and also enables subcommands to turn on passThroughOptions.
|
|
1932
|
-
* The default behaviour is non-positional and global options may appear anywhere on the command line.
|
|
1933
|
-
*
|
|
1934
|
-
* @param {boolean} [positional]
|
|
1935
|
-
* @return {Command} `this` command for chaining
|
|
1936
|
-
*/
|
|
1937
|
-
enablePositionalOptions(positional = true) {
|
|
1938
|
-
this._enablePositionalOptions = !!positional;
|
|
1939
|
-
return this;
|
|
1940
|
-
}
|
|
1941
|
-
/**
|
|
1942
|
-
* Pass through options that come after command-arguments rather than treat them as command-options,
|
|
1943
|
-
* so actual command-options come before command-arguments. Turning this on for a subcommand requires
|
|
1944
|
-
* positional options to have been enabled on the program (parent commands).
|
|
1945
|
-
* The default behaviour is non-positional and options may appear before or after command-arguments.
|
|
1946
|
-
*
|
|
1947
|
-
* @param {boolean} [passThrough] for unknown options.
|
|
1948
|
-
* @return {Command} `this` command for chaining
|
|
1949
|
-
*/
|
|
1950
|
-
passThroughOptions(passThrough = true) {
|
|
1951
|
-
this._passThroughOptions = !!passThrough;
|
|
1952
|
-
this._checkForBrokenPassThrough();
|
|
1953
|
-
return this;
|
|
1954
|
-
}
|
|
1955
|
-
/**
|
|
1956
|
-
* @private
|
|
1957
|
-
*/
|
|
1958
|
-
_checkForBrokenPassThrough() {
|
|
1959
|
-
if (this.parent && this._passThroughOptions && !this.parent._enablePositionalOptions) {
|
|
1960
|
-
throw new Error(
|
|
1961
|
-
`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`
|
|
1962
|
-
);
|
|
1963
|
-
}
|
|
1964
|
-
}
|
|
1965
|
-
/**
|
|
1966
|
-
* Whether to store option values as properties on command object,
|
|
1967
|
-
* or store separately (specify false). In both cases the option values can be accessed using .opts().
|
|
1968
|
-
*
|
|
1969
|
-
* @param {boolean} [storeAsProperties=true]
|
|
1970
|
-
* @return {Command} `this` command for chaining
|
|
1971
|
-
*/
|
|
1972
|
-
storeOptionsAsProperties(storeAsProperties = true) {
|
|
1973
|
-
if (this.options.length) {
|
|
1974
|
-
throw new Error("call .storeOptionsAsProperties() before adding options");
|
|
1975
|
-
}
|
|
1976
|
-
if (Object.keys(this._optionValues).length) {
|
|
1977
|
-
throw new Error(
|
|
1978
|
-
"call .storeOptionsAsProperties() before setting option values"
|
|
1979
|
-
);
|
|
1980
|
-
}
|
|
1981
|
-
this._storeOptionsAsProperties = !!storeAsProperties;
|
|
1982
|
-
return this;
|
|
1983
|
-
}
|
|
1984
|
-
/**
|
|
1985
|
-
* Retrieve option value.
|
|
1986
|
-
*
|
|
1987
|
-
* @param {string} key
|
|
1988
|
-
* @return {object} value
|
|
1989
|
-
*/
|
|
1990
|
-
getOptionValue(key) {
|
|
1991
|
-
if (this._storeOptionsAsProperties) {
|
|
1992
|
-
return this[key];
|
|
1993
|
-
}
|
|
1994
|
-
return this._optionValues[key];
|
|
1995
|
-
}
|
|
1996
|
-
/**
|
|
1997
|
-
* Store option value.
|
|
1998
|
-
*
|
|
1999
|
-
* @param {string} key
|
|
2000
|
-
* @param {object} value
|
|
2001
|
-
* @return {Command} `this` command for chaining
|
|
2002
|
-
*/
|
|
2003
|
-
setOptionValue(key, value) {
|
|
2004
|
-
return this.setOptionValueWithSource(key, value, void 0);
|
|
2005
|
-
}
|
|
2006
|
-
/**
|
|
2007
|
-
* Store option value and where the value came from.
|
|
2008
|
-
*
|
|
2009
|
-
* @param {string} key
|
|
2010
|
-
* @param {object} value
|
|
2011
|
-
* @param {string} source - expected values are default/config/env/cli/implied
|
|
2012
|
-
* @return {Command} `this` command for chaining
|
|
2013
|
-
*/
|
|
2014
|
-
setOptionValueWithSource(key, value, source) {
|
|
2015
|
-
if (this._storeOptionsAsProperties) {
|
|
2016
|
-
this[key] = value;
|
|
2017
|
-
} else {
|
|
2018
|
-
this._optionValues[key] = value;
|
|
2019
|
-
}
|
|
2020
|
-
this._optionValueSources[key] = source;
|
|
2021
|
-
return this;
|
|
2022
|
-
}
|
|
2023
|
-
/**
|
|
2024
|
-
* Get source of option value.
|
|
2025
|
-
* Expected values are default | config | env | cli | implied
|
|
2026
|
-
*
|
|
2027
|
-
* @param {string} key
|
|
2028
|
-
* @return {string}
|
|
2029
|
-
*/
|
|
2030
|
-
getOptionValueSource(key) {
|
|
2031
|
-
return this._optionValueSources[key];
|
|
2032
|
-
}
|
|
2033
|
-
/**
|
|
2034
|
-
* Get source of option value. See also .optsWithGlobals().
|
|
2035
|
-
* Expected values are default | config | env | cli | implied
|
|
2036
|
-
*
|
|
2037
|
-
* @param {string} key
|
|
2038
|
-
* @return {string}
|
|
2039
|
-
*/
|
|
2040
|
-
getOptionValueSourceWithGlobals(key) {
|
|
2041
|
-
let source;
|
|
2042
|
-
this._getCommandAndAncestors().forEach((cmd) => {
|
|
2043
|
-
if (cmd.getOptionValueSource(key) !== void 0) {
|
|
2044
|
-
source = cmd.getOptionValueSource(key);
|
|
2045
|
-
}
|
|
2046
|
-
});
|
|
2047
|
-
return source;
|
|
2048
|
-
}
|
|
2049
|
-
/**
|
|
2050
|
-
* Get user arguments from implied or explicit arguments.
|
|
2051
|
-
* Side-effects: set _scriptPath if args included script. Used for default program name, and subcommand searches.
|
|
2052
|
-
*
|
|
2053
|
-
* @private
|
|
2054
|
-
*/
|
|
2055
|
-
_prepareUserArgs(argv, parseOptions) {
|
|
2056
|
-
if (argv !== void 0 && !Array.isArray(argv)) {
|
|
2057
|
-
throw new Error("first parameter to parse must be array or undefined");
|
|
2058
|
-
}
|
|
2059
|
-
parseOptions = parseOptions || {};
|
|
2060
|
-
if (argv === void 0 && parseOptions.from === void 0) {
|
|
2061
|
-
if (process2.versions?.electron) {
|
|
2062
|
-
parseOptions.from = "electron";
|
|
2063
|
-
}
|
|
2064
|
-
const execArgv = process2.execArgv ?? [];
|
|
2065
|
-
if (execArgv.includes("-e") || execArgv.includes("--eval") || execArgv.includes("-p") || execArgv.includes("--print")) {
|
|
2066
|
-
parseOptions.from = "eval";
|
|
2067
|
-
}
|
|
2068
|
-
}
|
|
2069
|
-
if (argv === void 0) {
|
|
2070
|
-
argv = process2.argv;
|
|
2071
|
-
}
|
|
2072
|
-
this.rawArgs = argv.slice();
|
|
2073
|
-
let userArgs;
|
|
2074
|
-
switch (parseOptions.from) {
|
|
2075
|
-
case void 0:
|
|
2076
|
-
case "node":
|
|
2077
|
-
this._scriptPath = argv[1];
|
|
2078
|
-
userArgs = argv.slice(2);
|
|
2079
|
-
break;
|
|
2080
|
-
case "electron":
|
|
2081
|
-
if (process2.defaultApp) {
|
|
2082
|
-
this._scriptPath = argv[1];
|
|
2083
|
-
userArgs = argv.slice(2);
|
|
2084
|
-
} else {
|
|
2085
|
-
userArgs = argv.slice(1);
|
|
2086
|
-
}
|
|
2087
|
-
break;
|
|
2088
|
-
case "user":
|
|
2089
|
-
userArgs = argv.slice(0);
|
|
2090
|
-
break;
|
|
2091
|
-
case "eval":
|
|
2092
|
-
userArgs = argv.slice(1);
|
|
2093
|
-
break;
|
|
2094
|
-
default:
|
|
2095
|
-
throw new Error(
|
|
2096
|
-
`unexpected parse option { from: '${parseOptions.from}' }`
|
|
2097
|
-
);
|
|
2098
|
-
}
|
|
2099
|
-
if (!this._name && this._scriptPath)
|
|
2100
|
-
this.nameFromFilename(this._scriptPath);
|
|
2101
|
-
this._name = this._name || "program";
|
|
2102
|
-
return userArgs;
|
|
2103
|
-
}
|
|
2104
|
-
/**
|
|
2105
|
-
* Parse `argv`, setting options and invoking commands when defined.
|
|
2106
|
-
*
|
|
2107
|
-
* Use parseAsync instead of parse if any of your action handlers are async.
|
|
2108
|
-
*
|
|
2109
|
-
* Call with no parameters to parse `process.argv`. Detects Electron and special node options like `node --eval`. Easy mode!
|
|
2110
|
-
*
|
|
2111
|
-
* Or call with an array of strings to parse, and optionally where the user arguments start by specifying where the arguments are `from`:
|
|
2112
|
-
* - `'node'`: default, `argv[0]` is the application and `argv[1]` is the script being run, with user arguments after that
|
|
2113
|
-
* - `'electron'`: `argv[0]` is the application and `argv[1]` varies depending on whether the electron application is packaged
|
|
2114
|
-
* - `'user'`: just user arguments
|
|
2115
|
-
*
|
|
2116
|
-
* @example
|
|
2117
|
-
* program.parse(); // parse process.argv and auto-detect electron and special node flags
|
|
2118
|
-
* program.parse(process.argv); // assume argv[0] is app and argv[1] is script
|
|
2119
|
-
* program.parse(my-args, { from: 'user' }); // just user supplied arguments, nothing special about argv[0]
|
|
2120
|
-
*
|
|
2121
|
-
* @param {string[]} [argv] - optional, defaults to process.argv
|
|
2122
|
-
* @param {object} [parseOptions] - optionally specify style of options with from: node/user/electron
|
|
2123
|
-
* @param {string} [parseOptions.from] - where the args are from: 'node', 'user', 'electron'
|
|
2124
|
-
* @return {Command} `this` command for chaining
|
|
2125
|
-
*/
|
|
2126
|
-
parse(argv, parseOptions) {
|
|
2127
|
-
this._prepareForParse();
|
|
2128
|
-
const userArgs = this._prepareUserArgs(argv, parseOptions);
|
|
2129
|
-
this._parseCommand([], userArgs);
|
|
2130
|
-
return this;
|
|
2131
|
-
}
|
|
2132
|
-
/**
|
|
2133
|
-
* Parse `argv`, setting options and invoking commands when defined.
|
|
2134
|
-
*
|
|
2135
|
-
* Call with no parameters to parse `process.argv`. Detects Electron and special node options like `node --eval`. Easy mode!
|
|
2136
|
-
*
|
|
2137
|
-
* Or call with an array of strings to parse, and optionally where the user arguments start by specifying where the arguments are `from`:
|
|
2138
|
-
* - `'node'`: default, `argv[0]` is the application and `argv[1]` is the script being run, with user arguments after that
|
|
2139
|
-
* - `'electron'`: `argv[0]` is the application and `argv[1]` varies depending on whether the electron application is packaged
|
|
2140
|
-
* - `'user'`: just user arguments
|
|
2141
|
-
*
|
|
2142
|
-
* @example
|
|
2143
|
-
* await program.parseAsync(); // parse process.argv and auto-detect electron and special node flags
|
|
2144
|
-
* await program.parseAsync(process.argv); // assume argv[0] is app and argv[1] is script
|
|
2145
|
-
* await program.parseAsync(my-args, { from: 'user' }); // just user supplied arguments, nothing special about argv[0]
|
|
2146
|
-
*
|
|
2147
|
-
* @param {string[]} [argv]
|
|
2148
|
-
* @param {object} [parseOptions]
|
|
2149
|
-
* @param {string} parseOptions.from - where the args are from: 'node', 'user', 'electron'
|
|
2150
|
-
* @return {Promise}
|
|
2151
|
-
*/
|
|
2152
|
-
async parseAsync(argv, parseOptions) {
|
|
2153
|
-
this._prepareForParse();
|
|
2154
|
-
const userArgs = this._prepareUserArgs(argv, parseOptions);
|
|
2155
|
-
await this._parseCommand([], userArgs);
|
|
2156
|
-
return this;
|
|
2157
|
-
}
|
|
2158
|
-
_prepareForParse() {
|
|
2159
|
-
if (this._savedState === null) {
|
|
2160
|
-
this.saveStateBeforeParse();
|
|
2161
|
-
} else {
|
|
2162
|
-
this.restoreStateBeforeParse();
|
|
2163
|
-
}
|
|
2164
|
-
}
|
|
2165
|
-
/**
|
|
2166
|
-
* Called the first time parse is called to save state and allow a restore before subsequent calls to parse.
|
|
2167
|
-
* Not usually called directly, but available for subclasses to save their custom state.
|
|
2168
|
-
*
|
|
2169
|
-
* This is called in a lazy way. Only commands used in parsing chain will have state saved.
|
|
2170
|
-
*/
|
|
2171
|
-
saveStateBeforeParse() {
|
|
2172
|
-
this._savedState = {
|
|
2173
|
-
// name is stable if supplied by author, but may be unspecified for root command and deduced during parsing
|
|
2174
|
-
_name: this._name,
|
|
2175
|
-
// option values before parse have default values (including false for negated options)
|
|
2176
|
-
// shallow clones
|
|
2177
|
-
_optionValues: { ...this._optionValues },
|
|
2178
|
-
_optionValueSources: { ...this._optionValueSources }
|
|
2179
|
-
};
|
|
2180
|
-
}
|
|
2181
|
-
/**
|
|
2182
|
-
* Restore state before parse for calls after the first.
|
|
2183
|
-
* Not usually called directly, but available for subclasses to save their custom state.
|
|
2184
|
-
*
|
|
2185
|
-
* This is called in a lazy way. Only commands used in parsing chain will have state restored.
|
|
2186
|
-
*/
|
|
2187
|
-
restoreStateBeforeParse() {
|
|
2188
|
-
if (this._storeOptionsAsProperties)
|
|
2189
|
-
throw new Error(`Can not call parse again when storeOptionsAsProperties is true.
|
|
2190
|
-
- either make a new Command for each call to parse, or stop storing options as properties`);
|
|
2191
|
-
this._name = this._savedState._name;
|
|
2192
|
-
this._scriptPath = null;
|
|
2193
|
-
this.rawArgs = [];
|
|
2194
|
-
this._optionValues = { ...this._savedState._optionValues };
|
|
2195
|
-
this._optionValueSources = { ...this._savedState._optionValueSources };
|
|
2196
|
-
this.args = [];
|
|
2197
|
-
this.processedArgs = [];
|
|
2198
|
-
}
|
|
2199
|
-
/**
|
|
2200
|
-
* Throw if expected executable is missing. Add lots of help for author.
|
|
2201
|
-
*
|
|
2202
|
-
* @param {string} executableFile
|
|
2203
|
-
* @param {string} executableDir
|
|
2204
|
-
* @param {string} subcommandName
|
|
2205
|
-
*/
|
|
2206
|
-
_checkForMissingExecutable(executableFile, executableDir, subcommandName) {
|
|
2207
|
-
if (fs15.existsSync(executableFile)) return;
|
|
2208
|
-
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";
|
|
2209
|
-
const executableMissing = `'${executableFile}' does not exist
|
|
2210
|
-
- if '${subcommandName}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
|
|
2211
|
-
- if the default executable name is not suitable, use the executableFile option to supply a custom name or path
|
|
2212
|
-
- ${executableDirMessage}`;
|
|
2213
|
-
throw new Error(executableMissing);
|
|
2214
|
-
}
|
|
2215
|
-
/**
|
|
2216
|
-
* Execute a sub-command executable.
|
|
2217
|
-
*
|
|
2218
|
-
* @private
|
|
2219
|
-
*/
|
|
2220
|
-
_executeSubCommand(subcommand, args) {
|
|
2221
|
-
args = args.slice();
|
|
2222
|
-
let launchWithNode = false;
|
|
2223
|
-
const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
|
|
2224
|
-
function findFile(baseDir, baseName) {
|
|
2225
|
-
const localBin = path18.resolve(baseDir, baseName);
|
|
2226
|
-
if (fs15.existsSync(localBin)) return localBin;
|
|
2227
|
-
if (sourceExt.includes(path18.extname(baseName))) return void 0;
|
|
2228
|
-
const foundExt = sourceExt.find(
|
|
2229
|
-
(ext2) => fs15.existsSync(`${localBin}${ext2}`)
|
|
2230
|
-
);
|
|
2231
|
-
if (foundExt) return `${localBin}${foundExt}`;
|
|
2232
|
-
return void 0;
|
|
2233
|
-
}
|
|
2234
|
-
this._checkForMissingMandatoryOptions();
|
|
2235
|
-
this._checkForConflictingOptions();
|
|
2236
|
-
let executableFile = subcommand._executableFile || `${this._name}-${subcommand._name}`;
|
|
2237
|
-
let executableDir = this._executableDir || "";
|
|
2238
|
-
if (this._scriptPath) {
|
|
2239
|
-
let resolvedScriptPath;
|
|
2240
|
-
try {
|
|
2241
|
-
resolvedScriptPath = fs15.realpathSync(this._scriptPath);
|
|
2242
|
-
} catch {
|
|
2243
|
-
resolvedScriptPath = this._scriptPath;
|
|
2244
|
-
}
|
|
2245
|
-
executableDir = path18.resolve(
|
|
2246
|
-
path18.dirname(resolvedScriptPath),
|
|
2247
|
-
executableDir
|
|
2248
|
-
);
|
|
2249
|
-
}
|
|
2250
|
-
if (executableDir) {
|
|
2251
|
-
let localFile = findFile(executableDir, executableFile);
|
|
2252
|
-
if (!localFile && !subcommand._executableFile && this._scriptPath) {
|
|
2253
|
-
const legacyName = path18.basename(
|
|
2254
|
-
this._scriptPath,
|
|
2255
|
-
path18.extname(this._scriptPath)
|
|
2256
|
-
);
|
|
2257
|
-
if (legacyName !== this._name) {
|
|
2258
|
-
localFile = findFile(
|
|
2259
|
-
executableDir,
|
|
2260
|
-
`${legacyName}-${subcommand._name}`
|
|
2261
|
-
);
|
|
2262
|
-
}
|
|
2263
|
-
}
|
|
2264
|
-
executableFile = localFile || executableFile;
|
|
2265
|
-
}
|
|
2266
|
-
launchWithNode = sourceExt.includes(path18.extname(executableFile));
|
|
2267
|
-
let proc;
|
|
2268
|
-
if (process2.platform !== "win32") {
|
|
2269
|
-
if (launchWithNode) {
|
|
2270
|
-
args.unshift(executableFile);
|
|
2271
|
-
args = incrementNodeInspectorPort(process2.execArgv).concat(args);
|
|
2272
|
-
proc = childProcess.spawn(process2.argv[0], args, { stdio: "inherit" });
|
|
2273
|
-
} else {
|
|
2274
|
-
proc = childProcess.spawn(executableFile, args, { stdio: "inherit" });
|
|
2275
|
-
}
|
|
2276
|
-
} else {
|
|
2277
|
-
this._checkForMissingExecutable(
|
|
2278
|
-
executableFile,
|
|
2279
|
-
executableDir,
|
|
2280
|
-
subcommand._name
|
|
2281
|
-
);
|
|
2282
|
-
args.unshift(executableFile);
|
|
2283
|
-
args = incrementNodeInspectorPort(process2.execArgv).concat(args);
|
|
2284
|
-
proc = childProcess.spawn(process2.execPath, args, { stdio: "inherit" });
|
|
2285
|
-
}
|
|
2286
|
-
if (!proc.killed) {
|
|
2287
|
-
const signals = ["SIGUSR1", "SIGUSR2", "SIGTERM", "SIGINT", "SIGHUP"];
|
|
2288
|
-
signals.forEach((signal) => {
|
|
2289
|
-
process2.on(signal, () => {
|
|
2290
|
-
if (proc.killed === false && proc.exitCode === null) {
|
|
2291
|
-
proc.kill(signal);
|
|
2292
|
-
}
|
|
2293
|
-
});
|
|
2294
|
-
});
|
|
2295
|
-
}
|
|
2296
|
-
const exitCallback = this._exitCallback;
|
|
2297
|
-
proc.on("close", (code) => {
|
|
2298
|
-
code = code ?? 1;
|
|
2299
|
-
if (!exitCallback) {
|
|
2300
|
-
process2.exit(code);
|
|
2301
|
-
} else {
|
|
2302
|
-
exitCallback(
|
|
2303
|
-
new CommanderError2(
|
|
2304
|
-
code,
|
|
2305
|
-
"commander.executeSubCommandAsync",
|
|
2306
|
-
"(close)"
|
|
2307
|
-
)
|
|
2308
|
-
);
|
|
2309
|
-
}
|
|
2310
|
-
});
|
|
2311
|
-
proc.on("error", (err) => {
|
|
2312
|
-
if (err.code === "ENOENT") {
|
|
2313
|
-
this._checkForMissingExecutable(
|
|
2314
|
-
executableFile,
|
|
2315
|
-
executableDir,
|
|
2316
|
-
subcommand._name
|
|
2317
|
-
);
|
|
2318
|
-
} else if (err.code === "EACCES") {
|
|
2319
|
-
throw new Error(`'${executableFile}' not executable`);
|
|
2320
|
-
}
|
|
2321
|
-
if (!exitCallback) {
|
|
2322
|
-
process2.exit(1);
|
|
2323
|
-
} else {
|
|
2324
|
-
const wrappedError = new CommanderError2(
|
|
2325
|
-
1,
|
|
2326
|
-
"commander.executeSubCommandAsync",
|
|
2327
|
-
"(error)"
|
|
2328
|
-
);
|
|
2329
|
-
wrappedError.nestedError = err;
|
|
2330
|
-
exitCallback(wrappedError);
|
|
2331
|
-
}
|
|
2332
|
-
});
|
|
2333
|
-
this.runningCommand = proc;
|
|
2334
|
-
}
|
|
2335
|
-
/**
|
|
2336
|
-
* @private
|
|
2337
|
-
*/
|
|
2338
|
-
_dispatchSubcommand(commandName, operands, unknown) {
|
|
2339
|
-
const subCommand = this._findCommand(commandName);
|
|
2340
|
-
if (!subCommand) this.help({ error: true });
|
|
2341
|
-
subCommand._prepareForParse();
|
|
2342
|
-
let promiseChain;
|
|
2343
|
-
promiseChain = this._chainOrCallSubCommandHook(
|
|
2344
|
-
promiseChain,
|
|
2345
|
-
subCommand,
|
|
2346
|
-
"preSubcommand"
|
|
2347
|
-
);
|
|
2348
|
-
promiseChain = this._chainOrCall(promiseChain, () => {
|
|
2349
|
-
if (subCommand._executableHandler) {
|
|
2350
|
-
this._executeSubCommand(subCommand, operands.concat(unknown));
|
|
2351
|
-
} else {
|
|
2352
|
-
return subCommand._parseCommand(operands, unknown);
|
|
2353
|
-
}
|
|
2354
|
-
});
|
|
2355
|
-
return promiseChain;
|
|
2356
|
-
}
|
|
2357
|
-
/**
|
|
2358
|
-
* Invoke help directly if possible, or dispatch if necessary.
|
|
2359
|
-
* e.g. help foo
|
|
2360
|
-
*
|
|
2361
|
-
* @private
|
|
2362
|
-
*/
|
|
2363
|
-
_dispatchHelpCommand(subcommandName) {
|
|
2364
|
-
if (!subcommandName) {
|
|
2365
|
-
this.help();
|
|
2366
|
-
}
|
|
2367
|
-
const subCommand = this._findCommand(subcommandName);
|
|
2368
|
-
if (subCommand && !subCommand._executableHandler) {
|
|
2369
|
-
subCommand.help();
|
|
2370
|
-
}
|
|
2371
|
-
return this._dispatchSubcommand(
|
|
2372
|
-
subcommandName,
|
|
2373
|
-
[],
|
|
2374
|
-
[this._getHelpOption()?.long ?? this._getHelpOption()?.short ?? "--help"]
|
|
2375
|
-
);
|
|
2376
|
-
}
|
|
2377
|
-
/**
|
|
2378
|
-
* Check this.args against expected this.registeredArguments.
|
|
2379
|
-
*
|
|
2380
|
-
* @private
|
|
2381
|
-
*/
|
|
2382
|
-
_checkNumberOfArguments() {
|
|
2383
|
-
this.registeredArguments.forEach((arg, i) => {
|
|
2384
|
-
if (arg.required && this.args[i] == null) {
|
|
2385
|
-
this.missingArgument(arg.name());
|
|
2386
|
-
}
|
|
2387
|
-
});
|
|
2388
|
-
if (this.registeredArguments.length > 0 && this.registeredArguments[this.registeredArguments.length - 1].variadic) {
|
|
2389
|
-
return;
|
|
2390
|
-
}
|
|
2391
|
-
if (this.args.length > this.registeredArguments.length) {
|
|
2392
|
-
this._excessArguments(this.args);
|
|
2393
|
-
}
|
|
2394
|
-
}
|
|
2395
|
-
/**
|
|
2396
|
-
* Process this.args using this.registeredArguments and save as this.processedArgs!
|
|
2397
|
-
*
|
|
2398
|
-
* @private
|
|
2399
|
-
*/
|
|
2400
|
-
_processArguments() {
|
|
2401
|
-
const myParseArg = (argument, value, previous) => {
|
|
2402
|
-
let parsedValue = value;
|
|
2403
|
-
if (value !== null && argument.parseArg) {
|
|
2404
|
-
const invalidValueMessage = `error: command-argument value '${value}' is invalid for argument '${argument.name()}'.`;
|
|
2405
|
-
parsedValue = this._callParseArg(
|
|
2406
|
-
argument,
|
|
2407
|
-
value,
|
|
2408
|
-
previous,
|
|
2409
|
-
invalidValueMessage
|
|
2410
|
-
);
|
|
2411
|
-
}
|
|
2412
|
-
return parsedValue;
|
|
2413
|
-
};
|
|
2414
|
-
this._checkNumberOfArguments();
|
|
2415
|
-
const processedArgs = [];
|
|
2416
|
-
this.registeredArguments.forEach((declaredArg, index) => {
|
|
2417
|
-
let value = declaredArg.defaultValue;
|
|
2418
|
-
if (declaredArg.variadic) {
|
|
2419
|
-
if (index < this.args.length) {
|
|
2420
|
-
value = this.args.slice(index);
|
|
2421
|
-
if (declaredArg.parseArg) {
|
|
2422
|
-
value = value.reduce((processed, v) => {
|
|
2423
|
-
return myParseArg(declaredArg, v, processed);
|
|
2424
|
-
}, declaredArg.defaultValue);
|
|
2425
|
-
}
|
|
2426
|
-
} else if (value === void 0) {
|
|
2427
|
-
value = [];
|
|
2428
|
-
}
|
|
2429
|
-
} else if (index < this.args.length) {
|
|
2430
|
-
value = this.args[index];
|
|
2431
|
-
if (declaredArg.parseArg) {
|
|
2432
|
-
value = myParseArg(declaredArg, value, declaredArg.defaultValue);
|
|
2433
|
-
}
|
|
2434
|
-
}
|
|
2435
|
-
processedArgs[index] = value;
|
|
2436
|
-
});
|
|
2437
|
-
this.processedArgs = processedArgs;
|
|
2438
|
-
}
|
|
2439
|
-
/**
|
|
2440
|
-
* Once we have a promise we chain, but call synchronously until then.
|
|
2441
|
-
*
|
|
2442
|
-
* @param {(Promise|undefined)} promise
|
|
2443
|
-
* @param {Function} fn
|
|
2444
|
-
* @return {(Promise|undefined)}
|
|
2445
|
-
* @private
|
|
2446
|
-
*/
|
|
2447
|
-
_chainOrCall(promise2, fn) {
|
|
2448
|
-
if (promise2?.then && typeof promise2.then === "function") {
|
|
2449
|
-
return promise2.then(() => fn());
|
|
2450
|
-
}
|
|
2451
|
-
return fn();
|
|
2452
|
-
}
|
|
2453
|
-
/**
|
|
2454
|
-
*
|
|
2455
|
-
* @param {(Promise|undefined)} promise
|
|
2456
|
-
* @param {string} event
|
|
2457
|
-
* @return {(Promise|undefined)}
|
|
2458
|
-
* @private
|
|
2459
|
-
*/
|
|
2460
|
-
_chainOrCallHooks(promise2, event) {
|
|
2461
|
-
let result = promise2;
|
|
2462
|
-
const hooks = [];
|
|
2463
|
-
this._getCommandAndAncestors().reverse().filter((cmd) => cmd._lifeCycleHooks[event] !== void 0).forEach((hookedCommand) => {
|
|
2464
|
-
hookedCommand._lifeCycleHooks[event].forEach((callback2) => {
|
|
2465
|
-
hooks.push({ hookedCommand, callback: callback2 });
|
|
2466
|
-
});
|
|
2467
|
-
});
|
|
2468
|
-
if (event === "postAction") {
|
|
2469
|
-
hooks.reverse();
|
|
2470
|
-
}
|
|
2471
|
-
hooks.forEach((hookDetail) => {
|
|
2472
|
-
result = this._chainOrCall(result, () => {
|
|
2473
|
-
return hookDetail.callback(hookDetail.hookedCommand, this);
|
|
2474
|
-
});
|
|
2475
|
-
});
|
|
2476
|
-
return result;
|
|
2477
|
-
}
|
|
2478
|
-
/**
|
|
2479
|
-
*
|
|
2480
|
-
* @param {(Promise|undefined)} promise
|
|
2481
|
-
* @param {Command} subCommand
|
|
2482
|
-
* @param {string} event
|
|
2483
|
-
* @return {(Promise|undefined)}
|
|
2484
|
-
* @private
|
|
2485
|
-
*/
|
|
2486
|
-
_chainOrCallSubCommandHook(promise2, subCommand, event) {
|
|
2487
|
-
let result = promise2;
|
|
2488
|
-
if (this._lifeCycleHooks[event] !== void 0) {
|
|
2489
|
-
this._lifeCycleHooks[event].forEach((hook) => {
|
|
2490
|
-
result = this._chainOrCall(result, () => {
|
|
2491
|
-
return hook(this, subCommand);
|
|
2492
|
-
});
|
|
2493
|
-
});
|
|
2494
|
-
}
|
|
2495
|
-
return result;
|
|
2496
|
-
}
|
|
2497
|
-
/**
|
|
2498
|
-
* Process arguments in context of this command.
|
|
2499
|
-
* Returns action result, in case it is a promise.
|
|
2500
|
-
*
|
|
2501
|
-
* @private
|
|
2502
|
-
*/
|
|
2503
|
-
_parseCommand(operands, unknown) {
|
|
2504
|
-
const parsed = this.parseOptions(unknown);
|
|
2505
|
-
this._parseOptionsEnv();
|
|
2506
|
-
this._parseOptionsImplied();
|
|
2507
|
-
operands = operands.concat(parsed.operands);
|
|
2508
|
-
unknown = parsed.unknown;
|
|
2509
|
-
this.args = operands.concat(unknown);
|
|
2510
|
-
if (operands && this._findCommand(operands[0])) {
|
|
2511
|
-
return this._dispatchSubcommand(operands[0], operands.slice(1), unknown);
|
|
2512
|
-
}
|
|
2513
|
-
if (this._getHelpCommand() && operands[0] === this._getHelpCommand().name()) {
|
|
2514
|
-
return this._dispatchHelpCommand(operands[1]);
|
|
2515
|
-
}
|
|
2516
|
-
if (this._defaultCommandName) {
|
|
2517
|
-
this._outputHelpIfRequested(unknown);
|
|
2518
|
-
return this._dispatchSubcommand(
|
|
2519
|
-
this._defaultCommandName,
|
|
2520
|
-
operands,
|
|
2521
|
-
unknown
|
|
2522
|
-
);
|
|
2523
|
-
}
|
|
2524
|
-
if (this.commands.length && this.args.length === 0 && !this._actionHandler && !this._defaultCommandName) {
|
|
2525
|
-
this.help({ error: true });
|
|
2526
|
-
}
|
|
2527
|
-
this._outputHelpIfRequested(parsed.unknown);
|
|
2528
|
-
this._checkForMissingMandatoryOptions();
|
|
2529
|
-
this._checkForConflictingOptions();
|
|
2530
|
-
const checkForUnknownOptions = () => {
|
|
2531
|
-
if (parsed.unknown.length > 0) {
|
|
2532
|
-
this.unknownOption(parsed.unknown[0]);
|
|
2533
|
-
}
|
|
2534
|
-
};
|
|
2535
|
-
const commandEvent = `command:${this.name()}`;
|
|
2536
|
-
if (this._actionHandler) {
|
|
2537
|
-
checkForUnknownOptions();
|
|
2538
|
-
this._processArguments();
|
|
2539
|
-
let promiseChain;
|
|
2540
|
-
promiseChain = this._chainOrCallHooks(promiseChain, "preAction");
|
|
2541
|
-
promiseChain = this._chainOrCall(
|
|
2542
|
-
promiseChain,
|
|
2543
|
-
() => this._actionHandler(this.processedArgs)
|
|
2544
|
-
);
|
|
2545
|
-
if (this.parent) {
|
|
2546
|
-
promiseChain = this._chainOrCall(promiseChain, () => {
|
|
2547
|
-
this.parent.emit(commandEvent, operands, unknown);
|
|
2548
|
-
});
|
|
2549
|
-
}
|
|
2550
|
-
promiseChain = this._chainOrCallHooks(promiseChain, "postAction");
|
|
2551
|
-
return promiseChain;
|
|
2552
|
-
}
|
|
2553
|
-
if (this.parent?.listenerCount(commandEvent)) {
|
|
2554
|
-
checkForUnknownOptions();
|
|
2555
|
-
this._processArguments();
|
|
2556
|
-
this.parent.emit(commandEvent, operands, unknown);
|
|
2557
|
-
} else if (operands.length) {
|
|
2558
|
-
if (this._findCommand("*")) {
|
|
2559
|
-
return this._dispatchSubcommand("*", operands, unknown);
|
|
2560
|
-
}
|
|
2561
|
-
if (this.listenerCount("command:*")) {
|
|
2562
|
-
this.emit("command:*", operands, unknown);
|
|
2563
|
-
} else if (this.commands.length) {
|
|
2564
|
-
this.unknownCommand();
|
|
2565
|
-
} else {
|
|
2566
|
-
checkForUnknownOptions();
|
|
2567
|
-
this._processArguments();
|
|
2568
|
-
}
|
|
2569
|
-
} else if (this.commands.length) {
|
|
2570
|
-
checkForUnknownOptions();
|
|
2571
|
-
this.help({ error: true });
|
|
2572
|
-
} else {
|
|
2573
|
-
checkForUnknownOptions();
|
|
2574
|
-
this._processArguments();
|
|
2575
|
-
}
|
|
2576
|
-
}
|
|
2577
|
-
/**
|
|
2578
|
-
* Find matching command.
|
|
2579
|
-
*
|
|
2580
|
-
* @private
|
|
2581
|
-
* @return {Command | undefined}
|
|
2582
|
-
*/
|
|
2583
|
-
_findCommand(name) {
|
|
2584
|
-
if (!name) return void 0;
|
|
2585
|
-
return this.commands.find(
|
|
2586
|
-
(cmd) => cmd._name === name || cmd._aliases.includes(name)
|
|
2587
|
-
);
|
|
2588
|
-
}
|
|
2589
|
-
/**
|
|
2590
|
-
* Return an option matching `arg` if any.
|
|
2591
|
-
*
|
|
2592
|
-
* @param {string} arg
|
|
2593
|
-
* @return {Option}
|
|
2594
|
-
* @package
|
|
2595
|
-
*/
|
|
2596
|
-
_findOption(arg) {
|
|
2597
|
-
return this.options.find((option) => option.is(arg));
|
|
2598
|
-
}
|
|
2599
|
-
/**
|
|
2600
|
-
* Display an error message if a mandatory option does not have a value.
|
|
2601
|
-
* Called after checking for help flags in leaf subcommand.
|
|
2602
|
-
*
|
|
2603
|
-
* @private
|
|
2604
|
-
*/
|
|
2605
|
-
_checkForMissingMandatoryOptions() {
|
|
2606
|
-
this._getCommandAndAncestors().forEach((cmd) => {
|
|
2607
|
-
cmd.options.forEach((anOption) => {
|
|
2608
|
-
if (anOption.mandatory && cmd.getOptionValue(anOption.attributeName()) === void 0) {
|
|
2609
|
-
cmd.missingMandatoryOptionValue(anOption);
|
|
2610
|
-
}
|
|
2611
|
-
});
|
|
2612
|
-
});
|
|
2613
|
-
}
|
|
2614
|
-
/**
|
|
2615
|
-
* Display an error message if conflicting options are used together in this.
|
|
2616
|
-
*
|
|
2617
|
-
* @private
|
|
2618
|
-
*/
|
|
2619
|
-
_checkForConflictingLocalOptions() {
|
|
2620
|
-
const definedNonDefaultOptions = this.options.filter((option) => {
|
|
2621
|
-
const optionKey = option.attributeName();
|
|
2622
|
-
if (this.getOptionValue(optionKey) === void 0) {
|
|
2623
|
-
return false;
|
|
2624
|
-
}
|
|
2625
|
-
return this.getOptionValueSource(optionKey) !== "default";
|
|
2626
|
-
});
|
|
2627
|
-
const optionsWithConflicting = definedNonDefaultOptions.filter(
|
|
2628
|
-
(option) => option.conflictsWith.length > 0
|
|
2629
|
-
);
|
|
2630
|
-
optionsWithConflicting.forEach((option) => {
|
|
2631
|
-
const conflictingAndDefined = definedNonDefaultOptions.find(
|
|
2632
|
-
(defined) => option.conflictsWith.includes(defined.attributeName())
|
|
2633
|
-
);
|
|
2634
|
-
if (conflictingAndDefined) {
|
|
2635
|
-
this._conflictingOption(option, conflictingAndDefined);
|
|
2636
|
-
}
|
|
2637
|
-
});
|
|
2638
|
-
}
|
|
2639
|
-
/**
|
|
2640
|
-
* Display an error message if conflicting options are used together.
|
|
2641
|
-
* Called after checking for help flags in leaf subcommand.
|
|
2642
|
-
*
|
|
2643
|
-
* @private
|
|
2644
|
-
*/
|
|
2645
|
-
_checkForConflictingOptions() {
|
|
2646
|
-
this._getCommandAndAncestors().forEach((cmd) => {
|
|
2647
|
-
cmd._checkForConflictingLocalOptions();
|
|
2648
|
-
});
|
|
2649
|
-
}
|
|
2650
|
-
/**
|
|
2651
|
-
* Parse options from `argv` removing known options,
|
|
2652
|
-
* and return argv split into operands and unknown arguments.
|
|
2653
|
-
*
|
|
2654
|
-
* Side effects: modifies command by storing options. Does not reset state if called again.
|
|
2655
|
-
*
|
|
2656
|
-
* Examples:
|
|
2657
|
-
*
|
|
2658
|
-
* argv => operands, unknown
|
|
2659
|
-
* --known kkk op => [op], []
|
|
2660
|
-
* op --known kkk => [op], []
|
|
2661
|
-
* sub --unknown uuu op => [sub], [--unknown uuu op]
|
|
2662
|
-
* sub -- --unknown uuu op => [sub --unknown uuu op], []
|
|
2663
|
-
*
|
|
2664
|
-
* @param {string[]} args
|
|
2665
|
-
* @return {{operands: string[], unknown: string[]}}
|
|
2666
|
-
*/
|
|
2667
|
-
parseOptions(args) {
|
|
2668
|
-
const operands = [];
|
|
2669
|
-
const unknown = [];
|
|
2670
|
-
let dest = operands;
|
|
2671
|
-
function maybeOption(arg) {
|
|
2672
|
-
return arg.length > 1 && arg[0] === "-";
|
|
2673
|
-
}
|
|
2674
|
-
const negativeNumberArg = (arg) => {
|
|
2675
|
-
if (!/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(arg)) return false;
|
|
2676
|
-
return !this._getCommandAndAncestors().some(
|
|
2677
|
-
(cmd) => cmd.options.map((opt) => opt.short).some((short) => /^-\d$/.test(short))
|
|
2678
|
-
);
|
|
2679
|
-
};
|
|
2680
|
-
let activeVariadicOption = null;
|
|
2681
|
-
let activeGroup = null;
|
|
2682
|
-
let i = 0;
|
|
2683
|
-
while (i < args.length || activeGroup) {
|
|
2684
|
-
const arg = activeGroup ?? args[i++];
|
|
2685
|
-
activeGroup = null;
|
|
2686
|
-
if (arg === "--") {
|
|
2687
|
-
if (dest === unknown) dest.push(arg);
|
|
2688
|
-
dest.push(...args.slice(i));
|
|
2689
|
-
break;
|
|
2690
|
-
}
|
|
2691
|
-
if (activeVariadicOption && (!maybeOption(arg) || negativeNumberArg(arg))) {
|
|
2692
|
-
this.emit(`option:${activeVariadicOption.name()}`, arg);
|
|
2693
|
-
continue;
|
|
2694
|
-
}
|
|
2695
|
-
activeVariadicOption = null;
|
|
2696
|
-
if (maybeOption(arg)) {
|
|
2697
|
-
const option = this._findOption(arg);
|
|
2698
|
-
if (option) {
|
|
2699
|
-
if (option.required) {
|
|
2700
|
-
const value = args[i++];
|
|
2701
|
-
if (value === void 0) this.optionMissingArgument(option);
|
|
2702
|
-
this.emit(`option:${option.name()}`, value);
|
|
2703
|
-
} else if (option.optional) {
|
|
2704
|
-
let value = null;
|
|
2705
|
-
if (i < args.length && (!maybeOption(args[i]) || negativeNumberArg(args[i]))) {
|
|
2706
|
-
value = args[i++];
|
|
2707
|
-
}
|
|
2708
|
-
this.emit(`option:${option.name()}`, value);
|
|
2709
|
-
} else {
|
|
2710
|
-
this.emit(`option:${option.name()}`);
|
|
2711
|
-
}
|
|
2712
|
-
activeVariadicOption = option.variadic ? option : null;
|
|
2713
|
-
continue;
|
|
2714
|
-
}
|
|
2715
|
-
}
|
|
2716
|
-
if (arg.length > 2 && arg[0] === "-" && arg[1] !== "-") {
|
|
2717
|
-
const option = this._findOption(`-${arg[1]}`);
|
|
2718
|
-
if (option) {
|
|
2719
|
-
if (option.required || option.optional && this._combineFlagAndOptionalValue) {
|
|
2720
|
-
this.emit(`option:${option.name()}`, arg.slice(2));
|
|
2721
|
-
} else {
|
|
2722
|
-
this.emit(`option:${option.name()}`);
|
|
2723
|
-
activeGroup = `-${arg.slice(2)}`;
|
|
2724
|
-
}
|
|
2725
|
-
continue;
|
|
2726
|
-
}
|
|
2727
|
-
}
|
|
2728
|
-
if (/^--[^=]+=/.test(arg)) {
|
|
2729
|
-
const index = arg.indexOf("=");
|
|
2730
|
-
const option = this._findOption(arg.slice(0, index));
|
|
2731
|
-
if (option && (option.required || option.optional)) {
|
|
2732
|
-
this.emit(`option:${option.name()}`, arg.slice(index + 1));
|
|
2733
|
-
continue;
|
|
2734
|
-
}
|
|
2735
|
-
}
|
|
2736
|
-
if (dest === operands && maybeOption(arg) && !(this.commands.length === 0 && negativeNumberArg(arg))) {
|
|
2737
|
-
dest = unknown;
|
|
2738
|
-
}
|
|
2739
|
-
if ((this._enablePositionalOptions || this._passThroughOptions) && operands.length === 0 && unknown.length === 0) {
|
|
2740
|
-
if (this._findCommand(arg)) {
|
|
2741
|
-
operands.push(arg);
|
|
2742
|
-
unknown.push(...args.slice(i));
|
|
2743
|
-
break;
|
|
2744
|
-
} else if (this._getHelpCommand() && arg === this._getHelpCommand().name()) {
|
|
2745
|
-
operands.push(arg, ...args.slice(i));
|
|
2746
|
-
break;
|
|
2747
|
-
} else if (this._defaultCommandName) {
|
|
2748
|
-
unknown.push(arg, ...args.slice(i));
|
|
2749
|
-
break;
|
|
2750
|
-
}
|
|
2751
|
-
}
|
|
2752
|
-
if (this._passThroughOptions) {
|
|
2753
|
-
dest.push(arg, ...args.slice(i));
|
|
2754
|
-
break;
|
|
2755
|
-
}
|
|
2756
|
-
dest.push(arg);
|
|
2757
|
-
}
|
|
2758
|
-
return { operands, unknown };
|
|
2759
|
-
}
|
|
2760
|
-
/**
|
|
2761
|
-
* Return an object containing local option values as key-value pairs.
|
|
2762
|
-
*
|
|
2763
|
-
* @return {object}
|
|
2764
|
-
*/
|
|
2765
|
-
opts() {
|
|
2766
|
-
if (this._storeOptionsAsProperties) {
|
|
2767
|
-
const result = {};
|
|
2768
|
-
const len = this.options.length;
|
|
2769
|
-
for (let i = 0; i < len; i++) {
|
|
2770
|
-
const key = this.options[i].attributeName();
|
|
2771
|
-
result[key] = key === this._versionOptionName ? this._version : this[key];
|
|
2772
|
-
}
|
|
2773
|
-
return result;
|
|
2774
|
-
}
|
|
2775
|
-
return this._optionValues;
|
|
2776
|
-
}
|
|
2777
|
-
/**
|
|
2778
|
-
* Return an object containing merged local and global option values as key-value pairs.
|
|
2779
|
-
*
|
|
2780
|
-
* @return {object}
|
|
2781
|
-
*/
|
|
2782
|
-
optsWithGlobals() {
|
|
2783
|
-
return this._getCommandAndAncestors().reduce(
|
|
2784
|
-
(combinedOptions, cmd) => Object.assign(combinedOptions, cmd.opts()),
|
|
2785
|
-
{}
|
|
2786
|
-
);
|
|
2787
|
-
}
|
|
2788
|
-
/**
|
|
2789
|
-
* Display error message and exit (or call exitOverride).
|
|
2790
|
-
*
|
|
2791
|
-
* @param {string} message
|
|
2792
|
-
* @param {object} [errorOptions]
|
|
2793
|
-
* @param {string} [errorOptions.code] - an id string representing the error
|
|
2794
|
-
* @param {number} [errorOptions.exitCode] - used with process.exit
|
|
2795
|
-
*/
|
|
2796
|
-
error(message, errorOptions) {
|
|
2797
|
-
this._outputConfiguration.outputError(
|
|
2798
|
-
`${message}
|
|
2799
|
-
`,
|
|
2800
|
-
this._outputConfiguration.writeErr
|
|
2801
|
-
);
|
|
2802
|
-
if (typeof this._showHelpAfterError === "string") {
|
|
2803
|
-
this._outputConfiguration.writeErr(`${this._showHelpAfterError}
|
|
2804
|
-
`);
|
|
2805
|
-
} else if (this._showHelpAfterError) {
|
|
2806
|
-
this._outputConfiguration.writeErr("\n");
|
|
2807
|
-
this.outputHelp({ error: true });
|
|
2808
|
-
}
|
|
2809
|
-
const config = errorOptions || {};
|
|
2810
|
-
const exitCode3 = config.exitCode || 1;
|
|
2811
|
-
const code = config.code || "commander.error";
|
|
2812
|
-
this._exit(exitCode3, code, message);
|
|
2813
|
-
}
|
|
2814
|
-
/**
|
|
2815
|
-
* Apply any option related environment variables, if option does
|
|
2816
|
-
* not have a value from cli or client code.
|
|
2817
|
-
*
|
|
2818
|
-
* @private
|
|
2819
|
-
*/
|
|
2820
|
-
_parseOptionsEnv() {
|
|
2821
|
-
this.options.forEach((option) => {
|
|
2822
|
-
if (option.envVar && option.envVar in process2.env) {
|
|
2823
|
-
const optionKey = option.attributeName();
|
|
2824
|
-
if (this.getOptionValue(optionKey) === void 0 || ["default", "config", "env"].includes(
|
|
2825
|
-
this.getOptionValueSource(optionKey)
|
|
2826
|
-
)) {
|
|
2827
|
-
if (option.required || option.optional) {
|
|
2828
|
-
this.emit(`optionEnv:${option.name()}`, process2.env[option.envVar]);
|
|
2829
|
-
} else {
|
|
2830
|
-
this.emit(`optionEnv:${option.name()}`);
|
|
2831
|
-
}
|
|
2832
|
-
}
|
|
2833
|
-
}
|
|
2834
|
-
});
|
|
2835
|
-
}
|
|
2836
|
-
/**
|
|
2837
|
-
* Apply any implied option values, if option is undefined or default value.
|
|
2838
|
-
*
|
|
2839
|
-
* @private
|
|
2840
|
-
*/
|
|
2841
|
-
_parseOptionsImplied() {
|
|
2842
|
-
const dualHelper = new DualOptions(this.options);
|
|
2843
|
-
const hasCustomOptionValue = (optionKey) => {
|
|
2844
|
-
return this.getOptionValue(optionKey) !== void 0 && !["default", "implied"].includes(this.getOptionValueSource(optionKey));
|
|
2845
|
-
};
|
|
2846
|
-
this.options.filter(
|
|
2847
|
-
(option) => option.implied !== void 0 && hasCustomOptionValue(option.attributeName()) && dualHelper.valueFromOption(
|
|
2848
|
-
this.getOptionValue(option.attributeName()),
|
|
2849
|
-
option
|
|
2850
|
-
)
|
|
2851
|
-
).forEach((option) => {
|
|
2852
|
-
Object.keys(option.implied).filter((impliedKey) => !hasCustomOptionValue(impliedKey)).forEach((impliedKey) => {
|
|
2853
|
-
this.setOptionValueWithSource(
|
|
2854
|
-
impliedKey,
|
|
2855
|
-
option.implied[impliedKey],
|
|
2856
|
-
"implied"
|
|
2857
|
-
);
|
|
2858
|
-
});
|
|
2859
|
-
});
|
|
2860
|
-
}
|
|
2861
|
-
/**
|
|
2862
|
-
* Argument `name` is missing.
|
|
2863
|
-
*
|
|
2864
|
-
* @param {string} name
|
|
2865
|
-
* @private
|
|
2866
|
-
*/
|
|
2867
|
-
missingArgument(name) {
|
|
2868
|
-
const message = `error: missing required argument '${name}'`;
|
|
2869
|
-
this.error(message, { code: "commander.missingArgument" });
|
|
2870
|
-
}
|
|
2871
|
-
/**
|
|
2872
|
-
* `Option` is missing an argument.
|
|
2873
|
-
*
|
|
2874
|
-
* @param {Option} option
|
|
2875
|
-
* @private
|
|
2876
|
-
*/
|
|
2877
|
-
optionMissingArgument(option) {
|
|
2878
|
-
const message = `error: option '${option.flags}' argument missing`;
|
|
2879
|
-
this.error(message, { code: "commander.optionMissingArgument" });
|
|
2880
|
-
}
|
|
2881
|
-
/**
|
|
2882
|
-
* `Option` does not have a value, and is a mandatory option.
|
|
2883
|
-
*
|
|
2884
|
-
* @param {Option} option
|
|
2885
|
-
* @private
|
|
2886
|
-
*/
|
|
2887
|
-
missingMandatoryOptionValue(option) {
|
|
2888
|
-
const message = `error: required option '${option.flags}' not specified`;
|
|
2889
|
-
this.error(message, { code: "commander.missingMandatoryOptionValue" });
|
|
2890
|
-
}
|
|
2891
|
-
/**
|
|
2892
|
-
* `Option` conflicts with another option.
|
|
2893
|
-
*
|
|
2894
|
-
* @param {Option} option
|
|
2895
|
-
* @param {Option} conflictingOption
|
|
2896
|
-
* @private
|
|
2897
|
-
*/
|
|
2898
|
-
_conflictingOption(option, conflictingOption) {
|
|
2899
|
-
const findBestOptionFromValue = (option2) => {
|
|
2900
|
-
const optionKey = option2.attributeName();
|
|
2901
|
-
const optionValue = this.getOptionValue(optionKey);
|
|
2902
|
-
const negativeOption = this.options.find(
|
|
2903
|
-
(target) => target.negate && optionKey === target.attributeName()
|
|
2904
|
-
);
|
|
2905
|
-
const positiveOption = this.options.find(
|
|
2906
|
-
(target) => !target.negate && optionKey === target.attributeName()
|
|
2907
|
-
);
|
|
2908
|
-
if (negativeOption && (negativeOption.presetArg === void 0 && optionValue === false || negativeOption.presetArg !== void 0 && optionValue === negativeOption.presetArg)) {
|
|
2909
|
-
return negativeOption;
|
|
2910
|
-
}
|
|
2911
|
-
return positiveOption || option2;
|
|
2912
|
-
};
|
|
2913
|
-
const getErrorMessage = (option2) => {
|
|
2914
|
-
const bestOption = findBestOptionFromValue(option2);
|
|
2915
|
-
const optionKey = bestOption.attributeName();
|
|
2916
|
-
const source = this.getOptionValueSource(optionKey);
|
|
2917
|
-
if (source === "env") {
|
|
2918
|
-
return `environment variable '${bestOption.envVar}'`;
|
|
2919
|
-
}
|
|
2920
|
-
return `option '${bestOption.flags}'`;
|
|
2921
|
-
};
|
|
2922
|
-
const message = `error: ${getErrorMessage(option)} cannot be used with ${getErrorMessage(conflictingOption)}`;
|
|
2923
|
-
this.error(message, { code: "commander.conflictingOption" });
|
|
2924
|
-
}
|
|
2925
|
-
/**
|
|
2926
|
-
* Unknown option `flag`.
|
|
2927
|
-
*
|
|
2928
|
-
* @param {string} flag
|
|
2929
|
-
* @private
|
|
2930
|
-
*/
|
|
2931
|
-
unknownOption(flag) {
|
|
2932
|
-
if (this._allowUnknownOption) return;
|
|
2933
|
-
let suggestion = "";
|
|
2934
|
-
if (flag.startsWith("--") && this._showSuggestionAfterError) {
|
|
2935
|
-
let candidateFlags = [];
|
|
2936
|
-
let command = this;
|
|
2937
|
-
do {
|
|
2938
|
-
const moreFlags = command.createHelp().visibleOptions(command).filter((option) => option.long).map((option) => option.long);
|
|
2939
|
-
candidateFlags = candidateFlags.concat(moreFlags);
|
|
2940
|
-
command = command.parent;
|
|
2941
|
-
} while (command && !command._enablePositionalOptions);
|
|
2942
|
-
suggestion = suggestSimilar(flag, candidateFlags);
|
|
2943
|
-
}
|
|
2944
|
-
const message = `error: unknown option '${flag}'${suggestion}`;
|
|
2945
|
-
this.error(message, { code: "commander.unknownOption" });
|
|
2946
|
-
}
|
|
2947
|
-
/**
|
|
2948
|
-
* Excess arguments, more than expected.
|
|
2949
|
-
*
|
|
2950
|
-
* @param {string[]} receivedArgs
|
|
2951
|
-
* @private
|
|
2952
|
-
*/
|
|
2953
|
-
_excessArguments(receivedArgs) {
|
|
2954
|
-
if (this._allowExcessArguments) return;
|
|
2955
|
-
const expected = this.registeredArguments.length;
|
|
2956
|
-
const s = expected === 1 ? "" : "s";
|
|
2957
|
-
const forSubcommand = this.parent ? ` for '${this.name()}'` : "";
|
|
2958
|
-
const message = `error: too many arguments${forSubcommand}. Expected ${expected} argument${s} but got ${receivedArgs.length}.`;
|
|
2959
|
-
this.error(message, { code: "commander.excessArguments" });
|
|
2960
|
-
}
|
|
2961
|
-
/**
|
|
2962
|
-
* Unknown command.
|
|
2963
|
-
*
|
|
2964
|
-
* @private
|
|
2965
|
-
*/
|
|
2966
|
-
unknownCommand() {
|
|
2967
|
-
const unknownName = this.args[0];
|
|
2968
|
-
let suggestion = "";
|
|
2969
|
-
if (this._showSuggestionAfterError) {
|
|
2970
|
-
const candidateNames = [];
|
|
2971
|
-
this.createHelp().visibleCommands(this).forEach((command) => {
|
|
2972
|
-
candidateNames.push(command.name());
|
|
2973
|
-
if (command.alias()) candidateNames.push(command.alias());
|
|
2974
|
-
});
|
|
2975
|
-
suggestion = suggestSimilar(unknownName, candidateNames);
|
|
2976
|
-
}
|
|
2977
|
-
const message = `error: unknown command '${unknownName}'${suggestion}`;
|
|
2978
|
-
this.error(message, { code: "commander.unknownCommand" });
|
|
2979
|
-
}
|
|
2980
|
-
/**
|
|
2981
|
-
* Get or set the program version.
|
|
2982
|
-
*
|
|
2983
|
-
* This method auto-registers the "-V, --version" option which will print the version number.
|
|
2984
|
-
*
|
|
2985
|
-
* You can optionally supply the flags and description to override the defaults.
|
|
2986
|
-
*
|
|
2987
|
-
* @param {string} [str]
|
|
2988
|
-
* @param {string} [flags]
|
|
2989
|
-
* @param {string} [description]
|
|
2990
|
-
* @return {(this | string | undefined)} `this` command for chaining, or version string if no arguments
|
|
2991
|
-
*/
|
|
2992
|
-
version(str3, flags, description) {
|
|
2993
|
-
if (str3 === void 0) return this._version;
|
|
2994
|
-
this._version = str3;
|
|
2995
|
-
flags = flags || "-V, --version";
|
|
2996
|
-
description = description || "output the version number";
|
|
2997
|
-
const versionOption = this.createOption(flags, description);
|
|
2998
|
-
this._versionOptionName = versionOption.attributeName();
|
|
2999
|
-
this._registerOption(versionOption);
|
|
3000
|
-
this.on("option:" + versionOption.name(), () => {
|
|
3001
|
-
this._outputConfiguration.writeOut(`${str3}
|
|
3002
|
-
`);
|
|
3003
|
-
this._exit(0, "commander.version", str3);
|
|
3004
|
-
});
|
|
3005
|
-
return this;
|
|
3006
|
-
}
|
|
3007
|
-
/**
|
|
3008
|
-
* Set the description.
|
|
3009
|
-
*
|
|
3010
|
-
* @param {string} [str]
|
|
3011
|
-
* @param {object} [argsDescription]
|
|
3012
|
-
* @return {(string|Command)}
|
|
3013
|
-
*/
|
|
3014
|
-
description(str3, argsDescription) {
|
|
3015
|
-
if (str3 === void 0 && argsDescription === void 0)
|
|
3016
|
-
return this._description;
|
|
3017
|
-
this._description = str3;
|
|
3018
|
-
if (argsDescription) {
|
|
3019
|
-
this._argsDescription = argsDescription;
|
|
3020
|
-
}
|
|
3021
|
-
return this;
|
|
3022
|
-
}
|
|
3023
|
-
/**
|
|
3024
|
-
* Set the summary. Used when listed as subcommand of parent.
|
|
3025
|
-
*
|
|
3026
|
-
* @param {string} [str]
|
|
3027
|
-
* @return {(string|Command)}
|
|
3028
|
-
*/
|
|
3029
|
-
summary(str3) {
|
|
3030
|
-
if (str3 === void 0) return this._summary;
|
|
3031
|
-
this._summary = str3;
|
|
3032
|
-
return this;
|
|
3033
|
-
}
|
|
3034
|
-
/**
|
|
3035
|
-
* Set an alias for the command.
|
|
3036
|
-
*
|
|
3037
|
-
* You may call more than once to add multiple aliases. Only the first alias is shown in the auto-generated help.
|
|
3038
|
-
*
|
|
3039
|
-
* @param {string} [alias]
|
|
3040
|
-
* @return {(string|Command)}
|
|
3041
|
-
*/
|
|
3042
|
-
alias(alias) {
|
|
3043
|
-
if (alias === void 0) return this._aliases[0];
|
|
3044
|
-
let command = this;
|
|
3045
|
-
if (this.commands.length !== 0 && this.commands[this.commands.length - 1]._executableHandler) {
|
|
3046
|
-
command = this.commands[this.commands.length - 1];
|
|
3047
|
-
}
|
|
3048
|
-
if (alias === command._name)
|
|
3049
|
-
throw new Error("Command alias can't be the same as its name");
|
|
3050
|
-
const matchingCommand = this.parent?._findCommand(alias);
|
|
3051
|
-
if (matchingCommand) {
|
|
3052
|
-
const existingCmd = [matchingCommand.name()].concat(matchingCommand.aliases()).join("|");
|
|
3053
|
-
throw new Error(
|
|
3054
|
-
`cannot add alias '${alias}' to command '${this.name()}' as already have command '${existingCmd}'`
|
|
3055
|
-
);
|
|
3056
|
-
}
|
|
3057
|
-
command._aliases.push(alias);
|
|
3058
|
-
return this;
|
|
3059
|
-
}
|
|
3060
|
-
/**
|
|
3061
|
-
* Set aliases for the command.
|
|
3062
|
-
*
|
|
3063
|
-
* Only the first alias is shown in the auto-generated help.
|
|
3064
|
-
*
|
|
3065
|
-
* @param {string[]} [aliases]
|
|
3066
|
-
* @return {(string[]|Command)}
|
|
3067
|
-
*/
|
|
3068
|
-
aliases(aliases) {
|
|
3069
|
-
if (aliases === void 0) return this._aliases;
|
|
3070
|
-
aliases.forEach((alias) => this.alias(alias));
|
|
3071
|
-
return this;
|
|
3072
|
-
}
|
|
3073
|
-
/**
|
|
3074
|
-
* Set / get the command usage `str`.
|
|
3075
|
-
*
|
|
3076
|
-
* @param {string} [str]
|
|
3077
|
-
* @return {(string|Command)}
|
|
3078
|
-
*/
|
|
3079
|
-
usage(str3) {
|
|
3080
|
-
if (str3 === void 0) {
|
|
3081
|
-
if (this._usage) return this._usage;
|
|
3082
|
-
const args = this.registeredArguments.map((arg) => {
|
|
3083
|
-
return humanReadableArgName(arg);
|
|
3084
|
-
});
|
|
3085
|
-
return [].concat(
|
|
3086
|
-
this.options.length || this._helpOption !== null ? "[options]" : [],
|
|
3087
|
-
this.commands.length ? "[command]" : [],
|
|
3088
|
-
this.registeredArguments.length ? args : []
|
|
3089
|
-
).join(" ");
|
|
3090
|
-
}
|
|
3091
|
-
this._usage = str3;
|
|
3092
|
-
return this;
|
|
3093
|
-
}
|
|
3094
|
-
/**
|
|
3095
|
-
* Get or set the name of the command.
|
|
3096
|
-
*
|
|
3097
|
-
* @param {string} [str]
|
|
3098
|
-
* @return {(string|Command)}
|
|
3099
|
-
*/
|
|
3100
|
-
name(str3) {
|
|
3101
|
-
if (str3 === void 0) return this._name;
|
|
3102
|
-
this._name = str3;
|
|
3103
|
-
return this;
|
|
3104
|
-
}
|
|
3105
|
-
/**
|
|
3106
|
-
* Set/get the help group heading for this subcommand in parent command's help.
|
|
3107
|
-
*
|
|
3108
|
-
* @param {string} [heading]
|
|
3109
|
-
* @return {Command | string}
|
|
3110
|
-
*/
|
|
3111
|
-
helpGroup(heading) {
|
|
3112
|
-
if (heading === void 0) return this._helpGroupHeading ?? "";
|
|
3113
|
-
this._helpGroupHeading = heading;
|
|
3114
|
-
return this;
|
|
3115
|
-
}
|
|
3116
|
-
/**
|
|
3117
|
-
* Set/get the default help group heading for subcommands added to this command.
|
|
3118
|
-
* (This does not override a group set directly on the subcommand using .helpGroup().)
|
|
3119
|
-
*
|
|
3120
|
-
* @example
|
|
3121
|
-
* program.commandsGroup('Development Commands:);
|
|
3122
|
-
* program.command('watch')...
|
|
3123
|
-
* program.command('lint')...
|
|
3124
|
-
* ...
|
|
3125
|
-
*
|
|
3126
|
-
* @param {string} [heading]
|
|
3127
|
-
* @returns {Command | string}
|
|
3128
|
-
*/
|
|
3129
|
-
commandsGroup(heading) {
|
|
3130
|
-
if (heading === void 0) return this._defaultCommandGroup ?? "";
|
|
3131
|
-
this._defaultCommandGroup = heading;
|
|
3132
|
-
return this;
|
|
3133
|
-
}
|
|
3134
|
-
/**
|
|
3135
|
-
* Set/get the default help group heading for options added to this command.
|
|
3136
|
-
* (This does not override a group set directly on the option using .helpGroup().)
|
|
3137
|
-
*
|
|
3138
|
-
* @example
|
|
3139
|
-
* program
|
|
3140
|
-
* .optionsGroup('Development Options:')
|
|
3141
|
-
* .option('-d, --debug', 'output extra debugging')
|
|
3142
|
-
* .option('-p, --profile', 'output profiling information')
|
|
3143
|
-
*
|
|
3144
|
-
* @param {string} [heading]
|
|
3145
|
-
* @returns {Command | string}
|
|
3146
|
-
*/
|
|
3147
|
-
optionsGroup(heading) {
|
|
3148
|
-
if (heading === void 0) return this._defaultOptionGroup ?? "";
|
|
3149
|
-
this._defaultOptionGroup = heading;
|
|
3150
|
-
return this;
|
|
3151
|
-
}
|
|
3152
|
-
/**
|
|
3153
|
-
* @param {Option} option
|
|
3154
|
-
* @private
|
|
3155
|
-
*/
|
|
3156
|
-
_initOptionGroup(option) {
|
|
3157
|
-
if (this._defaultOptionGroup && !option.helpGroupHeading)
|
|
3158
|
-
option.helpGroup(this._defaultOptionGroup);
|
|
3159
|
-
}
|
|
3160
|
-
/**
|
|
3161
|
-
* @param {Command} cmd
|
|
3162
|
-
* @private
|
|
3163
|
-
*/
|
|
3164
|
-
_initCommandGroup(cmd) {
|
|
3165
|
-
if (this._defaultCommandGroup && !cmd.helpGroup())
|
|
3166
|
-
cmd.helpGroup(this._defaultCommandGroup);
|
|
3167
|
-
}
|
|
3168
|
-
/**
|
|
3169
|
-
* Set the name of the command from script filename, such as process.argv[1],
|
|
3170
|
-
* or require.main.filename, or __filename.
|
|
3171
|
-
*
|
|
3172
|
-
* (Used internally and public although not documented in README.)
|
|
3173
|
-
*
|
|
3174
|
-
* @example
|
|
3175
|
-
* program.nameFromFilename(require.main.filename);
|
|
3176
|
-
*
|
|
3177
|
-
* @param {string} filename
|
|
3178
|
-
* @return {Command}
|
|
3179
|
-
*/
|
|
3180
|
-
nameFromFilename(filename) {
|
|
3181
|
-
this._name = path18.basename(filename, path18.extname(filename));
|
|
3182
|
-
return this;
|
|
3183
|
-
}
|
|
3184
|
-
/**
|
|
3185
|
-
* Get or set the directory for searching for executable subcommands of this command.
|
|
3186
|
-
*
|
|
3187
|
-
* @example
|
|
3188
|
-
* program.executableDir(__dirname);
|
|
3189
|
-
* // or
|
|
3190
|
-
* program.executableDir('subcommands');
|
|
3191
|
-
*
|
|
3192
|
-
* @param {string} [path]
|
|
3193
|
-
* @return {(string|null|Command)}
|
|
3194
|
-
*/
|
|
3195
|
-
executableDir(path19) {
|
|
3196
|
-
if (path19 === void 0) return this._executableDir;
|
|
3197
|
-
this._executableDir = path19;
|
|
3198
|
-
return this;
|
|
3199
|
-
}
|
|
3200
|
-
/**
|
|
3201
|
-
* Return program help documentation.
|
|
3202
|
-
*
|
|
3203
|
-
* @param {{ error: boolean }} [contextOptions] - pass {error:true} to wrap for stderr instead of stdout
|
|
3204
|
-
* @return {string}
|
|
3205
|
-
*/
|
|
3206
|
-
helpInformation(contextOptions) {
|
|
3207
|
-
const helper = this.createHelp();
|
|
3208
|
-
const context = this._getOutputContext(contextOptions);
|
|
3209
|
-
helper.prepareContext({
|
|
3210
|
-
error: context.error,
|
|
3211
|
-
helpWidth: context.helpWidth,
|
|
3212
|
-
outputHasColors: context.hasColors
|
|
3213
|
-
});
|
|
3214
|
-
const text = helper.formatHelp(this, helper);
|
|
3215
|
-
if (context.hasColors) return text;
|
|
3216
|
-
return this._outputConfiguration.stripColor(text);
|
|
3217
|
-
}
|
|
3218
|
-
/**
|
|
3219
|
-
* @typedef HelpContext
|
|
3220
|
-
* @type {object}
|
|
3221
|
-
* @property {boolean} error
|
|
3222
|
-
* @property {number} helpWidth
|
|
3223
|
-
* @property {boolean} hasColors
|
|
3224
|
-
* @property {function} write - includes stripColor if needed
|
|
3225
|
-
*
|
|
3226
|
-
* @returns {HelpContext}
|
|
3227
|
-
* @private
|
|
3228
|
-
*/
|
|
3229
|
-
_getOutputContext(contextOptions) {
|
|
3230
|
-
contextOptions = contextOptions || {};
|
|
3231
|
-
const error3 = !!contextOptions.error;
|
|
3232
|
-
let baseWrite;
|
|
3233
|
-
let hasColors;
|
|
3234
|
-
let helpWidth;
|
|
3235
|
-
if (error3) {
|
|
3236
|
-
baseWrite = (str3) => this._outputConfiguration.writeErr(str3);
|
|
3237
|
-
hasColors = this._outputConfiguration.getErrHasColors();
|
|
3238
|
-
helpWidth = this._outputConfiguration.getErrHelpWidth();
|
|
3239
|
-
} else {
|
|
3240
|
-
baseWrite = (str3) => this._outputConfiguration.writeOut(str3);
|
|
3241
|
-
hasColors = this._outputConfiguration.getOutHasColors();
|
|
3242
|
-
helpWidth = this._outputConfiguration.getOutHelpWidth();
|
|
3243
|
-
}
|
|
3244
|
-
const write = (str3) => {
|
|
3245
|
-
if (!hasColors) str3 = this._outputConfiguration.stripColor(str3);
|
|
3246
|
-
return baseWrite(str3);
|
|
3247
|
-
};
|
|
3248
|
-
return { error: error3, write, hasColors, helpWidth };
|
|
3249
|
-
}
|
|
3250
|
-
/**
|
|
3251
|
-
* Output help information for this command.
|
|
3252
|
-
*
|
|
3253
|
-
* Outputs built-in help, and custom text added using `.addHelpText()`.
|
|
3254
|
-
*
|
|
3255
|
-
* @param {{ error: boolean } | Function} [contextOptions] - pass {error:true} to write to stderr instead of stdout
|
|
3256
|
-
*/
|
|
3257
|
-
outputHelp(contextOptions) {
|
|
3258
|
-
let deprecatedCallback;
|
|
3259
|
-
if (typeof contextOptions === "function") {
|
|
3260
|
-
deprecatedCallback = contextOptions;
|
|
3261
|
-
contextOptions = void 0;
|
|
3262
|
-
}
|
|
3263
|
-
const outputContext = this._getOutputContext(contextOptions);
|
|
3264
|
-
const eventContext = {
|
|
3265
|
-
error: outputContext.error,
|
|
3266
|
-
write: outputContext.write,
|
|
3267
|
-
command: this
|
|
3268
|
-
};
|
|
3269
|
-
this._getCommandAndAncestors().reverse().forEach((command) => command.emit("beforeAllHelp", eventContext));
|
|
3270
|
-
this.emit("beforeHelp", eventContext);
|
|
3271
|
-
let helpInformation = this.helpInformation({ error: outputContext.error });
|
|
3272
|
-
if (deprecatedCallback) {
|
|
3273
|
-
helpInformation = deprecatedCallback(helpInformation);
|
|
3274
|
-
if (typeof helpInformation !== "string" && !Buffer.isBuffer(helpInformation)) {
|
|
3275
|
-
throw new Error("outputHelp callback must return a string or a Buffer");
|
|
3276
|
-
}
|
|
3277
|
-
}
|
|
3278
|
-
outputContext.write(helpInformation);
|
|
3279
|
-
if (this._getHelpOption()?.long) {
|
|
3280
|
-
this.emit(this._getHelpOption().long);
|
|
3281
|
-
}
|
|
3282
|
-
this.emit("afterHelp", eventContext);
|
|
3283
|
-
this._getCommandAndAncestors().forEach(
|
|
3284
|
-
(command) => command.emit("afterAllHelp", eventContext)
|
|
3285
|
-
);
|
|
3286
|
-
}
|
|
3287
|
-
/**
|
|
3288
|
-
* You can pass in flags and a description to customise the built-in help option.
|
|
3289
|
-
* Pass in false to disable the built-in help option.
|
|
3290
|
-
*
|
|
3291
|
-
* @example
|
|
3292
|
-
* program.helpOption('-?, --help' 'show help'); // customise
|
|
3293
|
-
* program.helpOption(false); // disable
|
|
3294
|
-
*
|
|
3295
|
-
* @param {(string | boolean)} flags
|
|
3296
|
-
* @param {string} [description]
|
|
3297
|
-
* @return {Command} `this` command for chaining
|
|
3298
|
-
*/
|
|
3299
|
-
helpOption(flags, description) {
|
|
3300
|
-
if (typeof flags === "boolean") {
|
|
3301
|
-
if (flags) {
|
|
3302
|
-
if (this._helpOption === null) this._helpOption = void 0;
|
|
3303
|
-
if (this._defaultOptionGroup) {
|
|
3304
|
-
this._initOptionGroup(this._getHelpOption());
|
|
3305
|
-
}
|
|
3306
|
-
} else {
|
|
3307
|
-
this._helpOption = null;
|
|
3308
|
-
}
|
|
3309
|
-
return this;
|
|
3310
|
-
}
|
|
3311
|
-
this._helpOption = this.createOption(
|
|
3312
|
-
flags ?? "-h, --help",
|
|
3313
|
-
description ?? "display help for command"
|
|
3314
|
-
);
|
|
3315
|
-
if (flags || description) this._initOptionGroup(this._helpOption);
|
|
3316
|
-
return this;
|
|
3317
|
-
}
|
|
3318
|
-
/**
|
|
3319
|
-
* Lazy create help option.
|
|
3320
|
-
* Returns null if has been disabled with .helpOption(false).
|
|
3321
|
-
*
|
|
3322
|
-
* @returns {(Option | null)} the help option
|
|
3323
|
-
* @package
|
|
3324
|
-
*/
|
|
3325
|
-
_getHelpOption() {
|
|
3326
|
-
if (this._helpOption === void 0) {
|
|
3327
|
-
this.helpOption(void 0, void 0);
|
|
3328
|
-
}
|
|
3329
|
-
return this._helpOption;
|
|
3330
|
-
}
|
|
3331
|
-
/**
|
|
3332
|
-
* Supply your own option to use for the built-in help option.
|
|
3333
|
-
* This is an alternative to using helpOption() to customise the flags and description etc.
|
|
3334
|
-
*
|
|
3335
|
-
* @param {Option} option
|
|
3336
|
-
* @return {Command} `this` command for chaining
|
|
3337
|
-
*/
|
|
3338
|
-
addHelpOption(option) {
|
|
3339
|
-
this._helpOption = option;
|
|
3340
|
-
this._initOptionGroup(option);
|
|
3341
|
-
return this;
|
|
3342
|
-
}
|
|
3343
|
-
/**
|
|
3344
|
-
* Output help information and exit.
|
|
3345
|
-
*
|
|
3346
|
-
* Outputs built-in help, and custom text added using `.addHelpText()`.
|
|
3347
|
-
*
|
|
3348
|
-
* @param {{ error: boolean }} [contextOptions] - pass {error:true} to write to stderr instead of stdout
|
|
3349
|
-
*/
|
|
3350
|
-
help(contextOptions) {
|
|
3351
|
-
this.outputHelp(contextOptions);
|
|
3352
|
-
let exitCode3 = Number(process2.exitCode ?? 0);
|
|
3353
|
-
if (exitCode3 === 0 && contextOptions && typeof contextOptions !== "function" && contextOptions.error) {
|
|
3354
|
-
exitCode3 = 1;
|
|
3355
|
-
}
|
|
3356
|
-
this._exit(exitCode3, "commander.help", "(outputHelp)");
|
|
3357
|
-
}
|
|
3358
|
-
/**
|
|
3359
|
-
* // Do a little typing to coordinate emit and listener for the help text events.
|
|
3360
|
-
* @typedef HelpTextEventContext
|
|
3361
|
-
* @type {object}
|
|
3362
|
-
* @property {boolean} error
|
|
3363
|
-
* @property {Command} command
|
|
3364
|
-
* @property {function} write
|
|
3365
|
-
*/
|
|
3366
|
-
/**
|
|
3367
|
-
* Add additional text to be displayed with the built-in help.
|
|
3368
|
-
*
|
|
3369
|
-
* Position is 'before' or 'after' to affect just this command,
|
|
3370
|
-
* and 'beforeAll' or 'afterAll' to affect this command and all its subcommands.
|
|
3371
|
-
*
|
|
3372
|
-
* @param {string} position - before or after built-in help
|
|
3373
|
-
* @param {(string | Function)} text - string to add, or a function returning a string
|
|
3374
|
-
* @return {Command} `this` command for chaining
|
|
3375
|
-
*/
|
|
3376
|
-
addHelpText(position, text) {
|
|
3377
|
-
const allowedValues = ["beforeAll", "before", "after", "afterAll"];
|
|
3378
|
-
if (!allowedValues.includes(position)) {
|
|
3379
|
-
throw new Error(`Unexpected value for position to addHelpText.
|
|
3380
|
-
Expecting one of '${allowedValues.join("', '")}'`);
|
|
3381
|
-
}
|
|
3382
|
-
const helpEvent = `${position}Help`;
|
|
3383
|
-
this.on(helpEvent, (context) => {
|
|
3384
|
-
let helpStr;
|
|
3385
|
-
if (typeof text === "function") {
|
|
3386
|
-
helpStr = text({ error: context.error, command: context.command });
|
|
3387
|
-
} else {
|
|
3388
|
-
helpStr = text;
|
|
3389
|
-
}
|
|
3390
|
-
if (helpStr) {
|
|
3391
|
-
context.write(`${helpStr}
|
|
3392
|
-
`);
|
|
3393
|
-
}
|
|
3394
|
-
});
|
|
3395
|
-
return this;
|
|
3396
|
-
}
|
|
3397
|
-
/**
|
|
3398
|
-
* Output help information if help flags specified
|
|
3399
|
-
*
|
|
3400
|
-
* @param {Array} args - array of options to search for help flags
|
|
3401
|
-
* @private
|
|
3402
|
-
*/
|
|
3403
|
-
_outputHelpIfRequested(args) {
|
|
3404
|
-
const helpOption = this._getHelpOption();
|
|
3405
|
-
const helpRequested = helpOption && args.find((arg) => helpOption.is(arg));
|
|
3406
|
-
if (helpRequested) {
|
|
3407
|
-
this.outputHelp();
|
|
3408
|
-
this._exit(0, "commander.helpDisplayed", "(outputHelp)");
|
|
3409
|
-
}
|
|
3410
|
-
}
|
|
3411
|
-
};
|
|
3412
|
-
function incrementNodeInspectorPort(args) {
|
|
3413
|
-
return args.map((arg) => {
|
|
3414
|
-
if (!arg.startsWith("--inspect")) {
|
|
3415
|
-
return arg;
|
|
3416
|
-
}
|
|
3417
|
-
let debugOption;
|
|
3418
|
-
let debugHost = "127.0.0.1";
|
|
3419
|
-
let debugPort = "9229";
|
|
3420
|
-
let match2;
|
|
3421
|
-
if ((match2 = arg.match(/^(--inspect(-brk)?)$/)) !== null) {
|
|
3422
|
-
debugOption = match2[1];
|
|
3423
|
-
} else if ((match2 = arg.match(/^(--inspect(-brk|-port)?)=([^:]+)$/)) !== null) {
|
|
3424
|
-
debugOption = match2[1];
|
|
3425
|
-
if (/^\d+$/.test(match2[3])) {
|
|
3426
|
-
debugPort = match2[3];
|
|
3427
|
-
} else {
|
|
3428
|
-
debugHost = match2[3];
|
|
3429
|
-
}
|
|
3430
|
-
} else if ((match2 = arg.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/)) !== null) {
|
|
3431
|
-
debugOption = match2[1];
|
|
3432
|
-
debugHost = match2[3];
|
|
3433
|
-
debugPort = match2[4];
|
|
3434
|
-
}
|
|
3435
|
-
if (debugOption && debugPort !== "0") {
|
|
3436
|
-
return `${debugOption}=${debugHost}:${parseInt(debugPort) + 1}`;
|
|
3437
|
-
}
|
|
3438
|
-
return arg;
|
|
3439
|
-
});
|
|
3440
|
-
}
|
|
3441
|
-
function useColor() {
|
|
3442
|
-
if (process2.env.NO_COLOR || process2.env.FORCE_COLOR === "0" || process2.env.FORCE_COLOR === "false")
|
|
3443
|
-
return false;
|
|
3444
|
-
if (process2.env.FORCE_COLOR || process2.env.CLICOLOR_FORCE !== void 0)
|
|
3445
|
-
return true;
|
|
3446
|
-
return void 0;
|
|
3447
|
-
}
|
|
3448
|
-
exports2.Command = Command2;
|
|
3449
|
-
exports2.useColor = useColor;
|
|
3450
|
-
}
|
|
3451
|
-
});
|
|
3452
|
-
|
|
3453
|
-
// ../../node_modules/.pnpm/commander@14.0.3/node_modules/commander/index.js
|
|
3454
|
-
var require_commander = __commonJS({
|
|
3455
|
-
"../../node_modules/.pnpm/commander@14.0.3/node_modules/commander/index.js"(exports2) {
|
|
3456
|
-
"use strict";
|
|
3457
|
-
var { Argument: Argument2 } = require_argument();
|
|
3458
|
-
var { Command: Command2 } = require_command();
|
|
3459
|
-
var { CommanderError: CommanderError2, InvalidArgumentError: InvalidArgumentError2 } = require_error();
|
|
3460
|
-
var { Help: Help2 } = require_help();
|
|
3461
|
-
var { Option: Option2 } = require_option();
|
|
3462
|
-
exports2.program = new Command2();
|
|
3463
|
-
exports2.createCommand = (name) => new Command2(name);
|
|
3464
|
-
exports2.createOption = (flags, description) => new Option2(flags, description);
|
|
3465
|
-
exports2.createArgument = (name, description) => new Argument2(name, description);
|
|
3466
|
-
exports2.Command = Command2;
|
|
3467
|
-
exports2.Option = Option2;
|
|
3468
|
-
exports2.Argument = Argument2;
|
|
3469
|
-
exports2.Help = Help2;
|
|
3470
|
-
exports2.CommanderError = CommanderError2;
|
|
3471
|
-
exports2.InvalidArgumentError = InvalidArgumentError2;
|
|
3472
|
-
exports2.InvalidOptionArgumentError = InvalidArgumentError2;
|
|
3473
|
-
}
|
|
3474
|
-
});
|
|
3475
|
-
|
|
3476
|
-
// ../../node_modules/.pnpm/commander@14.0.3/node_modules/commander/esm.mjs
|
|
3477
|
-
var import_index, program, createCommand, createArgument, createOption, CommanderError, InvalidArgumentError, InvalidOptionArgumentError, Command, Argument, Option, Help;
|
|
3478
|
-
var init_esm = __esm({
|
|
3479
|
-
"../../node_modules/.pnpm/commander@14.0.3/node_modules/commander/esm.mjs"() {
|
|
3480
|
-
"use strict";
|
|
3481
|
-
import_index = __toESM(require_commander(), 1);
|
|
3482
|
-
({
|
|
3483
|
-
program,
|
|
3484
|
-
createCommand,
|
|
3485
|
-
createArgument,
|
|
3486
|
-
createOption,
|
|
3487
|
-
CommanderError,
|
|
3488
|
-
InvalidArgumentError,
|
|
3489
|
-
InvalidOptionArgumentError,
|
|
3490
|
-
Command: (
|
|
3491
|
-
// deprecated old name
|
|
3492
|
-
Command
|
|
3493
|
-
),
|
|
3494
|
-
Argument,
|
|
3495
|
-
Option,
|
|
3496
|
-
Help
|
|
3497
|
-
} = import_index.default);
|
|
3498
|
-
}
|
|
3499
|
-
});
|
|
3500
|
-
|
|
3501
43
|
// ../version/dist/chunk-Q3FHZORY.js
|
|
3502
44
|
import chalk2 from "chalk";
|
|
3503
45
|
function shouldLog2(level) {
|
|
@@ -8869,7 +5411,7 @@ var init_node_figlet = __esm({
|
|
|
8869
5411
|
|
|
8870
5412
|
// ../../node_modules/.pnpm/balanced-match@4.0.4/node_modules/balanced-match/dist/esm/index.js
|
|
8871
5413
|
var balanced, maybeMatch, range;
|
|
8872
|
-
var
|
|
5414
|
+
var init_esm = __esm({
|
|
8873
5415
|
"../../node_modules/.pnpm/balanced-match@4.0.4/node_modules/balanced-match/dist/esm/index.js"() {
|
|
8874
5416
|
"use strict";
|
|
8875
5417
|
balanced = (a, b, str3) => {
|
|
@@ -9070,10 +5612,10 @@ function expand_(str3, max, isTop) {
|
|
|
9070
5612
|
return expansions;
|
|
9071
5613
|
}
|
|
9072
5614
|
var escSlash, escOpen, escClose, escComma, escPeriod, escSlashPattern, escOpenPattern, escClosePattern, escCommaPattern, escPeriodPattern, slashPattern, openPattern, closePattern, commaPattern, periodPattern, EXPANSION_MAX;
|
|
9073
|
-
var
|
|
5615
|
+
var init_esm2 = __esm({
|
|
9074
5616
|
"../../node_modules/.pnpm/brace-expansion@5.0.5/node_modules/brace-expansion/dist/esm/index.js"() {
|
|
9075
5617
|
"use strict";
|
|
9076
|
-
|
|
5618
|
+
init_esm();
|
|
9077
5619
|
escSlash = "\0SLASH" + Math.random() + "\0";
|
|
9078
5620
|
escOpen = "\0OPEN" + Math.random() + "\0";
|
|
9079
5621
|
escClose = "\0CLOSE" + Math.random() + "\0";
|
|
@@ -9906,10 +6448,10 @@ var init_escape = __esm({
|
|
|
9906
6448
|
|
|
9907
6449
|
// ../../node_modules/.pnpm/minimatch@10.2.5/node_modules/minimatch/dist/esm/index.js
|
|
9908
6450
|
var minimatch, starDotExtRE, starDotExtTest, starDotExtTestDot, starDotExtTestNocase, starDotExtTestNocaseDot, starDotStarRE, starDotStarTest, starDotStarTestDot, dotStarRE, dotStarTest, starRE, starTest, starTestDot, qmarksRE, qmarksTestNocase, qmarksTestNocaseDot, qmarksTestDot, qmarksTest, qmarksTestNoExt, qmarksTestNoExtDot, defaultPlatform, path7, sep, GLOBSTAR, qmark2, star2, twoStarDot, twoStarNoDot, filter, ext, defaults, braceExpand, makeRe, match, globMagic, regExpEscape2, Minimatch;
|
|
9909
|
-
var
|
|
6451
|
+
var init_esm3 = __esm({
|
|
9910
6452
|
"../../node_modules/.pnpm/minimatch@10.2.5/node_modules/minimatch/dist/esm/index.js"() {
|
|
9911
6453
|
"use strict";
|
|
9912
|
-
|
|
6454
|
+
init_esm2();
|
|
9913
6455
|
init_assert_valid_pattern();
|
|
9914
6456
|
init_ast();
|
|
9915
6457
|
init_escape();
|
|
@@ -17992,6 +14534,7 @@ import fs10 from "fs";
|
|
|
17992
14534
|
import * as path82 from "path";
|
|
17993
14535
|
import { cwd as cwd2 } from "process";
|
|
17994
14536
|
import path92 from "path";
|
|
14537
|
+
import { Command } from "commander";
|
|
17995
14538
|
function parseCargoToml(cargoPath) {
|
|
17996
14539
|
const content = fs9.readFileSync(cargoPath, "utf-8");
|
|
17997
14540
|
return TOML2.parse(content);
|
|
@@ -19765,10 +16308,9 @@ var init_chunk_UBCKZYTO = __esm({
|
|
|
19765
16308
|
import_semver4 = __toESM(require_semver2(), 1);
|
|
19766
16309
|
init_node_figlet();
|
|
19767
16310
|
import_semver5 = __toESM(require_semver2(), 1);
|
|
19768
|
-
|
|
16311
|
+
init_esm3();
|
|
19769
16312
|
init_manypkg_get_packages();
|
|
19770
|
-
|
|
19771
|
-
init_esm();
|
|
16313
|
+
init_esm3();
|
|
19772
16314
|
ConfigError2 = class extends ReleaseKitError2 {
|
|
19773
16315
|
code = "CONFIG_ERROR";
|
|
19774
16316
|
suggestions;
|
|
@@ -35571,7 +32113,7 @@ var require_runtime = __commonJS({
|
|
|
35571
32113
|
return ret2;
|
|
35572
32114
|
},
|
|
35573
32115
|
programs: [],
|
|
35574
|
-
program: function
|
|
32116
|
+
program: function program(i, data, declaredBlockParams, blockParams, depths) {
|
|
35575
32117
|
var programWrapper = this.programs[i], fn = this.fn(i);
|
|
35576
32118
|
if (data || depths || blockParams || declaredBlockParams) {
|
|
35577
32119
|
programWrapper = wrapProgram(this, i, fn, data, declaredBlockParams, blockParams, depths);
|
|
@@ -35947,9 +32489,9 @@ var require_parser = __commonJS({
|
|
|
35947
32489
|
this.$ = { strip: yy.stripFlags($$[$0 - 1], $$[$0 - 1]), program: $$[$0] };
|
|
35948
32490
|
break;
|
|
35949
32491
|
case 19:
|
|
35950
|
-
var inverse = yy.prepareBlock($$[$0 - 2], $$[$0 - 1], $$[$0], $$[$0], false, this._$),
|
|
35951
|
-
|
|
35952
|
-
this.$ = { strip: $$[$0 - 2].strip, program
|
|
32492
|
+
var inverse = yy.prepareBlock($$[$0 - 2], $$[$0 - 1], $$[$0], $$[$0], false, this._$), program = yy.prepareProgram([inverse], $$[$0 - 1].loc);
|
|
32493
|
+
program.chained = true;
|
|
32494
|
+
this.$ = { strip: $$[$0 - 2].strip, program, chain: true };
|
|
35953
32495
|
break;
|
|
35954
32496
|
case 20:
|
|
35955
32497
|
this.$ = $$[$0];
|
|
@@ -36641,8 +33183,8 @@ var require_visitor = __commonJS({
|
|
|
36641
33183
|
return object;
|
|
36642
33184
|
}
|
|
36643
33185
|
},
|
|
36644
|
-
Program: function Program(
|
|
36645
|
-
this.acceptArray(
|
|
33186
|
+
Program: function Program(program) {
|
|
33187
|
+
this.acceptArray(program.body);
|
|
36646
33188
|
},
|
|
36647
33189
|
MustacheStatement: visitSubExpression,
|
|
36648
33190
|
Decorator: visitSubExpression,
|
|
@@ -36712,11 +33254,11 @@ var require_whitespace_control = __commonJS({
|
|
|
36712
33254
|
this.options = options;
|
|
36713
33255
|
}
|
|
36714
33256
|
WhitespaceControl.prototype = new _visitor2["default"]();
|
|
36715
|
-
WhitespaceControl.prototype.Program = function(
|
|
33257
|
+
WhitespaceControl.prototype.Program = function(program) {
|
|
36716
33258
|
var doStandalone = !this.options.ignoreStandalone;
|
|
36717
33259
|
var isRoot2 = !this.isRootSeen;
|
|
36718
33260
|
this.isRootSeen = true;
|
|
36719
|
-
var body =
|
|
33261
|
+
var body = program.body;
|
|
36720
33262
|
for (var i = 0, l = body.length; i < l; i++) {
|
|
36721
33263
|
var current = body[i], strip3 = this.accept(current);
|
|
36722
33264
|
if (!strip3) {
|
|
@@ -36746,12 +33288,12 @@ var require_whitespace_control = __commonJS({
|
|
|
36746
33288
|
omitLeft((current.inverse || current.program).body);
|
|
36747
33289
|
}
|
|
36748
33290
|
}
|
|
36749
|
-
return
|
|
33291
|
+
return program;
|
|
36750
33292
|
};
|
|
36751
33293
|
WhitespaceControl.prototype.BlockStatement = WhitespaceControl.prototype.DecoratorBlock = WhitespaceControl.prototype.PartialBlockStatement = function(block) {
|
|
36752
33294
|
this.accept(block.program);
|
|
36753
33295
|
this.accept(block.inverse);
|
|
36754
|
-
var
|
|
33296
|
+
var program = block.program || block.inverse, inverse = block.program && block.inverse, firstInverse = inverse, lastInverse = inverse;
|
|
36755
33297
|
if (inverse && inverse.chained) {
|
|
36756
33298
|
firstInverse = inverse.body[0].program;
|
|
36757
33299
|
while (lastInverse.chained) {
|
|
@@ -36763,16 +33305,16 @@ var require_whitespace_control = __commonJS({
|
|
|
36763
33305
|
close: block.closeStrip.close,
|
|
36764
33306
|
// Determine the standalone candiacy. Basically flag our content as being possibly standalone
|
|
36765
33307
|
// so our parent can determine if we actually are standalone
|
|
36766
|
-
openStandalone: isNextWhitespace(
|
|
36767
|
-
closeStandalone: isPrevWhitespace((firstInverse ||
|
|
33308
|
+
openStandalone: isNextWhitespace(program.body),
|
|
33309
|
+
closeStandalone: isPrevWhitespace((firstInverse || program).body)
|
|
36768
33310
|
};
|
|
36769
33311
|
if (block.openStrip.close) {
|
|
36770
|
-
omitRight(
|
|
33312
|
+
omitRight(program.body, null, true);
|
|
36771
33313
|
}
|
|
36772
33314
|
if (inverse) {
|
|
36773
33315
|
var inverseStrip = block.inverseStrip;
|
|
36774
33316
|
if (inverseStrip.open) {
|
|
36775
|
-
omitLeft(
|
|
33317
|
+
omitLeft(program.body, null, true);
|
|
36776
33318
|
}
|
|
36777
33319
|
if (inverseStrip.close) {
|
|
36778
33320
|
omitRight(firstInverse.body, null, true);
|
|
@@ -36780,12 +33322,12 @@ var require_whitespace_control = __commonJS({
|
|
|
36780
33322
|
if (block.closeStrip.open) {
|
|
36781
33323
|
omitLeft(lastInverse.body, null, true);
|
|
36782
33324
|
}
|
|
36783
|
-
if (!this.options.ignoreStandalone && isPrevWhitespace(
|
|
36784
|
-
omitLeft(
|
|
33325
|
+
if (!this.options.ignoreStandalone && isPrevWhitespace(program.body) && isNextWhitespace(firstInverse.body)) {
|
|
33326
|
+
omitLeft(program.body);
|
|
36785
33327
|
omitRight(firstInverse.body);
|
|
36786
33328
|
}
|
|
36787
33329
|
} else if (block.closeStrip.open) {
|
|
36788
|
-
omitLeft(
|
|
33330
|
+
omitLeft(program.body, null, true);
|
|
36789
33331
|
}
|
|
36790
33332
|
return strip3;
|
|
36791
33333
|
};
|
|
@@ -36943,7 +33485,7 @@ var require_helpers2 = __commonJS({
|
|
|
36943
33485
|
function prepareRawBlock(openRawBlock, contents, close, locInfo) {
|
|
36944
33486
|
validateClose(openRawBlock, close);
|
|
36945
33487
|
locInfo = this.locInfo(locInfo);
|
|
36946
|
-
var
|
|
33488
|
+
var program = {
|
|
36947
33489
|
type: "Program",
|
|
36948
33490
|
body: contents,
|
|
36949
33491
|
strip: {},
|
|
@@ -36954,19 +33496,19 @@ var require_helpers2 = __commonJS({
|
|
|
36954
33496
|
path: openRawBlock.path,
|
|
36955
33497
|
params: openRawBlock.params,
|
|
36956
33498
|
hash: openRawBlock.hash,
|
|
36957
|
-
program
|
|
33499
|
+
program,
|
|
36958
33500
|
openStrip: {},
|
|
36959
33501
|
inverseStrip: {},
|
|
36960
33502
|
closeStrip: {},
|
|
36961
33503
|
loc: locInfo
|
|
36962
33504
|
};
|
|
36963
33505
|
}
|
|
36964
|
-
function prepareBlock(openBlock,
|
|
33506
|
+
function prepareBlock(openBlock, program, inverseAndProgram, close, inverted, locInfo) {
|
|
36965
33507
|
if (close && close.path) {
|
|
36966
33508
|
validateClose(openBlock, close);
|
|
36967
33509
|
}
|
|
36968
33510
|
var decorator = /\*/.test(openBlock.open);
|
|
36969
|
-
|
|
33511
|
+
program.blockParams = openBlock.blockParams;
|
|
36970
33512
|
var inverse = void 0, inverseStrip = void 0;
|
|
36971
33513
|
if (inverseAndProgram) {
|
|
36972
33514
|
if (decorator) {
|
|
@@ -36980,15 +33522,15 @@ var require_helpers2 = __commonJS({
|
|
|
36980
33522
|
}
|
|
36981
33523
|
if (inverted) {
|
|
36982
33524
|
inverted = inverse;
|
|
36983
|
-
inverse =
|
|
36984
|
-
|
|
33525
|
+
inverse = program;
|
|
33526
|
+
program = inverted;
|
|
36985
33527
|
}
|
|
36986
33528
|
return {
|
|
36987
33529
|
type: decorator ? "DecoratorBlock" : "BlockStatement",
|
|
36988
33530
|
path: openBlock.path,
|
|
36989
33531
|
params: openBlock.params,
|
|
36990
33532
|
hash: openBlock.hash,
|
|
36991
|
-
program
|
|
33533
|
+
program,
|
|
36992
33534
|
inverse,
|
|
36993
33535
|
openStrip: openBlock.strip,
|
|
36994
33536
|
inverseStrip,
|
|
@@ -37020,14 +33562,14 @@ var require_helpers2 = __commonJS({
|
|
|
37020
33562
|
loc
|
|
37021
33563
|
};
|
|
37022
33564
|
}
|
|
37023
|
-
function preparePartialBlock(open,
|
|
33565
|
+
function preparePartialBlock(open, program, close, locInfo) {
|
|
37024
33566
|
validateClose(open, close);
|
|
37025
33567
|
return {
|
|
37026
33568
|
type: "PartialBlockStatement",
|
|
37027
33569
|
name: open.path,
|
|
37028
33570
|
params: open.params,
|
|
37029
33571
|
hash: open.hash,
|
|
37030
|
-
program
|
|
33572
|
+
program,
|
|
37031
33573
|
openStrip: open.strip,
|
|
37032
33574
|
closeStrip: close && close.strip,
|
|
37033
33575
|
loc: this.locInfo(locInfo)
|
|
@@ -37178,7 +33720,7 @@ var require_compiler = __commonJS({
|
|
|
37178
33720
|
return true;
|
|
37179
33721
|
},
|
|
37180
33722
|
guid: 0,
|
|
37181
|
-
compile: function compile3(
|
|
33723
|
+
compile: function compile3(program, options) {
|
|
37182
33724
|
this.sourceNode = [];
|
|
37183
33725
|
this.opcodes = [];
|
|
37184
33726
|
this.children = [];
|
|
@@ -37196,10 +33738,10 @@ var require_compiler = __commonJS({
|
|
|
37196
33738
|
log: true,
|
|
37197
33739
|
lookup: true
|
|
37198
33740
|
}, options.knownHelpers);
|
|
37199
|
-
return this.accept(
|
|
33741
|
+
return this.accept(program);
|
|
37200
33742
|
},
|
|
37201
|
-
compileProgram: function compileProgram(
|
|
37202
|
-
var childCompiler = new this.compiler(), result = childCompiler.compile(
|
|
33743
|
+
compileProgram: function compileProgram(program) {
|
|
33744
|
+
var childCompiler = new this.compiler(), result = childCompiler.compile(program, this.options), guid = this.guid++;
|
|
37203
33745
|
this.usePartial = this.usePartial || result.usePartial;
|
|
37204
33746
|
this.children[guid] = result;
|
|
37205
33747
|
this.useDepths = this.useDepths || result.useDepths;
|
|
@@ -37214,34 +33756,34 @@ var require_compiler = __commonJS({
|
|
|
37214
33756
|
this.sourceNode.shift();
|
|
37215
33757
|
return ret;
|
|
37216
33758
|
},
|
|
37217
|
-
Program: function Program(
|
|
37218
|
-
this.options.blockParams.unshift(
|
|
37219
|
-
var body =
|
|
33759
|
+
Program: function Program(program) {
|
|
33760
|
+
this.options.blockParams.unshift(program.blockParams);
|
|
33761
|
+
var body = program.body, bodyLength = body.length;
|
|
37220
33762
|
for (var i = 0; i < bodyLength; i++) {
|
|
37221
33763
|
this.accept(body[i]);
|
|
37222
33764
|
}
|
|
37223
33765
|
this.options.blockParams.shift();
|
|
37224
33766
|
this.isSimple = bodyLength === 1;
|
|
37225
|
-
this.blockParams =
|
|
33767
|
+
this.blockParams = program.blockParams ? program.blockParams.length : 0;
|
|
37226
33768
|
return this;
|
|
37227
33769
|
},
|
|
37228
33770
|
BlockStatement: function BlockStatement(block) {
|
|
37229
33771
|
transformLiteralToPath(block);
|
|
37230
|
-
var
|
|
37231
|
-
|
|
33772
|
+
var program = block.program, inverse = block.inverse;
|
|
33773
|
+
program = program && this.compileProgram(program);
|
|
37232
33774
|
inverse = inverse && this.compileProgram(inverse);
|
|
37233
33775
|
var type2 = this.classifySexpr(block);
|
|
37234
33776
|
if (type2 === "helper") {
|
|
37235
|
-
this.helperSexpr(block,
|
|
33777
|
+
this.helperSexpr(block, program, inverse);
|
|
37236
33778
|
} else if (type2 === "simple") {
|
|
37237
33779
|
this.simpleSexpr(block);
|
|
37238
|
-
this.opcode("pushProgram",
|
|
33780
|
+
this.opcode("pushProgram", program);
|
|
37239
33781
|
this.opcode("pushProgram", inverse);
|
|
37240
33782
|
this.opcode("emptyHash");
|
|
37241
33783
|
this.opcode("blockValue", block.path.original);
|
|
37242
33784
|
} else {
|
|
37243
|
-
this.ambiguousSexpr(block,
|
|
37244
|
-
this.opcode("pushProgram",
|
|
33785
|
+
this.ambiguousSexpr(block, program, inverse);
|
|
33786
|
+
this.opcode("pushProgram", program);
|
|
37245
33787
|
this.opcode("pushProgram", inverse);
|
|
37246
33788
|
this.opcode("emptyHash");
|
|
37247
33789
|
this.opcode("ambiguousBlockValue");
|
|
@@ -37249,16 +33791,16 @@ var require_compiler = __commonJS({
|
|
|
37249
33791
|
this.opcode("append");
|
|
37250
33792
|
},
|
|
37251
33793
|
DecoratorBlock: function DecoratorBlock(decorator) {
|
|
37252
|
-
var
|
|
37253
|
-
var params = this.setupFullMustacheParams(decorator,
|
|
33794
|
+
var program = decorator.program && this.compileProgram(decorator.program);
|
|
33795
|
+
var params = this.setupFullMustacheParams(decorator, program, void 0), path18 = decorator.path;
|
|
37254
33796
|
this.useDecorators = true;
|
|
37255
33797
|
this.opcode("registerDecorator", params.length, path18.original);
|
|
37256
33798
|
},
|
|
37257
33799
|
PartialStatement: function PartialStatement(partial) {
|
|
37258
33800
|
this.usePartial = true;
|
|
37259
|
-
var
|
|
37260
|
-
if (
|
|
37261
|
-
|
|
33801
|
+
var program = partial.program;
|
|
33802
|
+
if (program) {
|
|
33803
|
+
program = this.compileProgram(partial.program);
|
|
37262
33804
|
}
|
|
37263
33805
|
var params = partial.params;
|
|
37264
33806
|
if (params.length > 1) {
|
|
@@ -37274,7 +33816,7 @@ var require_compiler = __commonJS({
|
|
|
37274
33816
|
if (isDynamic) {
|
|
37275
33817
|
this.accept(partial.name);
|
|
37276
33818
|
}
|
|
37277
|
-
this.setupFullMustacheParams(partial,
|
|
33819
|
+
this.setupFullMustacheParams(partial, program, void 0, true);
|
|
37278
33820
|
var indent = partial.indent || "";
|
|
37279
33821
|
if (this.options.preventIndent && indent) {
|
|
37280
33822
|
this.opcode("appendContent", indent);
|
|
@@ -37315,10 +33857,10 @@ var require_compiler = __commonJS({
|
|
|
37315
33857
|
this.ambiguousSexpr(sexpr);
|
|
37316
33858
|
}
|
|
37317
33859
|
},
|
|
37318
|
-
ambiguousSexpr: function ambiguousSexpr(sexpr,
|
|
37319
|
-
var path18 = sexpr.path, name = path18.parts[0], isBlock =
|
|
33860
|
+
ambiguousSexpr: function ambiguousSexpr(sexpr, program, inverse) {
|
|
33861
|
+
var path18 = sexpr.path, name = path18.parts[0], isBlock = program != null || inverse != null;
|
|
37320
33862
|
this.opcode("getContext", path18.depth);
|
|
37321
|
-
this.opcode("pushProgram",
|
|
33863
|
+
this.opcode("pushProgram", program);
|
|
37322
33864
|
this.opcode("pushProgram", inverse);
|
|
37323
33865
|
path18.strict = true;
|
|
37324
33866
|
this.accept(path18);
|
|
@@ -37330,8 +33872,8 @@ var require_compiler = __commonJS({
|
|
|
37330
33872
|
this.accept(path18);
|
|
37331
33873
|
this.opcode("resolvePossibleLambda");
|
|
37332
33874
|
},
|
|
37333
|
-
helperSexpr: function helperSexpr(sexpr,
|
|
37334
|
-
var params = this.setupFullMustacheParams(sexpr,
|
|
33875
|
+
helperSexpr: function helperSexpr(sexpr, program, inverse) {
|
|
33876
|
+
var params = this.setupFullMustacheParams(sexpr, program, inverse), path18 = sexpr.path, name = path18.parts[0];
|
|
37335
33877
|
if (this.options.knownHelpers[name]) {
|
|
37336
33878
|
this.opcode("invokeKnownHelper", params.length, name);
|
|
37337
33879
|
} else if (this.options.knownHelpersOnly) {
|
|
@@ -37458,10 +34000,10 @@ var require_compiler = __commonJS({
|
|
|
37458
34000
|
this.accept(val);
|
|
37459
34001
|
}
|
|
37460
34002
|
},
|
|
37461
|
-
setupFullMustacheParams: function setupFullMustacheParams(sexpr,
|
|
34003
|
+
setupFullMustacheParams: function setupFullMustacheParams(sexpr, program, inverse, omitEmpty) {
|
|
37462
34004
|
var params = sexpr.params;
|
|
37463
34005
|
this.pushParams(params);
|
|
37464
|
-
this.opcode("pushProgram",
|
|
34006
|
+
this.opcode("pushProgram", program);
|
|
37465
34007
|
this.opcode("pushProgram", inverse);
|
|
37466
34008
|
if (sexpr.hash) {
|
|
37467
34009
|
this.accept(sexpr.hash);
|
|
@@ -40291,9 +36833,9 @@ var require_javascript_compiler = __commonJS({
|
|
|
40291
36833
|
options.hashTypes = this.popStack();
|
|
40292
36834
|
options.hashContexts = this.popStack();
|
|
40293
36835
|
}
|
|
40294
|
-
var inverse = this.popStack(),
|
|
40295
|
-
if (
|
|
40296
|
-
options.fn =
|
|
36836
|
+
var inverse = this.popStack(), program = this.popStack();
|
|
36837
|
+
if (program || inverse) {
|
|
36838
|
+
options.fn = program || "container.noop";
|
|
40297
36839
|
options.inverse = inverse || "container.noop";
|
|
40298
36840
|
}
|
|
40299
36841
|
var i = paramSize;
|
|
@@ -40445,12 +36987,12 @@ var require_printer = __commonJS({
|
|
|
40445
36987
|
out += string + "\n";
|
|
40446
36988
|
return out;
|
|
40447
36989
|
};
|
|
40448
|
-
PrintVisitor.prototype.Program = function(
|
|
40449
|
-
var out = "", body =
|
|
40450
|
-
if (
|
|
36990
|
+
PrintVisitor.prototype.Program = function(program) {
|
|
36991
|
+
var out = "", body = program.body, i = void 0, l = void 0;
|
|
36992
|
+
if (program.blockParams) {
|
|
40451
36993
|
var blockParams = "BLOCK PARAMS: [";
|
|
40452
|
-
for (i = 0, l =
|
|
40453
|
-
blockParams += " " +
|
|
36994
|
+
for (i = 0, l = program.blockParams.length; i < l; i++) {
|
|
36995
|
+
blockParams += " " + program.blockParams[i];
|
|
40454
36996
|
}
|
|
40455
36997
|
blockParams += " ]";
|
|
40456
36998
|
out += this.pad(blockParams);
|
|
@@ -45397,6 +41939,7 @@ import * as fs83 from "fs";
|
|
|
45397
41939
|
import * as path62 from "path";
|
|
45398
41940
|
import * as fs102 from "fs";
|
|
45399
41941
|
import * as readline from "readline";
|
|
41942
|
+
import { Command as Command2 } from "commander";
|
|
45400
41943
|
function parseJsonc3(content) {
|
|
45401
41944
|
if (content.length > MAX_JSONC_LENGTH3) {
|
|
45402
41945
|
throw new Error(`JSONC content too long: ${content.length} characters (max ${MAX_JSONC_LENGTH3})`);
|
|
@@ -46519,7 +43062,7 @@ async function writeMonorepoFiles(contexts, config, dryRun, fileName) {
|
|
|
46519
43062
|
return monoFiles;
|
|
46520
43063
|
}
|
|
46521
43064
|
function createNotesCommand() {
|
|
46522
|
-
const cmd = new
|
|
43065
|
+
const cmd = new Command2("notes").description(
|
|
46523
43066
|
"Generate changelogs with LLM-powered enhancement and flexible templating"
|
|
46524
43067
|
);
|
|
46525
43068
|
cmd.command("generate", { isDefault: true }).description("Generate changelog from input data").option("-i, --input <file>", "Input file (default: stdin)").option("--no-changelog", "Disable changelog generation").option("--changelog-mode <mode>", "Changelog location mode (root|packages|both)").option("--changelog-file <name>", "Changelog file name override").option("--release-notes-mode <mode>", "Enable release notes and set location (root|packages|both)").option("--release-notes-file <name>", "Release notes file name override").option("--no-release-notes", "Disable release notes generation").option("-t, --template <path>", "Template file or directory").option("-e, --engine <engine>", "Template engine (handlebars|liquid|ejs)").option("--monorepo <mode>", "Monorepo mode (root|packages|both)").option("--llm-provider <provider>", "LLM provider").option("--llm-model <model>", "LLM model").option("--llm-base-url <url>", "LLM base URL (for openai-compatible provider)").option("--llm-tasks <tasks>", "Comma-separated LLM tasks").option("--no-llm", "Disable LLM processing").option("--target <package>", "Filter to a specific package name").option("--config <path>", "Config file path").option("--regenerate", "Regenerate entire changelog instead of prepending new entries").option("--dry-run", "Preview without writing").option("-v, --verbose", "Increase verbosity", increaseVerbosity, 0).option("-q, --quiet", "Suppress non-error output").action(async (options) => {
|
|
@@ -46717,7 +43260,6 @@ var init_chunk_Y4S5UWCL = __esm({
|
|
|
46717
43260
|
init_ejs();
|
|
46718
43261
|
import_handlebars = __toESM(require_lib(), 1);
|
|
46719
43262
|
init_liquid_node();
|
|
46720
|
-
init_esm();
|
|
46721
43263
|
ConfigError3 = class extends ReleaseKitError3 {
|
|
46722
43264
|
code = "CONFIG_ERROR";
|
|
46723
43265
|
suggestions;
|
|
@@ -47407,6 +43949,7 @@ import * as fs94 from "fs";
|
|
|
47407
43949
|
import * as path93 from "path";
|
|
47408
43950
|
import * as fs103 from "fs";
|
|
47409
43951
|
import { z as z32 } from "zod";
|
|
43952
|
+
import { Command as Command3 } from "commander";
|
|
47410
43953
|
function setLogLevel3(level) {
|
|
47411
43954
|
currentLevel4 = level;
|
|
47412
43955
|
}
|
|
@@ -48864,7 +45407,7 @@ async function readStdin2() {
|
|
|
48864
45407
|
return chunks.join("");
|
|
48865
45408
|
}
|
|
48866
45409
|
function createPublishCommand() {
|
|
48867
|
-
return new
|
|
45410
|
+
return new Command3("publish").description("Publish packages to registries with git tagging and GitHub releases").option("--input <path>", "Path to version output JSON (default: stdin)").option("--config <path>", "Path to releasekit config").option("--registry <type>", "Registry to publish to (npm, cargo, all)", "all").option("--npm-auth <method>", "NPM auth method (oidc, token, auto)", "auto").option("--dry-run", "Simulate all operations", false).option("--skip-git", "Skip git commit/tag/push", false).option("--skip-publish", "Skip registry publishing", false).option("--skip-github-release", "Skip GitHub Release creation", false).option("--skip-verification", "Skip post-publish verification", false).option("--json", "Output results as JSON", false).option("--verbose", "Verbose logging", false).action(async (options) => {
|
|
48868
45411
|
if (options.verbose) setLogLevel3("debug");
|
|
48869
45412
|
if (options.json) setJsonMode2(true);
|
|
48870
45413
|
try {
|
|
@@ -48919,7 +45462,6 @@ var init_chunk_OZHNJUFW = __esm({
|
|
|
48919
45462
|
"../publish/dist/chunk-OZHNJUFW.js"() {
|
|
48920
45463
|
"use strict";
|
|
48921
45464
|
import_semver6 = __toESM(require_semver2(), 1);
|
|
48922
|
-
init_esm();
|
|
48923
45465
|
LOG_LEVELS4 = {
|
|
48924
45466
|
error: 0,
|
|
48925
45467
|
warn: 1,
|
|
@@ -49487,10 +46029,10 @@ var EXIT_CODES = {
|
|
|
49487
46029
|
};
|
|
49488
46030
|
|
|
49489
46031
|
// src/cli.ts
|
|
49490
|
-
|
|
46032
|
+
import { Command as Command6 } from "commander";
|
|
49491
46033
|
|
|
49492
46034
|
// src/preview-command.ts
|
|
49493
|
-
|
|
46035
|
+
import { Command as Command4 } from "commander";
|
|
49494
46036
|
|
|
49495
46037
|
// ../config/dist/index.js
|
|
49496
46038
|
import * as TOML from "smol-toml";
|
|
@@ -50466,7 +47008,7 @@ async function applyLabelOverrides(options, ciConfig, context, existingOctokit)
|
|
|
50466
47008
|
|
|
50467
47009
|
// src/preview-command.ts
|
|
50468
47010
|
function createPreviewCommand() {
|
|
50469
|
-
return new
|
|
47011
|
+
return new Command4("preview").description("Post a release preview comment on the current pull request").option("-c, --config <path>", "Path to config file").option("--project-dir <path>", "Project directory", process.cwd()).option("--pr <number>", "PR number (auto-detected from GitHub Actions)").option("--repo <owner/repo>", "Repository (auto-detected from GITHUB_REPOSITORY)").option("-p, --prerelease [identifier]", "Force prerelease preview (auto-detected by default)").option("--stable", "Force stable release preview (graduation from prerelease)", false).option(
|
|
50470
47012
|
"-d, --dry-run",
|
|
50471
47013
|
"Print the comment to stdout without posting (GitHub context not available in dry-run mode)",
|
|
50472
47014
|
false
|
|
@@ -50489,9 +47031,9 @@ function createPreviewCommand() {
|
|
|
50489
47031
|
}
|
|
50490
47032
|
|
|
50491
47033
|
// src/release-command.ts
|
|
50492
|
-
|
|
47034
|
+
import { Command as Command5, Option } from "commander";
|
|
50493
47035
|
function createReleaseCommand() {
|
|
50494
|
-
return new
|
|
47036
|
+
return new Command5("release").description("Run the full release pipeline").option("-c, --config <path>", "Path to config file").option("-d, --dry-run", "Preview all steps without side effects", false).option("-b, --bump <type>", "Force bump type (patch|minor|major)").option("-p, --prerelease [identifier]", "Create prerelease version").option("-s, --sync", "Use synchronized versioning across all packages", false).option("-t, --target <packages>", "Target specific packages (comma-separated)").option("--branch <name>", "Override the git branch used for push").addOption(new Option("--npm-auth <method>", "NPM auth method").choices(["auto", "oidc", "token"]).default("auto")).option("--skip-notes", "Skip changelog generation", false).option("--skip-publish", "Skip registry publishing and git operations", false).option("--skip-git", "Skip git commit/tag/push", false).option("--skip-github-release", "Skip GitHub release creation", false).option("--skip-verification", "Skip post-publish verification", false).option("-j, --json", "Output results as JSON", false).option("-v, --verbose", "Verbose logging", false).option("-q, --quiet", "Suppress non-error output", false).option("--project-dir <path>", "Project directory", process.cwd()).action(async (opts) => {
|
|
50495
47037
|
const options = {
|
|
50496
47038
|
config: opts.config,
|
|
50497
47039
|
dryRun: opts.dryRun,
|
|
@@ -50528,7 +47070,7 @@ function createReleaseCommand() {
|
|
|
50528
47070
|
|
|
50529
47071
|
// src/cli.ts
|
|
50530
47072
|
function createReleaseProgram() {
|
|
50531
|
-
return new
|
|
47073
|
+
return new Command6().name("releasekit-release").description("Unified release pipeline: version, changelog, and publish").version(readPackageVersion(import.meta.url)).addCommand(createReleaseCommand(), { isDefault: true }).addCommand(createPreviewCommand());
|
|
50532
47074
|
}
|
|
50533
47075
|
var isMain = (() => {
|
|
50534
47076
|
try {
|