@uipath/common 0.1.13 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +2338 -70
- package/package.json +7 -12
package/dist/index.js
CHANGED
|
@@ -1,6 +1,2130 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
function __accessProp(key) {
|
|
8
|
+
return this[key];
|
|
9
|
+
}
|
|
10
|
+
var __toESMCache_node;
|
|
11
|
+
var __toESMCache_esm;
|
|
12
|
+
var __toESM = (mod, isNodeMode, target) => {
|
|
13
|
+
var canCache = mod != null && typeof mod === "object";
|
|
14
|
+
if (canCache) {
|
|
15
|
+
var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
|
|
16
|
+
var cached = cache.get(mod);
|
|
17
|
+
if (cached)
|
|
18
|
+
return cached;
|
|
19
|
+
}
|
|
20
|
+
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
21
|
+
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
22
|
+
for (let key of __getOwnPropNames(mod))
|
|
23
|
+
if (!__hasOwnProp.call(to, key))
|
|
24
|
+
__defProp(to, key, {
|
|
25
|
+
get: __accessProp.bind(mod, key),
|
|
26
|
+
enumerable: true
|
|
27
|
+
});
|
|
28
|
+
if (canCache)
|
|
29
|
+
cache.set(mod, to);
|
|
30
|
+
return to;
|
|
31
|
+
};
|
|
32
|
+
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
2
33
|
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
3
34
|
|
|
35
|
+
// ../../node_modules/commander/lib/error.js
|
|
36
|
+
var require_error = __commonJS((exports) => {
|
|
37
|
+
class CommanderError extends Error {
|
|
38
|
+
constructor(exitCode, code, message) {
|
|
39
|
+
super(message);
|
|
40
|
+
Error.captureStackTrace(this, this.constructor);
|
|
41
|
+
this.name = this.constructor.name;
|
|
42
|
+
this.code = code;
|
|
43
|
+
this.exitCode = exitCode;
|
|
44
|
+
this.nestedError = undefined;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
class InvalidArgumentError extends CommanderError {
|
|
49
|
+
constructor(message) {
|
|
50
|
+
super(1, "commander.invalidArgument", message);
|
|
51
|
+
Error.captureStackTrace(this, this.constructor);
|
|
52
|
+
this.name = this.constructor.name;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
exports.CommanderError = CommanderError;
|
|
56
|
+
exports.InvalidArgumentError = InvalidArgumentError;
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
// ../../node_modules/commander/lib/argument.js
|
|
60
|
+
var require_argument = __commonJS((exports) => {
|
|
61
|
+
var { InvalidArgumentError } = require_error();
|
|
62
|
+
|
|
63
|
+
class Argument {
|
|
64
|
+
constructor(name, description) {
|
|
65
|
+
this.description = description || "";
|
|
66
|
+
this.variadic = false;
|
|
67
|
+
this.parseArg = undefined;
|
|
68
|
+
this.defaultValue = undefined;
|
|
69
|
+
this.defaultValueDescription = undefined;
|
|
70
|
+
this.argChoices = undefined;
|
|
71
|
+
switch (name[0]) {
|
|
72
|
+
case "<":
|
|
73
|
+
this.required = true;
|
|
74
|
+
this._name = name.slice(1, -1);
|
|
75
|
+
break;
|
|
76
|
+
case "[":
|
|
77
|
+
this.required = false;
|
|
78
|
+
this._name = name.slice(1, -1);
|
|
79
|
+
break;
|
|
80
|
+
default:
|
|
81
|
+
this.required = true;
|
|
82
|
+
this._name = name;
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
if (this._name.endsWith("...")) {
|
|
86
|
+
this.variadic = true;
|
|
87
|
+
this._name = this._name.slice(0, -3);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
name() {
|
|
91
|
+
return this._name;
|
|
92
|
+
}
|
|
93
|
+
_collectValue(value, previous) {
|
|
94
|
+
if (previous === this.defaultValue || !Array.isArray(previous)) {
|
|
95
|
+
return [value];
|
|
96
|
+
}
|
|
97
|
+
previous.push(value);
|
|
98
|
+
return previous;
|
|
99
|
+
}
|
|
100
|
+
default(value, description) {
|
|
101
|
+
this.defaultValue = value;
|
|
102
|
+
this.defaultValueDescription = description;
|
|
103
|
+
return this;
|
|
104
|
+
}
|
|
105
|
+
argParser(fn) {
|
|
106
|
+
this.parseArg = fn;
|
|
107
|
+
return this;
|
|
108
|
+
}
|
|
109
|
+
choices(values) {
|
|
110
|
+
this.argChoices = values.slice();
|
|
111
|
+
this.parseArg = (arg, previous) => {
|
|
112
|
+
if (!this.argChoices.includes(arg)) {
|
|
113
|
+
throw new InvalidArgumentError(`Allowed choices are ${this.argChoices.join(", ")}.`);
|
|
114
|
+
}
|
|
115
|
+
if (this.variadic) {
|
|
116
|
+
return this._collectValue(arg, previous);
|
|
117
|
+
}
|
|
118
|
+
return arg;
|
|
119
|
+
};
|
|
120
|
+
return this;
|
|
121
|
+
}
|
|
122
|
+
argRequired() {
|
|
123
|
+
this.required = true;
|
|
124
|
+
return this;
|
|
125
|
+
}
|
|
126
|
+
argOptional() {
|
|
127
|
+
this.required = false;
|
|
128
|
+
return this;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
function humanReadableArgName(arg) {
|
|
132
|
+
const nameOutput = arg.name() + (arg.variadic === true ? "..." : "");
|
|
133
|
+
return arg.required ? "<" + nameOutput + ">" : "[" + nameOutput + "]";
|
|
134
|
+
}
|
|
135
|
+
exports.Argument = Argument;
|
|
136
|
+
exports.humanReadableArgName = humanReadableArgName;
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
// ../../node_modules/commander/lib/help.js
|
|
140
|
+
var require_help = __commonJS((exports) => {
|
|
141
|
+
var { humanReadableArgName } = require_argument();
|
|
142
|
+
|
|
143
|
+
class Help {
|
|
144
|
+
constructor() {
|
|
145
|
+
this.helpWidth = undefined;
|
|
146
|
+
this.minWidthToWrap = 40;
|
|
147
|
+
this.sortSubcommands = false;
|
|
148
|
+
this.sortOptions = false;
|
|
149
|
+
this.showGlobalOptions = false;
|
|
150
|
+
}
|
|
151
|
+
prepareContext(contextOptions) {
|
|
152
|
+
this.helpWidth = this.helpWidth ?? contextOptions.helpWidth ?? 80;
|
|
153
|
+
}
|
|
154
|
+
visibleCommands(cmd) {
|
|
155
|
+
const visibleCommands = cmd.commands.filter((cmd2) => !cmd2._hidden);
|
|
156
|
+
const helpCommand = cmd._getHelpCommand();
|
|
157
|
+
if (helpCommand && !helpCommand._hidden) {
|
|
158
|
+
visibleCommands.push(helpCommand);
|
|
159
|
+
}
|
|
160
|
+
if (this.sortSubcommands) {
|
|
161
|
+
visibleCommands.sort((a, b) => {
|
|
162
|
+
return a.name().localeCompare(b.name());
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
return visibleCommands;
|
|
166
|
+
}
|
|
167
|
+
compareOptions(a, b) {
|
|
168
|
+
const getSortKey = (option) => {
|
|
169
|
+
return option.short ? option.short.replace(/^-/, "") : option.long.replace(/^--/, "");
|
|
170
|
+
};
|
|
171
|
+
return getSortKey(a).localeCompare(getSortKey(b));
|
|
172
|
+
}
|
|
173
|
+
visibleOptions(cmd) {
|
|
174
|
+
const visibleOptions = cmd.options.filter((option) => !option.hidden);
|
|
175
|
+
const helpOption = cmd._getHelpOption();
|
|
176
|
+
if (helpOption && !helpOption.hidden) {
|
|
177
|
+
const removeShort = helpOption.short && cmd._findOption(helpOption.short);
|
|
178
|
+
const removeLong = helpOption.long && cmd._findOption(helpOption.long);
|
|
179
|
+
if (!removeShort && !removeLong) {
|
|
180
|
+
visibleOptions.push(helpOption);
|
|
181
|
+
} else if (helpOption.long && !removeLong) {
|
|
182
|
+
visibleOptions.push(cmd.createOption(helpOption.long, helpOption.description));
|
|
183
|
+
} else if (helpOption.short && !removeShort) {
|
|
184
|
+
visibleOptions.push(cmd.createOption(helpOption.short, helpOption.description));
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
if (this.sortOptions) {
|
|
188
|
+
visibleOptions.sort(this.compareOptions);
|
|
189
|
+
}
|
|
190
|
+
return visibleOptions;
|
|
191
|
+
}
|
|
192
|
+
visibleGlobalOptions(cmd) {
|
|
193
|
+
if (!this.showGlobalOptions)
|
|
194
|
+
return [];
|
|
195
|
+
const globalOptions = [];
|
|
196
|
+
for (let ancestorCmd = cmd.parent;ancestorCmd; ancestorCmd = ancestorCmd.parent) {
|
|
197
|
+
const visibleOptions = ancestorCmd.options.filter((option) => !option.hidden);
|
|
198
|
+
globalOptions.push(...visibleOptions);
|
|
199
|
+
}
|
|
200
|
+
if (this.sortOptions) {
|
|
201
|
+
globalOptions.sort(this.compareOptions);
|
|
202
|
+
}
|
|
203
|
+
return globalOptions;
|
|
204
|
+
}
|
|
205
|
+
visibleArguments(cmd) {
|
|
206
|
+
if (cmd._argsDescription) {
|
|
207
|
+
cmd.registeredArguments.forEach((argument) => {
|
|
208
|
+
argument.description = argument.description || cmd._argsDescription[argument.name()] || "";
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
if (cmd.registeredArguments.find((argument) => argument.description)) {
|
|
212
|
+
return cmd.registeredArguments;
|
|
213
|
+
}
|
|
214
|
+
return [];
|
|
215
|
+
}
|
|
216
|
+
subcommandTerm(cmd) {
|
|
217
|
+
const args = cmd.registeredArguments.map((arg) => humanReadableArgName(arg)).join(" ");
|
|
218
|
+
return cmd._name + (cmd._aliases[0] ? "|" + cmd._aliases[0] : "") + (cmd.options.length ? " [options]" : "") + (args ? " " + args : "");
|
|
219
|
+
}
|
|
220
|
+
optionTerm(option) {
|
|
221
|
+
return option.flags;
|
|
222
|
+
}
|
|
223
|
+
argumentTerm(argument) {
|
|
224
|
+
return argument.name();
|
|
225
|
+
}
|
|
226
|
+
longestSubcommandTermLength(cmd, helper) {
|
|
227
|
+
return helper.visibleCommands(cmd).reduce((max, command) => {
|
|
228
|
+
return Math.max(max, this.displayWidth(helper.styleSubcommandTerm(helper.subcommandTerm(command))));
|
|
229
|
+
}, 0);
|
|
230
|
+
}
|
|
231
|
+
longestOptionTermLength(cmd, helper) {
|
|
232
|
+
return helper.visibleOptions(cmd).reduce((max, option) => {
|
|
233
|
+
return Math.max(max, this.displayWidth(helper.styleOptionTerm(helper.optionTerm(option))));
|
|
234
|
+
}, 0);
|
|
235
|
+
}
|
|
236
|
+
longestGlobalOptionTermLength(cmd, helper) {
|
|
237
|
+
return helper.visibleGlobalOptions(cmd).reduce((max, option) => {
|
|
238
|
+
return Math.max(max, this.displayWidth(helper.styleOptionTerm(helper.optionTerm(option))));
|
|
239
|
+
}, 0);
|
|
240
|
+
}
|
|
241
|
+
longestArgumentTermLength(cmd, helper) {
|
|
242
|
+
return helper.visibleArguments(cmd).reduce((max, argument) => {
|
|
243
|
+
return Math.max(max, this.displayWidth(helper.styleArgumentTerm(helper.argumentTerm(argument))));
|
|
244
|
+
}, 0);
|
|
245
|
+
}
|
|
246
|
+
commandUsage(cmd) {
|
|
247
|
+
let cmdName = cmd._name;
|
|
248
|
+
if (cmd._aliases[0]) {
|
|
249
|
+
cmdName = cmdName + "|" + cmd._aliases[0];
|
|
250
|
+
}
|
|
251
|
+
let ancestorCmdNames = "";
|
|
252
|
+
for (let ancestorCmd = cmd.parent;ancestorCmd; ancestorCmd = ancestorCmd.parent) {
|
|
253
|
+
ancestorCmdNames = ancestorCmd.name() + " " + ancestorCmdNames;
|
|
254
|
+
}
|
|
255
|
+
return ancestorCmdNames + cmdName + " " + cmd.usage();
|
|
256
|
+
}
|
|
257
|
+
commandDescription(cmd) {
|
|
258
|
+
return cmd.description();
|
|
259
|
+
}
|
|
260
|
+
subcommandDescription(cmd) {
|
|
261
|
+
return cmd.summary() || cmd.description();
|
|
262
|
+
}
|
|
263
|
+
optionDescription(option) {
|
|
264
|
+
const extraInfo = [];
|
|
265
|
+
if (option.argChoices) {
|
|
266
|
+
extraInfo.push(`choices: ${option.argChoices.map((choice) => JSON.stringify(choice)).join(", ")}`);
|
|
267
|
+
}
|
|
268
|
+
if (option.defaultValue !== undefined) {
|
|
269
|
+
const showDefault = option.required || option.optional || option.isBoolean() && typeof option.defaultValue === "boolean";
|
|
270
|
+
if (showDefault) {
|
|
271
|
+
extraInfo.push(`default: ${option.defaultValueDescription || JSON.stringify(option.defaultValue)}`);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
if (option.presetArg !== undefined && option.optional) {
|
|
275
|
+
extraInfo.push(`preset: ${JSON.stringify(option.presetArg)}`);
|
|
276
|
+
}
|
|
277
|
+
if (option.envVar !== undefined) {
|
|
278
|
+
extraInfo.push(`env: ${option.envVar}`);
|
|
279
|
+
}
|
|
280
|
+
if (extraInfo.length > 0) {
|
|
281
|
+
const extraDescription = `(${extraInfo.join(", ")})`;
|
|
282
|
+
if (option.description) {
|
|
283
|
+
return `${option.description} ${extraDescription}`;
|
|
284
|
+
}
|
|
285
|
+
return extraDescription;
|
|
286
|
+
}
|
|
287
|
+
return option.description;
|
|
288
|
+
}
|
|
289
|
+
argumentDescription(argument) {
|
|
290
|
+
const extraInfo = [];
|
|
291
|
+
if (argument.argChoices) {
|
|
292
|
+
extraInfo.push(`choices: ${argument.argChoices.map((choice) => JSON.stringify(choice)).join(", ")}`);
|
|
293
|
+
}
|
|
294
|
+
if (argument.defaultValue !== undefined) {
|
|
295
|
+
extraInfo.push(`default: ${argument.defaultValueDescription || JSON.stringify(argument.defaultValue)}`);
|
|
296
|
+
}
|
|
297
|
+
if (extraInfo.length > 0) {
|
|
298
|
+
const extraDescription = `(${extraInfo.join(", ")})`;
|
|
299
|
+
if (argument.description) {
|
|
300
|
+
return `${argument.description} ${extraDescription}`;
|
|
301
|
+
}
|
|
302
|
+
return extraDescription;
|
|
303
|
+
}
|
|
304
|
+
return argument.description;
|
|
305
|
+
}
|
|
306
|
+
formatItemList(heading, items, helper) {
|
|
307
|
+
if (items.length === 0)
|
|
308
|
+
return [];
|
|
309
|
+
return [helper.styleTitle(heading), ...items, ""];
|
|
310
|
+
}
|
|
311
|
+
groupItems(unsortedItems, visibleItems, getGroup) {
|
|
312
|
+
const result = new Map;
|
|
313
|
+
unsortedItems.forEach((item) => {
|
|
314
|
+
const group = getGroup(item);
|
|
315
|
+
if (!result.has(group))
|
|
316
|
+
result.set(group, []);
|
|
317
|
+
});
|
|
318
|
+
visibleItems.forEach((item) => {
|
|
319
|
+
const group = getGroup(item);
|
|
320
|
+
if (!result.has(group)) {
|
|
321
|
+
result.set(group, []);
|
|
322
|
+
}
|
|
323
|
+
result.get(group).push(item);
|
|
324
|
+
});
|
|
325
|
+
return result;
|
|
326
|
+
}
|
|
327
|
+
formatHelp(cmd, helper) {
|
|
328
|
+
const termWidth = helper.padWidth(cmd, helper);
|
|
329
|
+
const helpWidth = helper.helpWidth ?? 80;
|
|
330
|
+
function callFormatItem(term, description) {
|
|
331
|
+
return helper.formatItem(term, termWidth, description, helper);
|
|
332
|
+
}
|
|
333
|
+
let output = [
|
|
334
|
+
`${helper.styleTitle("Usage:")} ${helper.styleUsage(helper.commandUsage(cmd))}`,
|
|
335
|
+
""
|
|
336
|
+
];
|
|
337
|
+
const commandDescription = helper.commandDescription(cmd);
|
|
338
|
+
if (commandDescription.length > 0) {
|
|
339
|
+
output = output.concat([
|
|
340
|
+
helper.boxWrap(helper.styleCommandDescription(commandDescription), helpWidth),
|
|
341
|
+
""
|
|
342
|
+
]);
|
|
343
|
+
}
|
|
344
|
+
const argumentList = helper.visibleArguments(cmd).map((argument) => {
|
|
345
|
+
return callFormatItem(helper.styleArgumentTerm(helper.argumentTerm(argument)), helper.styleArgumentDescription(helper.argumentDescription(argument)));
|
|
346
|
+
});
|
|
347
|
+
output = output.concat(this.formatItemList("Arguments:", argumentList, helper));
|
|
348
|
+
const optionGroups = this.groupItems(cmd.options, helper.visibleOptions(cmd), (option) => option.helpGroupHeading ?? "Options:");
|
|
349
|
+
optionGroups.forEach((options, group) => {
|
|
350
|
+
const optionList = options.map((option) => {
|
|
351
|
+
return callFormatItem(helper.styleOptionTerm(helper.optionTerm(option)), helper.styleOptionDescription(helper.optionDescription(option)));
|
|
352
|
+
});
|
|
353
|
+
output = output.concat(this.formatItemList(group, optionList, helper));
|
|
354
|
+
});
|
|
355
|
+
if (helper.showGlobalOptions) {
|
|
356
|
+
const globalOptionList = helper.visibleGlobalOptions(cmd).map((option) => {
|
|
357
|
+
return callFormatItem(helper.styleOptionTerm(helper.optionTerm(option)), helper.styleOptionDescription(helper.optionDescription(option)));
|
|
358
|
+
});
|
|
359
|
+
output = output.concat(this.formatItemList("Global Options:", globalOptionList, helper));
|
|
360
|
+
}
|
|
361
|
+
const commandGroups = this.groupItems(cmd.commands, helper.visibleCommands(cmd), (sub) => sub.helpGroup() || "Commands:");
|
|
362
|
+
commandGroups.forEach((commands, group) => {
|
|
363
|
+
const commandList = commands.map((sub) => {
|
|
364
|
+
return callFormatItem(helper.styleSubcommandTerm(helper.subcommandTerm(sub)), helper.styleSubcommandDescription(helper.subcommandDescription(sub)));
|
|
365
|
+
});
|
|
366
|
+
output = output.concat(this.formatItemList(group, commandList, helper));
|
|
367
|
+
});
|
|
368
|
+
return output.join(`
|
|
369
|
+
`);
|
|
370
|
+
}
|
|
371
|
+
displayWidth(str) {
|
|
372
|
+
return stripColor(str).length;
|
|
373
|
+
}
|
|
374
|
+
styleTitle(str) {
|
|
375
|
+
return str;
|
|
376
|
+
}
|
|
377
|
+
styleUsage(str) {
|
|
378
|
+
return str.split(" ").map((word) => {
|
|
379
|
+
if (word === "[options]")
|
|
380
|
+
return this.styleOptionText(word);
|
|
381
|
+
if (word === "[command]")
|
|
382
|
+
return this.styleSubcommandText(word);
|
|
383
|
+
if (word[0] === "[" || word[0] === "<")
|
|
384
|
+
return this.styleArgumentText(word);
|
|
385
|
+
return this.styleCommandText(word);
|
|
386
|
+
}).join(" ");
|
|
387
|
+
}
|
|
388
|
+
styleCommandDescription(str) {
|
|
389
|
+
return this.styleDescriptionText(str);
|
|
390
|
+
}
|
|
391
|
+
styleOptionDescription(str) {
|
|
392
|
+
return this.styleDescriptionText(str);
|
|
393
|
+
}
|
|
394
|
+
styleSubcommandDescription(str) {
|
|
395
|
+
return this.styleDescriptionText(str);
|
|
396
|
+
}
|
|
397
|
+
styleArgumentDescription(str) {
|
|
398
|
+
return this.styleDescriptionText(str);
|
|
399
|
+
}
|
|
400
|
+
styleDescriptionText(str) {
|
|
401
|
+
return str;
|
|
402
|
+
}
|
|
403
|
+
styleOptionTerm(str) {
|
|
404
|
+
return this.styleOptionText(str);
|
|
405
|
+
}
|
|
406
|
+
styleSubcommandTerm(str) {
|
|
407
|
+
return str.split(" ").map((word) => {
|
|
408
|
+
if (word === "[options]")
|
|
409
|
+
return this.styleOptionText(word);
|
|
410
|
+
if (word[0] === "[" || word[0] === "<")
|
|
411
|
+
return this.styleArgumentText(word);
|
|
412
|
+
return this.styleSubcommandText(word);
|
|
413
|
+
}).join(" ");
|
|
414
|
+
}
|
|
415
|
+
styleArgumentTerm(str) {
|
|
416
|
+
return this.styleArgumentText(str);
|
|
417
|
+
}
|
|
418
|
+
styleOptionText(str) {
|
|
419
|
+
return str;
|
|
420
|
+
}
|
|
421
|
+
styleArgumentText(str) {
|
|
422
|
+
return str;
|
|
423
|
+
}
|
|
424
|
+
styleSubcommandText(str) {
|
|
425
|
+
return str;
|
|
426
|
+
}
|
|
427
|
+
styleCommandText(str) {
|
|
428
|
+
return str;
|
|
429
|
+
}
|
|
430
|
+
padWidth(cmd, helper) {
|
|
431
|
+
return Math.max(helper.longestOptionTermLength(cmd, helper), helper.longestGlobalOptionTermLength(cmd, helper), helper.longestSubcommandTermLength(cmd, helper), helper.longestArgumentTermLength(cmd, helper));
|
|
432
|
+
}
|
|
433
|
+
preformatted(str) {
|
|
434
|
+
return /\n[^\S\r\n]/.test(str);
|
|
435
|
+
}
|
|
436
|
+
formatItem(term, termWidth, description, helper) {
|
|
437
|
+
const itemIndent = 2;
|
|
438
|
+
const itemIndentStr = " ".repeat(itemIndent);
|
|
439
|
+
if (!description)
|
|
440
|
+
return itemIndentStr + term;
|
|
441
|
+
const paddedTerm = term.padEnd(termWidth + term.length - helper.displayWidth(term));
|
|
442
|
+
const spacerWidth = 2;
|
|
443
|
+
const helpWidth = this.helpWidth ?? 80;
|
|
444
|
+
const remainingWidth = helpWidth - termWidth - spacerWidth - itemIndent;
|
|
445
|
+
let formattedDescription;
|
|
446
|
+
if (remainingWidth < this.minWidthToWrap || helper.preformatted(description)) {
|
|
447
|
+
formattedDescription = description;
|
|
448
|
+
} else {
|
|
449
|
+
const wrappedDescription = helper.boxWrap(description, remainingWidth);
|
|
450
|
+
formattedDescription = wrappedDescription.replace(/\n/g, `
|
|
451
|
+
` + " ".repeat(termWidth + spacerWidth));
|
|
452
|
+
}
|
|
453
|
+
return itemIndentStr + paddedTerm + " ".repeat(spacerWidth) + formattedDescription.replace(/\n/g, `
|
|
454
|
+
${itemIndentStr}`);
|
|
455
|
+
}
|
|
456
|
+
boxWrap(str, width) {
|
|
457
|
+
if (width < this.minWidthToWrap)
|
|
458
|
+
return str;
|
|
459
|
+
const rawLines = str.split(/\r\n|\n/);
|
|
460
|
+
const chunkPattern = /[\s]*[^\s]+/g;
|
|
461
|
+
const wrappedLines = [];
|
|
462
|
+
rawLines.forEach((line) => {
|
|
463
|
+
const chunks = line.match(chunkPattern);
|
|
464
|
+
if (chunks === null) {
|
|
465
|
+
wrappedLines.push("");
|
|
466
|
+
return;
|
|
467
|
+
}
|
|
468
|
+
let sumChunks = [chunks.shift()];
|
|
469
|
+
let sumWidth = this.displayWidth(sumChunks[0]);
|
|
470
|
+
chunks.forEach((chunk) => {
|
|
471
|
+
const visibleWidth = this.displayWidth(chunk);
|
|
472
|
+
if (sumWidth + visibleWidth <= width) {
|
|
473
|
+
sumChunks.push(chunk);
|
|
474
|
+
sumWidth += visibleWidth;
|
|
475
|
+
return;
|
|
476
|
+
}
|
|
477
|
+
wrappedLines.push(sumChunks.join(""));
|
|
478
|
+
const nextChunk = chunk.trimStart();
|
|
479
|
+
sumChunks = [nextChunk];
|
|
480
|
+
sumWidth = this.displayWidth(nextChunk);
|
|
481
|
+
});
|
|
482
|
+
wrappedLines.push(sumChunks.join(""));
|
|
483
|
+
});
|
|
484
|
+
return wrappedLines.join(`
|
|
485
|
+
`);
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
function stripColor(str) {
|
|
489
|
+
const sgrPattern = /\x1b\[\d*(;\d*)*m/g;
|
|
490
|
+
return str.replace(sgrPattern, "");
|
|
491
|
+
}
|
|
492
|
+
exports.Help = Help;
|
|
493
|
+
exports.stripColor = stripColor;
|
|
494
|
+
});
|
|
495
|
+
|
|
496
|
+
// ../../node_modules/commander/lib/option.js
|
|
497
|
+
var require_option = __commonJS((exports) => {
|
|
498
|
+
var { InvalidArgumentError } = require_error();
|
|
499
|
+
|
|
500
|
+
class Option {
|
|
501
|
+
constructor(flags, description) {
|
|
502
|
+
this.flags = flags;
|
|
503
|
+
this.description = description || "";
|
|
504
|
+
this.required = flags.includes("<");
|
|
505
|
+
this.optional = flags.includes("[");
|
|
506
|
+
this.variadic = /\w\.\.\.[>\]]$/.test(flags);
|
|
507
|
+
this.mandatory = false;
|
|
508
|
+
const optionFlags = splitOptionFlags(flags);
|
|
509
|
+
this.short = optionFlags.shortFlag;
|
|
510
|
+
this.long = optionFlags.longFlag;
|
|
511
|
+
this.negate = false;
|
|
512
|
+
if (this.long) {
|
|
513
|
+
this.negate = this.long.startsWith("--no-");
|
|
514
|
+
}
|
|
515
|
+
this.defaultValue = undefined;
|
|
516
|
+
this.defaultValueDescription = undefined;
|
|
517
|
+
this.presetArg = undefined;
|
|
518
|
+
this.envVar = undefined;
|
|
519
|
+
this.parseArg = undefined;
|
|
520
|
+
this.hidden = false;
|
|
521
|
+
this.argChoices = undefined;
|
|
522
|
+
this.conflictsWith = [];
|
|
523
|
+
this.implied = undefined;
|
|
524
|
+
this.helpGroupHeading = undefined;
|
|
525
|
+
}
|
|
526
|
+
default(value, description) {
|
|
527
|
+
this.defaultValue = value;
|
|
528
|
+
this.defaultValueDescription = description;
|
|
529
|
+
return this;
|
|
530
|
+
}
|
|
531
|
+
preset(arg) {
|
|
532
|
+
this.presetArg = arg;
|
|
533
|
+
return this;
|
|
534
|
+
}
|
|
535
|
+
conflicts(names) {
|
|
536
|
+
this.conflictsWith = this.conflictsWith.concat(names);
|
|
537
|
+
return this;
|
|
538
|
+
}
|
|
539
|
+
implies(impliedOptionValues) {
|
|
540
|
+
let newImplied = impliedOptionValues;
|
|
541
|
+
if (typeof impliedOptionValues === "string") {
|
|
542
|
+
newImplied = { [impliedOptionValues]: true };
|
|
543
|
+
}
|
|
544
|
+
this.implied = Object.assign(this.implied || {}, newImplied);
|
|
545
|
+
return this;
|
|
546
|
+
}
|
|
547
|
+
env(name) {
|
|
548
|
+
this.envVar = name;
|
|
549
|
+
return this;
|
|
550
|
+
}
|
|
551
|
+
argParser(fn) {
|
|
552
|
+
this.parseArg = fn;
|
|
553
|
+
return this;
|
|
554
|
+
}
|
|
555
|
+
makeOptionMandatory(mandatory = true) {
|
|
556
|
+
this.mandatory = !!mandatory;
|
|
557
|
+
return this;
|
|
558
|
+
}
|
|
559
|
+
hideHelp(hide = true) {
|
|
560
|
+
this.hidden = !!hide;
|
|
561
|
+
return this;
|
|
562
|
+
}
|
|
563
|
+
_collectValue(value, previous) {
|
|
564
|
+
if (previous === this.defaultValue || !Array.isArray(previous)) {
|
|
565
|
+
return [value];
|
|
566
|
+
}
|
|
567
|
+
previous.push(value);
|
|
568
|
+
return previous;
|
|
569
|
+
}
|
|
570
|
+
choices(values) {
|
|
571
|
+
this.argChoices = values.slice();
|
|
572
|
+
this.parseArg = (arg, previous) => {
|
|
573
|
+
if (!this.argChoices.includes(arg)) {
|
|
574
|
+
throw new InvalidArgumentError(`Allowed choices are ${this.argChoices.join(", ")}.`);
|
|
575
|
+
}
|
|
576
|
+
if (this.variadic) {
|
|
577
|
+
return this._collectValue(arg, previous);
|
|
578
|
+
}
|
|
579
|
+
return arg;
|
|
580
|
+
};
|
|
581
|
+
return this;
|
|
582
|
+
}
|
|
583
|
+
name() {
|
|
584
|
+
if (this.long) {
|
|
585
|
+
return this.long.replace(/^--/, "");
|
|
586
|
+
}
|
|
587
|
+
return this.short.replace(/^-/, "");
|
|
588
|
+
}
|
|
589
|
+
attributeName() {
|
|
590
|
+
if (this.negate) {
|
|
591
|
+
return camelcase(this.name().replace(/^no-/, ""));
|
|
592
|
+
}
|
|
593
|
+
return camelcase(this.name());
|
|
594
|
+
}
|
|
595
|
+
helpGroup(heading) {
|
|
596
|
+
this.helpGroupHeading = heading;
|
|
597
|
+
return this;
|
|
598
|
+
}
|
|
599
|
+
is(arg) {
|
|
600
|
+
return this.short === arg || this.long === arg;
|
|
601
|
+
}
|
|
602
|
+
isBoolean() {
|
|
603
|
+
return !this.required && !this.optional && !this.negate;
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
class DualOptions {
|
|
608
|
+
constructor(options) {
|
|
609
|
+
this.positiveOptions = new Map;
|
|
610
|
+
this.negativeOptions = new Map;
|
|
611
|
+
this.dualOptions = new Set;
|
|
612
|
+
options.forEach((option) => {
|
|
613
|
+
if (option.negate) {
|
|
614
|
+
this.negativeOptions.set(option.attributeName(), option);
|
|
615
|
+
} else {
|
|
616
|
+
this.positiveOptions.set(option.attributeName(), option);
|
|
617
|
+
}
|
|
618
|
+
});
|
|
619
|
+
this.negativeOptions.forEach((value, key) => {
|
|
620
|
+
if (this.positiveOptions.has(key)) {
|
|
621
|
+
this.dualOptions.add(key);
|
|
622
|
+
}
|
|
623
|
+
});
|
|
624
|
+
}
|
|
625
|
+
valueFromOption(value, option) {
|
|
626
|
+
const optionKey = option.attributeName();
|
|
627
|
+
if (!this.dualOptions.has(optionKey))
|
|
628
|
+
return true;
|
|
629
|
+
const preset = this.negativeOptions.get(optionKey).presetArg;
|
|
630
|
+
const negativeValue = preset !== undefined ? preset : false;
|
|
631
|
+
return option.negate === (negativeValue === value);
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
function camelcase(str) {
|
|
635
|
+
return str.split("-").reduce((str2, word) => {
|
|
636
|
+
return str2 + word[0].toUpperCase() + word.slice(1);
|
|
637
|
+
});
|
|
638
|
+
}
|
|
639
|
+
function splitOptionFlags(flags) {
|
|
640
|
+
let shortFlag;
|
|
641
|
+
let longFlag;
|
|
642
|
+
const shortFlagExp = /^-[^-]$/;
|
|
643
|
+
const longFlagExp = /^--[^-]/;
|
|
644
|
+
const flagParts = flags.split(/[ |,]+/).concat("guard");
|
|
645
|
+
if (shortFlagExp.test(flagParts[0]))
|
|
646
|
+
shortFlag = flagParts.shift();
|
|
647
|
+
if (longFlagExp.test(flagParts[0]))
|
|
648
|
+
longFlag = flagParts.shift();
|
|
649
|
+
if (!shortFlag && shortFlagExp.test(flagParts[0]))
|
|
650
|
+
shortFlag = flagParts.shift();
|
|
651
|
+
if (!shortFlag && longFlagExp.test(flagParts[0])) {
|
|
652
|
+
shortFlag = longFlag;
|
|
653
|
+
longFlag = flagParts.shift();
|
|
654
|
+
}
|
|
655
|
+
if (flagParts[0].startsWith("-")) {
|
|
656
|
+
const unsupportedFlag = flagParts[0];
|
|
657
|
+
const baseError = `option creation failed due to '${unsupportedFlag}' in option flags '${flags}'`;
|
|
658
|
+
if (/^-[^-][^-]/.test(unsupportedFlag))
|
|
659
|
+
throw new Error(`${baseError}
|
|
660
|
+
- a short flag is a single dash and a single character
|
|
661
|
+
- either use a single dash and a single character (for a short flag)
|
|
662
|
+
- or use a double dash for a long option (and can have two, like '--ws, --workspace')`);
|
|
663
|
+
if (shortFlagExp.test(unsupportedFlag))
|
|
664
|
+
throw new Error(`${baseError}
|
|
665
|
+
- too many short flags`);
|
|
666
|
+
if (longFlagExp.test(unsupportedFlag))
|
|
667
|
+
throw new Error(`${baseError}
|
|
668
|
+
- too many long flags`);
|
|
669
|
+
throw new Error(`${baseError}
|
|
670
|
+
- unrecognised flag format`);
|
|
671
|
+
}
|
|
672
|
+
if (shortFlag === undefined && longFlag === undefined)
|
|
673
|
+
throw new Error(`option creation failed due to no flags found in '${flags}'.`);
|
|
674
|
+
return { shortFlag, longFlag };
|
|
675
|
+
}
|
|
676
|
+
exports.Option = Option;
|
|
677
|
+
exports.DualOptions = DualOptions;
|
|
678
|
+
});
|
|
679
|
+
|
|
680
|
+
// ../../node_modules/commander/lib/suggestSimilar.js
|
|
681
|
+
var require_suggestSimilar = __commonJS((exports) => {
|
|
682
|
+
var maxDistance = 3;
|
|
683
|
+
function editDistance(a, b) {
|
|
684
|
+
if (Math.abs(a.length - b.length) > maxDistance)
|
|
685
|
+
return Math.max(a.length, b.length);
|
|
686
|
+
const d = [];
|
|
687
|
+
for (let i = 0;i <= a.length; i++) {
|
|
688
|
+
d[i] = [i];
|
|
689
|
+
}
|
|
690
|
+
for (let j = 0;j <= b.length; j++) {
|
|
691
|
+
d[0][j] = j;
|
|
692
|
+
}
|
|
693
|
+
for (let j = 1;j <= b.length; j++) {
|
|
694
|
+
for (let i = 1;i <= a.length; i++) {
|
|
695
|
+
let cost = 1;
|
|
696
|
+
if (a[i - 1] === b[j - 1]) {
|
|
697
|
+
cost = 0;
|
|
698
|
+
} else {
|
|
699
|
+
cost = 1;
|
|
700
|
+
}
|
|
701
|
+
d[i][j] = Math.min(d[i - 1][j] + 1, d[i][j - 1] + 1, d[i - 1][j - 1] + cost);
|
|
702
|
+
if (i > 1 && j > 1 && a[i - 1] === b[j - 2] && a[i - 2] === b[j - 1]) {
|
|
703
|
+
d[i][j] = Math.min(d[i][j], d[i - 2][j - 2] + 1);
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
return d[a.length][b.length];
|
|
708
|
+
}
|
|
709
|
+
function suggestSimilar(word, candidates) {
|
|
710
|
+
if (!candidates || candidates.length === 0)
|
|
711
|
+
return "";
|
|
712
|
+
candidates = Array.from(new Set(candidates));
|
|
713
|
+
const searchingOptions = word.startsWith("--");
|
|
714
|
+
if (searchingOptions) {
|
|
715
|
+
word = word.slice(2);
|
|
716
|
+
candidates = candidates.map((candidate) => candidate.slice(2));
|
|
717
|
+
}
|
|
718
|
+
let similar = [];
|
|
719
|
+
let bestDistance = maxDistance;
|
|
720
|
+
const minSimilarity = 0.4;
|
|
721
|
+
candidates.forEach((candidate) => {
|
|
722
|
+
if (candidate.length <= 1)
|
|
723
|
+
return;
|
|
724
|
+
const distance = editDistance(word, candidate);
|
|
725
|
+
const length = Math.max(word.length, candidate.length);
|
|
726
|
+
const similarity = (length - distance) / length;
|
|
727
|
+
if (similarity > minSimilarity) {
|
|
728
|
+
if (distance < bestDistance) {
|
|
729
|
+
bestDistance = distance;
|
|
730
|
+
similar = [candidate];
|
|
731
|
+
} else if (distance === bestDistance) {
|
|
732
|
+
similar.push(candidate);
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
});
|
|
736
|
+
similar.sort((a, b) => a.localeCompare(b));
|
|
737
|
+
if (searchingOptions) {
|
|
738
|
+
similar = similar.map((candidate) => `--${candidate}`);
|
|
739
|
+
}
|
|
740
|
+
if (similar.length > 1) {
|
|
741
|
+
return `
|
|
742
|
+
(Did you mean one of ${similar.join(", ")}?)`;
|
|
743
|
+
}
|
|
744
|
+
if (similar.length === 1) {
|
|
745
|
+
return `
|
|
746
|
+
(Did you mean ${similar[0]}?)`;
|
|
747
|
+
}
|
|
748
|
+
return "";
|
|
749
|
+
}
|
|
750
|
+
exports.suggestSimilar = suggestSimilar;
|
|
751
|
+
});
|
|
752
|
+
|
|
753
|
+
// ../../node_modules/commander/lib/command.js
|
|
754
|
+
var require_command = __commonJS((exports) => {
|
|
755
|
+
var EventEmitter = __require("node:events").EventEmitter;
|
|
756
|
+
var childProcess = __require("node:child_process");
|
|
757
|
+
var path = __require("node:path");
|
|
758
|
+
var fs = __require("node:fs");
|
|
759
|
+
var process2 = __require("node:process");
|
|
760
|
+
var { Argument, humanReadableArgName } = require_argument();
|
|
761
|
+
var { CommanderError } = require_error();
|
|
762
|
+
var { Help, stripColor } = require_help();
|
|
763
|
+
var { Option, DualOptions } = require_option();
|
|
764
|
+
var { suggestSimilar } = require_suggestSimilar();
|
|
765
|
+
|
|
766
|
+
class Command extends EventEmitter {
|
|
767
|
+
constructor(name) {
|
|
768
|
+
super();
|
|
769
|
+
this.commands = [];
|
|
770
|
+
this.options = [];
|
|
771
|
+
this.parent = null;
|
|
772
|
+
this._allowUnknownOption = false;
|
|
773
|
+
this._allowExcessArguments = false;
|
|
774
|
+
this.registeredArguments = [];
|
|
775
|
+
this._args = this.registeredArguments;
|
|
776
|
+
this.args = [];
|
|
777
|
+
this.rawArgs = [];
|
|
778
|
+
this.processedArgs = [];
|
|
779
|
+
this._scriptPath = null;
|
|
780
|
+
this._name = name || "";
|
|
781
|
+
this._optionValues = {};
|
|
782
|
+
this._optionValueSources = {};
|
|
783
|
+
this._storeOptionsAsProperties = false;
|
|
784
|
+
this._actionHandler = null;
|
|
785
|
+
this._executableHandler = false;
|
|
786
|
+
this._executableFile = null;
|
|
787
|
+
this._executableDir = null;
|
|
788
|
+
this._defaultCommandName = null;
|
|
789
|
+
this._exitCallback = null;
|
|
790
|
+
this._aliases = [];
|
|
791
|
+
this._combineFlagAndOptionalValue = true;
|
|
792
|
+
this._description = "";
|
|
793
|
+
this._summary = "";
|
|
794
|
+
this._argsDescription = undefined;
|
|
795
|
+
this._enablePositionalOptions = false;
|
|
796
|
+
this._passThroughOptions = false;
|
|
797
|
+
this._lifeCycleHooks = {};
|
|
798
|
+
this._showHelpAfterError = false;
|
|
799
|
+
this._showSuggestionAfterError = true;
|
|
800
|
+
this._savedState = null;
|
|
801
|
+
this._outputConfiguration = {
|
|
802
|
+
writeOut: (str) => process2.stdout.write(str),
|
|
803
|
+
writeErr: (str) => process2.stderr.write(str),
|
|
804
|
+
outputError: (str, write) => write(str),
|
|
805
|
+
getOutHelpWidth: () => process2.stdout.isTTY ? process2.stdout.columns : undefined,
|
|
806
|
+
getErrHelpWidth: () => process2.stderr.isTTY ? process2.stderr.columns : undefined,
|
|
807
|
+
getOutHasColors: () => useColor() ?? (process2.stdout.isTTY && process2.stdout.hasColors?.()),
|
|
808
|
+
getErrHasColors: () => useColor() ?? (process2.stderr.isTTY && process2.stderr.hasColors?.()),
|
|
809
|
+
stripColor: (str) => stripColor(str)
|
|
810
|
+
};
|
|
811
|
+
this._hidden = false;
|
|
812
|
+
this._helpOption = undefined;
|
|
813
|
+
this._addImplicitHelpCommand = undefined;
|
|
814
|
+
this._helpCommand = undefined;
|
|
815
|
+
this._helpConfiguration = {};
|
|
816
|
+
this._helpGroupHeading = undefined;
|
|
817
|
+
this._defaultCommandGroup = undefined;
|
|
818
|
+
this._defaultOptionGroup = undefined;
|
|
819
|
+
}
|
|
820
|
+
copyInheritedSettings(sourceCommand) {
|
|
821
|
+
this._outputConfiguration = sourceCommand._outputConfiguration;
|
|
822
|
+
this._helpOption = sourceCommand._helpOption;
|
|
823
|
+
this._helpCommand = sourceCommand._helpCommand;
|
|
824
|
+
this._helpConfiguration = sourceCommand._helpConfiguration;
|
|
825
|
+
this._exitCallback = sourceCommand._exitCallback;
|
|
826
|
+
this._storeOptionsAsProperties = sourceCommand._storeOptionsAsProperties;
|
|
827
|
+
this._combineFlagAndOptionalValue = sourceCommand._combineFlagAndOptionalValue;
|
|
828
|
+
this._allowExcessArguments = sourceCommand._allowExcessArguments;
|
|
829
|
+
this._enablePositionalOptions = sourceCommand._enablePositionalOptions;
|
|
830
|
+
this._showHelpAfterError = sourceCommand._showHelpAfterError;
|
|
831
|
+
this._showSuggestionAfterError = sourceCommand._showSuggestionAfterError;
|
|
832
|
+
return this;
|
|
833
|
+
}
|
|
834
|
+
_getCommandAndAncestors() {
|
|
835
|
+
const result = [];
|
|
836
|
+
for (let command = this;command; command = command.parent) {
|
|
837
|
+
result.push(command);
|
|
838
|
+
}
|
|
839
|
+
return result;
|
|
840
|
+
}
|
|
841
|
+
command(nameAndArgs, actionOptsOrExecDesc, execOpts) {
|
|
842
|
+
let desc = actionOptsOrExecDesc;
|
|
843
|
+
let opts = execOpts;
|
|
844
|
+
if (typeof desc === "object" && desc !== null) {
|
|
845
|
+
opts = desc;
|
|
846
|
+
desc = null;
|
|
847
|
+
}
|
|
848
|
+
opts = opts || {};
|
|
849
|
+
const [, name, args] = nameAndArgs.match(/([^ ]+) *(.*)/);
|
|
850
|
+
const cmd = this.createCommand(name);
|
|
851
|
+
if (desc) {
|
|
852
|
+
cmd.description(desc);
|
|
853
|
+
cmd._executableHandler = true;
|
|
854
|
+
}
|
|
855
|
+
if (opts.isDefault)
|
|
856
|
+
this._defaultCommandName = cmd._name;
|
|
857
|
+
cmd._hidden = !!(opts.noHelp || opts.hidden);
|
|
858
|
+
cmd._executableFile = opts.executableFile || null;
|
|
859
|
+
if (args)
|
|
860
|
+
cmd.arguments(args);
|
|
861
|
+
this._registerCommand(cmd);
|
|
862
|
+
cmd.parent = this;
|
|
863
|
+
cmd.copyInheritedSettings(this);
|
|
864
|
+
if (desc)
|
|
865
|
+
return this;
|
|
866
|
+
return cmd;
|
|
867
|
+
}
|
|
868
|
+
createCommand(name) {
|
|
869
|
+
return new Command(name);
|
|
870
|
+
}
|
|
871
|
+
createHelp() {
|
|
872
|
+
return Object.assign(new Help, this.configureHelp());
|
|
873
|
+
}
|
|
874
|
+
configureHelp(configuration) {
|
|
875
|
+
if (configuration === undefined)
|
|
876
|
+
return this._helpConfiguration;
|
|
877
|
+
this._helpConfiguration = configuration;
|
|
878
|
+
return this;
|
|
879
|
+
}
|
|
880
|
+
configureOutput(configuration) {
|
|
881
|
+
if (configuration === undefined)
|
|
882
|
+
return this._outputConfiguration;
|
|
883
|
+
this._outputConfiguration = {
|
|
884
|
+
...this._outputConfiguration,
|
|
885
|
+
...configuration
|
|
886
|
+
};
|
|
887
|
+
return this;
|
|
888
|
+
}
|
|
889
|
+
showHelpAfterError(displayHelp = true) {
|
|
890
|
+
if (typeof displayHelp !== "string")
|
|
891
|
+
displayHelp = !!displayHelp;
|
|
892
|
+
this._showHelpAfterError = displayHelp;
|
|
893
|
+
return this;
|
|
894
|
+
}
|
|
895
|
+
showSuggestionAfterError(displaySuggestion = true) {
|
|
896
|
+
this._showSuggestionAfterError = !!displaySuggestion;
|
|
897
|
+
return this;
|
|
898
|
+
}
|
|
899
|
+
addCommand(cmd, opts) {
|
|
900
|
+
if (!cmd._name) {
|
|
901
|
+
throw new Error(`Command passed to .addCommand() must have a name
|
|
902
|
+
- specify the name in Command constructor or using .name()`);
|
|
903
|
+
}
|
|
904
|
+
opts = opts || {};
|
|
905
|
+
if (opts.isDefault)
|
|
906
|
+
this._defaultCommandName = cmd._name;
|
|
907
|
+
if (opts.noHelp || opts.hidden)
|
|
908
|
+
cmd._hidden = true;
|
|
909
|
+
this._registerCommand(cmd);
|
|
910
|
+
cmd.parent = this;
|
|
911
|
+
cmd._checkForBrokenPassThrough();
|
|
912
|
+
return this;
|
|
913
|
+
}
|
|
914
|
+
createArgument(name, description) {
|
|
915
|
+
return new Argument(name, description);
|
|
916
|
+
}
|
|
917
|
+
argument(name, description, parseArg, defaultValue) {
|
|
918
|
+
const argument = this.createArgument(name, description);
|
|
919
|
+
if (typeof parseArg === "function") {
|
|
920
|
+
argument.default(defaultValue).argParser(parseArg);
|
|
921
|
+
} else {
|
|
922
|
+
argument.default(parseArg);
|
|
923
|
+
}
|
|
924
|
+
this.addArgument(argument);
|
|
925
|
+
return this;
|
|
926
|
+
}
|
|
927
|
+
arguments(names) {
|
|
928
|
+
names.trim().split(/ +/).forEach((detail) => {
|
|
929
|
+
this.argument(detail);
|
|
930
|
+
});
|
|
931
|
+
return this;
|
|
932
|
+
}
|
|
933
|
+
addArgument(argument) {
|
|
934
|
+
const previousArgument = this.registeredArguments.slice(-1)[0];
|
|
935
|
+
if (previousArgument?.variadic) {
|
|
936
|
+
throw new Error(`only the last argument can be variadic '${previousArgument.name()}'`);
|
|
937
|
+
}
|
|
938
|
+
if (argument.required && argument.defaultValue !== undefined && argument.parseArg === undefined) {
|
|
939
|
+
throw new Error(`a default value for a required argument is never used: '${argument.name()}'`);
|
|
940
|
+
}
|
|
941
|
+
this.registeredArguments.push(argument);
|
|
942
|
+
return this;
|
|
943
|
+
}
|
|
944
|
+
helpCommand(enableOrNameAndArgs, description) {
|
|
945
|
+
if (typeof enableOrNameAndArgs === "boolean") {
|
|
946
|
+
this._addImplicitHelpCommand = enableOrNameAndArgs;
|
|
947
|
+
if (enableOrNameAndArgs && this._defaultCommandGroup) {
|
|
948
|
+
this._initCommandGroup(this._getHelpCommand());
|
|
949
|
+
}
|
|
950
|
+
return this;
|
|
951
|
+
}
|
|
952
|
+
const nameAndArgs = enableOrNameAndArgs ?? "help [command]";
|
|
953
|
+
const [, helpName, helpArgs] = nameAndArgs.match(/([^ ]+) *(.*)/);
|
|
954
|
+
const helpDescription = description ?? "display help for command";
|
|
955
|
+
const helpCommand = this.createCommand(helpName);
|
|
956
|
+
helpCommand.helpOption(false);
|
|
957
|
+
if (helpArgs)
|
|
958
|
+
helpCommand.arguments(helpArgs);
|
|
959
|
+
if (helpDescription)
|
|
960
|
+
helpCommand.description(helpDescription);
|
|
961
|
+
this._addImplicitHelpCommand = true;
|
|
962
|
+
this._helpCommand = helpCommand;
|
|
963
|
+
if (enableOrNameAndArgs || description)
|
|
964
|
+
this._initCommandGroup(helpCommand);
|
|
965
|
+
return this;
|
|
966
|
+
}
|
|
967
|
+
addHelpCommand(helpCommand, deprecatedDescription) {
|
|
968
|
+
if (typeof helpCommand !== "object") {
|
|
969
|
+
this.helpCommand(helpCommand, deprecatedDescription);
|
|
970
|
+
return this;
|
|
971
|
+
}
|
|
972
|
+
this._addImplicitHelpCommand = true;
|
|
973
|
+
this._helpCommand = helpCommand;
|
|
974
|
+
this._initCommandGroup(helpCommand);
|
|
975
|
+
return this;
|
|
976
|
+
}
|
|
977
|
+
_getHelpCommand() {
|
|
978
|
+
const hasImplicitHelpCommand = this._addImplicitHelpCommand ?? (this.commands.length && !this._actionHandler && !this._findCommand("help"));
|
|
979
|
+
if (hasImplicitHelpCommand) {
|
|
980
|
+
if (this._helpCommand === undefined) {
|
|
981
|
+
this.helpCommand(undefined, undefined);
|
|
982
|
+
}
|
|
983
|
+
return this._helpCommand;
|
|
984
|
+
}
|
|
985
|
+
return null;
|
|
986
|
+
}
|
|
987
|
+
hook(event, listener) {
|
|
988
|
+
const allowedValues = ["preSubcommand", "preAction", "postAction"];
|
|
989
|
+
if (!allowedValues.includes(event)) {
|
|
990
|
+
throw new Error(`Unexpected value for event passed to hook : '${event}'.
|
|
991
|
+
Expecting one of '${allowedValues.join("', '")}'`);
|
|
992
|
+
}
|
|
993
|
+
if (this._lifeCycleHooks[event]) {
|
|
994
|
+
this._lifeCycleHooks[event].push(listener);
|
|
995
|
+
} else {
|
|
996
|
+
this._lifeCycleHooks[event] = [listener];
|
|
997
|
+
}
|
|
998
|
+
return this;
|
|
999
|
+
}
|
|
1000
|
+
exitOverride(fn) {
|
|
1001
|
+
if (fn) {
|
|
1002
|
+
this._exitCallback = fn;
|
|
1003
|
+
} else {
|
|
1004
|
+
this._exitCallback = (err) => {
|
|
1005
|
+
if (err.code !== "commander.executeSubCommandAsync") {
|
|
1006
|
+
throw err;
|
|
1007
|
+
} else {}
|
|
1008
|
+
};
|
|
1009
|
+
}
|
|
1010
|
+
return this;
|
|
1011
|
+
}
|
|
1012
|
+
_exit(exitCode, code, message) {
|
|
1013
|
+
if (this._exitCallback) {
|
|
1014
|
+
this._exitCallback(new CommanderError(exitCode, code, message));
|
|
1015
|
+
}
|
|
1016
|
+
process2.exit(exitCode);
|
|
1017
|
+
}
|
|
1018
|
+
action(fn) {
|
|
1019
|
+
const listener = (args) => {
|
|
1020
|
+
const expectedArgsCount = this.registeredArguments.length;
|
|
1021
|
+
const actionArgs = args.slice(0, expectedArgsCount);
|
|
1022
|
+
if (this._storeOptionsAsProperties) {
|
|
1023
|
+
actionArgs[expectedArgsCount] = this;
|
|
1024
|
+
} else {
|
|
1025
|
+
actionArgs[expectedArgsCount] = this.opts();
|
|
1026
|
+
}
|
|
1027
|
+
actionArgs.push(this);
|
|
1028
|
+
return fn.apply(this, actionArgs);
|
|
1029
|
+
};
|
|
1030
|
+
this._actionHandler = listener;
|
|
1031
|
+
return this;
|
|
1032
|
+
}
|
|
1033
|
+
createOption(flags, description) {
|
|
1034
|
+
return new Option(flags, description);
|
|
1035
|
+
}
|
|
1036
|
+
_callParseArg(target, value, previous, invalidArgumentMessage) {
|
|
1037
|
+
try {
|
|
1038
|
+
return target.parseArg(value, previous);
|
|
1039
|
+
} catch (err) {
|
|
1040
|
+
if (err.code === "commander.invalidArgument") {
|
|
1041
|
+
const message = `${invalidArgumentMessage} ${err.message}`;
|
|
1042
|
+
this.error(message, { exitCode: err.exitCode, code: err.code });
|
|
1043
|
+
}
|
|
1044
|
+
throw err;
|
|
1045
|
+
}
|
|
1046
|
+
}
|
|
1047
|
+
_registerOption(option) {
|
|
1048
|
+
const matchingOption = option.short && this._findOption(option.short) || option.long && this._findOption(option.long);
|
|
1049
|
+
if (matchingOption) {
|
|
1050
|
+
const matchingFlag = option.long && this._findOption(option.long) ? option.long : option.short;
|
|
1051
|
+
throw new Error(`Cannot add option '${option.flags}'${this._name && ` to command '${this._name}'`} due to conflicting flag '${matchingFlag}'
|
|
1052
|
+
- already used by option '${matchingOption.flags}'`);
|
|
1053
|
+
}
|
|
1054
|
+
this._initOptionGroup(option);
|
|
1055
|
+
this.options.push(option);
|
|
1056
|
+
}
|
|
1057
|
+
_registerCommand(command) {
|
|
1058
|
+
const knownBy = (cmd) => {
|
|
1059
|
+
return [cmd.name()].concat(cmd.aliases());
|
|
1060
|
+
};
|
|
1061
|
+
const alreadyUsed = knownBy(command).find((name) => this._findCommand(name));
|
|
1062
|
+
if (alreadyUsed) {
|
|
1063
|
+
const existingCmd = knownBy(this._findCommand(alreadyUsed)).join("|");
|
|
1064
|
+
const newCmd = knownBy(command).join("|");
|
|
1065
|
+
throw new Error(`cannot add command '${newCmd}' as already have command '${existingCmd}'`);
|
|
1066
|
+
}
|
|
1067
|
+
this._initCommandGroup(command);
|
|
1068
|
+
this.commands.push(command);
|
|
1069
|
+
}
|
|
1070
|
+
addOption(option) {
|
|
1071
|
+
this._registerOption(option);
|
|
1072
|
+
const oname = option.name();
|
|
1073
|
+
const name = option.attributeName();
|
|
1074
|
+
if (option.negate) {
|
|
1075
|
+
const positiveLongFlag = option.long.replace(/^--no-/, "--");
|
|
1076
|
+
if (!this._findOption(positiveLongFlag)) {
|
|
1077
|
+
this.setOptionValueWithSource(name, option.defaultValue === undefined ? true : option.defaultValue, "default");
|
|
1078
|
+
}
|
|
1079
|
+
} else if (option.defaultValue !== undefined) {
|
|
1080
|
+
this.setOptionValueWithSource(name, option.defaultValue, "default");
|
|
1081
|
+
}
|
|
1082
|
+
const handleOptionValue = (val, invalidValueMessage, valueSource) => {
|
|
1083
|
+
if (val == null && option.presetArg !== undefined) {
|
|
1084
|
+
val = option.presetArg;
|
|
1085
|
+
}
|
|
1086
|
+
const oldValue = this.getOptionValue(name);
|
|
1087
|
+
if (val !== null && option.parseArg) {
|
|
1088
|
+
val = this._callParseArg(option, val, oldValue, invalidValueMessage);
|
|
1089
|
+
} else if (val !== null && option.variadic) {
|
|
1090
|
+
val = option._collectValue(val, oldValue);
|
|
1091
|
+
}
|
|
1092
|
+
if (val == null) {
|
|
1093
|
+
if (option.negate) {
|
|
1094
|
+
val = false;
|
|
1095
|
+
} else if (option.isBoolean() || option.optional) {
|
|
1096
|
+
val = true;
|
|
1097
|
+
} else {
|
|
1098
|
+
val = "";
|
|
1099
|
+
}
|
|
1100
|
+
}
|
|
1101
|
+
this.setOptionValueWithSource(name, val, valueSource);
|
|
1102
|
+
};
|
|
1103
|
+
this.on("option:" + oname, (val) => {
|
|
1104
|
+
const invalidValueMessage = `error: option '${option.flags}' argument '${val}' is invalid.`;
|
|
1105
|
+
handleOptionValue(val, invalidValueMessage, "cli");
|
|
1106
|
+
});
|
|
1107
|
+
if (option.envVar) {
|
|
1108
|
+
this.on("optionEnv:" + oname, (val) => {
|
|
1109
|
+
const invalidValueMessage = `error: option '${option.flags}' value '${val}' from env '${option.envVar}' is invalid.`;
|
|
1110
|
+
handleOptionValue(val, invalidValueMessage, "env");
|
|
1111
|
+
});
|
|
1112
|
+
}
|
|
1113
|
+
return this;
|
|
1114
|
+
}
|
|
1115
|
+
_optionEx(config, flags, description, fn, defaultValue) {
|
|
1116
|
+
if (typeof flags === "object" && flags instanceof Option) {
|
|
1117
|
+
throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");
|
|
1118
|
+
}
|
|
1119
|
+
const option = this.createOption(flags, description);
|
|
1120
|
+
option.makeOptionMandatory(!!config.mandatory);
|
|
1121
|
+
if (typeof fn === "function") {
|
|
1122
|
+
option.default(defaultValue).argParser(fn);
|
|
1123
|
+
} else if (fn instanceof RegExp) {
|
|
1124
|
+
const regex = fn;
|
|
1125
|
+
fn = (val, def) => {
|
|
1126
|
+
const m = regex.exec(val);
|
|
1127
|
+
return m ? m[0] : def;
|
|
1128
|
+
};
|
|
1129
|
+
option.default(defaultValue).argParser(fn);
|
|
1130
|
+
} else {
|
|
1131
|
+
option.default(fn);
|
|
1132
|
+
}
|
|
1133
|
+
return this.addOption(option);
|
|
1134
|
+
}
|
|
1135
|
+
option(flags, description, parseArg, defaultValue) {
|
|
1136
|
+
return this._optionEx({}, flags, description, parseArg, defaultValue);
|
|
1137
|
+
}
|
|
1138
|
+
requiredOption(flags, description, parseArg, defaultValue) {
|
|
1139
|
+
return this._optionEx({ mandatory: true }, flags, description, parseArg, defaultValue);
|
|
1140
|
+
}
|
|
1141
|
+
combineFlagAndOptionalValue(combine = true) {
|
|
1142
|
+
this._combineFlagAndOptionalValue = !!combine;
|
|
1143
|
+
return this;
|
|
1144
|
+
}
|
|
1145
|
+
allowUnknownOption(allowUnknown = true) {
|
|
1146
|
+
this._allowUnknownOption = !!allowUnknown;
|
|
1147
|
+
return this;
|
|
1148
|
+
}
|
|
1149
|
+
allowExcessArguments(allowExcess = true) {
|
|
1150
|
+
this._allowExcessArguments = !!allowExcess;
|
|
1151
|
+
return this;
|
|
1152
|
+
}
|
|
1153
|
+
enablePositionalOptions(positional = true) {
|
|
1154
|
+
this._enablePositionalOptions = !!positional;
|
|
1155
|
+
return this;
|
|
1156
|
+
}
|
|
1157
|
+
passThroughOptions(passThrough = true) {
|
|
1158
|
+
this._passThroughOptions = !!passThrough;
|
|
1159
|
+
this._checkForBrokenPassThrough();
|
|
1160
|
+
return this;
|
|
1161
|
+
}
|
|
1162
|
+
_checkForBrokenPassThrough() {
|
|
1163
|
+
if (this.parent && this._passThroughOptions && !this.parent._enablePositionalOptions) {
|
|
1164
|
+
throw new Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`);
|
|
1165
|
+
}
|
|
1166
|
+
}
|
|
1167
|
+
storeOptionsAsProperties(storeAsProperties = true) {
|
|
1168
|
+
if (this.options.length) {
|
|
1169
|
+
throw new Error("call .storeOptionsAsProperties() before adding options");
|
|
1170
|
+
}
|
|
1171
|
+
if (Object.keys(this._optionValues).length) {
|
|
1172
|
+
throw new Error("call .storeOptionsAsProperties() before setting option values");
|
|
1173
|
+
}
|
|
1174
|
+
this._storeOptionsAsProperties = !!storeAsProperties;
|
|
1175
|
+
return this;
|
|
1176
|
+
}
|
|
1177
|
+
getOptionValue(key) {
|
|
1178
|
+
if (this._storeOptionsAsProperties) {
|
|
1179
|
+
return this[key];
|
|
1180
|
+
}
|
|
1181
|
+
return this._optionValues[key];
|
|
1182
|
+
}
|
|
1183
|
+
setOptionValue(key, value) {
|
|
1184
|
+
return this.setOptionValueWithSource(key, value, undefined);
|
|
1185
|
+
}
|
|
1186
|
+
setOptionValueWithSource(key, value, source) {
|
|
1187
|
+
if (this._storeOptionsAsProperties) {
|
|
1188
|
+
this[key] = value;
|
|
1189
|
+
} else {
|
|
1190
|
+
this._optionValues[key] = value;
|
|
1191
|
+
}
|
|
1192
|
+
this._optionValueSources[key] = source;
|
|
1193
|
+
return this;
|
|
1194
|
+
}
|
|
1195
|
+
getOptionValueSource(key) {
|
|
1196
|
+
return this._optionValueSources[key];
|
|
1197
|
+
}
|
|
1198
|
+
getOptionValueSourceWithGlobals(key) {
|
|
1199
|
+
let source;
|
|
1200
|
+
this._getCommandAndAncestors().forEach((cmd) => {
|
|
1201
|
+
if (cmd.getOptionValueSource(key) !== undefined) {
|
|
1202
|
+
source = cmd.getOptionValueSource(key);
|
|
1203
|
+
}
|
|
1204
|
+
});
|
|
1205
|
+
return source;
|
|
1206
|
+
}
|
|
1207
|
+
_prepareUserArgs(argv, parseOptions) {
|
|
1208
|
+
if (argv !== undefined && !Array.isArray(argv)) {
|
|
1209
|
+
throw new Error("first parameter to parse must be array or undefined");
|
|
1210
|
+
}
|
|
1211
|
+
parseOptions = parseOptions || {};
|
|
1212
|
+
if (argv === undefined && parseOptions.from === undefined) {
|
|
1213
|
+
if (process2.versions?.electron) {
|
|
1214
|
+
parseOptions.from = "electron";
|
|
1215
|
+
}
|
|
1216
|
+
const execArgv = process2.execArgv ?? [];
|
|
1217
|
+
if (execArgv.includes("-e") || execArgv.includes("--eval") || execArgv.includes("-p") || execArgv.includes("--print")) {
|
|
1218
|
+
parseOptions.from = "eval";
|
|
1219
|
+
}
|
|
1220
|
+
}
|
|
1221
|
+
if (argv === undefined) {
|
|
1222
|
+
argv = process2.argv;
|
|
1223
|
+
}
|
|
1224
|
+
this.rawArgs = argv.slice();
|
|
1225
|
+
let userArgs;
|
|
1226
|
+
switch (parseOptions.from) {
|
|
1227
|
+
case undefined:
|
|
1228
|
+
case "node":
|
|
1229
|
+
this._scriptPath = argv[1];
|
|
1230
|
+
userArgs = argv.slice(2);
|
|
1231
|
+
break;
|
|
1232
|
+
case "electron":
|
|
1233
|
+
if (process2.defaultApp) {
|
|
1234
|
+
this._scriptPath = argv[1];
|
|
1235
|
+
userArgs = argv.slice(2);
|
|
1236
|
+
} else {
|
|
1237
|
+
userArgs = argv.slice(1);
|
|
1238
|
+
}
|
|
1239
|
+
break;
|
|
1240
|
+
case "user":
|
|
1241
|
+
userArgs = argv.slice(0);
|
|
1242
|
+
break;
|
|
1243
|
+
case "eval":
|
|
1244
|
+
userArgs = argv.slice(1);
|
|
1245
|
+
break;
|
|
1246
|
+
default:
|
|
1247
|
+
throw new Error(`unexpected parse option { from: '${parseOptions.from}' }`);
|
|
1248
|
+
}
|
|
1249
|
+
if (!this._name && this._scriptPath)
|
|
1250
|
+
this.nameFromFilename(this._scriptPath);
|
|
1251
|
+
this._name = this._name || "program";
|
|
1252
|
+
return userArgs;
|
|
1253
|
+
}
|
|
1254
|
+
parse(argv, parseOptions) {
|
|
1255
|
+
this._prepareForParse();
|
|
1256
|
+
const userArgs = this._prepareUserArgs(argv, parseOptions);
|
|
1257
|
+
this._parseCommand([], userArgs);
|
|
1258
|
+
return this;
|
|
1259
|
+
}
|
|
1260
|
+
async parseAsync(argv, parseOptions) {
|
|
1261
|
+
this._prepareForParse();
|
|
1262
|
+
const userArgs = this._prepareUserArgs(argv, parseOptions);
|
|
1263
|
+
await this._parseCommand([], userArgs);
|
|
1264
|
+
return this;
|
|
1265
|
+
}
|
|
1266
|
+
_prepareForParse() {
|
|
1267
|
+
if (this._savedState === null) {
|
|
1268
|
+
this.saveStateBeforeParse();
|
|
1269
|
+
} else {
|
|
1270
|
+
this.restoreStateBeforeParse();
|
|
1271
|
+
}
|
|
1272
|
+
}
|
|
1273
|
+
saveStateBeforeParse() {
|
|
1274
|
+
this._savedState = {
|
|
1275
|
+
_name: this._name,
|
|
1276
|
+
_optionValues: { ...this._optionValues },
|
|
1277
|
+
_optionValueSources: { ...this._optionValueSources }
|
|
1278
|
+
};
|
|
1279
|
+
}
|
|
1280
|
+
restoreStateBeforeParse() {
|
|
1281
|
+
if (this._storeOptionsAsProperties)
|
|
1282
|
+
throw new Error(`Can not call parse again when storeOptionsAsProperties is true.
|
|
1283
|
+
- either make a new Command for each call to parse, or stop storing options as properties`);
|
|
1284
|
+
this._name = this._savedState._name;
|
|
1285
|
+
this._scriptPath = null;
|
|
1286
|
+
this.rawArgs = [];
|
|
1287
|
+
this._optionValues = { ...this._savedState._optionValues };
|
|
1288
|
+
this._optionValueSources = { ...this._savedState._optionValueSources };
|
|
1289
|
+
this.args = [];
|
|
1290
|
+
this.processedArgs = [];
|
|
1291
|
+
}
|
|
1292
|
+
_checkForMissingExecutable(executableFile, executableDir, subcommandName) {
|
|
1293
|
+
if (fs.existsSync(executableFile))
|
|
1294
|
+
return;
|
|
1295
|
+
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";
|
|
1296
|
+
const executableMissing = `'${executableFile}' does not exist
|
|
1297
|
+
- if '${subcommandName}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
|
|
1298
|
+
- if the default executable name is not suitable, use the executableFile option to supply a custom name or path
|
|
1299
|
+
- ${executableDirMessage}`;
|
|
1300
|
+
throw new Error(executableMissing);
|
|
1301
|
+
}
|
|
1302
|
+
_executeSubCommand(subcommand, args) {
|
|
1303
|
+
args = args.slice();
|
|
1304
|
+
let launchWithNode = false;
|
|
1305
|
+
const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
|
|
1306
|
+
function findFile(baseDir, baseName) {
|
|
1307
|
+
const localBin = path.resolve(baseDir, baseName);
|
|
1308
|
+
if (fs.existsSync(localBin))
|
|
1309
|
+
return localBin;
|
|
1310
|
+
if (sourceExt.includes(path.extname(baseName)))
|
|
1311
|
+
return;
|
|
1312
|
+
const foundExt = sourceExt.find((ext) => fs.existsSync(`${localBin}${ext}`));
|
|
1313
|
+
if (foundExt)
|
|
1314
|
+
return `${localBin}${foundExt}`;
|
|
1315
|
+
return;
|
|
1316
|
+
}
|
|
1317
|
+
this._checkForMissingMandatoryOptions();
|
|
1318
|
+
this._checkForConflictingOptions();
|
|
1319
|
+
let executableFile = subcommand._executableFile || `${this._name}-${subcommand._name}`;
|
|
1320
|
+
let executableDir = this._executableDir || "";
|
|
1321
|
+
if (this._scriptPath) {
|
|
1322
|
+
let resolvedScriptPath;
|
|
1323
|
+
try {
|
|
1324
|
+
resolvedScriptPath = fs.realpathSync(this._scriptPath);
|
|
1325
|
+
} catch {
|
|
1326
|
+
resolvedScriptPath = this._scriptPath;
|
|
1327
|
+
}
|
|
1328
|
+
executableDir = path.resolve(path.dirname(resolvedScriptPath), executableDir);
|
|
1329
|
+
}
|
|
1330
|
+
if (executableDir) {
|
|
1331
|
+
let localFile = findFile(executableDir, executableFile);
|
|
1332
|
+
if (!localFile && !subcommand._executableFile && this._scriptPath) {
|
|
1333
|
+
const legacyName = path.basename(this._scriptPath, path.extname(this._scriptPath));
|
|
1334
|
+
if (legacyName !== this._name) {
|
|
1335
|
+
localFile = findFile(executableDir, `${legacyName}-${subcommand._name}`);
|
|
1336
|
+
}
|
|
1337
|
+
}
|
|
1338
|
+
executableFile = localFile || executableFile;
|
|
1339
|
+
}
|
|
1340
|
+
launchWithNode = sourceExt.includes(path.extname(executableFile));
|
|
1341
|
+
let proc;
|
|
1342
|
+
if (process2.platform !== "win32") {
|
|
1343
|
+
if (launchWithNode) {
|
|
1344
|
+
args.unshift(executableFile);
|
|
1345
|
+
args = incrementNodeInspectorPort(process2.execArgv).concat(args);
|
|
1346
|
+
proc = childProcess.spawn(process2.argv[0], args, { stdio: "inherit" });
|
|
1347
|
+
} else {
|
|
1348
|
+
proc = childProcess.spawn(executableFile, args, { stdio: "inherit" });
|
|
1349
|
+
}
|
|
1350
|
+
} else {
|
|
1351
|
+
this._checkForMissingExecutable(executableFile, executableDir, subcommand._name);
|
|
1352
|
+
args.unshift(executableFile);
|
|
1353
|
+
args = incrementNodeInspectorPort(process2.execArgv).concat(args);
|
|
1354
|
+
proc = childProcess.spawn(process2.execPath, args, { stdio: "inherit" });
|
|
1355
|
+
}
|
|
1356
|
+
if (!proc.killed) {
|
|
1357
|
+
const signals = ["SIGUSR1", "SIGUSR2", "SIGTERM", "SIGINT", "SIGHUP"];
|
|
1358
|
+
signals.forEach((signal) => {
|
|
1359
|
+
process2.on(signal, () => {
|
|
1360
|
+
if (proc.killed === false && proc.exitCode === null) {
|
|
1361
|
+
proc.kill(signal);
|
|
1362
|
+
}
|
|
1363
|
+
});
|
|
1364
|
+
});
|
|
1365
|
+
}
|
|
1366
|
+
const exitCallback = this._exitCallback;
|
|
1367
|
+
proc.on("close", (code) => {
|
|
1368
|
+
code = code ?? 1;
|
|
1369
|
+
if (!exitCallback) {
|
|
1370
|
+
process2.exit(code);
|
|
1371
|
+
} else {
|
|
1372
|
+
exitCallback(new CommanderError(code, "commander.executeSubCommandAsync", "(close)"));
|
|
1373
|
+
}
|
|
1374
|
+
});
|
|
1375
|
+
proc.on("error", (err) => {
|
|
1376
|
+
if (err.code === "ENOENT") {
|
|
1377
|
+
this._checkForMissingExecutable(executableFile, executableDir, subcommand._name);
|
|
1378
|
+
} else if (err.code === "EACCES") {
|
|
1379
|
+
throw new Error(`'${executableFile}' not executable`);
|
|
1380
|
+
}
|
|
1381
|
+
if (!exitCallback) {
|
|
1382
|
+
process2.exit(1);
|
|
1383
|
+
} else {
|
|
1384
|
+
const wrappedError = new CommanderError(1, "commander.executeSubCommandAsync", "(error)");
|
|
1385
|
+
wrappedError.nestedError = err;
|
|
1386
|
+
exitCallback(wrappedError);
|
|
1387
|
+
}
|
|
1388
|
+
});
|
|
1389
|
+
this.runningCommand = proc;
|
|
1390
|
+
}
|
|
1391
|
+
_dispatchSubcommand(commandName, operands, unknown) {
|
|
1392
|
+
const subCommand = this._findCommand(commandName);
|
|
1393
|
+
if (!subCommand)
|
|
1394
|
+
this.help({ error: true });
|
|
1395
|
+
subCommand._prepareForParse();
|
|
1396
|
+
let promiseChain;
|
|
1397
|
+
promiseChain = this._chainOrCallSubCommandHook(promiseChain, subCommand, "preSubcommand");
|
|
1398
|
+
promiseChain = this._chainOrCall(promiseChain, () => {
|
|
1399
|
+
if (subCommand._executableHandler) {
|
|
1400
|
+
this._executeSubCommand(subCommand, operands.concat(unknown));
|
|
1401
|
+
} else {
|
|
1402
|
+
return subCommand._parseCommand(operands, unknown);
|
|
1403
|
+
}
|
|
1404
|
+
});
|
|
1405
|
+
return promiseChain;
|
|
1406
|
+
}
|
|
1407
|
+
_dispatchHelpCommand(subcommandName) {
|
|
1408
|
+
if (!subcommandName) {
|
|
1409
|
+
this.help();
|
|
1410
|
+
}
|
|
1411
|
+
const subCommand = this._findCommand(subcommandName);
|
|
1412
|
+
if (subCommand && !subCommand._executableHandler) {
|
|
1413
|
+
subCommand.help();
|
|
1414
|
+
}
|
|
1415
|
+
return this._dispatchSubcommand(subcommandName, [], [this._getHelpOption()?.long ?? this._getHelpOption()?.short ?? "--help"]);
|
|
1416
|
+
}
|
|
1417
|
+
_checkNumberOfArguments() {
|
|
1418
|
+
this.registeredArguments.forEach((arg, i) => {
|
|
1419
|
+
if (arg.required && this.args[i] == null) {
|
|
1420
|
+
this.missingArgument(arg.name());
|
|
1421
|
+
}
|
|
1422
|
+
});
|
|
1423
|
+
if (this.registeredArguments.length > 0 && this.registeredArguments[this.registeredArguments.length - 1].variadic) {
|
|
1424
|
+
return;
|
|
1425
|
+
}
|
|
1426
|
+
if (this.args.length > this.registeredArguments.length) {
|
|
1427
|
+
this._excessArguments(this.args);
|
|
1428
|
+
}
|
|
1429
|
+
}
|
|
1430
|
+
_processArguments() {
|
|
1431
|
+
const myParseArg = (argument, value, previous) => {
|
|
1432
|
+
let parsedValue = value;
|
|
1433
|
+
if (value !== null && argument.parseArg) {
|
|
1434
|
+
const invalidValueMessage = `error: command-argument value '${value}' is invalid for argument '${argument.name()}'.`;
|
|
1435
|
+
parsedValue = this._callParseArg(argument, value, previous, invalidValueMessage);
|
|
1436
|
+
}
|
|
1437
|
+
return parsedValue;
|
|
1438
|
+
};
|
|
1439
|
+
this._checkNumberOfArguments();
|
|
1440
|
+
const processedArgs = [];
|
|
1441
|
+
this.registeredArguments.forEach((declaredArg, index) => {
|
|
1442
|
+
let value = declaredArg.defaultValue;
|
|
1443
|
+
if (declaredArg.variadic) {
|
|
1444
|
+
if (index < this.args.length) {
|
|
1445
|
+
value = this.args.slice(index);
|
|
1446
|
+
if (declaredArg.parseArg) {
|
|
1447
|
+
value = value.reduce((processed, v) => {
|
|
1448
|
+
return myParseArg(declaredArg, v, processed);
|
|
1449
|
+
}, declaredArg.defaultValue);
|
|
1450
|
+
}
|
|
1451
|
+
} else if (value === undefined) {
|
|
1452
|
+
value = [];
|
|
1453
|
+
}
|
|
1454
|
+
} else if (index < this.args.length) {
|
|
1455
|
+
value = this.args[index];
|
|
1456
|
+
if (declaredArg.parseArg) {
|
|
1457
|
+
value = myParseArg(declaredArg, value, declaredArg.defaultValue);
|
|
1458
|
+
}
|
|
1459
|
+
}
|
|
1460
|
+
processedArgs[index] = value;
|
|
1461
|
+
});
|
|
1462
|
+
this.processedArgs = processedArgs;
|
|
1463
|
+
}
|
|
1464
|
+
_chainOrCall(promise, fn) {
|
|
1465
|
+
if (promise?.then && typeof promise.then === "function") {
|
|
1466
|
+
return promise.then(() => fn());
|
|
1467
|
+
}
|
|
1468
|
+
return fn();
|
|
1469
|
+
}
|
|
1470
|
+
_chainOrCallHooks(promise, event) {
|
|
1471
|
+
let result = promise;
|
|
1472
|
+
const hooks = [];
|
|
1473
|
+
this._getCommandAndAncestors().reverse().filter((cmd) => cmd._lifeCycleHooks[event] !== undefined).forEach((hookedCommand) => {
|
|
1474
|
+
hookedCommand._lifeCycleHooks[event].forEach((callback) => {
|
|
1475
|
+
hooks.push({ hookedCommand, callback });
|
|
1476
|
+
});
|
|
1477
|
+
});
|
|
1478
|
+
if (event === "postAction") {
|
|
1479
|
+
hooks.reverse();
|
|
1480
|
+
}
|
|
1481
|
+
hooks.forEach((hookDetail) => {
|
|
1482
|
+
result = this._chainOrCall(result, () => {
|
|
1483
|
+
return hookDetail.callback(hookDetail.hookedCommand, this);
|
|
1484
|
+
});
|
|
1485
|
+
});
|
|
1486
|
+
return result;
|
|
1487
|
+
}
|
|
1488
|
+
_chainOrCallSubCommandHook(promise, subCommand, event) {
|
|
1489
|
+
let result = promise;
|
|
1490
|
+
if (this._lifeCycleHooks[event] !== undefined) {
|
|
1491
|
+
this._lifeCycleHooks[event].forEach((hook) => {
|
|
1492
|
+
result = this._chainOrCall(result, () => {
|
|
1493
|
+
return hook(this, subCommand);
|
|
1494
|
+
});
|
|
1495
|
+
});
|
|
1496
|
+
}
|
|
1497
|
+
return result;
|
|
1498
|
+
}
|
|
1499
|
+
_parseCommand(operands, unknown) {
|
|
1500
|
+
const parsed = this.parseOptions(unknown);
|
|
1501
|
+
this._parseOptionsEnv();
|
|
1502
|
+
this._parseOptionsImplied();
|
|
1503
|
+
operands = operands.concat(parsed.operands);
|
|
1504
|
+
unknown = parsed.unknown;
|
|
1505
|
+
this.args = operands.concat(unknown);
|
|
1506
|
+
if (operands && this._findCommand(operands[0])) {
|
|
1507
|
+
return this._dispatchSubcommand(operands[0], operands.slice(1), unknown);
|
|
1508
|
+
}
|
|
1509
|
+
if (this._getHelpCommand() && operands[0] === this._getHelpCommand().name()) {
|
|
1510
|
+
return this._dispatchHelpCommand(operands[1]);
|
|
1511
|
+
}
|
|
1512
|
+
if (this._defaultCommandName) {
|
|
1513
|
+
this._outputHelpIfRequested(unknown);
|
|
1514
|
+
return this._dispatchSubcommand(this._defaultCommandName, operands, unknown);
|
|
1515
|
+
}
|
|
1516
|
+
if (this.commands.length && this.args.length === 0 && !this._actionHandler && !this._defaultCommandName) {
|
|
1517
|
+
this.help({ error: true });
|
|
1518
|
+
}
|
|
1519
|
+
this._outputHelpIfRequested(parsed.unknown);
|
|
1520
|
+
this._checkForMissingMandatoryOptions();
|
|
1521
|
+
this._checkForConflictingOptions();
|
|
1522
|
+
const checkForUnknownOptions = () => {
|
|
1523
|
+
if (parsed.unknown.length > 0) {
|
|
1524
|
+
this.unknownOption(parsed.unknown[0]);
|
|
1525
|
+
}
|
|
1526
|
+
};
|
|
1527
|
+
const commandEvent = `command:${this.name()}`;
|
|
1528
|
+
if (this._actionHandler) {
|
|
1529
|
+
checkForUnknownOptions();
|
|
1530
|
+
this._processArguments();
|
|
1531
|
+
let promiseChain;
|
|
1532
|
+
promiseChain = this._chainOrCallHooks(promiseChain, "preAction");
|
|
1533
|
+
promiseChain = this._chainOrCall(promiseChain, () => this._actionHandler(this.processedArgs));
|
|
1534
|
+
if (this.parent) {
|
|
1535
|
+
promiseChain = this._chainOrCall(promiseChain, () => {
|
|
1536
|
+
this.parent.emit(commandEvent, operands, unknown);
|
|
1537
|
+
});
|
|
1538
|
+
}
|
|
1539
|
+
promiseChain = this._chainOrCallHooks(promiseChain, "postAction");
|
|
1540
|
+
return promiseChain;
|
|
1541
|
+
}
|
|
1542
|
+
if (this.parent?.listenerCount(commandEvent)) {
|
|
1543
|
+
checkForUnknownOptions();
|
|
1544
|
+
this._processArguments();
|
|
1545
|
+
this.parent.emit(commandEvent, operands, unknown);
|
|
1546
|
+
} else if (operands.length) {
|
|
1547
|
+
if (this._findCommand("*")) {
|
|
1548
|
+
return this._dispatchSubcommand("*", operands, unknown);
|
|
1549
|
+
}
|
|
1550
|
+
if (this.listenerCount("command:*")) {
|
|
1551
|
+
this.emit("command:*", operands, unknown);
|
|
1552
|
+
} else if (this.commands.length) {
|
|
1553
|
+
this.unknownCommand();
|
|
1554
|
+
} else {
|
|
1555
|
+
checkForUnknownOptions();
|
|
1556
|
+
this._processArguments();
|
|
1557
|
+
}
|
|
1558
|
+
} else if (this.commands.length) {
|
|
1559
|
+
checkForUnknownOptions();
|
|
1560
|
+
this.help({ error: true });
|
|
1561
|
+
} else {
|
|
1562
|
+
checkForUnknownOptions();
|
|
1563
|
+
this._processArguments();
|
|
1564
|
+
}
|
|
1565
|
+
}
|
|
1566
|
+
_findCommand(name) {
|
|
1567
|
+
if (!name)
|
|
1568
|
+
return;
|
|
1569
|
+
return this.commands.find((cmd) => cmd._name === name || cmd._aliases.includes(name));
|
|
1570
|
+
}
|
|
1571
|
+
_findOption(arg) {
|
|
1572
|
+
return this.options.find((option) => option.is(arg));
|
|
1573
|
+
}
|
|
1574
|
+
_checkForMissingMandatoryOptions() {
|
|
1575
|
+
this._getCommandAndAncestors().forEach((cmd) => {
|
|
1576
|
+
cmd.options.forEach((anOption) => {
|
|
1577
|
+
if (anOption.mandatory && cmd.getOptionValue(anOption.attributeName()) === undefined) {
|
|
1578
|
+
cmd.missingMandatoryOptionValue(anOption);
|
|
1579
|
+
}
|
|
1580
|
+
});
|
|
1581
|
+
});
|
|
1582
|
+
}
|
|
1583
|
+
_checkForConflictingLocalOptions() {
|
|
1584
|
+
const definedNonDefaultOptions = this.options.filter((option) => {
|
|
1585
|
+
const optionKey = option.attributeName();
|
|
1586
|
+
if (this.getOptionValue(optionKey) === undefined) {
|
|
1587
|
+
return false;
|
|
1588
|
+
}
|
|
1589
|
+
return this.getOptionValueSource(optionKey) !== "default";
|
|
1590
|
+
});
|
|
1591
|
+
const optionsWithConflicting = definedNonDefaultOptions.filter((option) => option.conflictsWith.length > 0);
|
|
1592
|
+
optionsWithConflicting.forEach((option) => {
|
|
1593
|
+
const conflictingAndDefined = definedNonDefaultOptions.find((defined) => option.conflictsWith.includes(defined.attributeName()));
|
|
1594
|
+
if (conflictingAndDefined) {
|
|
1595
|
+
this._conflictingOption(option, conflictingAndDefined);
|
|
1596
|
+
}
|
|
1597
|
+
});
|
|
1598
|
+
}
|
|
1599
|
+
_checkForConflictingOptions() {
|
|
1600
|
+
this._getCommandAndAncestors().forEach((cmd) => {
|
|
1601
|
+
cmd._checkForConflictingLocalOptions();
|
|
1602
|
+
});
|
|
1603
|
+
}
|
|
1604
|
+
parseOptions(args) {
|
|
1605
|
+
const operands = [];
|
|
1606
|
+
const unknown = [];
|
|
1607
|
+
let dest = operands;
|
|
1608
|
+
function maybeOption(arg) {
|
|
1609
|
+
return arg.length > 1 && arg[0] === "-";
|
|
1610
|
+
}
|
|
1611
|
+
const negativeNumberArg = (arg) => {
|
|
1612
|
+
if (!/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(arg))
|
|
1613
|
+
return false;
|
|
1614
|
+
return !this._getCommandAndAncestors().some((cmd) => cmd.options.map((opt) => opt.short).some((short) => /^-\d$/.test(short)));
|
|
1615
|
+
};
|
|
1616
|
+
let activeVariadicOption = null;
|
|
1617
|
+
let activeGroup = null;
|
|
1618
|
+
let i = 0;
|
|
1619
|
+
while (i < args.length || activeGroup) {
|
|
1620
|
+
const arg = activeGroup ?? args[i++];
|
|
1621
|
+
activeGroup = null;
|
|
1622
|
+
if (arg === "--") {
|
|
1623
|
+
if (dest === unknown)
|
|
1624
|
+
dest.push(arg);
|
|
1625
|
+
dest.push(...args.slice(i));
|
|
1626
|
+
break;
|
|
1627
|
+
}
|
|
1628
|
+
if (activeVariadicOption && (!maybeOption(arg) || negativeNumberArg(arg))) {
|
|
1629
|
+
this.emit(`option:${activeVariadicOption.name()}`, arg);
|
|
1630
|
+
continue;
|
|
1631
|
+
}
|
|
1632
|
+
activeVariadicOption = null;
|
|
1633
|
+
if (maybeOption(arg)) {
|
|
1634
|
+
const option = this._findOption(arg);
|
|
1635
|
+
if (option) {
|
|
1636
|
+
if (option.required) {
|
|
1637
|
+
const value = args[i++];
|
|
1638
|
+
if (value === undefined)
|
|
1639
|
+
this.optionMissingArgument(option);
|
|
1640
|
+
this.emit(`option:${option.name()}`, value);
|
|
1641
|
+
} else if (option.optional) {
|
|
1642
|
+
let value = null;
|
|
1643
|
+
if (i < args.length && (!maybeOption(args[i]) || negativeNumberArg(args[i]))) {
|
|
1644
|
+
value = args[i++];
|
|
1645
|
+
}
|
|
1646
|
+
this.emit(`option:${option.name()}`, value);
|
|
1647
|
+
} else {
|
|
1648
|
+
this.emit(`option:${option.name()}`);
|
|
1649
|
+
}
|
|
1650
|
+
activeVariadicOption = option.variadic ? option : null;
|
|
1651
|
+
continue;
|
|
1652
|
+
}
|
|
1653
|
+
}
|
|
1654
|
+
if (arg.length > 2 && arg[0] === "-" && arg[1] !== "-") {
|
|
1655
|
+
const option = this._findOption(`-${arg[1]}`);
|
|
1656
|
+
if (option) {
|
|
1657
|
+
if (option.required || option.optional && this._combineFlagAndOptionalValue) {
|
|
1658
|
+
this.emit(`option:${option.name()}`, arg.slice(2));
|
|
1659
|
+
} else {
|
|
1660
|
+
this.emit(`option:${option.name()}`);
|
|
1661
|
+
activeGroup = `-${arg.slice(2)}`;
|
|
1662
|
+
}
|
|
1663
|
+
continue;
|
|
1664
|
+
}
|
|
1665
|
+
}
|
|
1666
|
+
if (/^--[^=]+=/.test(arg)) {
|
|
1667
|
+
const index = arg.indexOf("=");
|
|
1668
|
+
const option = this._findOption(arg.slice(0, index));
|
|
1669
|
+
if (option && (option.required || option.optional)) {
|
|
1670
|
+
this.emit(`option:${option.name()}`, arg.slice(index + 1));
|
|
1671
|
+
continue;
|
|
1672
|
+
}
|
|
1673
|
+
}
|
|
1674
|
+
if (dest === operands && maybeOption(arg) && !(this.commands.length === 0 && negativeNumberArg(arg))) {
|
|
1675
|
+
dest = unknown;
|
|
1676
|
+
}
|
|
1677
|
+
if ((this._enablePositionalOptions || this._passThroughOptions) && operands.length === 0 && unknown.length === 0) {
|
|
1678
|
+
if (this._findCommand(arg)) {
|
|
1679
|
+
operands.push(arg);
|
|
1680
|
+
unknown.push(...args.slice(i));
|
|
1681
|
+
break;
|
|
1682
|
+
} else if (this._getHelpCommand() && arg === this._getHelpCommand().name()) {
|
|
1683
|
+
operands.push(arg, ...args.slice(i));
|
|
1684
|
+
break;
|
|
1685
|
+
} else if (this._defaultCommandName) {
|
|
1686
|
+
unknown.push(arg, ...args.slice(i));
|
|
1687
|
+
break;
|
|
1688
|
+
}
|
|
1689
|
+
}
|
|
1690
|
+
if (this._passThroughOptions) {
|
|
1691
|
+
dest.push(arg, ...args.slice(i));
|
|
1692
|
+
break;
|
|
1693
|
+
}
|
|
1694
|
+
dest.push(arg);
|
|
1695
|
+
}
|
|
1696
|
+
return { operands, unknown };
|
|
1697
|
+
}
|
|
1698
|
+
opts() {
|
|
1699
|
+
if (this._storeOptionsAsProperties) {
|
|
1700
|
+
const result = {};
|
|
1701
|
+
const len = this.options.length;
|
|
1702
|
+
for (let i = 0;i < len; i++) {
|
|
1703
|
+
const key = this.options[i].attributeName();
|
|
1704
|
+
result[key] = key === this._versionOptionName ? this._version : this[key];
|
|
1705
|
+
}
|
|
1706
|
+
return result;
|
|
1707
|
+
}
|
|
1708
|
+
return this._optionValues;
|
|
1709
|
+
}
|
|
1710
|
+
optsWithGlobals() {
|
|
1711
|
+
return this._getCommandAndAncestors().reduce((combinedOptions, cmd) => Object.assign(combinedOptions, cmd.opts()), {});
|
|
1712
|
+
}
|
|
1713
|
+
error(message, errorOptions) {
|
|
1714
|
+
this._outputConfiguration.outputError(`${message}
|
|
1715
|
+
`, this._outputConfiguration.writeErr);
|
|
1716
|
+
if (typeof this._showHelpAfterError === "string") {
|
|
1717
|
+
this._outputConfiguration.writeErr(`${this._showHelpAfterError}
|
|
1718
|
+
`);
|
|
1719
|
+
} else if (this._showHelpAfterError) {
|
|
1720
|
+
this._outputConfiguration.writeErr(`
|
|
1721
|
+
`);
|
|
1722
|
+
this.outputHelp({ error: true });
|
|
1723
|
+
}
|
|
1724
|
+
const config = errorOptions || {};
|
|
1725
|
+
const exitCode = config.exitCode || 1;
|
|
1726
|
+
const code = config.code || "commander.error";
|
|
1727
|
+
this._exit(exitCode, code, message);
|
|
1728
|
+
}
|
|
1729
|
+
_parseOptionsEnv() {
|
|
1730
|
+
this.options.forEach((option) => {
|
|
1731
|
+
if (option.envVar && option.envVar in process2.env) {
|
|
1732
|
+
const optionKey = option.attributeName();
|
|
1733
|
+
if (this.getOptionValue(optionKey) === undefined || ["default", "config", "env"].includes(this.getOptionValueSource(optionKey))) {
|
|
1734
|
+
if (option.required || option.optional) {
|
|
1735
|
+
this.emit(`optionEnv:${option.name()}`, process2.env[option.envVar]);
|
|
1736
|
+
} else {
|
|
1737
|
+
this.emit(`optionEnv:${option.name()}`);
|
|
1738
|
+
}
|
|
1739
|
+
}
|
|
1740
|
+
}
|
|
1741
|
+
});
|
|
1742
|
+
}
|
|
1743
|
+
_parseOptionsImplied() {
|
|
1744
|
+
const dualHelper = new DualOptions(this.options);
|
|
1745
|
+
const hasCustomOptionValue = (optionKey) => {
|
|
1746
|
+
return this.getOptionValue(optionKey) !== undefined && !["default", "implied"].includes(this.getOptionValueSource(optionKey));
|
|
1747
|
+
};
|
|
1748
|
+
this.options.filter((option) => option.implied !== undefined && hasCustomOptionValue(option.attributeName()) && dualHelper.valueFromOption(this.getOptionValue(option.attributeName()), option)).forEach((option) => {
|
|
1749
|
+
Object.keys(option.implied).filter((impliedKey) => !hasCustomOptionValue(impliedKey)).forEach((impliedKey) => {
|
|
1750
|
+
this.setOptionValueWithSource(impliedKey, option.implied[impliedKey], "implied");
|
|
1751
|
+
});
|
|
1752
|
+
});
|
|
1753
|
+
}
|
|
1754
|
+
missingArgument(name) {
|
|
1755
|
+
const message = `error: missing required argument '${name}'`;
|
|
1756
|
+
this.error(message, { code: "commander.missingArgument" });
|
|
1757
|
+
}
|
|
1758
|
+
optionMissingArgument(option) {
|
|
1759
|
+
const message = `error: option '${option.flags}' argument missing`;
|
|
1760
|
+
this.error(message, { code: "commander.optionMissingArgument" });
|
|
1761
|
+
}
|
|
1762
|
+
missingMandatoryOptionValue(option) {
|
|
1763
|
+
const message = `error: required option '${option.flags}' not specified`;
|
|
1764
|
+
this.error(message, { code: "commander.missingMandatoryOptionValue" });
|
|
1765
|
+
}
|
|
1766
|
+
_conflictingOption(option, conflictingOption) {
|
|
1767
|
+
const findBestOptionFromValue = (option2) => {
|
|
1768
|
+
const optionKey = option2.attributeName();
|
|
1769
|
+
const optionValue = this.getOptionValue(optionKey);
|
|
1770
|
+
const negativeOption = this.options.find((target) => target.negate && optionKey === target.attributeName());
|
|
1771
|
+
const positiveOption = this.options.find((target) => !target.negate && optionKey === target.attributeName());
|
|
1772
|
+
if (negativeOption && (negativeOption.presetArg === undefined && optionValue === false || negativeOption.presetArg !== undefined && optionValue === negativeOption.presetArg)) {
|
|
1773
|
+
return negativeOption;
|
|
1774
|
+
}
|
|
1775
|
+
return positiveOption || option2;
|
|
1776
|
+
};
|
|
1777
|
+
const getErrorMessage = (option2) => {
|
|
1778
|
+
const bestOption = findBestOptionFromValue(option2);
|
|
1779
|
+
const optionKey = bestOption.attributeName();
|
|
1780
|
+
const source = this.getOptionValueSource(optionKey);
|
|
1781
|
+
if (source === "env") {
|
|
1782
|
+
return `environment variable '${bestOption.envVar}'`;
|
|
1783
|
+
}
|
|
1784
|
+
return `option '${bestOption.flags}'`;
|
|
1785
|
+
};
|
|
1786
|
+
const message = `error: ${getErrorMessage(option)} cannot be used with ${getErrorMessage(conflictingOption)}`;
|
|
1787
|
+
this.error(message, { code: "commander.conflictingOption" });
|
|
1788
|
+
}
|
|
1789
|
+
unknownOption(flag) {
|
|
1790
|
+
if (this._allowUnknownOption)
|
|
1791
|
+
return;
|
|
1792
|
+
let suggestion = "";
|
|
1793
|
+
if (flag.startsWith("--") && this._showSuggestionAfterError) {
|
|
1794
|
+
let candidateFlags = [];
|
|
1795
|
+
let command = this;
|
|
1796
|
+
do {
|
|
1797
|
+
const moreFlags = command.createHelp().visibleOptions(command).filter((option) => option.long).map((option) => option.long);
|
|
1798
|
+
candidateFlags = candidateFlags.concat(moreFlags);
|
|
1799
|
+
command = command.parent;
|
|
1800
|
+
} while (command && !command._enablePositionalOptions);
|
|
1801
|
+
suggestion = suggestSimilar(flag, candidateFlags);
|
|
1802
|
+
}
|
|
1803
|
+
const message = `error: unknown option '${flag}'${suggestion}`;
|
|
1804
|
+
this.error(message, { code: "commander.unknownOption" });
|
|
1805
|
+
}
|
|
1806
|
+
_excessArguments(receivedArgs) {
|
|
1807
|
+
if (this._allowExcessArguments)
|
|
1808
|
+
return;
|
|
1809
|
+
const expected = this.registeredArguments.length;
|
|
1810
|
+
const s = expected === 1 ? "" : "s";
|
|
1811
|
+
const forSubcommand = this.parent ? ` for '${this.name()}'` : "";
|
|
1812
|
+
const message = `error: too many arguments${forSubcommand}. Expected ${expected} argument${s} but got ${receivedArgs.length}.`;
|
|
1813
|
+
this.error(message, { code: "commander.excessArguments" });
|
|
1814
|
+
}
|
|
1815
|
+
unknownCommand() {
|
|
1816
|
+
const unknownName = this.args[0];
|
|
1817
|
+
let suggestion = "";
|
|
1818
|
+
if (this._showSuggestionAfterError) {
|
|
1819
|
+
const candidateNames = [];
|
|
1820
|
+
this.createHelp().visibleCommands(this).forEach((command) => {
|
|
1821
|
+
candidateNames.push(command.name());
|
|
1822
|
+
if (command.alias())
|
|
1823
|
+
candidateNames.push(command.alias());
|
|
1824
|
+
});
|
|
1825
|
+
suggestion = suggestSimilar(unknownName, candidateNames);
|
|
1826
|
+
}
|
|
1827
|
+
const message = `error: unknown command '${unknownName}'${suggestion}`;
|
|
1828
|
+
this.error(message, { code: "commander.unknownCommand" });
|
|
1829
|
+
}
|
|
1830
|
+
version(str, flags, description) {
|
|
1831
|
+
if (str === undefined)
|
|
1832
|
+
return this._version;
|
|
1833
|
+
this._version = str;
|
|
1834
|
+
flags = flags || "-V, --version";
|
|
1835
|
+
description = description || "output the version number";
|
|
1836
|
+
const versionOption = this.createOption(flags, description);
|
|
1837
|
+
this._versionOptionName = versionOption.attributeName();
|
|
1838
|
+
this._registerOption(versionOption);
|
|
1839
|
+
this.on("option:" + versionOption.name(), () => {
|
|
1840
|
+
this._outputConfiguration.writeOut(`${str}
|
|
1841
|
+
`);
|
|
1842
|
+
this._exit(0, "commander.version", str);
|
|
1843
|
+
});
|
|
1844
|
+
return this;
|
|
1845
|
+
}
|
|
1846
|
+
description(str, argsDescription) {
|
|
1847
|
+
if (str === undefined && argsDescription === undefined)
|
|
1848
|
+
return this._description;
|
|
1849
|
+
this._description = str;
|
|
1850
|
+
if (argsDescription) {
|
|
1851
|
+
this._argsDescription = argsDescription;
|
|
1852
|
+
}
|
|
1853
|
+
return this;
|
|
1854
|
+
}
|
|
1855
|
+
summary(str) {
|
|
1856
|
+
if (str === undefined)
|
|
1857
|
+
return this._summary;
|
|
1858
|
+
this._summary = str;
|
|
1859
|
+
return this;
|
|
1860
|
+
}
|
|
1861
|
+
alias(alias) {
|
|
1862
|
+
if (alias === undefined)
|
|
1863
|
+
return this._aliases[0];
|
|
1864
|
+
let command = this;
|
|
1865
|
+
if (this.commands.length !== 0 && this.commands[this.commands.length - 1]._executableHandler) {
|
|
1866
|
+
command = this.commands[this.commands.length - 1];
|
|
1867
|
+
}
|
|
1868
|
+
if (alias === command._name)
|
|
1869
|
+
throw new Error("Command alias can't be the same as its name");
|
|
1870
|
+
const matchingCommand = this.parent?._findCommand(alias);
|
|
1871
|
+
if (matchingCommand) {
|
|
1872
|
+
const existingCmd = [matchingCommand.name()].concat(matchingCommand.aliases()).join("|");
|
|
1873
|
+
throw new Error(`cannot add alias '${alias}' to command '${this.name()}' as already have command '${existingCmd}'`);
|
|
1874
|
+
}
|
|
1875
|
+
command._aliases.push(alias);
|
|
1876
|
+
return this;
|
|
1877
|
+
}
|
|
1878
|
+
aliases(aliases) {
|
|
1879
|
+
if (aliases === undefined)
|
|
1880
|
+
return this._aliases;
|
|
1881
|
+
aliases.forEach((alias) => this.alias(alias));
|
|
1882
|
+
return this;
|
|
1883
|
+
}
|
|
1884
|
+
usage(str) {
|
|
1885
|
+
if (str === undefined) {
|
|
1886
|
+
if (this._usage)
|
|
1887
|
+
return this._usage;
|
|
1888
|
+
const args = this.registeredArguments.map((arg) => {
|
|
1889
|
+
return humanReadableArgName(arg);
|
|
1890
|
+
});
|
|
1891
|
+
return [].concat(this.options.length || this._helpOption !== null ? "[options]" : [], this.commands.length ? "[command]" : [], this.registeredArguments.length ? args : []).join(" ");
|
|
1892
|
+
}
|
|
1893
|
+
this._usage = str;
|
|
1894
|
+
return this;
|
|
1895
|
+
}
|
|
1896
|
+
name(str) {
|
|
1897
|
+
if (str === undefined)
|
|
1898
|
+
return this._name;
|
|
1899
|
+
this._name = str;
|
|
1900
|
+
return this;
|
|
1901
|
+
}
|
|
1902
|
+
helpGroup(heading) {
|
|
1903
|
+
if (heading === undefined)
|
|
1904
|
+
return this._helpGroupHeading ?? "";
|
|
1905
|
+
this._helpGroupHeading = heading;
|
|
1906
|
+
return this;
|
|
1907
|
+
}
|
|
1908
|
+
commandsGroup(heading) {
|
|
1909
|
+
if (heading === undefined)
|
|
1910
|
+
return this._defaultCommandGroup ?? "";
|
|
1911
|
+
this._defaultCommandGroup = heading;
|
|
1912
|
+
return this;
|
|
1913
|
+
}
|
|
1914
|
+
optionsGroup(heading) {
|
|
1915
|
+
if (heading === undefined)
|
|
1916
|
+
return this._defaultOptionGroup ?? "";
|
|
1917
|
+
this._defaultOptionGroup = heading;
|
|
1918
|
+
return this;
|
|
1919
|
+
}
|
|
1920
|
+
_initOptionGroup(option) {
|
|
1921
|
+
if (this._defaultOptionGroup && !option.helpGroupHeading)
|
|
1922
|
+
option.helpGroup(this._defaultOptionGroup);
|
|
1923
|
+
}
|
|
1924
|
+
_initCommandGroup(cmd) {
|
|
1925
|
+
if (this._defaultCommandGroup && !cmd.helpGroup())
|
|
1926
|
+
cmd.helpGroup(this._defaultCommandGroup);
|
|
1927
|
+
}
|
|
1928
|
+
nameFromFilename(filename) {
|
|
1929
|
+
this._name = path.basename(filename, path.extname(filename));
|
|
1930
|
+
return this;
|
|
1931
|
+
}
|
|
1932
|
+
executableDir(path2) {
|
|
1933
|
+
if (path2 === undefined)
|
|
1934
|
+
return this._executableDir;
|
|
1935
|
+
this._executableDir = path2;
|
|
1936
|
+
return this;
|
|
1937
|
+
}
|
|
1938
|
+
helpInformation(contextOptions) {
|
|
1939
|
+
const helper = this.createHelp();
|
|
1940
|
+
const context = this._getOutputContext(contextOptions);
|
|
1941
|
+
helper.prepareContext({
|
|
1942
|
+
error: context.error,
|
|
1943
|
+
helpWidth: context.helpWidth,
|
|
1944
|
+
outputHasColors: context.hasColors
|
|
1945
|
+
});
|
|
1946
|
+
const text = helper.formatHelp(this, helper);
|
|
1947
|
+
if (context.hasColors)
|
|
1948
|
+
return text;
|
|
1949
|
+
return this._outputConfiguration.stripColor(text);
|
|
1950
|
+
}
|
|
1951
|
+
_getOutputContext(contextOptions) {
|
|
1952
|
+
contextOptions = contextOptions || {};
|
|
1953
|
+
const error = !!contextOptions.error;
|
|
1954
|
+
let baseWrite;
|
|
1955
|
+
let hasColors;
|
|
1956
|
+
let helpWidth;
|
|
1957
|
+
if (error) {
|
|
1958
|
+
baseWrite = (str) => this._outputConfiguration.writeErr(str);
|
|
1959
|
+
hasColors = this._outputConfiguration.getErrHasColors();
|
|
1960
|
+
helpWidth = this._outputConfiguration.getErrHelpWidth();
|
|
1961
|
+
} else {
|
|
1962
|
+
baseWrite = (str) => this._outputConfiguration.writeOut(str);
|
|
1963
|
+
hasColors = this._outputConfiguration.getOutHasColors();
|
|
1964
|
+
helpWidth = this._outputConfiguration.getOutHelpWidth();
|
|
1965
|
+
}
|
|
1966
|
+
const write = (str) => {
|
|
1967
|
+
if (!hasColors)
|
|
1968
|
+
str = this._outputConfiguration.stripColor(str);
|
|
1969
|
+
return baseWrite(str);
|
|
1970
|
+
};
|
|
1971
|
+
return { error, write, hasColors, helpWidth };
|
|
1972
|
+
}
|
|
1973
|
+
outputHelp(contextOptions) {
|
|
1974
|
+
let deprecatedCallback;
|
|
1975
|
+
if (typeof contextOptions === "function") {
|
|
1976
|
+
deprecatedCallback = contextOptions;
|
|
1977
|
+
contextOptions = undefined;
|
|
1978
|
+
}
|
|
1979
|
+
const outputContext = this._getOutputContext(contextOptions);
|
|
1980
|
+
const eventContext = {
|
|
1981
|
+
error: outputContext.error,
|
|
1982
|
+
write: outputContext.write,
|
|
1983
|
+
command: this
|
|
1984
|
+
};
|
|
1985
|
+
this._getCommandAndAncestors().reverse().forEach((command) => command.emit("beforeAllHelp", eventContext));
|
|
1986
|
+
this.emit("beforeHelp", eventContext);
|
|
1987
|
+
let helpInformation = this.helpInformation({ error: outputContext.error });
|
|
1988
|
+
if (deprecatedCallback) {
|
|
1989
|
+
helpInformation = deprecatedCallback(helpInformation);
|
|
1990
|
+
if (typeof helpInformation !== "string" && !Buffer.isBuffer(helpInformation)) {
|
|
1991
|
+
throw new Error("outputHelp callback must return a string or a Buffer");
|
|
1992
|
+
}
|
|
1993
|
+
}
|
|
1994
|
+
outputContext.write(helpInformation);
|
|
1995
|
+
if (this._getHelpOption()?.long) {
|
|
1996
|
+
this.emit(this._getHelpOption().long);
|
|
1997
|
+
}
|
|
1998
|
+
this.emit("afterHelp", eventContext);
|
|
1999
|
+
this._getCommandAndAncestors().forEach((command) => command.emit("afterAllHelp", eventContext));
|
|
2000
|
+
}
|
|
2001
|
+
helpOption(flags, description) {
|
|
2002
|
+
if (typeof flags === "boolean") {
|
|
2003
|
+
if (flags) {
|
|
2004
|
+
if (this._helpOption === null)
|
|
2005
|
+
this._helpOption = undefined;
|
|
2006
|
+
if (this._defaultOptionGroup) {
|
|
2007
|
+
this._initOptionGroup(this._getHelpOption());
|
|
2008
|
+
}
|
|
2009
|
+
} else {
|
|
2010
|
+
this._helpOption = null;
|
|
2011
|
+
}
|
|
2012
|
+
return this;
|
|
2013
|
+
}
|
|
2014
|
+
this._helpOption = this.createOption(flags ?? "-h, --help", description ?? "display help for command");
|
|
2015
|
+
if (flags || description)
|
|
2016
|
+
this._initOptionGroup(this._helpOption);
|
|
2017
|
+
return this;
|
|
2018
|
+
}
|
|
2019
|
+
_getHelpOption() {
|
|
2020
|
+
if (this._helpOption === undefined) {
|
|
2021
|
+
this.helpOption(undefined, undefined);
|
|
2022
|
+
}
|
|
2023
|
+
return this._helpOption;
|
|
2024
|
+
}
|
|
2025
|
+
addHelpOption(option) {
|
|
2026
|
+
this._helpOption = option;
|
|
2027
|
+
this._initOptionGroup(option);
|
|
2028
|
+
return this;
|
|
2029
|
+
}
|
|
2030
|
+
help(contextOptions) {
|
|
2031
|
+
this.outputHelp(contextOptions);
|
|
2032
|
+
let exitCode = Number(process2.exitCode ?? 0);
|
|
2033
|
+
if (exitCode === 0 && contextOptions && typeof contextOptions !== "function" && contextOptions.error) {
|
|
2034
|
+
exitCode = 1;
|
|
2035
|
+
}
|
|
2036
|
+
this._exit(exitCode, "commander.help", "(outputHelp)");
|
|
2037
|
+
}
|
|
2038
|
+
addHelpText(position, text) {
|
|
2039
|
+
const allowedValues = ["beforeAll", "before", "after", "afterAll"];
|
|
2040
|
+
if (!allowedValues.includes(position)) {
|
|
2041
|
+
throw new Error(`Unexpected value for position to addHelpText.
|
|
2042
|
+
Expecting one of '${allowedValues.join("', '")}'`);
|
|
2043
|
+
}
|
|
2044
|
+
const helpEvent = `${position}Help`;
|
|
2045
|
+
this.on(helpEvent, (context) => {
|
|
2046
|
+
let helpStr;
|
|
2047
|
+
if (typeof text === "function") {
|
|
2048
|
+
helpStr = text({ error: context.error, command: context.command });
|
|
2049
|
+
} else {
|
|
2050
|
+
helpStr = text;
|
|
2051
|
+
}
|
|
2052
|
+
if (helpStr) {
|
|
2053
|
+
context.write(`${helpStr}
|
|
2054
|
+
`);
|
|
2055
|
+
}
|
|
2056
|
+
});
|
|
2057
|
+
return this;
|
|
2058
|
+
}
|
|
2059
|
+
_outputHelpIfRequested(args) {
|
|
2060
|
+
const helpOption = this._getHelpOption();
|
|
2061
|
+
const helpRequested = helpOption && args.find((arg) => helpOption.is(arg));
|
|
2062
|
+
if (helpRequested) {
|
|
2063
|
+
this.outputHelp();
|
|
2064
|
+
this._exit(0, "commander.helpDisplayed", "(outputHelp)");
|
|
2065
|
+
}
|
|
2066
|
+
}
|
|
2067
|
+
}
|
|
2068
|
+
function incrementNodeInspectorPort(args) {
|
|
2069
|
+
return args.map((arg) => {
|
|
2070
|
+
if (!arg.startsWith("--inspect")) {
|
|
2071
|
+
return arg;
|
|
2072
|
+
}
|
|
2073
|
+
let debugOption;
|
|
2074
|
+
let debugHost = "127.0.0.1";
|
|
2075
|
+
let debugPort = "9229";
|
|
2076
|
+
let match;
|
|
2077
|
+
if ((match = arg.match(/^(--inspect(-brk)?)$/)) !== null) {
|
|
2078
|
+
debugOption = match[1];
|
|
2079
|
+
} else if ((match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+)$/)) !== null) {
|
|
2080
|
+
debugOption = match[1];
|
|
2081
|
+
if (/^\d+$/.test(match[3])) {
|
|
2082
|
+
debugPort = match[3];
|
|
2083
|
+
} else {
|
|
2084
|
+
debugHost = match[3];
|
|
2085
|
+
}
|
|
2086
|
+
} else if ((match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/)) !== null) {
|
|
2087
|
+
debugOption = match[1];
|
|
2088
|
+
debugHost = match[3];
|
|
2089
|
+
debugPort = match[4];
|
|
2090
|
+
}
|
|
2091
|
+
if (debugOption && debugPort !== "0") {
|
|
2092
|
+
return `${debugOption}=${debugHost}:${parseInt(debugPort) + 1}`;
|
|
2093
|
+
}
|
|
2094
|
+
return arg;
|
|
2095
|
+
});
|
|
2096
|
+
}
|
|
2097
|
+
function useColor() {
|
|
2098
|
+
if (process2.env.NO_COLOR || process2.env.FORCE_COLOR === "0" || process2.env.FORCE_COLOR === "false")
|
|
2099
|
+
return false;
|
|
2100
|
+
if (process2.env.FORCE_COLOR || process2.env.CLICOLOR_FORCE !== undefined)
|
|
2101
|
+
return true;
|
|
2102
|
+
return;
|
|
2103
|
+
}
|
|
2104
|
+
exports.Command = Command;
|
|
2105
|
+
exports.useColor = useColor;
|
|
2106
|
+
});
|
|
2107
|
+
|
|
2108
|
+
// ../../node_modules/commander/index.js
|
|
2109
|
+
var require_commander = __commonJS((exports) => {
|
|
2110
|
+
var { Argument } = require_argument();
|
|
2111
|
+
var { Command } = require_command();
|
|
2112
|
+
var { CommanderError, InvalidArgumentError } = require_error();
|
|
2113
|
+
var { Help } = require_help();
|
|
2114
|
+
var { Option } = require_option();
|
|
2115
|
+
exports.program = new Command;
|
|
2116
|
+
exports.createCommand = (name) => new Command(name);
|
|
2117
|
+
exports.createOption = (flags, description) => new Option(flags, description);
|
|
2118
|
+
exports.createArgument = (name, description) => new Argument(name, description);
|
|
2119
|
+
exports.Command = Command;
|
|
2120
|
+
exports.Option = Option;
|
|
2121
|
+
exports.Argument = Argument;
|
|
2122
|
+
exports.Help = Help;
|
|
2123
|
+
exports.CommanderError = CommanderError;
|
|
2124
|
+
exports.InvalidArgumentError = InvalidArgumentError;
|
|
2125
|
+
exports.InvalidOptionArgumentError = InvalidArgumentError;
|
|
2126
|
+
});
|
|
2127
|
+
|
|
4
2128
|
// src/catch-error.ts
|
|
5
2129
|
function catchError(fnOrPromise) {
|
|
6
2130
|
if (fnOrPromise instanceof Promise) {
|
|
@@ -25,8 +2149,21 @@ function catchError(fnOrPromise) {
|
|
|
25
2149
|
];
|
|
26
2150
|
}
|
|
27
2151
|
}
|
|
28
|
-
//
|
|
29
|
-
|
|
2152
|
+
// ../../node_modules/commander/esm.mjs
|
|
2153
|
+
var import__ = __toESM(require_commander(), 1);
|
|
2154
|
+
var {
|
|
2155
|
+
program,
|
|
2156
|
+
createCommand,
|
|
2157
|
+
createArgument,
|
|
2158
|
+
createOption,
|
|
2159
|
+
CommanderError,
|
|
2160
|
+
InvalidArgumentError,
|
|
2161
|
+
InvalidOptionArgumentError,
|
|
2162
|
+
Command,
|
|
2163
|
+
Argument,
|
|
2164
|
+
Option,
|
|
2165
|
+
Help
|
|
2166
|
+
} = import__.default;
|
|
30
2167
|
|
|
31
2168
|
// src/command-walker.ts
|
|
32
2169
|
function collectCommands(command, parentName, result) {
|
|
@@ -4655,6 +6792,36 @@ var safeDump = renamed("safeDump", "dump");
|
|
|
4655
6792
|
import { appendFileSync, mkdirSync, writeFileSync } from "node:fs";
|
|
4656
6793
|
import { dirname } from "node:path";
|
|
4657
6794
|
|
|
6795
|
+
// src/singleton.ts
|
|
6796
|
+
var PREFIX = "@uipath/common/";
|
|
6797
|
+
var _g = globalThis;
|
|
6798
|
+
function singleton(ctorOrName) {
|
|
6799
|
+
const name = typeof ctorOrName === "string" ? ctorOrName : ctorOrName.name;
|
|
6800
|
+
const key = Symbol.for(PREFIX + name);
|
|
6801
|
+
return {
|
|
6802
|
+
get(fallback) {
|
|
6803
|
+
return _g[key] ?? fallback;
|
|
6804
|
+
},
|
|
6805
|
+
set(value) {
|
|
6806
|
+
_g[key] = value;
|
|
6807
|
+
},
|
|
6808
|
+
clear() {
|
|
6809
|
+
delete _g[key];
|
|
6810
|
+
},
|
|
6811
|
+
getOrInit(factory, guard) {
|
|
6812
|
+
const existing = _g[key];
|
|
6813
|
+
if (existing != null && typeof existing === "object") {
|
|
6814
|
+
if (!guard || guard(existing)) {
|
|
6815
|
+
return existing;
|
|
6816
|
+
}
|
|
6817
|
+
}
|
|
6818
|
+
const instance = factory();
|
|
6819
|
+
_g[key] = instance;
|
|
6820
|
+
return instance;
|
|
6821
|
+
}
|
|
6822
|
+
};
|
|
6823
|
+
}
|
|
6824
|
+
|
|
4658
6825
|
// src/output-context.ts
|
|
4659
6826
|
function createStorage() {
|
|
4660
6827
|
const [error, mod2] = catchError(() => __require("node:async_hooks"));
|
|
@@ -4668,8 +6835,9 @@ function createStorage() {
|
|
|
4668
6835
|
}
|
|
4669
6836
|
return new mod2.AsyncLocalStorage;
|
|
4670
6837
|
}
|
|
4671
|
-
var
|
|
4672
|
-
var
|
|
6838
|
+
var storageSingleton = singleton("OutputStorage");
|
|
6839
|
+
var sinkSlot = singleton("OutputSink");
|
|
6840
|
+
var outputStorage = storageSingleton.getOrInit(createStorage, (v) => ("getStore" in v));
|
|
4673
6841
|
var CONSOLE_FALLBACK = {
|
|
4674
6842
|
writeOut: (str2) => process.stdout.write(str2),
|
|
4675
6843
|
writeErr: (str2) => process.stderr.write(str2),
|
|
@@ -4684,19 +6852,19 @@ function runWithSink(sink, fn) {
|
|
|
4684
6852
|
return outputStorage.run(sink, fn);
|
|
4685
6853
|
}
|
|
4686
6854
|
function getOutputSink() {
|
|
4687
|
-
return outputStorage.getStore() ??
|
|
6855
|
+
return outputStorage.getStore() ?? sinkSlot.get() ?? CONSOLE_FALLBACK;
|
|
4688
6856
|
}
|
|
4689
6857
|
function setGlobalSink(sink) {
|
|
4690
|
-
|
|
6858
|
+
sinkSlot.set(sink);
|
|
4691
6859
|
}
|
|
4692
6860
|
|
|
4693
6861
|
// src/logger.ts
|
|
4694
|
-
var
|
|
6862
|
+
var logFilePathSlot = singleton("logFilePath");
|
|
4695
6863
|
function setGlobalLogFilePath(path) {
|
|
4696
|
-
|
|
6864
|
+
logFilePathSlot.set(path);
|
|
4697
6865
|
}
|
|
4698
6866
|
function getGlobalLogFilePath() {
|
|
4699
|
-
return
|
|
6867
|
+
return logFilePathSlot.get("");
|
|
4700
6868
|
}
|
|
4701
6869
|
var LogLevel;
|
|
4702
6870
|
((LogLevel2) => {
|
|
@@ -4708,7 +6876,7 @@ var LogLevel;
|
|
|
4708
6876
|
var DEFAULT_LOG_LEVEL = 3 /* ERROR */;
|
|
4709
6877
|
|
|
4710
6878
|
class SimpleLogger {
|
|
4711
|
-
|
|
6879
|
+
__brand = "SimpleLogger";
|
|
4712
6880
|
level;
|
|
4713
6881
|
logFilePath;
|
|
4714
6882
|
fileLoggingEnabled;
|
|
@@ -4718,13 +6886,10 @@ class SimpleLogger {
|
|
|
4718
6886
|
this.fileLoggingEnabled = false;
|
|
4719
6887
|
}
|
|
4720
6888
|
static getInstance() {
|
|
4721
|
-
|
|
4722
|
-
SimpleLogger.instance = new SimpleLogger;
|
|
4723
|
-
}
|
|
4724
|
-
return SimpleLogger.instance;
|
|
6889
|
+
return loggerSingleton.getOrInit(() => new SimpleLogger, (v) => ("__brand" in v) && v.__brand === "SimpleLogger");
|
|
4725
6890
|
}
|
|
4726
6891
|
static resetInstance() {
|
|
4727
|
-
|
|
6892
|
+
loggerSingleton.clear();
|
|
4728
6893
|
}
|
|
4729
6894
|
static isNode = typeof process !== "undefined" && !!process.versions?.node;
|
|
4730
6895
|
static resolveLevel() {
|
|
@@ -4868,7 +7033,11 @@ class SimpleLogger {
|
|
|
4868
7033
|
}
|
|
4869
7034
|
};
|
|
4870
7035
|
}
|
|
7036
|
+
var loggerSingleton = singleton(SimpleLogger);
|
|
4871
7037
|
var logger = SimpleLogger.getInstance();
|
|
7038
|
+
function resetLoggerInstance() {
|
|
7039
|
+
SimpleLogger.resetInstance();
|
|
7040
|
+
}
|
|
4872
7041
|
function getLogFilePath() {
|
|
4873
7042
|
return logger.getLogFilePath();
|
|
4874
7043
|
}
|
|
@@ -4888,24 +7057,120 @@ function configureLogger(config) {
|
|
|
4888
7057
|
}
|
|
4889
7058
|
|
|
4890
7059
|
// src/output-format-context.ts
|
|
4891
|
-
var
|
|
4892
|
-
var
|
|
7060
|
+
var formatSlot = singleton("OutputFormat");
|
|
7061
|
+
var filterSlot = singleton("OutputFilter");
|
|
4893
7062
|
function setOutputFormat(format) {
|
|
4894
|
-
|
|
7063
|
+
formatSlot.set(format);
|
|
4895
7064
|
}
|
|
4896
7065
|
function getOutputFormat() {
|
|
4897
|
-
return
|
|
7066
|
+
return formatSlot.get("table");
|
|
4898
7067
|
}
|
|
4899
7068
|
function setOutputFilter(filter) {
|
|
4900
|
-
|
|
7069
|
+
filterSlot.set(filter);
|
|
4901
7070
|
}
|
|
4902
7071
|
function getOutputFilter() {
|
|
4903
|
-
return
|
|
7072
|
+
return filterSlot.get();
|
|
4904
7073
|
}
|
|
7074
|
+
// ../telemetry/src/contextstorage/adapters/node-context-storage.ts
|
|
7075
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
4905
7076
|
|
|
4906
|
-
|
|
4907
|
-
|
|
4908
|
-
|
|
7077
|
+
class NodeContextStorage {
|
|
7078
|
+
storage = new AsyncLocalStorage;
|
|
7079
|
+
run(context, fn) {
|
|
7080
|
+
return this.storage.run(context, fn);
|
|
7081
|
+
}
|
|
7082
|
+
getContext() {
|
|
7083
|
+
return this.storage.getStore();
|
|
7084
|
+
}
|
|
7085
|
+
}
|
|
7086
|
+
// ../telemetry/src/telemetry-service.ts
|
|
7087
|
+
class TelemetryService {
|
|
7088
|
+
telemetryProvider;
|
|
7089
|
+
contextStorage;
|
|
7090
|
+
operationId;
|
|
7091
|
+
defaultProperties;
|
|
7092
|
+
constructor(telemetryProvider, contextStorage) {
|
|
7093
|
+
this.telemetryProvider = telemetryProvider;
|
|
7094
|
+
this.contextStorage = contextStorage;
|
|
7095
|
+
}
|
|
7096
|
+
setOperationId(operationId) {
|
|
7097
|
+
this.operationId = operationId;
|
|
7098
|
+
}
|
|
7099
|
+
setProvider(provider) {
|
|
7100
|
+
this.telemetryProvider = provider;
|
|
7101
|
+
}
|
|
7102
|
+
setDefaultProperties(properties) {
|
|
7103
|
+
this.defaultProperties = properties;
|
|
7104
|
+
}
|
|
7105
|
+
trackEvent(name, properties) {
|
|
7106
|
+
const context = this.getCurrentContext();
|
|
7107
|
+
const enrichedProperties = this.enrichPropertiesWithContext(properties, context);
|
|
7108
|
+
this.telemetryProvider.trackEvent(name, enrichedProperties);
|
|
7109
|
+
}
|
|
7110
|
+
trackException(error, properties) {
|
|
7111
|
+
const context = this.getCurrentContext();
|
|
7112
|
+
const enrichedProperties = this.enrichPropertiesWithContext(properties, context);
|
|
7113
|
+
this.telemetryProvider.trackException(error, enrichedProperties);
|
|
7114
|
+
}
|
|
7115
|
+
async trackRequest(name, fn, properties) {
|
|
7116
|
+
const context = {
|
|
7117
|
+
operationId: this.operationId ?? this.generateId(),
|
|
7118
|
+
id: this.generateId()
|
|
7119
|
+
};
|
|
7120
|
+
const startTime = performance.now();
|
|
7121
|
+
try {
|
|
7122
|
+
const result = await this.contextStorage.run(context, fn);
|
|
7123
|
+
const durationMs = performance.now() - startTime;
|
|
7124
|
+
const enrichedProperties = this.enrichPropertiesWithContext(properties, context);
|
|
7125
|
+
await this.telemetryProvider.trackRequest(name, durationMs, true, enrichedProperties);
|
|
7126
|
+
return result;
|
|
7127
|
+
} catch (error) {
|
|
7128
|
+
const durationMs = performance.now() - startTime;
|
|
7129
|
+
const err = error instanceof Error ? error : new Error(String(error));
|
|
7130
|
+
const enrichedProperties = this.enrichPropertiesWithContext({ ...properties, errorMessage: err.message }, context);
|
|
7131
|
+
await this.telemetryProvider.trackRequest(name, durationMs, false, enrichedProperties);
|
|
7132
|
+
throw error;
|
|
7133
|
+
}
|
|
7134
|
+
}
|
|
7135
|
+
async trackDependencyOperation(name, type2, fn, properties) {
|
|
7136
|
+
const parentContext = this.getCurrentContext();
|
|
7137
|
+
if (!parentContext) {
|
|
7138
|
+
throw new Error("trackDependencyOperation must be called within a trackRequest block.");
|
|
7139
|
+
}
|
|
7140
|
+
const childContext = {
|
|
7141
|
+
operationId: parentContext.operationId,
|
|
7142
|
+
parentId: parentContext.id,
|
|
7143
|
+
id: this.generateId()
|
|
7144
|
+
};
|
|
7145
|
+
const startTime = performance.now();
|
|
7146
|
+
try {
|
|
7147
|
+
const result = await this.contextStorage.run(childContext, fn);
|
|
7148
|
+
const durationMs = performance.now() - startTime;
|
|
7149
|
+
const enrichedProperties = this.enrichPropertiesWithContext(properties, childContext);
|
|
7150
|
+
await this.telemetryProvider.trackDependency(name, type2, durationMs, true, enrichedProperties);
|
|
7151
|
+
return result;
|
|
7152
|
+
} catch (error) {
|
|
7153
|
+
const durationMs = performance.now() - startTime;
|
|
7154
|
+
const err = error instanceof Error ? error : new Error(String(error));
|
|
7155
|
+
const enrichedProperties = this.enrichPropertiesWithContext({ ...properties, errorMessage: err.message }, childContext);
|
|
7156
|
+
await this.telemetryProvider.trackDependency(name, type2, durationMs, false, enrichedProperties);
|
|
7157
|
+
throw error;
|
|
7158
|
+
}
|
|
7159
|
+
}
|
|
7160
|
+
getCurrentContext() {
|
|
7161
|
+
return this.contextStorage.getContext();
|
|
7162
|
+
}
|
|
7163
|
+
enrichPropertiesWithContext(properties, context) {
|
|
7164
|
+
return {
|
|
7165
|
+
...this.defaultProperties,
|
|
7166
|
+
...properties,
|
|
7167
|
+
...context
|
|
7168
|
+
};
|
|
7169
|
+
}
|
|
7170
|
+
generateId() {
|
|
7171
|
+
return crypto.randomUUID().replaceAll("-", "");
|
|
7172
|
+
}
|
|
7173
|
+
}
|
|
4909
7174
|
// src/registry.ts
|
|
4910
7175
|
import { execFileSync } from "node:child_process";
|
|
4911
7176
|
function readRegistryValue(keyPath, valueName) {
|
|
@@ -4972,17 +7237,14 @@ function formatMessage(category, name, properties) {
|
|
|
4972
7237
|
}
|
|
4973
7238
|
|
|
4974
7239
|
// src/node-appinsights-telemetry-provider.ts
|
|
4975
|
-
var
|
|
4976
|
-
var
|
|
7240
|
+
var telemetryPropsSlot = singleton("TelemetryDefaultProps");
|
|
7241
|
+
var providerSlot = singleton("TelemetryProvider");
|
|
4977
7242
|
function setGlobalTelemetryProperties(properties) {
|
|
4978
7243
|
const existing = getGlobalTelemetryProperties();
|
|
4979
|
-
|
|
4980
|
-
...existing,
|
|
4981
|
-
...properties
|
|
4982
|
-
};
|
|
7244
|
+
telemetryPropsSlot.set({ ...existing, ...properties });
|
|
4983
7245
|
}
|
|
4984
7246
|
function getGlobalTelemetryProperties() {
|
|
4985
|
-
return
|
|
7247
|
+
return telemetryPropsSlot.get();
|
|
4986
7248
|
}
|
|
4987
7249
|
async function loadApplicationInsights() {
|
|
4988
7250
|
const savedDebug = process.env.DEBUG;
|
|
@@ -5130,8 +7392,7 @@ class NodeAppInsightsTelemetryProvider {
|
|
|
5130
7392
|
}
|
|
5131
7393
|
}
|
|
5132
7394
|
async function getOrCreateProvider(connectionString) {
|
|
5133
|
-
const
|
|
5134
|
-
const existing = g[GLOBAL_PROVIDER_KEY];
|
|
7395
|
+
const existing = providerSlot.get();
|
|
5135
7396
|
if (existing && typeof existing === "object" && "flush" in existing && typeof existing.flush === "function") {
|
|
5136
7397
|
return existing;
|
|
5137
7398
|
}
|
|
@@ -5142,18 +7403,18 @@ async function getOrCreateProvider(connectionString) {
|
|
|
5142
7403
|
const provider = new NodeAppInsightsTelemetryProvider(connectionString);
|
|
5143
7404
|
const ok = await provider.initialize();
|
|
5144
7405
|
if (!ok) {
|
|
5145
|
-
|
|
7406
|
+
providerSlot.clear();
|
|
5146
7407
|
return;
|
|
5147
7408
|
}
|
|
5148
|
-
|
|
7409
|
+
providerSlot.set(provider);
|
|
5149
7410
|
return provider;
|
|
5150
7411
|
})();
|
|
5151
|
-
|
|
7412
|
+
providerSlot.set(initPromise);
|
|
5152
7413
|
return initPromise;
|
|
5153
7414
|
}
|
|
5154
7415
|
|
|
5155
7416
|
// src/telemetry.ts
|
|
5156
|
-
var
|
|
7417
|
+
var telemetryInstanceSlot = singleton("TelemetryService");
|
|
5157
7418
|
var DEFAULT_AI_CONNECTION_STRING = Buffer.from("SW5zdHJ1bWVudGF0aW9uS2V5PTliZDM3NDgyLTgxMGUtNDQyYS1hYWE2LWQzOGVmNjVjNjY3NDtJbmdlc3Rpb25FbmRwb2ludD1odHRwczovL3dlc3RldXJvcGUtNS5pbi5hcHBsaWNhdGlvbmluc2lnaHRzLmF6dXJlLmNvbS87TGl2ZUVuZHBvaW50PWh0dHBzOi8vd2VzdGV1cm9wZS5saXZlZGlhZ25vc3RpY3MubW9uaXRvci5henVyZS5jb20vO0FwcGxpY2F0aW9uSWQ9MzU2OTdlZjEtOGJkMC00ZjE5LWEyN2MtZDg3Y2NhYzY2ZDJj", "base64").toString("utf-8");
|
|
5158
7419
|
function getConnectionString() {
|
|
5159
7420
|
return process.env.UIPATH_AI_CONNECTION_STRING || DEFAULT_AI_CONNECTION_STRING;
|
|
@@ -5185,14 +7446,14 @@ async function createTelemetryProvider() {
|
|
|
5185
7446
|
return { provider, name: "NodeAppInsightsTelemetryProvider" };
|
|
5186
7447
|
}
|
|
5187
7448
|
function getGlobalTelemetryInstance() {
|
|
5188
|
-
const existing =
|
|
7449
|
+
const existing = telemetryInstanceSlot.get();
|
|
5189
7450
|
if (existing && typeof existing === "object" && "trackEvent" in existing && typeof existing.trackEvent === "function") {
|
|
5190
7451
|
return existing;
|
|
5191
7452
|
}
|
|
5192
7453
|
return;
|
|
5193
7454
|
}
|
|
5194
7455
|
function setGlobalTelemetryInstance(instance) {
|
|
5195
|
-
|
|
7456
|
+
telemetryInstanceSlot.set(instance);
|
|
5196
7457
|
}
|
|
5197
7458
|
var _localTelemetryInstance;
|
|
5198
7459
|
function getTelemetryInstance() {
|
|
@@ -5639,10 +7900,10 @@ function formatArgs(args) {
|
|
|
5639
7900
|
return `${format(args[0], ...args.slice(1))}
|
|
5640
7901
|
`;
|
|
5641
7902
|
}
|
|
5642
|
-
var
|
|
5643
|
-
var
|
|
7903
|
+
var guardInstalledSlot = singleton("ConsoleGuardInstalled");
|
|
7904
|
+
var savedOriginalsSlot = singleton("ConsoleGuardOriginals");
|
|
5644
7905
|
function installConsoleGuard() {
|
|
5645
|
-
if (
|
|
7906
|
+
if (guardInstalledSlot.get(false))
|
|
5646
7907
|
return;
|
|
5647
7908
|
const originals = {
|
|
5648
7909
|
log: console.log,
|
|
@@ -5651,7 +7912,7 @@ function installConsoleGuard() {
|
|
|
5651
7912
|
error: console.error,
|
|
5652
7913
|
debug: console.debug
|
|
5653
7914
|
};
|
|
5654
|
-
|
|
7915
|
+
savedOriginalsSlot.set(originals);
|
|
5655
7916
|
let reentrant = false;
|
|
5656
7917
|
function guardedWriter(original) {
|
|
5657
7918
|
return (...args) => {
|
|
@@ -5672,17 +7933,18 @@ function installConsoleGuard() {
|
|
|
5672
7933
|
console.warn = guardedWriter(originals.warn);
|
|
5673
7934
|
console.error = guardedWriter(originals.error);
|
|
5674
7935
|
console.debug = guardedWriter(originals.debug);
|
|
5675
|
-
|
|
7936
|
+
guardInstalledSlot.set(true);
|
|
5676
7937
|
}
|
|
5677
7938
|
function restoreConsole() {
|
|
5678
|
-
|
|
7939
|
+
const originals = savedOriginalsSlot.get();
|
|
7940
|
+
if (!originals)
|
|
5679
7941
|
return;
|
|
5680
|
-
console.log =
|
|
5681
|
-
console.info =
|
|
5682
|
-
console.warn =
|
|
5683
|
-
console.error =
|
|
5684
|
-
console.debug =
|
|
5685
|
-
|
|
7942
|
+
console.log = originals.log;
|
|
7943
|
+
console.info = originals.info;
|
|
7944
|
+
console.warn = originals.warn;
|
|
7945
|
+
console.error = originals.error;
|
|
7946
|
+
console.debug = originals.debug;
|
|
7947
|
+
guardInstalledSlot.clear();
|
|
5686
7948
|
}
|
|
5687
7949
|
// src/constants.ts
|
|
5688
7950
|
var UIPATH_HOME_DIR = ".uipath";
|
|
@@ -5694,6 +7956,20 @@ var DEFAULT_PAGE_SIZE = 50;
|
|
|
5694
7956
|
var DEFAULT_AUTH_TIMEOUT_MS = 5 * 60 * 1000;
|
|
5695
7957
|
var DEFAULT_FETCH_TIMEOUT_MS = 30000;
|
|
5696
7958
|
var DEFAULT_REDIRECT_URI = "http://localhost:8104/oidc/login";
|
|
7959
|
+
// src/env-reference.ts
|
|
7960
|
+
function resolveEnvReference(value) {
|
|
7961
|
+
if (value == null)
|
|
7962
|
+
return value;
|
|
7963
|
+
if (value.startsWith("env.")) {
|
|
7964
|
+
const name = value.slice(4);
|
|
7965
|
+
const resolved = process.env[name];
|
|
7966
|
+
if (!resolved) {
|
|
7967
|
+
throw new Error(`Environment variable "${name}" is not set`);
|
|
7968
|
+
}
|
|
7969
|
+
return resolved;
|
|
7970
|
+
}
|
|
7971
|
+
return value;
|
|
7972
|
+
}
|
|
5697
7973
|
// src/error-handler.ts
|
|
5698
7974
|
var DEFAULT_401 = "Unauthorized (401). Run `uip login` to authenticate.";
|
|
5699
7975
|
var DEFAULT_403 = "Forbidden (403). Ensure the account has the required permissions.";
|
|
@@ -7702,30 +9978,29 @@ var ScreenLogger;
|
|
|
7702
9978
|
ScreenLogger.progress = progress;
|
|
7703
9979
|
})(ScreenLogger ||= {});
|
|
7704
9980
|
// src/tool-provider.ts
|
|
7705
|
-
var
|
|
7706
|
-
var _global = globalThis;
|
|
9981
|
+
var factorySlot = singleton("PackagerFactoryProvider");
|
|
7707
9982
|
function setPackagerFactoryProvider(provider) {
|
|
7708
|
-
|
|
9983
|
+
factorySlot.set(provider);
|
|
7709
9984
|
}
|
|
7710
9985
|
async function ensurePackagerFactory(verb) {
|
|
7711
|
-
|
|
9986
|
+
const provider = factorySlot.get();
|
|
9987
|
+
if (!provider) {
|
|
7712
9988
|
throw new Error(`Packager factory for '${verb}' is required but no factory provider is registered. ` + `Run 'uip tools install ${verb}' manually.`);
|
|
7713
9989
|
}
|
|
7714
|
-
await
|
|
9990
|
+
await provider(verb);
|
|
7715
9991
|
}
|
|
7716
9992
|
// src/trackedAction.ts
|
|
7717
|
-
|
|
7718
|
-
var POLL_SIGNAL_KEY = Symbol.for("@uipath/common/poll-signal");
|
|
9993
|
+
var pollSignalSlot = singleton("PollSignal");
|
|
7719
9994
|
var processContext = {
|
|
7720
9995
|
exit: (code) => {
|
|
7721
9996
|
process.exitCode = code;
|
|
7722
9997
|
},
|
|
7723
9998
|
get pollSignal() {
|
|
7724
|
-
return
|
|
9999
|
+
return pollSignalSlot.get();
|
|
7725
10000
|
}
|
|
7726
10001
|
};
|
|
7727
10002
|
function setProcessContextPollSignal(signal) {
|
|
7728
|
-
|
|
10003
|
+
pollSignalSlot.set(signal);
|
|
7729
10004
|
}
|
|
7730
10005
|
function deriveCommandPath(cmd) {
|
|
7731
10006
|
const parts = [];
|
|
@@ -7742,17 +10017,8 @@ function deriveCommandPath(cmd) {
|
|
|
7742
10017
|
}
|
|
7743
10018
|
return ["uip", ...parts.filter((p) => p !== "uip")].join(".");
|
|
7744
10019
|
}
|
|
7745
|
-
Command.prototype.trackedAction = function(context,
|
|
10020
|
+
Command.prototype.trackedAction = function(context, fn, properties) {
|
|
7746
10021
|
const command = this;
|
|
7747
|
-
let fn;
|
|
7748
|
-
let properties;
|
|
7749
|
-
if (typeof fnOrName === "string") {
|
|
7750
|
-
fn = fnOrProps;
|
|
7751
|
-
properties = legacyProperties;
|
|
7752
|
-
} else {
|
|
7753
|
-
fn = fnOrName;
|
|
7754
|
-
properties = fnOrProps;
|
|
7755
|
-
}
|
|
7756
10022
|
return this.action(async (...args) => {
|
|
7757
10023
|
const telemetryName = deriveCommandPath(command);
|
|
7758
10024
|
const props = typeof properties === "function" ? properties(...args) : properties;
|
|
@@ -7792,6 +10058,8 @@ export {
|
|
|
7792
10058
|
setGlobalLogFilePath,
|
|
7793
10059
|
runWithSink,
|
|
7794
10060
|
restoreConsole,
|
|
10061
|
+
resolveEnvReference,
|
|
10062
|
+
resetLoggerInstance,
|
|
7795
10063
|
registerHelpAll,
|
|
7796
10064
|
readRegistryValue,
|
|
7797
10065
|
processContext,
|