@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.
Files changed (29) hide show
  1. package/README.md +7 -1
  2. package/dist/{dist-PKSGYMK7.mjs → dist-SYWHGZLI.mjs} +17 -30
  3. package/dist/index.js +440 -345
  4. package/dist/index.mjs +424 -316
  5. package/dist/{uws_darwin_arm64_108-CLFXMYPI.node → uws_darwin_arm64_127-NGHTXN5Q.node} +0 -0
  6. package/dist/{uws_darwin_arm64_127-KHC2FVAM.node → uws_darwin_arm64_137-ESY6MPLH.node} +0 -0
  7. package/dist/{uws_darwin_arm64_115-7FFEG3YF.node → uws_darwin_arm64_147-V7BKA3SU.node} +0 -0
  8. package/dist/{uws_darwin_x64_127-NHKQMMST.node → uws_darwin_x64_127-WIZGG7MS.node} +0 -0
  9. package/dist/{uws_darwin_x64_108-BRGT45AT.node → uws_darwin_x64_137-APKZWL4Y.node} +0 -0
  10. package/dist/{uws_darwin_x64_115-4HGPQGDD.node → uws_darwin_x64_147-W2HKFQZT.node} +0 -0
  11. package/dist/{uws_linux_arm64_115-EIAAY4WO.node → uws_linux_arm64_127-3CO7NSFJ.node} +0 -0
  12. package/dist/{uws_linux_arm64_120-OADY5FIN.node → uws_linux_arm64_137-HWEDGGZV.node} +0 -0
  13. package/dist/{uws_linux_arm64_108-YHK7ACON.node → uws_linux_arm64_147-7UCIYMK2.node} +0 -0
  14. package/dist/{uws_linux_x64_108-QSNE6XWU.node → uws_linux_x64_127-KA4E76LJ.node} +0 -0
  15. package/dist/{uws_linux_x64_127-HBA6RNSU.node → uws_linux_x64_137-DDFLTTJR.node} +0 -0
  16. package/dist/{uws_linux_x64_120-AIZ6RIW2.node → uws_linux_x64_147-MJSFREL3.node} +0 -0
  17. package/dist/{uws_win32_x64_120-XH4MVJGN.node → uws_win32_x64_127-O4US4Y4L.node} +0 -0
  18. package/dist/{uws_win32_x64_127-JBAEKR4X.node → uws_win32_x64_137-L5OZROQ7.node} +0 -0
  19. package/dist/{uws_win32_x64_115-V5N4NHJ5.node → uws_win32_x64_147-D7MGKVRG.node} +0 -0
  20. package/package.json +30 -14
  21. package/dist/uws_darwin_arm64_120-GFZT7CLS.node +0 -0
  22. package/dist/uws_darwin_x64_120-C2SGUHP4.node +0 -0
  23. package/dist/uws_linux_arm64_127-U2SRLYQM.node +0 -0
  24. package/dist/uws_linux_arm_108-BKVITVZA.node +0 -0
  25. package/dist/uws_linux_arm_115-7IORQF77.node +0 -0
  26. package/dist/uws_linux_arm_120-LCX4ED5F.node +0 -0
  27. package/dist/uws_linux_arm_127-6UTO7TL6.node +0 -0
  28. package/dist/uws_linux_x64_115-7AAZWMWE.node +0 -0
  29. package/dist/uws_win32_x64_108-J6KONPDM.node +0 -0
package/dist/index.js CHANGED
@@ -90,7 +90,6 @@ var require_error = __commonJS({
90
90
  * @param {number} exitCode suggested exit code which could be used with process.exit
91
91
  * @param {string} code an id string representing the error
92
92
  * @param {string} message human-readable description of the error
93
- * @constructor
94
93
  */
95
94
  constructor(exitCode, code, message) {
96
95
  super(message);
@@ -105,7 +104,6 @@ var require_error = __commonJS({
105
104
  /**
106
105
  * Constructs the InvalidArgumentError class
107
106
  * @param {string} [message] explanation of why argument is invalid
108
- * @constructor
109
107
  */
110
108
  constructor(message) {
111
109
  super(1, "commander.invalidArgument", message);
@@ -166,7 +164,7 @@ var require_argument = __commonJS({
166
164
  return this._name;
167
165
  }
168
166
  /**
169
- * @package internal use only
167
+ * @package
170
168
  */
171
169
  _concatValue(value, previous) {
172
170
  if (previous === this.defaultValue || !Array.isArray(previous)) {
@@ -206,7 +204,9 @@ var require_argument = __commonJS({
206
204
  this.argChoices = values.slice();
207
205
  this.parseArg = (arg, previous) => {
208
206
  if (!this.argChoices.includes(arg)) {
209
- throw new InvalidArgumentError2(`Allowed choices are ${this.argChoices.join(", ")}.`);
207
+ throw new InvalidArgumentError2(
208
+ `Allowed choices are ${this.argChoices.join(", ")}.`
209
+ );
210
210
  }
211
211
  if (this.variadic) {
212
212
  return this._concatValue(arg, previous);
@@ -217,6 +217,8 @@ var require_argument = __commonJS({
217
217
  }
218
218
  /**
219
219
  * Make argument required.
220
+ *
221
+ * @returns {Argument}
220
222
  */
221
223
  argRequired() {
222
224
  this.required = true;
@@ -224,6 +226,8 @@ var require_argument = __commonJS({
224
226
  }
225
227
  /**
226
228
  * Make argument optional.
229
+ *
230
+ * @returns {Argument}
227
231
  */
228
232
  argOptional() {
229
233
  this.required = false;
@@ -274,7 +278,7 @@ var require_help = __commonJS({
274
278
  *
275
279
  * @param {Option} a
276
280
  * @param {Option} b
277
- * @returns number
281
+ * @returns {number}
278
282
  */
279
283
  compareOptions(a, b) {
280
284
  const getSortKey = (option) => {
@@ -297,9 +301,13 @@ var require_help = __commonJS({
297
301
  if (!removeShort && !removeLong) {
298
302
  visibleOptions.push(helpOption);
299
303
  } else if (helpOption.long && !removeLong) {
300
- visibleOptions.push(cmd.createOption(helpOption.long, helpOption.description));
304
+ visibleOptions.push(
305
+ cmd.createOption(helpOption.long, helpOption.description)
306
+ );
301
307
  } else if (helpOption.short && !removeShort) {
302
- visibleOptions.push(cmd.createOption(helpOption.short, helpOption.description));
308
+ visibleOptions.push(
309
+ cmd.createOption(helpOption.short, helpOption.description)
310
+ );
303
311
  }
304
312
  }
305
313
  if (this.sortOptions) {
@@ -317,7 +325,9 @@ var require_help = __commonJS({
317
325
  if (!this.showGlobalOptions) return [];
318
326
  const globalOptions = [];
319
327
  for (let ancestorCmd = cmd.parent; ancestorCmd; ancestorCmd = ancestorCmd.parent) {
320
- const visibleOptions = ancestorCmd.options.filter((option) => !option.hidden);
328
+ const visibleOptions = ancestorCmd.options.filter(
329
+ (option) => !option.hidden
330
+ );
321
331
  globalOptions.push(...visibleOptions);
322
332
  }
323
333
  if (this.sortOptions) {
@@ -472,7 +482,9 @@ var require_help = __commonJS({
472
482
  if (option.defaultValue !== void 0) {
473
483
  const showDefault = option.required || option.optional || option.isBoolean() && typeof option.defaultValue === "boolean";
474
484
  if (showDefault) {
475
- extraInfo.push(`default: ${option.defaultValueDescription || JSON.stringify(option.defaultValue)}`);
485
+ extraInfo.push(
486
+ `default: ${option.defaultValueDescription || JSON.stringify(option.defaultValue)}`
487
+ );
476
488
  }
477
489
  }
478
490
  if (option.presetArg !== void 0 && option.optional) {
@@ -501,7 +513,9 @@ var require_help = __commonJS({
501
513
  );
502
514
  }
503
515
  if (argument.defaultValue !== void 0) {
504
- extraInfo.push(`default: ${argument.defaultValueDescription || JSON.stringify(argument.defaultValue)}`);
516
+ extraInfo.push(
517
+ `default: ${argument.defaultValueDescription || JSON.stringify(argument.defaultValue)}`
518
+ );
505
519
  }
506
520
  if (extraInfo.length > 0) {
507
521
  const extraDescripton = `(${extraInfo.join(", ")})`;
@@ -527,7 +541,11 @@ var require_help = __commonJS({
527
541
  function formatItem(term, description) {
528
542
  if (description) {
529
543
  const fullText = `${term.padEnd(termWidth + itemSeparatorWidth)}${description}`;
530
- return helper.wrap(fullText, helpWidth - itemIndentWidth, termWidth + itemSeparatorWidth);
544
+ return helper.wrap(
545
+ fullText,
546
+ helpWidth - itemIndentWidth,
547
+ termWidth + itemSeparatorWidth
548
+ );
531
549
  }
532
550
  return term;
533
551
  }
@@ -537,30 +555,49 @@ var require_help = __commonJS({
537
555
  let output = [`Usage: ${helper.commandUsage(cmd)}`, ""];
538
556
  const commandDescription = helper.commandDescription(cmd);
539
557
  if (commandDescription.length > 0) {
540
- output = output.concat([helper.wrap(commandDescription, helpWidth, 0), ""]);
558
+ output = output.concat([
559
+ helper.wrap(commandDescription, helpWidth, 0),
560
+ ""
561
+ ]);
541
562
  }
542
563
  const argumentList = helper.visibleArguments(cmd).map((argument) => {
543
- return formatItem(helper.argumentTerm(argument), helper.argumentDescription(argument));
564
+ return formatItem(
565
+ helper.argumentTerm(argument),
566
+ helper.argumentDescription(argument)
567
+ );
544
568
  });
545
569
  if (argumentList.length > 0) {
546
570
  output = output.concat(["Arguments:", formatList(argumentList), ""]);
547
571
  }
548
572
  const optionList = helper.visibleOptions(cmd).map((option) => {
549
- return formatItem(helper.optionTerm(option), helper.optionDescription(option));
573
+ return formatItem(
574
+ helper.optionTerm(option),
575
+ helper.optionDescription(option)
576
+ );
550
577
  });
551
578
  if (optionList.length > 0) {
552
579
  output = output.concat(["Options:", formatList(optionList), ""]);
553
580
  }
554
581
  if (this.showGlobalOptions) {
555
582
  const globalOptionList = helper.visibleGlobalOptions(cmd).map((option) => {
556
- return formatItem(helper.optionTerm(option), helper.optionDescription(option));
583
+ return formatItem(
584
+ helper.optionTerm(option),
585
+ helper.optionDescription(option)
586
+ );
557
587
  });
558
588
  if (globalOptionList.length > 0) {
559
- output = output.concat(["Global Options:", formatList(globalOptionList), ""]);
589
+ output = output.concat([
590
+ "Global Options:",
591
+ formatList(globalOptionList),
592
+ ""
593
+ ]);
560
594
  }
561
595
  }
562
596
  const commandList = helper.visibleCommands(cmd).map((cmd2) => {
563
- return formatItem(helper.subcommandTerm(cmd2), helper.subcommandDescription(cmd2));
597
+ return formatItem(
598
+ helper.subcommandTerm(cmd2),
599
+ helper.subcommandDescription(cmd2)
600
+ );
564
601
  });
565
602
  if (commandList.length > 0) {
566
603
  output = output.concat(["Commands:", formatList(commandList), ""]);
@@ -604,8 +641,11 @@ var require_help = __commonJS({
604
641
  const indentString = " ".repeat(indent);
605
642
  const zeroWidthSpace = "\u200B";
606
643
  const breaks = `\\s${zeroWidthSpace}`;
607
- const regex = new RegExp(`
608
- |.{1,${columnWidth - 1}}([${breaks}]|$)|[^${breaks}]+?([${breaks}]|$)`, "g");
644
+ const regex = new RegExp(
645
+ `
646
+ |.{1,${columnWidth - 1}}([${breaks}]|$)|[^${breaks}]+?([${breaks}]|$)`,
647
+ "g"
648
+ );
609
649
  const lines = columnText.match(regex) || [];
610
650
  return leadingStr + lines.map((line, i) => {
611
651
  if (line === "\n") return "";
@@ -704,7 +744,7 @@ var require_option = __commonJS({
704
744
  * .addOption(new Option('--log', 'write logging information to file'))
705
745
  * .addOption(new Option('--trace', 'log extra details').implies({ log: 'trace.txt' }));
706
746
  *
707
- * @param {Object} impliedOptionValues
747
+ * @param {object} impliedOptionValues
708
748
  * @return {Option}
709
749
  */
710
750
  implies(impliedOptionValues) {
@@ -759,7 +799,7 @@ var require_option = __commonJS({
759
799
  return this;
760
800
  }
761
801
  /**
762
- * @package internal use only
802
+ * @package
763
803
  */
764
804
  _concatValue(value, previous) {
765
805
  if (previous === this.defaultValue || !Array.isArray(previous)) {
@@ -777,7 +817,9 @@ var require_option = __commonJS({
777
817
  this.argChoices = values.slice();
778
818
  this.parseArg = (arg, previous) => {
779
819
  if (!this.argChoices.includes(arg)) {
780
- throw new InvalidArgumentError2(`Allowed choices are ${this.argChoices.join(", ")}.`);
820
+ throw new InvalidArgumentError2(
821
+ `Allowed choices are ${this.argChoices.join(", ")}.`
822
+ );
781
823
  }
782
824
  if (this.variadic) {
783
825
  return this._concatValue(arg, previous);
@@ -811,7 +853,7 @@ var require_option = __commonJS({
811
853
  *
812
854
  * @param {string} arg
813
855
  * @return {boolean}
814
- * @package internal use only
856
+ * @package
815
857
  */
816
858
  is(arg) {
817
859
  return this.short === arg || this.long === arg;
@@ -822,7 +864,7 @@ var require_option = __commonJS({
822
864
  * Options are one of boolean, negated, required argument, or optional argument.
823
865
  *
824
866
  * @return {boolean}
825
- * @package internal use only
867
+ * @package
826
868
  */
827
869
  isBoolean() {
828
870
  return !this.required && !this.optional && !this.negate;
@@ -873,7 +915,8 @@ var require_option = __commonJS({
873
915
  let shortFlag;
874
916
  let longFlag;
875
917
  const flagParts = flags.split(/[ |,]+/);
876
- if (flagParts.length > 1 && !/^[[<]/.test(flagParts[1])) shortFlag = flagParts.shift();
918
+ if (flagParts.length > 1 && !/^[[<]/.test(flagParts[1]))
919
+ shortFlag = flagParts.shift();
877
920
  longFlag = flagParts.shift();
878
921
  if (!shortFlag && /^-[^-]$/.test(longFlag)) {
879
922
  shortFlag = longFlag;
@@ -891,7 +934,8 @@ var require_suggestSimilar = __commonJS({
891
934
  "node_modules/commander/lib/suggestSimilar.js"(exports) {
892
935
  var maxDistance = 3;
893
936
  function editDistance(a, b) {
894
- if (Math.abs(a.length - b.length) > maxDistance) return Math.max(a.length, b.length);
937
+ if (Math.abs(a.length - b.length) > maxDistance)
938
+ return Math.max(a.length, b.length);
895
939
  const d = [];
896
940
  for (let i = 0; i <= a.length; i++) {
897
941
  d[i] = [i];
@@ -1083,8 +1127,8 @@ var require_command = __commonJS({
1083
1127
  * .command('stop [service]', 'stop named service, or all if no name supplied');
1084
1128
  *
1085
1129
  * @param {string} nameAndArgs - command name and arguments, args are `<required>` or `[optional]` and last may also be `variadic...`
1086
- * @param {(Object|string)} [actionOptsOrExecDesc] - configuration options (for action), or description (for executable)
1087
- * @param {Object} [execOpts] - configuration options (for executable)
1130
+ * @param {(object | string)} [actionOptsOrExecDesc] - configuration options (for action), or description (for executable)
1131
+ * @param {object} [execOpts] - configuration options (for executable)
1088
1132
  * @return {Command} returns new command for action handler, or `this` for executable command
1089
1133
  */
1090
1134
  command(nameAndArgs, actionOptsOrExecDesc, execOpts) {
@@ -1136,8 +1180,8 @@ var require_command = __commonJS({
1136
1180
  * You can customise the help by overriding Help properties using configureHelp(),
1137
1181
  * or with a subclass of Help by overriding createHelp().
1138
1182
  *
1139
- * @param {Object} [configuration] - configuration options
1140
- * @return {(Command|Object)} `this` command for chaining, or stored configuration
1183
+ * @param {object} [configuration] - configuration options
1184
+ * @return {(Command | object)} `this` command for chaining, or stored configuration
1141
1185
  */
1142
1186
  configureHelp(configuration) {
1143
1187
  if (configuration === void 0) return this._helpConfiguration;
@@ -1159,8 +1203,8 @@ var require_command = __commonJS({
1159
1203
  * // functions based on what is being written out
1160
1204
  * outputError(str, write) // used for displaying errors, and not used for displaying help
1161
1205
  *
1162
- * @param {Object} [configuration] - configuration options
1163
- * @return {(Command|Object)} `this` command for chaining, or stored configuration
1206
+ * @param {object} [configuration] - configuration options
1207
+ * @return {(Command | object)} `this` command for chaining, or stored configuration
1164
1208
  */
1165
1209
  configureOutput(configuration) {
1166
1210
  if (configuration === void 0) return this._outputConfiguration;
@@ -1194,7 +1238,7 @@ var require_command = __commonJS({
1194
1238
  * See .command() for creating an attached subcommand which inherits settings from its parent.
1195
1239
  *
1196
1240
  * @param {Command} cmd - new subcommand
1197
- * @param {Object} [opts] - configuration options
1241
+ * @param {object} [opts] - configuration options
1198
1242
  * @return {Command} `this` command for chaining
1199
1243
  */
1200
1244
  addCommand(cmd, opts) {
@@ -1275,10 +1319,14 @@ var require_command = __commonJS({
1275
1319
  addArgument(argument) {
1276
1320
  const previousArgument = this.registeredArguments.slice(-1)[0];
1277
1321
  if (previousArgument && previousArgument.variadic) {
1278
- throw new Error(`only the last argument can be variadic '${previousArgument.name()}'`);
1322
+ throw new Error(
1323
+ `only the last argument can be variadic '${previousArgument.name()}'`
1324
+ );
1279
1325
  }
1280
1326
  if (argument.required && argument.defaultValue !== void 0 && argument.parseArg === void 0) {
1281
- throw new Error(`a default value for a required argument is never used: '${argument.name()}'`);
1327
+ throw new Error(
1328
+ `a default value for a required argument is never used: '${argument.name()}'`
1329
+ );
1282
1330
  }
1283
1331
  this.registeredArguments.push(argument);
1284
1332
  return this;
@@ -1286,6 +1334,7 @@ var require_command = __commonJS({
1286
1334
  /**
1287
1335
  * Customise or override default help command. By default a help command is automatically added if your command has subcommands.
1288
1336
  *
1337
+ * @example
1289
1338
  * program.helpCommand('help [cmd]');
1290
1339
  * program.helpCommand('help [cmd]', 'show help');
1291
1340
  * program.helpCommand(false); // suppress default help command
@@ -1463,7 +1512,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
1463
1512
  * Register option if no conflicts found, or throw on conflict.
1464
1513
  *
1465
1514
  * @param {Option} option
1466
- * @api private
1515
+ * @private
1467
1516
  */
1468
1517
  _registerOption(option) {
1469
1518
  const matchingOption = option.short && this._findOption(option.short) || option.long && this._findOption(option.long);
@@ -1479,17 +1528,21 @@ Expecting one of '${allowedValues.join("', '")}'`);
1479
1528
  * Register command if no conflicts found, or throw on conflict.
1480
1529
  *
1481
1530
  * @param {Command} command
1482
- * @api private
1531
+ * @private
1483
1532
  */
1484
1533
  _registerCommand(command) {
1485
1534
  const knownBy = (cmd) => {
1486
1535
  return [cmd.name()].concat(cmd.aliases());
1487
1536
  };
1488
- const alreadyUsed = knownBy(command).find((name) => this._findCommand(name));
1537
+ const alreadyUsed = knownBy(command).find(
1538
+ (name) => this._findCommand(name)
1539
+ );
1489
1540
  if (alreadyUsed) {
1490
1541
  const existingCmd = knownBy(this._findCommand(alreadyUsed)).join("|");
1491
1542
  const newCmd = knownBy(command).join("|");
1492
- throw new Error(`cannot add command '${newCmd}' as already have command '${existingCmd}'`);
1543
+ throw new Error(
1544
+ `cannot add command '${newCmd}' as already have command '${existingCmd}'`
1545
+ );
1493
1546
  }
1494
1547
  this.commands.push(command);
1495
1548
  }
@@ -1506,7 +1559,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
1506
1559
  if (option.negate) {
1507
1560
  const positiveLongFlag = option.long.replace(/^--no-/, "--");
1508
1561
  if (!this._findOption(positiveLongFlag)) {
1509
- this.setOptionValueWithSource(name, option.defaultValue === void 0 ? true : option.defaultValue, "default");
1562
+ this.setOptionValueWithSource(
1563
+ name,
1564
+ option.defaultValue === void 0 ? true : option.defaultValue,
1565
+ "default"
1566
+ );
1510
1567
  }
1511
1568
  } else if (option.defaultValue !== void 0) {
1512
1569
  this.setOptionValueWithSource(name, option.defaultValue, "default");
@@ -1547,11 +1604,14 @@ Expecting one of '${allowedValues.join("', '")}'`);
1547
1604
  /**
1548
1605
  * Internal implementation shared by .option() and .requiredOption()
1549
1606
  *
1607
+ * @return {Command} `this` command for chaining
1550
1608
  * @private
1551
1609
  */
1552
1610
  _optionEx(config, flags, description, fn, defaultValue) {
1553
1611
  if (typeof flags === "object" && flags instanceof Option2) {
1554
- throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");
1612
+ throw new Error(
1613
+ "To add an Option object use addOption() instead of option() or requiredOption()"
1614
+ );
1555
1615
  }
1556
1616
  const option = this.createOption(flags, description);
1557
1617
  option.makeOptionMandatory(!!config.mandatory);
@@ -1594,19 +1654,25 @@ Expecting one of '${allowedValues.join("', '")}'`);
1594
1654
  return this._optionEx({}, flags, description, parseArg, defaultValue);
1595
1655
  }
1596
1656
  /**
1597
- * Add a required option which must have a value after parsing. This usually means
1598
- * the option must be specified on the command line. (Otherwise the same as .option().)
1599
- *
1600
- * The `flags` string contains the short and/or long flags, separated by comma, a pipe or space.
1601
- *
1602
- * @param {string} flags
1603
- * @param {string} [description]
1604
- * @param {(Function|*)} [parseArg] - custom option processing function or default value
1605
- * @param {*} [defaultValue]
1606
- * @return {Command} `this` command for chaining
1607
- */
1657
+ * Add a required option which must have a value after parsing. This usually means
1658
+ * the option must be specified on the command line. (Otherwise the same as .option().)
1659
+ *
1660
+ * The `flags` string contains the short and/or long flags, separated by comma, a pipe or space.
1661
+ *
1662
+ * @param {string} flags
1663
+ * @param {string} [description]
1664
+ * @param {(Function|*)} [parseArg] - custom option processing function or default value
1665
+ * @param {*} [defaultValue]
1666
+ * @return {Command} `this` command for chaining
1667
+ */
1608
1668
  requiredOption(flags, description, parseArg, defaultValue) {
1609
- return this._optionEx({ mandatory: true }, flags, description, parseArg, defaultValue);
1669
+ return this._optionEx(
1670
+ { mandatory: true },
1671
+ flags,
1672
+ description,
1673
+ parseArg,
1674
+ defaultValue
1675
+ );
1610
1676
  }
1611
1677
  /**
1612
1678
  * Alter parsing of short flags with optional values.
@@ -1616,7 +1682,8 @@ Expecting one of '${allowedValues.join("', '")}'`);
1616
1682
  * program.combineFlagAndOptionalValue(true); // `-f80` is treated like `--flag=80`, this is the default behaviour
1617
1683
  * program.combineFlagAndOptionalValue(false) // `-fb` is treated like `-f -b`
1618
1684
  *
1619
- * @param {boolean} [combine=true] - if `true` or omitted, an optional value can be specified directly after the flag.
1685
+ * @param {boolean} [combine] - if `true` or omitted, an optional value can be specified directly after the flag.
1686
+ * @return {Command} `this` command for chaining
1620
1687
  */
1621
1688
  combineFlagAndOptionalValue(combine = true) {
1622
1689
  this._combineFlagAndOptionalValue = !!combine;
@@ -1625,8 +1692,8 @@ Expecting one of '${allowedValues.join("', '")}'`);
1625
1692
  /**
1626
1693
  * Allow unknown options on the command line.
1627
1694
  *
1628
- * @param {boolean} [allowUnknown=true] - if `true` or omitted, no error will be thrown
1629
- * for unknown options.
1695
+ * @param {boolean} [allowUnknown] - if `true` or omitted, no error will be thrown for unknown options.
1696
+ * @return {Command} `this` command for chaining
1630
1697
  */
1631
1698
  allowUnknownOption(allowUnknown = true) {
1632
1699
  this._allowUnknownOption = !!allowUnknown;
@@ -1635,8 +1702,8 @@ Expecting one of '${allowedValues.join("', '")}'`);
1635
1702
  /**
1636
1703
  * Allow excess command-arguments on the command line. Pass false to make excess arguments an error.
1637
1704
  *
1638
- * @param {boolean} [allowExcess=true] - if `true` or omitted, no error will be thrown
1639
- * for excess arguments.
1705
+ * @param {boolean} [allowExcess] - if `true` or omitted, no error will be thrown for excess arguments.
1706
+ * @return {Command} `this` command for chaining
1640
1707
  */
1641
1708
  allowExcessArguments(allowExcess = true) {
1642
1709
  this._allowExcessArguments = !!allowExcess;
@@ -1647,7 +1714,8 @@ Expecting one of '${allowedValues.join("', '")}'`);
1647
1714
  * subcommands reuse the same option names, and also enables subcommands to turn on passThroughOptions.
1648
1715
  * The default behaviour is non-positional and global options may appear anywhere on the command line.
1649
1716
  *
1650
- * @param {boolean} [positional=true]
1717
+ * @param {boolean} [positional]
1718
+ * @return {Command} `this` command for chaining
1651
1719
  */
1652
1720
  enablePositionalOptions(positional = true) {
1653
1721
  this._enablePositionalOptions = !!positional;
@@ -1659,8 +1727,8 @@ Expecting one of '${allowedValues.join("', '")}'`);
1659
1727
  * positional options to have been enabled on the program (parent commands).
1660
1728
  * The default behaviour is non-positional and options may appear before or after command-arguments.
1661
1729
  *
1662
- * @param {boolean} [passThrough=true]
1663
- * for unknown options.
1730
+ * @param {boolean} [passThrough] for unknown options.
1731
+ * @return {Command} `this` command for chaining
1664
1732
  */
1665
1733
  passThroughOptions(passThrough = true) {
1666
1734
  this._passThroughOptions = !!passThrough;
@@ -1672,22 +1740,26 @@ Expecting one of '${allowedValues.join("', '")}'`);
1672
1740
  */
1673
1741
  _checkForBrokenPassThrough() {
1674
1742
  if (this.parent && this._passThroughOptions && !this.parent._enablePositionalOptions) {
1675
- throw new Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`);
1743
+ throw new Error(
1744
+ `passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`
1745
+ );
1676
1746
  }
1677
1747
  }
1678
1748
  /**
1679
- * Whether to store option values as properties on command object,
1680
- * or store separately (specify false). In both cases the option values can be accessed using .opts().
1681
- *
1682
- * @param {boolean} [storeAsProperties=true]
1683
- * @return {Command} `this` command for chaining
1684
- */
1749
+ * Whether to store option values as properties on command object,
1750
+ * or store separately (specify false). In both cases the option values can be accessed using .opts().
1751
+ *
1752
+ * @param {boolean} [storeAsProperties=true]
1753
+ * @return {Command} `this` command for chaining
1754
+ */
1685
1755
  storeOptionsAsProperties(storeAsProperties = true) {
1686
1756
  if (this.options.length) {
1687
1757
  throw new Error("call .storeOptionsAsProperties() before adding options");
1688
1758
  }
1689
1759
  if (Object.keys(this._optionValues).length) {
1690
- throw new Error("call .storeOptionsAsProperties() before setting option values");
1760
+ throw new Error(
1761
+ "call .storeOptionsAsProperties() before setting option values"
1762
+ );
1691
1763
  }
1692
1764
  this._storeOptionsAsProperties = !!storeAsProperties;
1693
1765
  return this;
@@ -1696,7 +1768,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
1696
1768
  * Retrieve option value.
1697
1769
  *
1698
1770
  * @param {string} key
1699
- * @return {Object} value
1771
+ * @return {object} value
1700
1772
  */
1701
1773
  getOptionValue(key) {
1702
1774
  if (this._storeOptionsAsProperties) {
@@ -1708,20 +1780,20 @@ Expecting one of '${allowedValues.join("', '")}'`);
1708
1780
  * Store option value.
1709
1781
  *
1710
1782
  * @param {string} key
1711
- * @param {Object} value
1783
+ * @param {object} value
1712
1784
  * @return {Command} `this` command for chaining
1713
1785
  */
1714
1786
  setOptionValue(key, value) {
1715
1787
  return this.setOptionValueWithSource(key, value, void 0);
1716
1788
  }
1717
1789
  /**
1718
- * Store option value and where the value came from.
1719
- *
1720
- * @param {string} key
1721
- * @param {Object} value
1722
- * @param {string} source - expected values are default/config/env/cli/implied
1723
- * @return {Command} `this` command for chaining
1724
- */
1790
+ * Store option value and where the value came from.
1791
+ *
1792
+ * @param {string} key
1793
+ * @param {object} value
1794
+ * @param {string} source - expected values are default/config/env/cli/implied
1795
+ * @return {Command} `this` command for chaining
1796
+ */
1725
1797
  setOptionValueWithSource(key, value, source) {
1726
1798
  if (this._storeOptionsAsProperties) {
1727
1799
  this[key] = value;
@@ -1732,22 +1804,22 @@ Expecting one of '${allowedValues.join("', '")}'`);
1732
1804
  return this;
1733
1805
  }
1734
1806
  /**
1735
- * Get source of option value.
1736
- * Expected values are default | config | env | cli | implied
1737
- *
1738
- * @param {string} key
1739
- * @return {string}
1740
- */
1807
+ * Get source of option value.
1808
+ * Expected values are default | config | env | cli | implied
1809
+ *
1810
+ * @param {string} key
1811
+ * @return {string}
1812
+ */
1741
1813
  getOptionValueSource(key) {
1742
1814
  return this._optionValueSources[key];
1743
1815
  }
1744
1816
  /**
1745
- * Get source of option value. See also .optsWithGlobals().
1746
- * Expected values are default | config | env | cli | implied
1747
- *
1748
- * @param {string} key
1749
- * @return {string}
1750
- */
1817
+ * Get source of option value. See also .optsWithGlobals().
1818
+ * Expected values are default | config | env | cli | implied
1819
+ *
1820
+ * @param {string} key
1821
+ * @return {string}
1822
+ */
1751
1823
  getOptionValueSourceWithGlobals(key) {
1752
1824
  let source;
1753
1825
  this._getCommandAndAncestors().forEach((cmd) => {
@@ -1768,11 +1840,17 @@ Expecting one of '${allowedValues.join("', '")}'`);
1768
1840
  throw new Error("first parameter to parse must be array or undefined");
1769
1841
  }
1770
1842
  parseOptions = parseOptions || {};
1771
- if (argv === void 0) {
1772
- argv = process2.argv;
1773
- if (process2.versions && process2.versions.electron) {
1843
+ if (argv === void 0 && parseOptions.from === void 0) {
1844
+ if (process2.versions?.electron) {
1774
1845
  parseOptions.from = "electron";
1775
1846
  }
1847
+ const execArgv = process2.execArgv ?? [];
1848
+ if (execArgv.includes("-e") || execArgv.includes("--eval") || execArgv.includes("-p") || execArgv.includes("--print")) {
1849
+ parseOptions.from = "eval";
1850
+ }
1851
+ }
1852
+ if (argv === void 0) {
1853
+ argv = process2.argv;
1776
1854
  }
1777
1855
  this.rawArgs = argv.slice();
1778
1856
  let userArgs;
@@ -1793,26 +1871,38 @@ Expecting one of '${allowedValues.join("', '")}'`);
1793
1871
  case "user":
1794
1872
  userArgs = argv.slice(0);
1795
1873
  break;
1874
+ case "eval":
1875
+ userArgs = argv.slice(1);
1876
+ break;
1796
1877
  default:
1797
- throw new Error(`unexpected parse option { from: '${parseOptions.from}' }`);
1878
+ throw new Error(
1879
+ `unexpected parse option { from: '${parseOptions.from}' }`
1880
+ );
1798
1881
  }
1799
- if (!this._name && this._scriptPath) this.nameFromFilename(this._scriptPath);
1882
+ if (!this._name && this._scriptPath)
1883
+ this.nameFromFilename(this._scriptPath);
1800
1884
  this._name = this._name || "program";
1801
1885
  return userArgs;
1802
1886
  }
1803
1887
  /**
1804
1888
  * Parse `argv`, setting options and invoking commands when defined.
1805
1889
  *
1806
- * The default expectation is that the arguments are from node and have the application as argv[0]
1807
- * and the script being run in argv[1], with user parameters after that.
1890
+ * Use parseAsync instead of parse if any of your action handlers are async.
1891
+ *
1892
+ * Call with no parameters to parse `process.argv`. Detects Electron and special node options like `node --eval`. Easy mode!
1893
+ *
1894
+ * Or call with an array of strings to parse, and optionally where the user arguments start by specifying where the arguments are `from`:
1895
+ * - `'node'`: default, `argv[0]` is the application and `argv[1]` is the script being run, with user arguments after that
1896
+ * - `'electron'`: `argv[0]` is the application and `argv[1]` varies depending on whether the electron application is packaged
1897
+ * - `'user'`: just user arguments
1808
1898
  *
1809
1899
  * @example
1810
- * program.parse(process.argv);
1811
- * program.parse(); // implicitly use process.argv and auto-detect node vs electron conventions
1900
+ * program.parse(); // parse process.argv and auto-detect electron and special node flags
1901
+ * program.parse(process.argv); // assume argv[0] is app and argv[1] is script
1812
1902
  * program.parse(my-args, { from: 'user' }); // just user supplied arguments, nothing special about argv[0]
1813
1903
  *
1814
1904
  * @param {string[]} [argv] - optional, defaults to process.argv
1815
- * @param {Object} [parseOptions] - optionally specify style of options with from: node/user/electron
1905
+ * @param {object} [parseOptions] - optionally specify style of options with from: node/user/electron
1816
1906
  * @param {string} [parseOptions.from] - where the args are from: 'node', 'user', 'electron'
1817
1907
  * @return {Command} `this` command for chaining
1818
1908
  */
@@ -1824,18 +1914,20 @@ Expecting one of '${allowedValues.join("', '")}'`);
1824
1914
  /**
1825
1915
  * Parse `argv`, setting options and invoking commands when defined.
1826
1916
  *
1827
- * Use parseAsync instead of parse if any of your action handlers are async. Returns a Promise.
1917
+ * Call with no parameters to parse `process.argv`. Detects Electron and special node options like `node --eval`. Easy mode!
1828
1918
  *
1829
- * The default expectation is that the arguments are from node and have the application as argv[0]
1830
- * and the script being run in argv[1], with user parameters after that.
1919
+ * Or call with an array of strings to parse, and optionally where the user arguments start by specifying where the arguments are `from`:
1920
+ * - `'node'`: default, `argv[0]` is the application and `argv[1]` is the script being run, with user arguments after that
1921
+ * - `'electron'`: `argv[0]` is the application and `argv[1]` varies depending on whether the electron application is packaged
1922
+ * - `'user'`: just user arguments
1831
1923
  *
1832
1924
  * @example
1833
- * await program.parseAsync(process.argv);
1834
- * await program.parseAsync(); // implicitly use process.argv and auto-detect node vs electron conventions
1925
+ * await program.parseAsync(); // parse process.argv and auto-detect electron and special node flags
1926
+ * await program.parseAsync(process.argv); // assume argv[0] is app and argv[1] is script
1835
1927
  * await program.parseAsync(my-args, { from: 'user' }); // just user supplied arguments, nothing special about argv[0]
1836
1928
  *
1837
1929
  * @param {string[]} [argv]
1838
- * @param {Object} [parseOptions]
1930
+ * @param {object} [parseOptions]
1839
1931
  * @param {string} parseOptions.from - where the args are from: 'node', 'user', 'electron'
1840
1932
  * @return {Promise}
1841
1933
  */
@@ -1857,7 +1949,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
1857
1949
  const localBin = path11.resolve(baseDir, baseName);
1858
1950
  if (fs9.existsSync(localBin)) return localBin;
1859
1951
  if (sourceExt.includes(path11.extname(baseName))) return void 0;
1860
- const foundExt = sourceExt.find((ext) => fs9.existsSync(`${localBin}${ext}`));
1952
+ const foundExt = sourceExt.find(
1953
+ (ext) => fs9.existsSync(`${localBin}${ext}`)
1954
+ );
1861
1955
  if (foundExt) return `${localBin}${foundExt}`;
1862
1956
  return void 0;
1863
1957
  }
@@ -1872,14 +1966,23 @@ Expecting one of '${allowedValues.join("', '")}'`);
1872
1966
  } catch (err) {
1873
1967
  resolvedScriptPath = this._scriptPath;
1874
1968
  }
1875
- executableDir = path11.resolve(path11.dirname(resolvedScriptPath), executableDir);
1969
+ executableDir = path11.resolve(
1970
+ path11.dirname(resolvedScriptPath),
1971
+ executableDir
1972
+ );
1876
1973
  }
1877
1974
  if (executableDir) {
1878
1975
  let localFile = findFile(executableDir, executableFile);
1879
1976
  if (!localFile && !subcommand._executableFile && this._scriptPath) {
1880
- const legacyName = path11.basename(this._scriptPath, path11.extname(this._scriptPath));
1977
+ const legacyName = path11.basename(
1978
+ this._scriptPath,
1979
+ path11.extname(this._scriptPath)
1980
+ );
1881
1981
  if (legacyName !== this._name) {
1882
- localFile = findFile(executableDir, `${legacyName}-${subcommand._name}`);
1982
+ localFile = findFile(
1983
+ executableDir,
1984
+ `${legacyName}-${subcommand._name}`
1985
+ );
1883
1986
  }
1884
1987
  }
1885
1988
  executableFile = localFile || executableFile;
@@ -1910,12 +2013,18 @@ Expecting one of '${allowedValues.join("', '")}'`);
1910
2013
  });
1911
2014
  }
1912
2015
  const exitCallback = this._exitCallback;
1913
- proc.on("close", (code, _signal) => {
2016
+ proc.on("close", (code) => {
1914
2017
  code = code ?? 1;
1915
2018
  if (!exitCallback) {
1916
2019
  process2.exit(code);
1917
2020
  } else {
1918
- exitCallback(new CommanderError2(code, "commander.executeSubCommandAsync", "(close)"));
2021
+ exitCallback(
2022
+ new CommanderError2(
2023
+ code,
2024
+ "commander.executeSubCommandAsync",
2025
+ "(close)"
2026
+ )
2027
+ );
1919
2028
  }
1920
2029
  });
1921
2030
  proc.on("error", (err) => {
@@ -1932,7 +2041,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
1932
2041
  if (!exitCallback) {
1933
2042
  process2.exit(1);
1934
2043
  } else {
1935
- const wrappedError = new CommanderError2(1, "commander.executeSubCommandAsync", "(error)");
2044
+ const wrappedError = new CommanderError2(
2045
+ 1,
2046
+ "commander.executeSubCommandAsync",
2047
+ "(error)"
2048
+ );
1936
2049
  wrappedError.nestedError = err;
1937
2050
  exitCallback(wrappedError);
1938
2051
  }
@@ -1946,7 +2059,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
1946
2059
  const subCommand = this._findCommand(commandName);
1947
2060
  if (!subCommand) this.help({ error: true });
1948
2061
  let promiseChain;
1949
- promiseChain = this._chainOrCallSubCommandHook(promiseChain, subCommand, "preSubcommand");
2062
+ promiseChain = this._chainOrCallSubCommandHook(
2063
+ promiseChain,
2064
+ subCommand,
2065
+ "preSubcommand"
2066
+ );
1950
2067
  promiseChain = this._chainOrCall(promiseChain, () => {
1951
2068
  if (subCommand._executableHandler) {
1952
2069
  this._executeSubCommand(subCommand, operands.concat(unknown));
@@ -1970,9 +2087,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
1970
2087
  if (subCommand && !subCommand._executableHandler) {
1971
2088
  subCommand.help();
1972
2089
  }
1973
- return this._dispatchSubcommand(subcommandName, [], [
1974
- this._getHelpOption()?.long ?? this._getHelpOption()?.short ?? "--help"
1975
- ]);
2090
+ return this._dispatchSubcommand(
2091
+ subcommandName,
2092
+ [],
2093
+ [this._getHelpOption()?.long ?? this._getHelpOption()?.short ?? "--help"]
2094
+ );
1976
2095
  }
1977
2096
  /**
1978
2097
  * Check this.args against expected this.registeredArguments.
@@ -2002,7 +2121,12 @@ Expecting one of '${allowedValues.join("', '")}'`);
2002
2121
  let parsedValue = value;
2003
2122
  if (value !== null && argument.parseArg) {
2004
2123
  const invalidValueMessage = `error: command-argument value '${value}' is invalid for argument '${argument.name()}'.`;
2005
- parsedValue = this._callParseArg(argument, value, previous, invalidValueMessage);
2124
+ parsedValue = this._callParseArg(
2125
+ argument,
2126
+ value,
2127
+ previous,
2128
+ invalidValueMessage
2129
+ );
2006
2130
  }
2007
2131
  return parsedValue;
2008
2132
  };
@@ -2110,7 +2234,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
2110
2234
  }
2111
2235
  if (this._defaultCommandName) {
2112
2236
  this._outputHelpIfRequested(unknown);
2113
- return this._dispatchSubcommand(this._defaultCommandName, operands, unknown);
2237
+ return this._dispatchSubcommand(
2238
+ this._defaultCommandName,
2239
+ operands,
2240
+ unknown
2241
+ );
2114
2242
  }
2115
2243
  if (this.commands.length && this.args.length === 0 && !this._actionHandler && !this._defaultCommandName) {
2116
2244
  this.help({ error: true });
@@ -2129,7 +2257,10 @@ Expecting one of '${allowedValues.join("', '")}'`);
2129
2257
  this._processArguments();
2130
2258
  let promiseChain;
2131
2259
  promiseChain = this._chainOrCallHooks(promiseChain, "preAction");
2132
- promiseChain = this._chainOrCall(promiseChain, () => this._actionHandler(this.processedArgs));
2260
+ promiseChain = this._chainOrCall(
2261
+ promiseChain,
2262
+ () => this._actionHandler(this.processedArgs)
2263
+ );
2133
2264
  if (this.parent) {
2134
2265
  promiseChain = this._chainOrCall(promiseChain, () => {
2135
2266
  this.parent.emit(commandEvent, operands, unknown);
@@ -2166,17 +2297,20 @@ Expecting one of '${allowedValues.join("', '")}'`);
2166
2297
  * Find matching command.
2167
2298
  *
2168
2299
  * @private
2300
+ * @return {Command | undefined}
2169
2301
  */
2170
2302
  _findCommand(name) {
2171
2303
  if (!name) return void 0;
2172
- return this.commands.find((cmd) => cmd._name === name || cmd._aliases.includes(name));
2304
+ return this.commands.find(
2305
+ (cmd) => cmd._name === name || cmd._aliases.includes(name)
2306
+ );
2173
2307
  }
2174
2308
  /**
2175
2309
  * Return an option matching `arg` if any.
2176
2310
  *
2177
2311
  * @param {string} arg
2178
2312
  * @return {Option}
2179
- * @package internal use only
2313
+ * @package
2180
2314
  */
2181
2315
  _findOption(arg) {
2182
2316
  return this.options.find((option) => option.is(arg));
@@ -2202,15 +2336,13 @@ Expecting one of '${allowedValues.join("', '")}'`);
2202
2336
  * @private
2203
2337
  */
2204
2338
  _checkForConflictingLocalOptions() {
2205
- const definedNonDefaultOptions = this.options.filter(
2206
- (option) => {
2207
- const optionKey = option.attributeName();
2208
- if (this.getOptionValue(optionKey) === void 0) {
2209
- return false;
2210
- }
2211
- return this.getOptionValueSource(optionKey) !== "default";
2339
+ const definedNonDefaultOptions = this.options.filter((option) => {
2340
+ const optionKey = option.attributeName();
2341
+ if (this.getOptionValue(optionKey) === void 0) {
2342
+ return false;
2212
2343
  }
2213
- );
2344
+ return this.getOptionValueSource(optionKey) !== "default";
2345
+ });
2214
2346
  const optionsWithConflicting = definedNonDefaultOptions.filter(
2215
2347
  (option) => option.conflictsWith.length > 0
2216
2348
  );
@@ -2340,7 +2472,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
2340
2472
  /**
2341
2473
  * Return an object containing local option values as key-value pairs.
2342
2474
  *
2343
- * @return {Object}
2475
+ * @return {object}
2344
2476
  */
2345
2477
  opts() {
2346
2478
  if (this._storeOptionsAsProperties) {
@@ -2357,7 +2489,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
2357
2489
  /**
2358
2490
  * Return an object containing merged local and global option values as key-value pairs.
2359
2491
  *
2360
- * @return {Object}
2492
+ * @return {object}
2361
2493
  */
2362
2494
  optsWithGlobals() {
2363
2495
  return this._getCommandAndAncestors().reduce(
@@ -2369,13 +2501,16 @@ Expecting one of '${allowedValues.join("', '")}'`);
2369
2501
  * Display error message and exit (or call exitOverride).
2370
2502
  *
2371
2503
  * @param {string} message
2372
- * @param {Object} [errorOptions]
2504
+ * @param {object} [errorOptions]
2373
2505
  * @param {string} [errorOptions.code] - an id string representing the error
2374
2506
  * @param {number} [errorOptions.exitCode] - used with process.exit
2375
2507
  */
2376
2508
  error(message, errorOptions) {
2377
- this._outputConfiguration.outputError(`${message}
2378
- `, this._outputConfiguration.writeErr);
2509
+ this._outputConfiguration.outputError(
2510
+ `${message}
2511
+ `,
2512
+ this._outputConfiguration.writeErr
2513
+ );
2379
2514
  if (typeof this._showHelpAfterError === "string") {
2380
2515
  this._outputConfiguration.writeErr(`${this._showHelpAfterError}
2381
2516
  `);
@@ -2398,7 +2533,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
2398
2533
  this.options.forEach((option) => {
2399
2534
  if (option.envVar && option.envVar in process2.env) {
2400
2535
  const optionKey = option.attributeName();
2401
- if (this.getOptionValue(optionKey) === void 0 || ["default", "config", "env"].includes(this.getOptionValueSource(optionKey))) {
2536
+ if (this.getOptionValue(optionKey) === void 0 || ["default", "config", "env"].includes(
2537
+ this.getOptionValueSource(optionKey)
2538
+ )) {
2402
2539
  if (option.required || option.optional) {
2403
2540
  this.emit(`optionEnv:${option.name()}`, process2.env[option.envVar]);
2404
2541
  } else {
@@ -2418,9 +2555,18 @@ Expecting one of '${allowedValues.join("', '")}'`);
2418
2555
  const hasCustomOptionValue = (optionKey) => {
2419
2556
  return this.getOptionValue(optionKey) !== void 0 && !["default", "implied"].includes(this.getOptionValueSource(optionKey));
2420
2557
  };
2421
- this.options.filter((option) => option.implied !== void 0 && hasCustomOptionValue(option.attributeName()) && dualHelper.valueFromOption(this.getOptionValue(option.attributeName()), option)).forEach((option) => {
2558
+ this.options.filter(
2559
+ (option) => option.implied !== void 0 && hasCustomOptionValue(option.attributeName()) && dualHelper.valueFromOption(
2560
+ this.getOptionValue(option.attributeName()),
2561
+ option
2562
+ )
2563
+ ).forEach((option) => {
2422
2564
  Object.keys(option.implied).filter((impliedKey) => !hasCustomOptionValue(impliedKey)).forEach((impliedKey) => {
2423
- this.setOptionValueWithSource(impliedKey, option.implied[impliedKey], "implied");
2565
+ this.setOptionValueWithSource(
2566
+ impliedKey,
2567
+ option.implied[impliedKey],
2568
+ "implied"
2569
+ );
2424
2570
  });
2425
2571
  });
2426
2572
  }
@@ -2465,8 +2611,12 @@ Expecting one of '${allowedValues.join("', '")}'`);
2465
2611
  const findBestOptionFromValue = (option2) => {
2466
2612
  const optionKey = option2.attributeName();
2467
2613
  const optionValue = this.getOptionValue(optionKey);
2468
- const negativeOption = this.options.find((target) => target.negate && optionKey === target.attributeName());
2469
- const positiveOption = this.options.find((target) => !target.negate && optionKey === target.attributeName());
2614
+ const negativeOption = this.options.find(
2615
+ (target) => target.negate && optionKey === target.attributeName()
2616
+ );
2617
+ const positiveOption = this.options.find(
2618
+ (target) => !target.negate && optionKey === target.attributeName()
2619
+ );
2470
2620
  if (negativeOption && (negativeOption.presetArg === void 0 && optionValue === false || negativeOption.presetArg !== void 0 && optionValue === negativeOption.presetArg)) {
2471
2621
  return negativeOption;
2472
2622
  }
@@ -2570,11 +2720,12 @@ Expecting one of '${allowedValues.join("', '")}'`);
2570
2720
  * Set the description.
2571
2721
  *
2572
2722
  * @param {string} [str]
2573
- * @param {Object} [argsDescription]
2723
+ * @param {object} [argsDescription]
2574
2724
  * @return {(string|Command)}
2575
2725
  */
2576
2726
  description(str, argsDescription) {
2577
- if (str === void 0 && argsDescription === void 0) return this._description;
2727
+ if (str === void 0 && argsDescription === void 0)
2728
+ return this._description;
2578
2729
  this._description = str;
2579
2730
  if (argsDescription) {
2580
2731
  this._argsDescription = argsDescription;
@@ -2606,11 +2757,14 @@ Expecting one of '${allowedValues.join("', '")}'`);
2606
2757
  if (this.commands.length !== 0 && this.commands[this.commands.length - 1]._executableHandler) {
2607
2758
  command = this.commands[this.commands.length - 1];
2608
2759
  }
2609
- if (alias === command._name) throw new Error("Command alias can't be the same as its name");
2760
+ if (alias === command._name)
2761
+ throw new Error("Command alias can't be the same as its name");
2610
2762
  const matchingCommand = this.parent?._findCommand(alias);
2611
2763
  if (matchingCommand) {
2612
2764
  const existingCmd = [matchingCommand.name()].concat(matchingCommand.aliases()).join("|");
2613
- throw new Error(`cannot add alias '${alias}' to command '${this.name()}' as already have command '${existingCmd}'`);
2765
+ throw new Error(
2766
+ `cannot add alias '${alias}' to command '${this.name()}' as already have command '${existingCmd}'`
2767
+ );
2614
2768
  }
2615
2769
  command._aliases.push(alias);
2616
2770
  return this;
@@ -2749,7 +2903,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
2749
2903
  this.emit(this._getHelpOption().long);
2750
2904
  }
2751
2905
  this.emit("afterHelp", context2);
2752
- this._getCommandAndAncestors().forEach((command) => command.emit("afterAllHelp", context2));
2906
+ this._getCommandAndAncestors().forEach(
2907
+ (command) => command.emit("afterAllHelp", context2)
2908
+ );
2753
2909
  }
2754
2910
  /**
2755
2911
  * You can pass in flags and a description to customise the built-in help option.
@@ -2782,7 +2938,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
2782
2938
  * Returns null if has been disabled with .helpOption(false).
2783
2939
  *
2784
2940
  * @returns {(Option | null)} the help option
2785
- * @package internal use only
2941
+ * @package
2786
2942
  */
2787
2943
  _getHelpOption() {
2788
2944
  if (this._helpOption === void 0) {
@@ -2917,171 +3073,108 @@ var require_commander = __commonJS({
2917
3073
  }
2918
3074
  });
2919
3075
 
2920
- // ../../node_modules/uWebSockets.js/uws_darwin_arm64_108.node
2921
- var require_uws_darwin_arm64_108 = __commonJS({
2922
- "../../node_modules/uWebSockets.js/uws_darwin_arm64_108.node"(exports, module) {
2923
- module.exports = "./uws_darwin_arm64_108-CLFXMYPI.node";
2924
- }
2925
- });
2926
-
2927
- // ../../node_modules/uWebSockets.js/uws_darwin_arm64_115.node
2928
- var require_uws_darwin_arm64_115 = __commonJS({
2929
- "../../node_modules/uWebSockets.js/uws_darwin_arm64_115.node"(exports, module) {
2930
- module.exports = "./uws_darwin_arm64_115-7FFEG3YF.node";
2931
- }
2932
- });
2933
-
2934
- // ../../node_modules/uWebSockets.js/uws_darwin_arm64_120.node
2935
- var require_uws_darwin_arm64_120 = __commonJS({
2936
- "../../node_modules/uWebSockets.js/uws_darwin_arm64_120.node"(exports, module) {
2937
- module.exports = "./uws_darwin_arm64_120-GFZT7CLS.node";
2938
- }
2939
- });
2940
-
2941
3076
  // ../../node_modules/uWebSockets.js/uws_darwin_arm64_127.node
2942
3077
  var require_uws_darwin_arm64_127 = __commonJS({
2943
3078
  "../../node_modules/uWebSockets.js/uws_darwin_arm64_127.node"(exports, module) {
2944
- module.exports = "./uws_darwin_arm64_127-KHC2FVAM.node";
2945
- }
2946
- });
2947
-
2948
- // ../../node_modules/uWebSockets.js/uws_darwin_x64_108.node
2949
- var require_uws_darwin_x64_108 = __commonJS({
2950
- "../../node_modules/uWebSockets.js/uws_darwin_x64_108.node"(exports, module) {
2951
- module.exports = "./uws_darwin_x64_108-BRGT45AT.node";
3079
+ module.exports = "./uws_darwin_arm64_127-NGHTXN5Q.node";
2952
3080
  }
2953
3081
  });
2954
3082
 
2955
- // ../../node_modules/uWebSockets.js/uws_darwin_x64_115.node
2956
- var require_uws_darwin_x64_115 = __commonJS({
2957
- "../../node_modules/uWebSockets.js/uws_darwin_x64_115.node"(exports, module) {
2958
- module.exports = "./uws_darwin_x64_115-4HGPQGDD.node";
3083
+ // ../../node_modules/uWebSockets.js/uws_darwin_arm64_137.node
3084
+ var require_uws_darwin_arm64_137 = __commonJS({
3085
+ "../../node_modules/uWebSockets.js/uws_darwin_arm64_137.node"(exports, module) {
3086
+ module.exports = "./uws_darwin_arm64_137-ESY6MPLH.node";
2959
3087
  }
2960
3088
  });
2961
3089
 
2962
- // ../../node_modules/uWebSockets.js/uws_darwin_x64_120.node
2963
- var require_uws_darwin_x64_120 = __commonJS({
2964
- "../../node_modules/uWebSockets.js/uws_darwin_x64_120.node"(exports, module) {
2965
- module.exports = "./uws_darwin_x64_120-C2SGUHP4.node";
3090
+ // ../../node_modules/uWebSockets.js/uws_darwin_arm64_147.node
3091
+ var require_uws_darwin_arm64_147 = __commonJS({
3092
+ "../../node_modules/uWebSockets.js/uws_darwin_arm64_147.node"(exports, module) {
3093
+ module.exports = "./uws_darwin_arm64_147-V7BKA3SU.node";
2966
3094
  }
2967
3095
  });
2968
3096
 
2969
3097
  // ../../node_modules/uWebSockets.js/uws_darwin_x64_127.node
2970
3098
  var require_uws_darwin_x64_127 = __commonJS({
2971
3099
  "../../node_modules/uWebSockets.js/uws_darwin_x64_127.node"(exports, module) {
2972
- module.exports = "./uws_darwin_x64_127-NHKQMMST.node";
2973
- }
2974
- });
2975
-
2976
- // ../../node_modules/uWebSockets.js/uws_linux_arm64_108.node
2977
- var require_uws_linux_arm64_108 = __commonJS({
2978
- "../../node_modules/uWebSockets.js/uws_linux_arm64_108.node"(exports, module) {
2979
- module.exports = "./uws_linux_arm64_108-YHK7ACON.node";
3100
+ module.exports = "./uws_darwin_x64_127-WIZGG7MS.node";
2980
3101
  }
2981
3102
  });
2982
3103
 
2983
- // ../../node_modules/uWebSockets.js/uws_linux_arm64_115.node
2984
- var require_uws_linux_arm64_115 = __commonJS({
2985
- "../../node_modules/uWebSockets.js/uws_linux_arm64_115.node"(exports, module) {
2986
- module.exports = "./uws_linux_arm64_115-EIAAY4WO.node";
3104
+ // ../../node_modules/uWebSockets.js/uws_darwin_x64_137.node
3105
+ var require_uws_darwin_x64_137 = __commonJS({
3106
+ "../../node_modules/uWebSockets.js/uws_darwin_x64_137.node"(exports, module) {
3107
+ module.exports = "./uws_darwin_x64_137-APKZWL4Y.node";
2987
3108
  }
2988
3109
  });
2989
3110
 
2990
- // ../../node_modules/uWebSockets.js/uws_linux_arm64_120.node
2991
- var require_uws_linux_arm64_120 = __commonJS({
2992
- "../../node_modules/uWebSockets.js/uws_linux_arm64_120.node"(exports, module) {
2993
- module.exports = "./uws_linux_arm64_120-OADY5FIN.node";
3111
+ // ../../node_modules/uWebSockets.js/uws_darwin_x64_147.node
3112
+ var require_uws_darwin_x64_147 = __commonJS({
3113
+ "../../node_modules/uWebSockets.js/uws_darwin_x64_147.node"(exports, module) {
3114
+ module.exports = "./uws_darwin_x64_147-W2HKFQZT.node";
2994
3115
  }
2995
3116
  });
2996
3117
 
2997
3118
  // ../../node_modules/uWebSockets.js/uws_linux_arm64_127.node
2998
3119
  var require_uws_linux_arm64_127 = __commonJS({
2999
3120
  "../../node_modules/uWebSockets.js/uws_linux_arm64_127.node"(exports, module) {
3000
- module.exports = "./uws_linux_arm64_127-U2SRLYQM.node";
3001
- }
3002
- });
3003
-
3004
- // ../../node_modules/uWebSockets.js/uws_linux_arm_108.node
3005
- var require_uws_linux_arm_108 = __commonJS({
3006
- "../../node_modules/uWebSockets.js/uws_linux_arm_108.node"(exports, module) {
3007
- module.exports = "./uws_linux_arm_108-BKVITVZA.node";
3121
+ module.exports = "./uws_linux_arm64_127-3CO7NSFJ.node";
3008
3122
  }
3009
3123
  });
3010
3124
 
3011
- // ../../node_modules/uWebSockets.js/uws_linux_arm_115.node
3012
- var require_uws_linux_arm_115 = __commonJS({
3013
- "../../node_modules/uWebSockets.js/uws_linux_arm_115.node"(exports, module) {
3014
- module.exports = "./uws_linux_arm_115-7IORQF77.node";
3125
+ // ../../node_modules/uWebSockets.js/uws_linux_arm64_137.node
3126
+ var require_uws_linux_arm64_137 = __commonJS({
3127
+ "../../node_modules/uWebSockets.js/uws_linux_arm64_137.node"(exports, module) {
3128
+ module.exports = "./uws_linux_arm64_137-HWEDGGZV.node";
3015
3129
  }
3016
3130
  });
3017
3131
 
3018
- // ../../node_modules/uWebSockets.js/uws_linux_arm_120.node
3019
- var require_uws_linux_arm_120 = __commonJS({
3020
- "../../node_modules/uWebSockets.js/uws_linux_arm_120.node"(exports, module) {
3021
- module.exports = "./uws_linux_arm_120-LCX4ED5F.node";
3022
- }
3023
- });
3024
-
3025
- // ../../node_modules/uWebSockets.js/uws_linux_arm_127.node
3026
- var require_uws_linux_arm_127 = __commonJS({
3027
- "../../node_modules/uWebSockets.js/uws_linux_arm_127.node"(exports, module) {
3028
- module.exports = "./uws_linux_arm_127-6UTO7TL6.node";
3029
- }
3030
- });
3031
-
3032
- // ../../node_modules/uWebSockets.js/uws_linux_x64_108.node
3033
- var require_uws_linux_x64_108 = __commonJS({
3034
- "../../node_modules/uWebSockets.js/uws_linux_x64_108.node"(exports, module) {
3035
- module.exports = "./uws_linux_x64_108-QSNE6XWU.node";
3036
- }
3037
- });
3038
-
3039
- // ../../node_modules/uWebSockets.js/uws_linux_x64_115.node
3040
- var require_uws_linux_x64_115 = __commonJS({
3041
- "../../node_modules/uWebSockets.js/uws_linux_x64_115.node"(exports, module) {
3042
- module.exports = "./uws_linux_x64_115-7AAZWMWE.node";
3043
- }
3044
- });
3045
-
3046
- // ../../node_modules/uWebSockets.js/uws_linux_x64_120.node
3047
- var require_uws_linux_x64_120 = __commonJS({
3048
- "../../node_modules/uWebSockets.js/uws_linux_x64_120.node"(exports, module) {
3049
- module.exports = "./uws_linux_x64_120-AIZ6RIW2.node";
3132
+ // ../../node_modules/uWebSockets.js/uws_linux_arm64_147.node
3133
+ var require_uws_linux_arm64_147 = __commonJS({
3134
+ "../../node_modules/uWebSockets.js/uws_linux_arm64_147.node"(exports, module) {
3135
+ module.exports = "./uws_linux_arm64_147-7UCIYMK2.node";
3050
3136
  }
3051
3137
  });
3052
3138
 
3053
3139
  // ../../node_modules/uWebSockets.js/uws_linux_x64_127.node
3054
3140
  var require_uws_linux_x64_127 = __commonJS({
3055
3141
  "../../node_modules/uWebSockets.js/uws_linux_x64_127.node"(exports, module) {
3056
- module.exports = "./uws_linux_x64_127-HBA6RNSU.node";
3057
- }
3058
- });
3059
-
3060
- // ../../node_modules/uWebSockets.js/uws_win32_x64_108.node
3061
- var require_uws_win32_x64_108 = __commonJS({
3062
- "../../node_modules/uWebSockets.js/uws_win32_x64_108.node"(exports, module) {
3063
- module.exports = "./uws_win32_x64_108-J6KONPDM.node";
3142
+ module.exports = "./uws_linux_x64_127-KA4E76LJ.node";
3064
3143
  }
3065
3144
  });
3066
3145
 
3067
- // ../../node_modules/uWebSockets.js/uws_win32_x64_115.node
3068
- var require_uws_win32_x64_115 = __commonJS({
3069
- "../../node_modules/uWebSockets.js/uws_win32_x64_115.node"(exports, module) {
3070
- module.exports = "./uws_win32_x64_115-V5N4NHJ5.node";
3146
+ // ../../node_modules/uWebSockets.js/uws_linux_x64_137.node
3147
+ var require_uws_linux_x64_137 = __commonJS({
3148
+ "../../node_modules/uWebSockets.js/uws_linux_x64_137.node"(exports, module) {
3149
+ module.exports = "./uws_linux_x64_137-DDFLTTJR.node";
3071
3150
  }
3072
3151
  });
3073
3152
 
3074
- // ../../node_modules/uWebSockets.js/uws_win32_x64_120.node
3075
- var require_uws_win32_x64_120 = __commonJS({
3076
- "../../node_modules/uWebSockets.js/uws_win32_x64_120.node"(exports, module) {
3077
- module.exports = "./uws_win32_x64_120-XH4MVJGN.node";
3153
+ // ../../node_modules/uWebSockets.js/uws_linux_x64_147.node
3154
+ var require_uws_linux_x64_147 = __commonJS({
3155
+ "../../node_modules/uWebSockets.js/uws_linux_x64_147.node"(exports, module) {
3156
+ module.exports = "./uws_linux_x64_147-MJSFREL3.node";
3078
3157
  }
3079
3158
  });
3080
3159
 
3081
3160
  // ../../node_modules/uWebSockets.js/uws_win32_x64_127.node
3082
3161
  var require_uws_win32_x64_127 = __commonJS({
3083
3162
  "../../node_modules/uWebSockets.js/uws_win32_x64_127.node"(exports, module) {
3084
- module.exports = "./uws_win32_x64_127-JBAEKR4X.node";
3163
+ module.exports = "./uws_win32_x64_127-O4US4Y4L.node";
3164
+ }
3165
+ });
3166
+
3167
+ // ../../node_modules/uWebSockets.js/uws_win32_x64_137.node
3168
+ var require_uws_win32_x64_137 = __commonJS({
3169
+ "../../node_modules/uWebSockets.js/uws_win32_x64_137.node"(exports, module) {
3170
+ module.exports = "./uws_win32_x64_137-L5OZROQ7.node";
3171
+ }
3172
+ });
3173
+
3174
+ // ../../node_modules/uWebSockets.js/uws_win32_x64_147.node
3175
+ var require_uws_win32_x64_147 = __commonJS({
3176
+ "../../node_modules/uWebSockets.js/uws_win32_x64_147.node"(exports, module) {
3177
+ module.exports = "./uws_win32_x64_147-D7MGKVRG.node";
3085
3178
  }
3086
3179
  });
3087
3180
 
@@ -3090,30 +3183,21 @@ var globRequire_uws______node;
3090
3183
  var init_ = __esm({
3091
3184
  'require("./uws_*_*_*.node") in ../../node_modules/uWebSockets.js/uws.js'() {
3092
3185
  globRequire_uws______node = __glob({
3093
- "./uws_darwin_arm64_108.node": () => require_uws_darwin_arm64_108(),
3094
- "./uws_darwin_arm64_115.node": () => require_uws_darwin_arm64_115(),
3095
- "./uws_darwin_arm64_120.node": () => require_uws_darwin_arm64_120(),
3096
3186
  "./uws_darwin_arm64_127.node": () => require_uws_darwin_arm64_127(),
3097
- "./uws_darwin_x64_108.node": () => require_uws_darwin_x64_108(),
3098
- "./uws_darwin_x64_115.node": () => require_uws_darwin_x64_115(),
3099
- "./uws_darwin_x64_120.node": () => require_uws_darwin_x64_120(),
3187
+ "./uws_darwin_arm64_137.node": () => require_uws_darwin_arm64_137(),
3188
+ "./uws_darwin_arm64_147.node": () => require_uws_darwin_arm64_147(),
3100
3189
  "./uws_darwin_x64_127.node": () => require_uws_darwin_x64_127(),
3101
- "./uws_linux_arm64_108.node": () => require_uws_linux_arm64_108(),
3102
- "./uws_linux_arm64_115.node": () => require_uws_linux_arm64_115(),
3103
- "./uws_linux_arm64_120.node": () => require_uws_linux_arm64_120(),
3190
+ "./uws_darwin_x64_137.node": () => require_uws_darwin_x64_137(),
3191
+ "./uws_darwin_x64_147.node": () => require_uws_darwin_x64_147(),
3104
3192
  "./uws_linux_arm64_127.node": () => require_uws_linux_arm64_127(),
3105
- "./uws_linux_arm_108.node": () => require_uws_linux_arm_108(),
3106
- "./uws_linux_arm_115.node": () => require_uws_linux_arm_115(),
3107
- "./uws_linux_arm_120.node": () => require_uws_linux_arm_120(),
3108
- "./uws_linux_arm_127.node": () => require_uws_linux_arm_127(),
3109
- "./uws_linux_x64_108.node": () => require_uws_linux_x64_108(),
3110
- "./uws_linux_x64_115.node": () => require_uws_linux_x64_115(),
3111
- "./uws_linux_x64_120.node": () => require_uws_linux_x64_120(),
3193
+ "./uws_linux_arm64_137.node": () => require_uws_linux_arm64_137(),
3194
+ "./uws_linux_arm64_147.node": () => require_uws_linux_arm64_147(),
3112
3195
  "./uws_linux_x64_127.node": () => require_uws_linux_x64_127(),
3113
- "./uws_win32_x64_108.node": () => require_uws_win32_x64_108(),
3114
- "./uws_win32_x64_115.node": () => require_uws_win32_x64_115(),
3115
- "./uws_win32_x64_120.node": () => require_uws_win32_x64_120(),
3116
- "./uws_win32_x64_127.node": () => require_uws_win32_x64_127()
3196
+ "./uws_linux_x64_137.node": () => require_uws_linux_x64_137(),
3197
+ "./uws_linux_x64_147.node": () => require_uws_linux_x64_147(),
3198
+ "./uws_win32_x64_127.node": () => require_uws_win32_x64_127(),
3199
+ "./uws_win32_x64_137.node": () => require_uws_win32_x64_137(),
3200
+ "./uws_win32_x64_147.node": () => require_uws_win32_x64_147()
3117
3201
  });
3118
3202
  }
3119
3203
  });
@@ -3126,27 +3210,37 @@ var require_uws = __commonJS({
3126
3210
  try {
3127
3211
  return globRequire_uws______node("./uws_" + process.platform + "_" + process.arch + "_" + process.versions.modules + ".node");
3128
3212
  } catch (e) {
3129
- throw new Error("This version of uWS.js supports only Node.js versions 18, 20, 21 and 22 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());
3213
+ 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());
3130
3214
  }
3131
3215
  })();
3216
+ var MAX_U8 = Math.pow(2, 8) - 1;
3217
+ var MAX_U16 = Math.pow(2, 16) - 1;
3218
+ var textEncoder = new TextEncoder();
3219
+ var toUint8Array = (value) => {
3220
+ if (value === void 0) return new Uint8Array(0);
3221
+ else if (typeof value === "string") return textEncoder.encode(value);
3222
+ else if (value instanceof ArrayBuffer) return new Uint8Array(value);
3223
+ else if (value instanceof SharedArrayBuffer) return new Uint8Array(value);
3224
+ else return new Uint8Array(value.buffer, value.byteOffset, value.byteLength);
3225
+ };
3132
3226
  module.exports.DeclarativeResponse = class DeclarativeResponse {
3133
3227
  constructor() {
3134
3228
  this.instructions = [];
3135
3229
  }
3136
- // Utility method to encode text and append instruction
3137
- _appendInstruction(opcode, ...text) {
3230
+ // Append instruction and 1-byte length values
3231
+ _appendInstruction(opcode, ...values) {
3138
3232
  this.instructions.push(opcode);
3139
- text.forEach((str) => {
3140
- const bytes = typeof str === "string" ? new TextEncoder().encode(str) : str;
3141
- this.instructions.push(bytes.length, ...bytes);
3233
+ values.forEach((value) => {
3234
+ const uint8Array = toUint8Array(value);
3235
+ if (uint8Array.byteLength > MAX_U8) throw new RangeError("Data length exceeds " + MAX_U8);
3236
+ this.instructions.push(uint8Array.byteLength, ...uint8Array);
3142
3237
  });
3143
3238
  }
3144
- // Utility method to append 2-byte length text in little-endian format
3145
- _appendInstructionWithLength(opcode, text) {
3146
- this.instructions.push(opcode);
3147
- const bytes = new TextEncoder().encode(text);
3148
- const length = bytes.length;
3149
- this.instructions.push(length & 255, length >> 8 & 255, ...bytes);
3239
+ // Append instruction and 2-byte length value
3240
+ _appendInstructionWithLength(opcode, value) {
3241
+ const uint8Array = toUint8Array(value);
3242
+ if (uint8Array.byteLength > MAX_U16) throw new RangeError("Data length exceeds " + MAX_U16);
3243
+ this.instructions.push(opcode, uint8Array.byteLength & 255, uint8Array.byteLength >> 8 & 255, ...uint8Array);
3150
3244
  }
3151
3245
  writeHeader(key, value) {
3152
3246
  return this._appendInstruction(1, key, value), this;
@@ -3166,10 +3260,11 @@ var require_uws = __commonJS({
3166
3260
  writeParameterValue(key) {
3167
3261
  return this._appendInstruction(6, key), this;
3168
3262
  }
3263
+ writeStatus(status) {
3264
+ return this._appendInstruction(7, status), this;
3265
+ }
3169
3266
  end(value) {
3170
- const bytes = new TextEncoder().encode(value);
3171
- const length = bytes.length;
3172
- this.instructions.push(0, length & 255, length >> 8 & 255, ...bytes);
3267
+ this._appendInstructionWithLength(0, value);
3173
3268
  return new Uint8Array(this.instructions).buffer;
3174
3269
  }
3175
3270
  };
@@ -3363,7 +3458,7 @@ var init_dist = __esm({
3363
3458
  options;
3364
3459
  generate() {
3365
3460
  const spec = {
3366
- openapi: "3.0.3",
3461
+ openapi: "3.1.0",
3367
3462
  info: this.options.info,
3368
3463
  paths: {}
3369
3464
  };
@@ -3374,39 +3469,27 @@ var init_dist = __esm({
3374
3469
  const method = route.method.toLowerCase();
3375
3470
  const paths = spec.paths;
3376
3471
  if (!paths[openApiPath]) paths[openApiPath] = {};
3377
- const op = route.openapi ?? void 0;
3472
+ const s = route.schema ?? {};
3378
3473
  const operation = {
3379
- // OAS §4.7.10.2 — summary. Default to `${method} ${path}` so the
3380
- // docs UI always has a human-readable title even without user input.
3381
- summary: op?.summary ?? `${route.method} ${route.path}`,
3382
- // OAS §4.7.10.5 operationId. Client codegen tools
3383
- // (openapi-typescript, openapi-generator) use this to name the
3384
- // generated function. When the user doesn't supply one we
3385
- // synthesise a stable name from method+path:
3386
- // GET /users/:id → "getUsersById"
3387
- // POST /users → "postUsers"
3388
- // Determinism matters here — codegen output should not drift
3389
- // between releases unless method+path actually change.
3390
- operationId: op?.operationId ?? this.synthesiseOperationId(route.method, route.path),
3474
+ // OAS §4.8.10.2 — summary. Defaults to `${method} ${path}`.
3475
+ summary: s.summary ?? `${route.method} ${route.path}`,
3476
+ // OAS §4.8.10.5 — operationId for client codegen tools.
3477
+ // Auto-synthesised from method+path when omitted:
3478
+ // GET /users/:id "getUsersById" POST /users "postUsers"
3479
+ operationId: s.operationId ?? this.synthesiseOperationId(route.method, route.path),
3391
3480
  parameters: this.extractParameters(route),
3392
3481
  responses: this.extractResponses(route)
3393
3482
  };
3394
- const legacySchema = route.schema ?? {};
3395
- const description = op?.description ?? legacySchema.description;
3396
- const tags = op?.tags ?? legacySchema.tags;
3397
- const security = op?.security ?? legacySchema.security;
3398
- if (description) operation.description = description;
3399
- if (tags) operation.tags = tags;
3400
- if (security !== void 0) operation.security = security;
3401
- if (op?.deprecated) operation.deprecated = true;
3402
- if (op?.externalDocs) operation.externalDocs = op.externalDocs;
3403
- if (op?.servers) operation.servers = op.servers;
3404
- if (op?.callbacks) operation.callbacks = op.callbacks;
3483
+ if (s.description) operation.description = s.description;
3484
+ if (s.tags) operation.tags = s.tags;
3485
+ if (s.security !== void 0) operation.security = s.security;
3486
+ if (s.deprecated) operation.deprecated = true;
3487
+ if (s.externalDocs) operation.externalDocs = s.externalDocs;
3488
+ if (s.servers) operation.servers = s.servers;
3489
+ if (s.callbacks) operation.callbacks = s.callbacks;
3405
3490
  const body = this.extractBody(route);
3406
3491
  if (body) {
3407
- if (op?.requestBodyDescription) {
3408
- body.description = op.requestBodyDescription;
3409
- }
3492
+ if (s.requestBodyDescription) body.description = s.requestBodyDescription;
3410
3493
  operation.requestBody = body;
3411
3494
  }
3412
3495
  paths[openApiPath][method] = operation;
@@ -3500,8 +3583,7 @@ var init_dist = __esm({
3500
3583
  return { required: true, content: { [contentType]: { schema: finalSchema } } };
3501
3584
  }
3502
3585
  extractResponses(route) {
3503
- const op = route.openapi;
3504
- const descriptions = op?.responseDescriptions ?? {};
3586
+ const descriptions = route.schema?.responseDescriptions ?? {};
3505
3587
  const defaultResponse = {
3506
3588
  "200": {
3507
3589
  description: descriptions["200"] ?? "Successful response",
@@ -3561,7 +3643,7 @@ var {
3561
3643
 
3562
3644
  // package.json
3563
3645
  var package_default = {
3564
- version: "6.0.0-rc.2"};
3646
+ version: "6.0.0"};
3565
3647
  var ALWAYS_EXTERNAL = ["uWebSockets.js"];
3566
3648
  function getUserExternals(cwd) {
3567
3649
  let pkgExternals = [];
@@ -3829,7 +3911,16 @@ function checkOpenApiNaming(ctx) {
3829
3911
  severity: "fail",
3830
3912
  area: "api",
3831
3913
  message: `${usingMeta.length} route${usingMeta.length === 1 ? "" : "s"} use the removed \`meta:\` field`,
3832
- hint: `The \`meta:\` field was removed in 6.0. Rename to \`openapi:\` \u2014 shape is identical. First offender: ${usingMeta[0].method} ${usingMeta[0].path}`
3914
+ 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}`
3915
+ });
3916
+ }
3917
+ const usingOpenapi = routes.filter((r) => r.openapi);
3918
+ if (usingOpenapi.length > 0) {
3919
+ add(ctx, {
3920
+ severity: "fail",
3921
+ area: "api",
3922
+ message: `${usingOpenapi.length} route${usingOpenapi.length === 1 ? "" : "s"} use the removed top-level \`openapi:\` field`,
3923
+ 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}`
3833
3924
  });
3834
3925
  }
3835
3926
  }
@@ -4539,15 +4630,20 @@ async function initProject(targetDir, options = {}) {
4539
4630
  }
4540
4631
  var RULES = [
4541
4632
  {
4542
- id: "meta-to-openapi",
4543
- description: "`meta:` route field renamed to `openapi:` (OpenAPI 3.0.3 Operation Object terminology)",
4544
- // Match `meta: {` or `meta:{` after whitespace/comma avoid matching
4545
- // unrelated `meta:` fields in other object literals by requiring an
4546
- // adjacent route-definition cue (method, path, schema, handler nearby).
4547
- // To stay simple and conservative, only rewrite when the line starts
4548
- // with optional whitespace + `meta:` (the common formatting).
4633
+ id: "meta-to-schema",
4634
+ description: "`meta:` route field removed \u2014 metadata now lives inside `schema:` alongside Zod fields",
4635
+ // NOTE: This rule renames `meta:` a comment directing the dev to merge
4636
+ // contents into schema:. A full structural AST merge is out of scope for
4637
+ // the regex codemod; flag it for manual review instead (see report).
4549
4638
  match: /^(\s*)meta:(\s*\{)/gm,
4550
- replace: "$1openapi:$2"
4639
+ replace: "$1/* TODO(axiomify-migrate): merge meta fields into schema: */ openapi_REMOVE:$2"
4640
+ },
4641
+ {
4642
+ id: "openapi-field-to-schema",
4643
+ description: "`openapi:` top-level route field \u2192 contents merged into `schema:` (removed in 6.1)",
4644
+ // Same conservative approach: flag for manual review via TODO comment.
4645
+ match: /^(\s*)openapi:(\s*\{)/gm,
4646
+ replace: "$1/* TODO(axiomify-migrate): merge openapi fields into schema: */ openapi_REMOVE:$2"
4551
4647
  },
4552
4648
  {
4553
4649
  id: "useSwagger-import",
@@ -4566,7 +4662,7 @@ var RULES = [
4566
4662
  },
4567
4663
  {
4568
4664
  id: "RouteMeta-type",
4569
- description: "`RouteMeta` type \u2192 `OpenApiOperation` (alias kept through 5.x, removed in 6.0)",
4665
+ description: "`RouteMeta` type \u2192 `OpenApiOperation` (alias removed in 6.0)",
4570
4666
  // Match `RouteMeta` only as a type position (after `:` or `<` or
4571
4667
  // `as`) — avoids hitting an unrelated variable named `RouteMeta`.
4572
4668
  match: /(:\s*|<\s*|\bas\s+)RouteMeta\b/g,
@@ -4674,7 +4770,7 @@ async function runMigrate(opts = {}) {
4674
4770
  )
4675
4771
  );
4676
4772
  if (results.length === 0) {
4677
- console.log(` ${symbols.ok} Nothing to migrate \u2014 looks like you're already on the v5 shape.`);
4773
+ console.log(` ${symbols.ok} Nothing to migrate \u2014 all patterns look up to date.`);
4678
4774
  console.log();
4679
4775
  return;
4680
4776
  }
@@ -4760,7 +4856,7 @@ async function runMigrate(opts = {}) {
4760
4856
  );
4761
4857
  console.log();
4762
4858
  console.log(
4763
- ` See ${pc__default.default.cyan("docs/migration-v4-to-v5.md")} for the full guide and ` + pc__default.default.cyan("axiomify check") + " to verify the migrated app."
4859
+ ` See ${pc__default.default.cyan("docs/migration-v4-to-v5.md")} for the full guide and ` + pc__default.default.cyan("axiomify check") + " to verify the migrated app.\n" + pc__default.default.yellow(" Note: `openapi:` / `meta:` merges into `schema:` require manual review \u2014 check TODO comments.")
4764
4860
  );
4765
4861
  console.log();
4766
4862
  }
@@ -4857,14 +4953,14 @@ function normalise(raw, isWs) {
4857
4953
  if (raw.schema?.response) validation.push("Response");
4858
4954
  if (raw.schema?.files) validation.push("Files");
4859
4955
  if (raw.schema?.message) validation.push("Message");
4860
- const op = raw.openapi ?? {};
4956
+ const s = raw.schema ?? {};
4861
4957
  return {
4862
4958
  method: isWs ? "WS" : raw.method,
4863
4959
  path: raw.path,
4864
4960
  validation,
4865
- tags: Array.isArray(op.tags) ? op.tags : [],
4866
- operationId: typeof op.operationId === "string" ? op.operationId : void 0,
4867
- deprecated: op.deprecated === true,
4961
+ tags: Array.isArray(s.tags) ? s.tags : [],
4962
+ operationId: typeof s.operationId === "string" ? s.operationId : void 0,
4963
+ deprecated: s.deprecated === true,
4868
4964
  timeout: typeof raw.timeout === "number" && raw.timeout > 0 ? raw.timeout : void 0,
4869
4965
  plugins: Array.isArray(raw.plugins) ? raw.plugins.length : 0,
4870
4966
  isWs
@@ -5096,10 +5192,9 @@ const limiter = createRateLimitPlugin({
5096
5192
  }),` : "",
5097
5193
  ` // response: z.object({ /* response shape */ }),`,
5098
5194
  ` },`,
5099
- ` openapi: {`,
5195
+ ` // OpenAPI metadata (tags, summary, operationId etc.) lives in schema: too`,
5100
5196
  ` tags: ['${pathToFilename(routePath).split("-")[0] || "general"}'],`,
5101
5197
  ` summary: '${method} ${routePath}',`,
5102
- ` },`,
5103
5198
  plugins.length > 0 ? ` plugins: [${plugins.join(", ")}],` : "",
5104
5199
  ` handler: async (${paramKeys.length > 0 || method !== "GET" ? "req" : "_req"}, res) => {`,
5105
5200
  method === "POST" ? ` // TODO \u2014 handler logic
@@ -5211,7 +5306,7 @@ var scaffold = program2.command("scaffold").description("Generate boilerplate (r
5211
5306
  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(
5212
5307
  (method, routePath, options) => scaffoldRoute(method, routePath, options)
5213
5308
  );
5214
- program2.command("migrate").description("v4 \u2192 v5 codemod: rename meta\u2192openapi, useSwagger\u2192useOpenAPI, 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(
5309
+ 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(
5215
5310
  (options) => runMigrate(options)
5216
5311
  );
5217
5312
  program2.parse(process.argv);