@settlemint/sdk-mcp 1.1.16-prc78f6086 → 1.1.16-pre2559e50

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 (3) hide show
  1. package/dist/mcp.js +606 -403
  2. package/dist/mcp.js.map +12 -12
  3. package/package.json +4 -3
package/dist/mcp.js CHANGED
@@ -10014,8 +10014,7 @@ var require_mapAsyncIterator = __commonJS((exports) => {
10014
10014
  if (typeof iterator.return === "function") {
10015
10015
  try {
10016
10016
  await iterator.return();
10017
- } catch (_e) {
10018
- }
10017
+ } catch (_e) {}
10019
10018
  }
10020
10019
  throw error;
10021
10020
  }
@@ -13988,8 +13987,7 @@ var require_p_limit = __commonJS((exports, module) => {
13988
13987
  resolve(result);
13989
13988
  try {
13990
13989
  await result;
13991
- } catch {
13992
- }
13990
+ } catch {}
13993
13991
  next();
13994
13992
  };
13995
13993
  const enqueue = (fn, resolve, ...args) => {
@@ -14037,8 +14035,7 @@ var require_constants = __commonJS((exports, module) => {
14037
14035
  kListener: Symbol("kListener"),
14038
14036
  kStatusCode: Symbol("status-code"),
14039
14037
  kWebSocket: Symbol("websocket"),
14040
- NOOP: () => {
14041
- }
14038
+ NOOP: () => {}
14042
14039
  };
14043
14040
  });
14044
14041
 
@@ -14116,8 +14113,7 @@ var require_buffer_util = __commonJS((exports, module) => {
14116
14113
  else
14117
14114
  bufferUtil.unmask(buffer, mask);
14118
14115
  };
14119
- } catch (e) {
14120
- }
14116
+ } catch (e) {}
14121
14117
  }
14122
14118
  });
14123
14119
 
@@ -14596,8 +14592,7 @@ var require_validation2 = __commonJS((exports, module) => {
14596
14592
  module.exports.isValidUTF8 = function(buf) {
14597
14593
  return buf.length < 32 ? _isValidUTF8(buf) : isValidUTF8(buf);
14598
14594
  };
14599
- } catch (e) {
14600
- }
14595
+ } catch (e) {}
14601
14596
  }
14602
14597
  });
14603
14598
 
@@ -18883,8 +18878,7 @@ var require_utils = __commonJS((exports, module) => {
18883
18878
  try {
18884
18879
  const decoder = new TextDecoder(exports);
18885
18880
  return decoder.decode(data);
18886
- } catch {
18887
- }
18881
+ } catch {}
18888
18882
  }
18889
18883
  };
18890
18884
  function convertToUTF8(data, charset, hint) {
@@ -20614,8 +20608,7 @@ var require_multipart = __commonJS((exports, module) => {
20614
20608
  `);
20615
20609
  var BUF_CR = Buffer.from("\r");
20616
20610
  var BUF_DASH = Buffer.from("-");
20617
- function noop() {
20618
- }
20611
+ function noop() {}
20619
20612
  var MAX_HEADER_PAIRS = 2000;
20620
20613
  var MAX_HEADER_SIZE = 16 * 1024;
20621
20614
  var HPARSER_NAME = 0;
@@ -20783,10 +20776,8 @@ var require_multipart = __commonJS((exports, module) => {
20783
20776
  }
20784
20777
  }
20785
20778
  var ignoreData = {
20786
- push: (chunk, pos) => {
20787
- },
20788
- destroy: () => {
20789
- }
20779
+ push: (chunk, pos) => {},
20780
+ destroy: () => {}
20790
20781
  };
20791
20782
  function callAndUnsetCb(self2, err) {
20792
20783
  const cb = self2._writecb;
@@ -24701,8 +24692,7 @@ var require_WritableStream = __commonJS((exports) => {
24701
24692
  resolve(undefined);
24702
24693
  });
24703
24694
  }),
24704
- releaseLock() {
24705
- },
24695
+ releaseLock() {},
24706
24696
  write(chunk) {
24707
24697
  if (chunk == null) {
24708
24698
  return (0, utils_js_1.fakePromise)();
@@ -24803,8 +24793,7 @@ var require_TransformStream = __commonJS((exports) => {
24803
24793
  }
24804
24794
  };
24805
24795
  const transform = new node_stream_1.Transform({
24806
- read() {
24807
- },
24796
+ read() {},
24808
24797
  write(chunk, _encoding, callback) {
24809
24798
  try {
24810
24799
  const result = transformer.transform?.(chunk, controller);
@@ -25219,8 +25208,7 @@ var require_ValueOrPromise = __commonJS((exports) => {
25219
25208
  }
25220
25209
  if (containsPromise) {
25221
25210
  if (rejected) {
25222
- Promise.all(values).catch(() => {
25223
- });
25211
+ Promise.all(values).catch(() => {});
25224
25212
  return new ValueOrPromise(() => {
25225
25213
  throw reason;
25226
25214
  });
@@ -25411,8 +25399,7 @@ var require_dataloader = __commonJS((exports, module) => {
25411
25399
  var promise;
25412
25400
  if (value instanceof Error) {
25413
25401
  promise = Promise.reject(value);
25414
- promise["catch"](function() {
25415
- });
25402
+ promise["catch"](function() {});
25416
25403
  } else {
25417
25404
  promise = Promise.resolve(value);
25418
25405
  }
@@ -27662,8 +27649,7 @@ var require_push_directory = __commonJS((exports) => {
27662
27649
  paths.push(path);
27663
27650
  }
27664
27651
  };
27665
- var empty = () => {
27666
- };
27652
+ var empty = () => {};
27667
27653
  function build(root, options) {
27668
27654
  const { includeDirs, filters, relativePaths } = options;
27669
27655
  if (!includeDirs)
@@ -27693,8 +27679,7 @@ var require_push_file = __commonJS((exports) => {
27693
27679
  var pushFile = (filename, paths) => {
27694
27680
  paths.push(filename);
27695
27681
  };
27696
- var empty = () => {
27697
- };
27682
+ var empty = () => {};
27698
27683
  function build(options) {
27699
27684
  const { excludeFiles, filters, onlyCounts } = options;
27700
27685
  if (excludeFiles)
@@ -27733,8 +27718,7 @@ var require_group_files = __commonJS((exports) => {
27733
27718
  var groupFiles = (groups, directory, files) => {
27734
27719
  groups.push({ directory, files, dir: directory });
27735
27720
  };
27736
- var empty = () => {
27737
- };
27721
+ var empty = () => {};
27738
27722
  function build(options) {
27739
27723
  return options.group ? groupFiles : empty;
27740
27724
  }
@@ -29592,8 +29576,7 @@ var require_builder = __commonJS((exports) => {
29592
29576
  try {
29593
29577
  __require.resolve("picomatch");
29594
29578
  pm = require_picomatch2();
29595
- } catch (_e) {
29596
- }
29579
+ } catch (_e) {}
29597
29580
 
29598
29581
  class Builder {
29599
29582
  globCache = {};
@@ -30327,8 +30310,7 @@ var require_utils7 = __commonJS((exports) => {
30327
30310
  function numberToBytesBE(n, len) {
30328
30311
  return hexToBytes(n.toString(16).padStart(len * 2, "0"));
30329
30312
  }
30330
- var nextTick = async () => {
30331
- };
30313
+ var nextTick = async () => {};
30332
30314
  exports.nextTick = nextTick;
30333
30315
  function utf8ToBytes(str) {
30334
30316
  if (typeof str !== "string")
@@ -30791,8 +30773,7 @@ var require_utils8 = __commonJS((exports) => {
30791
30773
  }
30792
30774
  return array2;
30793
30775
  }
30794
- var nextTick = async () => {
30795
- };
30776
+ var nextTick = async () => {};
30796
30777
  exports.nextTick = nextTick;
30797
30778
  async function asyncLoop(iters, tick, cb) {
30798
30779
  let ts = Date.now();
@@ -31789,8 +31770,7 @@ var require_modular = __commonJS((exports) => {
31789
31770
  return root;
31790
31771
  };
31791
31772
  }
31792
- if (P % _16n === _9n) {
31793
- }
31773
+ if (P % _16n === _9n) {}
31794
31774
  return tonelliShanks(P);
31795
31775
  }
31796
31776
  var isNegativeLE = (num, modulo) => (mod(num, modulo) & _1n) === _1n;
@@ -37158,8 +37138,7 @@ var require_main3 = __commonJS((exports, module) => {
37158
37138
  logger.success(`✔ set ${key}${withEncryption} (${changedFilepaths.join(",")})`);
37159
37139
  } else if (unchangedFilepaths.length > 0) {
37160
37140
  logger.info(`no changes (${unchangedFilepaths})`);
37161
- } else {
37162
- }
37141
+ } else {}
37163
37142
  for (const processedEnv of processedEnvs) {
37164
37143
  if (processedEnv.privateKeyAdded) {
37165
37144
  logger.success(`✔ key added to ${processedEnv.envKeysFilepath} (${processedEnv.privateKeyName})`);
@@ -37563,18 +37542,18 @@ var require_help = __commonJS((exports) => {
37563
37542
  class Help {
37564
37543
  constructor() {
37565
37544
  this.helpWidth = undefined;
37545
+ this.minWidthToWrap = 40;
37566
37546
  this.sortSubcommands = false;
37567
37547
  this.sortOptions = false;
37568
37548
  this.showGlobalOptions = false;
37569
37549
  }
37550
+ prepareContext(contextOptions) {
37551
+ this.helpWidth = this.helpWidth ?? contextOptions.helpWidth ?? 80;
37552
+ }
37570
37553
  visibleCommands(cmd) {
37571
37554
  const visibleCommands = cmd.commands.filter((cmd2) => !cmd2._hidden);
37572
- if (cmd._hasImplicitHelpCommand()) {
37573
- const [, helpName, helpArgs] = cmd._helpCommandnameAndArgs.match(/([^ ]+) *(.*)/);
37574
- const helpCommand = cmd.createCommand(helpName).helpOption(false);
37575
- helpCommand.description(cmd._helpCommandDescription);
37576
- if (helpArgs)
37577
- helpCommand.arguments(helpArgs);
37555
+ const helpCommand = cmd._getHelpCommand();
37556
+ if (helpCommand && !helpCommand._hidden) {
37578
37557
  visibleCommands.push(helpCommand);
37579
37558
  }
37580
37559
  if (this.sortSubcommands) {
@@ -37592,18 +37571,17 @@ var require_help = __commonJS((exports) => {
37592
37571
  }
37593
37572
  visibleOptions(cmd) {
37594
37573
  const visibleOptions = cmd.options.filter((option) => !option.hidden);
37595
- const showShortHelpFlag = cmd._hasHelpOption && cmd._helpShortFlag && !cmd._findOption(cmd._helpShortFlag);
37596
- const showLongHelpFlag = cmd._hasHelpOption && !cmd._findOption(cmd._helpLongFlag);
37597
- if (showShortHelpFlag || showLongHelpFlag) {
37598
- let helpOption;
37599
- if (!showShortHelpFlag) {
37600
- helpOption = cmd.createOption(cmd._helpLongFlag, cmd._helpDescription);
37601
- } else if (!showLongHelpFlag) {
37602
- helpOption = cmd.createOption(cmd._helpShortFlag, cmd._helpDescription);
37603
- } else {
37604
- helpOption = cmd.createOption(cmd._helpFlags, cmd._helpDescription);
37574
+ const helpOption = cmd._getHelpOption();
37575
+ if (helpOption && !helpOption.hidden) {
37576
+ const removeShort = helpOption.short && cmd._findOption(helpOption.short);
37577
+ const removeLong = helpOption.long && cmd._findOption(helpOption.long);
37578
+ if (!removeShort && !removeLong) {
37579
+ visibleOptions.push(helpOption);
37580
+ } else if (helpOption.long && !removeLong) {
37581
+ visibleOptions.push(cmd.createOption(helpOption.long, helpOption.description));
37582
+ } else if (helpOption.short && !removeShort) {
37583
+ visibleOptions.push(cmd.createOption(helpOption.short, helpOption.description));
37605
37584
  }
37606
- visibleOptions.push(helpOption);
37607
37585
  }
37608
37586
  if (this.sortOptions) {
37609
37587
  visibleOptions.sort(this.compareOptions);
@@ -37614,8 +37592,8 @@ var require_help = __commonJS((exports) => {
37614
37592
  if (!this.showGlobalOptions)
37615
37593
  return [];
37616
37594
  const globalOptions = [];
37617
- for (let parentCmd = cmd.parent;parentCmd; parentCmd = parentCmd.parent) {
37618
- const visibleOptions = parentCmd.options.filter((option) => !option.hidden);
37595
+ for (let ancestorCmd = cmd.parent;ancestorCmd; ancestorCmd = ancestorCmd.parent) {
37596
+ const visibleOptions = ancestorCmd.options.filter((option) => !option.hidden);
37619
37597
  globalOptions.push(...visibleOptions);
37620
37598
  }
37621
37599
  if (this.sortOptions) {
@@ -37625,17 +37603,17 @@ var require_help = __commonJS((exports) => {
37625
37603
  }
37626
37604
  visibleArguments(cmd) {
37627
37605
  if (cmd._argsDescription) {
37628
- cmd._args.forEach((argument) => {
37606
+ cmd.registeredArguments.forEach((argument) => {
37629
37607
  argument.description = argument.description || cmd._argsDescription[argument.name()] || "";
37630
37608
  });
37631
37609
  }
37632
- if (cmd._args.find((argument) => argument.description)) {
37633
- return cmd._args;
37610
+ if (cmd.registeredArguments.find((argument) => argument.description)) {
37611
+ return cmd.registeredArguments;
37634
37612
  }
37635
37613
  return [];
37636
37614
  }
37637
37615
  subcommandTerm(cmd) {
37638
- const args = cmd._args.map((arg) => humanReadableArgName(arg)).join(" ");
37616
+ const args = cmd.registeredArguments.map((arg) => humanReadableArgName(arg)).join(" ");
37639
37617
  return cmd._name + (cmd._aliases[0] ? "|" + cmd._aliases[0] : "") + (cmd.options.length ? " [options]" : "") + (args ? " " + args : "");
37640
37618
  }
37641
37619
  optionTerm(option) {
@@ -37646,22 +37624,22 @@ var require_help = __commonJS((exports) => {
37646
37624
  }
37647
37625
  longestSubcommandTermLength(cmd, helper) {
37648
37626
  return helper.visibleCommands(cmd).reduce((max, command) => {
37649
- return Math.max(max, helper.subcommandTerm(command).length);
37627
+ return Math.max(max, this.displayWidth(helper.styleSubcommandTerm(helper.subcommandTerm(command))));
37650
37628
  }, 0);
37651
37629
  }
37652
37630
  longestOptionTermLength(cmd, helper) {
37653
37631
  return helper.visibleOptions(cmd).reduce((max, option) => {
37654
- return Math.max(max, helper.optionTerm(option).length);
37632
+ return Math.max(max, this.displayWidth(helper.styleOptionTerm(helper.optionTerm(option))));
37655
37633
  }, 0);
37656
37634
  }
37657
37635
  longestGlobalOptionTermLength(cmd, helper) {
37658
37636
  return helper.visibleGlobalOptions(cmd).reduce((max, option) => {
37659
- return Math.max(max, helper.optionTerm(option).length);
37637
+ return Math.max(max, this.displayWidth(helper.styleOptionTerm(helper.optionTerm(option))));
37660
37638
  }, 0);
37661
37639
  }
37662
37640
  longestArgumentTermLength(cmd, helper) {
37663
37641
  return helper.visibleArguments(cmd).reduce((max, argument) => {
37664
- return Math.max(max, helper.argumentTerm(argument).length);
37642
+ return Math.max(max, this.displayWidth(helper.styleArgumentTerm(helper.argumentTerm(argument))));
37665
37643
  }, 0);
37666
37644
  }
37667
37645
  commandUsage(cmd) {
@@ -37669,11 +37647,11 @@ var require_help = __commonJS((exports) => {
37669
37647
  if (cmd._aliases[0]) {
37670
37648
  cmdName = cmdName + "|" + cmd._aliases[0];
37671
37649
  }
37672
- let parentCmdNames = "";
37673
- for (let parentCmd = cmd.parent;parentCmd; parentCmd = parentCmd.parent) {
37674
- parentCmdNames = parentCmd.name() + " " + parentCmdNames;
37650
+ let ancestorCmdNames = "";
37651
+ for (let ancestorCmd = cmd.parent;ancestorCmd; ancestorCmd = ancestorCmd.parent) {
37652
+ ancestorCmdNames = ancestorCmd.name() + " " + ancestorCmdNames;
37675
37653
  }
37676
- return parentCmdNames + cmdName + " " + cmd.usage();
37654
+ return ancestorCmdNames + cmdName + " " + cmd.usage();
37677
37655
  }
37678
37656
  commandDescription(cmd) {
37679
37657
  return cmd.description();
@@ -37712,95 +37690,199 @@ var require_help = __commonJS((exports) => {
37712
37690
  extraInfo.push(`default: ${argument.defaultValueDescription || JSON.stringify(argument.defaultValue)}`);
37713
37691
  }
37714
37692
  if (extraInfo.length > 0) {
37715
- const extraDescripton = `(${extraInfo.join(", ")})`;
37693
+ const extraDescription = `(${extraInfo.join(", ")})`;
37716
37694
  if (argument.description) {
37717
- return `${argument.description} ${extraDescripton}`;
37695
+ return `${argument.description} ${extraDescription}`;
37718
37696
  }
37719
- return extraDescripton;
37697
+ return extraDescription;
37720
37698
  }
37721
37699
  return argument.description;
37722
37700
  }
37723
37701
  formatHelp(cmd, helper) {
37724
37702
  const termWidth = helper.padWidth(cmd, helper);
37725
- const helpWidth = helper.helpWidth || 80;
37726
- const itemIndentWidth = 2;
37727
- const itemSeparatorWidth = 2;
37728
- function formatItem(term, description) {
37729
- if (description) {
37730
- const fullText = `${term.padEnd(termWidth + itemSeparatorWidth)}${description}`;
37731
- return helper.wrap(fullText, helpWidth - itemIndentWidth, termWidth + itemSeparatorWidth);
37732
- }
37733
- return term;
37703
+ const helpWidth = helper.helpWidth ?? 80;
37704
+ function callFormatItem(term, description) {
37705
+ return helper.formatItem(term, termWidth, description, helper);
37734
37706
  }
37735
- function formatList(textArray) {
37736
- return textArray.join(`
37737
- `).replace(/^/gm, " ".repeat(itemIndentWidth));
37738
- }
37739
- let output = [`Usage: ${helper.commandUsage(cmd)}`, ""];
37707
+ let output = [
37708
+ `${helper.styleTitle("Usage:")} ${helper.styleUsage(helper.commandUsage(cmd))}`,
37709
+ ""
37710
+ ];
37740
37711
  const commandDescription = helper.commandDescription(cmd);
37741
37712
  if (commandDescription.length > 0) {
37742
- output = output.concat([helper.wrap(commandDescription, helpWidth, 0), ""]);
37713
+ output = output.concat([
37714
+ helper.boxWrap(helper.styleCommandDescription(commandDescription), helpWidth),
37715
+ ""
37716
+ ]);
37743
37717
  }
37744
37718
  const argumentList = helper.visibleArguments(cmd).map((argument) => {
37745
- return formatItem(helper.argumentTerm(argument), helper.argumentDescription(argument));
37719
+ return callFormatItem(helper.styleArgumentTerm(helper.argumentTerm(argument)), helper.styleArgumentDescription(helper.argumentDescription(argument)));
37746
37720
  });
37747
37721
  if (argumentList.length > 0) {
37748
- output = output.concat(["Arguments:", formatList(argumentList), ""]);
37722
+ output = output.concat([
37723
+ helper.styleTitle("Arguments:"),
37724
+ ...argumentList,
37725
+ ""
37726
+ ]);
37749
37727
  }
37750
37728
  const optionList = helper.visibleOptions(cmd).map((option) => {
37751
- return formatItem(helper.optionTerm(option), helper.optionDescription(option));
37729
+ return callFormatItem(helper.styleOptionTerm(helper.optionTerm(option)), helper.styleOptionDescription(helper.optionDescription(option)));
37752
37730
  });
37753
37731
  if (optionList.length > 0) {
37754
- output = output.concat(["Options:", formatList(optionList), ""]);
37732
+ output = output.concat([
37733
+ helper.styleTitle("Options:"),
37734
+ ...optionList,
37735
+ ""
37736
+ ]);
37755
37737
  }
37756
- if (this.showGlobalOptions) {
37738
+ if (helper.showGlobalOptions) {
37757
37739
  const globalOptionList = helper.visibleGlobalOptions(cmd).map((option) => {
37758
- return formatItem(helper.optionTerm(option), helper.optionDescription(option));
37740
+ return callFormatItem(helper.styleOptionTerm(helper.optionTerm(option)), helper.styleOptionDescription(helper.optionDescription(option)));
37759
37741
  });
37760
37742
  if (globalOptionList.length > 0) {
37761
- output = output.concat(["Global Options:", formatList(globalOptionList), ""]);
37743
+ output = output.concat([
37744
+ helper.styleTitle("Global Options:"),
37745
+ ...globalOptionList,
37746
+ ""
37747
+ ]);
37762
37748
  }
37763
37749
  }
37764
37750
  const commandList = helper.visibleCommands(cmd).map((cmd2) => {
37765
- return formatItem(helper.subcommandTerm(cmd2), helper.subcommandDescription(cmd2));
37751
+ return callFormatItem(helper.styleSubcommandTerm(helper.subcommandTerm(cmd2)), helper.styleSubcommandDescription(helper.subcommandDescription(cmd2)));
37766
37752
  });
37767
37753
  if (commandList.length > 0) {
37768
- output = output.concat(["Commands:", formatList(commandList), ""]);
37754
+ output = output.concat([
37755
+ helper.styleTitle("Commands:"),
37756
+ ...commandList,
37757
+ ""
37758
+ ]);
37769
37759
  }
37770
37760
  return output.join(`
37771
37761
  `);
37772
37762
  }
37763
+ displayWidth(str) {
37764
+ return stripColor(str).length;
37765
+ }
37766
+ styleTitle(str) {
37767
+ return str;
37768
+ }
37769
+ styleUsage(str) {
37770
+ return str.split(" ").map((word) => {
37771
+ if (word === "[options]")
37772
+ return this.styleOptionText(word);
37773
+ if (word === "[command]")
37774
+ return this.styleSubcommandText(word);
37775
+ if (word[0] === "[" || word[0] === "<")
37776
+ return this.styleArgumentText(word);
37777
+ return this.styleCommandText(word);
37778
+ }).join(" ");
37779
+ }
37780
+ styleCommandDescription(str) {
37781
+ return this.styleDescriptionText(str);
37782
+ }
37783
+ styleOptionDescription(str) {
37784
+ return this.styleDescriptionText(str);
37785
+ }
37786
+ styleSubcommandDescription(str) {
37787
+ return this.styleDescriptionText(str);
37788
+ }
37789
+ styleArgumentDescription(str) {
37790
+ return this.styleDescriptionText(str);
37791
+ }
37792
+ styleDescriptionText(str) {
37793
+ return str;
37794
+ }
37795
+ styleOptionTerm(str) {
37796
+ return this.styleOptionText(str);
37797
+ }
37798
+ styleSubcommandTerm(str) {
37799
+ return str.split(" ").map((word) => {
37800
+ if (word === "[options]")
37801
+ return this.styleOptionText(word);
37802
+ if (word[0] === "[" || word[0] === "<")
37803
+ return this.styleArgumentText(word);
37804
+ return this.styleSubcommandText(word);
37805
+ }).join(" ");
37806
+ }
37807
+ styleArgumentTerm(str) {
37808
+ return this.styleArgumentText(str);
37809
+ }
37810
+ styleOptionText(str) {
37811
+ return str;
37812
+ }
37813
+ styleArgumentText(str) {
37814
+ return str;
37815
+ }
37816
+ styleSubcommandText(str) {
37817
+ return str;
37818
+ }
37819
+ styleCommandText(str) {
37820
+ return str;
37821
+ }
37773
37822
  padWidth(cmd, helper) {
37774
37823
  return Math.max(helper.longestOptionTermLength(cmd, helper), helper.longestGlobalOptionTermLength(cmd, helper), helper.longestSubcommandTermLength(cmd, helper), helper.longestArgumentTermLength(cmd, helper));
37775
37824
  }
37776
- wrap(str, width, indent2, minColumnWidth = 40) {
37777
- const indents = " \\f\\t\\v   -    \uFEFF";
37778
- const manualIndent = new RegExp(`[\\n][${indents}]+`);
37779
- if (str.match(manualIndent))
37780
- return str;
37781
- const columnWidth = width - indent2;
37782
- if (columnWidth < minColumnWidth)
37825
+ preformatted(str) {
37826
+ return /\n[^\S\r\n]/.test(str);
37827
+ }
37828
+ formatItem(term, termWidth, description, helper) {
37829
+ const itemIndent = 2;
37830
+ const itemIndentStr = " ".repeat(itemIndent);
37831
+ if (!description)
37832
+ return itemIndentStr + term;
37833
+ const paddedTerm = term.padEnd(termWidth + term.length - helper.displayWidth(term));
37834
+ const spacerWidth = 2;
37835
+ const helpWidth = this.helpWidth ?? 80;
37836
+ const remainingWidth = helpWidth - termWidth - spacerWidth - itemIndent;
37837
+ let formattedDescription;
37838
+ if (remainingWidth < this.minWidthToWrap || helper.preformatted(description)) {
37839
+ formattedDescription = description;
37840
+ } else {
37841
+ const wrappedDescription = helper.boxWrap(description, remainingWidth);
37842
+ formattedDescription = wrappedDescription.replace(/\n/g, `
37843
+ ` + " ".repeat(termWidth + spacerWidth));
37844
+ }
37845
+ return itemIndentStr + paddedTerm + " ".repeat(spacerWidth) + formattedDescription.replace(/\n/g, `
37846
+ ${itemIndentStr}`);
37847
+ }
37848
+ boxWrap(str, width) {
37849
+ if (width < this.minWidthToWrap)
37783
37850
  return str;
37784
- const leadingStr = str.slice(0, indent2);
37785
- const columnText = str.slice(indent2).replace(`\r
37786
- `, `
37787
- `);
37788
- const indentString = " ".repeat(indent2);
37789
- const zeroWidthSpace = "​";
37790
- const breaks = `\\s${zeroWidthSpace}`;
37791
- const regex = new RegExp(`
37792
- |.{1,${columnWidth - 1}}([${breaks}]|$)|[^${breaks}]+?([${breaks}]|$)`, "g");
37793
- const lines = columnText.match(regex) || [];
37794
- return leadingStr + lines.map((line, i) => {
37795
- if (line === `
37796
- `)
37797
- return "";
37798
- return (i > 0 ? indentString : "") + line.trimEnd();
37799
- }).join(`
37851
+ const rawLines = str.split(/\r\n|\n/);
37852
+ const chunkPattern = /[\s]*[^\s]+/g;
37853
+ const wrappedLines = [];
37854
+ rawLines.forEach((line) => {
37855
+ const chunks = line.match(chunkPattern);
37856
+ if (chunks === null) {
37857
+ wrappedLines.push("");
37858
+ return;
37859
+ }
37860
+ let sumChunks = [chunks.shift()];
37861
+ let sumWidth = this.displayWidth(sumChunks[0]);
37862
+ chunks.forEach((chunk) => {
37863
+ const visibleWidth = this.displayWidth(chunk);
37864
+ if (sumWidth + visibleWidth <= width) {
37865
+ sumChunks.push(chunk);
37866
+ sumWidth += visibleWidth;
37867
+ return;
37868
+ }
37869
+ wrappedLines.push(sumChunks.join(""));
37870
+ const nextChunk = chunk.trimStart();
37871
+ sumChunks = [nextChunk];
37872
+ sumWidth = this.displayWidth(nextChunk);
37873
+ });
37874
+ wrappedLines.push(sumChunks.join(""));
37875
+ });
37876
+ return wrappedLines.join(`
37800
37877
  `);
37801
37878
  }
37802
37879
  }
37880
+ function stripColor(str) {
37881
+ const sgrPattern = /\x1b\[\d*(;\d*)*m/g;
37882
+ return str.replace(sgrPattern, "");
37883
+ }
37803
37884
  exports.Help = Help;
37885
+ exports.stripColor = stripColor;
37804
37886
  });
37805
37887
 
37806
37888
  // ../../node_modules/commander/lib/option.js
@@ -37895,7 +37977,10 @@ var require_option = __commonJS((exports) => {
37895
37977
  return this.short.replace(/^-/, "");
37896
37978
  }
37897
37979
  attributeName() {
37898
- return camelcase(this.name().replace(/^no-/, ""));
37980
+ if (this.negate) {
37981
+ return camelcase(this.name().replace(/^no-/, ""));
37982
+ }
37983
+ return camelcase(this.name());
37899
37984
  }
37900
37985
  is(arg) {
37901
37986
  return this.short === arg || this.long === arg;
@@ -37940,18 +38025,41 @@ var require_option = __commonJS((exports) => {
37940
38025
  function splitOptionFlags(flags) {
37941
38026
  let shortFlag;
37942
38027
  let longFlag;
37943
- const flagParts = flags.split(/[ |,]+/);
37944
- if (flagParts.length > 1 && !/^[[<]/.test(flagParts[1]))
38028
+ const shortFlagExp = /^-[^-]$/;
38029
+ const longFlagExp = /^--[^-]/;
38030
+ const flagParts = flags.split(/[ |,]+/).concat("guard");
38031
+ if (shortFlagExp.test(flagParts[0]))
38032
+ shortFlag = flagParts.shift();
38033
+ if (longFlagExp.test(flagParts[0]))
38034
+ longFlag = flagParts.shift();
38035
+ if (!shortFlag && shortFlagExp.test(flagParts[0]))
37945
38036
  shortFlag = flagParts.shift();
37946
- longFlag = flagParts.shift();
37947
- if (!shortFlag && /^-[^-]$/.test(longFlag)) {
38037
+ if (!shortFlag && longFlagExp.test(flagParts[0])) {
37948
38038
  shortFlag = longFlag;
37949
- longFlag = undefined;
37950
- }
38039
+ longFlag = flagParts.shift();
38040
+ }
38041
+ if (flagParts[0].startsWith("-")) {
38042
+ const unsupportedFlag = flagParts[0];
38043
+ const baseError = `option creation failed due to '${unsupportedFlag}' in option flags '${flags}'`;
38044
+ if (/^-[^-][^-]/.test(unsupportedFlag))
38045
+ throw new Error(`${baseError}
38046
+ - a short flag is a single dash and a single character
38047
+ - either use a single dash and a single character (for a short flag)
38048
+ - or use a double dash for a long option (and can have two, like '--ws, --workspace')`);
38049
+ if (shortFlagExp.test(unsupportedFlag))
38050
+ throw new Error(`${baseError}
38051
+ - too many short flags`);
38052
+ if (longFlagExp.test(unsupportedFlag))
38053
+ throw new Error(`${baseError}
38054
+ - too many long flags`);
38055
+ throw new Error(`${baseError}
38056
+ - unrecognised flag format`);
38057
+ }
38058
+ if (shortFlag === undefined && longFlag === undefined)
38059
+ throw new Error(`option creation failed due to no flags found in '${flags}'.`);
37951
38060
  return { shortFlag, longFlag };
37952
38061
  }
37953
38062
  exports.Option = Option;
37954
- exports.splitOptionFlags = splitOptionFlags;
37955
38063
  exports.DualOptions = DualOptions;
37956
38064
  });
37957
38065
 
@@ -38030,15 +38138,15 @@ var require_suggestSimilar = __commonJS((exports) => {
38030
38138
 
38031
38139
  // ../../node_modules/commander/lib/command.js
38032
38140
  var require_command = __commonJS((exports) => {
38033
- var EventEmitter2 = __require("events").EventEmitter;
38034
- var childProcess = __require("child_process");
38035
- var path2 = __require("path");
38036
- var fs = __require("fs");
38037
- var process3 = __require("process");
38141
+ var EventEmitter2 = __require("node:events").EventEmitter;
38142
+ var childProcess = __require("node:child_process");
38143
+ var path2 = __require("node:path");
38144
+ var fs = __require("node:fs");
38145
+ var process3 = __require("node:process");
38038
38146
  var { Argument, humanReadableArgName } = require_argument();
38039
38147
  var { CommanderError } = require_error3();
38040
- var { Help } = require_help();
38041
- var { Option, splitOptionFlags, DualOptions } = require_option();
38148
+ var { Help, stripColor } = require_help();
38149
+ var { Option, DualOptions } = require_option();
38042
38150
  var { suggestSimilar } = require_suggestSimilar();
38043
38151
 
38044
38152
  class Command extends EventEmitter2 {
@@ -38048,8 +38156,9 @@ var require_command = __commonJS((exports) => {
38048
38156
  this.options = [];
38049
38157
  this.parent = null;
38050
38158
  this._allowUnknownOption = false;
38051
- this._allowExcessArguments = true;
38052
- this._args = [];
38159
+ this._allowExcessArguments = false;
38160
+ this.registeredArguments = [];
38161
+ this._args = this.registeredArguments;
38053
38162
  this.args = [];
38054
38163
  this.rawArgs = [];
38055
38164
  this.processedArgs = [];
@@ -38074,35 +38183,27 @@ var require_command = __commonJS((exports) => {
38074
38183
  this._lifeCycleHooks = {};
38075
38184
  this._showHelpAfterError = false;
38076
38185
  this._showSuggestionAfterError = true;
38186
+ this._savedState = null;
38077
38187
  this._outputConfiguration = {
38078
38188
  writeOut: (str) => process3.stdout.write(str),
38079
38189
  writeErr: (str) => process3.stderr.write(str),
38190
+ outputError: (str, write) => write(str),
38080
38191
  getOutHelpWidth: () => process3.stdout.isTTY ? process3.stdout.columns : undefined,
38081
38192
  getErrHelpWidth: () => process3.stderr.isTTY ? process3.stderr.columns : undefined,
38082
- outputError: (str, write) => write(str)
38193
+ getOutHasColors: () => useColor() ?? (process3.stdout.isTTY && process3.stdout.hasColors?.()),
38194
+ getErrHasColors: () => useColor() ?? (process3.stderr.isTTY && process3.stderr.hasColors?.()),
38195
+ stripColor: (str) => stripColor(str)
38083
38196
  };
38084
38197
  this._hidden = false;
38085
- this._hasHelpOption = true;
38086
- this._helpFlags = "-h, --help";
38087
- this._helpDescription = "display help for command";
38088
- this._helpShortFlag = "-h";
38089
- this._helpLongFlag = "--help";
38198
+ this._helpOption = undefined;
38090
38199
  this._addImplicitHelpCommand = undefined;
38091
- this._helpCommandName = "help";
38092
- this._helpCommandnameAndArgs = "help [command]";
38093
- this._helpCommandDescription = "display help for command";
38200
+ this._helpCommand = undefined;
38094
38201
  this._helpConfiguration = {};
38095
38202
  }
38096
38203
  copyInheritedSettings(sourceCommand) {
38097
38204
  this._outputConfiguration = sourceCommand._outputConfiguration;
38098
- this._hasHelpOption = sourceCommand._hasHelpOption;
38099
- this._helpFlags = sourceCommand._helpFlags;
38100
- this._helpDescription = sourceCommand._helpDescription;
38101
- this._helpShortFlag = sourceCommand._helpShortFlag;
38102
- this._helpLongFlag = sourceCommand._helpLongFlag;
38103
- this._helpCommandName = sourceCommand._helpCommandName;
38104
- this._helpCommandnameAndArgs = sourceCommand._helpCommandnameAndArgs;
38105
- this._helpCommandDescription = sourceCommand._helpCommandDescription;
38205
+ this._helpOption = sourceCommand._helpOption;
38206
+ this._helpCommand = sourceCommand._helpCommand;
38106
38207
  this._helpConfiguration = sourceCommand._helpConfiguration;
38107
38208
  this._exitCallback = sourceCommand._exitCallback;
38108
38209
  this._storeOptionsAsProperties = sourceCommand._storeOptionsAsProperties;
@@ -38113,6 +38214,13 @@ var require_command = __commonJS((exports) => {
38113
38214
  this._showSuggestionAfterError = sourceCommand._showSuggestionAfterError;
38114
38215
  return this;
38115
38216
  }
38217
+ _getCommandAndAncestors() {
38218
+ const result = [];
38219
+ for (let command = this;command; command = command.parent) {
38220
+ result.push(command);
38221
+ }
38222
+ return result;
38223
+ }
38116
38224
  command(nameAndArgs, actionOptsOrExecDesc, execOpts) {
38117
38225
  let desc = actionOptsOrExecDesc;
38118
38226
  let opts = execOpts;
@@ -38133,7 +38241,7 @@ var require_command = __commonJS((exports) => {
38133
38241
  cmd._executableFile = opts.executableFile || null;
38134
38242
  if (args)
38135
38243
  cmd.arguments(args);
38136
- this.commands.push(cmd);
38244
+ this._registerCommand(cmd);
38137
38245
  cmd.parent = this;
38138
38246
  cmd.copyInheritedSettings(this);
38139
38247
  if (desc)
@@ -38178,8 +38286,9 @@ var require_command = __commonJS((exports) => {
38178
38286
  this._defaultCommandName = cmd._name;
38179
38287
  if (opts.noHelp || opts.hidden)
38180
38288
  cmd._hidden = true;
38181
- this.commands.push(cmd);
38289
+ this._registerCommand(cmd);
38182
38290
  cmd.parent = this;
38291
+ cmd._checkForBrokenPassThrough();
38183
38292
  return this;
38184
38293
  }
38185
38294
  createArgument(name, description) {
@@ -38196,40 +38305,58 @@ var require_command = __commonJS((exports) => {
38196
38305
  return this;
38197
38306
  }
38198
38307
  arguments(names) {
38199
- names.split(/ +/).forEach((detail) => {
38308
+ names.trim().split(/ +/).forEach((detail) => {
38200
38309
  this.argument(detail);
38201
38310
  });
38202
38311
  return this;
38203
38312
  }
38204
38313
  addArgument(argument) {
38205
- const previousArgument = this._args.slice(-1)[0];
38314
+ const previousArgument = this.registeredArguments.slice(-1)[0];
38206
38315
  if (previousArgument && previousArgument.variadic) {
38207
38316
  throw new Error(`only the last argument can be variadic '${previousArgument.name()}'`);
38208
38317
  }
38209
38318
  if (argument.required && argument.defaultValue !== undefined && argument.parseArg === undefined) {
38210
38319
  throw new Error(`a default value for a required argument is never used: '${argument.name()}'`);
38211
38320
  }
38212
- this._args.push(argument);
38321
+ this.registeredArguments.push(argument);
38213
38322
  return this;
38214
38323
  }
38215
- addHelpCommand(enableOrNameAndArgs, description) {
38216
- if (enableOrNameAndArgs === false) {
38217
- this._addImplicitHelpCommand = false;
38218
- } else {
38219
- this._addImplicitHelpCommand = true;
38220
- if (typeof enableOrNameAndArgs === "string") {
38221
- this._helpCommandName = enableOrNameAndArgs.split(" ")[0];
38222
- this._helpCommandnameAndArgs = enableOrNameAndArgs;
38223
- }
38224
- this._helpCommandDescription = description || this._helpCommandDescription;
38324
+ helpCommand(enableOrNameAndArgs, description) {
38325
+ if (typeof enableOrNameAndArgs === "boolean") {
38326
+ this._addImplicitHelpCommand = enableOrNameAndArgs;
38327
+ return this;
38328
+ }
38329
+ enableOrNameAndArgs = enableOrNameAndArgs ?? "help [command]";
38330
+ const [, helpName, helpArgs] = enableOrNameAndArgs.match(/([^ ]+) *(.*)/);
38331
+ const helpDescription = description ?? "display help for command";
38332
+ const helpCommand = this.createCommand(helpName);
38333
+ helpCommand.helpOption(false);
38334
+ if (helpArgs)
38335
+ helpCommand.arguments(helpArgs);
38336
+ if (helpDescription)
38337
+ helpCommand.description(helpDescription);
38338
+ this._addImplicitHelpCommand = true;
38339
+ this._helpCommand = helpCommand;
38340
+ return this;
38341
+ }
38342
+ addHelpCommand(helpCommand, deprecatedDescription) {
38343
+ if (typeof helpCommand !== "object") {
38344
+ this.helpCommand(helpCommand, deprecatedDescription);
38345
+ return this;
38225
38346
  }
38347
+ this._addImplicitHelpCommand = true;
38348
+ this._helpCommand = helpCommand;
38226
38349
  return this;
38227
38350
  }
38228
- _hasImplicitHelpCommand() {
38229
- if (this._addImplicitHelpCommand === undefined) {
38230
- return this.commands.length && !this._actionHandler && !this._findCommand("help");
38351
+ _getHelpCommand() {
38352
+ const hasImplicitHelpCommand = this._addImplicitHelpCommand ?? (this.commands.length && !this._actionHandler && !this._findCommand("help"));
38353
+ if (hasImplicitHelpCommand) {
38354
+ if (this._helpCommand === undefined) {
38355
+ this.helpCommand(undefined, undefined);
38356
+ }
38357
+ return this._helpCommand;
38231
38358
  }
38232
- return this._addImplicitHelpCommand;
38359
+ return null;
38233
38360
  }
38234
38361
  hook(event, listener) {
38235
38362
  const allowedValues = ["preSubcommand", "preAction", "postAction"];
@@ -38251,8 +38378,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
38251
38378
  this._exitCallback = (err) => {
38252
38379
  if (err.code !== "commander.executeSubCommandAsync") {
38253
38380
  throw err;
38254
- } else {
38255
- }
38381
+ } else {}
38256
38382
  };
38257
38383
  }
38258
38384
  return this;
@@ -38265,7 +38391,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
38265
38391
  }
38266
38392
  action(fn) {
38267
38393
  const listener = (args) => {
38268
- const expectedArgsCount = this._args.length;
38394
+ const expectedArgsCount = this.registeredArguments.length;
38269
38395
  const actionArgs = args.slice(0, expectedArgsCount);
38270
38396
  if (this._storeOptionsAsProperties) {
38271
38397
  actionArgs[expectedArgsCount] = this;
@@ -38281,7 +38407,40 @@ Expecting one of '${allowedValues.join("', '")}'`);
38281
38407
  createOption(flags, description) {
38282
38408
  return new Option(flags, description);
38283
38409
  }
38410
+ _callParseArg(target, value, previous, invalidArgumentMessage) {
38411
+ try {
38412
+ return target.parseArg(value, previous);
38413
+ } catch (err) {
38414
+ if (err.code === "commander.invalidArgument") {
38415
+ const message = `${invalidArgumentMessage} ${err.message}`;
38416
+ this.error(message, { exitCode: err.exitCode, code: err.code });
38417
+ }
38418
+ throw err;
38419
+ }
38420
+ }
38421
+ _registerOption(option) {
38422
+ const matchingOption = option.short && this._findOption(option.short) || option.long && this._findOption(option.long);
38423
+ if (matchingOption) {
38424
+ const matchingFlag = option.long && this._findOption(option.long) ? option.long : option.short;
38425
+ throw new Error(`Cannot add option '${option.flags}'${this._name && ` to command '${this._name}'`} due to conflicting flag '${matchingFlag}'
38426
+ - already used by option '${matchingOption.flags}'`);
38427
+ }
38428
+ this.options.push(option);
38429
+ }
38430
+ _registerCommand(command) {
38431
+ const knownBy = (cmd) => {
38432
+ return [cmd.name()].concat(cmd.aliases());
38433
+ };
38434
+ const alreadyUsed = knownBy(command).find((name) => this._findCommand(name));
38435
+ if (alreadyUsed) {
38436
+ const existingCmd = knownBy(this._findCommand(alreadyUsed)).join("|");
38437
+ const newCmd = knownBy(command).join("|");
38438
+ throw new Error(`cannot add command '${newCmd}' as already have command '${existingCmd}'`);
38439
+ }
38440
+ this.commands.push(command);
38441
+ }
38284
38442
  addOption(option) {
38443
+ this._registerOption(option);
38285
38444
  const oname = option.name();
38286
38445
  const name = option.attributeName();
38287
38446
  if (option.negate) {
@@ -38292,22 +38451,13 @@ Expecting one of '${allowedValues.join("', '")}'`);
38292
38451
  } else if (option.defaultValue !== undefined) {
38293
38452
  this.setOptionValueWithSource(name, option.defaultValue, "default");
38294
38453
  }
38295
- this.options.push(option);
38296
38454
  const handleOptionValue = (val, invalidValueMessage, valueSource) => {
38297
38455
  if (val == null && option.presetArg !== undefined) {
38298
38456
  val = option.presetArg;
38299
38457
  }
38300
38458
  const oldValue = this.getOptionValue(name);
38301
38459
  if (val !== null && option.parseArg) {
38302
- try {
38303
- val = option.parseArg(val, oldValue);
38304
- } catch (err) {
38305
- if (err.code === "commander.invalidArgument") {
38306
- const message = `${invalidValueMessage} ${err.message}`;
38307
- this.error(message, { exitCode: err.exitCode, code: err.code });
38308
- }
38309
- throw err;
38310
- }
38460
+ val = this._callParseArg(option, val, oldValue, invalidValueMessage);
38311
38461
  } else if (val !== null && option.variadic) {
38312
38462
  val = option._concatValue(val, oldValue);
38313
38463
  }
@@ -38354,11 +38504,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
38354
38504
  }
38355
38505
  return this.addOption(option);
38356
38506
  }
38357
- option(flags, description, fn, defaultValue) {
38358
- return this._optionEx({}, flags, description, fn, defaultValue);
38507
+ option(flags, description, parseArg, defaultValue) {
38508
+ return this._optionEx({}, flags, description, parseArg, defaultValue);
38359
38509
  }
38360
- requiredOption(flags, description, fn, defaultValue) {
38361
- return this._optionEx({ mandatory: true }, flags, description, fn, defaultValue);
38510
+ requiredOption(flags, description, parseArg, defaultValue) {
38511
+ return this._optionEx({ mandatory: true }, flags, description, parseArg, defaultValue);
38362
38512
  }
38363
38513
  combineFlagAndOptionalValue(combine = true) {
38364
38514
  this._combineFlagAndOptionalValue = !!combine;
@@ -38378,16 +38528,22 @@ Expecting one of '${allowedValues.join("', '")}'`);
38378
38528
  }
38379
38529
  passThroughOptions(passThrough = true) {
38380
38530
  this._passThroughOptions = !!passThrough;
38381
- if (!!this.parent && passThrough && !this.parent._enablePositionalOptions) {
38382
- throw new Error("passThroughOptions can not be used without turning on enablePositionalOptions for parent command(s)");
38383
- }
38531
+ this._checkForBrokenPassThrough();
38384
38532
  return this;
38385
38533
  }
38534
+ _checkForBrokenPassThrough() {
38535
+ if (this.parent && this._passThroughOptions && !this.parent._enablePositionalOptions) {
38536
+ throw new Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`);
38537
+ }
38538
+ }
38386
38539
  storeOptionsAsProperties(storeAsProperties = true) {
38387
- this._storeOptionsAsProperties = !!storeAsProperties;
38388
38540
  if (this.options.length) {
38389
38541
  throw new Error("call .storeOptionsAsProperties() before adding options");
38390
38542
  }
38543
+ if (Object.keys(this._optionValues).length) {
38544
+ throw new Error("call .storeOptionsAsProperties() before setting option values");
38545
+ }
38546
+ this._storeOptionsAsProperties = !!storeAsProperties;
38391
38547
  return this;
38392
38548
  }
38393
38549
  getOptionValue(key) {
@@ -38413,7 +38569,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
38413
38569
  }
38414
38570
  getOptionValueSourceWithGlobals(key) {
38415
38571
  let source;
38416
- getCommandAndParents(this).forEach((cmd) => {
38572
+ this._getCommandAndAncestors().forEach((cmd) => {
38417
38573
  if (cmd.getOptionValueSource(key) !== undefined) {
38418
38574
  source = cmd.getOptionValueSource(key);
38419
38575
  }
@@ -38425,11 +38581,17 @@ Expecting one of '${allowedValues.join("', '")}'`);
38425
38581
  throw new Error("first parameter to parse must be array or undefined");
38426
38582
  }
38427
38583
  parseOptions = parseOptions || {};
38428
- if (argv === undefined) {
38429
- argv = process3.argv;
38430
- if (process3.versions && process3.versions.electron) {
38584
+ if (argv === undefined && parseOptions.from === undefined) {
38585
+ if (process3.versions?.electron) {
38431
38586
  parseOptions.from = "electron";
38432
38587
  }
38588
+ const execArgv = process3.execArgv ?? [];
38589
+ if (execArgv.includes("-e") || execArgv.includes("--eval") || execArgv.includes("-p") || execArgv.includes("--print")) {
38590
+ parseOptions.from = "eval";
38591
+ }
38592
+ }
38593
+ if (argv === undefined) {
38594
+ argv = process3.argv;
38433
38595
  }
38434
38596
  this.rawArgs = argv.slice();
38435
38597
  let userArgs;
@@ -38450,6 +38612,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
38450
38612
  case "user":
38451
38613
  userArgs = argv.slice(0);
38452
38614
  break;
38615
+ case "eval":
38616
+ userArgs = argv.slice(1);
38617
+ break;
38453
38618
  default:
38454
38619
  throw new Error(`unexpected parse option { from: '${parseOptions.from}' }`);
38455
38620
  }
@@ -38459,15 +38624,53 @@ Expecting one of '${allowedValues.join("', '")}'`);
38459
38624
  return userArgs;
38460
38625
  }
38461
38626
  parse(argv, parseOptions) {
38627
+ this._prepareForParse();
38462
38628
  const userArgs = this._prepareUserArgs(argv, parseOptions);
38463
38629
  this._parseCommand([], userArgs);
38464
38630
  return this;
38465
38631
  }
38466
38632
  async parseAsync(argv, parseOptions) {
38633
+ this._prepareForParse();
38467
38634
  const userArgs = this._prepareUserArgs(argv, parseOptions);
38468
38635
  await this._parseCommand([], userArgs);
38469
38636
  return this;
38470
38637
  }
38638
+ _prepareForParse() {
38639
+ if (this._savedState === null) {
38640
+ this.saveStateBeforeParse();
38641
+ } else {
38642
+ this.restoreStateBeforeParse();
38643
+ }
38644
+ }
38645
+ saveStateBeforeParse() {
38646
+ this._savedState = {
38647
+ _name: this._name,
38648
+ _optionValues: { ...this._optionValues },
38649
+ _optionValueSources: { ...this._optionValueSources }
38650
+ };
38651
+ }
38652
+ restoreStateBeforeParse() {
38653
+ if (this._storeOptionsAsProperties)
38654
+ throw new Error(`Can not call parse again when storeOptionsAsProperties is true.
38655
+ - either make a new Command for each call to parse, or stop storing options as properties`);
38656
+ this._name = this._savedState._name;
38657
+ this._scriptPath = null;
38658
+ this.rawArgs = [];
38659
+ this._optionValues = { ...this._savedState._optionValues };
38660
+ this._optionValueSources = { ...this._savedState._optionValueSources };
38661
+ this.args = [];
38662
+ this.processedArgs = [];
38663
+ }
38664
+ _checkForMissingExecutable(executableFile, executableDir, subcommandName) {
38665
+ if (fs.existsSync(executableFile))
38666
+ return;
38667
+ const executableDirMessage = executableDir ? `searched for local subcommand relative to directory '${executableDir}'` : "no directory for search for local subcommand, use .executableDir() to supply a custom directory";
38668
+ const executableMissing = `'${executableFile}' does not exist
38669
+ - if '${subcommandName}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
38670
+ - if the default executable name is not suitable, use the executableFile option to supply a custom name or path
38671
+ - ${executableDirMessage}`;
38672
+ throw new Error(executableMissing);
38673
+ }
38471
38674
  _executeSubCommand(subcommand, args) {
38472
38675
  args = args.slice();
38473
38676
  let launchWithNode = false;
@@ -38491,7 +38694,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
38491
38694
  let resolvedScriptPath;
38492
38695
  try {
38493
38696
  resolvedScriptPath = fs.realpathSync(this._scriptPath);
38494
- } catch (err) {
38697
+ } catch {
38495
38698
  resolvedScriptPath = this._scriptPath;
38496
38699
  }
38497
38700
  executableDir = path2.resolve(path2.dirname(resolvedScriptPath), executableDir);
@@ -38517,6 +38720,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
38517
38720
  proc2 = childProcess.spawn(executableFile, args, { stdio: "inherit" });
38518
38721
  }
38519
38722
  } else {
38723
+ this._checkForMissingExecutable(executableFile, executableDir, subcommand._name);
38520
38724
  args.unshift(executableFile);
38521
38725
  args = incrementNodeInspectorPort(process3.execArgv).concat(args);
38522
38726
  proc2 = childProcess.spawn(process3.execPath, args, { stdio: "inherit" });
@@ -38532,21 +38736,17 @@ Expecting one of '${allowedValues.join("', '")}'`);
38532
38736
  });
38533
38737
  }
38534
38738
  const exitCallback = this._exitCallback;
38535
- if (!exitCallback) {
38536
- proc2.on("close", process3.exit.bind(process3));
38537
- } else {
38538
- proc2.on("close", () => {
38539
- exitCallback(new CommanderError(process3.exitCode || 0, "commander.executeSubCommandAsync", "(close)"));
38540
- });
38541
- }
38739
+ proc2.on("close", (code) => {
38740
+ code = code ?? 1;
38741
+ if (!exitCallback) {
38742
+ process3.exit(code);
38743
+ } else {
38744
+ exitCallback(new CommanderError(code, "commander.executeSubCommandAsync", "(close)"));
38745
+ }
38746
+ });
38542
38747
  proc2.on("error", (err) => {
38543
38748
  if (err.code === "ENOENT") {
38544
- const executableDirMessage = executableDir ? `searched for local subcommand relative to directory '${executableDir}'` : "no directory for search for local subcommand, use .executableDir() to supply a custom directory";
38545
- const executableMissing = `'${executableFile}' does not exist
38546
- - if '${subcommand._name}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
38547
- - if the default executable name is not suitable, use the executableFile option to supply a custom name or path
38548
- - ${executableDirMessage}`;
38549
- throw new Error(executableMissing);
38749
+ this._checkForMissingExecutable(executableFile, executableDir, subcommand._name);
38550
38750
  } else if (err.code === "EACCES") {
38551
38751
  throw new Error(`'${executableFile}' not executable`);
38552
38752
  }
@@ -38564,27 +38764,38 @@ Expecting one of '${allowedValues.join("', '")}'`);
38564
38764
  const subCommand = this._findCommand(commandName);
38565
38765
  if (!subCommand)
38566
38766
  this.help({ error: true });
38567
- let hookResult;
38568
- hookResult = this._chainOrCallSubCommandHook(hookResult, subCommand, "preSubcommand");
38569
- hookResult = this._chainOrCall(hookResult, () => {
38767
+ subCommand._prepareForParse();
38768
+ let promiseChain;
38769
+ promiseChain = this._chainOrCallSubCommandHook(promiseChain, subCommand, "preSubcommand");
38770
+ promiseChain = this._chainOrCall(promiseChain, () => {
38570
38771
  if (subCommand._executableHandler) {
38571
38772
  this._executeSubCommand(subCommand, operands.concat(unknown2));
38572
38773
  } else {
38573
38774
  return subCommand._parseCommand(operands, unknown2);
38574
38775
  }
38575
38776
  });
38576
- return hookResult;
38777
+ return promiseChain;
38778
+ }
38779
+ _dispatchHelpCommand(subcommandName) {
38780
+ if (!subcommandName) {
38781
+ this.help();
38782
+ }
38783
+ const subCommand = this._findCommand(subcommandName);
38784
+ if (subCommand && !subCommand._executableHandler) {
38785
+ subCommand.help();
38786
+ }
38787
+ return this._dispatchSubcommand(subcommandName, [], [this._getHelpOption()?.long ?? this._getHelpOption()?.short ?? "--help"]);
38577
38788
  }
38578
38789
  _checkNumberOfArguments() {
38579
- this._args.forEach((arg, i) => {
38790
+ this.registeredArguments.forEach((arg, i) => {
38580
38791
  if (arg.required && this.args[i] == null) {
38581
38792
  this.missingArgument(arg.name());
38582
38793
  }
38583
38794
  });
38584
- if (this._args.length > 0 && this._args[this._args.length - 1].variadic) {
38795
+ if (this.registeredArguments.length > 0 && this.registeredArguments[this.registeredArguments.length - 1].variadic) {
38585
38796
  return;
38586
38797
  }
38587
- if (this.args.length > this._args.length) {
38798
+ if (this.args.length > this.registeredArguments.length) {
38588
38799
  this._excessArguments(this.args);
38589
38800
  }
38590
38801
  }
@@ -38592,21 +38803,14 @@ Expecting one of '${allowedValues.join("', '")}'`);
38592
38803
  const myParseArg = (argument, value, previous) => {
38593
38804
  let parsedValue = value;
38594
38805
  if (value !== null && argument.parseArg) {
38595
- try {
38596
- parsedValue = argument.parseArg(value, previous);
38597
- } catch (err) {
38598
- if (err.code === "commander.invalidArgument") {
38599
- const message = `error: command-argument value '${value}' is invalid for argument '${argument.name()}'. ${err.message}`;
38600
- this.error(message, { exitCode: err.exitCode, code: err.code });
38601
- }
38602
- throw err;
38603
- }
38806
+ const invalidValueMessage = `error: command-argument value '${value}' is invalid for argument '${argument.name()}'.`;
38807
+ parsedValue = this._callParseArg(argument, value, previous, invalidValueMessage);
38604
38808
  }
38605
38809
  return parsedValue;
38606
38810
  };
38607
38811
  this._checkNumberOfArguments();
38608
38812
  const processedArgs = [];
38609
- this._args.forEach((declaredArg, index) => {
38813
+ this.registeredArguments.forEach((declaredArg, index) => {
38610
38814
  let value = declaredArg.defaultValue;
38611
38815
  if (declaredArg.variadic) {
38612
38816
  if (index < this.args.length) {
@@ -38638,7 +38842,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
38638
38842
  _chainOrCallHooks(promise2, event) {
38639
38843
  let result = promise2;
38640
38844
  const hooks = [];
38641
- getCommandAndParents(this).reverse().filter((cmd) => cmd._lifeCycleHooks[event] !== undefined).forEach((hookedCommand) => {
38845
+ this._getCommandAndAncestors().reverse().filter((cmd) => cmd._lifeCycleHooks[event] !== undefined).forEach((hookedCommand) => {
38642
38846
  hookedCommand._lifeCycleHooks[event].forEach((callback) => {
38643
38847
  hooks.push({ hookedCommand, callback });
38644
38848
  });
@@ -38674,20 +38878,17 @@ Expecting one of '${allowedValues.join("', '")}'`);
38674
38878
  if (operands && this._findCommand(operands[0])) {
38675
38879
  return this._dispatchSubcommand(operands[0], operands.slice(1), unknown2);
38676
38880
  }
38677
- if (this._hasImplicitHelpCommand() && operands[0] === this._helpCommandName) {
38678
- if (operands.length === 1) {
38679
- this.help();
38680
- }
38681
- return this._dispatchSubcommand(operands[1], [], [this._helpLongFlag]);
38881
+ if (this._getHelpCommand() && operands[0] === this._getHelpCommand().name()) {
38882
+ return this._dispatchHelpCommand(operands[1]);
38682
38883
  }
38683
38884
  if (this._defaultCommandName) {
38684
- outputHelpIfRequested(this, unknown2);
38885
+ this._outputHelpIfRequested(unknown2);
38685
38886
  return this._dispatchSubcommand(this._defaultCommandName, operands, unknown2);
38686
38887
  }
38687
38888
  if (this.commands.length && this.args.length === 0 && !this._actionHandler && !this._defaultCommandName) {
38688
38889
  this.help({ error: true });
38689
38890
  }
38690
- outputHelpIfRequested(this, parsed.unknown);
38891
+ this._outputHelpIfRequested(parsed.unknown);
38691
38892
  this._checkForMissingMandatoryOptions();
38692
38893
  this._checkForConflictingOptions();
38693
38894
  const checkForUnknownOptions = () => {
@@ -38699,16 +38900,16 @@ Expecting one of '${allowedValues.join("', '")}'`);
38699
38900
  if (this._actionHandler) {
38700
38901
  checkForUnknownOptions();
38701
38902
  this._processArguments();
38702
- let actionResult;
38703
- actionResult = this._chainOrCallHooks(actionResult, "preAction");
38704
- actionResult = this._chainOrCall(actionResult, () => this._actionHandler(this.processedArgs));
38903
+ let promiseChain;
38904
+ promiseChain = this._chainOrCallHooks(promiseChain, "preAction");
38905
+ promiseChain = this._chainOrCall(promiseChain, () => this._actionHandler(this.processedArgs));
38705
38906
  if (this.parent) {
38706
- actionResult = this._chainOrCall(actionResult, () => {
38907
+ promiseChain = this._chainOrCall(promiseChain, () => {
38707
38908
  this.parent.emit(commandEvent, operands, unknown2);
38708
38909
  });
38709
38910
  }
38710
- actionResult = this._chainOrCallHooks(actionResult, "postAction");
38711
- return actionResult;
38911
+ promiseChain = this._chainOrCallHooks(promiseChain, "postAction");
38912
+ return promiseChain;
38712
38913
  }
38713
38914
  if (this.parent && this.parent.listenerCount(commandEvent)) {
38714
38915
  checkForUnknownOptions();
@@ -38743,13 +38944,13 @@ Expecting one of '${allowedValues.join("', '")}'`);
38743
38944
  return this.options.find((option) => option.is(arg));
38744
38945
  }
38745
38946
  _checkForMissingMandatoryOptions() {
38746
- for (let cmd = this;cmd; cmd = cmd.parent) {
38947
+ this._getCommandAndAncestors().forEach((cmd) => {
38747
38948
  cmd.options.forEach((anOption) => {
38748
38949
  if (anOption.mandatory && cmd.getOptionValue(anOption.attributeName()) === undefined) {
38749
38950
  cmd.missingMandatoryOptionValue(anOption);
38750
38951
  }
38751
38952
  });
38752
- }
38953
+ });
38753
38954
  }
38754
38955
  _checkForConflictingLocalOptions() {
38755
38956
  const definedNonDefaultOptions = this.options.filter((option) => {
@@ -38768,9 +38969,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
38768
38969
  });
38769
38970
  }
38770
38971
  _checkForConflictingOptions() {
38771
- for (let cmd = this;cmd; cmd = cmd.parent) {
38972
+ this._getCommandAndAncestors().forEach((cmd) => {
38772
38973
  cmd._checkForConflictingLocalOptions();
38773
- }
38974
+ });
38774
38975
  }
38775
38976
  parseOptions(argv) {
38776
38977
  const operands = [];
@@ -38844,7 +39045,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
38844
39045
  if (args.length > 0)
38845
39046
  unknown2.push(...args);
38846
39047
  break;
38847
- } else if (arg === this._helpCommandName && this._hasImplicitHelpCommand()) {
39048
+ } else if (this._getHelpCommand() && arg === this._getHelpCommand().name()) {
38848
39049
  operands.push(arg);
38849
39050
  if (args.length > 0)
38850
39051
  operands.push(...args);
@@ -38879,7 +39080,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
38879
39080
  return this._optionValues;
38880
39081
  }
38881
39082
  optsWithGlobals() {
38882
- return getCommandAndParents(this).reduce((combinedOptions, cmd) => Object.assign(combinedOptions, cmd.opts()), {});
39083
+ return this._getCommandAndAncestors().reduce((combinedOptions, cmd) => Object.assign(combinedOptions, cmd.opts()), {});
38883
39084
  }
38884
39085
  error(message, errorOptions) {
38885
39086
  this._outputConfiguration.outputError(`${message}
@@ -38977,7 +39178,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
38977
39178
  _excessArguments(receivedArgs) {
38978
39179
  if (this._allowExcessArguments)
38979
39180
  return;
38980
- const expected = this._args.length;
39181
+ const expected = this.registeredArguments.length;
38981
39182
  const s = expected === 1 ? "" : "s";
38982
39183
  const forSubcommand = this.parent ? ` for '${this.name()}'` : "";
38983
39184
  const message = `error: too many arguments${forSubcommand}. Expected ${expected} argument${s} but got ${receivedArgs.length}.`;
@@ -39006,7 +39207,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
39006
39207
  description = description || "output the version number";
39007
39208
  const versionOption = this.createOption(flags, description);
39008
39209
  this._versionOptionName = versionOption.attributeName();
39009
- this.options.push(versionOption);
39210
+ this._registerOption(versionOption);
39010
39211
  this.on("option:" + versionOption.name(), () => {
39011
39212
  this._outputConfiguration.writeOut(`${str}
39012
39213
  `);
@@ -39038,6 +39239,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
39038
39239
  }
39039
39240
  if (alias === command._name)
39040
39241
  throw new Error("Command alias can't be the same as its name");
39242
+ const matchingCommand = this.parent?._findCommand(alias);
39243
+ if (matchingCommand) {
39244
+ const existingCmd = [matchingCommand.name()].concat(matchingCommand.aliases()).join("|");
39245
+ throw new Error(`cannot add alias '${alias}' to command '${this.name()}' as already have command '${existingCmd}'`);
39246
+ }
39041
39247
  command._aliases.push(alias);
39042
39248
  return this;
39043
39249
  }
@@ -39051,10 +39257,10 @@ Expecting one of '${allowedValues.join("', '")}'`);
39051
39257
  if (str === undefined) {
39052
39258
  if (this._usage)
39053
39259
  return this._usage;
39054
- const args = this._args.map((arg) => {
39260
+ const args = this.registeredArguments.map((arg) => {
39055
39261
  return humanReadableArgName(arg);
39056
39262
  });
39057
- return [].concat(this.options.length || this._hasHelpOption ? "[options]" : [], this.commands.length ? "[command]" : [], this._args.length ? args : []).join(" ");
39263
+ return [].concat(this.options.length || this._helpOption !== null ? "[options]" : [], this.commands.length ? "[command]" : [], this.registeredArguments.length ? args : []).join(" ");
39058
39264
  }
39059
39265
  this._usage = str;
39060
39266
  return this;
@@ -39077,23 +39283,38 @@ Expecting one of '${allowedValues.join("', '")}'`);
39077
39283
  }
39078
39284
  helpInformation(contextOptions) {
39079
39285
  const helper = this.createHelp();
39080
- if (helper.helpWidth === undefined) {
39081
- helper.helpWidth = contextOptions && contextOptions.error ? this._outputConfiguration.getErrHelpWidth() : this._outputConfiguration.getOutHelpWidth();
39082
- }
39083
- return helper.formatHelp(this, helper);
39286
+ const context = this._getOutputContext(contextOptions);
39287
+ helper.prepareContext({
39288
+ error: context.error,
39289
+ helpWidth: context.helpWidth,
39290
+ outputHasColors: context.hasColors
39291
+ });
39292
+ const text = helper.formatHelp(this, helper);
39293
+ if (context.hasColors)
39294
+ return text;
39295
+ return this._outputConfiguration.stripColor(text);
39084
39296
  }
39085
- _getHelpContext(contextOptions) {
39297
+ _getOutputContext(contextOptions) {
39086
39298
  contextOptions = contextOptions || {};
39087
- const context = { error: !!contextOptions.error };
39088
- let write;
39089
- if (context.error) {
39090
- write = (arg) => this._outputConfiguration.writeErr(arg);
39299
+ const error = !!contextOptions.error;
39300
+ let baseWrite;
39301
+ let hasColors2;
39302
+ let helpWidth;
39303
+ if (error) {
39304
+ baseWrite = (str) => this._outputConfiguration.writeErr(str);
39305
+ hasColors2 = this._outputConfiguration.getErrHasColors();
39306
+ helpWidth = this._outputConfiguration.getErrHelpWidth();
39091
39307
  } else {
39092
- write = (arg) => this._outputConfiguration.writeOut(arg);
39093
- }
39094
- context.write = contextOptions.write || write;
39095
- context.command = this;
39096
- return context;
39308
+ baseWrite = (str) => this._outputConfiguration.writeOut(str);
39309
+ hasColors2 = this._outputConfiguration.getOutHasColors();
39310
+ helpWidth = this._outputConfiguration.getOutHelpWidth();
39311
+ }
39312
+ const write = (str) => {
39313
+ if (!hasColors2)
39314
+ str = this._outputConfiguration.stripColor(str);
39315
+ return baseWrite(str);
39316
+ };
39317
+ return { error, write, hasColors: hasColors2, helpWidth };
39097
39318
  }
39098
39319
  outputHelp(contextOptions) {
39099
39320
  let deprecatedCallback;
@@ -39101,36 +39322,55 @@ Expecting one of '${allowedValues.join("', '")}'`);
39101
39322
  deprecatedCallback = contextOptions;
39102
39323
  contextOptions = undefined;
39103
39324
  }
39104
- const context = this._getHelpContext(contextOptions);
39105
- getCommandAndParents(this).reverse().forEach((command) => command.emit("beforeAllHelp", context));
39106
- this.emit("beforeHelp", context);
39107
- let helpInformation = this.helpInformation(context);
39325
+ const outputContext = this._getOutputContext(contextOptions);
39326
+ const eventContext = {
39327
+ error: outputContext.error,
39328
+ write: outputContext.write,
39329
+ command: this
39330
+ };
39331
+ this._getCommandAndAncestors().reverse().forEach((command) => command.emit("beforeAllHelp", eventContext));
39332
+ this.emit("beforeHelp", eventContext);
39333
+ let helpInformation = this.helpInformation({ error: outputContext.error });
39108
39334
  if (deprecatedCallback) {
39109
39335
  helpInformation = deprecatedCallback(helpInformation);
39110
39336
  if (typeof helpInformation !== "string" && !Buffer.isBuffer(helpInformation)) {
39111
39337
  throw new Error("outputHelp callback must return a string or a Buffer");
39112
39338
  }
39113
39339
  }
39114
- context.write(helpInformation);
39115
- this.emit(this._helpLongFlag);
39116
- this.emit("afterHelp", context);
39117
- getCommandAndParents(this).forEach((command) => command.emit("afterAllHelp", context));
39340
+ outputContext.write(helpInformation);
39341
+ if (this._getHelpOption()?.long) {
39342
+ this.emit(this._getHelpOption().long);
39343
+ }
39344
+ this.emit("afterHelp", eventContext);
39345
+ this._getCommandAndAncestors().forEach((command) => command.emit("afterAllHelp", eventContext));
39118
39346
  }
39119
39347
  helpOption(flags, description) {
39120
39348
  if (typeof flags === "boolean") {
39121
- this._hasHelpOption = flags;
39349
+ if (flags) {
39350
+ this._helpOption = this._helpOption ?? undefined;
39351
+ } else {
39352
+ this._helpOption = null;
39353
+ }
39122
39354
  return this;
39123
39355
  }
39124
- this._helpFlags = flags || this._helpFlags;
39125
- this._helpDescription = description || this._helpDescription;
39126
- const helpFlags = splitOptionFlags(this._helpFlags);
39127
- this._helpShortFlag = helpFlags.shortFlag;
39128
- this._helpLongFlag = helpFlags.longFlag;
39356
+ flags = flags ?? "-h, --help";
39357
+ description = description ?? "display help for command";
39358
+ this._helpOption = this.createOption(flags, description);
39359
+ return this;
39360
+ }
39361
+ _getHelpOption() {
39362
+ if (this._helpOption === undefined) {
39363
+ this.helpOption(undefined, undefined);
39364
+ }
39365
+ return this._helpOption;
39366
+ }
39367
+ addHelpOption(option) {
39368
+ this._helpOption = option;
39129
39369
  return this;
39130
39370
  }
39131
39371
  help(contextOptions) {
39132
39372
  this.outputHelp(contextOptions);
39133
- let exitCode = process3.exitCode || 0;
39373
+ let exitCode = Number(process3.exitCode ?? 0);
39134
39374
  if (exitCode === 0 && contextOptions && typeof contextOptions !== "function" && contextOptions.error) {
39135
39375
  exitCode = 1;
39136
39376
  }
@@ -39157,12 +39397,13 @@ Expecting one of '${allowedValues.join("', '")}'`);
39157
39397
  });
39158
39398
  return this;
39159
39399
  }
39160
- }
39161
- function outputHelpIfRequested(cmd, args) {
39162
- const helpOption = cmd._hasHelpOption && args.find((arg) => arg === cmd._helpLongFlag || arg === cmd._helpShortFlag);
39163
- if (helpOption) {
39164
- cmd.outputHelp();
39165
- cmd._exit(0, "commander.helpDisplayed", "(outputHelp)");
39400
+ _outputHelpIfRequested(args) {
39401
+ const helpOption = this._getHelpOption();
39402
+ const helpRequested = helpOption && args.find((arg) => helpOption.is(arg));
39403
+ if (helpRequested) {
39404
+ this.outputHelp();
39405
+ this._exit(0, "commander.helpDisplayed", "(outputHelp)");
39406
+ }
39166
39407
  }
39167
39408
  }
39168
39409
  function incrementNodeInspectorPort(args) {
@@ -39194,32 +39435,35 @@ Expecting one of '${allowedValues.join("', '")}'`);
39194
39435
  return arg;
39195
39436
  });
39196
39437
  }
39197
- function getCommandAndParents(startCommand) {
39198
- const result = [];
39199
- for (let command = startCommand;command; command = command.parent) {
39200
- result.push(command);
39201
- }
39202
- return result;
39438
+ function useColor() {
39439
+ if (process3.env.NO_COLOR || process3.env.FORCE_COLOR === "0" || process3.env.FORCE_COLOR === "false")
39440
+ return false;
39441
+ if (process3.env.FORCE_COLOR || process3.env.CLICOLOR_FORCE !== undefined)
39442
+ return true;
39443
+ return;
39203
39444
  }
39204
39445
  exports.Command = Command;
39446
+ exports.useColor = useColor;
39205
39447
  });
39206
39448
 
39207
39449
  // ../../node_modules/commander/index.js
39208
- var require_commander = __commonJS((exports, module) => {
39450
+ var require_commander = __commonJS((exports) => {
39209
39451
  var { Argument } = require_argument();
39210
39452
  var { Command } = require_command();
39211
39453
  var { CommanderError, InvalidArgumentError } = require_error3();
39212
39454
  var { Help } = require_help();
39213
39455
  var { Option } = require_option();
39214
- exports = module.exports = new Command;
39215
- exports.program = exports;
39216
- exports.Argument = Argument;
39456
+ exports.program = new Command;
39457
+ exports.createCommand = (name) => new Command(name);
39458
+ exports.createOption = (flags, description) => new Option(flags, description);
39459
+ exports.createArgument = (name, description) => new Argument(name, description);
39217
39460
  exports.Command = Command;
39218
- exports.CommanderError = CommanderError;
39461
+ exports.Option = Option;
39462
+ exports.Argument = Argument;
39219
39463
  exports.Help = Help;
39464
+ exports.CommanderError = CommanderError;
39220
39465
  exports.InvalidArgumentError = InvalidArgumentError;
39221
39466
  exports.InvalidOptionArgumentError = InvalidArgumentError;
39222
- exports.Option = Option;
39223
39467
  });
39224
39468
  // ../../node_modules/@graphql-tools/utils/esm/helpers.js
39225
39469
  var import_graphql = __toESM(require_graphql2(), 1);
@@ -42350,8 +42594,7 @@ function getCustomLoaderByPath(path, cwd) {
42350
42594
  return requiredModule;
42351
42595
  }
42352
42596
  }
42353
- } catch (e) {
42354
- }
42597
+ } catch (e) {}
42355
42598
  return null;
42356
42599
  }
42357
42600
  async function useCustomLoader(loaderPointer, cwd) {
@@ -42386,8 +42629,7 @@ function useStack(...fns) {
42386
42629
  return (input) => {
42387
42630
  function createNext(i) {
42388
42631
  if (i >= fns.length) {
42389
- return () => {
42390
- };
42632
+ return () => {};
42391
42633
  }
42392
42634
  return function next() {
42393
42635
  fns[i](input, createNext(i + 1));
@@ -44321,8 +44563,7 @@ function createClient(options) {
44321
44563
  })())));
44322
44564
  if (socket.readyState === WebSocketImpl.CLOSING)
44323
44565
  await throwOnClose;
44324
- let release = () => {
44325
- };
44566
+ let release = () => {};
44326
44567
  const released = new Promise((resolve) => release = resolve);
44327
44568
  return [
44328
44569
  socket,
@@ -44458,8 +44699,7 @@ function createClient(options) {
44458
44699
  const deferred = {
44459
44700
  done: false,
44460
44701
  error: null,
44461
- resolve: () => {
44462
- }
44702
+ resolve: () => {}
44463
44703
  };
44464
44704
  const dispose = subscribe(request, {
44465
44705
  next(val) {
@@ -44620,8 +44860,7 @@ if (!shouldSkipPonyfill()) {
44620
44860
  try {
44621
44861
  const nodelibcurlName = "node-libcurl";
44622
44862
  globalThis.libcurl = globalThis.libcurl || __require(nodelibcurlName);
44623
- } catch (e) {
44624
- }
44863
+ } catch (e) {}
44625
44864
  }
44626
44865
  var $fetch = ponyfills.fetch;
44627
44866
  var $Headers = ponyfills.Headers;
@@ -44979,8 +45218,7 @@ var Stopped = 2;
44979
45218
  var Done = 3;
44980
45219
  var Rejected = 4;
44981
45220
  var MAX_QUEUE_LENGTH = 1024;
44982
- var NOOP = function() {
44983
- };
45221
+ var NOOP = function() {};
44984
45222
  function consumeExecution(r) {
44985
45223
  var err = r.err;
44986
45224
  var execution = Promise.resolve(r.execution).then(function(value) {
@@ -45746,8 +45984,7 @@ async function t(t2, n) {
45746
45984
  if (d = f2["content-type"], d && ~d.indexOf("application/json"))
45747
45985
  try {
45748
45986
  r3 = JSON.parse(r3), l3 = true;
45749
- } catch (e3) {
45750
- }
45987
+ } catch (e3) {}
45751
45988
  if (d = { headers: f2, body: r3, json: l3 }, a ? yield d : c.push(d), t5.slice(0, 2) === "--")
45752
45989
  break e;
45753
45990
  } else
@@ -45792,8 +46029,7 @@ async function e2(e3, t2) {
45792
46029
  if (f = d["content-type"], f && ~f.indexOf("application/json"))
45793
46030
  try {
45794
46031
  l2 = JSON.parse(String(l2)), i3 = true;
45795
- } catch (e7) {
45796
- }
46032
+ } catch (e7) {}
45797
46033
  if (f = { headers: d, body: l2, json: i3 }, a ? yield f : s.push(f), n4[0] === 45 && n4[1] === 45)
45798
46034
  break e;
45799
46035
  } else
@@ -47499,8 +47735,7 @@ async function executeStreamIterator(initialIndex, iterator, exeContext, fieldNo
47499
47735
  filterSubsequentPayloads(exeContext, path, asyncPayloadRecord);
47500
47736
  asyncPayloadRecord.addItems(null);
47501
47737
  if (iterator?.return) {
47502
- iterator.return().catch(() => {
47503
- });
47738
+ iterator.return().catch(() => {});
47504
47739
  }
47505
47740
  return;
47506
47741
  }
@@ -47535,8 +47770,7 @@ function filterSubsequentPayloads(exeContext, nullPath, currentAsyncRecord) {
47535
47770
  }
47536
47771
  }
47537
47772
  if (isStreamPayload(asyncRecord) && asyncRecord.iterator?.return) {
47538
- asyncRecord.iterator.return().catch(() => {
47539
- });
47773
+ asyncRecord.iterator.return().catch(() => {});
47540
47774
  }
47541
47775
  exeContext.subsequentPayloads.delete(asyncRecord);
47542
47776
  });
@@ -50394,54 +50628,39 @@ async function fetchProcessedSchema(endpoint, accessToken, adminSecret, timeoutM
50394
50628
  const schema = await fetchGraphQLSchema(endpoint, accessToken, adminSecret, timeoutMs);
50395
50629
  return processSchema(schema);
50396
50630
  }
50631
+ var formatField = (name, field) => {
50632
+ const args = field.args.length > 0 ? ` (${field.args.map((arg) => `${arg.name}: ${arg.type}`).join(", ")})` : "";
50633
+ const returnType = ` → ${field.type}`;
50634
+ return `• ${name}${args}${returnType}`;
50635
+ };
50636
+ var formatFields = (fields2) => {
50637
+ return Object.entries(fields2).map(([name, field]) => formatField(name, field));
50638
+ };
50397
50639
  var createSchemaDescription = (schema) => {
50398
50640
  const parts = [];
50399
50641
  const queryType = schema.getQueryType();
50400
50642
  if (queryType) {
50401
- const fields2 = queryType.getFields();
50402
- for (const [name, field] of Object.entries(fields2)) {
50403
- const args = field.args.length > 0 ? ` (${field.args.map((arg) => `${arg.name}: ${arg.type}`).join(", ")})` : "";
50404
- const returnType = ` → ${field.type}`;
50405
- parts.push(`• ${name}${args}${returnType}`);
50406
- }
50407
- parts.push("");
50643
+ parts.push(...formatFields(queryType.getFields()), "");
50408
50644
  }
50409
50645
  const mutationType = schema.getMutationType();
50410
50646
  if (mutationType) {
50411
- const fields2 = mutationType.getFields();
50412
- for (const [name, field] of Object.entries(fields2)) {
50413
- const args = field.args.length > 0 ? ` (${field.args.map((arg) => `${arg.name}: ${arg.type}`).join(", ")})` : "";
50414
- const returnType = ` → ${field.type}`;
50415
- parts.push(`• ${name}${args}${returnType}`);
50416
- }
50417
- parts.push("");
50647
+ parts.push(...formatFields(mutationType.getFields()), "");
50418
50648
  }
50419
50649
  return parts.join(`
50420
50650
  `).trim();
50421
50651
  };
50422
- var processFields = (type) => {
50423
- return type.getFields();
50652
+ var extractOperationFields = (schema, getType) => {
50653
+ const type = getType(schema);
50654
+ return type ? type.getFields() : {};
50424
50655
  };
50425
50656
  var extractQueries = (schema) => {
50426
- const queryType = schema.getQueryType();
50427
- if (!queryType) {
50428
- return {};
50429
- }
50430
- return processFields(queryType);
50657
+ return extractOperationFields(schema, (s) => s.getQueryType());
50431
50658
  };
50432
50659
  var extractMutations = (schema) => {
50433
- const mutationType = schema.getMutationType();
50434
- if (!mutationType) {
50435
- return {};
50436
- }
50437
- return processFields(mutationType);
50660
+ return extractOperationFields(schema, (s) => s.getMutationType());
50438
50661
  };
50439
50662
  var extractSubscriptions = (schema) => {
50440
- const subscriptionType = schema.getSubscriptionType();
50441
- if (!subscriptionType) {
50442
- return {};
50443
- }
50444
- return processFields(subscriptionType);
50663
+ return extractOperationFields(schema, (s) => s.getSubscriptionType());
50445
50664
  };
50446
50665
  var extractTypes = (schema) => {
50447
50666
  const typeMap = schema.getTypeMap();
@@ -50521,8 +50740,7 @@ var portalQueries = (server, env3) => {
50521
50740
  var util;
50522
50741
  (function(util2) {
50523
50742
  util2.assertEqual = (val) => val;
50524
- function assertIs(_arg) {
50525
- }
50743
+ function assertIs(_arg) {}
50526
50744
  util2.assertIs = assertIs;
50527
50745
  function assertNever(_x) {
50528
50746
  throw new Error;
@@ -55836,8 +56054,7 @@ function parseStringDef(def, refs) {
55836
56054
  case "trim":
55837
56055
  break;
55838
56056
  default:
55839
- ((_) => {
55840
- })(check);
56057
+ ((_) => {})(check);
55841
56058
  }
55842
56059
  }
55843
56060
  }
@@ -57848,8 +58065,7 @@ class Minimatch {
57848
58065
  }
57849
58066
  return false;
57850
58067
  }
57851
- debug(..._) {
57852
- }
58068
+ debug(..._) {}
57853
58069
  make() {
57854
58070
  const pattern = this.pattern;
57855
58071
  const options = this.options;
@@ -58681,12 +58897,9 @@ class LRUCache {
58681
58897
  return !!t2 && !!s && (cachedNow || getNow()) - s > t2;
58682
58898
  };
58683
58899
  }
58684
- #updateItemAge = () => {
58685
- };
58686
- #statusTTL = () => {
58687
- };
58688
- #setItemTTL = () => {
58689
- };
58900
+ #updateItemAge = () => {};
58901
+ #statusTTL = () => {};
58902
+ #setItemTTL = () => {};
58690
58903
  #isStale = () => false;
58691
58904
  #initializeSizeTracking() {
58692
58905
  const sizes = new ZeroArray(this.#max);
@@ -58730,10 +58943,8 @@ class LRUCache {
58730
58943
  }
58731
58944
  };
58732
58945
  }
58733
- #removeItemSize = (_i) => {
58734
- };
58735
- #addItemSize = (_i, _s, _st) => {
58736
- };
58946
+ #removeItemSize = (_i) => {};
58947
+ #addItemSize = (_i, _s, _st) => {};
58737
58948
  #requireSize = (_k, _v, size, sizeCalculation) => {
58738
58949
  if (size || sizeCalculation) {
58739
58950
  throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");
@@ -59532,8 +59743,7 @@ class Pipe {
59532
59743
  unpipe() {
59533
59744
  this.dest.removeListener("drain", this.ondrain);
59534
59745
  }
59535
- proxyErrors(_er) {
59536
- }
59746
+ proxyErrors(_er) {}
59537
59747
  end() {
59538
59748
  this.unpipe();
59539
59749
  if (this.opts.end)
@@ -59643,8 +59853,7 @@ class Minipass extends EventEmitter {
59643
59853
  get aborted() {
59644
59854
  return this[ABORTED];
59645
59855
  }
59646
- set aborted(_) {
59647
- }
59856
+ set aborted(_) {}
59648
59857
  write(chunk, encoding, cb) {
59649
59858
  if (this[ABORTED])
59650
59859
  return false;
@@ -59816,8 +60025,7 @@ class Minipass extends EventEmitter {
59816
60025
  return this[BUFFER].shift();
59817
60026
  }
59818
60027
  [FLUSH](noDrain = false) {
59819
- do {
59820
- } while (this[FLUSHCHUNK](this[BUFFERSHIFT]()) && this[BUFFER].length);
60028
+ do {} while (this[FLUSHCHUNK](this[BUFFERSHIFT]()) && this[BUFFER].length);
59821
60029
  if (!noDrain && !this[BUFFER].length && !this[EOF])
59822
60030
  this.emit("drain");
59823
60031
  }
@@ -60762,8 +60970,7 @@ class PathBase {
60762
60970
  if (this.#asyncReaddirInFlight) {
60763
60971
  await this.#asyncReaddirInFlight;
60764
60972
  } else {
60765
- let resolve = () => {
60766
- };
60973
+ let resolve = () => {};
60767
60974
  this.#asyncReaddirInFlight = new Promise((res) => resolve = res);
60768
60975
  try {
60769
60976
  for (const e3 of await this.#fs.promises.readdir(fullpath, {
@@ -62628,7 +62835,7 @@ var {
62628
62835
  var package_default = {
62629
62836
  name: "@settlemint/sdk-mcp",
62630
62837
  description: "MCP interface for SettleMint SDK, providing development tools and project management capabilities",
62631
- version: "1.1.16-prc78f6086",
62838
+ version: "1.1.16-pre2559e50",
62632
62839
  type: "module",
62633
62840
  private: false,
62634
62841
  license: "FSL-1.1-MIT",
@@ -62671,9 +62878,10 @@ var package_default = {
62671
62878
  "@graphql-tools/load": "8.0.17",
62672
62879
  "@graphql-tools/url-loader": "8.0.29",
62673
62880
  "@modelcontextprotocol/sdk": "1.6.1",
62674
- "@settlemint/sdk-js": "1.1.16-prc78f6086",
62675
- "@settlemint/sdk-utils": "1.1.16-prc78f6086",
62881
+ "@settlemint/sdk-js": "1.1.16-pre2559e50",
62882
+ "@settlemint/sdk-utils": "1.1.16-pre2559e50",
62676
62883
  "@commander-js/extra-typings": "13.1.0",
62884
+ commander: "13.1.0",
62677
62885
  zod: "3.24.2"
62678
62886
  },
62679
62887
  devDependencies: {},
@@ -63490,6 +63698,16 @@ var registerBlockchainConcepts = (server) => {
63490
63698
 
63491
63699
  // src/utils/sdl.ts
63492
63700
  var import_graphql53 = __toESM(require_graphql2(), 1);
63701
+ var processFieldTypes = (fields2, schema, collectedTypes) => {
63702
+ for (const field of Object.values(fields2)) {
63703
+ collectCustomTypes(field.type, schema, collectedTypes);
63704
+ if ("args" in field && field.args.length > 0) {
63705
+ for (const arg of field.args) {
63706
+ collectCustomTypes(arg.type, schema, collectedTypes);
63707
+ }
63708
+ }
63709
+ }
63710
+ };
63493
63711
  var collectCustomTypes = (type, schema, collectedTypes = new Set) => {
63494
63712
  const typeName = type.toString().replace(/[\[\]!]/g, "");
63495
63713
  if (collectedTypes.has(typeName) || ["String", "Int", "Float", "Boolean", "ID"].includes(typeName)) {
@@ -63500,20 +63718,9 @@ var collectCustomTypes = (type, schema, collectedTypes = new Set) => {
63500
63718
  return collectedTypes;
63501
63719
  }
63502
63720
  collectedTypes.add(typeName);
63503
- if (import_graphql53.isInputObjectType(schemaType)) {
63721
+ if (import_graphql53.isInputObjectType(schemaType) || import_graphql53.isObjectType(schemaType)) {
63504
63722
  const fields2 = schemaType.getFields();
63505
- for (const field of Object.values(fields2)) {
63506
- collectCustomTypes(field.type, schema, collectedTypes);
63507
- }
63508
- }
63509
- if (import_graphql53.isObjectType(schemaType)) {
63510
- const fields2 = schemaType.getFields();
63511
- for (const field of Object.values(fields2)) {
63512
- collectCustomTypes(field.type, schema, collectedTypes);
63513
- for (const arg of field.args) {
63514
- collectCustomTypes(arg.type, schema, collectedTypes);
63515
- }
63516
- }
63723
+ processFieldTypes(fields2, schema, collectedTypes);
63517
63724
  }
63518
63725
  return collectedTypes;
63519
63726
  };
@@ -64474,16 +64681,14 @@ function blockString(e4) {
64474
64681
  function ignored() {
64475
64682
  for (var e4 = 0 | i.charCodeAt(n++);e4 === 9 || e4 === 10 || e4 === 13 || e4 === 32 || e4 === 35 || e4 === 44 || e4 === 65279; e4 = 0 | i.charCodeAt(n++)) {
64476
64683
  if (e4 === 35) {
64477
- for (;(e4 = i.charCodeAt(n++)) !== 10 && e4 !== 13; ) {
64478
- }
64684
+ for (;(e4 = i.charCodeAt(n++)) !== 10 && e4 !== 13; ) {}
64479
64685
  }
64480
64686
  }
64481
64687
  n--;
64482
64688
  }
64483
64689
  function name() {
64484
64690
  var e4 = n;
64485
- for (var r = 0 | i.charCodeAt(n++);r >= 48 && r <= 57 || r >= 65 && r <= 90 || r === 95 || r >= 97 && r <= 122; r = 0 | i.charCodeAt(n++)) {
64486
- }
64691
+ for (var r = 0 | i.charCodeAt(n++);r >= 48 && r <= 57 || r >= 65 && r <= 90 || r === 95 || r >= 97 && r <= 122; r = 0 | i.charCodeAt(n++)) {}
64487
64692
  if (e4 === n - 1) {
64488
64693
  throw error("Name");
64489
64694
  }
@@ -64552,8 +64757,7 @@ function value(e4) {
64552
64757
  var s;
64553
64758
  n++;
64554
64759
  var c = false;
64555
- for (s = 0 | i.charCodeAt(n++);s === 92 && (n++, c = true) || s !== 10 && s !== 13 && s !== 34 && s; s = 0 | i.charCodeAt(n++)) {
64556
- }
64760
+ for (s = 0 | i.charCodeAt(n++);s === 92 && (n++, c = true) || s !== 10 && s !== 13 && s !== 34 && s; s = 0 | i.charCodeAt(n++)) {}
64557
64761
  if (s !== 34) {
64558
64762
  throw error("StringValue");
64559
64763
  }
@@ -64576,8 +64780,7 @@ function value(e4) {
64576
64780
  case 57:
64577
64781
  var v = n++;
64578
64782
  var f;
64579
- for (;(f = 0 | i.charCodeAt(n++)) >= 48 && f <= 57; ) {
64580
- }
64783
+ for (;(f = 0 | i.charCodeAt(n++)) >= 48 && f <= 57; ) {}
64581
64784
  var m = i.slice(v, --n);
64582
64785
  if ((f = i.charCodeAt(n)) === 46 || f === 69 || f === 101) {
64583
64786
  if ((r = advance(o)) == null) {
@@ -68345,4 +68548,4 @@ main().catch((error2) => {
68345
68548
  process.exit(1);
68346
68549
  });
68347
68550
 
68348
- //# debugId=6505AA9D00AFCA6F64756E2164756E21
68551
+ //# debugId=9465151886B8226464756E2164756E21