typescript-language-server 4.3.2 → 4.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/README.md +1 -1
- package/lib/cli.mjs +204 -142
- package/lib/cli.mjs.map +1 -1
- package/package.json +13 -12
package/lib/cli.mjs
CHANGED
|
@@ -55,15 +55,13 @@ function getDefaultExportFromCjs(x) {
|
|
|
55
55
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
var commander
|
|
59
|
-
exports: {}
|
|
60
|
-
};
|
|
58
|
+
var commander = {};
|
|
61
59
|
|
|
62
60
|
var argument = {};
|
|
63
61
|
|
|
64
62
|
var error$2 = {};
|
|
65
63
|
|
|
66
|
-
let CommanderError$
|
|
64
|
+
let CommanderError$3 = class CommanderError extends Error {
|
|
67
65
|
constructor(exitCode, code, message) {
|
|
68
66
|
super(message);
|
|
69
67
|
Error.captureStackTrace(this, this.constructor);
|
|
@@ -74,7 +72,7 @@ let CommanderError$2 = class CommanderError extends Error {
|
|
|
74
72
|
}
|
|
75
73
|
};
|
|
76
74
|
|
|
77
|
-
let InvalidArgumentError$
|
|
75
|
+
let InvalidArgumentError$4 = class InvalidArgumentError extends CommanderError$3 {
|
|
78
76
|
constructor(message) {
|
|
79
77
|
super(1, 'commander.invalidArgument', message);
|
|
80
78
|
Error.captureStackTrace(this, this.constructor);
|
|
@@ -82,13 +80,13 @@ let InvalidArgumentError$3 = class InvalidArgumentError extends CommanderError$2
|
|
|
82
80
|
}
|
|
83
81
|
};
|
|
84
82
|
|
|
85
|
-
error$2.CommanderError = CommanderError$
|
|
83
|
+
error$2.CommanderError = CommanderError$3;
|
|
86
84
|
|
|
87
|
-
error$2.InvalidArgumentError = InvalidArgumentError$
|
|
85
|
+
error$2.InvalidArgumentError = InvalidArgumentError$4;
|
|
88
86
|
|
|
89
|
-
const {InvalidArgumentError: InvalidArgumentError$
|
|
87
|
+
const {InvalidArgumentError: InvalidArgumentError$3} = error$2;
|
|
90
88
|
|
|
91
|
-
let Argument$
|
|
89
|
+
let Argument$3 = class Argument {
|
|
92
90
|
constructor(name, description) {
|
|
93
91
|
this.description = description || '';
|
|
94
92
|
this.variadic = false;
|
|
@@ -139,7 +137,7 @@ let Argument$2 = class Argument {
|
|
|
139
137
|
this.argChoices = values.slice();
|
|
140
138
|
this.parseArg = (arg, previous) => {
|
|
141
139
|
if (!this.argChoices.includes(arg)) {
|
|
142
|
-
throw new InvalidArgumentError$
|
|
140
|
+
throw new InvalidArgumentError$3(`Allowed choices are ${this.argChoices.join(', ')}.`);
|
|
143
141
|
}
|
|
144
142
|
if (this.variadic) {
|
|
145
143
|
return this._concatValue(arg, previous);
|
|
@@ -163,7 +161,7 @@ function humanReadableArgName$2(arg) {
|
|
|
163
161
|
return arg.required ? '<' + nameOutput + '>' : '[' + nameOutput + ']';
|
|
164
162
|
}
|
|
165
163
|
|
|
166
|
-
argument.Argument = Argument$
|
|
164
|
+
argument.Argument = Argument$3;
|
|
167
165
|
|
|
168
166
|
argument.humanReadableArgName = humanReadableArgName$2;
|
|
169
167
|
|
|
@@ -173,7 +171,7 @@ var help = {};
|
|
|
173
171
|
|
|
174
172
|
const {humanReadableArgName: humanReadableArgName$1} = argument;
|
|
175
173
|
|
|
176
|
-
let Help$
|
|
174
|
+
let Help$3 = class Help {
|
|
177
175
|
constructor() {
|
|
178
176
|
this.helpWidth = undefined;
|
|
179
177
|
this.sortSubcommands = false;
|
|
@@ -182,11 +180,8 @@ let Help$2 = class Help {
|
|
|
182
180
|
}
|
|
183
181
|
visibleCommands(cmd) {
|
|
184
182
|
const visibleCommands = cmd.commands.filter((cmd => !cmd._hidden));
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
const helpCommand = cmd.createCommand(helpName).helpOption(false);
|
|
188
|
-
helpCommand.description(cmd._helpCommandDescription);
|
|
189
|
-
if (helpArgs) helpCommand.arguments(helpArgs);
|
|
183
|
+
const helpCommand = cmd._getHelpCommand();
|
|
184
|
+
if (helpCommand && !helpCommand._hidden) {
|
|
190
185
|
visibleCommands.push(helpCommand);
|
|
191
186
|
}
|
|
192
187
|
if (this.sortSubcommands) {
|
|
@@ -200,18 +195,17 @@ let Help$2 = class Help {
|
|
|
200
195
|
}
|
|
201
196
|
visibleOptions(cmd) {
|
|
202
197
|
const visibleOptions = cmd.options.filter((option => !option.hidden));
|
|
203
|
-
const
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
if (!
|
|
208
|
-
|
|
209
|
-
} else if (!
|
|
210
|
-
|
|
211
|
-
} else {
|
|
212
|
-
|
|
198
|
+
const helpOption = cmd._getHelpOption();
|
|
199
|
+
if (helpOption && !helpOption.hidden) {
|
|
200
|
+
const removeShort = helpOption.short && cmd._findOption(helpOption.short);
|
|
201
|
+
const removeLong = helpOption.long && cmd._findOption(helpOption.long);
|
|
202
|
+
if (!removeShort && !removeLong) {
|
|
203
|
+
visibleOptions.push(helpOption);
|
|
204
|
+
} else if (helpOption.long && !removeLong) {
|
|
205
|
+
visibleOptions.push(cmd.createOption(helpOption.long, helpOption.description));
|
|
206
|
+
} else if (helpOption.short && !removeShort) {
|
|
207
|
+
visibleOptions.push(cmd.createOption(helpOption.short, helpOption.description));
|
|
213
208
|
}
|
|
214
|
-
visibleOptions.push(helpOption);
|
|
215
209
|
}
|
|
216
210
|
if (this.sortOptions) {
|
|
217
211
|
visibleOptions.sort(this.compareOptions);
|
|
@@ -382,13 +376,13 @@ let Help$2 = class Help {
|
|
|
382
376
|
}
|
|
383
377
|
};
|
|
384
378
|
|
|
385
|
-
help.Help = Help$
|
|
379
|
+
help.Help = Help$3;
|
|
386
380
|
|
|
387
381
|
var option = {};
|
|
388
382
|
|
|
389
|
-
const {InvalidArgumentError: InvalidArgumentError$
|
|
383
|
+
const {InvalidArgumentError: InvalidArgumentError$2} = error$2;
|
|
390
384
|
|
|
391
|
-
let Option$
|
|
385
|
+
let Option$3 = class Option {
|
|
392
386
|
constructor(flags, description) {
|
|
393
387
|
this.flags = flags;
|
|
394
388
|
this.description = description || '';
|
|
@@ -396,7 +390,7 @@ let Option$2 = class Option {
|
|
|
396
390
|
this.optional = flags.includes('[');
|
|
397
391
|
this.variadic = /\w\.\.\.[>\]]$/.test(flags);
|
|
398
392
|
this.mandatory = false;
|
|
399
|
-
const optionFlags = splitOptionFlags
|
|
393
|
+
const optionFlags = splitOptionFlags(flags);
|
|
400
394
|
this.short = optionFlags.shortFlag;
|
|
401
395
|
this.long = optionFlags.longFlag;
|
|
402
396
|
this.negate = false;
|
|
@@ -462,7 +456,7 @@ let Option$2 = class Option {
|
|
|
462
456
|
this.argChoices = values.slice();
|
|
463
457
|
this.parseArg = (arg, previous) => {
|
|
464
458
|
if (!this.argChoices.includes(arg)) {
|
|
465
|
-
throw new InvalidArgumentError$
|
|
459
|
+
throw new InvalidArgumentError$2(`Allowed choices are ${this.argChoices.join(', ')}.`);
|
|
466
460
|
}
|
|
467
461
|
if (this.variadic) {
|
|
468
462
|
return this._concatValue(arg, previous);
|
|
@@ -519,7 +513,7 @@ function camelcase(str) {
|
|
|
519
513
|
return str.split('-').reduce(((str, word) => str + word[0].toUpperCase() + word.slice(1)));
|
|
520
514
|
}
|
|
521
515
|
|
|
522
|
-
function splitOptionFlags
|
|
516
|
+
function splitOptionFlags(flags) {
|
|
523
517
|
let shortFlag;
|
|
524
518
|
let longFlag;
|
|
525
519
|
const flagParts = flags.split(/[ |,]+/);
|
|
@@ -535,9 +529,7 @@ function splitOptionFlags$1(flags) {
|
|
|
535
529
|
};
|
|
536
530
|
}
|
|
537
531
|
|
|
538
|
-
option.Option = Option$
|
|
539
|
-
|
|
540
|
-
option.splitOptionFlags = splitOptionFlags$1;
|
|
532
|
+
option.Option = Option$3;
|
|
541
533
|
|
|
542
534
|
option.DualOptions = DualOptions$1;
|
|
543
535
|
|
|
@@ -621,17 +613,17 @@ const fs$k = require$$0$1;
|
|
|
621
613
|
|
|
622
614
|
const process$1 = require$$4;
|
|
623
615
|
|
|
624
|
-
const {Argument: Argument$
|
|
616
|
+
const {Argument: Argument$2, humanReadableArgName: humanReadableArgName} = argument;
|
|
625
617
|
|
|
626
|
-
const {CommanderError: CommanderError$
|
|
618
|
+
const {CommanderError: CommanderError$2} = error$2;
|
|
627
619
|
|
|
628
|
-
const {Help: Help$
|
|
620
|
+
const {Help: Help$2} = help;
|
|
629
621
|
|
|
630
|
-
const {Option: Option$
|
|
622
|
+
const {Option: Option$2, DualOptions: DualOptions} = option;
|
|
631
623
|
|
|
632
624
|
const {suggestSimilar: suggestSimilar} = suggestSimilar$2;
|
|
633
625
|
|
|
634
|
-
let Command$
|
|
626
|
+
let Command$2 = class Command extends EventEmitter {
|
|
635
627
|
constructor(name) {
|
|
636
628
|
super();
|
|
637
629
|
this.commands = [];
|
|
@@ -673,27 +665,15 @@ let Command$1 = class Command extends EventEmitter {
|
|
|
673
665
|
outputError: (str, write) => write(str)
|
|
674
666
|
};
|
|
675
667
|
this._hidden = false;
|
|
676
|
-
this.
|
|
677
|
-
this._helpFlags = '-h, --help';
|
|
678
|
-
this._helpDescription = 'display help for command';
|
|
679
|
-
this._helpShortFlag = '-h';
|
|
680
|
-
this._helpLongFlag = '--help';
|
|
668
|
+
this._helpOption = undefined;
|
|
681
669
|
this._addImplicitHelpCommand = undefined;
|
|
682
|
-
this.
|
|
683
|
-
this._helpCommandnameAndArgs = 'help [command]';
|
|
684
|
-
this._helpCommandDescription = 'display help for command';
|
|
670
|
+
this._helpCommand = undefined;
|
|
685
671
|
this._helpConfiguration = {};
|
|
686
672
|
}
|
|
687
673
|
copyInheritedSettings(sourceCommand) {
|
|
688
674
|
this._outputConfiguration = sourceCommand._outputConfiguration;
|
|
689
|
-
this.
|
|
690
|
-
this.
|
|
691
|
-
this._helpDescription = sourceCommand._helpDescription;
|
|
692
|
-
this._helpShortFlag = sourceCommand._helpShortFlag;
|
|
693
|
-
this._helpLongFlag = sourceCommand._helpLongFlag;
|
|
694
|
-
this._helpCommandName = sourceCommand._helpCommandName;
|
|
695
|
-
this._helpCommandnameAndArgs = sourceCommand._helpCommandnameAndArgs;
|
|
696
|
-
this._helpCommandDescription = sourceCommand._helpCommandDescription;
|
|
675
|
+
this._helpOption = sourceCommand._helpOption;
|
|
676
|
+
this._helpCommand = sourceCommand._helpCommand;
|
|
697
677
|
this._helpConfiguration = sourceCommand._helpConfiguration;
|
|
698
678
|
this._exitCallback = sourceCommand._exitCallback;
|
|
699
679
|
this._storeOptionsAsProperties = sourceCommand._storeOptionsAsProperties;
|
|
@@ -729,7 +709,7 @@ let Command$1 = class Command extends EventEmitter {
|
|
|
729
709
|
cmd._hidden = !!(opts.noHelp || opts.hidden);
|
|
730
710
|
cmd._executableFile = opts.executableFile || null;
|
|
731
711
|
if (args) cmd.arguments(args);
|
|
732
|
-
this.
|
|
712
|
+
this._registerCommand(cmd);
|
|
733
713
|
cmd.parent = this;
|
|
734
714
|
cmd.copyInheritedSettings(this);
|
|
735
715
|
if (desc) return this;
|
|
@@ -739,7 +719,7 @@ let Command$1 = class Command extends EventEmitter {
|
|
|
739
719
|
return new Command(name);
|
|
740
720
|
}
|
|
741
721
|
createHelp() {
|
|
742
|
-
return Object.assign(new Help$
|
|
722
|
+
return Object.assign(new Help$2, this.configureHelp());
|
|
743
723
|
}
|
|
744
724
|
configureHelp(configuration) {
|
|
745
725
|
if (configuration === undefined) return this._helpConfiguration;
|
|
@@ -767,12 +747,13 @@ let Command$1 = class Command extends EventEmitter {
|
|
|
767
747
|
opts = opts || {};
|
|
768
748
|
if (opts.isDefault) this._defaultCommandName = cmd._name;
|
|
769
749
|
if (opts.noHelp || opts.hidden) cmd._hidden = true;
|
|
770
|
-
this.
|
|
750
|
+
this._registerCommand(cmd);
|
|
771
751
|
cmd.parent = this;
|
|
752
|
+
cmd._checkForBrokenPassThrough();
|
|
772
753
|
return this;
|
|
773
754
|
}
|
|
774
755
|
createArgument(name, description) {
|
|
775
|
-
return new Argument$
|
|
756
|
+
return new Argument$2(name, description);
|
|
776
757
|
}
|
|
777
758
|
argument(name, description, fn, defaultValue) {
|
|
778
759
|
const argument = this.createArgument(name, description);
|
|
@@ -801,24 +782,40 @@ let Command$1 = class Command extends EventEmitter {
|
|
|
801
782
|
this.registeredArguments.push(argument);
|
|
802
783
|
return this;
|
|
803
784
|
}
|
|
804
|
-
|
|
805
|
-
if (enableOrNameAndArgs ===
|
|
806
|
-
this._addImplicitHelpCommand =
|
|
807
|
-
|
|
808
|
-
this._addImplicitHelpCommand = true;
|
|
809
|
-
if (typeof enableOrNameAndArgs === 'string') {
|
|
810
|
-
this._helpCommandName = enableOrNameAndArgs.split(' ')[0];
|
|
811
|
-
this._helpCommandnameAndArgs = enableOrNameAndArgs;
|
|
812
|
-
}
|
|
813
|
-
this._helpCommandDescription = description || this._helpCommandDescription;
|
|
785
|
+
helpCommand(enableOrNameAndArgs, description) {
|
|
786
|
+
if (typeof enableOrNameAndArgs === 'boolean') {
|
|
787
|
+
this._addImplicitHelpCommand = enableOrNameAndArgs;
|
|
788
|
+
return this;
|
|
814
789
|
}
|
|
790
|
+
enableOrNameAndArgs = enableOrNameAndArgs ?? 'help [command]';
|
|
791
|
+
const [, helpName, helpArgs] = enableOrNameAndArgs.match(/([^ ]+) *(.*)/);
|
|
792
|
+
const helpDescription = description ?? 'display help for command';
|
|
793
|
+
const helpCommand = this.createCommand(helpName);
|
|
794
|
+
helpCommand.helpOption(false);
|
|
795
|
+
if (helpArgs) helpCommand.arguments(helpArgs);
|
|
796
|
+
if (helpDescription) helpCommand.description(helpDescription);
|
|
797
|
+
this._addImplicitHelpCommand = true;
|
|
798
|
+
this._helpCommand = helpCommand;
|
|
815
799
|
return this;
|
|
816
800
|
}
|
|
817
|
-
|
|
818
|
-
if (
|
|
819
|
-
|
|
801
|
+
addHelpCommand(helpCommand, deprecatedDescription) {
|
|
802
|
+
if (typeof helpCommand !== 'object') {
|
|
803
|
+
this.helpCommand(helpCommand, deprecatedDescription);
|
|
804
|
+
return this;
|
|
820
805
|
}
|
|
821
|
-
|
|
806
|
+
this._addImplicitHelpCommand = true;
|
|
807
|
+
this._helpCommand = helpCommand;
|
|
808
|
+
return this;
|
|
809
|
+
}
|
|
810
|
+
_getHelpCommand() {
|
|
811
|
+
const hasImplicitHelpCommand = this._addImplicitHelpCommand ?? (this.commands.length && !this._actionHandler && !this._findCommand('help'));
|
|
812
|
+
if (hasImplicitHelpCommand) {
|
|
813
|
+
if (this._helpCommand === undefined) {
|
|
814
|
+
this.helpCommand(undefined, undefined);
|
|
815
|
+
}
|
|
816
|
+
return this._helpCommand;
|
|
817
|
+
}
|
|
818
|
+
return null;
|
|
822
819
|
}
|
|
823
820
|
hook(event, listener) {
|
|
824
821
|
const allowedValues = [ 'preSubcommand', 'preAction', 'postAction' ];
|
|
@@ -846,7 +843,7 @@ let Command$1 = class Command extends EventEmitter {
|
|
|
846
843
|
}
|
|
847
844
|
_exit(exitCode, code, message) {
|
|
848
845
|
if (this._exitCallback) {
|
|
849
|
-
this._exitCallback(new CommanderError$
|
|
846
|
+
this._exitCallback(new CommanderError$2(exitCode, code, message));
|
|
850
847
|
}
|
|
851
848
|
process$1.exit(exitCode);
|
|
852
849
|
}
|
|
@@ -866,7 +863,7 @@ let Command$1 = class Command extends EventEmitter {
|
|
|
866
863
|
return this;
|
|
867
864
|
}
|
|
868
865
|
createOption(flags, description) {
|
|
869
|
-
return new Option$
|
|
866
|
+
return new Option$2(flags, description);
|
|
870
867
|
}
|
|
871
868
|
_callParseArg(target, value, previous, invalidArgumentMessage) {
|
|
872
869
|
try {
|
|
@@ -882,7 +879,26 @@ let Command$1 = class Command extends EventEmitter {
|
|
|
882
879
|
throw err;
|
|
883
880
|
}
|
|
884
881
|
}
|
|
882
|
+
_registerOption(option) {
|
|
883
|
+
const matchingOption = option.short && this._findOption(option.short) || option.long && this._findOption(option.long);
|
|
884
|
+
if (matchingOption) {
|
|
885
|
+
const matchingFlag = option.long && this._findOption(option.long) ? option.long : option.short;
|
|
886
|
+
throw new Error(`Cannot add option '${option.flags}'${this._name && ` to command '${this._name}'`} due to conflicting flag '${matchingFlag}'\n- already used by option '${matchingOption.flags}'`);
|
|
887
|
+
}
|
|
888
|
+
this.options.push(option);
|
|
889
|
+
}
|
|
890
|
+
_registerCommand(command) {
|
|
891
|
+
const knownBy = cmd => [ cmd.name() ].concat(cmd.aliases());
|
|
892
|
+
const alreadyUsed = knownBy(command).find((name => this._findCommand(name)));
|
|
893
|
+
if (alreadyUsed) {
|
|
894
|
+
const existingCmd = knownBy(this._findCommand(alreadyUsed)).join('|');
|
|
895
|
+
const newCmd = knownBy(command).join('|');
|
|
896
|
+
throw new Error(`cannot add command '${newCmd}' as already have command '${existingCmd}'`);
|
|
897
|
+
}
|
|
898
|
+
this.commands.push(command);
|
|
899
|
+
}
|
|
885
900
|
addOption(option) {
|
|
901
|
+
this._registerOption(option);
|
|
886
902
|
const oname = option.name();
|
|
887
903
|
const name = option.attributeName();
|
|
888
904
|
if (option.negate) {
|
|
@@ -893,7 +909,6 @@ let Command$1 = class Command extends EventEmitter {
|
|
|
893
909
|
} else if (option.defaultValue !== undefined) {
|
|
894
910
|
this.setOptionValueWithSource(name, option.defaultValue, 'default');
|
|
895
911
|
}
|
|
896
|
-
this.options.push(option);
|
|
897
912
|
const handleOptionValue = (val, invalidValueMessage, valueSource) => {
|
|
898
913
|
if (val == null && option.presetArg !== undefined) {
|
|
899
914
|
val = option.presetArg;
|
|
@@ -928,7 +943,7 @@ let Command$1 = class Command extends EventEmitter {
|
|
|
928
943
|
return this;
|
|
929
944
|
}
|
|
930
945
|
_optionEx(config, flags, description, fn, defaultValue) {
|
|
931
|
-
if (typeof flags === 'object' && flags instanceof Option$
|
|
946
|
+
if (typeof flags === 'object' && flags instanceof Option$2) {
|
|
932
947
|
throw new Error('To add an Option object use addOption() instead of option() or requiredOption()');
|
|
933
948
|
}
|
|
934
949
|
const option = this.createOption(flags, description);
|
|
@@ -973,15 +988,21 @@ let Command$1 = class Command extends EventEmitter {
|
|
|
973
988
|
}
|
|
974
989
|
passThroughOptions(passThrough = true) {
|
|
975
990
|
this._passThroughOptions = !!passThrough;
|
|
976
|
-
|
|
977
|
-
throw new Error('passThroughOptions can not be used without turning on enablePositionalOptions for parent command(s)');
|
|
978
|
-
}
|
|
991
|
+
this._checkForBrokenPassThrough();
|
|
979
992
|
return this;
|
|
980
993
|
}
|
|
994
|
+
_checkForBrokenPassThrough() {
|
|
995
|
+
if (this.parent && this._passThroughOptions && !this.parent._enablePositionalOptions) {
|
|
996
|
+
throw new Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`);
|
|
997
|
+
}
|
|
998
|
+
}
|
|
981
999
|
storeOptionsAsProperties(storeAsProperties = true) {
|
|
982
1000
|
if (this.options.length) {
|
|
983
1001
|
throw new Error('call .storeOptionsAsProperties() before adding options');
|
|
984
1002
|
}
|
|
1003
|
+
if (Object.keys(this._optionValues).length) {
|
|
1004
|
+
throw new Error('call .storeOptionsAsProperties() before setting option values');
|
|
1005
|
+
}
|
|
985
1006
|
this._storeOptionsAsProperties = !!storeAsProperties;
|
|
986
1007
|
return this;
|
|
987
1008
|
}
|
|
@@ -1132,13 +1153,14 @@ let Command$1 = class Command extends EventEmitter {
|
|
|
1132
1153
|
}));
|
|
1133
1154
|
}
|
|
1134
1155
|
const exitCallback = this._exitCallback;
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1156
|
+
proc.on('close', ((code, _signal) => {
|
|
1157
|
+
code = code ?? 1;
|
|
1158
|
+
if (!exitCallback) {
|
|
1159
|
+
process$1.exit(code);
|
|
1160
|
+
} else {
|
|
1161
|
+
exitCallback(new CommanderError$2(code, 'commander.executeSubCommandAsync', '(close)'));
|
|
1162
|
+
}
|
|
1163
|
+
}));
|
|
1142
1164
|
proc.on('error', (err => {
|
|
1143
1165
|
if (err.code === 'ENOENT') {
|
|
1144
1166
|
const executableDirMessage = executableDir ? `searched for local subcommand relative to directory '${executableDir}'` : 'no directory for search for local subcommand, use .executableDir() to supply a custom directory';
|
|
@@ -1150,7 +1172,7 @@ let Command$1 = class Command extends EventEmitter {
|
|
|
1150
1172
|
if (!exitCallback) {
|
|
1151
1173
|
process$1.exit(1);
|
|
1152
1174
|
} else {
|
|
1153
|
-
const wrappedError = new CommanderError$
|
|
1175
|
+
const wrappedError = new CommanderError$2(1, 'commander.executeSubCommandAsync', '(error)');
|
|
1154
1176
|
wrappedError.nestedError = err;
|
|
1155
1177
|
exitCallback(wrappedError);
|
|
1156
1178
|
}
|
|
@@ -1181,7 +1203,7 @@ let Command$1 = class Command extends EventEmitter {
|
|
|
1181
1203
|
if (subCommand && !subCommand._executableHandler) {
|
|
1182
1204
|
subCommand.help();
|
|
1183
1205
|
}
|
|
1184
|
-
return this._dispatchSubcommand(subcommandName, [], [ this.
|
|
1206
|
+
return this._dispatchSubcommand(subcommandName, [], [ this._getHelpOption()?.long ?? this._getHelpOption()?.short ?? '--help' ]);
|
|
1185
1207
|
}
|
|
1186
1208
|
_checkNumberOfArguments() {
|
|
1187
1209
|
this.registeredArguments.forEach(((arg, i) => {
|
|
@@ -1272,11 +1294,11 @@ let Command$1 = class Command extends EventEmitter {
|
|
|
1272
1294
|
if (operands && this._findCommand(operands[0])) {
|
|
1273
1295
|
return this._dispatchSubcommand(operands[0], operands.slice(1), unknown);
|
|
1274
1296
|
}
|
|
1275
|
-
if (this.
|
|
1297
|
+
if (this._getHelpCommand() && operands[0] === this._getHelpCommand().name()) {
|
|
1276
1298
|
return this._dispatchHelpCommand(operands[1]);
|
|
1277
1299
|
}
|
|
1278
1300
|
if (this._defaultCommandName) {
|
|
1279
|
-
|
|
1301
|
+
this._outputHelpIfRequested(unknown);
|
|
1280
1302
|
return this._dispatchSubcommand(this._defaultCommandName, operands, unknown);
|
|
1281
1303
|
}
|
|
1282
1304
|
if (this.commands.length && this.args.length === 0 && !this._actionHandler && !this._defaultCommandName) {
|
|
@@ -1284,7 +1306,7 @@ let Command$1 = class Command extends EventEmitter {
|
|
|
1284
1306
|
error: true
|
|
1285
1307
|
});
|
|
1286
1308
|
}
|
|
1287
|
-
|
|
1309
|
+
this._outputHelpIfRequested(parsed.unknown);
|
|
1288
1310
|
this._checkForMissingMandatoryOptions();
|
|
1289
1311
|
this._checkForConflictingOptions();
|
|
1290
1312
|
const checkForUnknownOptions = () => {
|
|
@@ -1439,7 +1461,7 @@ let Command$1 = class Command extends EventEmitter {
|
|
|
1439
1461
|
operands.push(arg);
|
|
1440
1462
|
if (args.length > 0) unknown.push(...args);
|
|
1441
1463
|
break;
|
|
1442
|
-
} else if (
|
|
1464
|
+
} else if (this._getHelpCommand() && arg === this._getHelpCommand().name()) {
|
|
1443
1465
|
operands.push(arg);
|
|
1444
1466
|
if (args.length > 0) operands.push(...args);
|
|
1445
1467
|
break;
|
|
@@ -1608,7 +1630,7 @@ let Command$1 = class Command extends EventEmitter {
|
|
|
1608
1630
|
description = description || 'output the version number';
|
|
1609
1631
|
const versionOption = this.createOption(flags, description);
|
|
1610
1632
|
this._versionOptionName = versionOption.attributeName();
|
|
1611
|
-
this.
|
|
1633
|
+
this._registerOption(versionOption);
|
|
1612
1634
|
this.on('option:' + versionOption.name(), (() => {
|
|
1613
1635
|
this._outputConfiguration.writeOut(`${str}\n`);
|
|
1614
1636
|
this._exit(0, 'commander.version', str);
|
|
@@ -1635,6 +1657,11 @@ let Command$1 = class Command extends EventEmitter {
|
|
|
1635
1657
|
command = this.commands[this.commands.length - 1];
|
|
1636
1658
|
}
|
|
1637
1659
|
if (alias === command._name) throw new Error('Command alias can\'t be the same as its name');
|
|
1660
|
+
const matchingCommand = this.parent?._findCommand(alias);
|
|
1661
|
+
if (matchingCommand) {
|
|
1662
|
+
const existingCmd = [ matchingCommand.name() ].concat(matchingCommand.aliases()).join('|');
|
|
1663
|
+
throw new Error(`cannot add alias '${alias}' to command '${this.name()}' as already have command '${existingCmd}'`);
|
|
1664
|
+
}
|
|
1638
1665
|
command._aliases.push(alias);
|
|
1639
1666
|
return this;
|
|
1640
1667
|
}
|
|
@@ -1647,7 +1674,7 @@ let Command$1 = class Command extends EventEmitter {
|
|
|
1647
1674
|
if (str === undefined) {
|
|
1648
1675
|
if (this._usage) return this._usage;
|
|
1649
1676
|
const args = this.registeredArguments.map((arg => humanReadableArgName(arg)));
|
|
1650
|
-
return [].concat(this.options.length || this.
|
|
1677
|
+
return [].concat(this.options.length || this._helpOption !== null ? '[options]' : [], this.commands.length ? '[command]' : [], this.registeredArguments.length ? args : []).join(' ');
|
|
1651
1678
|
}
|
|
1652
1679
|
this._usage = str;
|
|
1653
1680
|
return this;
|
|
@@ -1705,22 +1732,34 @@ let Command$1 = class Command extends EventEmitter {
|
|
|
1705
1732
|
}
|
|
1706
1733
|
}
|
|
1707
1734
|
context.write(helpInformation);
|
|
1708
|
-
if (this.
|
|
1709
|
-
this.emit(this.
|
|
1735
|
+
if (this._getHelpOption()?.long) {
|
|
1736
|
+
this.emit(this._getHelpOption().long);
|
|
1710
1737
|
}
|
|
1711
1738
|
this.emit('afterHelp', context);
|
|
1712
1739
|
this._getCommandAndAncestors().forEach((command => command.emit('afterAllHelp', context)));
|
|
1713
1740
|
}
|
|
1714
1741
|
helpOption(flags, description) {
|
|
1715
1742
|
if (typeof flags === 'boolean') {
|
|
1716
|
-
|
|
1743
|
+
if (flags) {
|
|
1744
|
+
this._helpOption = this._helpOption ?? undefined;
|
|
1745
|
+
} else {
|
|
1746
|
+
this._helpOption = null;
|
|
1747
|
+
}
|
|
1717
1748
|
return this;
|
|
1718
1749
|
}
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
this
|
|
1723
|
-
|
|
1750
|
+
flags = flags ?? '-h, --help';
|
|
1751
|
+
description = description ?? 'display help for command';
|
|
1752
|
+
this._helpOption = this.createOption(flags, description);
|
|
1753
|
+
return this;
|
|
1754
|
+
}
|
|
1755
|
+
_getHelpOption() {
|
|
1756
|
+
if (this._helpOption === undefined) {
|
|
1757
|
+
this.helpOption(undefined, undefined);
|
|
1758
|
+
}
|
|
1759
|
+
return this._helpOption;
|
|
1760
|
+
}
|
|
1761
|
+
addHelpOption(option) {
|
|
1762
|
+
this._helpOption = option;
|
|
1724
1763
|
return this;
|
|
1725
1764
|
}
|
|
1726
1765
|
help(contextOptions) {
|
|
@@ -1753,15 +1792,15 @@ let Command$1 = class Command extends EventEmitter {
|
|
|
1753
1792
|
}));
|
|
1754
1793
|
return this;
|
|
1755
1794
|
}
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1795
|
+
_outputHelpIfRequested(args) {
|
|
1796
|
+
const helpOption = this._getHelpOption();
|
|
1797
|
+
const helpRequested = helpOption && args.find((arg => helpOption.is(arg)));
|
|
1798
|
+
if (helpRequested) {
|
|
1799
|
+
this.outputHelp();
|
|
1800
|
+
this._exit(0, 'commander.helpDisplayed', '(outputHelp)');
|
|
1801
|
+
}
|
|
1763
1802
|
}
|
|
1764
|
-
}
|
|
1803
|
+
};
|
|
1765
1804
|
|
|
1766
1805
|
function incrementNodeInspectorPort(args) {
|
|
1767
1806
|
return args.map((arg => {
|
|
@@ -1793,28 +1832,39 @@ function incrementNodeInspectorPort(args) {
|
|
|
1793
1832
|
}));
|
|
1794
1833
|
}
|
|
1795
1834
|
|
|
1796
|
-
command.Command = Command$
|
|
1835
|
+
command.Command = Command$2;
|
|
1797
1836
|
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1837
|
+
const {Argument: Argument$1} = argument;
|
|
1838
|
+
|
|
1839
|
+
const {Command: Command$1} = command;
|
|
1840
|
+
|
|
1841
|
+
const {CommanderError: CommanderError$1, InvalidArgumentError: InvalidArgumentError$1} = error$2;
|
|
1842
|
+
|
|
1843
|
+
const {Help: Help$1} = help;
|
|
1844
|
+
|
|
1845
|
+
const {Option: Option$1} = option;
|
|
1846
|
+
|
|
1847
|
+
commander.program = new Command$1;
|
|
1848
|
+
|
|
1849
|
+
commander.createCommand = name => new Command$1(name);
|
|
1850
|
+
|
|
1851
|
+
commander.createOption = (flags, description) => new Option$1(flags, description);
|
|
1852
|
+
|
|
1853
|
+
commander.createArgument = (name, description) => new Argument$1(name, description);
|
|
1854
|
+
|
|
1855
|
+
commander.Command = Command$1;
|
|
1856
|
+
|
|
1857
|
+
commander.Option = Option$1;
|
|
1858
|
+
|
|
1859
|
+
commander.Argument = Argument$1;
|
|
1860
|
+
|
|
1861
|
+
commander.Help = Help$1;
|
|
1862
|
+
|
|
1863
|
+
commander.CommanderError = CommanderError$1;
|
|
1864
|
+
|
|
1865
|
+
commander.InvalidArgumentError = InvalidArgumentError$1;
|
|
1866
|
+
|
|
1867
|
+
commander.InvalidOptionArgumentError = InvalidArgumentError$1;
|
|
1818
1868
|
|
|
1819
1869
|
const {program: program$1, createCommand: createCommand, createArgument: createArgument, createOption: createOption, CommanderError: CommanderError, InvalidArgumentError: InvalidArgumentError, InvalidOptionArgumentError: InvalidOptionArgumentError, Command: Command, Argument: Argument, Option: Option, Help: Help} = commander;
|
|
1820
1870
|
|
|
@@ -14697,8 +14747,11 @@ var debug_1 = debug$1;
|
|
|
14697
14747
|
createToken('XRANGEPLAINLOOSE', `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})` + `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` + `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` + `(?:${src[t.PRERELEASELOOSE]})?${src[t.BUILD]}?` + `)?)?`);
|
|
14698
14748
|
createToken('XRANGE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`);
|
|
14699
14749
|
createToken('XRANGELOOSE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`);
|
|
14700
|
-
createToken('
|
|
14750
|
+
createToken('COERCEPLAIN', `${'(^|[^\\d])' + '(\\d{1,'}${MAX_SAFE_COMPONENT_LENGTH}})` + `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` + `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?`);
|
|
14751
|
+
createToken('COERCE', `${src[t.COERCEPLAIN]}(?:$|[^\\d])`);
|
|
14752
|
+
createToken('COERCEFULL', src[t.COERCEPLAIN] + `(?:${src[t.PRERELEASE]})?` + `(?:${src[t.BUILD]})?` + `(?:$|[^\\d])`);
|
|
14701
14753
|
createToken('COERCERTL', src[t.COERCE], true);
|
|
14754
|
+
createToken('COERCERTLFULL', src[t.COERCEFULL], true);
|
|
14702
14755
|
createToken('LONETILDE', '(?:~>?)');
|
|
14703
14756
|
createToken('TILDETRIM', `(\\s*)${src[t.LONETILDE]}\\s+`, true);
|
|
14704
14757
|
exports.tildeTrimReplace = '$1~';
|
|
@@ -15282,21 +15335,27 @@ const coerce$1 = (version, options) => {
|
|
|
15282
15335
|
options = options || {};
|
|
15283
15336
|
let match = null;
|
|
15284
15337
|
if (!options.rtl) {
|
|
15285
|
-
match = version.match(re[t.COERCE]);
|
|
15338
|
+
match = version.match(options.includePrerelease ? re[t.COERCEFULL] : re[t.COERCE]);
|
|
15286
15339
|
} else {
|
|
15340
|
+
const coerceRtlRegex = options.includePrerelease ? re[t.COERCERTLFULL] : re[t.COERCERTL];
|
|
15287
15341
|
let next;
|
|
15288
|
-
while ((next =
|
|
15342
|
+
while ((next = coerceRtlRegex.exec(version)) && (!match || match.index + match[0].length !== version.length)) {
|
|
15289
15343
|
if (!match || next.index + next[0].length !== match.index + match[0].length) {
|
|
15290
15344
|
match = next;
|
|
15291
15345
|
}
|
|
15292
|
-
|
|
15346
|
+
coerceRtlRegex.lastIndex = next.index + next[1].length + next[2].length;
|
|
15293
15347
|
}
|
|
15294
|
-
|
|
15348
|
+
coerceRtlRegex.lastIndex = -1;
|
|
15295
15349
|
}
|
|
15296
15350
|
if (match === null) {
|
|
15297
15351
|
return null;
|
|
15298
15352
|
}
|
|
15299
|
-
|
|
15353
|
+
const major = match[2];
|
|
15354
|
+
const minor = match[3] || '0';
|
|
15355
|
+
const patch = match[4] || '0';
|
|
15356
|
+
const prerelease = options.includePrerelease && match[5] ? `-${match[5]}` : '';
|
|
15357
|
+
const build = options.includePrerelease && match[6] ? `+${match[6]}` : '';
|
|
15358
|
+
return parse$1(`${major}.${minor}.${patch}${prerelease}${build}`, options);
|
|
15300
15359
|
};
|
|
15301
15360
|
|
|
15302
15361
|
var coerce_1 = coerce$1;
|
|
@@ -19595,6 +19654,9 @@ class FileDiagnostics {
|
|
|
19595
19654
|
this.firePublishDiagnostics = pDebounce((() => this.publishDiagnostics()), 50);
|
|
19596
19655
|
}
|
|
19597
19656
|
update(kind, diagnostics) {
|
|
19657
|
+
if (this.diagnosticsPerKind.get(kind)?.length === 0 && diagnostics.length === 0) {
|
|
19658
|
+
return;
|
|
19659
|
+
}
|
|
19598
19660
|
this.diagnosticsPerKind.set(kind, diagnostics);
|
|
19599
19661
|
this.firePublishDiagnostics();
|
|
19600
19662
|
}
|
|
@@ -19794,7 +19856,7 @@ function getTagBodyText(tag, filePathConverter) {
|
|
|
19794
19856
|
if (/^\s*[~`]{3}/m.test(text)) {
|
|
19795
19857
|
return text;
|
|
19796
19858
|
}
|
|
19797
|
-
return '
|
|
19859
|
+
return '```typescript\n' + text + '\n```';
|
|
19798
19860
|
}
|
|
19799
19861
|
const text = convertLinkTags(tag.text, filePathConverter);
|
|
19800
19862
|
switch (tag.name) {
|