@axiomify/cli 6.0.0-rc.2 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -1
- package/dist/{dist-PKSGYMK7.mjs → dist-SYWHGZLI.mjs} +17 -30
- package/dist/index.js +440 -345
- package/dist/index.mjs +424 -316
- package/dist/{uws_darwin_arm64_108-CLFXMYPI.node → uws_darwin_arm64_127-NGHTXN5Q.node} +0 -0
- package/dist/{uws_darwin_arm64_127-KHC2FVAM.node → uws_darwin_arm64_137-ESY6MPLH.node} +0 -0
- package/dist/{uws_darwin_arm64_115-7FFEG3YF.node → uws_darwin_arm64_147-V7BKA3SU.node} +0 -0
- package/dist/{uws_darwin_x64_127-NHKQMMST.node → uws_darwin_x64_127-WIZGG7MS.node} +0 -0
- package/dist/{uws_darwin_x64_108-BRGT45AT.node → uws_darwin_x64_137-APKZWL4Y.node} +0 -0
- package/dist/{uws_darwin_x64_115-4HGPQGDD.node → uws_darwin_x64_147-W2HKFQZT.node} +0 -0
- package/dist/{uws_linux_arm64_115-EIAAY4WO.node → uws_linux_arm64_127-3CO7NSFJ.node} +0 -0
- package/dist/{uws_linux_arm64_120-OADY5FIN.node → uws_linux_arm64_137-HWEDGGZV.node} +0 -0
- package/dist/{uws_linux_arm64_108-YHK7ACON.node → uws_linux_arm64_147-7UCIYMK2.node} +0 -0
- package/dist/{uws_linux_x64_108-QSNE6XWU.node → uws_linux_x64_127-KA4E76LJ.node} +0 -0
- package/dist/{uws_linux_x64_127-HBA6RNSU.node → uws_linux_x64_137-DDFLTTJR.node} +0 -0
- package/dist/{uws_linux_x64_120-AIZ6RIW2.node → uws_linux_x64_147-MJSFREL3.node} +0 -0
- package/dist/{uws_win32_x64_120-XH4MVJGN.node → uws_win32_x64_127-O4US4Y4L.node} +0 -0
- package/dist/{uws_win32_x64_127-JBAEKR4X.node → uws_win32_x64_137-L5OZROQ7.node} +0 -0
- package/dist/{uws_win32_x64_115-V5N4NHJ5.node → uws_win32_x64_147-D7MGKVRG.node} +0 -0
- package/package.json +30 -14
- package/dist/uws_darwin_arm64_120-GFZT7CLS.node +0 -0
- package/dist/uws_darwin_x64_120-C2SGUHP4.node +0 -0
- package/dist/uws_linux_arm64_127-U2SRLYQM.node +0 -0
- package/dist/uws_linux_arm_108-BKVITVZA.node +0 -0
- package/dist/uws_linux_arm_115-7IORQF77.node +0 -0
- package/dist/uws_linux_arm_120-LCX4ED5F.node +0 -0
- package/dist/uws_linux_arm_127-6UTO7TL6.node +0 -0
- package/dist/uws_linux_x64_115-7AAZWMWE.node +0 -0
- package/dist/uws_win32_x64_108-J6KONPDM.node +0 -0
package/dist/index.mjs
CHANGED
|
@@ -19,7 +19,6 @@ var require_error = __commonJS({
|
|
|
19
19
|
* @param {number} exitCode suggested exit code which could be used with process.exit
|
|
20
20
|
* @param {string} code an id string representing the error
|
|
21
21
|
* @param {string} message human-readable description of the error
|
|
22
|
-
* @constructor
|
|
23
22
|
*/
|
|
24
23
|
constructor(exitCode, code, message) {
|
|
25
24
|
super(message);
|
|
@@ -34,7 +33,6 @@ var require_error = __commonJS({
|
|
|
34
33
|
/**
|
|
35
34
|
* Constructs the InvalidArgumentError class
|
|
36
35
|
* @param {string} [message] explanation of why argument is invalid
|
|
37
|
-
* @constructor
|
|
38
36
|
*/
|
|
39
37
|
constructor(message) {
|
|
40
38
|
super(1, "commander.invalidArgument", message);
|
|
@@ -95,7 +93,7 @@ var require_argument = __commonJS({
|
|
|
95
93
|
return this._name;
|
|
96
94
|
}
|
|
97
95
|
/**
|
|
98
|
-
* @package
|
|
96
|
+
* @package
|
|
99
97
|
*/
|
|
100
98
|
_concatValue(value, previous) {
|
|
101
99
|
if (previous === this.defaultValue || !Array.isArray(previous)) {
|
|
@@ -135,7 +133,9 @@ var require_argument = __commonJS({
|
|
|
135
133
|
this.argChoices = values.slice();
|
|
136
134
|
this.parseArg = (arg, previous) => {
|
|
137
135
|
if (!this.argChoices.includes(arg)) {
|
|
138
|
-
throw new InvalidArgumentError2(
|
|
136
|
+
throw new InvalidArgumentError2(
|
|
137
|
+
`Allowed choices are ${this.argChoices.join(", ")}.`
|
|
138
|
+
);
|
|
139
139
|
}
|
|
140
140
|
if (this.variadic) {
|
|
141
141
|
return this._concatValue(arg, previous);
|
|
@@ -146,6 +146,8 @@ var require_argument = __commonJS({
|
|
|
146
146
|
}
|
|
147
147
|
/**
|
|
148
148
|
* Make argument required.
|
|
149
|
+
*
|
|
150
|
+
* @returns {Argument}
|
|
149
151
|
*/
|
|
150
152
|
argRequired() {
|
|
151
153
|
this.required = true;
|
|
@@ -153,6 +155,8 @@ var require_argument = __commonJS({
|
|
|
153
155
|
}
|
|
154
156
|
/**
|
|
155
157
|
* Make argument optional.
|
|
158
|
+
*
|
|
159
|
+
* @returns {Argument}
|
|
156
160
|
*/
|
|
157
161
|
argOptional() {
|
|
158
162
|
this.required = false;
|
|
@@ -203,7 +207,7 @@ var require_help = __commonJS({
|
|
|
203
207
|
*
|
|
204
208
|
* @param {Option} a
|
|
205
209
|
* @param {Option} b
|
|
206
|
-
* @returns number
|
|
210
|
+
* @returns {number}
|
|
207
211
|
*/
|
|
208
212
|
compareOptions(a, b) {
|
|
209
213
|
const getSortKey = (option) => {
|
|
@@ -226,9 +230,13 @@ var require_help = __commonJS({
|
|
|
226
230
|
if (!removeShort && !removeLong) {
|
|
227
231
|
visibleOptions.push(helpOption);
|
|
228
232
|
} else if (helpOption.long && !removeLong) {
|
|
229
|
-
visibleOptions.push(
|
|
233
|
+
visibleOptions.push(
|
|
234
|
+
cmd.createOption(helpOption.long, helpOption.description)
|
|
235
|
+
);
|
|
230
236
|
} else if (helpOption.short && !removeShort) {
|
|
231
|
-
visibleOptions.push(
|
|
237
|
+
visibleOptions.push(
|
|
238
|
+
cmd.createOption(helpOption.short, helpOption.description)
|
|
239
|
+
);
|
|
232
240
|
}
|
|
233
241
|
}
|
|
234
242
|
if (this.sortOptions) {
|
|
@@ -246,7 +254,9 @@ var require_help = __commonJS({
|
|
|
246
254
|
if (!this.showGlobalOptions) return [];
|
|
247
255
|
const globalOptions = [];
|
|
248
256
|
for (let ancestorCmd = cmd.parent; ancestorCmd; ancestorCmd = ancestorCmd.parent) {
|
|
249
|
-
const visibleOptions = ancestorCmd.options.filter(
|
|
257
|
+
const visibleOptions = ancestorCmd.options.filter(
|
|
258
|
+
(option) => !option.hidden
|
|
259
|
+
);
|
|
250
260
|
globalOptions.push(...visibleOptions);
|
|
251
261
|
}
|
|
252
262
|
if (this.sortOptions) {
|
|
@@ -401,7 +411,9 @@ var require_help = __commonJS({
|
|
|
401
411
|
if (option.defaultValue !== void 0) {
|
|
402
412
|
const showDefault = option.required || option.optional || option.isBoolean() && typeof option.defaultValue === "boolean";
|
|
403
413
|
if (showDefault) {
|
|
404
|
-
extraInfo.push(
|
|
414
|
+
extraInfo.push(
|
|
415
|
+
`default: ${option.defaultValueDescription || JSON.stringify(option.defaultValue)}`
|
|
416
|
+
);
|
|
405
417
|
}
|
|
406
418
|
}
|
|
407
419
|
if (option.presetArg !== void 0 && option.optional) {
|
|
@@ -430,7 +442,9 @@ var require_help = __commonJS({
|
|
|
430
442
|
);
|
|
431
443
|
}
|
|
432
444
|
if (argument.defaultValue !== void 0) {
|
|
433
|
-
extraInfo.push(
|
|
445
|
+
extraInfo.push(
|
|
446
|
+
`default: ${argument.defaultValueDescription || JSON.stringify(argument.defaultValue)}`
|
|
447
|
+
);
|
|
434
448
|
}
|
|
435
449
|
if (extraInfo.length > 0) {
|
|
436
450
|
const extraDescripton = `(${extraInfo.join(", ")})`;
|
|
@@ -456,7 +470,11 @@ var require_help = __commonJS({
|
|
|
456
470
|
function formatItem(term, description) {
|
|
457
471
|
if (description) {
|
|
458
472
|
const fullText = `${term.padEnd(termWidth + itemSeparatorWidth)}${description}`;
|
|
459
|
-
return helper.wrap(
|
|
473
|
+
return helper.wrap(
|
|
474
|
+
fullText,
|
|
475
|
+
helpWidth - itemIndentWidth,
|
|
476
|
+
termWidth + itemSeparatorWidth
|
|
477
|
+
);
|
|
460
478
|
}
|
|
461
479
|
return term;
|
|
462
480
|
}
|
|
@@ -466,30 +484,49 @@ var require_help = __commonJS({
|
|
|
466
484
|
let output = [`Usage: ${helper.commandUsage(cmd)}`, ""];
|
|
467
485
|
const commandDescription = helper.commandDescription(cmd);
|
|
468
486
|
if (commandDescription.length > 0) {
|
|
469
|
-
output = output.concat([
|
|
487
|
+
output = output.concat([
|
|
488
|
+
helper.wrap(commandDescription, helpWidth, 0),
|
|
489
|
+
""
|
|
490
|
+
]);
|
|
470
491
|
}
|
|
471
492
|
const argumentList = helper.visibleArguments(cmd).map((argument) => {
|
|
472
|
-
return formatItem(
|
|
493
|
+
return formatItem(
|
|
494
|
+
helper.argumentTerm(argument),
|
|
495
|
+
helper.argumentDescription(argument)
|
|
496
|
+
);
|
|
473
497
|
});
|
|
474
498
|
if (argumentList.length > 0) {
|
|
475
499
|
output = output.concat(["Arguments:", formatList(argumentList), ""]);
|
|
476
500
|
}
|
|
477
501
|
const optionList = helper.visibleOptions(cmd).map((option) => {
|
|
478
|
-
return formatItem(
|
|
502
|
+
return formatItem(
|
|
503
|
+
helper.optionTerm(option),
|
|
504
|
+
helper.optionDescription(option)
|
|
505
|
+
);
|
|
479
506
|
});
|
|
480
507
|
if (optionList.length > 0) {
|
|
481
508
|
output = output.concat(["Options:", formatList(optionList), ""]);
|
|
482
509
|
}
|
|
483
510
|
if (this.showGlobalOptions) {
|
|
484
511
|
const globalOptionList = helper.visibleGlobalOptions(cmd).map((option) => {
|
|
485
|
-
return formatItem(
|
|
512
|
+
return formatItem(
|
|
513
|
+
helper.optionTerm(option),
|
|
514
|
+
helper.optionDescription(option)
|
|
515
|
+
);
|
|
486
516
|
});
|
|
487
517
|
if (globalOptionList.length > 0) {
|
|
488
|
-
output = output.concat([
|
|
518
|
+
output = output.concat([
|
|
519
|
+
"Global Options:",
|
|
520
|
+
formatList(globalOptionList),
|
|
521
|
+
""
|
|
522
|
+
]);
|
|
489
523
|
}
|
|
490
524
|
}
|
|
491
525
|
const commandList = helper.visibleCommands(cmd).map((cmd2) => {
|
|
492
|
-
return formatItem(
|
|
526
|
+
return formatItem(
|
|
527
|
+
helper.subcommandTerm(cmd2),
|
|
528
|
+
helper.subcommandDescription(cmd2)
|
|
529
|
+
);
|
|
493
530
|
});
|
|
494
531
|
if (commandList.length > 0) {
|
|
495
532
|
output = output.concat(["Commands:", formatList(commandList), ""]);
|
|
@@ -533,8 +570,11 @@ var require_help = __commonJS({
|
|
|
533
570
|
const indentString = " ".repeat(indent);
|
|
534
571
|
const zeroWidthSpace = "\u200B";
|
|
535
572
|
const breaks = `\\s${zeroWidthSpace}`;
|
|
536
|
-
const regex = new RegExp(
|
|
537
|
-
|
|
573
|
+
const regex = new RegExp(
|
|
574
|
+
`
|
|
575
|
+
|.{1,${columnWidth - 1}}([${breaks}]|$)|[^${breaks}]+?([${breaks}]|$)`,
|
|
576
|
+
"g"
|
|
577
|
+
);
|
|
538
578
|
const lines = columnText.match(regex) || [];
|
|
539
579
|
return leadingStr + lines.map((line, i) => {
|
|
540
580
|
if (line === "\n") return "";
|
|
@@ -633,7 +673,7 @@ var require_option = __commonJS({
|
|
|
633
673
|
* .addOption(new Option('--log', 'write logging information to file'))
|
|
634
674
|
* .addOption(new Option('--trace', 'log extra details').implies({ log: 'trace.txt' }));
|
|
635
675
|
*
|
|
636
|
-
* @param {
|
|
676
|
+
* @param {object} impliedOptionValues
|
|
637
677
|
* @return {Option}
|
|
638
678
|
*/
|
|
639
679
|
implies(impliedOptionValues) {
|
|
@@ -688,7 +728,7 @@ var require_option = __commonJS({
|
|
|
688
728
|
return this;
|
|
689
729
|
}
|
|
690
730
|
/**
|
|
691
|
-
* @package
|
|
731
|
+
* @package
|
|
692
732
|
*/
|
|
693
733
|
_concatValue(value, previous) {
|
|
694
734
|
if (previous === this.defaultValue || !Array.isArray(previous)) {
|
|
@@ -706,7 +746,9 @@ var require_option = __commonJS({
|
|
|
706
746
|
this.argChoices = values.slice();
|
|
707
747
|
this.parseArg = (arg, previous) => {
|
|
708
748
|
if (!this.argChoices.includes(arg)) {
|
|
709
|
-
throw new InvalidArgumentError2(
|
|
749
|
+
throw new InvalidArgumentError2(
|
|
750
|
+
`Allowed choices are ${this.argChoices.join(", ")}.`
|
|
751
|
+
);
|
|
710
752
|
}
|
|
711
753
|
if (this.variadic) {
|
|
712
754
|
return this._concatValue(arg, previous);
|
|
@@ -740,7 +782,7 @@ var require_option = __commonJS({
|
|
|
740
782
|
*
|
|
741
783
|
* @param {string} arg
|
|
742
784
|
* @return {boolean}
|
|
743
|
-
* @package
|
|
785
|
+
* @package
|
|
744
786
|
*/
|
|
745
787
|
is(arg) {
|
|
746
788
|
return this.short === arg || this.long === arg;
|
|
@@ -751,7 +793,7 @@ var require_option = __commonJS({
|
|
|
751
793
|
* Options are one of boolean, negated, required argument, or optional argument.
|
|
752
794
|
*
|
|
753
795
|
* @return {boolean}
|
|
754
|
-
* @package
|
|
796
|
+
* @package
|
|
755
797
|
*/
|
|
756
798
|
isBoolean() {
|
|
757
799
|
return !this.required && !this.optional && !this.negate;
|
|
@@ -802,7 +844,8 @@ var require_option = __commonJS({
|
|
|
802
844
|
let shortFlag;
|
|
803
845
|
let longFlag;
|
|
804
846
|
const flagParts = flags.split(/[ |,]+/);
|
|
805
|
-
if (flagParts.length > 1 && !/^[[<]/.test(flagParts[1]))
|
|
847
|
+
if (flagParts.length > 1 && !/^[[<]/.test(flagParts[1]))
|
|
848
|
+
shortFlag = flagParts.shift();
|
|
806
849
|
longFlag = flagParts.shift();
|
|
807
850
|
if (!shortFlag && /^-[^-]$/.test(longFlag)) {
|
|
808
851
|
shortFlag = longFlag;
|
|
@@ -820,7 +863,8 @@ var require_suggestSimilar = __commonJS({
|
|
|
820
863
|
"node_modules/commander/lib/suggestSimilar.js"(exports) {
|
|
821
864
|
var maxDistance = 3;
|
|
822
865
|
function editDistance(a, b) {
|
|
823
|
-
if (Math.abs(a.length - b.length) > maxDistance)
|
|
866
|
+
if (Math.abs(a.length - b.length) > maxDistance)
|
|
867
|
+
return Math.max(a.length, b.length);
|
|
824
868
|
const d = [];
|
|
825
869
|
for (let i = 0; i <= a.length; i++) {
|
|
826
870
|
d[i] = [i];
|
|
@@ -1012,8 +1056,8 @@ var require_command = __commonJS({
|
|
|
1012
1056
|
* .command('stop [service]', 'stop named service, or all if no name supplied');
|
|
1013
1057
|
*
|
|
1014
1058
|
* @param {string} nameAndArgs - command name and arguments, args are `<required>` or `[optional]` and last may also be `variadic...`
|
|
1015
|
-
* @param {(
|
|
1016
|
-
* @param {
|
|
1059
|
+
* @param {(object | string)} [actionOptsOrExecDesc] - configuration options (for action), or description (for executable)
|
|
1060
|
+
* @param {object} [execOpts] - configuration options (for executable)
|
|
1017
1061
|
* @return {Command} returns new command for action handler, or `this` for executable command
|
|
1018
1062
|
*/
|
|
1019
1063
|
command(nameAndArgs, actionOptsOrExecDesc, execOpts) {
|
|
@@ -1065,8 +1109,8 @@ var require_command = __commonJS({
|
|
|
1065
1109
|
* You can customise the help by overriding Help properties using configureHelp(),
|
|
1066
1110
|
* or with a subclass of Help by overriding createHelp().
|
|
1067
1111
|
*
|
|
1068
|
-
* @param {
|
|
1069
|
-
* @return {(Command|
|
|
1112
|
+
* @param {object} [configuration] - configuration options
|
|
1113
|
+
* @return {(Command | object)} `this` command for chaining, or stored configuration
|
|
1070
1114
|
*/
|
|
1071
1115
|
configureHelp(configuration) {
|
|
1072
1116
|
if (configuration === void 0) return this._helpConfiguration;
|
|
@@ -1088,8 +1132,8 @@ var require_command = __commonJS({
|
|
|
1088
1132
|
* // functions based on what is being written out
|
|
1089
1133
|
* outputError(str, write) // used for displaying errors, and not used for displaying help
|
|
1090
1134
|
*
|
|
1091
|
-
* @param {
|
|
1092
|
-
* @return {(Command|
|
|
1135
|
+
* @param {object} [configuration] - configuration options
|
|
1136
|
+
* @return {(Command | object)} `this` command for chaining, or stored configuration
|
|
1093
1137
|
*/
|
|
1094
1138
|
configureOutput(configuration) {
|
|
1095
1139
|
if (configuration === void 0) return this._outputConfiguration;
|
|
@@ -1123,7 +1167,7 @@ var require_command = __commonJS({
|
|
|
1123
1167
|
* See .command() for creating an attached subcommand which inherits settings from its parent.
|
|
1124
1168
|
*
|
|
1125
1169
|
* @param {Command} cmd - new subcommand
|
|
1126
|
-
* @param {
|
|
1170
|
+
* @param {object} [opts] - configuration options
|
|
1127
1171
|
* @return {Command} `this` command for chaining
|
|
1128
1172
|
*/
|
|
1129
1173
|
addCommand(cmd, opts) {
|
|
@@ -1204,10 +1248,14 @@ var require_command = __commonJS({
|
|
|
1204
1248
|
addArgument(argument) {
|
|
1205
1249
|
const previousArgument = this.registeredArguments.slice(-1)[0];
|
|
1206
1250
|
if (previousArgument && previousArgument.variadic) {
|
|
1207
|
-
throw new Error(
|
|
1251
|
+
throw new Error(
|
|
1252
|
+
`only the last argument can be variadic '${previousArgument.name()}'`
|
|
1253
|
+
);
|
|
1208
1254
|
}
|
|
1209
1255
|
if (argument.required && argument.defaultValue !== void 0 && argument.parseArg === void 0) {
|
|
1210
|
-
throw new Error(
|
|
1256
|
+
throw new Error(
|
|
1257
|
+
`a default value for a required argument is never used: '${argument.name()}'`
|
|
1258
|
+
);
|
|
1211
1259
|
}
|
|
1212
1260
|
this.registeredArguments.push(argument);
|
|
1213
1261
|
return this;
|
|
@@ -1215,6 +1263,7 @@ var require_command = __commonJS({
|
|
|
1215
1263
|
/**
|
|
1216
1264
|
* Customise or override default help command. By default a help command is automatically added if your command has subcommands.
|
|
1217
1265
|
*
|
|
1266
|
+
* @example
|
|
1218
1267
|
* program.helpCommand('help [cmd]');
|
|
1219
1268
|
* program.helpCommand('help [cmd]', 'show help');
|
|
1220
1269
|
* program.helpCommand(false); // suppress default help command
|
|
@@ -1392,7 +1441,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1392
1441
|
* Register option if no conflicts found, or throw on conflict.
|
|
1393
1442
|
*
|
|
1394
1443
|
* @param {Option} option
|
|
1395
|
-
* @
|
|
1444
|
+
* @private
|
|
1396
1445
|
*/
|
|
1397
1446
|
_registerOption(option) {
|
|
1398
1447
|
const matchingOption = option.short && this._findOption(option.short) || option.long && this._findOption(option.long);
|
|
@@ -1408,17 +1457,21 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1408
1457
|
* Register command if no conflicts found, or throw on conflict.
|
|
1409
1458
|
*
|
|
1410
1459
|
* @param {Command} command
|
|
1411
|
-
* @
|
|
1460
|
+
* @private
|
|
1412
1461
|
*/
|
|
1413
1462
|
_registerCommand(command) {
|
|
1414
1463
|
const knownBy = (cmd) => {
|
|
1415
1464
|
return [cmd.name()].concat(cmd.aliases());
|
|
1416
1465
|
};
|
|
1417
|
-
const alreadyUsed = knownBy(command).find(
|
|
1466
|
+
const alreadyUsed = knownBy(command).find(
|
|
1467
|
+
(name) => this._findCommand(name)
|
|
1468
|
+
);
|
|
1418
1469
|
if (alreadyUsed) {
|
|
1419
1470
|
const existingCmd = knownBy(this._findCommand(alreadyUsed)).join("|");
|
|
1420
1471
|
const newCmd = knownBy(command).join("|");
|
|
1421
|
-
throw new Error(
|
|
1472
|
+
throw new Error(
|
|
1473
|
+
`cannot add command '${newCmd}' as already have command '${existingCmd}'`
|
|
1474
|
+
);
|
|
1422
1475
|
}
|
|
1423
1476
|
this.commands.push(command);
|
|
1424
1477
|
}
|
|
@@ -1435,7 +1488,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1435
1488
|
if (option.negate) {
|
|
1436
1489
|
const positiveLongFlag = option.long.replace(/^--no-/, "--");
|
|
1437
1490
|
if (!this._findOption(positiveLongFlag)) {
|
|
1438
|
-
this.setOptionValueWithSource(
|
|
1491
|
+
this.setOptionValueWithSource(
|
|
1492
|
+
name,
|
|
1493
|
+
option.defaultValue === void 0 ? true : option.defaultValue,
|
|
1494
|
+
"default"
|
|
1495
|
+
);
|
|
1439
1496
|
}
|
|
1440
1497
|
} else if (option.defaultValue !== void 0) {
|
|
1441
1498
|
this.setOptionValueWithSource(name, option.defaultValue, "default");
|
|
@@ -1476,11 +1533,14 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1476
1533
|
/**
|
|
1477
1534
|
* Internal implementation shared by .option() and .requiredOption()
|
|
1478
1535
|
*
|
|
1536
|
+
* @return {Command} `this` command for chaining
|
|
1479
1537
|
* @private
|
|
1480
1538
|
*/
|
|
1481
1539
|
_optionEx(config, flags, description, fn, defaultValue) {
|
|
1482
1540
|
if (typeof flags === "object" && flags instanceof Option2) {
|
|
1483
|
-
throw new Error(
|
|
1541
|
+
throw new Error(
|
|
1542
|
+
"To add an Option object use addOption() instead of option() or requiredOption()"
|
|
1543
|
+
);
|
|
1484
1544
|
}
|
|
1485
1545
|
const option = this.createOption(flags, description);
|
|
1486
1546
|
option.makeOptionMandatory(!!config.mandatory);
|
|
@@ -1523,19 +1583,25 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1523
1583
|
return this._optionEx({}, flags, description, parseArg, defaultValue);
|
|
1524
1584
|
}
|
|
1525
1585
|
/**
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1586
|
+
* Add a required option which must have a value after parsing. This usually means
|
|
1587
|
+
* the option must be specified on the command line. (Otherwise the same as .option().)
|
|
1588
|
+
*
|
|
1589
|
+
* The `flags` string contains the short and/or long flags, separated by comma, a pipe or space.
|
|
1590
|
+
*
|
|
1591
|
+
* @param {string} flags
|
|
1592
|
+
* @param {string} [description]
|
|
1593
|
+
* @param {(Function|*)} [parseArg] - custom option processing function or default value
|
|
1594
|
+
* @param {*} [defaultValue]
|
|
1595
|
+
* @return {Command} `this` command for chaining
|
|
1596
|
+
*/
|
|
1537
1597
|
requiredOption(flags, description, parseArg, defaultValue) {
|
|
1538
|
-
return this._optionEx(
|
|
1598
|
+
return this._optionEx(
|
|
1599
|
+
{ mandatory: true },
|
|
1600
|
+
flags,
|
|
1601
|
+
description,
|
|
1602
|
+
parseArg,
|
|
1603
|
+
defaultValue
|
|
1604
|
+
);
|
|
1539
1605
|
}
|
|
1540
1606
|
/**
|
|
1541
1607
|
* Alter parsing of short flags with optional values.
|
|
@@ -1545,7 +1611,8 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1545
1611
|
* program.combineFlagAndOptionalValue(true); // `-f80` is treated like `--flag=80`, this is the default behaviour
|
|
1546
1612
|
* program.combineFlagAndOptionalValue(false) // `-fb` is treated like `-f -b`
|
|
1547
1613
|
*
|
|
1548
|
-
* @param {boolean} [combine
|
|
1614
|
+
* @param {boolean} [combine] - if `true` or omitted, an optional value can be specified directly after the flag.
|
|
1615
|
+
* @return {Command} `this` command for chaining
|
|
1549
1616
|
*/
|
|
1550
1617
|
combineFlagAndOptionalValue(combine = true) {
|
|
1551
1618
|
this._combineFlagAndOptionalValue = !!combine;
|
|
@@ -1554,8 +1621,8 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1554
1621
|
/**
|
|
1555
1622
|
* Allow unknown options on the command line.
|
|
1556
1623
|
*
|
|
1557
|
-
* @param {boolean} [allowUnknown
|
|
1558
|
-
* for
|
|
1624
|
+
* @param {boolean} [allowUnknown] - if `true` or omitted, no error will be thrown for unknown options.
|
|
1625
|
+
* @return {Command} `this` command for chaining
|
|
1559
1626
|
*/
|
|
1560
1627
|
allowUnknownOption(allowUnknown = true) {
|
|
1561
1628
|
this._allowUnknownOption = !!allowUnknown;
|
|
@@ -1564,8 +1631,8 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1564
1631
|
/**
|
|
1565
1632
|
* Allow excess command-arguments on the command line. Pass false to make excess arguments an error.
|
|
1566
1633
|
*
|
|
1567
|
-
* @param {boolean} [allowExcess
|
|
1568
|
-
* for
|
|
1634
|
+
* @param {boolean} [allowExcess] - if `true` or omitted, no error will be thrown for excess arguments.
|
|
1635
|
+
* @return {Command} `this` command for chaining
|
|
1569
1636
|
*/
|
|
1570
1637
|
allowExcessArguments(allowExcess = true) {
|
|
1571
1638
|
this._allowExcessArguments = !!allowExcess;
|
|
@@ -1576,7 +1643,8 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1576
1643
|
* subcommands reuse the same option names, and also enables subcommands to turn on passThroughOptions.
|
|
1577
1644
|
* The default behaviour is non-positional and global options may appear anywhere on the command line.
|
|
1578
1645
|
*
|
|
1579
|
-
* @param {boolean} [positional
|
|
1646
|
+
* @param {boolean} [positional]
|
|
1647
|
+
* @return {Command} `this` command for chaining
|
|
1580
1648
|
*/
|
|
1581
1649
|
enablePositionalOptions(positional = true) {
|
|
1582
1650
|
this._enablePositionalOptions = !!positional;
|
|
@@ -1588,8 +1656,8 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1588
1656
|
* positional options to have been enabled on the program (parent commands).
|
|
1589
1657
|
* The default behaviour is non-positional and options may appear before or after command-arguments.
|
|
1590
1658
|
*
|
|
1591
|
-
* @param {boolean} [passThrough
|
|
1592
|
-
* for
|
|
1659
|
+
* @param {boolean} [passThrough] for unknown options.
|
|
1660
|
+
* @return {Command} `this` command for chaining
|
|
1593
1661
|
*/
|
|
1594
1662
|
passThroughOptions(passThrough = true) {
|
|
1595
1663
|
this._passThroughOptions = !!passThrough;
|
|
@@ -1601,22 +1669,26 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1601
1669
|
*/
|
|
1602
1670
|
_checkForBrokenPassThrough() {
|
|
1603
1671
|
if (this.parent && this._passThroughOptions && !this.parent._enablePositionalOptions) {
|
|
1604
|
-
throw new Error(
|
|
1672
|
+
throw new Error(
|
|
1673
|
+
`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`
|
|
1674
|
+
);
|
|
1605
1675
|
}
|
|
1606
1676
|
}
|
|
1607
1677
|
/**
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1678
|
+
* Whether to store option values as properties on command object,
|
|
1679
|
+
* or store separately (specify false). In both cases the option values can be accessed using .opts().
|
|
1680
|
+
*
|
|
1681
|
+
* @param {boolean} [storeAsProperties=true]
|
|
1682
|
+
* @return {Command} `this` command for chaining
|
|
1683
|
+
*/
|
|
1614
1684
|
storeOptionsAsProperties(storeAsProperties = true) {
|
|
1615
1685
|
if (this.options.length) {
|
|
1616
1686
|
throw new Error("call .storeOptionsAsProperties() before adding options");
|
|
1617
1687
|
}
|
|
1618
1688
|
if (Object.keys(this._optionValues).length) {
|
|
1619
|
-
throw new Error(
|
|
1689
|
+
throw new Error(
|
|
1690
|
+
"call .storeOptionsAsProperties() before setting option values"
|
|
1691
|
+
);
|
|
1620
1692
|
}
|
|
1621
1693
|
this._storeOptionsAsProperties = !!storeAsProperties;
|
|
1622
1694
|
return this;
|
|
@@ -1625,7 +1697,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1625
1697
|
* Retrieve option value.
|
|
1626
1698
|
*
|
|
1627
1699
|
* @param {string} key
|
|
1628
|
-
* @return {
|
|
1700
|
+
* @return {object} value
|
|
1629
1701
|
*/
|
|
1630
1702
|
getOptionValue(key) {
|
|
1631
1703
|
if (this._storeOptionsAsProperties) {
|
|
@@ -1637,20 +1709,20 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1637
1709
|
* Store option value.
|
|
1638
1710
|
*
|
|
1639
1711
|
* @param {string} key
|
|
1640
|
-
* @param {
|
|
1712
|
+
* @param {object} value
|
|
1641
1713
|
* @return {Command} `this` command for chaining
|
|
1642
1714
|
*/
|
|
1643
1715
|
setOptionValue(key, value) {
|
|
1644
1716
|
return this.setOptionValueWithSource(key, value, void 0);
|
|
1645
1717
|
}
|
|
1646
1718
|
/**
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1719
|
+
* Store option value and where the value came from.
|
|
1720
|
+
*
|
|
1721
|
+
* @param {string} key
|
|
1722
|
+
* @param {object} value
|
|
1723
|
+
* @param {string} source - expected values are default/config/env/cli/implied
|
|
1724
|
+
* @return {Command} `this` command for chaining
|
|
1725
|
+
*/
|
|
1654
1726
|
setOptionValueWithSource(key, value, source) {
|
|
1655
1727
|
if (this._storeOptionsAsProperties) {
|
|
1656
1728
|
this[key] = value;
|
|
@@ -1661,22 +1733,22 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1661
1733
|
return this;
|
|
1662
1734
|
}
|
|
1663
1735
|
/**
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1736
|
+
* Get source of option value.
|
|
1737
|
+
* Expected values are default | config | env | cli | implied
|
|
1738
|
+
*
|
|
1739
|
+
* @param {string} key
|
|
1740
|
+
* @return {string}
|
|
1741
|
+
*/
|
|
1670
1742
|
getOptionValueSource(key) {
|
|
1671
1743
|
return this._optionValueSources[key];
|
|
1672
1744
|
}
|
|
1673
1745
|
/**
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1746
|
+
* Get source of option value. See also .optsWithGlobals().
|
|
1747
|
+
* Expected values are default | config | env | cli | implied
|
|
1748
|
+
*
|
|
1749
|
+
* @param {string} key
|
|
1750
|
+
* @return {string}
|
|
1751
|
+
*/
|
|
1680
1752
|
getOptionValueSourceWithGlobals(key) {
|
|
1681
1753
|
let source;
|
|
1682
1754
|
this._getCommandAndAncestors().forEach((cmd) => {
|
|
@@ -1697,11 +1769,17 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1697
1769
|
throw new Error("first parameter to parse must be array or undefined");
|
|
1698
1770
|
}
|
|
1699
1771
|
parseOptions = parseOptions || {};
|
|
1700
|
-
if (argv === void 0) {
|
|
1701
|
-
|
|
1702
|
-
if (process2.versions && process2.versions.electron) {
|
|
1772
|
+
if (argv === void 0 && parseOptions.from === void 0) {
|
|
1773
|
+
if (process2.versions?.electron) {
|
|
1703
1774
|
parseOptions.from = "electron";
|
|
1704
1775
|
}
|
|
1776
|
+
const execArgv = process2.execArgv ?? [];
|
|
1777
|
+
if (execArgv.includes("-e") || execArgv.includes("--eval") || execArgv.includes("-p") || execArgv.includes("--print")) {
|
|
1778
|
+
parseOptions.from = "eval";
|
|
1779
|
+
}
|
|
1780
|
+
}
|
|
1781
|
+
if (argv === void 0) {
|
|
1782
|
+
argv = process2.argv;
|
|
1705
1783
|
}
|
|
1706
1784
|
this.rawArgs = argv.slice();
|
|
1707
1785
|
let userArgs;
|
|
@@ -1722,26 +1800,38 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1722
1800
|
case "user":
|
|
1723
1801
|
userArgs = argv.slice(0);
|
|
1724
1802
|
break;
|
|
1803
|
+
case "eval":
|
|
1804
|
+
userArgs = argv.slice(1);
|
|
1805
|
+
break;
|
|
1725
1806
|
default:
|
|
1726
|
-
throw new Error(
|
|
1807
|
+
throw new Error(
|
|
1808
|
+
`unexpected parse option { from: '${parseOptions.from}' }`
|
|
1809
|
+
);
|
|
1727
1810
|
}
|
|
1728
|
-
if (!this._name && this._scriptPath)
|
|
1811
|
+
if (!this._name && this._scriptPath)
|
|
1812
|
+
this.nameFromFilename(this._scriptPath);
|
|
1729
1813
|
this._name = this._name || "program";
|
|
1730
1814
|
return userArgs;
|
|
1731
1815
|
}
|
|
1732
1816
|
/**
|
|
1733
1817
|
* Parse `argv`, setting options and invoking commands when defined.
|
|
1734
1818
|
*
|
|
1735
|
-
*
|
|
1736
|
-
*
|
|
1819
|
+
* Use parseAsync instead of parse if any of your action handlers are async.
|
|
1820
|
+
*
|
|
1821
|
+
* Call with no parameters to parse `process.argv`. Detects Electron and special node options like `node --eval`. Easy mode!
|
|
1822
|
+
*
|
|
1823
|
+
* Or call with an array of strings to parse, and optionally where the user arguments start by specifying where the arguments are `from`:
|
|
1824
|
+
* - `'node'`: default, `argv[0]` is the application and `argv[1]` is the script being run, with user arguments after that
|
|
1825
|
+
* - `'electron'`: `argv[0]` is the application and `argv[1]` varies depending on whether the electron application is packaged
|
|
1826
|
+
* - `'user'`: just user arguments
|
|
1737
1827
|
*
|
|
1738
1828
|
* @example
|
|
1739
|
-
* program.parse(process.argv
|
|
1740
|
-
* program.parse(); //
|
|
1829
|
+
* program.parse(); // parse process.argv and auto-detect electron and special node flags
|
|
1830
|
+
* program.parse(process.argv); // assume argv[0] is app and argv[1] is script
|
|
1741
1831
|
* program.parse(my-args, { from: 'user' }); // just user supplied arguments, nothing special about argv[0]
|
|
1742
1832
|
*
|
|
1743
1833
|
* @param {string[]} [argv] - optional, defaults to process.argv
|
|
1744
|
-
* @param {
|
|
1834
|
+
* @param {object} [parseOptions] - optionally specify style of options with from: node/user/electron
|
|
1745
1835
|
* @param {string} [parseOptions.from] - where the args are from: 'node', 'user', 'electron'
|
|
1746
1836
|
* @return {Command} `this` command for chaining
|
|
1747
1837
|
*/
|
|
@@ -1753,18 +1843,20 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1753
1843
|
/**
|
|
1754
1844
|
* Parse `argv`, setting options and invoking commands when defined.
|
|
1755
1845
|
*
|
|
1756
|
-
*
|
|
1846
|
+
* Call with no parameters to parse `process.argv`. Detects Electron and special node options like `node --eval`. Easy mode!
|
|
1757
1847
|
*
|
|
1758
|
-
*
|
|
1759
|
-
*
|
|
1848
|
+
* Or call with an array of strings to parse, and optionally where the user arguments start by specifying where the arguments are `from`:
|
|
1849
|
+
* - `'node'`: default, `argv[0]` is the application and `argv[1]` is the script being run, with user arguments after that
|
|
1850
|
+
* - `'electron'`: `argv[0]` is the application and `argv[1]` varies depending on whether the electron application is packaged
|
|
1851
|
+
* - `'user'`: just user arguments
|
|
1760
1852
|
*
|
|
1761
1853
|
* @example
|
|
1762
|
-
* await program.parseAsync(process.argv
|
|
1763
|
-
* await program.parseAsync(); //
|
|
1854
|
+
* await program.parseAsync(); // parse process.argv and auto-detect electron and special node flags
|
|
1855
|
+
* await program.parseAsync(process.argv); // assume argv[0] is app and argv[1] is script
|
|
1764
1856
|
* await program.parseAsync(my-args, { from: 'user' }); // just user supplied arguments, nothing special about argv[0]
|
|
1765
1857
|
*
|
|
1766
1858
|
* @param {string[]} [argv]
|
|
1767
|
-
* @param {
|
|
1859
|
+
* @param {object} [parseOptions]
|
|
1768
1860
|
* @param {string} parseOptions.from - where the args are from: 'node', 'user', 'electron'
|
|
1769
1861
|
* @return {Promise}
|
|
1770
1862
|
*/
|
|
@@ -1786,7 +1878,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1786
1878
|
const localBin = path11.resolve(baseDir, baseName);
|
|
1787
1879
|
if (fs9.existsSync(localBin)) return localBin;
|
|
1788
1880
|
if (sourceExt.includes(path11.extname(baseName))) return void 0;
|
|
1789
|
-
const foundExt = sourceExt.find(
|
|
1881
|
+
const foundExt = sourceExt.find(
|
|
1882
|
+
(ext) => fs9.existsSync(`${localBin}${ext}`)
|
|
1883
|
+
);
|
|
1790
1884
|
if (foundExt) return `${localBin}${foundExt}`;
|
|
1791
1885
|
return void 0;
|
|
1792
1886
|
}
|
|
@@ -1801,14 +1895,23 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1801
1895
|
} catch (err) {
|
|
1802
1896
|
resolvedScriptPath = this._scriptPath;
|
|
1803
1897
|
}
|
|
1804
|
-
executableDir = path11.resolve(
|
|
1898
|
+
executableDir = path11.resolve(
|
|
1899
|
+
path11.dirname(resolvedScriptPath),
|
|
1900
|
+
executableDir
|
|
1901
|
+
);
|
|
1805
1902
|
}
|
|
1806
1903
|
if (executableDir) {
|
|
1807
1904
|
let localFile = findFile(executableDir, executableFile);
|
|
1808
1905
|
if (!localFile && !subcommand._executableFile && this._scriptPath) {
|
|
1809
|
-
const legacyName = path11.basename(
|
|
1906
|
+
const legacyName = path11.basename(
|
|
1907
|
+
this._scriptPath,
|
|
1908
|
+
path11.extname(this._scriptPath)
|
|
1909
|
+
);
|
|
1810
1910
|
if (legacyName !== this._name) {
|
|
1811
|
-
localFile = findFile(
|
|
1911
|
+
localFile = findFile(
|
|
1912
|
+
executableDir,
|
|
1913
|
+
`${legacyName}-${subcommand._name}`
|
|
1914
|
+
);
|
|
1812
1915
|
}
|
|
1813
1916
|
}
|
|
1814
1917
|
executableFile = localFile || executableFile;
|
|
@@ -1839,12 +1942,18 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1839
1942
|
});
|
|
1840
1943
|
}
|
|
1841
1944
|
const exitCallback = this._exitCallback;
|
|
1842
|
-
proc.on("close", (code
|
|
1945
|
+
proc.on("close", (code) => {
|
|
1843
1946
|
code = code ?? 1;
|
|
1844
1947
|
if (!exitCallback) {
|
|
1845
1948
|
process2.exit(code);
|
|
1846
1949
|
} else {
|
|
1847
|
-
exitCallback(
|
|
1950
|
+
exitCallback(
|
|
1951
|
+
new CommanderError2(
|
|
1952
|
+
code,
|
|
1953
|
+
"commander.executeSubCommandAsync",
|
|
1954
|
+
"(close)"
|
|
1955
|
+
)
|
|
1956
|
+
);
|
|
1848
1957
|
}
|
|
1849
1958
|
});
|
|
1850
1959
|
proc.on("error", (err) => {
|
|
@@ -1861,7 +1970,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1861
1970
|
if (!exitCallback) {
|
|
1862
1971
|
process2.exit(1);
|
|
1863
1972
|
} else {
|
|
1864
|
-
const wrappedError = new CommanderError2(
|
|
1973
|
+
const wrappedError = new CommanderError2(
|
|
1974
|
+
1,
|
|
1975
|
+
"commander.executeSubCommandAsync",
|
|
1976
|
+
"(error)"
|
|
1977
|
+
);
|
|
1865
1978
|
wrappedError.nestedError = err;
|
|
1866
1979
|
exitCallback(wrappedError);
|
|
1867
1980
|
}
|
|
@@ -1875,7 +1988,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1875
1988
|
const subCommand = this._findCommand(commandName);
|
|
1876
1989
|
if (!subCommand) this.help({ error: true });
|
|
1877
1990
|
let promiseChain;
|
|
1878
|
-
promiseChain = this._chainOrCallSubCommandHook(
|
|
1991
|
+
promiseChain = this._chainOrCallSubCommandHook(
|
|
1992
|
+
promiseChain,
|
|
1993
|
+
subCommand,
|
|
1994
|
+
"preSubcommand"
|
|
1995
|
+
);
|
|
1879
1996
|
promiseChain = this._chainOrCall(promiseChain, () => {
|
|
1880
1997
|
if (subCommand._executableHandler) {
|
|
1881
1998
|
this._executeSubCommand(subCommand, operands.concat(unknown));
|
|
@@ -1899,9 +2016,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1899
2016
|
if (subCommand && !subCommand._executableHandler) {
|
|
1900
2017
|
subCommand.help();
|
|
1901
2018
|
}
|
|
1902
|
-
return this._dispatchSubcommand(
|
|
1903
|
-
|
|
1904
|
-
|
|
2019
|
+
return this._dispatchSubcommand(
|
|
2020
|
+
subcommandName,
|
|
2021
|
+
[],
|
|
2022
|
+
[this._getHelpOption()?.long ?? this._getHelpOption()?.short ?? "--help"]
|
|
2023
|
+
);
|
|
1905
2024
|
}
|
|
1906
2025
|
/**
|
|
1907
2026
|
* Check this.args against expected this.registeredArguments.
|
|
@@ -1931,7 +2050,12 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1931
2050
|
let parsedValue = value;
|
|
1932
2051
|
if (value !== null && argument.parseArg) {
|
|
1933
2052
|
const invalidValueMessage = `error: command-argument value '${value}' is invalid for argument '${argument.name()}'.`;
|
|
1934
|
-
parsedValue = this._callParseArg(
|
|
2053
|
+
parsedValue = this._callParseArg(
|
|
2054
|
+
argument,
|
|
2055
|
+
value,
|
|
2056
|
+
previous,
|
|
2057
|
+
invalidValueMessage
|
|
2058
|
+
);
|
|
1935
2059
|
}
|
|
1936
2060
|
return parsedValue;
|
|
1937
2061
|
};
|
|
@@ -2039,7 +2163,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2039
2163
|
}
|
|
2040
2164
|
if (this._defaultCommandName) {
|
|
2041
2165
|
this._outputHelpIfRequested(unknown);
|
|
2042
|
-
return this._dispatchSubcommand(
|
|
2166
|
+
return this._dispatchSubcommand(
|
|
2167
|
+
this._defaultCommandName,
|
|
2168
|
+
operands,
|
|
2169
|
+
unknown
|
|
2170
|
+
);
|
|
2043
2171
|
}
|
|
2044
2172
|
if (this.commands.length && this.args.length === 0 && !this._actionHandler && !this._defaultCommandName) {
|
|
2045
2173
|
this.help({ error: true });
|
|
@@ -2058,7 +2186,10 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2058
2186
|
this._processArguments();
|
|
2059
2187
|
let promiseChain;
|
|
2060
2188
|
promiseChain = this._chainOrCallHooks(promiseChain, "preAction");
|
|
2061
|
-
promiseChain = this._chainOrCall(
|
|
2189
|
+
promiseChain = this._chainOrCall(
|
|
2190
|
+
promiseChain,
|
|
2191
|
+
() => this._actionHandler(this.processedArgs)
|
|
2192
|
+
);
|
|
2062
2193
|
if (this.parent) {
|
|
2063
2194
|
promiseChain = this._chainOrCall(promiseChain, () => {
|
|
2064
2195
|
this.parent.emit(commandEvent, operands, unknown);
|
|
@@ -2095,17 +2226,20 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2095
2226
|
* Find matching command.
|
|
2096
2227
|
*
|
|
2097
2228
|
* @private
|
|
2229
|
+
* @return {Command | undefined}
|
|
2098
2230
|
*/
|
|
2099
2231
|
_findCommand(name) {
|
|
2100
2232
|
if (!name) return void 0;
|
|
2101
|
-
return this.commands.find(
|
|
2233
|
+
return this.commands.find(
|
|
2234
|
+
(cmd) => cmd._name === name || cmd._aliases.includes(name)
|
|
2235
|
+
);
|
|
2102
2236
|
}
|
|
2103
2237
|
/**
|
|
2104
2238
|
* Return an option matching `arg` if any.
|
|
2105
2239
|
*
|
|
2106
2240
|
* @param {string} arg
|
|
2107
2241
|
* @return {Option}
|
|
2108
|
-
* @package
|
|
2242
|
+
* @package
|
|
2109
2243
|
*/
|
|
2110
2244
|
_findOption(arg) {
|
|
2111
2245
|
return this.options.find((option) => option.is(arg));
|
|
@@ -2131,15 +2265,13 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2131
2265
|
* @private
|
|
2132
2266
|
*/
|
|
2133
2267
|
_checkForConflictingLocalOptions() {
|
|
2134
|
-
const definedNonDefaultOptions = this.options.filter(
|
|
2135
|
-
(
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
return false;
|
|
2139
|
-
}
|
|
2140
|
-
return this.getOptionValueSource(optionKey) !== "default";
|
|
2268
|
+
const definedNonDefaultOptions = this.options.filter((option) => {
|
|
2269
|
+
const optionKey = option.attributeName();
|
|
2270
|
+
if (this.getOptionValue(optionKey) === void 0) {
|
|
2271
|
+
return false;
|
|
2141
2272
|
}
|
|
2142
|
-
|
|
2273
|
+
return this.getOptionValueSource(optionKey) !== "default";
|
|
2274
|
+
});
|
|
2143
2275
|
const optionsWithConflicting = definedNonDefaultOptions.filter(
|
|
2144
2276
|
(option) => option.conflictsWith.length > 0
|
|
2145
2277
|
);
|
|
@@ -2269,7 +2401,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2269
2401
|
/**
|
|
2270
2402
|
* Return an object containing local option values as key-value pairs.
|
|
2271
2403
|
*
|
|
2272
|
-
* @return {
|
|
2404
|
+
* @return {object}
|
|
2273
2405
|
*/
|
|
2274
2406
|
opts() {
|
|
2275
2407
|
if (this._storeOptionsAsProperties) {
|
|
@@ -2286,7 +2418,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2286
2418
|
/**
|
|
2287
2419
|
* Return an object containing merged local and global option values as key-value pairs.
|
|
2288
2420
|
*
|
|
2289
|
-
* @return {
|
|
2421
|
+
* @return {object}
|
|
2290
2422
|
*/
|
|
2291
2423
|
optsWithGlobals() {
|
|
2292
2424
|
return this._getCommandAndAncestors().reduce(
|
|
@@ -2298,13 +2430,16 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2298
2430
|
* Display error message and exit (or call exitOverride).
|
|
2299
2431
|
*
|
|
2300
2432
|
* @param {string} message
|
|
2301
|
-
* @param {
|
|
2433
|
+
* @param {object} [errorOptions]
|
|
2302
2434
|
* @param {string} [errorOptions.code] - an id string representing the error
|
|
2303
2435
|
* @param {number} [errorOptions.exitCode] - used with process.exit
|
|
2304
2436
|
*/
|
|
2305
2437
|
error(message, errorOptions) {
|
|
2306
|
-
this._outputConfiguration.outputError(
|
|
2307
|
-
|
|
2438
|
+
this._outputConfiguration.outputError(
|
|
2439
|
+
`${message}
|
|
2440
|
+
`,
|
|
2441
|
+
this._outputConfiguration.writeErr
|
|
2442
|
+
);
|
|
2308
2443
|
if (typeof this._showHelpAfterError === "string") {
|
|
2309
2444
|
this._outputConfiguration.writeErr(`${this._showHelpAfterError}
|
|
2310
2445
|
`);
|
|
@@ -2327,7 +2462,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2327
2462
|
this.options.forEach((option) => {
|
|
2328
2463
|
if (option.envVar && option.envVar in process2.env) {
|
|
2329
2464
|
const optionKey = option.attributeName();
|
|
2330
|
-
if (this.getOptionValue(optionKey) === void 0 || ["default", "config", "env"].includes(
|
|
2465
|
+
if (this.getOptionValue(optionKey) === void 0 || ["default", "config", "env"].includes(
|
|
2466
|
+
this.getOptionValueSource(optionKey)
|
|
2467
|
+
)) {
|
|
2331
2468
|
if (option.required || option.optional) {
|
|
2332
2469
|
this.emit(`optionEnv:${option.name()}`, process2.env[option.envVar]);
|
|
2333
2470
|
} else {
|
|
@@ -2347,9 +2484,18 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2347
2484
|
const hasCustomOptionValue = (optionKey) => {
|
|
2348
2485
|
return this.getOptionValue(optionKey) !== void 0 && !["default", "implied"].includes(this.getOptionValueSource(optionKey));
|
|
2349
2486
|
};
|
|
2350
|
-
this.options.filter(
|
|
2487
|
+
this.options.filter(
|
|
2488
|
+
(option) => option.implied !== void 0 && hasCustomOptionValue(option.attributeName()) && dualHelper.valueFromOption(
|
|
2489
|
+
this.getOptionValue(option.attributeName()),
|
|
2490
|
+
option
|
|
2491
|
+
)
|
|
2492
|
+
).forEach((option) => {
|
|
2351
2493
|
Object.keys(option.implied).filter((impliedKey) => !hasCustomOptionValue(impliedKey)).forEach((impliedKey) => {
|
|
2352
|
-
this.setOptionValueWithSource(
|
|
2494
|
+
this.setOptionValueWithSource(
|
|
2495
|
+
impliedKey,
|
|
2496
|
+
option.implied[impliedKey],
|
|
2497
|
+
"implied"
|
|
2498
|
+
);
|
|
2353
2499
|
});
|
|
2354
2500
|
});
|
|
2355
2501
|
}
|
|
@@ -2394,8 +2540,12 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2394
2540
|
const findBestOptionFromValue = (option2) => {
|
|
2395
2541
|
const optionKey = option2.attributeName();
|
|
2396
2542
|
const optionValue = this.getOptionValue(optionKey);
|
|
2397
|
-
const negativeOption = this.options.find(
|
|
2398
|
-
|
|
2543
|
+
const negativeOption = this.options.find(
|
|
2544
|
+
(target) => target.negate && optionKey === target.attributeName()
|
|
2545
|
+
);
|
|
2546
|
+
const positiveOption = this.options.find(
|
|
2547
|
+
(target) => !target.negate && optionKey === target.attributeName()
|
|
2548
|
+
);
|
|
2399
2549
|
if (negativeOption && (negativeOption.presetArg === void 0 && optionValue === false || negativeOption.presetArg !== void 0 && optionValue === negativeOption.presetArg)) {
|
|
2400
2550
|
return negativeOption;
|
|
2401
2551
|
}
|
|
@@ -2499,11 +2649,12 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2499
2649
|
* Set the description.
|
|
2500
2650
|
*
|
|
2501
2651
|
* @param {string} [str]
|
|
2502
|
-
* @param {
|
|
2652
|
+
* @param {object} [argsDescription]
|
|
2503
2653
|
* @return {(string|Command)}
|
|
2504
2654
|
*/
|
|
2505
2655
|
description(str, argsDescription) {
|
|
2506
|
-
if (str === void 0 && argsDescription === void 0)
|
|
2656
|
+
if (str === void 0 && argsDescription === void 0)
|
|
2657
|
+
return this._description;
|
|
2507
2658
|
this._description = str;
|
|
2508
2659
|
if (argsDescription) {
|
|
2509
2660
|
this._argsDescription = argsDescription;
|
|
@@ -2535,11 +2686,14 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2535
2686
|
if (this.commands.length !== 0 && this.commands[this.commands.length - 1]._executableHandler) {
|
|
2536
2687
|
command = this.commands[this.commands.length - 1];
|
|
2537
2688
|
}
|
|
2538
|
-
if (alias === command._name)
|
|
2689
|
+
if (alias === command._name)
|
|
2690
|
+
throw new Error("Command alias can't be the same as its name");
|
|
2539
2691
|
const matchingCommand = this.parent?._findCommand(alias);
|
|
2540
2692
|
if (matchingCommand) {
|
|
2541
2693
|
const existingCmd = [matchingCommand.name()].concat(matchingCommand.aliases()).join("|");
|
|
2542
|
-
throw new Error(
|
|
2694
|
+
throw new Error(
|
|
2695
|
+
`cannot add alias '${alias}' to command '${this.name()}' as already have command '${existingCmd}'`
|
|
2696
|
+
);
|
|
2543
2697
|
}
|
|
2544
2698
|
command._aliases.push(alias);
|
|
2545
2699
|
return this;
|
|
@@ -2678,7 +2832,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2678
2832
|
this.emit(this._getHelpOption().long);
|
|
2679
2833
|
}
|
|
2680
2834
|
this.emit("afterHelp", context2);
|
|
2681
|
-
this._getCommandAndAncestors().forEach(
|
|
2835
|
+
this._getCommandAndAncestors().forEach(
|
|
2836
|
+
(command) => command.emit("afterAllHelp", context2)
|
|
2837
|
+
);
|
|
2682
2838
|
}
|
|
2683
2839
|
/**
|
|
2684
2840
|
* You can pass in flags and a description to customise the built-in help option.
|
|
@@ -2711,7 +2867,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2711
2867
|
* Returns null if has been disabled with .helpOption(false).
|
|
2712
2868
|
*
|
|
2713
2869
|
* @returns {(Option | null)} the help option
|
|
2714
|
-
* @package
|
|
2870
|
+
* @package
|
|
2715
2871
|
*/
|
|
2716
2872
|
_getHelpOption() {
|
|
2717
2873
|
if (this._helpOption === void 0) {
|
|
@@ -2846,171 +3002,108 @@ var require_commander = __commonJS({
|
|
|
2846
3002
|
}
|
|
2847
3003
|
});
|
|
2848
3004
|
|
|
2849
|
-
// ../../node_modules/uWebSockets.js/uws_darwin_arm64_108.node
|
|
2850
|
-
var require_uws_darwin_arm64_108 = __commonJS({
|
|
2851
|
-
"../../node_modules/uWebSockets.js/uws_darwin_arm64_108.node"(exports, module) {
|
|
2852
|
-
module.exports = "./uws_darwin_arm64_108-CLFXMYPI.node";
|
|
2853
|
-
}
|
|
2854
|
-
});
|
|
2855
|
-
|
|
2856
|
-
// ../../node_modules/uWebSockets.js/uws_darwin_arm64_115.node
|
|
2857
|
-
var require_uws_darwin_arm64_115 = __commonJS({
|
|
2858
|
-
"../../node_modules/uWebSockets.js/uws_darwin_arm64_115.node"(exports, module) {
|
|
2859
|
-
module.exports = "./uws_darwin_arm64_115-7FFEG3YF.node";
|
|
2860
|
-
}
|
|
2861
|
-
});
|
|
2862
|
-
|
|
2863
|
-
// ../../node_modules/uWebSockets.js/uws_darwin_arm64_120.node
|
|
2864
|
-
var require_uws_darwin_arm64_120 = __commonJS({
|
|
2865
|
-
"../../node_modules/uWebSockets.js/uws_darwin_arm64_120.node"(exports, module) {
|
|
2866
|
-
module.exports = "./uws_darwin_arm64_120-GFZT7CLS.node";
|
|
2867
|
-
}
|
|
2868
|
-
});
|
|
2869
|
-
|
|
2870
3005
|
// ../../node_modules/uWebSockets.js/uws_darwin_arm64_127.node
|
|
2871
3006
|
var require_uws_darwin_arm64_127 = __commonJS({
|
|
2872
3007
|
"../../node_modules/uWebSockets.js/uws_darwin_arm64_127.node"(exports, module) {
|
|
2873
|
-
module.exports = "./uws_darwin_arm64_127-
|
|
2874
|
-
}
|
|
2875
|
-
});
|
|
2876
|
-
|
|
2877
|
-
// ../../node_modules/uWebSockets.js/uws_darwin_x64_108.node
|
|
2878
|
-
var require_uws_darwin_x64_108 = __commonJS({
|
|
2879
|
-
"../../node_modules/uWebSockets.js/uws_darwin_x64_108.node"(exports, module) {
|
|
2880
|
-
module.exports = "./uws_darwin_x64_108-BRGT45AT.node";
|
|
3008
|
+
module.exports = "./uws_darwin_arm64_127-NGHTXN5Q.node";
|
|
2881
3009
|
}
|
|
2882
3010
|
});
|
|
2883
3011
|
|
|
2884
|
-
// ../../node_modules/uWebSockets.js/
|
|
2885
|
-
var
|
|
2886
|
-
"../../node_modules/uWebSockets.js/
|
|
2887
|
-
module.exports = "./
|
|
3012
|
+
// ../../node_modules/uWebSockets.js/uws_darwin_arm64_137.node
|
|
3013
|
+
var require_uws_darwin_arm64_137 = __commonJS({
|
|
3014
|
+
"../../node_modules/uWebSockets.js/uws_darwin_arm64_137.node"(exports, module) {
|
|
3015
|
+
module.exports = "./uws_darwin_arm64_137-ESY6MPLH.node";
|
|
2888
3016
|
}
|
|
2889
3017
|
});
|
|
2890
3018
|
|
|
2891
|
-
// ../../node_modules/uWebSockets.js/
|
|
2892
|
-
var
|
|
2893
|
-
"../../node_modules/uWebSockets.js/
|
|
2894
|
-
module.exports = "./
|
|
3019
|
+
// ../../node_modules/uWebSockets.js/uws_darwin_arm64_147.node
|
|
3020
|
+
var require_uws_darwin_arm64_147 = __commonJS({
|
|
3021
|
+
"../../node_modules/uWebSockets.js/uws_darwin_arm64_147.node"(exports, module) {
|
|
3022
|
+
module.exports = "./uws_darwin_arm64_147-V7BKA3SU.node";
|
|
2895
3023
|
}
|
|
2896
3024
|
});
|
|
2897
3025
|
|
|
2898
3026
|
// ../../node_modules/uWebSockets.js/uws_darwin_x64_127.node
|
|
2899
3027
|
var require_uws_darwin_x64_127 = __commonJS({
|
|
2900
3028
|
"../../node_modules/uWebSockets.js/uws_darwin_x64_127.node"(exports, module) {
|
|
2901
|
-
module.exports = "./uws_darwin_x64_127-
|
|
2902
|
-
}
|
|
2903
|
-
});
|
|
2904
|
-
|
|
2905
|
-
// ../../node_modules/uWebSockets.js/uws_linux_arm64_108.node
|
|
2906
|
-
var require_uws_linux_arm64_108 = __commonJS({
|
|
2907
|
-
"../../node_modules/uWebSockets.js/uws_linux_arm64_108.node"(exports, module) {
|
|
2908
|
-
module.exports = "./uws_linux_arm64_108-YHK7ACON.node";
|
|
3029
|
+
module.exports = "./uws_darwin_x64_127-WIZGG7MS.node";
|
|
2909
3030
|
}
|
|
2910
3031
|
});
|
|
2911
3032
|
|
|
2912
|
-
// ../../node_modules/uWebSockets.js/
|
|
2913
|
-
var
|
|
2914
|
-
"../../node_modules/uWebSockets.js/
|
|
2915
|
-
module.exports = "./
|
|
3033
|
+
// ../../node_modules/uWebSockets.js/uws_darwin_x64_137.node
|
|
3034
|
+
var require_uws_darwin_x64_137 = __commonJS({
|
|
3035
|
+
"../../node_modules/uWebSockets.js/uws_darwin_x64_137.node"(exports, module) {
|
|
3036
|
+
module.exports = "./uws_darwin_x64_137-APKZWL4Y.node";
|
|
2916
3037
|
}
|
|
2917
3038
|
});
|
|
2918
3039
|
|
|
2919
|
-
// ../../node_modules/uWebSockets.js/
|
|
2920
|
-
var
|
|
2921
|
-
"../../node_modules/uWebSockets.js/
|
|
2922
|
-
module.exports = "./
|
|
3040
|
+
// ../../node_modules/uWebSockets.js/uws_darwin_x64_147.node
|
|
3041
|
+
var require_uws_darwin_x64_147 = __commonJS({
|
|
3042
|
+
"../../node_modules/uWebSockets.js/uws_darwin_x64_147.node"(exports, module) {
|
|
3043
|
+
module.exports = "./uws_darwin_x64_147-W2HKFQZT.node";
|
|
2923
3044
|
}
|
|
2924
3045
|
});
|
|
2925
3046
|
|
|
2926
3047
|
// ../../node_modules/uWebSockets.js/uws_linux_arm64_127.node
|
|
2927
3048
|
var require_uws_linux_arm64_127 = __commonJS({
|
|
2928
3049
|
"../../node_modules/uWebSockets.js/uws_linux_arm64_127.node"(exports, module) {
|
|
2929
|
-
module.exports = "./uws_linux_arm64_127-
|
|
2930
|
-
}
|
|
2931
|
-
});
|
|
2932
|
-
|
|
2933
|
-
// ../../node_modules/uWebSockets.js/uws_linux_arm_108.node
|
|
2934
|
-
var require_uws_linux_arm_108 = __commonJS({
|
|
2935
|
-
"../../node_modules/uWebSockets.js/uws_linux_arm_108.node"(exports, module) {
|
|
2936
|
-
module.exports = "./uws_linux_arm_108-BKVITVZA.node";
|
|
3050
|
+
module.exports = "./uws_linux_arm64_127-3CO7NSFJ.node";
|
|
2937
3051
|
}
|
|
2938
3052
|
});
|
|
2939
3053
|
|
|
2940
|
-
// ../../node_modules/uWebSockets.js/
|
|
2941
|
-
var
|
|
2942
|
-
"../../node_modules/uWebSockets.js/
|
|
2943
|
-
module.exports = "./
|
|
3054
|
+
// ../../node_modules/uWebSockets.js/uws_linux_arm64_137.node
|
|
3055
|
+
var require_uws_linux_arm64_137 = __commonJS({
|
|
3056
|
+
"../../node_modules/uWebSockets.js/uws_linux_arm64_137.node"(exports, module) {
|
|
3057
|
+
module.exports = "./uws_linux_arm64_137-HWEDGGZV.node";
|
|
2944
3058
|
}
|
|
2945
3059
|
});
|
|
2946
3060
|
|
|
2947
|
-
// ../../node_modules/uWebSockets.js/
|
|
2948
|
-
var
|
|
2949
|
-
"../../node_modules/uWebSockets.js/
|
|
2950
|
-
module.exports = "./
|
|
2951
|
-
}
|
|
2952
|
-
});
|
|
2953
|
-
|
|
2954
|
-
// ../../node_modules/uWebSockets.js/uws_linux_arm_127.node
|
|
2955
|
-
var require_uws_linux_arm_127 = __commonJS({
|
|
2956
|
-
"../../node_modules/uWebSockets.js/uws_linux_arm_127.node"(exports, module) {
|
|
2957
|
-
module.exports = "./uws_linux_arm_127-6UTO7TL6.node";
|
|
2958
|
-
}
|
|
2959
|
-
});
|
|
2960
|
-
|
|
2961
|
-
// ../../node_modules/uWebSockets.js/uws_linux_x64_108.node
|
|
2962
|
-
var require_uws_linux_x64_108 = __commonJS({
|
|
2963
|
-
"../../node_modules/uWebSockets.js/uws_linux_x64_108.node"(exports, module) {
|
|
2964
|
-
module.exports = "./uws_linux_x64_108-QSNE6XWU.node";
|
|
2965
|
-
}
|
|
2966
|
-
});
|
|
2967
|
-
|
|
2968
|
-
// ../../node_modules/uWebSockets.js/uws_linux_x64_115.node
|
|
2969
|
-
var require_uws_linux_x64_115 = __commonJS({
|
|
2970
|
-
"../../node_modules/uWebSockets.js/uws_linux_x64_115.node"(exports, module) {
|
|
2971
|
-
module.exports = "./uws_linux_x64_115-7AAZWMWE.node";
|
|
2972
|
-
}
|
|
2973
|
-
});
|
|
2974
|
-
|
|
2975
|
-
// ../../node_modules/uWebSockets.js/uws_linux_x64_120.node
|
|
2976
|
-
var require_uws_linux_x64_120 = __commonJS({
|
|
2977
|
-
"../../node_modules/uWebSockets.js/uws_linux_x64_120.node"(exports, module) {
|
|
2978
|
-
module.exports = "./uws_linux_x64_120-AIZ6RIW2.node";
|
|
3061
|
+
// ../../node_modules/uWebSockets.js/uws_linux_arm64_147.node
|
|
3062
|
+
var require_uws_linux_arm64_147 = __commonJS({
|
|
3063
|
+
"../../node_modules/uWebSockets.js/uws_linux_arm64_147.node"(exports, module) {
|
|
3064
|
+
module.exports = "./uws_linux_arm64_147-7UCIYMK2.node";
|
|
2979
3065
|
}
|
|
2980
3066
|
});
|
|
2981
3067
|
|
|
2982
3068
|
// ../../node_modules/uWebSockets.js/uws_linux_x64_127.node
|
|
2983
3069
|
var require_uws_linux_x64_127 = __commonJS({
|
|
2984
3070
|
"../../node_modules/uWebSockets.js/uws_linux_x64_127.node"(exports, module) {
|
|
2985
|
-
module.exports = "./uws_linux_x64_127-
|
|
3071
|
+
module.exports = "./uws_linux_x64_127-KA4E76LJ.node";
|
|
2986
3072
|
}
|
|
2987
3073
|
});
|
|
2988
3074
|
|
|
2989
|
-
// ../../node_modules/uWebSockets.js/
|
|
2990
|
-
var
|
|
2991
|
-
"../../node_modules/uWebSockets.js/
|
|
2992
|
-
module.exports = "./
|
|
3075
|
+
// ../../node_modules/uWebSockets.js/uws_linux_x64_137.node
|
|
3076
|
+
var require_uws_linux_x64_137 = __commonJS({
|
|
3077
|
+
"../../node_modules/uWebSockets.js/uws_linux_x64_137.node"(exports, module) {
|
|
3078
|
+
module.exports = "./uws_linux_x64_137-DDFLTTJR.node";
|
|
2993
3079
|
}
|
|
2994
3080
|
});
|
|
2995
3081
|
|
|
2996
|
-
// ../../node_modules/uWebSockets.js/
|
|
2997
|
-
var
|
|
2998
|
-
"../../node_modules/uWebSockets.js/
|
|
2999
|
-
module.exports = "./
|
|
3000
|
-
}
|
|
3001
|
-
});
|
|
3002
|
-
|
|
3003
|
-
// ../../node_modules/uWebSockets.js/uws_win32_x64_120.node
|
|
3004
|
-
var require_uws_win32_x64_120 = __commonJS({
|
|
3005
|
-
"../../node_modules/uWebSockets.js/uws_win32_x64_120.node"(exports, module) {
|
|
3006
|
-
module.exports = "./uws_win32_x64_120-XH4MVJGN.node";
|
|
3082
|
+
// ../../node_modules/uWebSockets.js/uws_linux_x64_147.node
|
|
3083
|
+
var require_uws_linux_x64_147 = __commonJS({
|
|
3084
|
+
"../../node_modules/uWebSockets.js/uws_linux_x64_147.node"(exports, module) {
|
|
3085
|
+
module.exports = "./uws_linux_x64_147-MJSFREL3.node";
|
|
3007
3086
|
}
|
|
3008
3087
|
});
|
|
3009
3088
|
|
|
3010
3089
|
// ../../node_modules/uWebSockets.js/uws_win32_x64_127.node
|
|
3011
3090
|
var require_uws_win32_x64_127 = __commonJS({
|
|
3012
3091
|
"../../node_modules/uWebSockets.js/uws_win32_x64_127.node"(exports, module) {
|
|
3013
|
-
module.exports = "./uws_win32_x64_127-
|
|
3092
|
+
module.exports = "./uws_win32_x64_127-O4US4Y4L.node";
|
|
3093
|
+
}
|
|
3094
|
+
});
|
|
3095
|
+
|
|
3096
|
+
// ../../node_modules/uWebSockets.js/uws_win32_x64_137.node
|
|
3097
|
+
var require_uws_win32_x64_137 = __commonJS({
|
|
3098
|
+
"../../node_modules/uWebSockets.js/uws_win32_x64_137.node"(exports, module) {
|
|
3099
|
+
module.exports = "./uws_win32_x64_137-L5OZROQ7.node";
|
|
3100
|
+
}
|
|
3101
|
+
});
|
|
3102
|
+
|
|
3103
|
+
// ../../node_modules/uWebSockets.js/uws_win32_x64_147.node
|
|
3104
|
+
var require_uws_win32_x64_147 = __commonJS({
|
|
3105
|
+
"../../node_modules/uWebSockets.js/uws_win32_x64_147.node"(exports, module) {
|
|
3106
|
+
module.exports = "./uws_win32_x64_147-D7MGKVRG.node";
|
|
3014
3107
|
}
|
|
3015
3108
|
});
|
|
3016
3109
|
|
|
@@ -3019,30 +3112,21 @@ var globRequire_uws______node;
|
|
|
3019
3112
|
var init_ = __esm({
|
|
3020
3113
|
'require("./uws_*_*_*.node") in ../../node_modules/uWebSockets.js/uws.js'() {
|
|
3021
3114
|
globRequire_uws______node = __glob({
|
|
3022
|
-
"./uws_darwin_arm64_108.node": () => require_uws_darwin_arm64_108(),
|
|
3023
|
-
"./uws_darwin_arm64_115.node": () => require_uws_darwin_arm64_115(),
|
|
3024
|
-
"./uws_darwin_arm64_120.node": () => require_uws_darwin_arm64_120(),
|
|
3025
3115
|
"./uws_darwin_arm64_127.node": () => require_uws_darwin_arm64_127(),
|
|
3026
|
-
"./
|
|
3027
|
-
"./
|
|
3028
|
-
"./uws_darwin_x64_120.node": () => require_uws_darwin_x64_120(),
|
|
3116
|
+
"./uws_darwin_arm64_137.node": () => require_uws_darwin_arm64_137(),
|
|
3117
|
+
"./uws_darwin_arm64_147.node": () => require_uws_darwin_arm64_147(),
|
|
3029
3118
|
"./uws_darwin_x64_127.node": () => require_uws_darwin_x64_127(),
|
|
3030
|
-
"./
|
|
3031
|
-
"./
|
|
3032
|
-
"./uws_linux_arm64_120.node": () => require_uws_linux_arm64_120(),
|
|
3119
|
+
"./uws_darwin_x64_137.node": () => require_uws_darwin_x64_137(),
|
|
3120
|
+
"./uws_darwin_x64_147.node": () => require_uws_darwin_x64_147(),
|
|
3033
3121
|
"./uws_linux_arm64_127.node": () => require_uws_linux_arm64_127(),
|
|
3034
|
-
"./
|
|
3035
|
-
"./
|
|
3036
|
-
"./uws_linux_arm_120.node": () => require_uws_linux_arm_120(),
|
|
3037
|
-
"./uws_linux_arm_127.node": () => require_uws_linux_arm_127(),
|
|
3038
|
-
"./uws_linux_x64_108.node": () => require_uws_linux_x64_108(),
|
|
3039
|
-
"./uws_linux_x64_115.node": () => require_uws_linux_x64_115(),
|
|
3040
|
-
"./uws_linux_x64_120.node": () => require_uws_linux_x64_120(),
|
|
3122
|
+
"./uws_linux_arm64_137.node": () => require_uws_linux_arm64_137(),
|
|
3123
|
+
"./uws_linux_arm64_147.node": () => require_uws_linux_arm64_147(),
|
|
3041
3124
|
"./uws_linux_x64_127.node": () => require_uws_linux_x64_127(),
|
|
3042
|
-
"./
|
|
3043
|
-
"./
|
|
3044
|
-
"./
|
|
3045
|
-
"./
|
|
3125
|
+
"./uws_linux_x64_137.node": () => require_uws_linux_x64_137(),
|
|
3126
|
+
"./uws_linux_x64_147.node": () => require_uws_linux_x64_147(),
|
|
3127
|
+
"./uws_win32_x64_127.node": () => require_uws_win32_x64_127(),
|
|
3128
|
+
"./uws_win32_x64_137.node": () => require_uws_win32_x64_137(),
|
|
3129
|
+
"./uws_win32_x64_147.node": () => require_uws_win32_x64_147()
|
|
3046
3130
|
});
|
|
3047
3131
|
}
|
|
3048
3132
|
});
|
|
@@ -3055,27 +3139,37 @@ var require_uws = __commonJS({
|
|
|
3055
3139
|
try {
|
|
3056
3140
|
return globRequire_uws______node("./uws_" + process.platform + "_" + process.arch + "_" + process.versions.modules + ".node");
|
|
3057
3141
|
} catch (e) {
|
|
3058
|
-
throw new Error("This version of uWS.js supports only Node.js versions
|
|
3142
|
+
throw new Error("This version of uWS.js (v20.67.0) supports only Node.js versions 22, 24 and 26 on (glibc) Linux, macOS and Windows, on Tier 1 platforms (https://github.com/nodejs/node/blob/master/BUILDING.md#platform-list).\n\n" + e.toString());
|
|
3059
3143
|
}
|
|
3060
3144
|
})();
|
|
3145
|
+
var MAX_U8 = Math.pow(2, 8) - 1;
|
|
3146
|
+
var MAX_U16 = Math.pow(2, 16) - 1;
|
|
3147
|
+
var textEncoder = new TextEncoder();
|
|
3148
|
+
var toUint8Array = (value) => {
|
|
3149
|
+
if (value === void 0) return new Uint8Array(0);
|
|
3150
|
+
else if (typeof value === "string") return textEncoder.encode(value);
|
|
3151
|
+
else if (value instanceof ArrayBuffer) return new Uint8Array(value);
|
|
3152
|
+
else if (value instanceof SharedArrayBuffer) return new Uint8Array(value);
|
|
3153
|
+
else return new Uint8Array(value.buffer, value.byteOffset, value.byteLength);
|
|
3154
|
+
};
|
|
3061
3155
|
module.exports.DeclarativeResponse = class DeclarativeResponse {
|
|
3062
3156
|
constructor() {
|
|
3063
3157
|
this.instructions = [];
|
|
3064
3158
|
}
|
|
3065
|
-
//
|
|
3066
|
-
_appendInstruction(opcode, ...
|
|
3159
|
+
// Append instruction and 1-byte length values
|
|
3160
|
+
_appendInstruction(opcode, ...values) {
|
|
3067
3161
|
this.instructions.push(opcode);
|
|
3068
|
-
|
|
3069
|
-
const
|
|
3070
|
-
|
|
3162
|
+
values.forEach((value) => {
|
|
3163
|
+
const uint8Array = toUint8Array(value);
|
|
3164
|
+
if (uint8Array.byteLength > MAX_U8) throw new RangeError("Data length exceeds " + MAX_U8);
|
|
3165
|
+
this.instructions.push(uint8Array.byteLength, ...uint8Array);
|
|
3071
3166
|
});
|
|
3072
3167
|
}
|
|
3073
|
-
//
|
|
3074
|
-
_appendInstructionWithLength(opcode,
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
this.instructions.push(length & 255, length >> 8 & 255, ...bytes);
|
|
3168
|
+
// Append instruction and 2-byte length value
|
|
3169
|
+
_appendInstructionWithLength(opcode, value) {
|
|
3170
|
+
const uint8Array = toUint8Array(value);
|
|
3171
|
+
if (uint8Array.byteLength > MAX_U16) throw new RangeError("Data length exceeds " + MAX_U16);
|
|
3172
|
+
this.instructions.push(opcode, uint8Array.byteLength & 255, uint8Array.byteLength >> 8 & 255, ...uint8Array);
|
|
3079
3173
|
}
|
|
3080
3174
|
writeHeader(key, value) {
|
|
3081
3175
|
return this._appendInstruction(1, key, value), this;
|
|
@@ -3095,10 +3189,11 @@ var require_uws = __commonJS({
|
|
|
3095
3189
|
writeParameterValue(key) {
|
|
3096
3190
|
return this._appendInstruction(6, key), this;
|
|
3097
3191
|
}
|
|
3192
|
+
writeStatus(status) {
|
|
3193
|
+
return this._appendInstruction(7, status), this;
|
|
3194
|
+
}
|
|
3098
3195
|
end(value) {
|
|
3099
|
-
|
|
3100
|
-
const length = bytes.length;
|
|
3101
|
-
this.instructions.push(0, length & 255, length >> 8 & 255, ...bytes);
|
|
3196
|
+
this._appendInstructionWithLength(0, value);
|
|
3102
3197
|
return new Uint8Array(this.instructions).buffer;
|
|
3103
3198
|
}
|
|
3104
3199
|
};
|
|
@@ -3124,7 +3219,7 @@ var {
|
|
|
3124
3219
|
|
|
3125
3220
|
// package.json
|
|
3126
3221
|
var package_default = {
|
|
3127
|
-
version: "6.0.0
|
|
3222
|
+
version: "6.0.0"};
|
|
3128
3223
|
var ALWAYS_EXTERNAL = ["uWebSockets.js"];
|
|
3129
3224
|
function getUserExternals(cwd) {
|
|
3130
3225
|
let pkgExternals = [];
|
|
@@ -3392,7 +3487,16 @@ function checkOpenApiNaming(ctx) {
|
|
|
3392
3487
|
severity: "fail",
|
|
3393
3488
|
area: "api",
|
|
3394
3489
|
message: `${usingMeta.length} route${usingMeta.length === 1 ? "" : "s"} use the removed \`meta:\` field`,
|
|
3395
|
-
hint: `The \`meta:\` field was removed in 6.0.
|
|
3490
|
+
hint: `The \`meta:\` field was removed in 6.0. Move all metadata into \`schema:\` \u2014 e.g. schema: { tags: ['Users'], summary: '...' }. First offender: ${usingMeta[0].method} ${usingMeta[0].path}`
|
|
3491
|
+
});
|
|
3492
|
+
}
|
|
3493
|
+
const usingOpenapi = routes.filter((r) => r.openapi);
|
|
3494
|
+
if (usingOpenapi.length > 0) {
|
|
3495
|
+
add(ctx, {
|
|
3496
|
+
severity: "fail",
|
|
3497
|
+
area: "api",
|
|
3498
|
+
message: `${usingOpenapi.length} route${usingOpenapi.length === 1 ? "" : "s"} use the removed top-level \`openapi:\` field`,
|
|
3499
|
+
hint: `The separate \`openapi:\` property was removed in 6.1. Move all metadata directly into \`schema:\` alongside your Zod fields. Run \`npx axiomify migrate\` to apply automatically. First offender: ${usingOpenapi[0].method} ${usingOpenapi[0].path}`
|
|
3396
3500
|
});
|
|
3397
3501
|
}
|
|
3398
3502
|
}
|
|
@@ -4102,15 +4206,20 @@ async function initProject(targetDir, options = {}) {
|
|
|
4102
4206
|
}
|
|
4103
4207
|
var RULES = [
|
|
4104
4208
|
{
|
|
4105
|
-
id: "meta-to-
|
|
4106
|
-
description: "`meta:` route field
|
|
4107
|
-
//
|
|
4108
|
-
//
|
|
4109
|
-
//
|
|
4110
|
-
// To stay simple and conservative, only rewrite when the line starts
|
|
4111
|
-
// with optional whitespace + `meta:` (the common formatting).
|
|
4209
|
+
id: "meta-to-schema",
|
|
4210
|
+
description: "`meta:` route field removed \u2014 metadata now lives inside `schema:` alongside Zod fields",
|
|
4211
|
+
// NOTE: This rule renames `meta:` → a comment directing the dev to merge
|
|
4212
|
+
// contents into schema:. A full structural AST merge is out of scope for
|
|
4213
|
+
// the regex codemod; flag it for manual review instead (see report).
|
|
4112
4214
|
match: /^(\s*)meta:(\s*\{)/gm,
|
|
4113
|
-
replace: "$
|
|
4215
|
+
replace: "$1/* TODO(axiomify-migrate): merge meta fields into schema: */ openapi_REMOVE:$2"
|
|
4216
|
+
},
|
|
4217
|
+
{
|
|
4218
|
+
id: "openapi-field-to-schema",
|
|
4219
|
+
description: "`openapi:` top-level route field \u2192 contents merged into `schema:` (removed in 6.1)",
|
|
4220
|
+
// Same conservative approach: flag for manual review via TODO comment.
|
|
4221
|
+
match: /^(\s*)openapi:(\s*\{)/gm,
|
|
4222
|
+
replace: "$1/* TODO(axiomify-migrate): merge openapi fields into schema: */ openapi_REMOVE:$2"
|
|
4114
4223
|
},
|
|
4115
4224
|
{
|
|
4116
4225
|
id: "useSwagger-import",
|
|
@@ -4129,7 +4238,7 @@ var RULES = [
|
|
|
4129
4238
|
},
|
|
4130
4239
|
{
|
|
4131
4240
|
id: "RouteMeta-type",
|
|
4132
|
-
description: "`RouteMeta` type \u2192 `OpenApiOperation` (alias
|
|
4241
|
+
description: "`RouteMeta` type \u2192 `OpenApiOperation` (alias removed in 6.0)",
|
|
4133
4242
|
// Match `RouteMeta` only as a type position (after `:` or `<` or
|
|
4134
4243
|
// `as`) — avoids hitting an unrelated variable named `RouteMeta`.
|
|
4135
4244
|
match: /(:\s*|<\s*|\bas\s+)RouteMeta\b/g,
|
|
@@ -4237,7 +4346,7 @@ async function runMigrate(opts = {}) {
|
|
|
4237
4346
|
)
|
|
4238
4347
|
);
|
|
4239
4348
|
if (results.length === 0) {
|
|
4240
|
-
console.log(` ${symbols.ok} Nothing to migrate \u2014
|
|
4349
|
+
console.log(` ${symbols.ok} Nothing to migrate \u2014 all patterns look up to date.`);
|
|
4241
4350
|
console.log();
|
|
4242
4351
|
return;
|
|
4243
4352
|
}
|
|
@@ -4323,7 +4432,7 @@ async function runMigrate(opts = {}) {
|
|
|
4323
4432
|
);
|
|
4324
4433
|
console.log();
|
|
4325
4434
|
console.log(
|
|
4326
|
-
` See ${pc.cyan("docs/migration-v4-to-v5.md")} for the full guide and ` + pc.cyan("axiomify check") + " to verify the migrated app."
|
|
4435
|
+
` See ${pc.cyan("docs/migration-v4-to-v5.md")} for the full guide and ` + pc.cyan("axiomify check") + " to verify the migrated app.\n" + pc.yellow(" Note: `openapi:` / `meta:` merges into `schema:` require manual review \u2014 check TODO comments.")
|
|
4327
4436
|
);
|
|
4328
4437
|
console.log();
|
|
4329
4438
|
}
|
|
@@ -4375,7 +4484,7 @@ async function emitOpenApi(entry, opts = {}) {
|
|
|
4375
4484
|
try {
|
|
4376
4485
|
let OpenApiGenerator;
|
|
4377
4486
|
try {
|
|
4378
|
-
({ OpenApiGenerator } = await import('./dist-
|
|
4487
|
+
({ OpenApiGenerator } = await import('./dist-SYWHGZLI.mjs'));
|
|
4379
4488
|
} catch {
|
|
4380
4489
|
console.error(
|
|
4381
4490
|
pc.red("\u2717 @axiomify/openapi is not installed."),
|
|
@@ -4420,14 +4529,14 @@ function normalise(raw, isWs) {
|
|
|
4420
4529
|
if (raw.schema?.response) validation.push("Response");
|
|
4421
4530
|
if (raw.schema?.files) validation.push("Files");
|
|
4422
4531
|
if (raw.schema?.message) validation.push("Message");
|
|
4423
|
-
const
|
|
4532
|
+
const s = raw.schema ?? {};
|
|
4424
4533
|
return {
|
|
4425
4534
|
method: isWs ? "WS" : raw.method,
|
|
4426
4535
|
path: raw.path,
|
|
4427
4536
|
validation,
|
|
4428
|
-
tags: Array.isArray(
|
|
4429
|
-
operationId: typeof
|
|
4430
|
-
deprecated:
|
|
4537
|
+
tags: Array.isArray(s.tags) ? s.tags : [],
|
|
4538
|
+
operationId: typeof s.operationId === "string" ? s.operationId : void 0,
|
|
4539
|
+
deprecated: s.deprecated === true,
|
|
4431
4540
|
timeout: typeof raw.timeout === "number" && raw.timeout > 0 ? raw.timeout : void 0,
|
|
4432
4541
|
plugins: Array.isArray(raw.plugins) ? raw.plugins.length : 0,
|
|
4433
4542
|
isWs
|
|
@@ -4659,10 +4768,9 @@ const limiter = createRateLimitPlugin({
|
|
|
4659
4768
|
}),` : "",
|
|
4660
4769
|
` // response: z.object({ /* response shape */ }),`,
|
|
4661
4770
|
` },`,
|
|
4662
|
-
`
|
|
4771
|
+
` // OpenAPI metadata (tags, summary, operationId etc.) lives in schema: too`,
|
|
4663
4772
|
` tags: ['${pathToFilename(routePath).split("-")[0] || "general"}'],`,
|
|
4664
4773
|
` summary: '${method} ${routePath}',`,
|
|
4665
|
-
` },`,
|
|
4666
4774
|
plugins.length > 0 ? ` plugins: [${plugins.join(", ")}],` : "",
|
|
4667
4775
|
` handler: async (${paramKeys.length > 0 || method !== "GET" ? "req" : "_req"}, res) => {`,
|
|
4668
4776
|
method === "POST" ? ` // TODO \u2014 handler logic
|
|
@@ -4774,7 +4882,7 @@ var scaffold = program2.command("scaffold").description("Generate boilerplate (r
|
|
|
4774
4882
|
scaffold.command("route <method> <path>").description("Create a new route file under src/routes/").option("--auth", "Include `requireAuth` plugin and import", false).option("--rate-limit", "Include a default rate-limit plugin", false).option("--dry-run", "Print the generated source without writing", false).option("--force", "Overwrite the file if it already exists", false).option("--dir <dir>", "Directory under cwd to create the file in", "src/routes").action(
|
|
4775
4883
|
(method, routePath, options) => scaffoldRoute(method, routePath, options)
|
|
4776
4884
|
);
|
|
4777
|
-
program2.command("migrate").description("
|
|
4885
|
+
program2.command("migrate").description("v5 \u2192 v6 codemod: merge meta: fields into schema:, fix routePrefix \u2192 prefix, etc").option("--dry-run", "Show the unified diff without writing", false).option("--report-only", "Print a migration report and exit; do not write", false).option("--dir <dir>", "Directory to scan recursively", "src").action(
|
|
4778
4886
|
(options) => runMigrate(options)
|
|
4779
4887
|
);
|
|
4780
4888
|
program2.parse(process.argv);
|