@modern-js/upgrade-generator 3.0.11 → 3.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +1161 -909
  2. package/package.json +8 -8
package/dist/index.js CHANGED
@@ -134434,55 +134434,58 @@ var require_recursive_readdir2 = __commonJS({
134434
134434
  var require_commander2 = __commonJS({
134435
134435
  "../../../toolkit/utils/compiled/commander/index.js"(exports, module2) {
134436
134436
  (() => {
134437
- var e = { 81: (e2) => {
134437
+ var t = { 81: (t2) => {
134438
134438
  "use strict";
134439
- e2.exports = require("child_process");
134440
- }, 361: (e2) => {
134439
+ t2.exports = require("child_process");
134440
+ }, 361: (t2) => {
134441
134441
  "use strict";
134442
- e2.exports = require("events");
134443
- }, 147: (e2) => {
134442
+ t2.exports = require("events");
134443
+ }, 147: (t2) => {
134444
134444
  "use strict";
134445
- e2.exports = require("fs");
134446
- }, 17: (e2) => {
134445
+ t2.exports = require("fs");
134446
+ }, 17: (t2) => {
134447
134447
  "use strict";
134448
- e2.exports = require("path");
134449
- }, 922: (e2, t2, i2) => {
134450
- const { Argument: n } = i2(969);
134451
- const { Command: s } = i2(694);
134452
- const { CommanderError: r, InvalidArgumentError: o } = i2(967);
134453
- const { Help: a } = i2(34);
134454
- const { Option: h } = i2(278);
134455
- t2 = e2.exports = new s();
134456
- t2.program = t2;
134457
- t2.Argument = n;
134458
- t2.Command = s;
134459
- t2.CommanderError = r;
134460
- t2.Help = a;
134461
- t2.InvalidArgumentError = o;
134462
- t2.InvalidOptionArgumentError = o;
134463
- t2.Option = h;
134464
- }, 969: (e2, t2, i2) => {
134465
- const { InvalidArgumentError: n } = i2(967);
134448
+ t2.exports = require("path");
134449
+ }, 282: (t2) => {
134450
+ "use strict";
134451
+ t2.exports = require("process");
134452
+ }, 632: (t2, e2, i2) => {
134453
+ const { Argument: n } = i2(535);
134454
+ const { Command: s } = i2(302);
134455
+ const { CommanderError: r, InvalidArgumentError: o } = i2(796);
134456
+ const { Help: a } = i2(519);
134457
+ const { Option: l } = i2(437);
134458
+ e2 = t2.exports = new s();
134459
+ e2.program = e2;
134460
+ e2.Argument = n;
134461
+ e2.Command = s;
134462
+ e2.CommanderError = r;
134463
+ e2.Help = a;
134464
+ e2.InvalidArgumentError = o;
134465
+ e2.InvalidOptionArgumentError = o;
134466
+ e2.Option = l;
134467
+ }, 535: (t2, e2, i2) => {
134468
+ const { InvalidArgumentError: n } = i2(796);
134466
134469
  class Argument {
134467
- constructor(e3, t3) {
134468
- this.description = t3 || "";
134470
+ constructor(t3, e3) {
134471
+ this.description = e3 || "";
134469
134472
  this.variadic = false;
134470
134473
  this.parseArg = void 0;
134471
134474
  this.defaultValue = void 0;
134472
134475
  this.defaultValueDescription = void 0;
134473
134476
  this.argChoices = void 0;
134474
- switch (e3[0]) {
134477
+ switch (t3[0]) {
134475
134478
  case "<":
134476
134479
  this.required = true;
134477
- this._name = e3.slice(1, -1);
134480
+ this._name = t3.slice(1, -1);
134478
134481
  break;
134479
134482
  case "[":
134480
134483
  this.required = false;
134481
- this._name = e3.slice(1, -1);
134484
+ this._name = t3.slice(1, -1);
134482
134485
  break;
134483
134486
  default:
134484
134487
  this.required = true;
134485
- this._name = e3;
134488
+ this._name = t3;
134486
134489
  break;
134487
134490
  }
134488
134491
  if (this._name.length > 3 && this._name.slice(-3) === "...") {
@@ -134493,31 +134496,31 @@ var require_commander2 = __commonJS({
134493
134496
  name() {
134494
134497
  return this._name;
134495
134498
  }
134496
- _concatValue(e3, t3) {
134497
- if (t3 === this.defaultValue || !Array.isArray(t3)) {
134498
- return [e3];
134499
+ _concatValue(t3, e3) {
134500
+ if (e3 === this.defaultValue || !Array.isArray(e3)) {
134501
+ return [t3];
134499
134502
  }
134500
- return t3.concat(e3);
134503
+ return e3.concat(t3);
134501
134504
  }
134502
- default(e3, t3) {
134503
- this.defaultValue = e3;
134504
- this.defaultValueDescription = t3;
134505
+ default(t3, e3) {
134506
+ this.defaultValue = t3;
134507
+ this.defaultValueDescription = e3;
134505
134508
  return this;
134506
134509
  }
134507
- argParser(e3) {
134508
- this.parseArg = e3;
134510
+ argParser(t3) {
134511
+ this.parseArg = t3;
134509
134512
  return this;
134510
134513
  }
134511
- choices(e3) {
134512
- this.argChoices = e3;
134513
- this.parseArg = (t3, i3) => {
134514
- if (!e3.includes(t3)) {
134515
- throw new n(`Allowed choices are ${e3.join(", ")}.`);
134514
+ choices(t3) {
134515
+ this.argChoices = t3.slice();
134516
+ this.parseArg = (t4, e3) => {
134517
+ if (!this.argChoices.includes(t4)) {
134518
+ throw new n(`Allowed choices are ${this.argChoices.join(", ")}.`);
134516
134519
  }
134517
134520
  if (this.variadic) {
134518
- return this._concatValue(t3, i3);
134521
+ return this._concatValue(t4, e3);
134519
134522
  }
134520
- return t3;
134523
+ return t4;
134521
134524
  };
134522
134525
  return this;
134523
134526
  }
@@ -134530,24 +134533,25 @@ var require_commander2 = __commonJS({
134530
134533
  return this;
134531
134534
  }
134532
134535
  }
134533
- function humanReadableArgName(e3) {
134534
- const t3 = e3.name() + (e3.variadic === true ? "..." : "");
134535
- return e3.required ? "<" + t3 + ">" : "[" + t3 + "]";
134536
+ function humanReadableArgName(t3) {
134537
+ const e3 = t3.name() + (t3.variadic === true ? "..." : "");
134538
+ return t3.required ? "<" + e3 + ">" : "[" + e3 + "]";
134536
134539
  }
134537
- t2.Argument = Argument;
134538
- t2.humanReadableArgName = humanReadableArgName;
134539
- }, 694: (e2, t2, i2) => {
134540
+ e2.Argument = Argument;
134541
+ e2.humanReadableArgName = humanReadableArgName;
134542
+ }, 302: (t2, e2, i2) => {
134540
134543
  const n = i2(361).EventEmitter;
134541
134544
  const s = i2(81);
134542
134545
  const r = i2(17);
134543
134546
  const o = i2(147);
134544
- const { Argument: a, humanReadableArgName: h } = i2(969);
134545
- const { CommanderError: l } = i2(967);
134546
- const { Help: u } = i2(34);
134547
- const { Option: c, splitOptionFlags: p } = i2(278);
134548
- const { suggestSimilar: m } = i2(461);
134547
+ const a = i2(282);
134548
+ const { Argument: l, humanReadableArgName: h } = i2(535);
134549
+ const { CommanderError: u } = i2(796);
134550
+ const { Help: c } = i2(519);
134551
+ const { Option: p, splitOptionFlags: m, DualOptions: d } = i2(437);
134552
+ const { suggestSimilar: f } = i2(860);
134549
134553
  class Command2 extends n {
134550
- constructor(e3) {
134554
+ constructor(t3) {
134551
134555
  super();
134552
134556
  this.commands = [];
134553
134557
  this.options = [];
@@ -134559,25 +134563,27 @@ var require_commander2 = __commonJS({
134559
134563
  this.rawArgs = [];
134560
134564
  this.processedArgs = [];
134561
134565
  this._scriptPath = null;
134562
- this._name = e3 || "";
134566
+ this._name = t3 || "";
134563
134567
  this._optionValues = {};
134564
134568
  this._optionValueSources = {};
134565
134569
  this._storeOptionsAsProperties = false;
134566
134570
  this._actionHandler = null;
134567
134571
  this._executableHandler = false;
134568
134572
  this._executableFile = null;
134573
+ this._executableDir = null;
134569
134574
  this._defaultCommandName = null;
134570
134575
  this._exitCallback = null;
134571
134576
  this._aliases = [];
134572
134577
  this._combineFlagAndOptionalValue = true;
134573
134578
  this._description = "";
134579
+ this._summary = "";
134574
134580
  this._argsDescription = void 0;
134575
134581
  this._enablePositionalOptions = false;
134576
134582
  this._passThroughOptions = false;
134577
134583
  this._lifeCycleHooks = {};
134578
134584
  this._showHelpAfterError = false;
134579
- this._showSuggestionAfterError = false;
134580
- this._outputConfiguration = { writeOut: (e4) => process.stdout.write(e4), writeErr: (e4) => process.stderr.write(e4), getOutHelpWidth: () => process.stdout.isTTY ? process.stdout.columns : void 0, getErrHelpWidth: () => process.stderr.isTTY ? process.stderr.columns : void 0, outputError: (e4, t3) => t3(e4) };
134585
+ this._showSuggestionAfterError = true;
134586
+ this._outputConfiguration = { writeOut: (t4) => a.stdout.write(t4), writeErr: (t4) => a.stderr.write(t4), getOutHelpWidth: () => a.stdout.isTTY ? a.stdout.columns : void 0, getErrHelpWidth: () => a.stderr.isTTY ? a.stderr.columns : void 0, outputError: (t4, e3) => e3(t4) };
134581
134587
  this._hidden = false;
134582
134588
  this._hasHelpOption = true;
134583
134589
  this._helpFlags = "-h, --help";
@@ -134590,35 +134596,35 @@ var require_commander2 = __commonJS({
134590
134596
  this._helpCommandDescription = "display help for command";
134591
134597
  this._helpConfiguration = {};
134592
134598
  }
134593
- copyInheritedSettings(e3) {
134594
- this._outputConfiguration = e3._outputConfiguration;
134595
- this._hasHelpOption = e3._hasHelpOption;
134596
- this._helpFlags = e3._helpFlags;
134597
- this._helpDescription = e3._helpDescription;
134598
- this._helpShortFlag = e3._helpShortFlag;
134599
- this._helpLongFlag = e3._helpLongFlag;
134600
- this._helpCommandName = e3._helpCommandName;
134601
- this._helpCommandnameAndArgs = e3._helpCommandnameAndArgs;
134602
- this._helpCommandDescription = e3._helpCommandDescription;
134603
- this._helpConfiguration = e3._helpConfiguration;
134604
- this._exitCallback = e3._exitCallback;
134605
- this._storeOptionsAsProperties = e3._storeOptionsAsProperties;
134606
- this._combineFlagAndOptionalValue = e3._combineFlagAndOptionalValue;
134607
- this._allowExcessArguments = e3._allowExcessArguments;
134608
- this._enablePositionalOptions = e3._enablePositionalOptions;
134609
- this._showHelpAfterError = e3._showHelpAfterError;
134610
- this._showSuggestionAfterError = e3._showSuggestionAfterError;
134599
+ copyInheritedSettings(t3) {
134600
+ this._outputConfiguration = t3._outputConfiguration;
134601
+ this._hasHelpOption = t3._hasHelpOption;
134602
+ this._helpFlags = t3._helpFlags;
134603
+ this._helpDescription = t3._helpDescription;
134604
+ this._helpShortFlag = t3._helpShortFlag;
134605
+ this._helpLongFlag = t3._helpLongFlag;
134606
+ this._helpCommandName = t3._helpCommandName;
134607
+ this._helpCommandnameAndArgs = t3._helpCommandnameAndArgs;
134608
+ this._helpCommandDescription = t3._helpCommandDescription;
134609
+ this._helpConfiguration = t3._helpConfiguration;
134610
+ this._exitCallback = t3._exitCallback;
134611
+ this._storeOptionsAsProperties = t3._storeOptionsAsProperties;
134612
+ this._combineFlagAndOptionalValue = t3._combineFlagAndOptionalValue;
134613
+ this._allowExcessArguments = t3._allowExcessArguments;
134614
+ this._enablePositionalOptions = t3._enablePositionalOptions;
134615
+ this._showHelpAfterError = t3._showHelpAfterError;
134616
+ this._showSuggestionAfterError = t3._showSuggestionAfterError;
134611
134617
  return this;
134612
134618
  }
134613
- command(e3, t3, i3) {
134614
- let n2 = t3;
134619
+ command(t3, e3, i3) {
134620
+ let n2 = e3;
134615
134621
  let s2 = i3;
134616
134622
  if (typeof n2 === "object" && n2 !== null) {
134617
134623
  s2 = n2;
134618
134624
  n2 = null;
134619
134625
  }
134620
134626
  s2 = s2 || {};
134621
- const [, r2, o2] = e3.match(/([^ ]+) *(.*)/);
134627
+ const [, r2, o2] = t3.match(/([^ ]+) *(.*)/);
134622
134628
  const a2 = this.createCommand(r2);
134623
134629
  if (n2) {
134624
134630
  a2.description(n2);
@@ -134637,60 +134643,53 @@ var require_commander2 = __commonJS({
134637
134643
  return this;
134638
134644
  return a2;
134639
134645
  }
134640
- createCommand(e3) {
134641
- return new Command2(e3);
134646
+ createCommand(t3) {
134647
+ return new Command2(t3);
134642
134648
  }
134643
134649
  createHelp() {
134644
- return Object.assign(new u(), this.configureHelp());
134650
+ return Object.assign(new c(), this.configureHelp());
134645
134651
  }
134646
- configureHelp(e3) {
134647
- if (e3 === void 0)
134652
+ configureHelp(t3) {
134653
+ if (t3 === void 0)
134648
134654
  return this._helpConfiguration;
134649
- this._helpConfiguration = e3;
134655
+ this._helpConfiguration = t3;
134650
134656
  return this;
134651
134657
  }
134652
- configureOutput(e3) {
134653
- if (e3 === void 0)
134658
+ configureOutput(t3) {
134659
+ if (t3 === void 0)
134654
134660
  return this._outputConfiguration;
134655
- Object.assign(this._outputConfiguration, e3);
134661
+ Object.assign(this._outputConfiguration, t3);
134656
134662
  return this;
134657
134663
  }
134658
- showHelpAfterError(e3 = true) {
134659
- if (typeof e3 !== "string")
134660
- e3 = !!e3;
134661
- this._showHelpAfterError = e3;
134664
+ showHelpAfterError(t3 = true) {
134665
+ if (typeof t3 !== "string")
134666
+ t3 = !!t3;
134667
+ this._showHelpAfterError = t3;
134662
134668
  return this;
134663
134669
  }
134664
- showSuggestionAfterError(e3 = true) {
134665
- this._showSuggestionAfterError = !!e3;
134670
+ showSuggestionAfterError(t3 = true) {
134671
+ this._showSuggestionAfterError = !!t3;
134666
134672
  return this;
134667
134673
  }
134668
- addCommand(e3, t3) {
134669
- if (!e3._name)
134670
- throw new Error("Command passed to .addCommand() must have a name");
134671
- function checkExplicitNames(e4) {
134672
- e4.forEach((e5) => {
134673
- if (e5._executableHandler && !e5._executableFile) {
134674
- throw new Error(`Must specify executableFile for deeply nested executable: ${e5.name()}`);
134675
- }
134676
- checkExplicitNames(e5.commands);
134677
- });
134674
+ addCommand(t3, e3) {
134675
+ if (!t3._name) {
134676
+ throw new Error(`Command passed to .addCommand() must have a name
134677
+ - specify the name in Command constructor or using .name()`);
134678
134678
  }
134679
- checkExplicitNames(e3.commands);
134680
- t3 = t3 || {};
134681
- if (t3.isDefault)
134682
- this._defaultCommandName = e3._name;
134683
- if (t3.noHelp || t3.hidden)
134684
- e3._hidden = true;
134685
- this.commands.push(e3);
134686
- e3.parent = this;
134679
+ e3 = e3 || {};
134680
+ if (e3.isDefault)
134681
+ this._defaultCommandName = t3._name;
134682
+ if (e3.noHelp || e3.hidden)
134683
+ t3._hidden = true;
134684
+ this.commands.push(t3);
134685
+ t3.parent = this;
134687
134686
  return this;
134688
134687
  }
134689
- createArgument(e3, t3) {
134690
- return new a(e3, t3);
134688
+ createArgument(t3, e3) {
134689
+ return new l(t3, e3);
134691
134690
  }
134692
- argument(e3, t3, i3, n2) {
134693
- const s2 = this.createArgument(e3, t3);
134691
+ argument(t3, e3, i3, n2) {
134692
+ const s2 = this.createArgument(t3, e3);
134694
134693
  if (typeof i3 === "function") {
134695
134694
  s2.default(n2).argParser(i3);
134696
134695
  } else {
@@ -134699,33 +134698,33 @@ var require_commander2 = __commonJS({
134699
134698
  this.addArgument(s2);
134700
134699
  return this;
134701
134700
  }
134702
- arguments(e3) {
134703
- e3.split(/ +/).forEach((e4) => {
134704
- this.argument(e4);
134701
+ arguments(t3) {
134702
+ t3.split(/ +/).forEach((t4) => {
134703
+ this.argument(t4);
134705
134704
  });
134706
134705
  return this;
134707
134706
  }
134708
- addArgument(e3) {
134709
- const t3 = this._args.slice(-1)[0];
134710
- if (t3 && t3.variadic) {
134711
- throw new Error(`only the last argument can be variadic '${t3.name()}'`);
134707
+ addArgument(t3) {
134708
+ const e3 = this._args.slice(-1)[0];
134709
+ if (e3 && e3.variadic) {
134710
+ throw new Error(`only the last argument can be variadic '${e3.name()}'`);
134712
134711
  }
134713
- if (e3.required && e3.defaultValue !== void 0 && e3.parseArg === void 0) {
134714
- throw new Error(`a default value for a required argument is never used: '${e3.name()}'`);
134712
+ if (t3.required && t3.defaultValue !== void 0 && t3.parseArg === void 0) {
134713
+ throw new Error(`a default value for a required argument is never used: '${t3.name()}'`);
134715
134714
  }
134716
- this._args.push(e3);
134715
+ this._args.push(t3);
134717
134716
  return this;
134718
134717
  }
134719
- addHelpCommand(e3, t3) {
134720
- if (e3 === false) {
134718
+ addHelpCommand(t3, e3) {
134719
+ if (t3 === false) {
134721
134720
  this._addImplicitHelpCommand = false;
134722
134721
  } else {
134723
134722
  this._addImplicitHelpCommand = true;
134724
- if (typeof e3 === "string") {
134725
- this._helpCommandName = e3.split(" ")[0];
134726
- this._helpCommandnameAndArgs = e3;
134723
+ if (typeof t3 === "string") {
134724
+ this._helpCommandName = t3.split(" ")[0];
134725
+ this._helpCommandnameAndArgs = t3;
134727
134726
  }
134728
- this._helpCommandDescription = t3 || this._helpCommandDescription;
134727
+ this._helpCommandDescription = e3 || this._helpCommandDescription;
134729
134728
  }
134730
134729
  return this;
134731
134730
  }
@@ -134735,116 +134734,121 @@ var require_commander2 = __commonJS({
134735
134734
  }
134736
134735
  return this._addImplicitHelpCommand;
134737
134736
  }
134738
- hook(e3, t3) {
134739
- const i3 = ["preAction", "postAction"];
134740
- if (!i3.includes(e3)) {
134741
- throw new Error(`Unexpected value for event passed to hook : '${e3}'.
134737
+ hook(t3, e3) {
134738
+ const i3 = ["preSubcommand", "preAction", "postAction"];
134739
+ if (!i3.includes(t3)) {
134740
+ throw new Error(`Unexpected value for event passed to hook : '${t3}'.
134742
134741
  Expecting one of '${i3.join("', '")}'`);
134743
134742
  }
134744
- if (this._lifeCycleHooks[e3]) {
134745
- this._lifeCycleHooks[e3].push(t3);
134743
+ if (this._lifeCycleHooks[t3]) {
134744
+ this._lifeCycleHooks[t3].push(e3);
134746
134745
  } else {
134747
- this._lifeCycleHooks[e3] = [t3];
134746
+ this._lifeCycleHooks[t3] = [e3];
134748
134747
  }
134749
134748
  return this;
134750
134749
  }
134751
- exitOverride(e3) {
134752
- if (e3) {
134753
- this._exitCallback = e3;
134750
+ exitOverride(t3) {
134751
+ if (t3) {
134752
+ this._exitCallback = t3;
134754
134753
  } else {
134755
- this._exitCallback = (e4) => {
134756
- if (e4.code !== "commander.executeSubCommandAsync") {
134757
- throw e4;
134754
+ this._exitCallback = (t4) => {
134755
+ if (t4.code !== "commander.executeSubCommandAsync") {
134756
+ throw t4;
134758
134757
  } else {
134759
134758
  }
134760
134759
  };
134761
134760
  }
134762
134761
  return this;
134763
134762
  }
134764
- _exit(e3, t3, i3) {
134763
+ _exit(t3, e3, i3) {
134765
134764
  if (this._exitCallback) {
134766
- this._exitCallback(new l(e3, t3, i3));
134765
+ this._exitCallback(new u(t3, e3, i3));
134767
134766
  }
134768
- process.exit(e3);
134767
+ a.exit(t3);
134769
134768
  }
134770
- action(e3) {
134771
- const listener = (t3) => {
134769
+ action(t3) {
134770
+ const listener = (e3) => {
134772
134771
  const i3 = this._args.length;
134773
- const n2 = t3.slice(0, i3);
134772
+ const n2 = e3.slice(0, i3);
134774
134773
  if (this._storeOptionsAsProperties) {
134775
134774
  n2[i3] = this;
134776
134775
  } else {
134777
134776
  n2[i3] = this.opts();
134778
134777
  }
134779
134778
  n2.push(this);
134780
- return e3.apply(this, n2);
134779
+ return t3.apply(this, n2);
134781
134780
  };
134782
134781
  this._actionHandler = listener;
134783
134782
  return this;
134784
134783
  }
134785
- createOption(e3, t3) {
134786
- return new c(e3, t3);
134784
+ createOption(t3, e3) {
134785
+ return new p(t3, e3);
134787
134786
  }
134788
- addOption(e3) {
134789
- const t3 = e3.name();
134790
- const i3 = e3.attributeName();
134791
- let n2 = e3.defaultValue;
134792
- if (e3.negate || e3.optional || e3.required || typeof n2 === "boolean") {
134793
- if (e3.negate) {
134794
- const t4 = e3.long.replace(/^--no-/, "--");
134795
- n2 = this._findOption(t4) ? this.getOptionValue(i3) : true;
134796
- }
134797
- if (n2 !== void 0) {
134798
- this.setOptionValueWithSource(i3, n2, "default");
134787
+ addOption(t3) {
134788
+ const e3 = t3.name();
134789
+ const i3 = t3.attributeName();
134790
+ if (t3.negate) {
134791
+ const e4 = t3.long.replace(/^--no-/, "--");
134792
+ if (!this._findOption(e4)) {
134793
+ this.setOptionValueWithSource(i3, t3.defaultValue === void 0 ? true : t3.defaultValue, "default");
134799
134794
  }
134795
+ } else if (t3.defaultValue !== void 0) {
134796
+ this.setOptionValueWithSource(i3, t3.defaultValue, "default");
134800
134797
  }
134801
- this.options.push(e3);
134802
- const handleOptionValue = (t4, s2, r2) => {
134803
- const o2 = this.getOptionValue(i3);
134804
- if (t4 !== null && e3.parseArg) {
134798
+ this.options.push(t3);
134799
+ const handleOptionValue = (e4, n2, s2) => {
134800
+ if (e4 == null && t3.presetArg !== void 0) {
134801
+ e4 = t3.presetArg;
134802
+ }
134803
+ const r2 = this.getOptionValue(i3);
134804
+ if (e4 !== null && t3.parseArg) {
134805
134805
  try {
134806
- t4 = e3.parseArg(t4, o2 === void 0 ? n2 : o2);
134807
- } catch (e4) {
134808
- if (e4.code === "commander.invalidArgument") {
134809
- const t5 = `${s2} ${e4.message}`;
134810
- this._displayError(e4.exitCode, e4.code, t5);
134806
+ e4 = t3.parseArg(e4, r2);
134807
+ } catch (t4) {
134808
+ if (t4.code === "commander.invalidArgument") {
134809
+ const e5 = `${n2} ${t4.message}`;
134810
+ this.error(e5, { exitCode: t4.exitCode, code: t4.code });
134811
134811
  }
134812
- throw e4;
134812
+ throw t4;
134813
134813
  }
134814
- } else if (t4 !== null && e3.variadic) {
134815
- t4 = e3._concatValue(t4, o2);
134814
+ } else if (e4 !== null && t3.variadic) {
134815
+ e4 = t3._concatValue(e4, r2);
134816
134816
  }
134817
- if (typeof o2 === "boolean" || typeof o2 === "undefined") {
134818
- if (t4 == null) {
134819
- this.setOptionValueWithSource(i3, e3.negate ? false : n2 || true, r2);
134817
+ if (e4 == null) {
134818
+ if (t3.negate) {
134819
+ e4 = false;
134820
+ } else if (t3.isBoolean() || t3.optional) {
134821
+ e4 = true;
134820
134822
  } else {
134821
- this.setOptionValueWithSource(i3, t4, r2);
134823
+ e4 = "";
134822
134824
  }
134823
- } else if (t4 !== null) {
134824
- this.setOptionValueWithSource(i3, e3.negate ? false : t4, r2);
134825
134825
  }
134826
+ this.setOptionValueWithSource(i3, e4, s2);
134826
134827
  };
134827
- this.on("option:" + t3, (t4) => {
134828
- const i4 = `error: option '${e3.flags}' argument '${t4}' is invalid.`;
134829
- handleOptionValue(t4, i4, "cli");
134828
+ this.on("option:" + e3, (e4) => {
134829
+ const i4 = `error: option '${t3.flags}' argument '${e4}' is invalid.`;
134830
+ handleOptionValue(e4, i4, "cli");
134830
134831
  });
134831
- if (e3.envVar) {
134832
- this.on("optionEnv:" + t3, (t4) => {
134833
- const i4 = `error: option '${e3.flags}' value '${t4}' from env '${e3.envVar}' is invalid.`;
134834
- handleOptionValue(t4, i4, "env");
134832
+ if (t3.envVar) {
134833
+ this.on("optionEnv:" + e3, (e4) => {
134834
+ const i4 = `error: option '${t3.flags}' value '${e4}' from env '${t3.envVar}' is invalid.`;
134835
+ handleOptionValue(e4, i4, "env");
134835
134836
  });
134836
134837
  }
134837
134838
  return this;
134838
134839
  }
134839
- _optionEx(e3, t3, i3, n2, s2) {
134840
- const r2 = this.createOption(t3, i3);
134841
- r2.makeOptionMandatory(!!e3.mandatory);
134840
+ _optionEx(t3, e3, i3, n2, s2) {
134841
+ if (typeof e3 === "object" && e3 instanceof p) {
134842
+ throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");
134843
+ }
134844
+ const r2 = this.createOption(e3, i3);
134845
+ r2.makeOptionMandatory(!!t3.mandatory);
134842
134846
  if (typeof n2 === "function") {
134843
134847
  r2.default(s2).argParser(n2);
134844
134848
  } else if (n2 instanceof RegExp) {
134845
- const e4 = n2;
134846
- n2 = (t4, i4) => {
134847
- const n3 = e4.exec(t4);
134849
+ const t4 = n2;
134850
+ n2 = (e4, i4) => {
134851
+ const n3 = t4.exec(e4);
134848
134852
  return n3 ? n3[0] : i4;
134849
134853
  };
134850
134854
  r2.default(s2).argParser(n2);
@@ -134853,209 +134857,233 @@ Expecting one of '${i3.join("', '")}'`);
134853
134857
  }
134854
134858
  return this.addOption(r2);
134855
134859
  }
134856
- option(e3, t3, i3, n2) {
134857
- return this._optionEx({}, e3, t3, i3, n2);
134860
+ option(t3, e3, i3, n2) {
134861
+ return this._optionEx({}, t3, e3, i3, n2);
134858
134862
  }
134859
- requiredOption(e3, t3, i3, n2) {
134860
- return this._optionEx({ mandatory: true }, e3, t3, i3, n2);
134863
+ requiredOption(t3, e3, i3, n2) {
134864
+ return this._optionEx({ mandatory: true }, t3, e3, i3, n2);
134861
134865
  }
134862
- combineFlagAndOptionalValue(e3 = true) {
134863
- this._combineFlagAndOptionalValue = !!e3;
134866
+ combineFlagAndOptionalValue(t3 = true) {
134867
+ this._combineFlagAndOptionalValue = !!t3;
134864
134868
  return this;
134865
134869
  }
134866
- allowUnknownOption(e3 = true) {
134867
- this._allowUnknownOption = !!e3;
134870
+ allowUnknownOption(t3 = true) {
134871
+ this._allowUnknownOption = !!t3;
134868
134872
  return this;
134869
134873
  }
134870
- allowExcessArguments(e3 = true) {
134871
- this._allowExcessArguments = !!e3;
134874
+ allowExcessArguments(t3 = true) {
134875
+ this._allowExcessArguments = !!t3;
134872
134876
  return this;
134873
134877
  }
134874
- enablePositionalOptions(e3 = true) {
134875
- this._enablePositionalOptions = !!e3;
134878
+ enablePositionalOptions(t3 = true) {
134879
+ this._enablePositionalOptions = !!t3;
134876
134880
  return this;
134877
134881
  }
134878
- passThroughOptions(e3 = true) {
134879
- this._passThroughOptions = !!e3;
134880
- if (!!this.parent && e3 && !this.parent._enablePositionalOptions) {
134882
+ passThroughOptions(t3 = true) {
134883
+ this._passThroughOptions = !!t3;
134884
+ if (!!this.parent && t3 && !this.parent._enablePositionalOptions) {
134881
134885
  throw new Error("passThroughOptions can not be used without turning on enablePositionalOptions for parent command(s)");
134882
134886
  }
134883
134887
  return this;
134884
134888
  }
134885
- storeOptionsAsProperties(e3 = true) {
134886
- this._storeOptionsAsProperties = !!e3;
134889
+ storeOptionsAsProperties(t3 = true) {
134890
+ this._storeOptionsAsProperties = !!t3;
134887
134891
  if (this.options.length) {
134888
134892
  throw new Error("call .storeOptionsAsProperties() before adding options");
134889
134893
  }
134890
134894
  return this;
134891
134895
  }
134892
- getOptionValue(e3) {
134896
+ getOptionValue(t3) {
134893
134897
  if (this._storeOptionsAsProperties) {
134894
- return this[e3];
134898
+ return this[t3];
134895
134899
  }
134896
- return this._optionValues[e3];
134900
+ return this._optionValues[t3];
134897
134901
  }
134898
- setOptionValue(e3, t3) {
134902
+ setOptionValue(t3, e3) {
134903
+ return this.setOptionValueWithSource(t3, e3, void 0);
134904
+ }
134905
+ setOptionValueWithSource(t3, e3, i3) {
134899
134906
  if (this._storeOptionsAsProperties) {
134900
- this[e3] = t3;
134907
+ this[t3] = e3;
134901
134908
  } else {
134902
- this._optionValues[e3] = t3;
134909
+ this._optionValues[t3] = e3;
134903
134910
  }
134911
+ this._optionValueSources[t3] = i3;
134904
134912
  return this;
134905
134913
  }
134906
- setOptionValueWithSource(e3, t3, i3) {
134907
- this.setOptionValue(e3, t3);
134908
- this._optionValueSources[e3] = i3;
134909
- return this;
134914
+ getOptionValueSource(t3) {
134915
+ return this._optionValueSources[t3];
134910
134916
  }
134911
- getOptionValueSource(e3) {
134912
- return this._optionValueSources[e3];
134917
+ getOptionValueSourceWithGlobals(t3) {
134918
+ let e3;
134919
+ getCommandAndParents(this).forEach((i3) => {
134920
+ if (i3.getOptionValueSource(t3) !== void 0) {
134921
+ e3 = i3.getOptionValueSource(t3);
134922
+ }
134923
+ });
134924
+ return e3;
134913
134925
  }
134914
- _prepareUserArgs(e3, t3) {
134915
- if (e3 !== void 0 && !Array.isArray(e3)) {
134926
+ _prepareUserArgs(t3, e3) {
134927
+ if (t3 !== void 0 && !Array.isArray(t3)) {
134916
134928
  throw new Error("first parameter to parse must be array or undefined");
134917
134929
  }
134918
- t3 = t3 || {};
134919
- if (e3 === void 0) {
134920
- e3 = process.argv;
134921
- if (process.versions && process.versions.electron) {
134922
- t3.from = "electron";
134930
+ e3 = e3 || {};
134931
+ if (t3 === void 0) {
134932
+ t3 = a.argv;
134933
+ if (a.versions && a.versions.electron) {
134934
+ e3.from = "electron";
134923
134935
  }
134924
134936
  }
134925
- this.rawArgs = e3.slice();
134937
+ this.rawArgs = t3.slice();
134926
134938
  let i3;
134927
- switch (t3.from) {
134939
+ switch (e3.from) {
134928
134940
  case void 0:
134929
134941
  case "node":
134930
- this._scriptPath = e3[1];
134931
- i3 = e3.slice(2);
134942
+ this._scriptPath = t3[1];
134943
+ i3 = t3.slice(2);
134932
134944
  break;
134933
134945
  case "electron":
134934
- if (process.defaultApp) {
134935
- this._scriptPath = e3[1];
134936
- i3 = e3.slice(2);
134946
+ if (a.defaultApp) {
134947
+ this._scriptPath = t3[1];
134948
+ i3 = t3.slice(2);
134937
134949
  } else {
134938
- i3 = e3.slice(1);
134950
+ i3 = t3.slice(1);
134939
134951
  }
134940
134952
  break;
134941
134953
  case "user":
134942
- i3 = e3.slice(0);
134954
+ i3 = t3.slice(0);
134943
134955
  break;
134944
134956
  default:
134945
- throw new Error(`unexpected parse option { from: '${t3.from}' }`);
134957
+ throw new Error(`unexpected parse option { from: '${e3.from}' }`);
134946
134958
  }
134947
- if (!this._scriptPath && require.main) {
134948
- this._scriptPath = require.main.filename;
134949
- }
134950
- this._name = this._name || this._scriptPath && r.basename(this._scriptPath, r.extname(this._scriptPath));
134959
+ if (!this._name && this._scriptPath)
134960
+ this.nameFromFilename(this._scriptPath);
134961
+ this._name = this._name || "program";
134951
134962
  return i3;
134952
134963
  }
134953
- parse(e3, t3) {
134954
- const i3 = this._prepareUserArgs(e3, t3);
134964
+ parse(t3, e3) {
134965
+ const i3 = this._prepareUserArgs(t3, e3);
134955
134966
  this._parseCommand([], i3);
134956
134967
  return this;
134957
134968
  }
134958
- parseAsync(e3, t3) {
134969
+ parseAsync(t3, e3) {
134959
134970
  return __async(this, null, function* () {
134960
- const i3 = this._prepareUserArgs(e3, t3);
134971
+ const i3 = this._prepareUserArgs(t3, e3);
134961
134972
  yield this._parseCommand([], i3);
134962
134973
  return this;
134963
134974
  });
134964
134975
  }
134965
- _executeSubCommand(e3, t3) {
134966
- t3 = t3.slice();
134976
+ _executeSubCommand(t3, e3) {
134977
+ e3 = e3.slice();
134967
134978
  let i3 = false;
134968
134979
  const n2 = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
134969
- this._checkForMissingMandatoryOptions();
134970
- let a2 = this._scriptPath;
134971
- if (!a2 && require.main) {
134972
- a2 = require.main.filename;
134973
- }
134974
- let h2;
134975
- try {
134976
- const e4 = o.realpathSync(a2);
134977
- h2 = r.dirname(e4);
134978
- } catch (e4) {
134979
- h2 = ".";
134980
+ function findFile(t4, e4) {
134981
+ const i4 = r.resolve(t4, e4);
134982
+ if (o.existsSync(i4))
134983
+ return i4;
134984
+ if (n2.includes(r.extname(e4)))
134985
+ return void 0;
134986
+ const s2 = n2.find((t5) => o.existsSync(`${i4}${t5}`));
134987
+ if (s2)
134988
+ return `${i4}${s2}`;
134989
+ return void 0;
134980
134990
  }
134981
- let u2 = r.basename(a2, r.extname(a2)) + "-" + e3._name;
134982
- if (e3._executableFile) {
134983
- u2 = e3._executableFile;
134991
+ this._checkForMissingMandatoryOptions();
134992
+ this._checkForConflictingOptions();
134993
+ let l2 = t3._executableFile || `${this._name}-${t3._name}`;
134994
+ let h2 = this._executableDir || "";
134995
+ if (this._scriptPath) {
134996
+ let t4;
134997
+ try {
134998
+ t4 = o.realpathSync(this._scriptPath);
134999
+ } catch (e4) {
135000
+ t4 = this._scriptPath;
135001
+ }
135002
+ h2 = r.resolve(r.dirname(t4), h2);
134984
135003
  }
134985
- const c2 = r.join(h2, u2);
134986
- if (o.existsSync(c2)) {
134987
- u2 = c2;
134988
- } else {
134989
- n2.forEach((e4) => {
134990
- if (o.existsSync(`${c2}${e4}`)) {
134991
- u2 = `${c2}${e4}`;
135004
+ if (h2) {
135005
+ let e4 = findFile(h2, l2);
135006
+ if (!e4 && !t3._executableFile && this._scriptPath) {
135007
+ const i4 = r.basename(this._scriptPath, r.extname(this._scriptPath));
135008
+ if (i4 !== this._name) {
135009
+ e4 = findFile(h2, `${i4}-${t3._name}`);
134992
135010
  }
134993
- });
135011
+ }
135012
+ l2 = e4 || l2;
134994
135013
  }
134995
- i3 = n2.includes(r.extname(u2));
134996
- let p2;
134997
- if (process.platform !== "win32") {
135014
+ i3 = n2.includes(r.extname(l2));
135015
+ let c2;
135016
+ if (a.platform !== "win32") {
134998
135017
  if (i3) {
134999
- t3.unshift(u2);
135000
- t3 = incrementNodeInspectorPort(process.execArgv).concat(t3);
135001
- p2 = s.spawn(process.argv[0], t3, { stdio: "inherit" });
135018
+ e3.unshift(l2);
135019
+ e3 = incrementNodeInspectorPort(a.execArgv).concat(e3);
135020
+ c2 = s.spawn(a.argv[0], e3, { stdio: "inherit" });
135002
135021
  } else {
135003
- p2 = s.spawn(u2, t3, { stdio: "inherit" });
135022
+ c2 = s.spawn(l2, e3, { stdio: "inherit" });
135004
135023
  }
135005
135024
  } else {
135006
- t3.unshift(u2);
135007
- t3 = incrementNodeInspectorPort(process.execArgv).concat(t3);
135008
- p2 = s.spawn(process.execPath, t3, { stdio: "inherit" });
135009
- }
135010
- const m2 = ["SIGUSR1", "SIGUSR2", "SIGTERM", "SIGINT", "SIGHUP"];
135011
- m2.forEach((e4) => {
135012
- process.on(e4, () => {
135013
- if (p2.killed === false && p2.exitCode === null) {
135014
- p2.kill(e4);
135015
- }
135025
+ e3.unshift(l2);
135026
+ e3 = incrementNodeInspectorPort(a.execArgv).concat(e3);
135027
+ c2 = s.spawn(a.execPath, e3, { stdio: "inherit" });
135028
+ }
135029
+ if (!c2.killed) {
135030
+ const t4 = ["SIGUSR1", "SIGUSR2", "SIGTERM", "SIGINT", "SIGHUP"];
135031
+ t4.forEach((t5) => {
135032
+ a.on(t5, () => {
135033
+ if (c2.killed === false && c2.exitCode === null) {
135034
+ c2.kill(t5);
135035
+ }
135036
+ });
135016
135037
  });
135017
- });
135018
- const d = this._exitCallback;
135019
- if (!d) {
135020
- p2.on("close", process.exit.bind(process));
135038
+ }
135039
+ const p2 = this._exitCallback;
135040
+ if (!p2) {
135041
+ c2.on("close", a.exit.bind(a));
135021
135042
  } else {
135022
- p2.on("close", () => {
135023
- d(new l(process.exitCode || 0, "commander.executeSubCommandAsync", "(close)"));
135043
+ c2.on("close", () => {
135044
+ p2(new u(a.exitCode || 0, "commander.executeSubCommandAsync", "(close)"));
135024
135045
  });
135025
135046
  }
135026
- p2.on("error", (t4) => {
135027
- if (t4.code === "ENOENT") {
135028
- const t5 = `'${u2}' does not exist
135029
- - if '${e3._name}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
135030
- - if the default executable name is not suitable, use the executableFile option to supply a custom name`;
135031
- throw new Error(t5);
135032
- } else if (t4.code === "EACCES") {
135033
- throw new Error(`'${u2}' not executable`);
135034
- }
135035
- if (!d) {
135036
- process.exit(1);
135047
+ c2.on("error", (e4) => {
135048
+ if (e4.code === "ENOENT") {
135049
+ const e5 = h2 ? `searched for local subcommand relative to directory '${h2}'` : "no directory for search for local subcommand, use .executableDir() to supply a custom directory";
135050
+ const i4 = `'${l2}' does not exist
135051
+ - if '${t3._name}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
135052
+ - if the default executable name is not suitable, use the executableFile option to supply a custom name or path
135053
+ - ${e5}`;
135054
+ throw new Error(i4);
135055
+ } else if (e4.code === "EACCES") {
135056
+ throw new Error(`'${l2}' not executable`);
135057
+ }
135058
+ if (!p2) {
135059
+ a.exit(1);
135037
135060
  } else {
135038
- const e4 = new l(1, "commander.executeSubCommandAsync", "(error)");
135039
- e4.nestedError = t4;
135040
- d(e4);
135061
+ const t4 = new u(1, "commander.executeSubCommandAsync", "(error)");
135062
+ t4.nestedError = e4;
135063
+ p2(t4);
135041
135064
  }
135042
135065
  });
135043
- this.runningCommand = p2;
135066
+ this.runningCommand = c2;
135044
135067
  }
135045
- _dispatchSubcommand(e3, t3, i3) {
135046
- const n2 = this._findCommand(e3);
135068
+ _dispatchSubcommand(t3, e3, i3) {
135069
+ const n2 = this._findCommand(t3);
135047
135070
  if (!n2)
135048
135071
  this.help({ error: true });
135049
- if (n2._executableHandler) {
135050
- this._executeSubCommand(n2, t3.concat(i3));
135051
- } else {
135052
- return n2._parseCommand(t3, i3);
135053
- }
135072
+ let s2;
135073
+ s2 = this._chainOrCallSubCommandHook(s2, n2, "preSubcommand");
135074
+ s2 = this._chainOrCall(s2, () => {
135075
+ if (n2._executableHandler) {
135076
+ this._executeSubCommand(n2, e3.concat(i3));
135077
+ } else {
135078
+ return n2._parseCommand(e3, i3);
135079
+ }
135080
+ });
135081
+ return s2;
135054
135082
  }
135055
135083
  _checkNumberOfArguments() {
135056
- this._args.forEach((e3, t3) => {
135057
- if (e3.required && this.args[t3] == null) {
135058
- this.missingArgument(e3.name());
135084
+ this._args.forEach((t3, e3) => {
135085
+ if (t3.required && this.args[e3] == null) {
135086
+ this.missingArgument(t3.name());
135059
135087
  }
135060
135088
  });
135061
135089
  if (this._args.length > 0 && this._args[this._args.length - 1].variadic) {
@@ -135066,15 +135094,15 @@ Expecting one of '${i3.join("', '")}'`);
135066
135094
  }
135067
135095
  }
135068
135096
  _processArguments() {
135069
- const myParseArg = (e4, t3, i3) => {
135070
- let n2 = t3;
135071
- if (t3 !== null && e4.parseArg) {
135097
+ const myParseArg = (t4, e3, i3) => {
135098
+ let n2 = e3;
135099
+ if (e3 !== null && t4.parseArg) {
135072
135100
  try {
135073
- n2 = e4.parseArg(t3, i3);
135101
+ n2 = t4.parseArg(e3, i3);
135074
135102
  } catch (i4) {
135075
135103
  if (i4.code === "commander.invalidArgument") {
135076
- const n3 = `error: command-argument value '${t3}' is invalid for argument '${e4.name()}'. ${i4.message}`;
135077
- this._displayError(i4.exitCode, i4.code, n3);
135104
+ const n3 = `error: command-argument value '${e3}' is invalid for argument '${t4.name()}'. ${i4.message}`;
135105
+ this.error(n3, { exitCode: i4.exitCode, code: i4.code });
135078
135106
  }
135079
135107
  throw i4;
135080
135108
  }
@@ -135082,74 +135110,85 @@ Expecting one of '${i3.join("', '")}'`);
135082
135110
  return n2;
135083
135111
  };
135084
135112
  this._checkNumberOfArguments();
135085
- const e3 = [];
135086
- this._args.forEach((t3, i3) => {
135087
- let n2 = t3.defaultValue;
135088
- if (t3.variadic) {
135113
+ const t3 = [];
135114
+ this._args.forEach((e3, i3) => {
135115
+ let n2 = e3.defaultValue;
135116
+ if (e3.variadic) {
135089
135117
  if (i3 < this.args.length) {
135090
135118
  n2 = this.args.slice(i3);
135091
- if (t3.parseArg) {
135092
- n2 = n2.reduce((e4, i4) => myParseArg(t3, i4, e4), t3.defaultValue);
135119
+ if (e3.parseArg) {
135120
+ n2 = n2.reduce((t4, i4) => myParseArg(e3, i4, t4), e3.defaultValue);
135093
135121
  }
135094
135122
  } else if (n2 === void 0) {
135095
135123
  n2 = [];
135096
135124
  }
135097
135125
  } else if (i3 < this.args.length) {
135098
135126
  n2 = this.args[i3];
135099
- if (t3.parseArg) {
135100
- n2 = myParseArg(t3, n2, t3.defaultValue);
135127
+ if (e3.parseArg) {
135128
+ n2 = myParseArg(e3, n2, e3.defaultValue);
135101
135129
  }
135102
135130
  }
135103
- e3[i3] = n2;
135131
+ t3[i3] = n2;
135104
135132
  });
135105
- this.processedArgs = e3;
135133
+ this.processedArgs = t3;
135106
135134
  }
135107
- _chainOrCall(e3, t3) {
135108
- if (e3 && e3.then && typeof e3.then === "function") {
135109
- return e3.then(() => t3());
135135
+ _chainOrCall(t3, e3) {
135136
+ if (t3 && t3.then && typeof t3.then === "function") {
135137
+ return t3.then(() => e3());
135110
135138
  }
135111
- return t3();
135139
+ return e3();
135112
135140
  }
135113
- _chainOrCallHooks(e3, t3) {
135114
- let i3 = e3;
135141
+ _chainOrCallHooks(t3, e3) {
135142
+ let i3 = t3;
135115
135143
  const n2 = [];
135116
- getCommandAndParents(this).reverse().filter((e4) => e4._lifeCycleHooks[t3] !== void 0).forEach((e4) => {
135117
- e4._lifeCycleHooks[t3].forEach((t4) => {
135118
- n2.push({ hookedCommand: e4, callback: t4 });
135144
+ getCommandAndParents(this).reverse().filter((t4) => t4._lifeCycleHooks[e3] !== void 0).forEach((t4) => {
135145
+ t4._lifeCycleHooks[e3].forEach((e4) => {
135146
+ n2.push({ hookedCommand: t4, callback: e4 });
135119
135147
  });
135120
135148
  });
135121
- if (t3 === "postAction") {
135149
+ if (e3 === "postAction") {
135122
135150
  n2.reverse();
135123
135151
  }
135124
- n2.forEach((e4) => {
135125
- i3 = this._chainOrCall(i3, () => e4.callback(e4.hookedCommand, this));
135152
+ n2.forEach((t4) => {
135153
+ i3 = this._chainOrCall(i3, () => t4.callback(t4.hookedCommand, this));
135126
135154
  });
135127
135155
  return i3;
135128
135156
  }
135129
- _parseCommand(e3, t3) {
135130
- const i3 = this.parseOptions(t3);
135131
- this._parseOptionsEnv();
135132
- e3 = e3.concat(i3.operands);
135133
- t3 = i3.unknown;
135134
- this.args = e3.concat(t3);
135135
- if (e3 && this._findCommand(e3[0])) {
135136
- return this._dispatchSubcommand(e3[0], e3.slice(1), t3);
135157
+ _chainOrCallSubCommandHook(t3, e3, i3) {
135158
+ let n2 = t3;
135159
+ if (this._lifeCycleHooks[i3] !== void 0) {
135160
+ this._lifeCycleHooks[i3].forEach((t4) => {
135161
+ n2 = this._chainOrCall(n2, () => t4(this, e3));
135162
+ });
135137
135163
  }
135138
- if (this._hasImplicitHelpCommand() && e3[0] === this._helpCommandName) {
135139
- if (e3.length === 1) {
135164
+ return n2;
135165
+ }
135166
+ _parseCommand(t3, e3) {
135167
+ const i3 = this.parseOptions(e3);
135168
+ this._parseOptionsEnv();
135169
+ this._parseOptionsImplied();
135170
+ t3 = t3.concat(i3.operands);
135171
+ e3 = i3.unknown;
135172
+ this.args = t3.concat(e3);
135173
+ if (t3 && this._findCommand(t3[0])) {
135174
+ return this._dispatchSubcommand(t3[0], t3.slice(1), e3);
135175
+ }
135176
+ if (this._hasImplicitHelpCommand() && t3[0] === this._helpCommandName) {
135177
+ if (t3.length === 1) {
135140
135178
  this.help();
135141
135179
  }
135142
- return this._dispatchSubcommand(e3[1], [], [this._helpLongFlag]);
135180
+ return this._dispatchSubcommand(t3[1], [], [this._helpLongFlag]);
135143
135181
  }
135144
135182
  if (this._defaultCommandName) {
135145
- outputHelpIfRequested(this, t3);
135146
- return this._dispatchSubcommand(this._defaultCommandName, e3, t3);
135183
+ outputHelpIfRequested(this, e3);
135184
+ return this._dispatchSubcommand(this._defaultCommandName, t3, e3);
135147
135185
  }
135148
135186
  if (this.commands.length && this.args.length === 0 && !this._actionHandler && !this._defaultCommandName) {
135149
135187
  this.help({ error: true });
135150
135188
  }
135151
135189
  outputHelpIfRequested(this, i3.unknown);
135152
135190
  this._checkForMissingMandatoryOptions();
135191
+ this._checkForConflictingOptions();
135153
135192
  const checkForUnknownOptions = () => {
135154
135193
  if (i3.unknown.length > 0) {
135155
135194
  this.unknownOption(i3.unknown[0]);
@@ -135162,21 +135201,24 @@ Expecting one of '${i3.join("', '")}'`);
135162
135201
  let i4;
135163
135202
  i4 = this._chainOrCallHooks(i4, "preAction");
135164
135203
  i4 = this._chainOrCall(i4, () => this._actionHandler(this.processedArgs));
135165
- if (this.parent)
135166
- this.parent.emit(n2, e3, t3);
135204
+ if (this.parent) {
135205
+ i4 = this._chainOrCall(i4, () => {
135206
+ this.parent.emit(n2, t3, e3);
135207
+ });
135208
+ }
135167
135209
  i4 = this._chainOrCallHooks(i4, "postAction");
135168
135210
  return i4;
135169
135211
  }
135170
135212
  if (this.parent && this.parent.listenerCount(n2)) {
135171
135213
  checkForUnknownOptions();
135172
135214
  this._processArguments();
135173
- this.parent.emit(n2, e3, t3);
135174
- } else if (e3.length) {
135215
+ this.parent.emit(n2, t3, e3);
135216
+ } else if (t3.length) {
135175
135217
  if (this._findCommand("*")) {
135176
- return this._dispatchSubcommand("*", e3, t3);
135218
+ return this._dispatchSubcommand("*", t3, e3);
135177
135219
  }
135178
135220
  if (this.listenerCount("command:*")) {
135179
- this.emit("command:*", e3, t3);
135221
+ this.emit("command:*", t3, e3);
135180
135222
  } else if (this.commands.length) {
135181
135223
  this.unknownCommand();
135182
135224
  } else {
@@ -135191,131 +135233,155 @@ Expecting one of '${i3.join("', '")}'`);
135191
135233
  this._processArguments();
135192
135234
  }
135193
135235
  }
135194
- _findCommand(e3) {
135195
- if (!e3)
135236
+ _findCommand(t3) {
135237
+ if (!t3)
135196
135238
  return void 0;
135197
- return this.commands.find((t3) => t3._name === e3 || t3._aliases.includes(e3));
135239
+ return this.commands.find((e3) => e3._name === t3 || e3._aliases.includes(t3));
135198
135240
  }
135199
- _findOption(e3) {
135200
- return this.options.find((t3) => t3.is(e3));
135241
+ _findOption(t3) {
135242
+ return this.options.find((e3) => e3.is(t3));
135201
135243
  }
135202
135244
  _checkForMissingMandatoryOptions() {
135203
- for (let e3 = this; e3; e3 = e3.parent) {
135204
- e3.options.forEach((t3) => {
135205
- if (t3.mandatory && e3.getOptionValue(t3.attributeName()) === void 0) {
135206
- e3.missingMandatoryOptionValue(t3);
135245
+ for (let t3 = this; t3; t3 = t3.parent) {
135246
+ t3.options.forEach((e3) => {
135247
+ if (e3.mandatory && t3.getOptionValue(e3.attributeName()) === void 0) {
135248
+ t3.missingMandatoryOptionValue(e3);
135207
135249
  }
135208
135250
  });
135209
135251
  }
135210
135252
  }
135211
- parseOptions(e3) {
135212
- const t3 = [];
135253
+ _checkForConflictingLocalOptions() {
135254
+ const t3 = this.options.filter((t4) => {
135255
+ const e4 = t4.attributeName();
135256
+ if (this.getOptionValue(e4) === void 0) {
135257
+ return false;
135258
+ }
135259
+ return this.getOptionValueSource(e4) !== "default";
135260
+ });
135261
+ const e3 = t3.filter((t4) => t4.conflictsWith.length > 0);
135262
+ e3.forEach((e4) => {
135263
+ const i3 = t3.find((t4) => e4.conflictsWith.includes(t4.attributeName()));
135264
+ if (i3) {
135265
+ this._conflictingOption(e4, i3);
135266
+ }
135267
+ });
135268
+ }
135269
+ _checkForConflictingOptions() {
135270
+ for (let t3 = this; t3; t3 = t3.parent) {
135271
+ t3._checkForConflictingLocalOptions();
135272
+ }
135273
+ }
135274
+ parseOptions(t3) {
135275
+ const e3 = [];
135213
135276
  const i3 = [];
135214
- let n2 = t3;
135215
- const s2 = e3.slice();
135216
- function maybeOption(e4) {
135217
- return e4.length > 1 && e4[0] === "-";
135277
+ let n2 = e3;
135278
+ const s2 = t3.slice();
135279
+ function maybeOption(t4) {
135280
+ return t4.length > 1 && t4[0] === "-";
135218
135281
  }
135219
135282
  let r2 = null;
135220
135283
  while (s2.length) {
135221
- const e4 = s2.shift();
135222
- if (e4 === "--") {
135284
+ const t4 = s2.shift();
135285
+ if (t4 === "--") {
135223
135286
  if (n2 === i3)
135224
- n2.push(e4);
135287
+ n2.push(t4);
135225
135288
  n2.push(...s2);
135226
135289
  break;
135227
135290
  }
135228
- if (r2 && !maybeOption(e4)) {
135229
- this.emit(`option:${r2.name()}`, e4);
135291
+ if (r2 && !maybeOption(t4)) {
135292
+ this.emit(`option:${r2.name()}`, t4);
135230
135293
  continue;
135231
135294
  }
135232
135295
  r2 = null;
135233
- if (maybeOption(e4)) {
135234
- const t4 = this._findOption(e4);
135235
- if (t4) {
135236
- if (t4.required) {
135237
- const e5 = s2.shift();
135238
- if (e5 === void 0)
135239
- this.optionMissingArgument(t4);
135240
- this.emit(`option:${t4.name()}`, e5);
135241
- } else if (t4.optional) {
135242
- let e5 = null;
135296
+ if (maybeOption(t4)) {
135297
+ const e4 = this._findOption(t4);
135298
+ if (e4) {
135299
+ if (e4.required) {
135300
+ const t5 = s2.shift();
135301
+ if (t5 === void 0)
135302
+ this.optionMissingArgument(e4);
135303
+ this.emit(`option:${e4.name()}`, t5);
135304
+ } else if (e4.optional) {
135305
+ let t5 = null;
135243
135306
  if (s2.length > 0 && !maybeOption(s2[0])) {
135244
- e5 = s2.shift();
135307
+ t5 = s2.shift();
135245
135308
  }
135246
- this.emit(`option:${t4.name()}`, e5);
135309
+ this.emit(`option:${e4.name()}`, t5);
135247
135310
  } else {
135248
- this.emit(`option:${t4.name()}`);
135311
+ this.emit(`option:${e4.name()}`);
135249
135312
  }
135250
- r2 = t4.variadic ? t4 : null;
135313
+ r2 = e4.variadic ? e4 : null;
135251
135314
  continue;
135252
135315
  }
135253
135316
  }
135254
- if (e4.length > 2 && e4[0] === "-" && e4[1] !== "-") {
135255
- const t4 = this._findOption(`-${e4[1]}`);
135256
- if (t4) {
135257
- if (t4.required || t4.optional && this._combineFlagAndOptionalValue) {
135258
- this.emit(`option:${t4.name()}`, e4.slice(2));
135317
+ if (t4.length > 2 && t4[0] === "-" && t4[1] !== "-") {
135318
+ const e4 = this._findOption(`-${t4[1]}`);
135319
+ if (e4) {
135320
+ if (e4.required || e4.optional && this._combineFlagAndOptionalValue) {
135321
+ this.emit(`option:${e4.name()}`, t4.slice(2));
135259
135322
  } else {
135260
- this.emit(`option:${t4.name()}`);
135261
- s2.unshift(`-${e4.slice(2)}`);
135323
+ this.emit(`option:${e4.name()}`);
135324
+ s2.unshift(`-${t4.slice(2)}`);
135262
135325
  }
135263
135326
  continue;
135264
135327
  }
135265
135328
  }
135266
- if (/^--[^=]+=/.test(e4)) {
135267
- const t4 = e4.indexOf("=");
135268
- const i4 = this._findOption(e4.slice(0, t4));
135329
+ if (/^--[^=]+=/.test(t4)) {
135330
+ const e4 = t4.indexOf("=");
135331
+ const i4 = this._findOption(t4.slice(0, e4));
135269
135332
  if (i4 && (i4.required || i4.optional)) {
135270
- this.emit(`option:${i4.name()}`, e4.slice(t4 + 1));
135333
+ this.emit(`option:${i4.name()}`, t4.slice(e4 + 1));
135271
135334
  continue;
135272
135335
  }
135273
135336
  }
135274
- if (maybeOption(e4)) {
135337
+ if (maybeOption(t4)) {
135275
135338
  n2 = i3;
135276
135339
  }
135277
- if ((this._enablePositionalOptions || this._passThroughOptions) && t3.length === 0 && i3.length === 0) {
135278
- if (this._findCommand(e4)) {
135279
- t3.push(e4);
135340
+ if ((this._enablePositionalOptions || this._passThroughOptions) && e3.length === 0 && i3.length === 0) {
135341
+ if (this._findCommand(t4)) {
135342
+ e3.push(t4);
135280
135343
  if (s2.length > 0)
135281
135344
  i3.push(...s2);
135282
135345
  break;
135283
- } else if (e4 === this._helpCommandName && this._hasImplicitHelpCommand()) {
135284
- t3.push(e4);
135346
+ } else if (t4 === this._helpCommandName && this._hasImplicitHelpCommand()) {
135347
+ e3.push(t4);
135285
135348
  if (s2.length > 0)
135286
- t3.push(...s2);
135349
+ e3.push(...s2);
135287
135350
  break;
135288
135351
  } else if (this._defaultCommandName) {
135289
- i3.push(e4);
135352
+ i3.push(t4);
135290
135353
  if (s2.length > 0)
135291
135354
  i3.push(...s2);
135292
135355
  break;
135293
135356
  }
135294
135357
  }
135295
135358
  if (this._passThroughOptions) {
135296
- n2.push(e4);
135359
+ n2.push(t4);
135297
135360
  if (s2.length > 0)
135298
135361
  n2.push(...s2);
135299
135362
  break;
135300
135363
  }
135301
- n2.push(e4);
135364
+ n2.push(t4);
135302
135365
  }
135303
- return { operands: t3, unknown: i3 };
135366
+ return { operands: e3, unknown: i3 };
135304
135367
  }
135305
135368
  opts() {
135306
135369
  if (this._storeOptionsAsProperties) {
135307
- const e3 = {};
135308
- const t3 = this.options.length;
135309
- for (let i3 = 0; i3 < t3; i3++) {
135310
- const t4 = this.options[i3].attributeName();
135311
- e3[t4] = t4 === this._versionOptionName ? this._version : this[t4];
135370
+ const t3 = {};
135371
+ const e3 = this.options.length;
135372
+ for (let i3 = 0; i3 < e3; i3++) {
135373
+ const e4 = this.options[i3].attributeName();
135374
+ t3[e4] = e4 === this._versionOptionName ? this._version : this[e4];
135312
135375
  }
135313
- return e3;
135376
+ return t3;
135314
135377
  }
135315
135378
  return this._optionValues;
135316
135379
  }
135317
- _displayError(e3, t3, i3) {
135318
- this._outputConfiguration.outputError(`${i3}
135380
+ optsWithGlobals() {
135381
+ return getCommandAndParents(this).reduce((t3, e3) => Object.assign(t3, e3.opts()), {});
135382
+ }
135383
+ error(t3, e3) {
135384
+ this._outputConfiguration.outputError(`${t3}
135319
135385
  `, this._outputConfiguration.writeErr);
135320
135386
  if (typeof this._showHelpAfterError === "string") {
135321
135387
  this._outputConfiguration.writeErr(`${this._showHelpAfterError}
@@ -135324,166 +135390,217 @@ Expecting one of '${i3.join("', '")}'`);
135324
135390
  this._outputConfiguration.writeErr("\n");
135325
135391
  this.outputHelp({ error: true });
135326
135392
  }
135327
- this._exit(e3, t3, i3);
135393
+ const i3 = e3 || {};
135394
+ const n2 = i3.exitCode || 1;
135395
+ const s2 = i3.code || "commander.error";
135396
+ this._exit(n2, s2, t3);
135328
135397
  }
135329
135398
  _parseOptionsEnv() {
135330
- this.options.forEach((e3) => {
135331
- if (e3.envVar && e3.envVar in process.env) {
135332
- const t3 = e3.attributeName();
135333
- if (this.getOptionValue(t3) === void 0 || ["default", "config", "env"].includes(this.getOptionValueSource(t3))) {
135334
- if (e3.required || e3.optional) {
135335
- this.emit(`optionEnv:${e3.name()}`, process.env[e3.envVar]);
135399
+ this.options.forEach((t3) => {
135400
+ if (t3.envVar && t3.envVar in a.env) {
135401
+ const e3 = t3.attributeName();
135402
+ if (this.getOptionValue(e3) === void 0 || ["default", "config", "env"].includes(this.getOptionValueSource(e3))) {
135403
+ if (t3.required || t3.optional) {
135404
+ this.emit(`optionEnv:${t3.name()}`, a.env[t3.envVar]);
135336
135405
  } else {
135337
- this.emit(`optionEnv:${e3.name()}`);
135406
+ this.emit(`optionEnv:${t3.name()}`);
135338
135407
  }
135339
135408
  }
135340
135409
  }
135341
135410
  });
135342
135411
  }
135343
- missingArgument(e3) {
135344
- const t3 = `error: missing required argument '${e3}'`;
135345
- this._displayError(1, "commander.missingArgument", t3);
135346
- }
135347
- optionMissingArgument(e3) {
135348
- const t3 = `error: option '${e3.flags}' argument missing`;
135349
- this._displayError(1, "commander.optionMissingArgument", t3);
135412
+ _parseOptionsImplied() {
135413
+ const t3 = new d(this.options);
135414
+ const hasCustomOptionValue = (t4) => this.getOptionValue(t4) !== void 0 && !["default", "implied"].includes(this.getOptionValueSource(t4));
135415
+ this.options.filter((e3) => e3.implied !== void 0 && hasCustomOptionValue(e3.attributeName()) && t3.valueFromOption(this.getOptionValue(e3.attributeName()), e3)).forEach((t4) => {
135416
+ Object.keys(t4.implied).filter((t5) => !hasCustomOptionValue(t5)).forEach((e3) => {
135417
+ this.setOptionValueWithSource(e3, t4.implied[e3], "implied");
135418
+ });
135419
+ });
135350
135420
  }
135351
- missingMandatoryOptionValue(e3) {
135352
- const t3 = `error: required option '${e3.flags}' not specified`;
135353
- this._displayError(1, "commander.missingMandatoryOptionValue", t3);
135421
+ missingArgument(t3) {
135422
+ const e3 = `error: missing required argument '${t3}'`;
135423
+ this.error(e3, { code: "commander.missingArgument" });
135424
+ }
135425
+ optionMissingArgument(t3) {
135426
+ const e3 = `error: option '${t3.flags}' argument missing`;
135427
+ this.error(e3, { code: "commander.optionMissingArgument" });
135428
+ }
135429
+ missingMandatoryOptionValue(t3) {
135430
+ const e3 = `error: required option '${t3.flags}' not specified`;
135431
+ this.error(e3, { code: "commander.missingMandatoryOptionValue" });
135432
+ }
135433
+ _conflictingOption(t3, e3) {
135434
+ const findBestOptionFromValue = (t4) => {
135435
+ const e4 = t4.attributeName();
135436
+ const i4 = this.getOptionValue(e4);
135437
+ const n2 = this.options.find((t5) => t5.negate && e4 === t5.attributeName());
135438
+ const s2 = this.options.find((t5) => !t5.negate && e4 === t5.attributeName());
135439
+ if (n2 && (n2.presetArg === void 0 && i4 === false || n2.presetArg !== void 0 && i4 === n2.presetArg)) {
135440
+ return n2;
135441
+ }
135442
+ return s2 || t4;
135443
+ };
135444
+ const getErrorMessage = (t4) => {
135445
+ const e4 = findBestOptionFromValue(t4);
135446
+ const i4 = e4.attributeName();
135447
+ const n2 = this.getOptionValueSource(i4);
135448
+ if (n2 === "env") {
135449
+ return `environment variable '${e4.envVar}'`;
135450
+ }
135451
+ return `option '${e4.flags}'`;
135452
+ };
135453
+ const i3 = `error: ${getErrorMessage(t3)} cannot be used with ${getErrorMessage(e3)}`;
135454
+ this.error(i3, { code: "commander.conflictingOption" });
135354
135455
  }
135355
- unknownOption(e3) {
135456
+ unknownOption(t3) {
135356
135457
  if (this._allowUnknownOption)
135357
135458
  return;
135358
- let t3 = "";
135359
- if (e3.startsWith("--") && this._showSuggestionAfterError) {
135459
+ let e3 = "";
135460
+ if (t3.startsWith("--") && this._showSuggestionAfterError) {
135360
135461
  let i4 = [];
135361
135462
  let n2 = this;
135362
135463
  do {
135363
- const e4 = n2.createHelp().visibleOptions(n2).filter((e5) => e5.long).map((e5) => e5.long);
135364
- i4 = i4.concat(e4);
135464
+ const t4 = n2.createHelp().visibleOptions(n2).filter((t5) => t5.long).map((t5) => t5.long);
135465
+ i4 = i4.concat(t4);
135365
135466
  n2 = n2.parent;
135366
135467
  } while (n2 && !n2._enablePositionalOptions);
135367
- t3 = m(e3, i4);
135468
+ e3 = f(t3, i4);
135368
135469
  }
135369
- const i3 = `error: unknown option '${e3}'${t3}`;
135370
- this._displayError(1, "commander.unknownOption", i3);
135470
+ const i3 = `error: unknown option '${t3}'${e3}`;
135471
+ this.error(i3, { code: "commander.unknownOption" });
135371
135472
  }
135372
- _excessArguments(e3) {
135473
+ _excessArguments(t3) {
135373
135474
  if (this._allowExcessArguments)
135374
135475
  return;
135375
- const t3 = this._args.length;
135376
- const i3 = t3 === 1 ? "" : "s";
135476
+ const e3 = this._args.length;
135477
+ const i3 = e3 === 1 ? "" : "s";
135377
135478
  const n2 = this.parent ? ` for '${this.name()}'` : "";
135378
- const s2 = `error: too many arguments${n2}. Expected ${t3} argument${i3} but got ${e3.length}.`;
135379
- this._displayError(1, "commander.excessArguments", s2);
135479
+ const s2 = `error: too many arguments${n2}. Expected ${e3} argument${i3} but got ${t3.length}.`;
135480
+ this.error(s2, { code: "commander.excessArguments" });
135380
135481
  }
135381
135482
  unknownCommand() {
135382
- const e3 = this.args[0];
135383
- let t3 = "";
135483
+ const t3 = this.args[0];
135484
+ let e3 = "";
135384
135485
  if (this._showSuggestionAfterError) {
135385
135486
  const i4 = [];
135386
- this.createHelp().visibleCommands(this).forEach((e4) => {
135387
- i4.push(e4.name());
135388
- if (e4.alias())
135389
- i4.push(e4.alias());
135487
+ this.createHelp().visibleCommands(this).forEach((t4) => {
135488
+ i4.push(t4.name());
135489
+ if (t4.alias())
135490
+ i4.push(t4.alias());
135390
135491
  });
135391
- t3 = m(e3, i4);
135492
+ e3 = f(t3, i4);
135392
135493
  }
135393
- const i3 = `error: unknown command '${e3}'${t3}`;
135394
- this._displayError(1, "commander.unknownCommand", i3);
135494
+ const i3 = `error: unknown command '${t3}'${e3}`;
135495
+ this.error(i3, { code: "commander.unknownCommand" });
135395
135496
  }
135396
- version(e3, t3, i3) {
135397
- if (e3 === void 0)
135497
+ version(t3, e3, i3) {
135498
+ if (t3 === void 0)
135398
135499
  return this._version;
135399
- this._version = e3;
135400
- t3 = t3 || "-V, --version";
135500
+ this._version = t3;
135501
+ e3 = e3 || "-V, --version";
135401
135502
  i3 = i3 || "output the version number";
135402
- const n2 = this.createOption(t3, i3);
135503
+ const n2 = this.createOption(e3, i3);
135403
135504
  this._versionOptionName = n2.attributeName();
135404
135505
  this.options.push(n2);
135405
135506
  this.on("option:" + n2.name(), () => {
135406
- this._outputConfiguration.writeOut(`${e3}
135507
+ this._outputConfiguration.writeOut(`${t3}
135407
135508
  `);
135408
- this._exit(0, "commander.version", e3);
135509
+ this._exit(0, "commander.version", t3);
135409
135510
  });
135410
135511
  return this;
135411
135512
  }
135412
- description(e3, t3) {
135413
- if (e3 === void 0 && t3 === void 0)
135513
+ description(t3, e3) {
135514
+ if (t3 === void 0 && e3 === void 0)
135414
135515
  return this._description;
135415
- this._description = e3;
135416
- if (t3) {
135417
- this._argsDescription = t3;
135516
+ this._description = t3;
135517
+ if (e3) {
135518
+ this._argsDescription = e3;
135418
135519
  }
135419
135520
  return this;
135420
135521
  }
135421
- alias(e3) {
135422
- if (e3 === void 0)
135522
+ summary(t3) {
135523
+ if (t3 === void 0)
135524
+ return this._summary;
135525
+ this._summary = t3;
135526
+ return this;
135527
+ }
135528
+ alias(t3) {
135529
+ if (t3 === void 0)
135423
135530
  return this._aliases[0];
135424
- let t3 = this;
135531
+ let e3 = this;
135425
135532
  if (this.commands.length !== 0 && this.commands[this.commands.length - 1]._executableHandler) {
135426
- t3 = this.commands[this.commands.length - 1];
135533
+ e3 = this.commands[this.commands.length - 1];
135427
135534
  }
135428
- if (e3 === t3._name)
135535
+ if (t3 === e3._name)
135429
135536
  throw new Error("Command alias can't be the same as its name");
135430
- t3._aliases.push(e3);
135537
+ e3._aliases.push(t3);
135431
135538
  return this;
135432
135539
  }
135433
- aliases(e3) {
135434
- if (e3 === void 0)
135540
+ aliases(t3) {
135541
+ if (t3 === void 0)
135435
135542
  return this._aliases;
135436
- e3.forEach((e4) => this.alias(e4));
135543
+ t3.forEach((t4) => this.alias(t4));
135437
135544
  return this;
135438
135545
  }
135439
- usage(e3) {
135440
- if (e3 === void 0) {
135546
+ usage(t3) {
135547
+ if (t3 === void 0) {
135441
135548
  if (this._usage)
135442
135549
  return this._usage;
135443
- const e4 = this._args.map((e5) => h(e5));
135444
- return [].concat(this.options.length || this._hasHelpOption ? "[options]" : [], this.commands.length ? "[command]" : [], this._args.length ? e4 : []).join(" ");
135550
+ const t4 = this._args.map((t5) => h(t5));
135551
+ return [].concat(this.options.length || this._hasHelpOption ? "[options]" : [], this.commands.length ? "[command]" : [], this._args.length ? t4 : []).join(" ");
135445
135552
  }
135446
- this._usage = e3;
135553
+ this._usage = t3;
135447
135554
  return this;
135448
135555
  }
135449
- name(e3) {
135450
- if (e3 === void 0)
135556
+ name(t3) {
135557
+ if (t3 === void 0)
135451
135558
  return this._name;
135452
- this._name = e3;
135559
+ this._name = t3;
135453
135560
  return this;
135454
135561
  }
135455
- helpInformation(e3) {
135456
- const t3 = this.createHelp();
135457
- if (t3.helpWidth === void 0) {
135458
- t3.helpWidth = e3 && e3.error ? this._outputConfiguration.getErrHelpWidth() : this._outputConfiguration.getOutHelpWidth();
135562
+ nameFromFilename(t3) {
135563
+ this._name = r.basename(t3, r.extname(t3));
135564
+ return this;
135565
+ }
135566
+ executableDir(t3) {
135567
+ if (t3 === void 0)
135568
+ return this._executableDir;
135569
+ this._executableDir = t3;
135570
+ return this;
135571
+ }
135572
+ helpInformation(t3) {
135573
+ const e3 = this.createHelp();
135574
+ if (e3.helpWidth === void 0) {
135575
+ e3.helpWidth = t3 && t3.error ? this._outputConfiguration.getErrHelpWidth() : this._outputConfiguration.getOutHelpWidth();
135459
135576
  }
135460
- return t3.formatHelp(this, t3);
135577
+ return e3.formatHelp(this, e3);
135461
135578
  }
135462
- _getHelpContext(e3) {
135463
- e3 = e3 || {};
135464
- const t3 = { error: !!e3.error };
135579
+ _getHelpContext(t3) {
135580
+ t3 = t3 || {};
135581
+ const e3 = { error: !!t3.error };
135465
135582
  let i3;
135466
- if (t3.error) {
135467
- i3 = (e4) => this._outputConfiguration.writeErr(e4);
135583
+ if (e3.error) {
135584
+ i3 = (t4) => this._outputConfiguration.writeErr(t4);
135468
135585
  } else {
135469
- i3 = (e4) => this._outputConfiguration.writeOut(e4);
135586
+ i3 = (t4) => this._outputConfiguration.writeOut(t4);
135470
135587
  }
135471
- t3.write = e3.write || i3;
135472
- t3.command = this;
135473
- return t3;
135588
+ e3.write = t3.write || i3;
135589
+ e3.command = this;
135590
+ return e3;
135474
135591
  }
135475
- outputHelp(e3) {
135476
- let t3;
135477
- if (typeof e3 === "function") {
135478
- t3 = e3;
135479
- e3 = void 0;
135592
+ outputHelp(t3) {
135593
+ let e3;
135594
+ if (typeof t3 === "function") {
135595
+ e3 = t3;
135596
+ t3 = void 0;
135480
135597
  }
135481
- const i3 = this._getHelpContext(e3);
135482
- getCommandAndParents(this).reverse().forEach((e4) => e4.emit("beforeAllHelp", i3));
135598
+ const i3 = this._getHelpContext(t3);
135599
+ getCommandAndParents(this).reverse().forEach((t4) => t4.emit("beforeAllHelp", i3));
135483
135600
  this.emit("beforeHelp", i3);
135484
135601
  let n2 = this.helpInformation(i3);
135485
- if (t3) {
135486
- n2 = t3(n2);
135602
+ if (e3) {
135603
+ n2 = e3(n2);
135487
135604
  if (typeof n2 !== "string" && !Buffer.isBuffer(n2)) {
135488
135605
  throw new Error("outputHelp callback must return a string or a Buffer");
135489
135606
  }
@@ -135491,306 +135608,342 @@ Expecting one of '${i3.join("', '")}'`);
135491
135608
  i3.write(n2);
135492
135609
  this.emit(this._helpLongFlag);
135493
135610
  this.emit("afterHelp", i3);
135494
- getCommandAndParents(this).forEach((e4) => e4.emit("afterAllHelp", i3));
135611
+ getCommandAndParents(this).forEach((t4) => t4.emit("afterAllHelp", i3));
135495
135612
  }
135496
- helpOption(e3, t3) {
135497
- if (typeof e3 === "boolean") {
135498
- this._hasHelpOption = e3;
135613
+ helpOption(t3, e3) {
135614
+ if (typeof t3 === "boolean") {
135615
+ this._hasHelpOption = t3;
135499
135616
  return this;
135500
135617
  }
135501
- this._helpFlags = e3 || this._helpFlags;
135502
- this._helpDescription = t3 || this._helpDescription;
135503
- const i3 = p(this._helpFlags);
135618
+ this._helpFlags = t3 || this._helpFlags;
135619
+ this._helpDescription = e3 || this._helpDescription;
135620
+ const i3 = m(this._helpFlags);
135504
135621
  this._helpShortFlag = i3.shortFlag;
135505
135622
  this._helpLongFlag = i3.longFlag;
135506
135623
  return this;
135507
135624
  }
135508
- help(e3) {
135509
- this.outputHelp(e3);
135510
- let t3 = process.exitCode || 0;
135511
- if (t3 === 0 && e3 && typeof e3 !== "function" && e3.error) {
135512
- t3 = 1;
135625
+ help(t3) {
135626
+ this.outputHelp(t3);
135627
+ let e3 = a.exitCode || 0;
135628
+ if (e3 === 0 && t3 && typeof t3 !== "function" && t3.error) {
135629
+ e3 = 1;
135513
135630
  }
135514
- this._exit(t3, "commander.help", "(outputHelp)");
135631
+ this._exit(e3, "commander.help", "(outputHelp)");
135515
135632
  }
135516
- addHelpText(e3, t3) {
135633
+ addHelpText(t3, e3) {
135517
135634
  const i3 = ["beforeAll", "before", "after", "afterAll"];
135518
- if (!i3.includes(e3)) {
135635
+ if (!i3.includes(t3)) {
135519
135636
  throw new Error(`Unexpected value for position to addHelpText.
135520
135637
  Expecting one of '${i3.join("', '")}'`);
135521
135638
  }
135522
- const n2 = `${e3}Help`;
135523
- this.on(n2, (e4) => {
135639
+ const n2 = `${t3}Help`;
135640
+ this.on(n2, (t4) => {
135524
135641
  let i4;
135525
- if (typeof t3 === "function") {
135526
- i4 = t3({ error: e4.error, command: e4.command });
135642
+ if (typeof e3 === "function") {
135643
+ i4 = e3({ error: t4.error, command: t4.command });
135527
135644
  } else {
135528
- i4 = t3;
135645
+ i4 = e3;
135529
135646
  }
135530
135647
  if (i4) {
135531
- e4.write(`${i4}
135648
+ t4.write(`${i4}
135532
135649
  `);
135533
135650
  }
135534
135651
  });
135535
135652
  return this;
135536
135653
  }
135537
135654
  }
135538
- function outputHelpIfRequested(e3, t3) {
135539
- const i3 = e3._hasHelpOption && t3.find((t4) => t4 === e3._helpLongFlag || t4 === e3._helpShortFlag);
135655
+ function outputHelpIfRequested(t3, e3) {
135656
+ const i3 = t3._hasHelpOption && e3.find((e4) => e4 === t3._helpLongFlag || e4 === t3._helpShortFlag);
135540
135657
  if (i3) {
135541
- e3.outputHelp();
135542
- e3._exit(0, "commander.helpDisplayed", "(outputHelp)");
135658
+ t3.outputHelp();
135659
+ t3._exit(0, "commander.helpDisplayed", "(outputHelp)");
135543
135660
  }
135544
135661
  }
135545
- function incrementNodeInspectorPort(e3) {
135546
- return e3.map((e4) => {
135547
- if (!e4.startsWith("--inspect")) {
135548
- return e4;
135662
+ function incrementNodeInspectorPort(t3) {
135663
+ return t3.map((t4) => {
135664
+ if (!t4.startsWith("--inspect")) {
135665
+ return t4;
135549
135666
  }
135550
- let t3;
135667
+ let e3;
135551
135668
  let i3 = "127.0.0.1";
135552
135669
  let n2 = "9229";
135553
135670
  let s2;
135554
- if ((s2 = e4.match(/^(--inspect(-brk)?)$/)) !== null) {
135555
- t3 = s2[1];
135556
- } else if ((s2 = e4.match(/^(--inspect(-brk|-port)?)=([^:]+)$/)) !== null) {
135557
- t3 = s2[1];
135671
+ if ((s2 = t4.match(/^(--inspect(-brk)?)$/)) !== null) {
135672
+ e3 = s2[1];
135673
+ } else if ((s2 = t4.match(/^(--inspect(-brk|-port)?)=([^:]+)$/)) !== null) {
135674
+ e3 = s2[1];
135558
135675
  if (/^\d+$/.test(s2[3])) {
135559
135676
  n2 = s2[3];
135560
135677
  } else {
135561
135678
  i3 = s2[3];
135562
135679
  }
135563
- } else if ((s2 = e4.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/)) !== null) {
135564
- t3 = s2[1];
135680
+ } else if ((s2 = t4.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/)) !== null) {
135681
+ e3 = s2[1];
135565
135682
  i3 = s2[3];
135566
135683
  n2 = s2[4];
135567
135684
  }
135568
- if (t3 && n2 !== "0") {
135569
- return `${t3}=${i3}:${parseInt(n2) + 1}`;
135685
+ if (e3 && n2 !== "0") {
135686
+ return `${e3}=${i3}:${parseInt(n2) + 1}`;
135570
135687
  }
135571
- return e4;
135688
+ return t4;
135572
135689
  });
135573
135690
  }
135574
- function getCommandAndParents(e3) {
135575
- const t3 = [];
135576
- for (let i3 = e3; i3; i3 = i3.parent) {
135577
- t3.push(i3);
135691
+ function getCommandAndParents(t3) {
135692
+ const e3 = [];
135693
+ for (let i3 = t3; i3; i3 = i3.parent) {
135694
+ e3.push(i3);
135578
135695
  }
135579
- return t3;
135696
+ return e3;
135580
135697
  }
135581
- t2.Command = Command2;
135582
- }, 967: (e2, t2) => {
135698
+ e2.Command = Command2;
135699
+ }, 796: (t2, e2) => {
135583
135700
  class CommanderError extends Error {
135584
- constructor(e3, t3, i2) {
135701
+ constructor(t3, e3, i2) {
135585
135702
  super(i2);
135586
135703
  Error.captureStackTrace(this, this.constructor);
135587
135704
  this.name = this.constructor.name;
135588
- this.code = t3;
135589
- this.exitCode = e3;
135705
+ this.code = e3;
135706
+ this.exitCode = t3;
135590
135707
  this.nestedError = void 0;
135591
135708
  }
135592
135709
  }
135593
135710
  class InvalidArgumentError extends CommanderError {
135594
- constructor(e3) {
135595
- super(1, "commander.invalidArgument", e3);
135711
+ constructor(t3) {
135712
+ super(1, "commander.invalidArgument", t3);
135596
135713
  Error.captureStackTrace(this, this.constructor);
135597
135714
  this.name = this.constructor.name;
135598
135715
  }
135599
135716
  }
135600
- t2.CommanderError = CommanderError;
135601
- t2.InvalidArgumentError = InvalidArgumentError;
135602
- }, 34: (e2, t2, i2) => {
135603
- const { humanReadableArgName: n } = i2(969);
135717
+ e2.CommanderError = CommanderError;
135718
+ e2.InvalidArgumentError = InvalidArgumentError;
135719
+ }, 519: (t2, e2, i2) => {
135720
+ const { humanReadableArgName: n } = i2(535);
135604
135721
  class Help {
135605
135722
  constructor() {
135606
135723
  this.helpWidth = void 0;
135607
135724
  this.sortSubcommands = false;
135608
135725
  this.sortOptions = false;
135609
- }
135610
- visibleCommands(e3) {
135611
- const t3 = e3.commands.filter((e4) => !e4._hidden);
135612
- if (e3._hasImplicitHelpCommand()) {
135613
- const [, i3, n2] = e3._helpCommandnameAndArgs.match(/([^ ]+) *(.*)/);
135614
- const s = e3.createCommand(i3).helpOption(false);
135615
- s.description(e3._helpCommandDescription);
135726
+ this.showGlobalOptions = false;
135727
+ }
135728
+ visibleCommands(t3) {
135729
+ const e3 = t3.commands.filter((t4) => !t4._hidden);
135730
+ if (t3._hasImplicitHelpCommand()) {
135731
+ const [, i3, n2] = t3._helpCommandnameAndArgs.match(/([^ ]+) *(.*)/);
135732
+ const s = t3.createCommand(i3).helpOption(false);
135733
+ s.description(t3._helpCommandDescription);
135616
135734
  if (n2)
135617
135735
  s.arguments(n2);
135618
- t3.push(s);
135736
+ e3.push(s);
135619
135737
  }
135620
135738
  if (this.sortSubcommands) {
135621
- t3.sort((e4, t4) => e4.name().localeCompare(t4.name()));
135739
+ e3.sort((t4, e4) => t4.name().localeCompare(e4.name()));
135622
135740
  }
135623
- return t3;
135741
+ return e3;
135624
135742
  }
135625
- visibleOptions(e3) {
135626
- const t3 = e3.options.filter((e4) => !e4.hidden);
135627
- const i3 = e3._hasHelpOption && e3._helpShortFlag && !e3._findOption(e3._helpShortFlag);
135628
- const n2 = e3._hasHelpOption && !e3._findOption(e3._helpLongFlag);
135743
+ compareOptions(t3, e3) {
135744
+ const getSortKey = (t4) => t4.short ? t4.short.replace(/^-/, "") : t4.long.replace(/^--/, "");
135745
+ return getSortKey(t3).localeCompare(getSortKey(e3));
135746
+ }
135747
+ visibleOptions(t3) {
135748
+ const e3 = t3.options.filter((t4) => !t4.hidden);
135749
+ const i3 = t3._hasHelpOption && t3._helpShortFlag && !t3._findOption(t3._helpShortFlag);
135750
+ const n2 = t3._hasHelpOption && !t3._findOption(t3._helpLongFlag);
135629
135751
  if (i3 || n2) {
135630
135752
  let s;
135631
135753
  if (!i3) {
135632
- s = e3.createOption(e3._helpLongFlag, e3._helpDescription);
135754
+ s = t3.createOption(t3._helpLongFlag, t3._helpDescription);
135633
135755
  } else if (!n2) {
135634
- s = e3.createOption(e3._helpShortFlag, e3._helpDescription);
135756
+ s = t3.createOption(t3._helpShortFlag, t3._helpDescription);
135635
135757
  } else {
135636
- s = e3.createOption(e3._helpFlags, e3._helpDescription);
135758
+ s = t3.createOption(t3._helpFlags, t3._helpDescription);
135637
135759
  }
135638
- t3.push(s);
135760
+ e3.push(s);
135639
135761
  }
135640
135762
  if (this.sortOptions) {
135641
- const getSortKey = (e4) => e4.short ? e4.short.replace(/^-/, "") : e4.long.replace(/^--/, "");
135642
- t3.sort((e4, t4) => getSortKey(e4).localeCompare(getSortKey(t4)));
135763
+ e3.sort(this.compareOptions);
135643
135764
  }
135644
- return t3;
135765
+ return e3;
135645
135766
  }
135646
- visibleArguments(e3) {
135647
- if (e3._argsDescription) {
135648
- e3._args.forEach((t3) => {
135649
- t3.description = t3.description || e3._argsDescription[t3.name()] || "";
135767
+ visibleGlobalOptions(t3) {
135768
+ if (!this.showGlobalOptions)
135769
+ return [];
135770
+ const e3 = [];
135771
+ for (let i3 = t3.parent; i3; i3 = i3.parent) {
135772
+ const t4 = i3.options.filter((t5) => !t5.hidden);
135773
+ e3.push(...t4);
135774
+ }
135775
+ if (this.sortOptions) {
135776
+ e3.sort(this.compareOptions);
135777
+ }
135778
+ return e3;
135779
+ }
135780
+ visibleArguments(t3) {
135781
+ if (t3._argsDescription) {
135782
+ t3._args.forEach((e3) => {
135783
+ e3.description = e3.description || t3._argsDescription[e3.name()] || "";
135650
135784
  });
135651
135785
  }
135652
- if (e3._args.find((e4) => e4.description)) {
135653
- return e3._args;
135786
+ if (t3._args.find((t4) => t4.description)) {
135787
+ return t3._args;
135654
135788
  }
135655
135789
  return [];
135656
135790
  }
135657
- subcommandTerm(e3) {
135658
- const t3 = e3._args.map((e4) => n(e4)).join(" ");
135659
- return e3._name + (e3._aliases[0] ? "|" + e3._aliases[0] : "") + (e3.options.length ? " [options]" : "") + (t3 ? " " + t3 : "");
135791
+ subcommandTerm(t3) {
135792
+ const e3 = t3._args.map((t4) => n(t4)).join(" ");
135793
+ return t3._name + (t3._aliases[0] ? "|" + t3._aliases[0] : "") + (t3.options.length ? " [options]" : "") + (e3 ? " " + e3 : "");
135660
135794
  }
135661
- optionTerm(e3) {
135662
- return e3.flags;
135795
+ optionTerm(t3) {
135796
+ return t3.flags;
135663
135797
  }
135664
- argumentTerm(e3) {
135665
- return e3.name();
135798
+ argumentTerm(t3) {
135799
+ return t3.name();
135666
135800
  }
135667
- longestSubcommandTermLength(e3, t3) {
135668
- return t3.visibleCommands(e3).reduce((e4, i3) => Math.max(e4, t3.subcommandTerm(i3).length), 0);
135801
+ longestSubcommandTermLength(t3, e3) {
135802
+ return e3.visibleCommands(t3).reduce((t4, i3) => Math.max(t4, e3.subcommandTerm(i3).length), 0);
135669
135803
  }
135670
- longestOptionTermLength(e3, t3) {
135671
- return t3.visibleOptions(e3).reduce((e4, i3) => Math.max(e4, t3.optionTerm(i3).length), 0);
135804
+ longestOptionTermLength(t3, e3) {
135805
+ return e3.visibleOptions(t3).reduce((t4, i3) => Math.max(t4, e3.optionTerm(i3).length), 0);
135672
135806
  }
135673
- longestArgumentTermLength(e3, t3) {
135674
- return t3.visibleArguments(e3).reduce((e4, i3) => Math.max(e4, t3.argumentTerm(i3).length), 0);
135807
+ longestGlobalOptionTermLength(t3, e3) {
135808
+ return e3.visibleGlobalOptions(t3).reduce((t4, i3) => Math.max(t4, e3.optionTerm(i3).length), 0);
135675
135809
  }
135676
- commandUsage(e3) {
135677
- let t3 = e3._name;
135678
- if (e3._aliases[0]) {
135679
- t3 = t3 + "|" + e3._aliases[0];
135810
+ longestArgumentTermLength(t3, e3) {
135811
+ return e3.visibleArguments(t3).reduce((t4, i3) => Math.max(t4, e3.argumentTerm(i3).length), 0);
135812
+ }
135813
+ commandUsage(t3) {
135814
+ let e3 = t3._name;
135815
+ if (t3._aliases[0]) {
135816
+ e3 = e3 + "|" + t3._aliases[0];
135680
135817
  }
135681
135818
  let i3 = "";
135682
- for (let t4 = e3.parent; t4; t4 = t4.parent) {
135683
- i3 = t4.name() + " " + i3;
135819
+ for (let e4 = t3.parent; e4; e4 = e4.parent) {
135820
+ i3 = e4.name() + " " + i3;
135684
135821
  }
135685
- return i3 + t3 + " " + e3.usage();
135822
+ return i3 + e3 + " " + t3.usage();
135686
135823
  }
135687
- commandDescription(e3) {
135688
- return e3.description();
135824
+ commandDescription(t3) {
135825
+ return t3.description();
135689
135826
  }
135690
- subcommandDescription(e3) {
135691
- return e3.description();
135827
+ subcommandDescription(t3) {
135828
+ return t3.summary() || t3.description();
135692
135829
  }
135693
- optionDescription(e3) {
135694
- const t3 = [];
135695
- if (e3.argChoices && !e3.negate) {
135696
- t3.push(`choices: ${e3.argChoices.map((e4) => JSON.stringify(e4)).join(", ")}`);
135830
+ optionDescription(t3) {
135831
+ const e3 = [];
135832
+ if (t3.argChoices) {
135833
+ e3.push(`choices: ${t3.argChoices.map((t4) => JSON.stringify(t4)).join(", ")}`);
135697
135834
  }
135698
- if (e3.defaultValue !== void 0 && !e3.negate) {
135699
- t3.push(`default: ${e3.defaultValueDescription || JSON.stringify(e3.defaultValue)}`);
135835
+ if (t3.defaultValue !== void 0) {
135836
+ const i3 = t3.required || t3.optional || t3.isBoolean() && typeof t3.defaultValue === "boolean";
135837
+ if (i3) {
135838
+ e3.push(`default: ${t3.defaultValueDescription || JSON.stringify(t3.defaultValue)}`);
135839
+ }
135700
135840
  }
135701
- if (e3.envVar !== void 0) {
135702
- t3.push(`env: ${e3.envVar}`);
135841
+ if (t3.presetArg !== void 0 && t3.optional) {
135842
+ e3.push(`preset: ${JSON.stringify(t3.presetArg)}`);
135703
135843
  }
135704
- if (t3.length > 0) {
135705
- return `${e3.description} (${t3.join(", ")})`;
135844
+ if (t3.envVar !== void 0) {
135845
+ e3.push(`env: ${t3.envVar}`);
135706
135846
  }
135707
- return e3.description;
135847
+ if (e3.length > 0) {
135848
+ return `${t3.description} (${e3.join(", ")})`;
135849
+ }
135850
+ return t3.description;
135708
135851
  }
135709
- argumentDescription(e3) {
135710
- const t3 = [];
135711
- if (e3.argChoices) {
135712
- t3.push(`choices: ${e3.argChoices.map((e4) => JSON.stringify(e4)).join(", ")}`);
135852
+ argumentDescription(t3) {
135853
+ const e3 = [];
135854
+ if (t3.argChoices) {
135855
+ e3.push(`choices: ${t3.argChoices.map((t4) => JSON.stringify(t4)).join(", ")}`);
135713
135856
  }
135714
- if (e3.defaultValue !== void 0) {
135715
- t3.push(`default: ${e3.defaultValueDescription || JSON.stringify(e3.defaultValue)}`);
135857
+ if (t3.defaultValue !== void 0) {
135858
+ e3.push(`default: ${t3.defaultValueDescription || JSON.stringify(t3.defaultValue)}`);
135716
135859
  }
135717
- if (t3.length > 0) {
135718
- const i3 = `(${t3.join(", ")})`;
135719
- if (e3.description) {
135720
- return `${e3.description} ${i3}`;
135860
+ if (e3.length > 0) {
135861
+ const i3 = `(${e3.join(", ")})`;
135862
+ if (t3.description) {
135863
+ return `${t3.description} ${i3}`;
135721
135864
  }
135722
135865
  return i3;
135723
135866
  }
135724
- return e3.description;
135867
+ return t3.description;
135725
135868
  }
135726
- formatHelp(e3, t3) {
135727
- const i3 = t3.padWidth(e3, t3);
135728
- const n2 = t3.helpWidth || 80;
135869
+ formatHelp(t3, e3) {
135870
+ const i3 = e3.padWidth(t3, e3);
135871
+ const n2 = e3.helpWidth || 80;
135729
135872
  const s = 2;
135730
135873
  const r = 2;
135731
- function formatItem(e4, o2) {
135874
+ function formatItem(t4, o2) {
135732
135875
  if (o2) {
135733
- const a2 = `${e4.padEnd(i3 + r)}${o2}`;
135734
- return t3.wrap(a2, n2 - s, i3 + r);
135876
+ const a2 = `${t4.padEnd(i3 + r)}${o2}`;
135877
+ return e3.wrap(a2, n2 - s, i3 + r);
135735
135878
  }
135736
- return e4;
135879
+ return t4;
135737
135880
  }
135738
- function formatList(e4) {
135739
- return e4.join("\n").replace(/^/gm, " ".repeat(s));
135881
+ function formatList(t4) {
135882
+ return t4.join("\n").replace(/^/gm, " ".repeat(s));
135740
135883
  }
135741
- let o = [`Usage: ${t3.commandUsage(e3)}`, ""];
135742
- const a = t3.commandDescription(e3);
135884
+ let o = [`Usage: ${e3.commandUsage(t3)}`, ""];
135885
+ const a = e3.commandDescription(t3);
135743
135886
  if (a.length > 0) {
135744
- o = o.concat([a, ""]);
135887
+ o = o.concat([e3.wrap(a, n2, 0), ""]);
135745
135888
  }
135746
- const h = t3.visibleArguments(e3).map((e4) => formatItem(t3.argumentTerm(e4), t3.argumentDescription(e4)));
135889
+ const l = e3.visibleArguments(t3).map((t4) => formatItem(e3.argumentTerm(t4), e3.argumentDescription(t4)));
135890
+ if (l.length > 0) {
135891
+ o = o.concat(["Arguments:", formatList(l), ""]);
135892
+ }
135893
+ const h = e3.visibleOptions(t3).map((t4) => formatItem(e3.optionTerm(t4), e3.optionDescription(t4)));
135747
135894
  if (h.length > 0) {
135748
- o = o.concat(["Arguments:", formatList(h), ""]);
135895
+ o = o.concat(["Options:", formatList(h), ""]);
135749
135896
  }
135750
- const l = t3.visibleOptions(e3).map((e4) => formatItem(t3.optionTerm(e4), t3.optionDescription(e4)));
135751
- if (l.length > 0) {
135752
- o = o.concat(["Options:", formatList(l), ""]);
135897
+ if (this.showGlobalOptions) {
135898
+ const i4 = e3.visibleGlobalOptions(t3).map((t4) => formatItem(e3.optionTerm(t4), e3.optionDescription(t4)));
135899
+ if (i4.length > 0) {
135900
+ o = o.concat(["Global Options:", formatList(i4), ""]);
135901
+ }
135753
135902
  }
135754
- const u = t3.visibleCommands(e3).map((e4) => formatItem(t3.subcommandTerm(e4), t3.subcommandDescription(e4)));
135903
+ const u = e3.visibleCommands(t3).map((t4) => formatItem(e3.subcommandTerm(t4), e3.subcommandDescription(t4)));
135755
135904
  if (u.length > 0) {
135756
135905
  o = o.concat(["Commands:", formatList(u), ""]);
135757
135906
  }
135758
135907
  return o.join("\n");
135759
135908
  }
135760
- padWidth(e3, t3) {
135761
- return Math.max(t3.longestOptionTermLength(e3, t3), t3.longestSubcommandTermLength(e3, t3), t3.longestArgumentTermLength(e3, t3));
135909
+ padWidth(t3, e3) {
135910
+ return Math.max(e3.longestOptionTermLength(t3, e3), e3.longestGlobalOptionTermLength(t3, e3), e3.longestSubcommandTermLength(t3, e3), e3.longestArgumentTermLength(t3, e3));
135762
135911
  }
135763
- wrap(e3, t3, i3, n2 = 40) {
135764
- if (e3.match(/[\n]\s+/))
135765
- return e3;
135766
- const s = t3 - i3;
135767
- if (s < n2)
135768
- return e3;
135769
- const r = e3.substr(0, i3);
135770
- const o = e3.substr(i3);
135771
- const a = " ".repeat(i3);
135772
- const h = new RegExp(".{1," + (s - 1) + "}([\\s​]|$)|[^\\s​]+?([\\s​]|$)", "g");
135773
- const l = o.match(h) || [];
135774
- return r + l.map((e4, t4) => {
135775
- if (e4.slice(-1) === "\n") {
135776
- e4 = e4.slice(0, e4.length - 1);
135777
- }
135778
- return (t4 > 0 ? a : "") + e4.trimRight();
135912
+ wrap(t3, e3, i3, n2 = 40) {
135913
+ const s = " \\f\\t\\v   -    \uFEFF";
135914
+ const r = new RegExp(`[\\n][${s}]+`);
135915
+ if (t3.match(r))
135916
+ return t3;
135917
+ const o = e3 - i3;
135918
+ if (o < n2)
135919
+ return t3;
135920
+ const a = t3.slice(0, i3);
135921
+ const l = t3.slice(i3).replace("\r\n", "\n");
135922
+ const h = " ".repeat(i3);
135923
+ const u = "​";
135924
+ const c = `\\s${u}`;
135925
+ const p = new RegExp(`
135926
+ |.{1,${o - 1}}([${c}]|$)|[^${c}]+?([${c}]|$)`, "g");
135927
+ const m = l.match(p) || [];
135928
+ return a + m.map((t4, e4) => {
135929
+ if (t4 === "\n")
135930
+ return "";
135931
+ return (e4 > 0 ? h : "") + t4.trimEnd();
135779
135932
  }).join("\n");
135780
135933
  }
135781
135934
  }
135782
- t2.Help = Help;
135783
- }, 278: (e2, t2, i2) => {
135784
- const { InvalidArgumentError: n } = i2(967);
135935
+ e2.Help = Help;
135936
+ }, 437: (t2, e2, i2) => {
135937
+ const { InvalidArgumentError: n } = i2(796);
135785
135938
  class Option {
135786
- constructor(e3, t3) {
135787
- this.flags = e3;
135788
- this.description = t3 || "";
135789
- this.required = e3.includes("<");
135790
- this.optional = e3.includes("[");
135791
- this.variadic = /\w\.\.\.[>\]]$/.test(e3);
135939
+ constructor(t3, e3) {
135940
+ this.flags = t3;
135941
+ this.description = e3 || "";
135942
+ this.required = t3.includes("<");
135943
+ this.optional = t3.includes("[");
135944
+ this.variadic = /\w\.\.\.[>\]]$/.test(t3);
135792
135945
  this.mandatory = false;
135793
- const i3 = splitOptionFlags(e3);
135946
+ const i3 = splitOptionFlags(t3);
135794
135947
  this.short = i3.shortFlag;
135795
135948
  this.long = i3.longFlag;
135796
135949
  this.negate = false;
@@ -135799,48 +135952,63 @@ Expecting one of '${i3.join("', '")}'`);
135799
135952
  }
135800
135953
  this.defaultValue = void 0;
135801
135954
  this.defaultValueDescription = void 0;
135955
+ this.presetArg = void 0;
135802
135956
  this.envVar = void 0;
135803
135957
  this.parseArg = void 0;
135804
135958
  this.hidden = false;
135805
135959
  this.argChoices = void 0;
135960
+ this.conflictsWith = [];
135961
+ this.implied = void 0;
135806
135962
  }
135807
- default(e3, t3) {
135808
- this.defaultValue = e3;
135809
- this.defaultValueDescription = t3;
135963
+ default(t3, e3) {
135964
+ this.defaultValue = t3;
135965
+ this.defaultValueDescription = e3;
135810
135966
  return this;
135811
135967
  }
135812
- env(e3) {
135813
- this.envVar = e3;
135968
+ preset(t3) {
135969
+ this.presetArg = t3;
135814
135970
  return this;
135815
135971
  }
135816
- argParser(e3) {
135817
- this.parseArg = e3;
135972
+ conflicts(t3) {
135973
+ this.conflictsWith = this.conflictsWith.concat(t3);
135818
135974
  return this;
135819
135975
  }
135820
- makeOptionMandatory(e3 = true) {
135821
- this.mandatory = !!e3;
135976
+ implies(t3) {
135977
+ this.implied = Object.assign(this.implied || {}, t3);
135822
135978
  return this;
135823
135979
  }
135824
- hideHelp(e3 = true) {
135825
- this.hidden = !!e3;
135980
+ env(t3) {
135981
+ this.envVar = t3;
135826
135982
  return this;
135827
135983
  }
135828
- _concatValue(e3, t3) {
135829
- if (t3 === this.defaultValue || !Array.isArray(t3)) {
135830
- return [e3];
135984
+ argParser(t3) {
135985
+ this.parseArg = t3;
135986
+ return this;
135987
+ }
135988
+ makeOptionMandatory(t3 = true) {
135989
+ this.mandatory = !!t3;
135990
+ return this;
135991
+ }
135992
+ hideHelp(t3 = true) {
135993
+ this.hidden = !!t3;
135994
+ return this;
135995
+ }
135996
+ _concatValue(t3, e3) {
135997
+ if (e3 === this.defaultValue || !Array.isArray(e3)) {
135998
+ return [t3];
135831
135999
  }
135832
- return t3.concat(e3);
136000
+ return e3.concat(t3);
135833
136001
  }
135834
- choices(e3) {
135835
- this.argChoices = e3;
135836
- this.parseArg = (t3, i3) => {
135837
- if (!e3.includes(t3)) {
135838
- throw new n(`Allowed choices are ${e3.join(", ")}.`);
136002
+ choices(t3) {
136003
+ this.argChoices = t3.slice();
136004
+ this.parseArg = (t4, e3) => {
136005
+ if (!this.argChoices.includes(t4)) {
136006
+ throw new n(`Allowed choices are ${this.argChoices.join(", ")}.`);
135839
136007
  }
135840
136008
  if (this.variadic) {
135841
- return this._concatValue(t3, i3);
136009
+ return this._concatValue(t4, e3);
135842
136010
  }
135843
- return t3;
136011
+ return t4;
135844
136012
  };
135845
136013
  return this;
135846
136014
  }
@@ -135853,86 +136021,117 @@ Expecting one of '${i3.join("', '")}'`);
135853
136021
  attributeName() {
135854
136022
  return camelcase(this.name().replace(/^no-/, ""));
135855
136023
  }
135856
- is(e3) {
135857
- return this.short === e3 || this.long === e3;
136024
+ is(t3) {
136025
+ return this.short === t3 || this.long === t3;
136026
+ }
136027
+ isBoolean() {
136028
+ return !this.required && !this.optional && !this.negate;
135858
136029
  }
135859
136030
  }
135860
- function camelcase(e3) {
135861
- return e3.split("-").reduce((e4, t3) => e4 + t3[0].toUpperCase() + t3.slice(1));
136031
+ class DualOptions {
136032
+ constructor(t3) {
136033
+ this.positiveOptions = /* @__PURE__ */ new Map();
136034
+ this.negativeOptions = /* @__PURE__ */ new Map();
136035
+ this.dualOptions = /* @__PURE__ */ new Set();
136036
+ t3.forEach((t4) => {
136037
+ if (t4.negate) {
136038
+ this.negativeOptions.set(t4.attributeName(), t4);
136039
+ } else {
136040
+ this.positiveOptions.set(t4.attributeName(), t4);
136041
+ }
136042
+ });
136043
+ this.negativeOptions.forEach((t4, e3) => {
136044
+ if (this.positiveOptions.has(e3)) {
136045
+ this.dualOptions.add(e3);
136046
+ }
136047
+ });
136048
+ }
136049
+ valueFromOption(t3, e3) {
136050
+ const i3 = e3.attributeName();
136051
+ if (!this.dualOptions.has(i3))
136052
+ return true;
136053
+ const n2 = this.negativeOptions.get(i3).presetArg;
136054
+ const s = n2 !== void 0 ? n2 : false;
136055
+ return e3.negate === (s === t3);
136056
+ }
135862
136057
  }
135863
- function splitOptionFlags(e3) {
135864
- let t3;
136058
+ function camelcase(t3) {
136059
+ return t3.split("-").reduce((t4, e3) => t4 + e3[0].toUpperCase() + e3.slice(1));
136060
+ }
136061
+ function splitOptionFlags(t3) {
136062
+ let e3;
135865
136063
  let i3;
135866
- const n2 = e3.split(/[ |,]+/);
136064
+ const n2 = t3.split(/[ |,]+/);
135867
136065
  if (n2.length > 1 && !/^[[<]/.test(n2[1]))
135868
- t3 = n2.shift();
136066
+ e3 = n2.shift();
135869
136067
  i3 = n2.shift();
135870
- if (!t3 && /^-[^-]$/.test(i3)) {
135871
- t3 = i3;
136068
+ if (!e3 && /^-[^-]$/.test(i3)) {
136069
+ e3 = i3;
135872
136070
  i3 = void 0;
135873
136071
  }
135874
- return { shortFlag: t3, longFlag: i3 };
136072
+ return { shortFlag: e3, longFlag: i3 };
135875
136073
  }
135876
- t2.Option = Option;
135877
- t2.splitOptionFlags = splitOptionFlags;
135878
- }, 461: (e2, t2) => {
136074
+ e2.Option = Option;
136075
+ e2.splitOptionFlags = splitOptionFlags;
136076
+ e2.DualOptions = DualOptions;
136077
+ }, 860: (t2, e2) => {
135879
136078
  const i2 = 3;
135880
- function editDistance(e3, t3) {
135881
- if (Math.abs(e3.length - t3.length) > i2)
135882
- return Math.max(e3.length, t3.length);
136079
+ function editDistance(t3, e3) {
136080
+ if (Math.abs(t3.length - e3.length) > i2)
136081
+ return Math.max(t3.length, e3.length);
135883
136082
  const n = [];
135884
- for (let t4 = 0; t4 <= e3.length; t4++) {
135885
- n[t4] = [t4];
135886
- }
135887
136083
  for (let e4 = 0; e4 <= t3.length; e4++) {
135888
- n[0][e4] = e4;
136084
+ n[e4] = [e4];
135889
136085
  }
135890
- for (let i3 = 1; i3 <= t3.length; i3++) {
135891
- for (let s = 1; s <= e3.length; s++) {
136086
+ for (let t4 = 0; t4 <= e3.length; t4++) {
136087
+ n[0][t4] = t4;
136088
+ }
136089
+ for (let i3 = 1; i3 <= e3.length; i3++) {
136090
+ for (let s = 1; s <= t3.length; s++) {
135892
136091
  let r = 1;
135893
- if (e3[s - 1] === t3[i3 - 1]) {
136092
+ if (t3[s - 1] === e3[i3 - 1]) {
135894
136093
  r = 0;
135895
136094
  } else {
135896
136095
  r = 1;
135897
136096
  }
135898
136097
  n[s][i3] = Math.min(n[s - 1][i3] + 1, n[s][i3 - 1] + 1, n[s - 1][i3 - 1] + r);
135899
- if (s > 1 && i3 > 1 && e3[s - 1] === t3[i3 - 2] && e3[s - 2] === t3[i3 - 1]) {
136098
+ if (s > 1 && i3 > 1 && t3[s - 1] === e3[i3 - 2] && t3[s - 2] === e3[i3 - 1]) {
135900
136099
  n[s][i3] = Math.min(n[s][i3], n[s - 2][i3 - 2] + 1);
135901
136100
  }
135902
136101
  }
135903
136102
  }
135904
- return n[e3.length][t3.length];
136103
+ return n[t3.length][e3.length];
135905
136104
  }
135906
- function suggestSimilar(e3, t3) {
135907
- if (!t3 || t3.length === 0)
136105
+ function suggestSimilar(t3, e3) {
136106
+ if (!e3 || e3.length === 0)
135908
136107
  return "";
135909
- t3 = Array.from(new Set(t3));
135910
- const n = e3.startsWith("--");
136108
+ e3 = Array.from(new Set(e3));
136109
+ const n = t3.startsWith("--");
135911
136110
  if (n) {
135912
- e3 = e3.slice(2);
135913
- t3 = t3.map((e4) => e4.slice(2));
136111
+ t3 = t3.slice(2);
136112
+ e3 = e3.map((t4) => t4.slice(2));
135914
136113
  }
135915
136114
  let s = [];
135916
136115
  let r = i2;
135917
136116
  const o = 0.4;
135918
- t3.forEach((t4) => {
135919
- if (t4.length <= 1)
136117
+ e3.forEach((e4) => {
136118
+ if (e4.length <= 1)
135920
136119
  return;
135921
- const i3 = editDistance(e3, t4);
135922
- const n2 = Math.max(e3.length, t4.length);
136120
+ const i3 = editDistance(t3, e4);
136121
+ const n2 = Math.max(t3.length, e4.length);
135923
136122
  const a = (n2 - i3) / n2;
135924
136123
  if (a > o) {
135925
136124
  if (i3 < r) {
135926
136125
  r = i3;
135927
- s = [t4];
136126
+ s = [e4];
135928
136127
  } else if (i3 === r) {
135929
- s.push(t4);
136128
+ s.push(e4);
135930
136129
  }
135931
136130
  }
135932
136131
  });
135933
- s.sort((e4, t4) => e4.localeCompare(t4));
136132
+ s.sort((t4, e4) => t4.localeCompare(e4));
135934
136133
  if (n) {
135935
- s = s.map((e4) => `--${e4}`);
136134
+ s = s.map((t4) => `--${t4}`);
135936
136135
  }
135937
136136
  if (s.length > 1) {
135938
136137
  return `
@@ -135944,28 +136143,28 @@ Expecting one of '${i3.join("', '")}'`);
135944
136143
  }
135945
136144
  return "";
135946
136145
  }
135947
- t2.suggestSimilar = suggestSimilar;
136146
+ e2.suggestSimilar = suggestSimilar;
135948
136147
  } };
135949
- var t = {};
136148
+ var e = {};
135950
136149
  function __nccwpck_require__(i2) {
135951
- var n = t[i2];
136150
+ var n = e[i2];
135952
136151
  if (n !== void 0) {
135953
136152
  return n.exports;
135954
136153
  }
135955
- var s = t[i2] = { exports: {} };
136154
+ var s = e[i2] = { exports: {} };
135956
136155
  var r = true;
135957
136156
  try {
135958
- e[i2](s, s.exports, __nccwpck_require__);
136157
+ t[i2](s, s.exports, __nccwpck_require__);
135959
136158
  r = false;
135960
136159
  } finally {
135961
136160
  if (r)
135962
- delete t[i2];
136161
+ delete e[i2];
135963
136162
  }
135964
136163
  return s.exports;
135965
136164
  }
135966
136165
  if (typeof __nccwpck_require__ !== "undefined")
135967
136166
  __nccwpck_require__.ab = __dirname + "/";
135968
- var i = __nccwpck_require__(922);
136167
+ var i = __nccwpck_require__(632);
135969
136168
  module2.exports = i;
135970
136169
  })();
135971
136170
  }
@@ -136105,12 +136304,17 @@ var require_commands = __commonJS({
136105
136304
  var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
136106
136305
  var commands_exports = {};
136107
136306
  __export2(commands_exports, {
136307
+ getArgv: () => getArgv,
136108
136308
  getCommand: () => getCommand,
136109
136309
  isDevCommand: () => isDevCommand
136110
136310
  });
136111
136311
  module2.exports = __toCommonJS2(commands_exports);
136312
+ var getArgv = () => {
136313
+ var _a2;
136314
+ return (((_a2 = process.env.MODERN_ARGV) == null ? void 0 : _a2.split(" ")) || process.argv).slice(2);
136315
+ };
136112
136316
  var getCommand = () => {
136113
- const args = process.argv.slice(2);
136317
+ const args = getArgv();
136114
136318
  const command = args[0];
136115
136319
  return command;
136116
136320
  };
@@ -136121,108 +136325,6 @@ var require_commands = __commonJS({
136121
136325
  }
136122
136326
  });
136123
136327
 
136124
- // ../../../toolkit/utils/dist/format.js
136125
- var require_format2 = __commonJS({
136126
- "../../../toolkit/utils/dist/format.js"(exports, module2) {
136127
- var __defProp2 = Object.defineProperty;
136128
- var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
136129
- var __getOwnPropNames2 = Object.getOwnPropertyNames;
136130
- var __hasOwnProp2 = Object.prototype.hasOwnProperty;
136131
- var __export2 = (target, all) => {
136132
- for (var name in all)
136133
- __defProp2(target, name, { get: all[name], enumerable: true });
136134
- };
136135
- var __copyProps2 = (to, from, except, desc) => {
136136
- if (from && typeof from === "object" || typeof from === "function") {
136137
- for (let key of __getOwnPropNames2(from))
136138
- if (!__hasOwnProp2.call(to, key) && key !== except)
136139
- __defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
136140
- }
136141
- return to;
136142
- };
136143
- var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
136144
- var format_exports = {};
136145
- __export2(format_exports, {
136146
- formatWebpackMessages: () => formatWebpackMessages
136147
- });
136148
- module2.exports = __toCommonJS2(format_exports);
136149
- var friendlySyntaxErrorLabel = "SyntaxError:";
136150
- function isLikelyASyntaxError(message) {
136151
- return message.includes(friendlySyntaxErrorLabel);
136152
- }
136153
- function formatMessage(stats) {
136154
- let lines = [];
136155
- let message;
136156
- if (typeof stats === "object") {
136157
- const fileName = stats.moduleName ? `File: ${stats.moduleName}
136158
- ` : "";
136159
- const mainMessage = stats.message;
136160
- const details = stats.details ? `
136161
- Details: ${stats.details}
136162
- ` : "";
136163
- const stack = stats.stack ? `
136164
- ${stats.stack}` : "";
136165
- message = `${fileName}${mainMessage}${details}${stack}`;
136166
- } else {
136167
- message = stats;
136168
- }
136169
- lines = message.split("\n");
136170
- lines = lines.map((line) => {
136171
- const parsingError = /Line (\d+):(?:(\d+):)?\s*Parsing error: (.+)$/.exec(
136172
- line
136173
- );
136174
- if (!parsingError) {
136175
- return line;
136176
- }
136177
- const [, errorLine, errorColumn, errorMessage] = parsingError;
136178
- return `${friendlySyntaxErrorLabel} ${errorMessage} (${errorLine}:${errorColumn})`;
136179
- });
136180
- message = lines.join("\n");
136181
- message = message.replace(
136182
- /SyntaxError\s+\((\d+):(\d+)\)\s*(.+?)\n/g,
136183
- `${friendlySyntaxErrorLabel} $3 ($1:$2)
136184
- `
136185
- );
136186
- lines = message.split("\n");
136187
- if (lines.length > 2 && lines[1].trim() === "") {
136188
- lines.splice(1, 1);
136189
- }
136190
- lines[0] = lines[0].replace(/^(.*) \d+:\d+-\d+$/, "$1");
136191
- if (lines[1] && lines[1].indexOf("Module not found:") !== -1) {
136192
- lines[1] = lines[1].replace("Error: ", "");
136193
- }
136194
- message = lines.join("\n");
136195
- message = message.replace(
136196
- /^\s*at\s((?!webpack:).)*:\d+:\d+[\s)]*(\n|$)/gm,
136197
- ""
136198
- );
136199
- message = message.replace(/^\s*at\s<anonymous>(\n|$)/gm, "");
136200
- lines = message.split("\n");
136201
- lines = lines.filter(
136202
- (line, index, arr) => index === 0 || line.trim() !== "" || line.trim() !== arr[index - 1].trim()
136203
- );
136204
- message = lines.join("\n");
136205
- return message.trim();
136206
- }
136207
- function formatWebpackMessages(json) {
136208
- var _a2, _b, _c;
136209
- const formattedErrors = (_a2 = json == null ? void 0 : json.errors) == null ? void 0 : _a2.map(formatMessage);
136210
- const formattedWarnings = (_b = json == null ? void 0 : json.warnings) == null ? void 0 : _b.map(formatMessage);
136211
- const result = {
136212
- errors: formattedErrors || [],
136213
- warnings: formattedWarnings || []
136214
- };
136215
- if ((_c = result.errors) == null ? void 0 : _c.some(isLikelyASyntaxError)) {
136216
- result.errors = result.errors.filter(isLikelyASyntaxError);
136217
- }
136218
- if (result.errors.length > 1) {
136219
- result.errors.length = 1;
136220
- }
136221
- return result;
136222
- }
136223
- }
136224
- });
136225
-
136226
136328
  // ../../../toolkit/utils/dist/logger.js
136227
136329
  var require_logger4 = __commonJS({
136228
136330
  "../../../toolkit/utils/dist/logger.js"(exports, module2) {
@@ -137007,10 +137109,10 @@ var require_constants6 = __commonJS({
137007
137109
  API_DIR: () => API_DIR,
137008
137110
  CONFIG_CACHE_DIR: () => CONFIG_CACHE_DIR,
137009
137111
  CONFIG_FILE_EXTENSIONS: () => CONFIG_FILE_EXTENSIONS,
137112
+ DEFAULT_BABEL_PRESET_TYPESCRIPT_OPTIONS: () => DEFAULT_BABEL_PRESET_TYPESCRIPT_OPTIONS,
137010
137113
  DEFAULT_DEV_HOST: () => DEFAULT_DEV_HOST,
137011
137114
  DEFAULT_SERVER_CONFIG: () => DEFAULT_SERVER_CONFIG,
137012
137115
  ENTRY_NAME_PATTERN: () => ENTRY_NAME_PATTERN,
137013
- HMR_SOCK_PATH: () => HMR_SOCK_PATH,
137014
137116
  INTERNAL_APP_TOOLS_PLUGINS: () => INTERNAL_APP_TOOLS_PLUGINS,
137015
137117
  INTERNAL_APP_TOOLS_RUNTIME_PLUGINS: () => INTERNAL_APP_TOOLS_RUNTIME_PLUGINS,
137016
137118
  INTERNAL_CLI_PLUGINS: () => INTERNAL_CLI_PLUGINS,
@@ -137024,8 +137126,7 @@ var require_constants6 = __commonJS({
137024
137126
  MAIN_ENTRY_NAME: () => MAIN_ENTRY_NAME,
137025
137127
  OUTPUT_CONFIG_FILE: () => OUTPUT_CONFIG_FILE,
137026
137128
  PLUGIN_SCHEMAS: () => PLUGIN_SCHEMAS,
137027
- ROUTE_MANIFEST: () => ROUTE_MANIFEST,
137028
- ROUTE_MINIFEST_FILE: () => ROUTE_MINIFEST_FILE,
137129
+ ROUTE_MANIFEST_FILE: () => ROUTE_MANIFEST_FILE,
137029
137130
  ROUTE_SPEC_FILE: () => ROUTE_SPEC_FILE,
137030
137131
  SERVER_BUNDLE_DIRECTORY: () => SERVER_BUNDLE_DIRECTORY,
137031
137132
  SERVER_DIR: () => SERVER_DIR,
@@ -137041,7 +137142,6 @@ var require_constants6 = __commonJS({
137041
137142
  SHARED_DIR: () => SHARED_DIR
137042
137143
  });
137043
137144
  module2.exports = __toCommonJS2(constants_exports);
137044
- var HMR_SOCK_PATH = "/webpack-hmr";
137045
137145
  var ROUTE_SPEC_FILE = "route.json";
137046
137146
  var MAIN_ENTRY_NAME = "main";
137047
137147
  var LAUNCH_EDITOR_ENDPOINT = "/__open-stack-frame-in-editor";
@@ -137057,8 +137157,7 @@ var require_constants6 = __commonJS({
137057
137157
  var CONFIG_FILE_EXTENSIONS = [".js", ".ts", ".mjs"];
137058
137158
  var OUTPUT_CONFIG_FILE = "modern.config.json";
137059
137159
  var DEFAULT_SERVER_CONFIG = "modern.server-runtime.config";
137060
- var ROUTE_MINIFEST_FILE = "routes-manifest.json";
137061
- var ROUTE_MANIFEST = `_MODERNJS_ROUTE_MANIFEST`;
137160
+ var ROUTE_MANIFEST_FILE = "routes-manifest.json";
137062
137161
  var LOADER_ROUTES_DIR = `loader-routes`;
137063
137162
  var DEFAULT_DEV_HOST = "0.0.0.0";
137064
137163
  var INTERNAL_APP_TOOLS_PLUGINS = {
@@ -137262,6 +137361,15 @@ var require_constants6 = __commonJS({
137262
137361
  ],
137263
137362
  "@modern-js/plugin-nocode": []
137264
137363
  };
137364
+ var DEFAULT_BABEL_PRESET_TYPESCRIPT_OPTIONS = {
137365
+ allowNamespaces: true,
137366
+ allExtensions: true,
137367
+ allowDeclareFields: true,
137368
+ // aligns Babel's behavior with TypeScript's default behavior.
137369
+ // https://babeljs.io/docs/en/babel-preset-typescript#optimizeconstenums
137370
+ optimizeConstEnums: true,
137371
+ isTSX: true
137372
+ };
137265
137373
  }
137266
137374
  });
137267
137375
 
@@ -138783,9 +138891,9 @@ var require_getServerConfig2 = __commonJS({
138783
138891
  }
138784
138892
  });
138785
138893
 
138786
- // ../../../toolkit/utils/dist/tryResolve.js
138787
- var require_tryResolve2 = __commonJS({
138788
- "../../../toolkit/utils/dist/tryResolve.js"(exports, module2) {
138894
+ // ../../../toolkit/utils/dist/resolve.js
138895
+ var require_resolve = __commonJS({
138896
+ "../../../toolkit/utils/dist/resolve.js"(exports, module2) {
138789
138897
  var __defProp2 = Object.defineProperty;
138790
138898
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
138791
138899
  var __getOwnPropNames2 = Object.getOwnPropertyNames;
@@ -138803,12 +138911,13 @@ var require_tryResolve2 = __commonJS({
138803
138911
  return to;
138804
138912
  };
138805
138913
  var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
138806
- var tryResolve_exports = {};
138807
- __export2(tryResolve_exports, {
138914
+ var resolve_exports = {};
138915
+ __export2(resolve_exports, {
138916
+ getAntdMajorVersion: () => getAntdMajorVersion,
138808
138917
  isPackageInstalled: () => isPackageInstalled,
138809
138918
  tryResolve: () => tryResolve
138810
138919
  });
138811
- module2.exports = __toCommonJS2(tryResolve_exports);
138920
+ module2.exports = __toCommonJS2(resolve_exports);
138812
138921
  var import_ensureArray = require_ensureArray2();
138813
138922
  var tryResolve = (name, resolvePath) => {
138814
138923
  let filePath = "";
@@ -138831,6 +138940,17 @@ var require_tryResolve2 = __commonJS({
138831
138940
  return false;
138832
138941
  }
138833
138942
  };
138943
+ var getAntdMajorVersion = (appDirectory) => {
138944
+ try {
138945
+ const pkgJsonPath = require.resolve("antd/package.json", {
138946
+ paths: [appDirectory]
138947
+ });
138948
+ const { version } = require(pkgJsonPath);
138949
+ return Number(version.split(".")[0]);
138950
+ } catch (err) {
138951
+ return null;
138952
+ }
138953
+ };
138834
138954
  }
138835
138955
  });
138836
138956
 
@@ -138891,15 +139011,16 @@ var require_analyzeProject2 = __commonJS({
138891
139011
  });
138892
139012
  module2.exports = __toCommonJS2(analyzeProject_exports);
138893
139013
  var path3 = __toESM2(require("path"));
139014
+ var import_commands = require_commands();
138894
139015
  var import_compiled = require_compiled2();
138895
139016
  var isApiOnly = (appDirectory, entryDir) => __async2(void 0, null, function* () {
138896
139017
  const srcDir = path3.join(appDirectory, entryDir != null ? entryDir : "src");
138897
139018
  const existSrc = yield import_compiled.fs.pathExists(srcDir);
138898
- const options = (0, import_compiled.minimist)(process.argv.slice(2));
139019
+ const options = (0, import_compiled.minimist)((0, import_commands.getArgv)());
138899
139020
  return !existSrc || Boolean(options["api-only"]);
138900
139021
  });
138901
139022
  var isWebOnly = () => __async2(void 0, null, function* () {
138902
- const options = (0, import_compiled.minimist)(process.argv.slice(2));
139023
+ const options = (0, import_compiled.minimist)((0, import_commands.getArgv)());
138903
139024
  return Boolean(options["web-only"]);
138904
139025
  });
138905
139026
  }
@@ -138970,27 +139091,10 @@ var require_chainId2 = __commonJS({
138970
139091
  },
138971
139092
  /** Predefined rule groups */
138972
139093
  ONE_OF: {
138973
- JS: "js",
138974
- TS: "ts",
138975
- CSS: "css",
138976
- LESS: "less",
138977
- SASS: "sass",
138978
- YAML: "yml",
138979
- TOML: "toml",
138980
- FALLBACK: "fallback",
138981
- MARKDOWN: "markdown",
138982
- BFF_CLIENT: "bff-client",
138983
- CSS_MODULES: "css-modules",
138984
- LESS_MODULES: "less-modules",
138985
- SASS_MODULES: "sass-modules",
138986
139094
  SVG: "svg",
138987
139095
  SVG_URL: "svg-url",
138988
139096
  SVG_ASSET: "svg-asset",
138989
- SVG_INLINE: "svg-inline",
138990
- ASSETS: "assets",
138991
- ASSETS_URL: "assets-url",
138992
- ASSETS_INLINE: "assets-inline",
138993
- IMAGE_COMPRESS: "image-compress"
139097
+ SVG_INLINE: "svg-inline"
138994
139098
  },
138995
139099
  /** Predefined loaders */
138996
139100
  USE: {
@@ -139517,6 +139621,143 @@ var require_getTargetDir = __commonJS({
139517
139621
  }
139518
139622
  });
139519
139623
 
139624
+ // ../../../toolkit/utils/dist/babel.js
139625
+ var require_babel = __commonJS({
139626
+ "../../../toolkit/utils/dist/babel.js"(exports, module2) {
139627
+ var __defProp2 = Object.defineProperty;
139628
+ var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
139629
+ var __getOwnPropNames2 = Object.getOwnPropertyNames;
139630
+ var __getOwnPropSymbols2 = Object.getOwnPropertySymbols;
139631
+ var __hasOwnProp2 = Object.prototype.hasOwnProperty;
139632
+ var __propIsEnum2 = Object.prototype.propertyIsEnumerable;
139633
+ var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
139634
+ var __spreadValues2 = (a, b) => {
139635
+ for (var prop in b || (b = {}))
139636
+ if (__hasOwnProp2.call(b, prop))
139637
+ __defNormalProp2(a, prop, b[prop]);
139638
+ if (__getOwnPropSymbols2)
139639
+ for (var prop of __getOwnPropSymbols2(b)) {
139640
+ if (__propIsEnum2.call(b, prop))
139641
+ __defNormalProp2(a, prop, b[prop]);
139642
+ }
139643
+ return a;
139644
+ };
139645
+ var __export2 = (target, all) => {
139646
+ for (var name in all)
139647
+ __defProp2(target, name, { get: all[name], enumerable: true });
139648
+ };
139649
+ var __copyProps2 = (to, from, except, desc) => {
139650
+ if (from && typeof from === "object" || typeof from === "function") {
139651
+ for (let key of __getOwnPropNames2(from))
139652
+ if (!__hasOwnProp2.call(to, key) && key !== except)
139653
+ __defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
139654
+ }
139655
+ return to;
139656
+ };
139657
+ var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
139658
+ var babel_exports = {};
139659
+ __export2(babel_exports, {
139660
+ applyUserBabelConfig: () => applyUserBabelConfig,
139661
+ getBabelUtils: () => getBabelUtils
139662
+ });
139663
+ module2.exports = __toCommonJS2(babel_exports);
139664
+ var import_path4 = require("path");
139665
+ var import_applyOptionsChain = require_applyOptionsChain2();
139666
+ var import_ensureArray = require_ensureArray2();
139667
+ var import_path22 = require_path2();
139668
+ var formatPath = (originPath) => {
139669
+ if ((0, import_path4.isAbsolute)(originPath)) {
139670
+ return originPath.split(import_path4.sep).join("/");
139671
+ }
139672
+ return originPath;
139673
+ };
139674
+ var getPluginItemName = (item) => {
139675
+ if (typeof item === "string") {
139676
+ return formatPath(item);
139677
+ }
139678
+ if (Array.isArray(item) && typeof item[0] === "string") {
139679
+ return formatPath(item[0]);
139680
+ }
139681
+ return null;
139682
+ };
139683
+ var addPlugins = (plugins, config) => {
139684
+ if (config.plugins) {
139685
+ config.plugins.push(...plugins);
139686
+ } else {
139687
+ config.plugins = plugins;
139688
+ }
139689
+ };
139690
+ var addPresets = (presets, config) => {
139691
+ if (config.presets) {
139692
+ config.presets.push(...presets);
139693
+ } else {
139694
+ config.presets = presets;
139695
+ }
139696
+ };
139697
+ var removePlugins = (plugins, config) => {
139698
+ if (!config.plugins) {
139699
+ return;
139700
+ }
139701
+ const removeList = (0, import_ensureArray.ensureArray)(plugins);
139702
+ config.plugins = config.plugins.filter((item) => {
139703
+ const name = getPluginItemName(item);
139704
+ if (name) {
139705
+ return !removeList.find((removeItem) => name.includes(removeItem));
139706
+ }
139707
+ return true;
139708
+ });
139709
+ };
139710
+ var removePresets = (presets, config) => {
139711
+ if (!config.presets) {
139712
+ return;
139713
+ }
139714
+ const removeList = (0, import_ensureArray.ensureArray)(presets);
139715
+ config.presets = config.presets.filter((item) => {
139716
+ const name = getPluginItemName(item);
139717
+ if (name) {
139718
+ return !removeList.find((removeItem) => name.includes(removeItem));
139719
+ }
139720
+ return true;
139721
+ });
139722
+ };
139723
+ var modifyPresetOptions = (presetName, options, presets = []) => {
139724
+ presets.forEach((preset, index) => {
139725
+ if (Array.isArray(preset)) {
139726
+ if (typeof preset[0] === "string" && (0, import_path22.normalizeToPosixPath)(preset[0]).includes(presetName)) {
139727
+ preset[1] = __spreadValues2(__spreadValues2({}, preset[1] || {}), options);
139728
+ }
139729
+ } else if (typeof preset === "string" && (0, import_path22.normalizeToPosixPath)(preset).includes(presetName)) {
139730
+ presets[index] = [preset, options];
139731
+ }
139732
+ });
139733
+ };
139734
+ var getBabelUtils = (config) => {
139735
+ const noop = () => {
139736
+ };
139737
+ return {
139738
+ addPlugins: (plugins) => addPlugins(plugins, config),
139739
+ addPresets: (presets) => addPresets(presets, config),
139740
+ removePlugins: (plugins) => removePlugins(plugins, config),
139741
+ removePresets: (presets) => removePresets(presets, config),
139742
+ // `addIncludes` and `addExcludes` are noop functions by default,
139743
+ // It can be overridden by `extraBabelUtils`.
139744
+ addIncludes: noop,
139745
+ addExcludes: noop,
139746
+ // Compat `presetEnvOptions` and `presetReactOptions` in Eden.
139747
+ modifyPresetEnvOptions: (options) => modifyPresetOptions("@babel/preset-env", options, config.presets || []),
139748
+ modifyPresetReactOptions: (options) => modifyPresetOptions("@babel/preset-react", options, config.presets || [])
139749
+ };
139750
+ };
139751
+ var applyUserBabelConfig = (defaultOptions, userBabelConfig, extraBabelUtils) => {
139752
+ if (userBabelConfig) {
139753
+ const babelUtils = __spreadValues2(__spreadValues2({}, getBabelUtils(defaultOptions)), extraBabelUtils);
139754
+ return (0, import_applyOptionsChain.applyOptionsChain)(defaultOptions, userBabelConfig || {}, babelUtils);
139755
+ }
139756
+ return defaultOptions;
139757
+ };
139758
+ }
139759
+ });
139760
+
139520
139761
  // ../../../toolkit/utils/dist/index.js
139521
139762
  var require_dist3 = __commonJS({
139522
139763
  "../../../toolkit/utils/dist/index.js"(exports, module2) {
@@ -139538,7 +139779,6 @@ var require_dist3 = __commonJS({
139538
139779
  module2.exports = __toCommonJS2(src_exports2);
139539
139780
  __reExport(src_exports2, require_compiled2(), module2.exports);
139540
139781
  __reExport(src_exports2, require_commands(), module2.exports);
139541
- __reExport(src_exports2, require_format2(), module2.exports);
139542
139782
  __reExport(src_exports2, require_FileSizeReporter2(), module2.exports);
139543
139783
  __reExport(src_exports2, require_printBuildError2(), module2.exports);
139544
139784
  __reExport(src_exports2, require_debug5(), module2.exports);
@@ -139570,7 +139810,7 @@ var require_dist3 = __commonJS({
139570
139810
  __reExport(src_exports2, require_wait2(), module2.exports);
139571
139811
  __reExport(src_exports2, require_emptyDir2(), module2.exports);
139572
139812
  __reExport(src_exports2, require_getServerConfig2(), module2.exports);
139573
- __reExport(src_exports2, require_tryResolve2(), module2.exports);
139813
+ __reExport(src_exports2, require_resolve(), module2.exports);
139574
139814
  __reExport(src_exports2, require_analyzeProject2(), module2.exports);
139575
139815
  __reExport(src_exports2, require_chainId2(), module2.exports);
139576
139816
  __reExport(src_exports2, require_version2(), module2.exports);
@@ -139580,6 +139820,7 @@ var require_dist3 = __commonJS({
139580
139820
  __reExport(src_exports2, require_getCoreJsVersion(), module2.exports);
139581
139821
  __reExport(src_exports2, require_react(), module2.exports);
139582
139822
  __reExport(src_exports2, require_getTargetDir(), module2.exports);
139823
+ __reExport(src_exports2, require_babel(), module2.exports);
139583
139824
  }
139584
139825
  });
139585
139826
 
@@ -139673,6 +139914,7 @@ var ZH_LOCALE = {
139673
139914
  self: "请选择你想创建的工程类型",
139674
139915
  mwa: "Web 应用",
139675
139916
  module: "Npm 模块",
139917
+ doc: "文档站",
139676
139918
  monorepo: "Monorepo",
139677
139919
  custom: "自定义",
139678
139920
  default: "默认"
@@ -139769,6 +140011,7 @@ var EN_LOCALE = {
139769
140011
  self: "Please select the solution you want to create",
139770
140012
  mwa: "Web App",
139771
140013
  module: "Npm Module",
140014
+ doc: "Doc Site",
139772
140015
  monorepo: "Monorepo",
139773
140016
  custom: "Custom Solution",
139774
140017
  default: "Default"
@@ -139868,6 +140111,7 @@ var localeKeys = i18n.init("zh", { zh: ZH_LOCALE, en: EN_LOCALE });
139868
140111
  var Solution = /* @__PURE__ */ ((Solution2) => {
139869
140112
  Solution2["MWA"] = "mwa";
139870
140113
  Solution2["Module"] = "module";
140114
+ Solution2["Doc"] = "doc";
139871
140115
  Solution2["Monorepo"] = "monorepo";
139872
140116
  return Solution2;
139873
140117
  })(Solution || {});
@@ -139880,6 +140124,10 @@ var SolutionText = {
139880
140124
  "module"
139881
140125
  /* Module */
139882
140126
  ]: () => i18n.t(localeKeys.solution.module),
140127
+ [
140128
+ "doc"
140129
+ /* Doc */
140130
+ ]: () => i18n.t(localeKeys.solution.doc),
139883
140131
  [
139884
140132
  "monorepo"
139885
140133
  /* Monorepo */
@@ -139894,6 +140142,10 @@ var SolutionToolsMap = {
139894
140142
  "module"
139895
140143
  /* Module */
139896
140144
  ]: "@modern-js/module-tools",
140145
+ [
140146
+ "doc"
140147
+ /* Doc */
140148
+ ]: "@modern-js/doc-tools",
139897
140149
  [
139898
140150
  "monorepo"
139899
140151
  /* Monorepo */