@uipath/function-tool 1.202.0 → 1.202.1-preview.162

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/tool.js CHANGED
@@ -1,14 +1,2109 @@
1
1
  import {
2
2
  cliRunner
3
- } from "./packager-tool-3hvc4zcd.js";
3
+ } from "./packager-tool-sdc3wrcd.js";
4
4
  import {
5
- __require
6
- } from "./packager-tool-1bx83sw4.js";
5
+ __commonJS,
6
+ __require,
7
+ __toESM
8
+ } from "./packager-tool-1de529jm.js";
9
+
10
+ // ../../node_modules/commander/lib/error.js
11
+ var require_error3 = __commonJS(function(exports) {
12
+ class CommanderError3 extends Error {
13
+ constructor(exitCode, code, message) {
14
+ super(message);
15
+ Error.captureStackTrace(this, this.constructor);
16
+ this.name = this.constructor.name;
17
+ this.code = code;
18
+ this.exitCode = exitCode;
19
+ this.nestedError = undefined;
20
+ }
21
+ }
22
+
23
+ class InvalidArgumentError3 extends CommanderError3 {
24
+ constructor(message) {
25
+ super(1, "commander.invalidArgument", message);
26
+ Error.captureStackTrace(this, this.constructor);
27
+ this.name = this.constructor.name;
28
+ }
29
+ }
30
+ exports.CommanderError = CommanderError3;
31
+ exports.InvalidArgumentError = InvalidArgumentError3;
32
+ });
33
+
34
+ // ../../node_modules/commander/lib/argument.js
35
+ var require_argument3 = __commonJS(function(exports) {
36
+ var { InvalidArgumentError: InvalidArgumentError3 } = require_error3();
37
+
38
+ class Argument3 {
39
+ constructor(name, description) {
40
+ this.description = description || "";
41
+ this.variadic = false;
42
+ this.parseArg = undefined;
43
+ this.defaultValue = undefined;
44
+ this.defaultValueDescription = undefined;
45
+ this.argChoices = undefined;
46
+ switch (name[0]) {
47
+ case "<":
48
+ this.required = true;
49
+ this._name = name.slice(1, -1);
50
+ break;
51
+ case "[":
52
+ this.required = false;
53
+ this._name = name.slice(1, -1);
54
+ break;
55
+ default:
56
+ this.required = true;
57
+ this._name = name;
58
+ break;
59
+ }
60
+ if (this._name.endsWith("...")) {
61
+ this.variadic = true;
62
+ this._name = this._name.slice(0, -3);
63
+ }
64
+ }
65
+ name() {
66
+ return this._name;
67
+ }
68
+ _collectValue(value, previous) {
69
+ if (previous === this.defaultValue || !Array.isArray(previous)) {
70
+ return [value];
71
+ }
72
+ previous.push(value);
73
+ return previous;
74
+ }
75
+ default(value, description) {
76
+ this.defaultValue = value;
77
+ this.defaultValueDescription = description;
78
+ return this;
79
+ }
80
+ argParser(fn) {
81
+ this.parseArg = fn;
82
+ return this;
83
+ }
84
+ choices(values) {
85
+ this.argChoices = values.slice();
86
+ this.parseArg = (arg, previous) => {
87
+ if (!this.argChoices.includes(arg)) {
88
+ throw new InvalidArgumentError3(`Allowed choices are ${this.argChoices.join(", ")}.`);
89
+ }
90
+ if (this.variadic) {
91
+ return this._collectValue(arg, previous);
92
+ }
93
+ return arg;
94
+ };
95
+ return this;
96
+ }
97
+ argRequired() {
98
+ this.required = true;
99
+ return this;
100
+ }
101
+ argOptional() {
102
+ this.required = false;
103
+ return this;
104
+ }
105
+ }
106
+ function humanReadableArgName(arg) {
107
+ const nameOutput = arg.name() + (arg.variadic === true ? "..." : "");
108
+ return arg.required ? "<" + nameOutput + ">" : "[" + nameOutput + "]";
109
+ }
110
+ exports.Argument = Argument3;
111
+ exports.humanReadableArgName = humanReadableArgName;
112
+ });
113
+
114
+ // ../../node_modules/commander/lib/help.js
115
+ var require_help3 = __commonJS(function(exports) {
116
+ var { humanReadableArgName } = require_argument3();
117
+
118
+ class Help3 {
119
+ constructor() {
120
+ this.helpWidth = undefined;
121
+ this.minWidthToWrap = 40;
122
+ this.sortSubcommands = false;
123
+ this.sortOptions = false;
124
+ this.showGlobalOptions = false;
125
+ }
126
+ prepareContext(contextOptions) {
127
+ this.helpWidth = this.helpWidth ?? contextOptions.helpWidth ?? 80;
128
+ }
129
+ visibleCommands(cmd) {
130
+ const visibleCommands = cmd.commands.filter((cmd2) => !cmd2._hidden);
131
+ const helpCommand = cmd._getHelpCommand();
132
+ if (helpCommand && !helpCommand._hidden) {
133
+ visibleCommands.push(helpCommand);
134
+ }
135
+ if (this.sortSubcommands) {
136
+ visibleCommands.sort((a, b) => {
137
+ return a.name().localeCompare(b.name());
138
+ });
139
+ }
140
+ return visibleCommands;
141
+ }
142
+ compareOptions(a, b) {
143
+ const getSortKey = (option) => {
144
+ return option.short ? option.short.replace(/^-/, "") : option.long.replace(/^--/, "");
145
+ };
146
+ return getSortKey(a).localeCompare(getSortKey(b));
147
+ }
148
+ visibleOptions(cmd) {
149
+ const visibleOptions = cmd.options.filter((option) => !option.hidden);
150
+ const helpOption = cmd._getHelpOption();
151
+ if (helpOption && !helpOption.hidden) {
152
+ const removeShort = helpOption.short && cmd._findOption(helpOption.short);
153
+ const removeLong = helpOption.long && cmd._findOption(helpOption.long);
154
+ if (!removeShort && !removeLong) {
155
+ visibleOptions.push(helpOption);
156
+ } else if (helpOption.long && !removeLong) {
157
+ visibleOptions.push(cmd.createOption(helpOption.long, helpOption.description));
158
+ } else if (helpOption.short && !removeShort) {
159
+ visibleOptions.push(cmd.createOption(helpOption.short, helpOption.description));
160
+ }
161
+ }
162
+ if (this.sortOptions) {
163
+ visibleOptions.sort(this.compareOptions);
164
+ }
165
+ return visibleOptions;
166
+ }
167
+ visibleGlobalOptions(cmd) {
168
+ if (!this.showGlobalOptions)
169
+ return [];
170
+ const globalOptions = [];
171
+ for (let ancestorCmd = cmd.parent;ancestorCmd; ancestorCmd = ancestorCmd.parent) {
172
+ const visibleOptions = ancestorCmd.options.filter((option) => !option.hidden);
173
+ globalOptions.push(...visibleOptions);
174
+ }
175
+ if (this.sortOptions) {
176
+ globalOptions.sort(this.compareOptions);
177
+ }
178
+ return globalOptions;
179
+ }
180
+ visibleArguments(cmd) {
181
+ if (cmd._argsDescription) {
182
+ cmd.registeredArguments.forEach((argument) => {
183
+ argument.description = argument.description || cmd._argsDescription[argument.name()] || "";
184
+ });
185
+ }
186
+ if (cmd.registeredArguments.find((argument) => argument.description)) {
187
+ return cmd.registeredArguments;
188
+ }
189
+ return [];
190
+ }
191
+ subcommandTerm(cmd) {
192
+ const args = cmd.registeredArguments.map((arg) => humanReadableArgName(arg)).join(" ");
193
+ return cmd._name + (cmd._aliases[0] ? "|" + cmd._aliases[0] : "") + (cmd.options.length ? " [options]" : "") + (args ? " " + args : "");
194
+ }
195
+ optionTerm(option) {
196
+ return option.flags;
197
+ }
198
+ argumentTerm(argument) {
199
+ return argument.name();
200
+ }
201
+ longestSubcommandTermLength(cmd, helper) {
202
+ return helper.visibleCommands(cmd).reduce((max, command) => {
203
+ return Math.max(max, this.displayWidth(helper.styleSubcommandTerm(helper.subcommandTerm(command))));
204
+ }, 0);
205
+ }
206
+ longestOptionTermLength(cmd, helper) {
207
+ return helper.visibleOptions(cmd).reduce((max, option) => {
208
+ return Math.max(max, this.displayWidth(helper.styleOptionTerm(helper.optionTerm(option))));
209
+ }, 0);
210
+ }
211
+ longestGlobalOptionTermLength(cmd, helper) {
212
+ return helper.visibleGlobalOptions(cmd).reduce((max, option) => {
213
+ return Math.max(max, this.displayWidth(helper.styleOptionTerm(helper.optionTerm(option))));
214
+ }, 0);
215
+ }
216
+ longestArgumentTermLength(cmd, helper) {
217
+ return helper.visibleArguments(cmd).reduce((max, argument) => {
218
+ return Math.max(max, this.displayWidth(helper.styleArgumentTerm(helper.argumentTerm(argument))));
219
+ }, 0);
220
+ }
221
+ commandUsage(cmd) {
222
+ let cmdName = cmd._name;
223
+ if (cmd._aliases[0]) {
224
+ cmdName = cmdName + "|" + cmd._aliases[0];
225
+ }
226
+ let ancestorCmdNames = "";
227
+ for (let ancestorCmd = cmd.parent;ancestorCmd; ancestorCmd = ancestorCmd.parent) {
228
+ ancestorCmdNames = ancestorCmd.name() + " " + ancestorCmdNames;
229
+ }
230
+ return ancestorCmdNames + cmdName + " " + cmd.usage();
231
+ }
232
+ commandDescription(cmd) {
233
+ return cmd.description();
234
+ }
235
+ subcommandDescription(cmd) {
236
+ return cmd.summary() || cmd.description();
237
+ }
238
+ optionDescription(option) {
239
+ const extraInfo = [];
240
+ if (option.argChoices) {
241
+ extraInfo.push(`choices: ${option.argChoices.map((choice) => JSON.stringify(choice)).join(", ")}`);
242
+ }
243
+ if (option.defaultValue !== undefined) {
244
+ const showDefault = option.required || option.optional || option.isBoolean() && typeof option.defaultValue === "boolean";
245
+ if (showDefault) {
246
+ extraInfo.push(`default: ${option.defaultValueDescription || JSON.stringify(option.defaultValue)}`);
247
+ }
248
+ }
249
+ if (option.presetArg !== undefined && option.optional) {
250
+ extraInfo.push(`preset: ${JSON.stringify(option.presetArg)}`);
251
+ }
252
+ if (option.envVar !== undefined) {
253
+ extraInfo.push(`env: ${option.envVar}`);
254
+ }
255
+ if (extraInfo.length > 0) {
256
+ const extraDescription = `(${extraInfo.join(", ")})`;
257
+ if (option.description) {
258
+ return `${option.description} ${extraDescription}`;
259
+ }
260
+ return extraDescription;
261
+ }
262
+ return option.description;
263
+ }
264
+ argumentDescription(argument) {
265
+ const extraInfo = [];
266
+ if (argument.argChoices) {
267
+ extraInfo.push(`choices: ${argument.argChoices.map((choice) => JSON.stringify(choice)).join(", ")}`);
268
+ }
269
+ if (argument.defaultValue !== undefined) {
270
+ extraInfo.push(`default: ${argument.defaultValueDescription || JSON.stringify(argument.defaultValue)}`);
271
+ }
272
+ if (extraInfo.length > 0) {
273
+ const extraDescription = `(${extraInfo.join(", ")})`;
274
+ if (argument.description) {
275
+ return `${argument.description} ${extraDescription}`;
276
+ }
277
+ return extraDescription;
278
+ }
279
+ return argument.description;
280
+ }
281
+ formatItemList(heading, items, helper) {
282
+ if (items.length === 0)
283
+ return [];
284
+ return [helper.styleTitle(heading), ...items, ""];
285
+ }
286
+ groupItems(unsortedItems, visibleItems, getGroup) {
287
+ const result = new Map;
288
+ unsortedItems.forEach((item) => {
289
+ const group = getGroup(item);
290
+ if (!result.has(group))
291
+ result.set(group, []);
292
+ });
293
+ visibleItems.forEach((item) => {
294
+ const group = getGroup(item);
295
+ if (!result.has(group)) {
296
+ result.set(group, []);
297
+ }
298
+ result.get(group).push(item);
299
+ });
300
+ return result;
301
+ }
302
+ formatHelp(cmd, helper) {
303
+ const termWidth = helper.padWidth(cmd, helper);
304
+ const helpWidth = helper.helpWidth ?? 80;
305
+ function callFormatItem(term, description) {
306
+ return helper.formatItem(term, termWidth, description, helper);
307
+ }
308
+ let output = [
309
+ `${helper.styleTitle("Usage:")} ${helper.styleUsage(helper.commandUsage(cmd))}`,
310
+ ""
311
+ ];
312
+ const commandDescription = helper.commandDescription(cmd);
313
+ if (commandDescription.length > 0) {
314
+ output = output.concat([
315
+ helper.boxWrap(helper.styleCommandDescription(commandDescription), helpWidth),
316
+ ""
317
+ ]);
318
+ }
319
+ const argumentList = helper.visibleArguments(cmd).map((argument) => {
320
+ return callFormatItem(helper.styleArgumentTerm(helper.argumentTerm(argument)), helper.styleArgumentDescription(helper.argumentDescription(argument)));
321
+ });
322
+ output = output.concat(this.formatItemList("Arguments:", argumentList, helper));
323
+ const optionGroups = this.groupItems(cmd.options, helper.visibleOptions(cmd), (option) => option.helpGroupHeading ?? "Options:");
324
+ optionGroups.forEach((options, group) => {
325
+ const optionList = options.map((option) => {
326
+ return callFormatItem(helper.styleOptionTerm(helper.optionTerm(option)), helper.styleOptionDescription(helper.optionDescription(option)));
327
+ });
328
+ output = output.concat(this.formatItemList(group, optionList, helper));
329
+ });
330
+ if (helper.showGlobalOptions) {
331
+ const globalOptionList = helper.visibleGlobalOptions(cmd).map((option) => {
332
+ return callFormatItem(helper.styleOptionTerm(helper.optionTerm(option)), helper.styleOptionDescription(helper.optionDescription(option)));
333
+ });
334
+ output = output.concat(this.formatItemList("Global Options:", globalOptionList, helper));
335
+ }
336
+ const commandGroups = this.groupItems(cmd.commands, helper.visibleCommands(cmd), (sub) => sub.helpGroup() || "Commands:");
337
+ commandGroups.forEach((commands, group) => {
338
+ const commandList = commands.map((sub) => {
339
+ return callFormatItem(helper.styleSubcommandTerm(helper.subcommandTerm(sub)), helper.styleSubcommandDescription(helper.subcommandDescription(sub)));
340
+ });
341
+ output = output.concat(this.formatItemList(group, commandList, helper));
342
+ });
343
+ return output.join(`
344
+ `);
345
+ }
346
+ displayWidth(str3) {
347
+ return stripColor(str3).length;
348
+ }
349
+ styleTitle(str3) {
350
+ return str3;
351
+ }
352
+ styleUsage(str3) {
353
+ return str3.split(" ").map((word) => {
354
+ if (word === "[options]")
355
+ return this.styleOptionText(word);
356
+ if (word === "[command]")
357
+ return this.styleSubcommandText(word);
358
+ if (word[0] === "[" || word[0] === "<")
359
+ return this.styleArgumentText(word);
360
+ return this.styleCommandText(word);
361
+ }).join(" ");
362
+ }
363
+ styleCommandDescription(str3) {
364
+ return this.styleDescriptionText(str3);
365
+ }
366
+ styleOptionDescription(str3) {
367
+ return this.styleDescriptionText(str3);
368
+ }
369
+ styleSubcommandDescription(str3) {
370
+ return this.styleDescriptionText(str3);
371
+ }
372
+ styleArgumentDescription(str3) {
373
+ return this.styleDescriptionText(str3);
374
+ }
375
+ styleDescriptionText(str3) {
376
+ return str3;
377
+ }
378
+ styleOptionTerm(str3) {
379
+ return this.styleOptionText(str3);
380
+ }
381
+ styleSubcommandTerm(str3) {
382
+ return str3.split(" ").map((word) => {
383
+ if (word === "[options]")
384
+ return this.styleOptionText(word);
385
+ if (word[0] === "[" || word[0] === "<")
386
+ return this.styleArgumentText(word);
387
+ return this.styleSubcommandText(word);
388
+ }).join(" ");
389
+ }
390
+ styleArgumentTerm(str3) {
391
+ return this.styleArgumentText(str3);
392
+ }
393
+ styleOptionText(str3) {
394
+ return str3;
395
+ }
396
+ styleArgumentText(str3) {
397
+ return str3;
398
+ }
399
+ styleSubcommandText(str3) {
400
+ return str3;
401
+ }
402
+ styleCommandText(str3) {
403
+ return str3;
404
+ }
405
+ padWidth(cmd, helper) {
406
+ return Math.max(helper.longestOptionTermLength(cmd, helper), helper.longestGlobalOptionTermLength(cmd, helper), helper.longestSubcommandTermLength(cmd, helper), helper.longestArgumentTermLength(cmd, helper));
407
+ }
408
+ preformatted(str3) {
409
+ return /\n[^\S\r\n]/.test(str3);
410
+ }
411
+ formatItem(term, termWidth, description, helper) {
412
+ const itemIndent = 2;
413
+ const itemIndentStr = " ".repeat(itemIndent);
414
+ if (!description)
415
+ return itemIndentStr + term;
416
+ const paddedTerm = term.padEnd(termWidth + term.length - helper.displayWidth(term));
417
+ const spacerWidth = 2;
418
+ const helpWidth = this.helpWidth ?? 80;
419
+ const remainingWidth = helpWidth - termWidth - spacerWidth - itemIndent;
420
+ let formattedDescription;
421
+ if (remainingWidth < this.minWidthToWrap || helper.preformatted(description)) {
422
+ formattedDescription = description;
423
+ } else {
424
+ const wrappedDescription = helper.boxWrap(description, remainingWidth);
425
+ formattedDescription = wrappedDescription.replace(/\n/g, `
426
+ ` + " ".repeat(termWidth + spacerWidth));
427
+ }
428
+ return itemIndentStr + paddedTerm + " ".repeat(spacerWidth) + formattedDescription.replace(/\n/g, `
429
+ ${itemIndentStr}`);
430
+ }
431
+ boxWrap(str3, width) {
432
+ if (width < this.minWidthToWrap)
433
+ return str3;
434
+ const rawLines = str3.split(/\r\n|\n/);
435
+ const chunkPattern = /[\s]*[^\s]+/g;
436
+ const wrappedLines = [];
437
+ rawLines.forEach((line) => {
438
+ const chunks = line.match(chunkPattern);
439
+ if (chunks === null) {
440
+ wrappedLines.push("");
441
+ return;
442
+ }
443
+ let sumChunks = [chunks.shift()];
444
+ let sumWidth = this.displayWidth(sumChunks[0]);
445
+ chunks.forEach((chunk) => {
446
+ const visibleWidth = this.displayWidth(chunk);
447
+ if (sumWidth + visibleWidth <= width) {
448
+ sumChunks.push(chunk);
449
+ sumWidth += visibleWidth;
450
+ return;
451
+ }
452
+ wrappedLines.push(sumChunks.join(""));
453
+ const nextChunk = chunk.trimStart();
454
+ sumChunks = [nextChunk];
455
+ sumWidth = this.displayWidth(nextChunk);
456
+ });
457
+ wrappedLines.push(sumChunks.join(""));
458
+ });
459
+ return wrappedLines.join(`
460
+ `);
461
+ }
462
+ }
463
+ function stripColor(str3) {
464
+ const sgrPattern = /\x1b\[\d*(;\d*)*m/g;
465
+ return str3.replace(sgrPattern, "");
466
+ }
467
+ exports.Help = Help3;
468
+ exports.stripColor = stripColor;
469
+ });
470
+
471
+ // ../../node_modules/commander/lib/option.js
472
+ var require_option3 = __commonJS(function(exports) {
473
+ var { InvalidArgumentError: InvalidArgumentError3 } = require_error3();
474
+
475
+ class Option3 {
476
+ constructor(flags, description) {
477
+ this.flags = flags;
478
+ this.description = description || "";
479
+ this.required = flags.includes("<");
480
+ this.optional = flags.includes("[");
481
+ this.variadic = /\w\.\.\.[>\]]$/.test(flags);
482
+ this.mandatory = false;
483
+ const optionFlags = splitOptionFlags(flags);
484
+ this.short = optionFlags.shortFlag;
485
+ this.long = optionFlags.longFlag;
486
+ this.negate = false;
487
+ if (this.long) {
488
+ this.negate = this.long.startsWith("--no-");
489
+ }
490
+ this.defaultValue = undefined;
491
+ this.defaultValueDescription = undefined;
492
+ this.presetArg = undefined;
493
+ this.envVar = undefined;
494
+ this.parseArg = undefined;
495
+ this.hidden = false;
496
+ this.argChoices = undefined;
497
+ this.conflictsWith = [];
498
+ this.implied = undefined;
499
+ this.helpGroupHeading = undefined;
500
+ }
501
+ default(value, description) {
502
+ this.defaultValue = value;
503
+ this.defaultValueDescription = description;
504
+ return this;
505
+ }
506
+ preset(arg) {
507
+ this.presetArg = arg;
508
+ return this;
509
+ }
510
+ conflicts(names) {
511
+ this.conflictsWith = this.conflictsWith.concat(names);
512
+ return this;
513
+ }
514
+ implies(impliedOptionValues) {
515
+ let newImplied = impliedOptionValues;
516
+ if (typeof impliedOptionValues === "string") {
517
+ newImplied = { [impliedOptionValues]: true };
518
+ }
519
+ this.implied = Object.assign(this.implied || {}, newImplied);
520
+ return this;
521
+ }
522
+ env(name) {
523
+ this.envVar = name;
524
+ return this;
525
+ }
526
+ argParser(fn) {
527
+ this.parseArg = fn;
528
+ return this;
529
+ }
530
+ makeOptionMandatory(mandatory = true) {
531
+ this.mandatory = !!mandatory;
532
+ return this;
533
+ }
534
+ hideHelp(hide = true) {
535
+ this.hidden = !!hide;
536
+ return this;
537
+ }
538
+ _collectValue(value, previous) {
539
+ if (previous === this.defaultValue || !Array.isArray(previous)) {
540
+ return [value];
541
+ }
542
+ previous.push(value);
543
+ return previous;
544
+ }
545
+ choices(values) {
546
+ this.argChoices = values.slice();
547
+ this.parseArg = (arg, previous) => {
548
+ if (!this.argChoices.includes(arg)) {
549
+ throw new InvalidArgumentError3(`Allowed choices are ${this.argChoices.join(", ")}.`);
550
+ }
551
+ if (this.variadic) {
552
+ return this._collectValue(arg, previous);
553
+ }
554
+ return arg;
555
+ };
556
+ return this;
557
+ }
558
+ name() {
559
+ if (this.long) {
560
+ return this.long.replace(/^--/, "");
561
+ }
562
+ return this.short.replace(/^-/, "");
563
+ }
564
+ attributeName() {
565
+ if (this.negate) {
566
+ return camelcase(this.name().replace(/^no-/, ""));
567
+ }
568
+ return camelcase(this.name());
569
+ }
570
+ helpGroup(heading) {
571
+ this.helpGroupHeading = heading;
572
+ return this;
573
+ }
574
+ is(arg) {
575
+ return this.short === arg || this.long === arg;
576
+ }
577
+ isBoolean() {
578
+ return !this.required && !this.optional && !this.negate;
579
+ }
580
+ }
581
+
582
+ class DualOptions {
583
+ constructor(options) {
584
+ this.positiveOptions = new Map;
585
+ this.negativeOptions = new Map;
586
+ this.dualOptions = new Set;
587
+ options.forEach((option) => {
588
+ if (option.negate) {
589
+ this.negativeOptions.set(option.attributeName(), option);
590
+ } else {
591
+ this.positiveOptions.set(option.attributeName(), option);
592
+ }
593
+ });
594
+ this.negativeOptions.forEach((value, key) => {
595
+ if (this.positiveOptions.has(key)) {
596
+ this.dualOptions.add(key);
597
+ }
598
+ });
599
+ }
600
+ valueFromOption(value, option) {
601
+ const optionKey = option.attributeName();
602
+ if (!this.dualOptions.has(optionKey))
603
+ return true;
604
+ const preset = this.negativeOptions.get(optionKey).presetArg;
605
+ const negativeValue = preset !== undefined ? preset : false;
606
+ return option.negate === (negativeValue === value);
607
+ }
608
+ }
609
+ function camelcase(str3) {
610
+ return str3.split("-").reduce((str4, word) => {
611
+ return str4 + word[0].toUpperCase() + word.slice(1);
612
+ });
613
+ }
614
+ function splitOptionFlags(flags) {
615
+ let shortFlag;
616
+ let longFlag;
617
+ const shortFlagExp = /^-[^-]$/;
618
+ const longFlagExp = /^--[^-]/;
619
+ const flagParts = flags.split(/[ |,]+/).concat("guard");
620
+ if (shortFlagExp.test(flagParts[0]))
621
+ shortFlag = flagParts.shift();
622
+ if (longFlagExp.test(flagParts[0]))
623
+ longFlag = flagParts.shift();
624
+ if (!shortFlag && shortFlagExp.test(flagParts[0]))
625
+ shortFlag = flagParts.shift();
626
+ if (!shortFlag && longFlagExp.test(flagParts[0])) {
627
+ shortFlag = longFlag;
628
+ longFlag = flagParts.shift();
629
+ }
630
+ if (flagParts[0].startsWith("-")) {
631
+ const unsupportedFlag = flagParts[0];
632
+ const baseError = `option creation failed due to '${unsupportedFlag}' in option flags '${flags}'`;
633
+ if (/^-[^-][^-]/.test(unsupportedFlag))
634
+ throw new Error(`${baseError}
635
+ - a short flag is a single dash and a single character
636
+ - either use a single dash and a single character (for a short flag)
637
+ - or use a double dash for a long option (and can have two, like '--ws, --workspace')`);
638
+ if (shortFlagExp.test(unsupportedFlag))
639
+ throw new Error(`${baseError}
640
+ - too many short flags`);
641
+ if (longFlagExp.test(unsupportedFlag))
642
+ throw new Error(`${baseError}
643
+ - too many long flags`);
644
+ throw new Error(`${baseError}
645
+ - unrecognised flag format`);
646
+ }
647
+ if (shortFlag === undefined && longFlag === undefined)
648
+ throw new Error(`option creation failed due to no flags found in '${flags}'.`);
649
+ return { shortFlag, longFlag };
650
+ }
651
+ exports.Option = Option3;
652
+ exports.DualOptions = DualOptions;
653
+ });
654
+
655
+ // ../../node_modules/commander/lib/suggestSimilar.js
656
+ var require_suggestSimilar3 = __commonJS(function(exports) {
657
+ var maxDistance = 3;
658
+ function editDistance(a, b) {
659
+ if (Math.abs(a.length - b.length) > maxDistance)
660
+ return Math.max(a.length, b.length);
661
+ const d = [];
662
+ for (let i2 = 0;i2 <= a.length; i2++) {
663
+ d[i2] = [i2];
664
+ }
665
+ for (let j = 0;j <= b.length; j++) {
666
+ d[0][j] = j;
667
+ }
668
+ for (let j = 1;j <= b.length; j++) {
669
+ for (let i2 = 1;i2 <= a.length; i2++) {
670
+ let cost = 1;
671
+ if (a[i2 - 1] === b[j - 1]) {
672
+ cost = 0;
673
+ } else {
674
+ cost = 1;
675
+ }
676
+ d[i2][j] = Math.min(d[i2 - 1][j] + 1, d[i2][j - 1] + 1, d[i2 - 1][j - 1] + cost);
677
+ if (i2 > 1 && j > 1 && a[i2 - 1] === b[j - 2] && a[i2 - 2] === b[j - 1]) {
678
+ d[i2][j] = Math.min(d[i2][j], d[i2 - 2][j - 2] + 1);
679
+ }
680
+ }
681
+ }
682
+ return d[a.length][b.length];
683
+ }
684
+ function suggestSimilar(word, candidates) {
685
+ if (!candidates || candidates.length === 0)
686
+ return "";
687
+ candidates = Array.from(new Set(candidates));
688
+ const searchingOptions = word.startsWith("--");
689
+ if (searchingOptions) {
690
+ word = word.slice(2);
691
+ candidates = candidates.map((candidate) => candidate.slice(2));
692
+ }
693
+ let similar = [];
694
+ let bestDistance = maxDistance;
695
+ const minSimilarity = 0.4;
696
+ candidates.forEach((candidate) => {
697
+ if (candidate.length <= 1)
698
+ return;
699
+ const distance = editDistance(word, candidate);
700
+ const length = Math.max(word.length, candidate.length);
701
+ const similarity = (length - distance) / length;
702
+ if (similarity > minSimilarity) {
703
+ if (distance < bestDistance) {
704
+ bestDistance = distance;
705
+ similar = [candidate];
706
+ } else if (distance === bestDistance) {
707
+ similar.push(candidate);
708
+ }
709
+ }
710
+ });
711
+ similar.sort((a, b) => a.localeCompare(b));
712
+ if (searchingOptions) {
713
+ similar = similar.map((candidate) => `--${candidate}`);
714
+ }
715
+ if (similar.length > 1) {
716
+ return `
717
+ (Did you mean one of ${similar.join(", ")}?)`;
718
+ }
719
+ if (similar.length === 1) {
720
+ return `
721
+ (Did you mean ${similar[0]}?)`;
722
+ }
723
+ return "";
724
+ }
725
+ exports.suggestSimilar = suggestSimilar;
726
+ });
727
+
728
+ // ../../node_modules/commander/lib/command.js
729
+ var require_command3 = __commonJS(function(exports) {
730
+ var EventEmitter = __require("node:events").EventEmitter;
731
+ var childProcess5 = __require("node:child_process");
732
+ var path4 = __require("node:path");
733
+ var fs8 = __require("node:fs");
734
+ var process9 = __require("node:process");
735
+ var { Argument: Argument3, humanReadableArgName } = require_argument3();
736
+ var { CommanderError: CommanderError3 } = require_error3();
737
+ var { Help: Help3, stripColor } = require_help3();
738
+ var { Option: Option3, DualOptions } = require_option3();
739
+ var { suggestSimilar } = require_suggestSimilar3();
740
+
741
+ class Command3 extends EventEmitter {
742
+ constructor(name) {
743
+ super();
744
+ this.commands = [];
745
+ this.options = [];
746
+ this.parent = null;
747
+ this._allowUnknownOption = false;
748
+ this._allowExcessArguments = false;
749
+ this.registeredArguments = [];
750
+ this._args = this.registeredArguments;
751
+ this.args = [];
752
+ this.rawArgs = [];
753
+ this.processedArgs = [];
754
+ this._scriptPath = null;
755
+ this._name = name || "";
756
+ this._optionValues = {};
757
+ this._optionValueSources = {};
758
+ this._storeOptionsAsProperties = false;
759
+ this._actionHandler = null;
760
+ this._executableHandler = false;
761
+ this._executableFile = null;
762
+ this._executableDir = null;
763
+ this._defaultCommandName = null;
764
+ this._exitCallback = null;
765
+ this._aliases = [];
766
+ this._combineFlagAndOptionalValue = true;
767
+ this._description = "";
768
+ this._summary = "";
769
+ this._argsDescription = undefined;
770
+ this._enablePositionalOptions = false;
771
+ this._passThroughOptions = false;
772
+ this._lifeCycleHooks = {};
773
+ this._showHelpAfterError = false;
774
+ this._showSuggestionAfterError = true;
775
+ this._savedState = null;
776
+ this._outputConfiguration = {
777
+ writeOut: (str3) => process9.stdout.write(str3),
778
+ writeErr: (str3) => process9.stderr.write(str3),
779
+ outputError: (str3, write) => write(str3),
780
+ getOutHelpWidth: () => process9.stdout.isTTY ? process9.stdout.columns : undefined,
781
+ getErrHelpWidth: () => process9.stderr.isTTY ? process9.stderr.columns : undefined,
782
+ getOutHasColors: () => useColor() ?? (process9.stdout.isTTY && process9.stdout.hasColors?.()),
783
+ getErrHasColors: () => useColor() ?? (process9.stderr.isTTY && process9.stderr.hasColors?.()),
784
+ stripColor: (str3) => stripColor(str3)
785
+ };
786
+ this._hidden = false;
787
+ this._helpOption = undefined;
788
+ this._addImplicitHelpCommand = undefined;
789
+ this._helpCommand = undefined;
790
+ this._helpConfiguration = {};
791
+ this._helpGroupHeading = undefined;
792
+ this._defaultCommandGroup = undefined;
793
+ this._defaultOptionGroup = undefined;
794
+ }
795
+ copyInheritedSettings(sourceCommand) {
796
+ this._outputConfiguration = sourceCommand._outputConfiguration;
797
+ this._helpOption = sourceCommand._helpOption;
798
+ this._helpCommand = sourceCommand._helpCommand;
799
+ this._helpConfiguration = sourceCommand._helpConfiguration;
800
+ this._exitCallback = sourceCommand._exitCallback;
801
+ this._storeOptionsAsProperties = sourceCommand._storeOptionsAsProperties;
802
+ this._combineFlagAndOptionalValue = sourceCommand._combineFlagAndOptionalValue;
803
+ this._allowExcessArguments = sourceCommand._allowExcessArguments;
804
+ this._enablePositionalOptions = sourceCommand._enablePositionalOptions;
805
+ this._showHelpAfterError = sourceCommand._showHelpAfterError;
806
+ this._showSuggestionAfterError = sourceCommand._showSuggestionAfterError;
807
+ return this;
808
+ }
809
+ _getCommandAndAncestors() {
810
+ const result = [];
811
+ for (let command = this;command; command = command.parent) {
812
+ result.push(command);
813
+ }
814
+ return result;
815
+ }
816
+ command(nameAndArgs, actionOptsOrExecDesc, execOpts) {
817
+ let desc = actionOptsOrExecDesc;
818
+ let opts = execOpts;
819
+ if (typeof desc === "object" && desc !== null) {
820
+ opts = desc;
821
+ desc = null;
822
+ }
823
+ opts = opts || {};
824
+ const [, name, args] = nameAndArgs.match(/([^ ]+) *(.*)/);
825
+ const cmd = this.createCommand(name);
826
+ if (desc) {
827
+ cmd.description(desc);
828
+ cmd._executableHandler = true;
829
+ }
830
+ if (opts.isDefault)
831
+ this._defaultCommandName = cmd._name;
832
+ cmd._hidden = !!(opts.noHelp || opts.hidden);
833
+ cmd._executableFile = opts.executableFile || null;
834
+ if (args)
835
+ cmd.arguments(args);
836
+ this._registerCommand(cmd);
837
+ cmd.parent = this;
838
+ cmd.copyInheritedSettings(this);
839
+ if (desc)
840
+ return this;
841
+ return cmd;
842
+ }
843
+ createCommand(name) {
844
+ return new Command3(name);
845
+ }
846
+ createHelp() {
847
+ return Object.assign(new Help3, this.configureHelp());
848
+ }
849
+ configureHelp(configuration) {
850
+ if (configuration === undefined)
851
+ return this._helpConfiguration;
852
+ this._helpConfiguration = configuration;
853
+ return this;
854
+ }
855
+ configureOutput(configuration) {
856
+ if (configuration === undefined)
857
+ return this._outputConfiguration;
858
+ this._outputConfiguration = {
859
+ ...this._outputConfiguration,
860
+ ...configuration
861
+ };
862
+ return this;
863
+ }
864
+ showHelpAfterError(displayHelp = true) {
865
+ if (typeof displayHelp !== "string")
866
+ displayHelp = !!displayHelp;
867
+ this._showHelpAfterError = displayHelp;
868
+ return this;
869
+ }
870
+ showSuggestionAfterError(displaySuggestion = true) {
871
+ this._showSuggestionAfterError = !!displaySuggestion;
872
+ return this;
873
+ }
874
+ addCommand(cmd, opts) {
875
+ if (!cmd._name) {
876
+ throw new Error(`Command passed to .addCommand() must have a name
877
+ - specify the name in Command constructor or using .name()`);
878
+ }
879
+ opts = opts || {};
880
+ if (opts.isDefault)
881
+ this._defaultCommandName = cmd._name;
882
+ if (opts.noHelp || opts.hidden)
883
+ cmd._hidden = true;
884
+ this._registerCommand(cmd);
885
+ cmd.parent = this;
886
+ cmd._checkForBrokenPassThrough();
887
+ return this;
888
+ }
889
+ createArgument(name, description) {
890
+ return new Argument3(name, description);
891
+ }
892
+ argument(name, description, parseArg, defaultValue) {
893
+ const argument = this.createArgument(name, description);
894
+ if (typeof parseArg === "function") {
895
+ argument.default(defaultValue).argParser(parseArg);
896
+ } else {
897
+ argument.default(parseArg);
898
+ }
899
+ this.addArgument(argument);
900
+ return this;
901
+ }
902
+ arguments(names) {
903
+ names.trim().split(/ +/).forEach((detail) => {
904
+ this.argument(detail);
905
+ });
906
+ return this;
907
+ }
908
+ addArgument(argument) {
909
+ const previousArgument = this.registeredArguments.slice(-1)[0];
910
+ if (previousArgument?.variadic) {
911
+ throw new Error(`only the last argument can be variadic '${previousArgument.name()}'`);
912
+ }
913
+ if (argument.required && argument.defaultValue !== undefined && argument.parseArg === undefined) {
914
+ throw new Error(`a default value for a required argument is never used: '${argument.name()}'`);
915
+ }
916
+ this.registeredArguments.push(argument);
917
+ return this;
918
+ }
919
+ helpCommand(enableOrNameAndArgs, description) {
920
+ if (typeof enableOrNameAndArgs === "boolean") {
921
+ this._addImplicitHelpCommand = enableOrNameAndArgs;
922
+ if (enableOrNameAndArgs && this._defaultCommandGroup) {
923
+ this._initCommandGroup(this._getHelpCommand());
924
+ }
925
+ return this;
926
+ }
927
+ const nameAndArgs = enableOrNameAndArgs ?? "help [command]";
928
+ const [, helpName, helpArgs] = nameAndArgs.match(/([^ ]+) *(.*)/);
929
+ const helpDescription = description ?? "display help for command";
930
+ const helpCommand = this.createCommand(helpName);
931
+ helpCommand.helpOption(false);
932
+ if (helpArgs)
933
+ helpCommand.arguments(helpArgs);
934
+ if (helpDescription)
935
+ helpCommand.description(helpDescription);
936
+ this._addImplicitHelpCommand = true;
937
+ this._helpCommand = helpCommand;
938
+ if (enableOrNameAndArgs || description)
939
+ this._initCommandGroup(helpCommand);
940
+ return this;
941
+ }
942
+ addHelpCommand(helpCommand, deprecatedDescription) {
943
+ if (typeof helpCommand !== "object") {
944
+ this.helpCommand(helpCommand, deprecatedDescription);
945
+ return this;
946
+ }
947
+ this._addImplicitHelpCommand = true;
948
+ this._helpCommand = helpCommand;
949
+ this._initCommandGroup(helpCommand);
950
+ return this;
951
+ }
952
+ _getHelpCommand() {
953
+ const hasImplicitHelpCommand = this._addImplicitHelpCommand ?? (this.commands.length && !this._actionHandler && !this._findCommand("help"));
954
+ if (hasImplicitHelpCommand) {
955
+ if (this._helpCommand === undefined) {
956
+ this.helpCommand(undefined, undefined);
957
+ }
958
+ return this._helpCommand;
959
+ }
960
+ return null;
961
+ }
962
+ hook(event, listener) {
963
+ const allowedValues = ["preSubcommand", "preAction", "postAction"];
964
+ if (!allowedValues.includes(event)) {
965
+ throw new Error(`Unexpected value for event passed to hook : '${event}'.
966
+ Expecting one of '${allowedValues.join("', '")}'`);
967
+ }
968
+ if (this._lifeCycleHooks[event]) {
969
+ this._lifeCycleHooks[event].push(listener);
970
+ } else {
971
+ this._lifeCycleHooks[event] = [listener];
972
+ }
973
+ return this;
974
+ }
975
+ exitOverride(fn) {
976
+ if (fn) {
977
+ this._exitCallback = fn;
978
+ } else {
979
+ this._exitCallback = (err) => {
980
+ if (err.code !== "commander.executeSubCommandAsync") {
981
+ throw err;
982
+ }
983
+ };
984
+ }
985
+ return this;
986
+ }
987
+ _exit(exitCode, code, message) {
988
+ if (this._exitCallback) {
989
+ this._exitCallback(new CommanderError3(exitCode, code, message));
990
+ }
991
+ process9.exit(exitCode);
992
+ }
993
+ action(fn) {
994
+ const listener = (args) => {
995
+ const expectedArgsCount = this.registeredArguments.length;
996
+ const actionArgs = args.slice(0, expectedArgsCount);
997
+ if (this._storeOptionsAsProperties) {
998
+ actionArgs[expectedArgsCount] = this;
999
+ } else {
1000
+ actionArgs[expectedArgsCount] = this.opts();
1001
+ }
1002
+ actionArgs.push(this);
1003
+ return fn.apply(this, actionArgs);
1004
+ };
1005
+ this._actionHandler = listener;
1006
+ return this;
1007
+ }
1008
+ createOption(flags, description) {
1009
+ return new Option3(flags, description);
1010
+ }
1011
+ _callParseArg(target, value, previous, invalidArgumentMessage) {
1012
+ try {
1013
+ return target.parseArg(value, previous);
1014
+ } catch (err) {
1015
+ if (err.code === "commander.invalidArgument") {
1016
+ const message = `${invalidArgumentMessage} ${err.message}`;
1017
+ this.error(message, { exitCode: err.exitCode, code: err.code });
1018
+ }
1019
+ throw err;
1020
+ }
1021
+ }
1022
+ _registerOption(option) {
1023
+ const matchingOption = option.short && this._findOption(option.short) || option.long && this._findOption(option.long);
1024
+ if (matchingOption) {
1025
+ const matchingFlag = option.long && this._findOption(option.long) ? option.long : option.short;
1026
+ throw new Error(`Cannot add option '${option.flags}'${this._name && ` to command '${this._name}'`} due to conflicting flag '${matchingFlag}'
1027
+ - already used by option '${matchingOption.flags}'`);
1028
+ }
1029
+ this._initOptionGroup(option);
1030
+ this.options.push(option);
1031
+ }
1032
+ _registerCommand(command) {
1033
+ const knownBy = (cmd) => {
1034
+ return [cmd.name()].concat(cmd.aliases());
1035
+ };
1036
+ const alreadyUsed = knownBy(command).find((name) => this._findCommand(name));
1037
+ if (alreadyUsed) {
1038
+ const existingCmd = knownBy(this._findCommand(alreadyUsed)).join("|");
1039
+ const newCmd = knownBy(command).join("|");
1040
+ throw new Error(`cannot add command '${newCmd}' as already have command '${existingCmd}'`);
1041
+ }
1042
+ this._initCommandGroup(command);
1043
+ this.commands.push(command);
1044
+ }
1045
+ addOption(option) {
1046
+ this._registerOption(option);
1047
+ const oname = option.name();
1048
+ const name = option.attributeName();
1049
+ if (option.negate) {
1050
+ const positiveLongFlag = option.long.replace(/^--no-/, "--");
1051
+ if (!this._findOption(positiveLongFlag)) {
1052
+ this.setOptionValueWithSource(name, option.defaultValue === undefined ? true : option.defaultValue, "default");
1053
+ }
1054
+ } else if (option.defaultValue !== undefined) {
1055
+ this.setOptionValueWithSource(name, option.defaultValue, "default");
1056
+ }
1057
+ const handleOptionValue = (val, invalidValueMessage, valueSource) => {
1058
+ if (val == null && option.presetArg !== undefined) {
1059
+ val = option.presetArg;
1060
+ }
1061
+ const oldValue = this.getOptionValue(name);
1062
+ if (val !== null && option.parseArg) {
1063
+ val = this._callParseArg(option, val, oldValue, invalidValueMessage);
1064
+ } else if (val !== null && option.variadic) {
1065
+ val = option._collectValue(val, oldValue);
1066
+ }
1067
+ if (val == null) {
1068
+ if (option.negate) {
1069
+ val = false;
1070
+ } else if (option.isBoolean() || option.optional) {
1071
+ val = true;
1072
+ } else {
1073
+ val = "";
1074
+ }
1075
+ }
1076
+ this.setOptionValueWithSource(name, val, valueSource);
1077
+ };
1078
+ this.on("option:" + oname, (val) => {
1079
+ const invalidValueMessage = `error: option '${option.flags}' argument '${val}' is invalid.`;
1080
+ handleOptionValue(val, invalidValueMessage, "cli");
1081
+ });
1082
+ if (option.envVar) {
1083
+ this.on("optionEnv:" + oname, (val) => {
1084
+ const invalidValueMessage = `error: option '${option.flags}' value '${val}' from env '${option.envVar}' is invalid.`;
1085
+ handleOptionValue(val, invalidValueMessage, "env");
1086
+ });
1087
+ }
1088
+ return this;
1089
+ }
1090
+ _optionEx(config, flags, description, fn, defaultValue) {
1091
+ if (typeof flags === "object" && flags instanceof Option3) {
1092
+ throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");
1093
+ }
1094
+ const option = this.createOption(flags, description);
1095
+ option.makeOptionMandatory(!!config.mandatory);
1096
+ if (typeof fn === "function") {
1097
+ option.default(defaultValue).argParser(fn);
1098
+ } else if (fn instanceof RegExp) {
1099
+ const regex = fn;
1100
+ fn = (val, def) => {
1101
+ const m = regex.exec(val);
1102
+ return m ? m[0] : def;
1103
+ };
1104
+ option.default(defaultValue).argParser(fn);
1105
+ } else {
1106
+ option.default(fn);
1107
+ }
1108
+ return this.addOption(option);
1109
+ }
1110
+ option(flags, description, parseArg, defaultValue) {
1111
+ return this._optionEx({}, flags, description, parseArg, defaultValue);
1112
+ }
1113
+ requiredOption(flags, description, parseArg, defaultValue) {
1114
+ return this._optionEx({ mandatory: true }, flags, description, parseArg, defaultValue);
1115
+ }
1116
+ combineFlagAndOptionalValue(combine = true) {
1117
+ this._combineFlagAndOptionalValue = !!combine;
1118
+ return this;
1119
+ }
1120
+ allowUnknownOption(allowUnknown = true) {
1121
+ this._allowUnknownOption = !!allowUnknown;
1122
+ return this;
1123
+ }
1124
+ allowExcessArguments(allowExcess = true) {
1125
+ this._allowExcessArguments = !!allowExcess;
1126
+ return this;
1127
+ }
1128
+ enablePositionalOptions(positional = true) {
1129
+ this._enablePositionalOptions = !!positional;
1130
+ return this;
1131
+ }
1132
+ passThroughOptions(passThrough = true) {
1133
+ this._passThroughOptions = !!passThrough;
1134
+ this._checkForBrokenPassThrough();
1135
+ return this;
1136
+ }
1137
+ _checkForBrokenPassThrough() {
1138
+ if (this.parent && this._passThroughOptions && !this.parent._enablePositionalOptions) {
1139
+ throw new Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`);
1140
+ }
1141
+ }
1142
+ storeOptionsAsProperties(storeAsProperties = true) {
1143
+ if (this.options.length) {
1144
+ throw new Error("call .storeOptionsAsProperties() before adding options");
1145
+ }
1146
+ if (Object.keys(this._optionValues).length) {
1147
+ throw new Error("call .storeOptionsAsProperties() before setting option values");
1148
+ }
1149
+ this._storeOptionsAsProperties = !!storeAsProperties;
1150
+ return this;
1151
+ }
1152
+ getOptionValue(key) {
1153
+ if (this._storeOptionsAsProperties) {
1154
+ return this[key];
1155
+ }
1156
+ return this._optionValues[key];
1157
+ }
1158
+ setOptionValue(key, value) {
1159
+ return this.setOptionValueWithSource(key, value, undefined);
1160
+ }
1161
+ setOptionValueWithSource(key, value, source) {
1162
+ if (this._storeOptionsAsProperties) {
1163
+ this[key] = value;
1164
+ } else {
1165
+ this._optionValues[key] = value;
1166
+ }
1167
+ this._optionValueSources[key] = source;
1168
+ return this;
1169
+ }
1170
+ getOptionValueSource(key) {
1171
+ return this._optionValueSources[key];
1172
+ }
1173
+ getOptionValueSourceWithGlobals(key) {
1174
+ let source;
1175
+ this._getCommandAndAncestors().forEach((cmd) => {
1176
+ if (cmd.getOptionValueSource(key) !== undefined) {
1177
+ source = cmd.getOptionValueSource(key);
1178
+ }
1179
+ });
1180
+ return source;
1181
+ }
1182
+ _prepareUserArgs(argv, parseOptions) {
1183
+ if (argv !== undefined && !Array.isArray(argv)) {
1184
+ throw new Error("first parameter to parse must be array or undefined");
1185
+ }
1186
+ parseOptions = parseOptions || {};
1187
+ if (argv === undefined && parseOptions.from === undefined) {
1188
+ if (process9.versions?.electron) {
1189
+ parseOptions.from = "electron";
1190
+ }
1191
+ const execArgv = process9.execArgv ?? [];
1192
+ if (execArgv.includes("-e") || execArgv.includes("--eval") || execArgv.includes("-p") || execArgv.includes("--print")) {
1193
+ parseOptions.from = "eval";
1194
+ }
1195
+ }
1196
+ if (argv === undefined) {
1197
+ argv = process9.argv;
1198
+ }
1199
+ this.rawArgs = argv.slice();
1200
+ let userArgs;
1201
+ switch (parseOptions.from) {
1202
+ case undefined:
1203
+ case "node":
1204
+ this._scriptPath = argv[1];
1205
+ userArgs = argv.slice(2);
1206
+ break;
1207
+ case "electron":
1208
+ if (process9.defaultApp) {
1209
+ this._scriptPath = argv[1];
1210
+ userArgs = argv.slice(2);
1211
+ } else {
1212
+ userArgs = argv.slice(1);
1213
+ }
1214
+ break;
1215
+ case "user":
1216
+ userArgs = argv.slice(0);
1217
+ break;
1218
+ case "eval":
1219
+ userArgs = argv.slice(1);
1220
+ break;
1221
+ default:
1222
+ throw new Error(`unexpected parse option { from: '${parseOptions.from}' }`);
1223
+ }
1224
+ if (!this._name && this._scriptPath)
1225
+ this.nameFromFilename(this._scriptPath);
1226
+ this._name = this._name || "program";
1227
+ return userArgs;
1228
+ }
1229
+ parse(argv, parseOptions) {
1230
+ this._prepareForParse();
1231
+ const userArgs = this._prepareUserArgs(argv, parseOptions);
1232
+ this._parseCommand([], userArgs);
1233
+ return this;
1234
+ }
1235
+ async parseAsync(argv, parseOptions) {
1236
+ this._prepareForParse();
1237
+ const userArgs = this._prepareUserArgs(argv, parseOptions);
1238
+ await this._parseCommand([], userArgs);
1239
+ return this;
1240
+ }
1241
+ _prepareForParse() {
1242
+ if (this._savedState === null) {
1243
+ this.saveStateBeforeParse();
1244
+ } else {
1245
+ this.restoreStateBeforeParse();
1246
+ }
1247
+ }
1248
+ saveStateBeforeParse() {
1249
+ this._savedState = {
1250
+ _name: this._name,
1251
+ _optionValues: { ...this._optionValues },
1252
+ _optionValueSources: { ...this._optionValueSources }
1253
+ };
1254
+ }
1255
+ restoreStateBeforeParse() {
1256
+ if (this._storeOptionsAsProperties)
1257
+ throw new Error(`Can not call parse again when storeOptionsAsProperties is true.
1258
+ - either make a new Command for each call to parse, or stop storing options as properties`);
1259
+ this._name = this._savedState._name;
1260
+ this._scriptPath = null;
1261
+ this.rawArgs = [];
1262
+ this._optionValues = { ...this._savedState._optionValues };
1263
+ this._optionValueSources = { ...this._savedState._optionValueSources };
1264
+ this.args = [];
1265
+ this.processedArgs = [];
1266
+ }
1267
+ _checkForMissingExecutable(executableFile, executableDir, subcommandName) {
1268
+ if (fs8.existsSync(executableFile))
1269
+ return;
1270
+ 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";
1271
+ const executableMissing = `'${executableFile}' does not exist
1272
+ - if '${subcommandName}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
1273
+ - if the default executable name is not suitable, use the executableFile option to supply a custom name or path
1274
+ - ${executableDirMessage}`;
1275
+ throw new Error(executableMissing);
1276
+ }
1277
+ _executeSubCommand(subcommand, args) {
1278
+ args = args.slice();
1279
+ let launchWithNode = false;
1280
+ const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
1281
+ function findFile(baseDir, baseName) {
1282
+ const localBin = path4.resolve(baseDir, baseName);
1283
+ if (fs8.existsSync(localBin))
1284
+ return localBin;
1285
+ if (sourceExt.includes(path4.extname(baseName)))
1286
+ return;
1287
+ const foundExt = sourceExt.find((ext) => fs8.existsSync(`${localBin}${ext}`));
1288
+ if (foundExt)
1289
+ return `${localBin}${foundExt}`;
1290
+ return;
1291
+ }
1292
+ this._checkForMissingMandatoryOptions();
1293
+ this._checkForConflictingOptions();
1294
+ let executableFile = subcommand._executableFile || `${this._name}-${subcommand._name}`;
1295
+ let executableDir = this._executableDir || "";
1296
+ if (this._scriptPath) {
1297
+ let resolvedScriptPath;
1298
+ try {
1299
+ resolvedScriptPath = fs8.realpathSync(this._scriptPath);
1300
+ } catch {
1301
+ resolvedScriptPath = this._scriptPath;
1302
+ }
1303
+ executableDir = path4.resolve(path4.dirname(resolvedScriptPath), executableDir);
1304
+ }
1305
+ if (executableDir) {
1306
+ let localFile = findFile(executableDir, executableFile);
1307
+ if (!localFile && !subcommand._executableFile && this._scriptPath) {
1308
+ const legacyName = path4.basename(this._scriptPath, path4.extname(this._scriptPath));
1309
+ if (legacyName !== this._name) {
1310
+ localFile = findFile(executableDir, `${legacyName}-${subcommand._name}`);
1311
+ }
1312
+ }
1313
+ executableFile = localFile || executableFile;
1314
+ }
1315
+ launchWithNode = sourceExt.includes(path4.extname(executableFile));
1316
+ let proc;
1317
+ if (process9.platform !== "win32") {
1318
+ if (launchWithNode) {
1319
+ args.unshift(executableFile);
1320
+ args = incrementNodeInspectorPort(process9.execArgv).concat(args);
1321
+ proc = childProcess5.spawn(process9.argv[0], args, { stdio: "inherit" });
1322
+ } else {
1323
+ proc = childProcess5.spawn(executableFile, args, { stdio: "inherit" });
1324
+ }
1325
+ } else {
1326
+ this._checkForMissingExecutable(executableFile, executableDir, subcommand._name);
1327
+ args.unshift(executableFile);
1328
+ args = incrementNodeInspectorPort(process9.execArgv).concat(args);
1329
+ proc = childProcess5.spawn(process9.execPath, args, { stdio: "inherit" });
1330
+ }
1331
+ if (!proc.killed) {
1332
+ const signals = ["SIGUSR1", "SIGUSR2", "SIGTERM", "SIGINT", "SIGHUP"];
1333
+ signals.forEach((signal) => {
1334
+ process9.on(signal, () => {
1335
+ if (proc.killed === false && proc.exitCode === null) {
1336
+ proc.kill(signal);
1337
+ }
1338
+ });
1339
+ });
1340
+ }
1341
+ const exitCallback = this._exitCallback;
1342
+ proc.on("close", (code) => {
1343
+ code = code ?? 1;
1344
+ if (!exitCallback) {
1345
+ process9.exit(code);
1346
+ } else {
1347
+ exitCallback(new CommanderError3(code, "commander.executeSubCommandAsync", "(close)"));
1348
+ }
1349
+ });
1350
+ proc.on("error", (err) => {
1351
+ if (err.code === "ENOENT") {
1352
+ this._checkForMissingExecutable(executableFile, executableDir, subcommand._name);
1353
+ } else if (err.code === "EACCES") {
1354
+ throw new Error(`'${executableFile}' not executable`);
1355
+ }
1356
+ if (!exitCallback) {
1357
+ process9.exit(1);
1358
+ } else {
1359
+ const wrappedError = new CommanderError3(1, "commander.executeSubCommandAsync", "(error)");
1360
+ wrappedError.nestedError = err;
1361
+ exitCallback(wrappedError);
1362
+ }
1363
+ });
1364
+ this.runningCommand = proc;
1365
+ }
1366
+ _dispatchSubcommand(commandName, operands, unknown) {
1367
+ const subCommand = this._findCommand(commandName);
1368
+ if (!subCommand)
1369
+ this.help({ error: true });
1370
+ subCommand._prepareForParse();
1371
+ let promiseChain;
1372
+ promiseChain = this._chainOrCallSubCommandHook(promiseChain, subCommand, "preSubcommand");
1373
+ promiseChain = this._chainOrCall(promiseChain, () => {
1374
+ if (subCommand._executableHandler) {
1375
+ this._executeSubCommand(subCommand, operands.concat(unknown));
1376
+ } else {
1377
+ return subCommand._parseCommand(operands, unknown);
1378
+ }
1379
+ });
1380
+ return promiseChain;
1381
+ }
1382
+ _dispatchHelpCommand(subcommandName) {
1383
+ if (!subcommandName) {
1384
+ this.help();
1385
+ }
1386
+ const subCommand = this._findCommand(subcommandName);
1387
+ if (subCommand && !subCommand._executableHandler) {
1388
+ subCommand.help();
1389
+ }
1390
+ return this._dispatchSubcommand(subcommandName, [], [this._getHelpOption()?.long ?? this._getHelpOption()?.short ?? "--help"]);
1391
+ }
1392
+ _checkNumberOfArguments() {
1393
+ this.registeredArguments.forEach((arg, i2) => {
1394
+ if (arg.required && this.args[i2] == null) {
1395
+ this.missingArgument(arg.name());
1396
+ }
1397
+ });
1398
+ if (this.registeredArguments.length > 0 && this.registeredArguments[this.registeredArguments.length - 1].variadic) {
1399
+ return;
1400
+ }
1401
+ if (this.args.length > this.registeredArguments.length) {
1402
+ this._excessArguments(this.args);
1403
+ }
1404
+ }
1405
+ _processArguments() {
1406
+ const myParseArg = (argument, value, previous) => {
1407
+ let parsedValue = value;
1408
+ if (value !== null && argument.parseArg) {
1409
+ const invalidValueMessage = `error: command-argument value '${value}' is invalid for argument '${argument.name()}'.`;
1410
+ parsedValue = this._callParseArg(argument, value, previous, invalidValueMessage);
1411
+ }
1412
+ return parsedValue;
1413
+ };
1414
+ this._checkNumberOfArguments();
1415
+ const processedArgs = [];
1416
+ this.registeredArguments.forEach((declaredArg, index) => {
1417
+ let value = declaredArg.defaultValue;
1418
+ if (declaredArg.variadic) {
1419
+ if (index < this.args.length) {
1420
+ value = this.args.slice(index);
1421
+ if (declaredArg.parseArg) {
1422
+ value = value.reduce((processed, v) => {
1423
+ return myParseArg(declaredArg, v, processed);
1424
+ }, declaredArg.defaultValue);
1425
+ }
1426
+ } else if (value === undefined) {
1427
+ value = [];
1428
+ }
1429
+ } else if (index < this.args.length) {
1430
+ value = this.args[index];
1431
+ if (declaredArg.parseArg) {
1432
+ value = myParseArg(declaredArg, value, declaredArg.defaultValue);
1433
+ }
1434
+ }
1435
+ processedArgs[index] = value;
1436
+ });
1437
+ this.processedArgs = processedArgs;
1438
+ }
1439
+ _chainOrCall(promise, fn) {
1440
+ if (promise?.then && typeof promise.then === "function") {
1441
+ return promise.then(() => fn());
1442
+ }
1443
+ return fn();
1444
+ }
1445
+ _chainOrCallHooks(promise, event) {
1446
+ let result = promise;
1447
+ const hooks = [];
1448
+ this._getCommandAndAncestors().reverse().filter((cmd) => cmd._lifeCycleHooks[event] !== undefined).forEach((hookedCommand) => {
1449
+ hookedCommand._lifeCycleHooks[event].forEach((callback) => {
1450
+ hooks.push({ hookedCommand, callback });
1451
+ });
1452
+ });
1453
+ if (event === "postAction") {
1454
+ hooks.reverse();
1455
+ }
1456
+ hooks.forEach((hookDetail) => {
1457
+ result = this._chainOrCall(result, () => {
1458
+ return hookDetail.callback(hookDetail.hookedCommand, this);
1459
+ });
1460
+ });
1461
+ return result;
1462
+ }
1463
+ _chainOrCallSubCommandHook(promise, subCommand, event) {
1464
+ let result = promise;
1465
+ if (this._lifeCycleHooks[event] !== undefined) {
1466
+ this._lifeCycleHooks[event].forEach((hook) => {
1467
+ result = this._chainOrCall(result, () => {
1468
+ return hook(this, subCommand);
1469
+ });
1470
+ });
1471
+ }
1472
+ return result;
1473
+ }
1474
+ _parseCommand(operands, unknown) {
1475
+ const parsed = this.parseOptions(unknown);
1476
+ this._parseOptionsEnv();
1477
+ this._parseOptionsImplied();
1478
+ operands = operands.concat(parsed.operands);
1479
+ unknown = parsed.unknown;
1480
+ this.args = operands.concat(unknown);
1481
+ if (operands && this._findCommand(operands[0])) {
1482
+ return this._dispatchSubcommand(operands[0], operands.slice(1), unknown);
1483
+ }
1484
+ if (this._getHelpCommand() && operands[0] === this._getHelpCommand().name()) {
1485
+ return this._dispatchHelpCommand(operands[1]);
1486
+ }
1487
+ if (this._defaultCommandName) {
1488
+ this._outputHelpIfRequested(unknown);
1489
+ return this._dispatchSubcommand(this._defaultCommandName, operands, unknown);
1490
+ }
1491
+ if (this.commands.length && this.args.length === 0 && !this._actionHandler && !this._defaultCommandName) {
1492
+ this.help({ error: true });
1493
+ }
1494
+ this._outputHelpIfRequested(parsed.unknown);
1495
+ this._checkForMissingMandatoryOptions();
1496
+ this._checkForConflictingOptions();
1497
+ const checkForUnknownOptions = () => {
1498
+ if (parsed.unknown.length > 0) {
1499
+ this.unknownOption(parsed.unknown[0]);
1500
+ }
1501
+ };
1502
+ const commandEvent = `command:${this.name()}`;
1503
+ if (this._actionHandler) {
1504
+ checkForUnknownOptions();
1505
+ this._processArguments();
1506
+ let promiseChain;
1507
+ promiseChain = this._chainOrCallHooks(promiseChain, "preAction");
1508
+ promiseChain = this._chainOrCall(promiseChain, () => this._actionHandler(this.processedArgs));
1509
+ if (this.parent) {
1510
+ promiseChain = this._chainOrCall(promiseChain, () => {
1511
+ this.parent.emit(commandEvent, operands, unknown);
1512
+ });
1513
+ }
1514
+ promiseChain = this._chainOrCallHooks(promiseChain, "postAction");
1515
+ return promiseChain;
1516
+ }
1517
+ if (this.parent?.listenerCount(commandEvent)) {
1518
+ checkForUnknownOptions();
1519
+ this._processArguments();
1520
+ this.parent.emit(commandEvent, operands, unknown);
1521
+ } else if (operands.length) {
1522
+ if (this._findCommand("*")) {
1523
+ return this._dispatchSubcommand("*", operands, unknown);
1524
+ }
1525
+ if (this.listenerCount("command:*")) {
1526
+ this.emit("command:*", operands, unknown);
1527
+ } else if (this.commands.length) {
1528
+ this.unknownCommand();
1529
+ } else {
1530
+ checkForUnknownOptions();
1531
+ this._processArguments();
1532
+ }
1533
+ } else if (this.commands.length) {
1534
+ checkForUnknownOptions();
1535
+ this.help({ error: true });
1536
+ } else {
1537
+ checkForUnknownOptions();
1538
+ this._processArguments();
1539
+ }
1540
+ }
1541
+ _findCommand(name) {
1542
+ if (!name)
1543
+ return;
1544
+ return this.commands.find((cmd) => cmd._name === name || cmd._aliases.includes(name));
1545
+ }
1546
+ _findOption(arg) {
1547
+ return this.options.find((option) => option.is(arg));
1548
+ }
1549
+ _checkForMissingMandatoryOptions() {
1550
+ this._getCommandAndAncestors().forEach((cmd) => {
1551
+ cmd.options.forEach((anOption) => {
1552
+ if (anOption.mandatory && cmd.getOptionValue(anOption.attributeName()) === undefined) {
1553
+ cmd.missingMandatoryOptionValue(anOption);
1554
+ }
1555
+ });
1556
+ });
1557
+ }
1558
+ _checkForConflictingLocalOptions() {
1559
+ const definedNonDefaultOptions = this.options.filter((option) => {
1560
+ const optionKey = option.attributeName();
1561
+ if (this.getOptionValue(optionKey) === undefined) {
1562
+ return false;
1563
+ }
1564
+ return this.getOptionValueSource(optionKey) !== "default";
1565
+ });
1566
+ const optionsWithConflicting = definedNonDefaultOptions.filter((option) => option.conflictsWith.length > 0);
1567
+ optionsWithConflicting.forEach((option) => {
1568
+ const conflictingAndDefined = definedNonDefaultOptions.find((defined) => option.conflictsWith.includes(defined.attributeName()));
1569
+ if (conflictingAndDefined) {
1570
+ this._conflictingOption(option, conflictingAndDefined);
1571
+ }
1572
+ });
1573
+ }
1574
+ _checkForConflictingOptions() {
1575
+ this._getCommandAndAncestors().forEach((cmd) => {
1576
+ cmd._checkForConflictingLocalOptions();
1577
+ });
1578
+ }
1579
+ parseOptions(args) {
1580
+ const operands = [];
1581
+ const unknown = [];
1582
+ let dest = operands;
1583
+ function maybeOption(arg) {
1584
+ return arg.length > 1 && arg[0] === "-";
1585
+ }
1586
+ const negativeNumberArg = (arg) => {
1587
+ if (!/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(arg))
1588
+ return false;
1589
+ return !this._getCommandAndAncestors().some((cmd) => cmd.options.map((opt) => opt.short).some((short) => /^-\d$/.test(short)));
1590
+ };
1591
+ let activeVariadicOption = null;
1592
+ let activeGroup = null;
1593
+ let i2 = 0;
1594
+ while (i2 < args.length || activeGroup) {
1595
+ const arg = activeGroup ?? args[i2++];
1596
+ activeGroup = null;
1597
+ if (arg === "--") {
1598
+ if (dest === unknown)
1599
+ dest.push(arg);
1600
+ dest.push(...args.slice(i2));
1601
+ break;
1602
+ }
1603
+ if (activeVariadicOption && (!maybeOption(arg) || negativeNumberArg(arg))) {
1604
+ this.emit(`option:${activeVariadicOption.name()}`, arg);
1605
+ continue;
1606
+ }
1607
+ activeVariadicOption = null;
1608
+ if (maybeOption(arg)) {
1609
+ const option = this._findOption(arg);
1610
+ if (option) {
1611
+ if (option.required) {
1612
+ const value = args[i2++];
1613
+ if (value === undefined)
1614
+ this.optionMissingArgument(option);
1615
+ this.emit(`option:${option.name()}`, value);
1616
+ } else if (option.optional) {
1617
+ let value = null;
1618
+ if (i2 < args.length && (!maybeOption(args[i2]) || negativeNumberArg(args[i2]))) {
1619
+ value = args[i2++];
1620
+ }
1621
+ this.emit(`option:${option.name()}`, value);
1622
+ } else {
1623
+ this.emit(`option:${option.name()}`);
1624
+ }
1625
+ activeVariadicOption = option.variadic ? option : null;
1626
+ continue;
1627
+ }
1628
+ }
1629
+ if (arg.length > 2 && arg[0] === "-" && arg[1] !== "-") {
1630
+ const option = this._findOption(`-${arg[1]}`);
1631
+ if (option) {
1632
+ if (option.required || option.optional && this._combineFlagAndOptionalValue) {
1633
+ this.emit(`option:${option.name()}`, arg.slice(2));
1634
+ } else {
1635
+ this.emit(`option:${option.name()}`);
1636
+ activeGroup = `-${arg.slice(2)}`;
1637
+ }
1638
+ continue;
1639
+ }
1640
+ }
1641
+ if (/^--[^=]+=/.test(arg)) {
1642
+ const index = arg.indexOf("=");
1643
+ const option = this._findOption(arg.slice(0, index));
1644
+ if (option && (option.required || option.optional)) {
1645
+ this.emit(`option:${option.name()}`, arg.slice(index + 1));
1646
+ continue;
1647
+ }
1648
+ }
1649
+ if (dest === operands && maybeOption(arg) && !(this.commands.length === 0 && negativeNumberArg(arg))) {
1650
+ dest = unknown;
1651
+ }
1652
+ if ((this._enablePositionalOptions || this._passThroughOptions) && operands.length === 0 && unknown.length === 0) {
1653
+ if (this._findCommand(arg)) {
1654
+ operands.push(arg);
1655
+ unknown.push(...args.slice(i2));
1656
+ break;
1657
+ } else if (this._getHelpCommand() && arg === this._getHelpCommand().name()) {
1658
+ operands.push(arg, ...args.slice(i2));
1659
+ break;
1660
+ } else if (this._defaultCommandName) {
1661
+ unknown.push(arg, ...args.slice(i2));
1662
+ break;
1663
+ }
1664
+ }
1665
+ if (this._passThroughOptions) {
1666
+ dest.push(arg, ...args.slice(i2));
1667
+ break;
1668
+ }
1669
+ dest.push(arg);
1670
+ }
1671
+ return { operands, unknown };
1672
+ }
1673
+ opts() {
1674
+ if (this._storeOptionsAsProperties) {
1675
+ const result = {};
1676
+ const len = this.options.length;
1677
+ for (let i2 = 0;i2 < len; i2++) {
1678
+ const key = this.options[i2].attributeName();
1679
+ result[key] = key === this._versionOptionName ? this._version : this[key];
1680
+ }
1681
+ return result;
1682
+ }
1683
+ return this._optionValues;
1684
+ }
1685
+ optsWithGlobals() {
1686
+ return this._getCommandAndAncestors().reduce((combinedOptions, cmd) => Object.assign(combinedOptions, cmd.opts()), {});
1687
+ }
1688
+ error(message, errorOptions) {
1689
+ this._outputConfiguration.outputError(`${message}
1690
+ `, this._outputConfiguration.writeErr);
1691
+ if (typeof this._showHelpAfterError === "string") {
1692
+ this._outputConfiguration.writeErr(`${this._showHelpAfterError}
1693
+ `);
1694
+ } else if (this._showHelpAfterError) {
1695
+ this._outputConfiguration.writeErr(`
1696
+ `);
1697
+ this.outputHelp({ error: true });
1698
+ }
1699
+ const config = errorOptions || {};
1700
+ const exitCode = config.exitCode || 1;
1701
+ const code = config.code || "commander.error";
1702
+ this._exit(exitCode, code, message);
1703
+ }
1704
+ _parseOptionsEnv() {
1705
+ this.options.forEach((option) => {
1706
+ if (option.envVar && option.envVar in process9.env) {
1707
+ const optionKey = option.attributeName();
1708
+ if (this.getOptionValue(optionKey) === undefined || ["default", "config", "env"].includes(this.getOptionValueSource(optionKey))) {
1709
+ if (option.required || option.optional) {
1710
+ this.emit(`optionEnv:${option.name()}`, process9.env[option.envVar]);
1711
+ } else {
1712
+ this.emit(`optionEnv:${option.name()}`);
1713
+ }
1714
+ }
1715
+ }
1716
+ });
1717
+ }
1718
+ _parseOptionsImplied() {
1719
+ const dualHelper = new DualOptions(this.options);
1720
+ const hasCustomOptionValue = (optionKey) => {
1721
+ return this.getOptionValue(optionKey) !== undefined && !["default", "implied"].includes(this.getOptionValueSource(optionKey));
1722
+ };
1723
+ this.options.filter((option) => option.implied !== undefined && hasCustomOptionValue(option.attributeName()) && dualHelper.valueFromOption(this.getOptionValue(option.attributeName()), option)).forEach((option) => {
1724
+ Object.keys(option.implied).filter((impliedKey) => !hasCustomOptionValue(impliedKey)).forEach((impliedKey) => {
1725
+ this.setOptionValueWithSource(impliedKey, option.implied[impliedKey], "implied");
1726
+ });
1727
+ });
1728
+ }
1729
+ missingArgument(name) {
1730
+ const message = `error: missing required argument '${name}'`;
1731
+ this.error(message, { code: "commander.missingArgument" });
1732
+ }
1733
+ optionMissingArgument(option) {
1734
+ const message = `error: option '${option.flags}' argument missing`;
1735
+ this.error(message, { code: "commander.optionMissingArgument" });
1736
+ }
1737
+ missingMandatoryOptionValue(option) {
1738
+ const message = `error: required option '${option.flags}' not specified`;
1739
+ this.error(message, { code: "commander.missingMandatoryOptionValue" });
1740
+ }
1741
+ _conflictingOption(option, conflictingOption) {
1742
+ const findBestOptionFromValue = (option2) => {
1743
+ const optionKey = option2.attributeName();
1744
+ const optionValue = this.getOptionValue(optionKey);
1745
+ const negativeOption = this.options.find((target) => target.negate && optionKey === target.attributeName());
1746
+ const positiveOption = this.options.find((target) => !target.negate && optionKey === target.attributeName());
1747
+ if (negativeOption && (negativeOption.presetArg === undefined && optionValue === false || negativeOption.presetArg !== undefined && optionValue === negativeOption.presetArg)) {
1748
+ return negativeOption;
1749
+ }
1750
+ return positiveOption || option2;
1751
+ };
1752
+ const getErrorMessage = (option2) => {
1753
+ const bestOption = findBestOptionFromValue(option2);
1754
+ const optionKey = bestOption.attributeName();
1755
+ const source = this.getOptionValueSource(optionKey);
1756
+ if (source === "env") {
1757
+ return `environment variable '${bestOption.envVar}'`;
1758
+ }
1759
+ return `option '${bestOption.flags}'`;
1760
+ };
1761
+ const message = `error: ${getErrorMessage(option)} cannot be used with ${getErrorMessage(conflictingOption)}`;
1762
+ this.error(message, { code: "commander.conflictingOption" });
1763
+ }
1764
+ unknownOption(flag) {
1765
+ if (this._allowUnknownOption)
1766
+ return;
1767
+ let suggestion = "";
1768
+ if (flag.startsWith("--") && this._showSuggestionAfterError) {
1769
+ let candidateFlags = [];
1770
+ let command = this;
1771
+ do {
1772
+ const moreFlags = command.createHelp().visibleOptions(command).filter((option) => option.long).map((option) => option.long);
1773
+ candidateFlags = candidateFlags.concat(moreFlags);
1774
+ command = command.parent;
1775
+ } while (command && !command._enablePositionalOptions);
1776
+ suggestion = suggestSimilar(flag, candidateFlags);
1777
+ }
1778
+ const message = `error: unknown option '${flag}'${suggestion}`;
1779
+ this.error(message, { code: "commander.unknownOption" });
1780
+ }
1781
+ _excessArguments(receivedArgs) {
1782
+ if (this._allowExcessArguments)
1783
+ return;
1784
+ const expected = this.registeredArguments.length;
1785
+ const s = expected === 1 ? "" : "s";
1786
+ const forSubcommand = this.parent ? ` for '${this.name()}'` : "";
1787
+ const message = `error: too many arguments${forSubcommand}. Expected ${expected} argument${s} but got ${receivedArgs.length}.`;
1788
+ this.error(message, { code: "commander.excessArguments" });
1789
+ }
1790
+ unknownCommand() {
1791
+ const unknownName = this.args[0];
1792
+ let suggestion = "";
1793
+ if (this._showSuggestionAfterError) {
1794
+ const candidateNames = [];
1795
+ this.createHelp().visibleCommands(this).forEach((command) => {
1796
+ candidateNames.push(command.name());
1797
+ if (command.alias())
1798
+ candidateNames.push(command.alias());
1799
+ });
1800
+ suggestion = suggestSimilar(unknownName, candidateNames);
1801
+ }
1802
+ const message = `error: unknown command '${unknownName}'${suggestion}`;
1803
+ this.error(message, { code: "commander.unknownCommand" });
1804
+ }
1805
+ version(str3, flags, description) {
1806
+ if (str3 === undefined)
1807
+ return this._version;
1808
+ this._version = str3;
1809
+ flags = flags || "-V, --version";
1810
+ description = description || "output the version number";
1811
+ const versionOption = this.createOption(flags, description);
1812
+ this._versionOptionName = versionOption.attributeName();
1813
+ this._registerOption(versionOption);
1814
+ this.on("option:" + versionOption.name(), () => {
1815
+ this._outputConfiguration.writeOut(`${str3}
1816
+ `);
1817
+ this._exit(0, "commander.version", str3);
1818
+ });
1819
+ return this;
1820
+ }
1821
+ description(str3, argsDescription) {
1822
+ if (str3 === undefined && argsDescription === undefined)
1823
+ return this._description;
1824
+ this._description = str3;
1825
+ if (argsDescription) {
1826
+ this._argsDescription = argsDescription;
1827
+ }
1828
+ return this;
1829
+ }
1830
+ summary(str3) {
1831
+ if (str3 === undefined)
1832
+ return this._summary;
1833
+ this._summary = str3;
1834
+ return this;
1835
+ }
1836
+ alias(alias) {
1837
+ if (alias === undefined)
1838
+ return this._aliases[0];
1839
+ let command = this;
1840
+ if (this.commands.length !== 0 && this.commands[this.commands.length - 1]._executableHandler) {
1841
+ command = this.commands[this.commands.length - 1];
1842
+ }
1843
+ if (alias === command._name)
1844
+ throw new Error("Command alias can't be the same as its name");
1845
+ const matchingCommand = this.parent?._findCommand(alias);
1846
+ if (matchingCommand) {
1847
+ const existingCmd = [matchingCommand.name()].concat(matchingCommand.aliases()).join("|");
1848
+ throw new Error(`cannot add alias '${alias}' to command '${this.name()}' as already have command '${existingCmd}'`);
1849
+ }
1850
+ command._aliases.push(alias);
1851
+ return this;
1852
+ }
1853
+ aliases(aliases) {
1854
+ if (aliases === undefined)
1855
+ return this._aliases;
1856
+ aliases.forEach((alias) => this.alias(alias));
1857
+ return this;
1858
+ }
1859
+ usage(str3) {
1860
+ if (str3 === undefined) {
1861
+ if (this._usage)
1862
+ return this._usage;
1863
+ const args = this.registeredArguments.map((arg) => {
1864
+ return humanReadableArgName(arg);
1865
+ });
1866
+ return [].concat(this.options.length || this._helpOption !== null ? "[options]" : [], this.commands.length ? "[command]" : [], this.registeredArguments.length ? args : []).join(" ");
1867
+ }
1868
+ this._usage = str3;
1869
+ return this;
1870
+ }
1871
+ name(str3) {
1872
+ if (str3 === undefined)
1873
+ return this._name;
1874
+ this._name = str3;
1875
+ return this;
1876
+ }
1877
+ helpGroup(heading) {
1878
+ if (heading === undefined)
1879
+ return this._helpGroupHeading ?? "";
1880
+ this._helpGroupHeading = heading;
1881
+ return this;
1882
+ }
1883
+ commandsGroup(heading) {
1884
+ if (heading === undefined)
1885
+ return this._defaultCommandGroup ?? "";
1886
+ this._defaultCommandGroup = heading;
1887
+ return this;
1888
+ }
1889
+ optionsGroup(heading) {
1890
+ if (heading === undefined)
1891
+ return this._defaultOptionGroup ?? "";
1892
+ this._defaultOptionGroup = heading;
1893
+ return this;
1894
+ }
1895
+ _initOptionGroup(option) {
1896
+ if (this._defaultOptionGroup && !option.helpGroupHeading)
1897
+ option.helpGroup(this._defaultOptionGroup);
1898
+ }
1899
+ _initCommandGroup(cmd) {
1900
+ if (this._defaultCommandGroup && !cmd.helpGroup())
1901
+ cmd.helpGroup(this._defaultCommandGroup);
1902
+ }
1903
+ nameFromFilename(filename) {
1904
+ this._name = path4.basename(filename, path4.extname(filename));
1905
+ return this;
1906
+ }
1907
+ executableDir(path7) {
1908
+ if (path7 === undefined)
1909
+ return this._executableDir;
1910
+ this._executableDir = path7;
1911
+ return this;
1912
+ }
1913
+ helpInformation(contextOptions) {
1914
+ const helper = this.createHelp();
1915
+ const context = this._getOutputContext(contextOptions);
1916
+ helper.prepareContext({
1917
+ error: context.error,
1918
+ helpWidth: context.helpWidth,
1919
+ outputHasColors: context.hasColors
1920
+ });
1921
+ const text = helper.formatHelp(this, helper);
1922
+ if (context.hasColors)
1923
+ return text;
1924
+ return this._outputConfiguration.stripColor(text);
1925
+ }
1926
+ _getOutputContext(contextOptions) {
1927
+ contextOptions = contextOptions || {};
1928
+ const error = !!contextOptions.error;
1929
+ let baseWrite;
1930
+ let hasColors;
1931
+ let helpWidth;
1932
+ if (error) {
1933
+ baseWrite = (str3) => this._outputConfiguration.writeErr(str3);
1934
+ hasColors = this._outputConfiguration.getErrHasColors();
1935
+ helpWidth = this._outputConfiguration.getErrHelpWidth();
1936
+ } else {
1937
+ baseWrite = (str3) => this._outputConfiguration.writeOut(str3);
1938
+ hasColors = this._outputConfiguration.getOutHasColors();
1939
+ helpWidth = this._outputConfiguration.getOutHelpWidth();
1940
+ }
1941
+ const write = (str3) => {
1942
+ if (!hasColors)
1943
+ str3 = this._outputConfiguration.stripColor(str3);
1944
+ return baseWrite(str3);
1945
+ };
1946
+ return { error, write, hasColors, helpWidth };
1947
+ }
1948
+ outputHelp(contextOptions) {
1949
+ let deprecatedCallback;
1950
+ if (typeof contextOptions === "function") {
1951
+ deprecatedCallback = contextOptions;
1952
+ contextOptions = undefined;
1953
+ }
1954
+ const outputContext = this._getOutputContext(contextOptions);
1955
+ const eventContext = {
1956
+ error: outputContext.error,
1957
+ write: outputContext.write,
1958
+ command: this
1959
+ };
1960
+ this._getCommandAndAncestors().reverse().forEach((command) => command.emit("beforeAllHelp", eventContext));
1961
+ this.emit("beforeHelp", eventContext);
1962
+ let helpInformation = this.helpInformation({ error: outputContext.error });
1963
+ if (deprecatedCallback) {
1964
+ helpInformation = deprecatedCallback(helpInformation);
1965
+ if (typeof helpInformation !== "string" && !Buffer.isBuffer(helpInformation)) {
1966
+ throw new Error("outputHelp callback must return a string or a Buffer");
1967
+ }
1968
+ }
1969
+ outputContext.write(helpInformation);
1970
+ if (this._getHelpOption()?.long) {
1971
+ this.emit(this._getHelpOption().long);
1972
+ }
1973
+ this.emit("afterHelp", eventContext);
1974
+ this._getCommandAndAncestors().forEach((command) => command.emit("afterAllHelp", eventContext));
1975
+ }
1976
+ helpOption(flags, description) {
1977
+ if (typeof flags === "boolean") {
1978
+ if (flags) {
1979
+ if (this._helpOption === null)
1980
+ this._helpOption = undefined;
1981
+ if (this._defaultOptionGroup) {
1982
+ this._initOptionGroup(this._getHelpOption());
1983
+ }
1984
+ } else {
1985
+ this._helpOption = null;
1986
+ }
1987
+ return this;
1988
+ }
1989
+ this._helpOption = this.createOption(flags ?? "-h, --help", description ?? "display help for command");
1990
+ if (flags || description)
1991
+ this._initOptionGroup(this._helpOption);
1992
+ return this;
1993
+ }
1994
+ _getHelpOption() {
1995
+ if (this._helpOption === undefined) {
1996
+ this.helpOption(undefined, undefined);
1997
+ }
1998
+ return this._helpOption;
1999
+ }
2000
+ addHelpOption(option) {
2001
+ this._helpOption = option;
2002
+ this._initOptionGroup(option);
2003
+ return this;
2004
+ }
2005
+ help(contextOptions) {
2006
+ this.outputHelp(contextOptions);
2007
+ let exitCode = Number(process9.exitCode ?? 0);
2008
+ if (exitCode === 0 && contextOptions && typeof contextOptions !== "function" && contextOptions.error) {
2009
+ exitCode = 1;
2010
+ }
2011
+ this._exit(exitCode, "commander.help", "(outputHelp)");
2012
+ }
2013
+ addHelpText(position, text) {
2014
+ const allowedValues = ["beforeAll", "before", "after", "afterAll"];
2015
+ if (!allowedValues.includes(position)) {
2016
+ throw new Error(`Unexpected value for position to addHelpText.
2017
+ Expecting one of '${allowedValues.join("', '")}'`);
2018
+ }
2019
+ const helpEvent = `${position}Help`;
2020
+ this.on(helpEvent, (context) => {
2021
+ let helpStr;
2022
+ if (typeof text === "function") {
2023
+ helpStr = text({ error: context.error, command: context.command });
2024
+ } else {
2025
+ helpStr = text;
2026
+ }
2027
+ if (helpStr) {
2028
+ context.write(`${helpStr}
2029
+ `);
2030
+ }
2031
+ });
2032
+ return this;
2033
+ }
2034
+ _outputHelpIfRequested(args) {
2035
+ const helpOption = this._getHelpOption();
2036
+ const helpRequested = helpOption && args.find((arg) => helpOption.is(arg));
2037
+ if (helpRequested) {
2038
+ this.outputHelp();
2039
+ this._exit(0, "commander.helpDisplayed", "(outputHelp)");
2040
+ }
2041
+ }
2042
+ }
2043
+ function incrementNodeInspectorPort(args) {
2044
+ return args.map((arg) => {
2045
+ if (!arg.startsWith("--inspect")) {
2046
+ return arg;
2047
+ }
2048
+ let debugOption;
2049
+ let debugHost = "127.0.0.1";
2050
+ let debugPort = "9229";
2051
+ let match;
2052
+ if ((match = arg.match(/^(--inspect(-brk)?)$/)) !== null) {
2053
+ debugOption = match[1];
2054
+ } else if ((match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+)$/)) !== null) {
2055
+ debugOption = match[1];
2056
+ if (/^\d+$/.test(match[3])) {
2057
+ debugPort = match[3];
2058
+ } else {
2059
+ debugHost = match[3];
2060
+ }
2061
+ } else if ((match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/)) !== null) {
2062
+ debugOption = match[1];
2063
+ debugHost = match[3];
2064
+ debugPort = match[4];
2065
+ }
2066
+ if (debugOption && debugPort !== "0") {
2067
+ return `${debugOption}=${debugHost}:${parseInt(debugPort) + 1}`;
2068
+ }
2069
+ return arg;
2070
+ });
2071
+ }
2072
+ function useColor() {
2073
+ if (process9.env.NO_COLOR || process9.env.FORCE_COLOR === "0" || process9.env.FORCE_COLOR === "false")
2074
+ return false;
2075
+ if (process9.env.FORCE_COLOR || process9.env.CLICOLOR_FORCE !== undefined)
2076
+ return true;
2077
+ return;
2078
+ }
2079
+ exports.Command = Command3;
2080
+ exports.useColor = useColor;
2081
+ });
2082
+
2083
+ // ../../node_modules/commander/index.js
2084
+ var require_commander3 = __commonJS(function(exports) {
2085
+ var { Argument: Argument3 } = require_argument3();
2086
+ var { Command: Command3 } = require_command3();
2087
+ var { CommanderError: CommanderError3, InvalidArgumentError: InvalidArgumentError3 } = require_error3();
2088
+ var { Help: Help3 } = require_help3();
2089
+ var { Option: Option3 } = require_option3();
2090
+ exports.program = new Command3;
2091
+ exports.createCommand = (name) => new Command3(name);
2092
+ exports.createOption = (flags, description) => new Option3(flags, description);
2093
+ exports.createArgument = (name, description) => new Argument3(name, description);
2094
+ exports.Command = Command3;
2095
+ exports.Option = Option3;
2096
+ exports.Argument = Argument3;
2097
+ exports.Help = Help3;
2098
+ exports.CommanderError = CommanderError3;
2099
+ exports.InvalidArgumentError = InvalidArgumentError3;
2100
+ exports.InvalidOptionArgumentError = InvalidArgumentError3;
2101
+ });
7
2102
  // package.json
8
2103
  var package_default = {
9
2104
  name: "@uipath/function-tool",
10
2105
  license: "SEE LICENSE IN LICENSE.txt",
11
- version: "1.202.0",
2106
+ version: "1.202.1-preview.162",
12
2107
  description: "UiPath CLI tool for JS/TS and Python Functions — thin passthrough to uipath-functions / uipath",
13
2108
  keywords: [
14
2109
  "uipcli-tool",
@@ -47,7 +2142,7 @@ var package_default = {
47
2142
  },
48
2143
  devDependencies: {
49
2144
  "@uipath/auth": "workspace:*",
50
- "@uipath/coded-functions-js-cli": "^0.1.80",
2145
+ "@uipath/coded-functions-js-cli": "0.1.86",
51
2146
  "@uipath/common": "workspace:*",
52
2147
  "@uipath/filesystem": "workspace:*",
53
2148
  "@uipath/packager-tool-functions": "workspace:*",
@@ -109,7 +2204,7 @@ function __accessProp(key) {
109
2204
  }
110
2205
  var __toESMCache_node;
111
2206
  var __toESMCache_esm;
112
- var __toESM = (mod, isNodeMode, target) => {
2207
+ var __toESM2 = (mod, isNodeMode, target) => {
113
2208
  var canCache = mod != null && typeof mod === "object";
114
2209
  if (canCache) {
115
2210
  var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
@@ -131,7 +2226,7 @@ var __toESM = (mod, isNodeMode, target) => {
131
2226
  cache.set(mod, to);
132
2227
  return to;
133
2228
  };
134
- var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
2229
+ var __commonJS2 = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
135
2230
  var __returnValue = (v) => v;
136
2231
  function __exportSetter(name, newValue) {
137
2232
  this[name] = __returnValue.bind(null, newValue);
@@ -3941,7 +6036,7 @@ var init_js_yaml = __esm(() => {
3941
6036
  safeDump
3942
6037
  } = yaml);
3943
6038
  });
3944
- var require_jmespath = __commonJS(function(exports) {
6039
+ var require_jmespath = __commonJS2(function(exports) {
3945
6040
  (function(exports2) {
3946
6041
  function isArray(obj) {
3947
6042
  if (obj !== null) {
@@ -5418,7 +7513,7 @@ var require_jmespath = __commonJS(function(exports) {
5418
7513
  exports2.strictDeepEqual = strictDeepEqual;
5419
7514
  })(typeof exports === "undefined" ? exports.jmespath = {} : exports);
5420
7515
  });
5421
- var require_error = __commonJS(function(exports) {
7516
+ var require_error = __commonJS2(function(exports) {
5422
7517
 
5423
7518
  class CommanderError extends Error {
5424
7519
  constructor(exitCode, code, message) {
@@ -5441,7 +7536,7 @@ var require_error = __commonJS(function(exports) {
5441
7536
  exports.CommanderError = CommanderError;
5442
7537
  exports.InvalidArgumentError = InvalidArgumentError;
5443
7538
  });
5444
- var require_argument = __commonJS(function(exports) {
7539
+ var require_argument = __commonJS2(function(exports) {
5445
7540
  var { InvalidArgumentError } = require_error();
5446
7541
 
5447
7542
  class Argument {
@@ -5519,7 +7614,7 @@ var require_argument = __commonJS(function(exports) {
5519
7614
  exports.Argument = Argument;
5520
7615
  exports.humanReadableArgName = humanReadableArgName;
5521
7616
  });
5522
- var require_help = __commonJS(function(exports) {
7617
+ var require_help = __commonJS2(function(exports) {
5523
7618
  var { humanReadableArgName } = require_argument();
5524
7619
 
5525
7620
  class Help {
@@ -5874,7 +7969,7 @@ ${itemIndentStr}`);
5874
7969
  exports.Help = Help;
5875
7970
  exports.stripColor = stripColor;
5876
7971
  });
5877
- var require_option = __commonJS(function(exports) {
7972
+ var require_option = __commonJS2(function(exports) {
5878
7973
  var { InvalidArgumentError } = require_error();
5879
7974
 
5880
7975
  class Option {
@@ -6056,7 +8151,7 @@ var require_option = __commonJS(function(exports) {
6056
8151
  exports.Option = Option;
6057
8152
  exports.DualOptions = DualOptions;
6058
8153
  });
6059
- var require_suggestSimilar = __commonJS(function(exports) {
8154
+ var require_suggestSimilar = __commonJS2(function(exports) {
6060
8155
  var maxDistance = 3;
6061
8156
  function editDistance(a, b) {
6062
8157
  if (Math.abs(a.length - b.length) > maxDistance)
@@ -6127,7 +8222,7 @@ var require_suggestSimilar = __commonJS(function(exports) {
6127
8222
  }
6128
8223
  exports.suggestSimilar = suggestSimilar;
6129
8224
  });
6130
- var require_command = __commonJS(function(exports) {
8225
+ var require_command = __commonJS2(function(exports) {
6131
8226
  var EventEmitter = __require2("node:events").EventEmitter;
6132
8227
  var childProcess4 = __require2("node:child_process");
6133
8228
  var path3 = __require2("node:path");
@@ -7480,7 +9575,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
7480
9575
  exports.Command = Command;
7481
9576
  exports.useColor = useColor;
7482
9577
  });
7483
- var require_commander = __commonJS(function(exports) {
9578
+ var require_commander = __commonJS2(function(exports) {
7484
9579
  var { Argument } = require_argument();
7485
9580
  var { Command } = require_command();
7486
9581
  var { CommanderError, InvalidArgumentError } = require_error();
@@ -8500,7 +10595,7 @@ async function loadOutputCodecsAsync(needed) {
8500
10595
  }));
8501
10596
  }
8502
10597
  if (needed.filter && jmespathSlot.get() === undefined) {
8503
- loads.push(Promise.resolve().then(() => __toESM(require_jmespath(), 1)).then((mod) => {
10598
+ loads.push(Promise.resolve().then(() => __toESM2(require_jmespath(), 1)).then((mod) => {
8504
10599
  jmespathSlot.set(mod);
8505
10600
  }));
8506
10601
  }
@@ -9939,7 +12034,7 @@ var OutputFormatter;
9939
12034
  }
9940
12035
  OutputFormatter2.formatToString = formatToString;
9941
12036
  })(OutputFormatter ||= {});
9942
- var import__ = __toESM(require_commander(), 1);
12037
+ var import__ = __toESM2(require_commander(), 1);
9943
12038
  var {
9944
12039
  program,
9945
12040
  createCommand,
@@ -11636,7 +13731,7 @@ function __accessProp2(key) {
11636
13731
  }
11637
13732
  var __toESMCache_node2;
11638
13733
  var __toESMCache_esm2;
11639
- var __toESM2 = (mod, isNodeMode, target) => {
13734
+ var __toESM3 = (mod, isNodeMode, target) => {
11640
13735
  var canCache = mod != null && typeof mod === "object";
11641
13736
  if (canCache) {
11642
13737
  var cache = isNodeMode ? __toESMCache_node2 ??= new WeakMap : __toESMCache_esm2 ??= new WeakMap;
@@ -11658,7 +13753,7 @@ var __toESM2 = (mod, isNodeMode, target) => {
11658
13753
  cache.set(mod, to);
11659
13754
  return to;
11660
13755
  };
11661
- var __commonJS2 = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
13756
+ var __commonJS3 = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
11662
13757
  var __returnValue3 = (v) => v;
11663
13758
  function __exportSetter3(name, newValue) {
11664
13759
  this[name] = __returnValue3.bind(null, newValue);
@@ -15695,7 +17790,7 @@ var init_js_yaml2 = __esm3(() => {
15695
17790
  safeDump: safeDump2
15696
17791
  } = yaml2);
15697
17792
  });
15698
- var require_jmespath2 = __commonJS2(function(exports) {
17793
+ var require_jmespath2 = __commonJS3(function(exports) {
15699
17794
  (function(exports2) {
15700
17795
  function isArray(obj) {
15701
17796
  if (obj !== null) {
@@ -17172,7 +19267,7 @@ var require_jmespath2 = __commonJS2(function(exports) {
17172
19267
  exports2.strictDeepEqual = strictDeepEqual;
17173
19268
  })(typeof exports === "undefined" ? exports.jmespath = {} : exports);
17174
19269
  });
17175
- var require_error2 = __commonJS2(function(exports) {
19270
+ var require_error2 = __commonJS3(function(exports) {
17176
19271
 
17177
19272
  class CommanderError2 extends Error {
17178
19273
  constructor(exitCode, code, message) {
@@ -17195,7 +19290,7 @@ var require_error2 = __commonJS2(function(exports) {
17195
19290
  exports.CommanderError = CommanderError2;
17196
19291
  exports.InvalidArgumentError = InvalidArgumentError2;
17197
19292
  });
17198
- var require_argument2 = __commonJS2(function(exports) {
19293
+ var require_argument2 = __commonJS3(function(exports) {
17199
19294
  var { InvalidArgumentError: InvalidArgumentError2 } = require_error2();
17200
19295
 
17201
19296
  class Argument2 {
@@ -17273,7 +19368,7 @@ var require_argument2 = __commonJS2(function(exports) {
17273
19368
  exports.Argument = Argument2;
17274
19369
  exports.humanReadableArgName = humanReadableArgName;
17275
19370
  });
17276
- var require_help2 = __commonJS2(function(exports) {
19371
+ var require_help2 = __commonJS3(function(exports) {
17277
19372
  var { humanReadableArgName } = require_argument2();
17278
19373
 
17279
19374
  class Help2 {
@@ -17628,7 +19723,7 @@ ${itemIndentStr}`);
17628
19723
  exports.Help = Help2;
17629
19724
  exports.stripColor = stripColor;
17630
19725
  });
17631
- var require_option2 = __commonJS2(function(exports) {
19726
+ var require_option2 = __commonJS3(function(exports) {
17632
19727
  var { InvalidArgumentError: InvalidArgumentError2 } = require_error2();
17633
19728
 
17634
19729
  class Option2 {
@@ -17810,7 +19905,7 @@ var require_option2 = __commonJS2(function(exports) {
17810
19905
  exports.Option = Option2;
17811
19906
  exports.DualOptions = DualOptions;
17812
19907
  });
17813
- var require_suggestSimilar2 = __commonJS2(function(exports) {
19908
+ var require_suggestSimilar2 = __commonJS3(function(exports) {
17814
19909
  var maxDistance = 3;
17815
19910
  function editDistance(a, b) {
17816
19911
  if (Math.abs(a.length - b.length) > maxDistance)
@@ -17881,7 +19976,7 @@ var require_suggestSimilar2 = __commonJS2(function(exports) {
17881
19976
  }
17882
19977
  exports.suggestSimilar = suggestSimilar;
17883
19978
  });
17884
- var require_command2 = __commonJS2(function(exports) {
19979
+ var require_command2 = __commonJS3(function(exports) {
17885
19980
  var EventEmitter = __require3("node:events").EventEmitter;
17886
19981
  var childProcess42 = __require3("node:child_process");
17887
19982
  var path32 = __require3("node:path");
@@ -19234,7 +21329,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
19234
21329
  exports.Command = Command2;
19235
21330
  exports.useColor = useColor;
19236
21331
  });
19237
- var require_commander2 = __commonJS2(function(exports) {
21332
+ var require_commander2 = __commonJS3(function(exports) {
19238
21333
  var { Argument: Argument2 } = require_argument2();
19239
21334
  var { Command: Command2 } = require_command2();
19240
21335
  var { CommanderError: CommanderError2, InvalidArgumentError: InvalidArgumentError2 } = require_error2();
@@ -19578,7 +21673,7 @@ function querystringSingleKey(key, value, keyPrefix = "") {
19578
21673
  var package_default2 = {
19579
21674
  name: "@uipath/solution-sdk",
19580
21675
  license: "SEE LICENSE IN LICENSE.txt",
19581
- version: "1.202.0",
21676
+ version: "1.202.0-preview.162",
19582
21677
  repository: {
19583
21678
  type: "git",
19584
21679
  url: "https://github.com/UiPath/cli.git",
@@ -20605,7 +22700,7 @@ async function loadOutputCodecsAsync2(needed) {
20605
22700
  }));
20606
22701
  }
20607
22702
  if (needed.filter && jmespathSlot2.get() === undefined) {
20608
- loads.push(Promise.resolve().then(() => __toESM2(require_jmespath2(), 1)).then((mod) => {
22703
+ loads.push(Promise.resolve().then(() => __toESM3(require_jmespath2(), 1)).then((mod) => {
20609
22704
  jmespathSlot2.set(mod);
20610
22705
  }));
20611
22706
  }
@@ -22036,7 +24131,7 @@ var OutputFormatter2;
22036
24131
  }
22037
24132
  OutputFormatter3.formatToString = formatToString;
22038
24133
  })(OutputFormatter2 ||= {});
22039
- var import__2 = __toESM2(require_commander2(), 1);
24134
+ var import__2 = __toESM3(require_commander2(), 1);
22040
24135
  var {
22041
24136
  program: program2,
22042
24137
  createCommand: createCommand2,
@@ -23165,6 +25260,49 @@ async function writeCache(cache) {
23165
25260
  await fs10.writeFile(getCacheFilePath(), JSON.stringify(cache, null, 2));
23166
25261
  }
23167
25262
 
25263
+ // src/services/js-args.ts
25264
+ var FLAGS_TO_DROP = ["--language", "-l"];
25265
+ var VERBS_OWNING_LANGUAGE = new Set(["new"]);
25266
+ var RUN_TARGET_FLAGS = ["--function", "--entrypoint"];
25267
+ function buildJsArgs(args) {
25268
+ return liftRunName(dropRouterFlags(args));
25269
+ }
25270
+ function dropRouterFlags(args) {
25271
+ if (VERBS_OWNING_LANGUAGE.has(args[0] ?? "")) {
25272
+ return args;
25273
+ }
25274
+ const kept = [];
25275
+ for (let i2 = 0;i2 < args.length; i2++) {
25276
+ const arg = args[i2] ?? "";
25277
+ if (FLAGS_TO_DROP.includes(arg)) {
25278
+ i2++;
25279
+ continue;
25280
+ }
25281
+ if (FLAGS_TO_DROP.some((flag) => arg.startsWith(`${flag}=`))) {
25282
+ continue;
25283
+ }
25284
+ kept.push(arg);
25285
+ }
25286
+ return kept;
25287
+ }
25288
+ function liftRunName(args) {
25289
+ if ((args[0] ?? "") !== "run") {
25290
+ return args;
25291
+ }
25292
+ const name = args[1];
25293
+ if (name === undefined || name.startsWith("-")) {
25294
+ return args;
25295
+ }
25296
+ const rest = args.slice(2);
25297
+ if (rest.some(namesRunTarget)) {
25298
+ return ["run", ...rest];
25299
+ }
25300
+ return ["run", "--function", name, ...rest];
25301
+ }
25302
+ function namesRunTarget(arg) {
25303
+ return RUN_TARGET_FLAGS.some((flag) => arg === flag || arg.startsWith(`${flag}=`));
25304
+ }
25305
+
23168
25306
  // src/services/utils.ts
23169
25307
  import { spawn } from "node:child_process";
23170
25308
 
@@ -26276,7 +28414,8 @@ async function spawnAndRelay(binary3, args, cwd, extraEnv = {}) {
26276
28414
  var fs12 = getFileSystem2();
26277
28415
  var AUTH_COMMANDS = new Set(["publish", "push"]);
26278
28416
  async function runJsCli(args, cwd) {
26279
- const verb = args[0] ?? "";
28417
+ const jsArgs = buildJsArgs(args);
28418
+ const verb = jsArgs[0] ?? "";
26280
28419
  if (AUTH_COMMANDS.has(verb)) {
26281
28420
  const extraEnv = await loadGlobalAuthEnv();
26282
28421
  for (const [k, v] of Object.entries(extraEnv)) {
@@ -26286,7 +28425,7 @@ async function runJsCli(args, cwd) {
26286
28425
  if (fs12.env.cwd() !== cwd) {
26287
28426
  process.chdir(cwd);
26288
28427
  }
26289
- await cliRunner(args);
28428
+ await cliRunner(jsArgs);
26290
28429
  }
26291
28430
 
26292
28431
  // src/services/language-resolver.ts
@@ -26578,6 +28717,22 @@ function registerNewCommand(program3) {
26578
28717
  program3.command("new [name]").description("Scaffold a new Functions project. " + "Includes a hello world function by default; pass --empty for an empty project.").option("--name <name>", "project name / directory — alias for positional arg (default: my-functions)").option("-l, --language <lang>", "ts (default), js — JS/TS; py or python — Python project").option("--empty", "skip the hello world function — empty project (JS/TS only)").examples(FUNCTIONS_NEW_EXAMPLES).allowUnknownOption(true).allowExcessArguments(true).trackedAction(processContext, passthrough);
26579
28718
  }
26580
28719
 
28720
+ // ../../node_modules/commander/esm.mjs
28721
+ var import__3 = __toESM(require_commander3(), 1);
28722
+ var {
28723
+ program: program3,
28724
+ createCommand: createCommand3,
28725
+ createArgument: createArgument3,
28726
+ createOption: createOption3,
28727
+ CommanderError: CommanderError3,
28728
+ InvalidArgumentError: InvalidArgumentError3,
28729
+ InvalidOptionArgumentError: InvalidOptionArgumentError3,
28730
+ Command: Command3,
28731
+ Argument: Argument3,
28732
+ Option: Option3,
28733
+ Help: Help3
28734
+ } = import__3.default;
28735
+
26581
28736
  // src/commands/pack.ts
26582
28737
  var FUNCTIONS_PACK_EXAMPLES = [
26583
28738
  {
@@ -26589,8 +28744,11 @@ var FUNCTIONS_PACK_EXAMPLES = [
26589
28744
  }
26590
28745
  }
26591
28746
  ];
26592
- function registerPackCommand(program3) {
26593
- program3.command("pack").description("Pack the project into a .nupkg for deployment").option("--nolock", "exclude lock file from the package (JS/TS)").examples(FUNCTIONS_PACK_EXAMPLES).allowUnknownOption(true).allowExcessArguments(true).trackedAction(processContext, passthrough);
28747
+ function createDeprecatedNolockOption() {
28748
+ return new Option3("--nolock", "Deprecated and ignored; the project's lock file is always packaged.").hideHelp();
28749
+ }
28750
+ function registerPackCommand(program4) {
28751
+ program4.command("pack").description("Pack the project into a .nupkg for deployment").addOption(createDeprecatedNolockOption()).examples(FUNCTIONS_PACK_EXAMPLES).allowUnknownOption(true).allowExcessArguments(true).trackedAction(processContext, passthrough);
26594
28752
  }
26595
28753
 
26596
28754
  // src/commands/publish.ts
@@ -26612,8 +28770,8 @@ var FUNCTIONS_PUBLISH_EXAMPLES = [
26612
28770
  }
26613
28771
  }
26614
28772
  ];
26615
- function registerPublishCommand(program3) {
26616
- program3.command("publish").description("Upload the latest .nupkg to an Orchestrator folder. " + "Fetches available feeds and prompts for selection; ESC to cancel. " + "Use --feed-id to skip the picker (CI use).").option("--url <url>", "UiPath platform URL (or UIPATH_URL env)").option("--org <org>", "organization name (or UIPATH_ORGANIZATION_NAME env)").addOption(createHiddenDeprecatedTenantOption("--tenant <tenant>")).option("--token <token>", "access token (or UIPATH_ACCESS_TOKEN env)").option("--feed-id <id>", "feed ID — skips the interactive picker (CI use)").examples(FUNCTIONS_PUBLISH_EXAMPLES).allowUnknownOption(true).allowExcessArguments(true).trackedAction(processContext, passthrough);
28773
+ function registerPublishCommand(program4) {
28774
+ program4.command("publish").description("Upload the latest .nupkg to an Orchestrator folder. " + "Fetches available feeds and prompts for selection; ESC to cancel. " + "Use --feed-id to skip the picker (CI use).").option("--url <url>", "UiPath platform URL (or UIPATH_URL env)").option("--org <org>", "organization name (or UIPATH_ORGANIZATION_NAME env)").addOption(createHiddenDeprecatedTenantOption("--tenant <tenant>")).option("--token <token>", "access token (or UIPATH_ACCESS_TOKEN env)").option("--feed-id <id>", "feed ID — skips the interactive picker (CI use)").examples(FUNCTIONS_PUBLISH_EXAMPLES).allowUnknownOption(true).allowExcessArguments(true).trackedAction(processContext, passthrough);
26617
28775
  }
26618
28776
 
26619
28777
  // src/commands/push.ts
@@ -26629,23 +28787,31 @@ var FUNCTIONS_PUSH_EXAMPLES = [
26629
28787
  }
26630
28788
  }
26631
28789
  ];
26632
- function registerPushCommand(program3) {
26633
- program3.command("push").description("Sync project to Studio Web (generate entry-points + upload changed files)").option("--url <url>", "UiPath platform URL (or UIPATH_URL env)").option("--project-id <id>", "Studio Web project ID — mandatory (or UIPATH_PROJECT_ID env)").option("--org <org>", "organization name (or UIPATH_ORGANIZATION_NAME env)").addOption(createHiddenDeprecatedTenantOption("--tenant <tenant>")).option("--token <token>", "access token (or UIPATH_ACCESS_TOKEN env)").examples(FUNCTIONS_PUSH_EXAMPLES).allowUnknownOption(true).allowExcessArguments(true).trackedAction(processContext, passthrough);
28790
+ function registerPushCommand(program4) {
28791
+ program4.command("push").description("Sync project to Studio Web (generate entry-points + upload changed files)").option("--url <url>", "UiPath platform URL (or UIPATH_URL env)").option("--project-id <id>", "Studio Web project ID — mandatory (or UIPATH_PROJECT_ID env)").option("--org <org>", "organization name (or UIPATH_ORGANIZATION_NAME env)").addOption(createHiddenDeprecatedTenantOption("--tenant <tenant>")).option("--token <token>", "access token (or UIPATH_ACCESS_TOKEN env)").examples(FUNCTIONS_PUSH_EXAMPLES).allowUnknownOption(true).allowExcessArguments(true).trackedAction(processContext, passthrough);
26634
28792
  }
26635
28793
 
26636
28794
  // src/commands/run.ts
26637
28795
  var FUNCTIONS_RUN_EXAMPLES = [
26638
28796
  {
26639
- Description: "Invoke the 'hello' function on the local serve endpoint with a JSON payload",
26640
- Command: `uip function run hello --input '{"x":1}'`,
28797
+ Description: "Run the 'hello' function once with a JSON payload",
28798
+ Command: `uip function run hello --input '{"name":"Ada"}'`,
28799
+ Output: {
28800
+ Code: "RunComplete",
28801
+ Data: { message: "Hello, Ada!" }
28802
+ }
28803
+ },
28804
+ {
28805
+ Description: "Run a function with a payload kept in a file",
28806
+ Command: "uip function run hello --input-file ./payload.json",
26641
28807
  Output: {
26642
28808
  Code: "RunComplete",
26643
- Data: { result: 2 }
28809
+ Data: { message: "Hello, Ada!" }
26644
28810
  }
26645
28811
  }
26646
28812
  ];
26647
- function registerRunCommand(program3) {
26648
- program3.command("run <name>").description("Invoke a function against the local serve endpoint (JS/TS)").option("--port <port>", "port the local server is on (default: 7070)").option("--input <json>", "JSON input payload (default: {})").examples(FUNCTIONS_RUN_EXAMPLES).allowUnknownOption(true).allowExcessArguments(true).trackedAction(processContext, passthrough);
28813
+ function registerRunCommand(program4) {
28814
+ program4.command("run [name]").description("Run one function once and print its result. " + "The name comes from your project's function list.").option("--input <json>", "JSON input payload (default: {})").option("--input-file <path>", "path to a JSON input file — wins over --input (JS/TS)").examples(FUNCTIONS_RUN_EXAMPLES).allowUnknownOption(true).allowExcessArguments(true).trackedAction(processContext, passthrough);
26649
28815
  }
26650
28816
 
26651
28817
  // src/commands/runtime-install.ts
@@ -26659,8 +28825,8 @@ var FUNCTIONS_RUNTIME_INSTALL_EXAMPLES = [
26659
28825
  }
26660
28826
  }
26661
28827
  ];
26662
- function registerRuntimeInstallCommand(program3) {
26663
- program3.command("runtime-install").description("Create a runner folder with a package.json and install runtime dependencies (JS/TS only)").option("--path <folder>", "target folder to create and install runtime deps into").examples(FUNCTIONS_RUNTIME_INSTALL_EXAMPLES).allowUnknownOption(true).allowExcessArguments(true).trackedAction(processContext, passthrough);
28828
+ function registerRuntimeInstallCommand(program4) {
28829
+ program4.command("runtime-install").description("Create a runner folder with a package.json and install runtime dependencies (JS/TS only)").option("--path <folder>", "target folder to create and install runtime deps into").examples(FUNCTIONS_RUNTIME_INSTALL_EXAMPLES).allowUnknownOption(true).allowExcessArguments(true).trackedAction(processContext, passthrough);
26664
28830
  }
26665
28831
 
26666
28832
  // src/commands/serve.ts
@@ -26674,8 +28840,8 @@ var FUNCTIONS_SERVE_EXAMPLES = [
26674
28840
  }
26675
28841
  }
26676
28842
  ];
26677
- function registerServeCommand(program3) {
26678
- program3.command("serve").description("Start the local function server with hot reload (JS/TS only)").option("--port <port>", "port to listen on (default: 7070)").option("--runtime <runtime>", "node (default) or deno").examples(FUNCTIONS_SERVE_EXAMPLES).allowUnknownOption(true).allowExcessArguments(true).trackedAction(processContext, passthrough);
28843
+ function registerServeCommand(program4) {
28844
+ program4.command("serve").description("Start the local function server with hot reload (JS/TS only)").option("--port <port>", "port to listen on (default: 7070)").option("--runtime <runtime>", "node (default) or deno").examples(FUNCTIONS_SERVE_EXAMPLES).allowUnknownOption(true).allowExcessArguments(true).trackedAction(processContext, passthrough);
26679
28845
  }
26680
28846
 
26681
28847
  // src/tool.ts
@@ -26685,20 +28851,20 @@ var metadata = {
26685
28851
  description: "Build, serve, and publish UiPath JS/TS and Python Functions.",
26686
28852
  commandPrefix: "function"
26687
28853
  };
26688
- var registerCommands = async (program3) => {
26689
- registerSetupCommand(program3);
26690
- registerInitCommand(program3);
26691
- registerNewCommand(program3);
26692
- registerServeCommand(program3);
26693
- registerPackCommand(program3);
26694
- registerPublishCommand(program3);
26695
- registerPushCommand(program3);
26696
- registerRunCommand(program3);
26697
- registerRuntimeInstallCommand(program3);
28854
+ var registerCommands = async (program4) => {
28855
+ registerSetupCommand(program4);
28856
+ registerInitCommand(program4);
28857
+ registerNewCommand(program4);
28858
+ registerServeCommand(program4);
28859
+ registerPackCommand(program4);
28860
+ registerPublishCommand(program4);
28861
+ registerPushCommand(program4);
28862
+ registerRunCommand(program4);
28863
+ registerRuntimeInstallCommand(program4);
26698
28864
  };
26699
28865
  export {
26700
28866
  metadata,
26701
28867
  registerCommands
26702
28868
  };
26703
28869
 
26704
- //# debugId=D15553870CE4B24D64756E2164756E21
28870
+ //# debugId=C571B4BBECA4F66364756E2164756E21