@uipath/vertical-solutions-tool 1.0.2 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/tool.js +1749 -1669
  2. package/package.json +5 -13
package/dist/tool.js CHANGED
@@ -46,533 +46,837 @@ var __export = (target, all) => {
46
46
  var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
47
47
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
48
48
 
49
- // ../../node_modules/commander/lib/error.js
50
- var require_error = __commonJS((exports) => {
51
- class CommanderError extends Error {
52
- constructor(exitCode, code, message) {
53
- super(message);
54
- Error.captureStackTrace(this, this.constructor);
55
- this.name = this.constructor.name;
56
- this.code = code;
57
- this.exitCode = exitCode;
58
- this.nestedError = undefined;
59
- }
49
+ // ../../node_modules/is-inside-container/node_modules/is-docker/index.js
50
+ import fs from "node:fs";
51
+ function hasDockerEnv() {
52
+ try {
53
+ fs.statSync("/.dockerenv");
54
+ return true;
55
+ } catch {
56
+ return false;
57
+ }
58
+ }
59
+ function hasDockerCGroup() {
60
+ try {
61
+ return fs.readFileSync("/proc/self/cgroup", "utf8").includes("docker");
62
+ } catch {
63
+ return false;
64
+ }
65
+ }
66
+ function isDocker() {
67
+ if (isDockerCached === undefined) {
68
+ isDockerCached = hasDockerEnv() || hasDockerCGroup();
60
69
  }
70
+ return isDockerCached;
71
+ }
72
+ var isDockerCached;
73
+ var init_is_docker = () => {};
61
74
 
62
- class InvalidArgumentError extends CommanderError {
63
- constructor(message) {
64
- super(1, "commander.invalidArgument", message);
65
- Error.captureStackTrace(this, this.constructor);
66
- this.name = this.constructor.name;
67
- }
75
+ // ../../node_modules/is-inside-container/index.js
76
+ import fs2 from "node:fs";
77
+ function isInsideContainer() {
78
+ if (cachedResult === undefined) {
79
+ cachedResult = hasContainerEnv() || isDocker();
68
80
  }
69
- exports.CommanderError = CommanderError;
70
- exports.InvalidArgumentError = InvalidArgumentError;
81
+ return cachedResult;
82
+ }
83
+ var cachedResult, hasContainerEnv = () => {
84
+ try {
85
+ fs2.statSync("/run/.containerenv");
86
+ return true;
87
+ } catch {
88
+ return false;
89
+ }
90
+ };
91
+ var init_is_inside_container = __esm(() => {
92
+ init_is_docker();
71
93
  });
72
94
 
73
- // ../../node_modules/commander/lib/argument.js
74
- var require_argument = __commonJS((exports) => {
75
- var { InvalidArgumentError } = require_error();
76
-
77
- class Argument {
78
- constructor(name, description) {
79
- this.description = description || "";
80
- this.variadic = false;
81
- this.parseArg = undefined;
82
- this.defaultValue = undefined;
83
- this.defaultValueDescription = undefined;
84
- this.argChoices = undefined;
85
- switch (name[0]) {
86
- case "<":
87
- this.required = true;
88
- this._name = name.slice(1, -1);
89
- break;
90
- case "[":
91
- this.required = false;
92
- this._name = name.slice(1, -1);
93
- break;
94
- default:
95
- this.required = true;
96
- this._name = name;
97
- break;
98
- }
99
- if (this._name.endsWith("...")) {
100
- this.variadic = true;
101
- this._name = this._name.slice(0, -3);
102
- }
103
- }
104
- name() {
105
- return this._name;
106
- }
107
- _collectValue(value, previous) {
108
- if (previous === this.defaultValue || !Array.isArray(previous)) {
109
- return [value];
110
- }
111
- previous.push(value);
112
- return previous;
113
- }
114
- default(value, description) {
115
- this.defaultValue = value;
116
- this.defaultValueDescription = description;
117
- return this;
118
- }
119
- argParser(fn) {
120
- this.parseArg = fn;
121
- return this;
122
- }
123
- choices(values) {
124
- this.argChoices = values.slice();
125
- this.parseArg = (arg, previous) => {
126
- if (!this.argChoices.includes(arg)) {
127
- throw new InvalidArgumentError(`Allowed choices are ${this.argChoices.join(", ")}.`);
128
- }
129
- if (this.variadic) {
130
- return this._collectValue(arg, previous);
131
- }
132
- return arg;
133
- };
134
- return this;
135
- }
136
- argRequired() {
137
- this.required = true;
138
- return this;
139
- }
140
- argOptional() {
141
- this.required = false;
142
- return this;
95
+ // ../../node_modules/wsl-utils/node_modules/is-wsl/index.js
96
+ import process2 from "node:process";
97
+ import os from "node:os";
98
+ import fs3 from "node:fs";
99
+ var isWsl = () => {
100
+ if (process2.platform !== "linux") {
101
+ return false;
102
+ }
103
+ if (os.release().toLowerCase().includes("microsoft")) {
104
+ if (isInsideContainer()) {
105
+ return false;
143
106
  }
107
+ return true;
144
108
  }
145
- function humanReadableArgName(arg) {
146
- const nameOutput = arg.name() + (arg.variadic === true ? "..." : "");
147
- return arg.required ? "<" + nameOutput + ">" : "[" + nameOutput + "]";
109
+ try {
110
+ if (fs3.readFileSync("/proc/version", "utf8").toLowerCase().includes("microsoft")) {
111
+ return !isInsideContainer();
112
+ }
113
+ } catch {}
114
+ if (fs3.existsSync("/proc/sys/fs/binfmt_misc/WSLInterop") || fs3.existsSync("/run/WSL")) {
115
+ return !isInsideContainer();
148
116
  }
149
- exports.Argument = Argument;
150
- exports.humanReadableArgName = humanReadableArgName;
117
+ return false;
118
+ }, is_wsl_default;
119
+ var init_is_wsl = __esm(() => {
120
+ init_is_inside_container();
121
+ is_wsl_default = process2.env.__IS_WSL_TEST__ ? isWsl : isWsl();
151
122
  });
152
123
 
153
- // ../../node_modules/commander/lib/help.js
154
- var require_help = __commonJS((exports) => {
155
- var { humanReadableArgName } = require_argument();
124
+ // ../../node_modules/powershell-utils/index.js
125
+ import process3 from "node:process";
126
+ import { Buffer as Buffer2 } from "node:buffer";
127
+ import { promisify } from "node:util";
128
+ import childProcess from "node:child_process";
129
+ var execFile, powerShellPath = () => `${process3.env.SYSTEMROOT || process3.env.windir || String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`, executePowerShell = async (command, options = {}) => {
130
+ const {
131
+ powerShellPath: psPath,
132
+ ...execFileOptions
133
+ } = options;
134
+ const encodedCommand = executePowerShell.encodeCommand(command);
135
+ return execFile(psPath ?? powerShellPath(), [
136
+ ...executePowerShell.argumentsPrefix,
137
+ encodedCommand
138
+ ], {
139
+ encoding: "utf8",
140
+ ...execFileOptions
141
+ });
142
+ };
143
+ var init_powershell_utils = __esm(() => {
144
+ execFile = promisify(childProcess.execFile);
145
+ executePowerShell.argumentsPrefix = [
146
+ "-NoProfile",
147
+ "-NonInteractive",
148
+ "-ExecutionPolicy",
149
+ "Bypass",
150
+ "-EncodedCommand"
151
+ ];
152
+ executePowerShell.encodeCommand = (command) => Buffer2.from(command, "utf16le").toString("base64");
153
+ executePowerShell.escapeArgument = (value) => `'${String(value).replaceAll("'", "''")}'`;
154
+ });
156
155
 
157
- class Help {
158
- constructor() {
159
- this.helpWidth = undefined;
160
- this.minWidthToWrap = 40;
161
- this.sortSubcommands = false;
162
- this.sortOptions = false;
163
- this.showGlobalOptions = false;
164
- }
165
- prepareContext(contextOptions) {
166
- this.helpWidth = this.helpWidth ?? contextOptions.helpWidth ?? 80;
167
- }
168
- visibleCommands(cmd) {
169
- const visibleCommands = cmd.commands.filter((cmd2) => !cmd2._hidden);
170
- const helpCommand = cmd._getHelpCommand();
171
- if (helpCommand && !helpCommand._hidden) {
172
- visibleCommands.push(helpCommand);
173
- }
174
- if (this.sortSubcommands) {
175
- visibleCommands.sort((a, b) => {
176
- return a.name().localeCompare(b.name());
177
- });
178
- }
179
- return visibleCommands;
180
- }
181
- compareOptions(a, b) {
182
- const getSortKey = (option) => {
183
- return option.short ? option.short.replace(/^-/, "") : option.long.replace(/^--/, "");
184
- };
185
- return getSortKey(a).localeCompare(getSortKey(b));
186
- }
187
- visibleOptions(cmd) {
188
- const visibleOptions = cmd.options.filter((option) => !option.hidden);
189
- const helpOption = cmd._getHelpOption();
190
- if (helpOption && !helpOption.hidden) {
191
- const removeShort = helpOption.short && cmd._findOption(helpOption.short);
192
- const removeLong = helpOption.long && cmd._findOption(helpOption.long);
193
- if (!removeShort && !removeLong) {
194
- visibleOptions.push(helpOption);
195
- } else if (helpOption.long && !removeLong) {
196
- visibleOptions.push(cmd.createOption(helpOption.long, helpOption.description));
197
- } else if (helpOption.short && !removeShort) {
198
- visibleOptions.push(cmd.createOption(helpOption.short, helpOption.description));
199
- }
200
- }
201
- if (this.sortOptions) {
202
- visibleOptions.sort(this.compareOptions);
203
- }
204
- return visibleOptions;
205
- }
206
- visibleGlobalOptions(cmd) {
207
- if (!this.showGlobalOptions)
208
- return [];
209
- const globalOptions = [];
210
- for (let ancestorCmd = cmd.parent;ancestorCmd; ancestorCmd = ancestorCmd.parent) {
211
- const visibleOptions = ancestorCmd.options.filter((option) => !option.hidden);
212
- globalOptions.push(...visibleOptions);
213
- }
214
- if (this.sortOptions) {
215
- globalOptions.sort(this.compareOptions);
216
- }
217
- return globalOptions;
218
- }
219
- visibleArguments(cmd) {
220
- if (cmd._argsDescription) {
221
- cmd.registeredArguments.forEach((argument) => {
222
- argument.description = argument.description || cmd._argsDescription[argument.name()] || "";
223
- });
224
- }
225
- if (cmd.registeredArguments.find((argument) => argument.description)) {
226
- return cmd.registeredArguments;
227
- }
228
- return [];
229
- }
230
- subcommandTerm(cmd) {
231
- const args = cmd.registeredArguments.map((arg) => humanReadableArgName(arg)).join(" ");
232
- return cmd._name + (cmd._aliases[0] ? "|" + cmd._aliases[0] : "") + (cmd.options.length ? " [options]" : "") + (args ? " " + args : "");
233
- }
234
- optionTerm(option) {
235
- return option.flags;
236
- }
237
- argumentTerm(argument) {
238
- return argument.name();
239
- }
240
- longestSubcommandTermLength(cmd, helper) {
241
- return helper.visibleCommands(cmd).reduce((max, command) => {
242
- return Math.max(max, this.displayWidth(helper.styleSubcommandTerm(helper.subcommandTerm(command))));
243
- }, 0);
244
- }
245
- longestOptionTermLength(cmd, helper) {
246
- return helper.visibleOptions(cmd).reduce((max, option) => {
247
- return Math.max(max, this.displayWidth(helper.styleOptionTerm(helper.optionTerm(option))));
248
- }, 0);
249
- }
250
- longestGlobalOptionTermLength(cmd, helper) {
251
- return helper.visibleGlobalOptions(cmd).reduce((max, option) => {
252
- return Math.max(max, this.displayWidth(helper.styleOptionTerm(helper.optionTerm(option))));
253
- }, 0);
254
- }
255
- longestArgumentTermLength(cmd, helper) {
256
- return helper.visibleArguments(cmd).reduce((max, argument) => {
257
- return Math.max(max, this.displayWidth(helper.styleArgumentTerm(helper.argumentTerm(argument))));
258
- }, 0);
259
- }
260
- commandUsage(cmd) {
261
- let cmdName = cmd._name;
262
- if (cmd._aliases[0]) {
263
- cmdName = cmdName + "|" + cmd._aliases[0];
264
- }
265
- let ancestorCmdNames = "";
266
- for (let ancestorCmd = cmd.parent;ancestorCmd; ancestorCmd = ancestorCmd.parent) {
267
- ancestorCmdNames = ancestorCmd.name() + " " + ancestorCmdNames;
268
- }
269
- return ancestorCmdNames + cmdName + " " + cmd.usage();
270
- }
271
- commandDescription(cmd) {
272
- return cmd.description();
156
+ // ../../node_modules/wsl-utils/utilities.js
157
+ function parseMountPointFromConfig(content) {
158
+ for (const line of content.split(`
159
+ `)) {
160
+ if (/^\s*#/.test(line)) {
161
+ continue;
273
162
  }
274
- subcommandDescription(cmd) {
275
- return cmd.summary() || cmd.description();
163
+ const match = /^\s*root\s*=\s*(?<mountPoint>"[^"]*"|'[^']*'|[^#]*)/.exec(line);
164
+ if (!match) {
165
+ continue;
276
166
  }
277
- optionDescription(option) {
278
- const extraInfo = [];
279
- if (option.argChoices) {
280
- extraInfo.push(`choices: ${option.argChoices.map((choice) => JSON.stringify(choice)).join(", ")}`);
281
- }
282
- if (option.defaultValue !== undefined) {
283
- const showDefault = option.required || option.optional || option.isBoolean() && typeof option.defaultValue === "boolean";
284
- if (showDefault) {
285
- extraInfo.push(`default: ${option.defaultValueDescription || JSON.stringify(option.defaultValue)}`);
286
- }
287
- }
288
- if (option.presetArg !== undefined && option.optional) {
289
- extraInfo.push(`preset: ${JSON.stringify(option.presetArg)}`);
290
- }
291
- if (option.envVar !== undefined) {
292
- extraInfo.push(`env: ${option.envVar}`);
293
- }
294
- if (extraInfo.length > 0) {
295
- const extraDescription = `(${extraInfo.join(", ")})`;
296
- if (option.description) {
297
- return `${option.description} ${extraDescription}`;
298
- }
299
- return extraDescription;
300
- }
301
- return option.description;
167
+ return match.groups.mountPoint.trim().replaceAll(/^["']|["']$/g, "");
168
+ }
169
+ }
170
+
171
+ // ../../node_modules/wsl-utils/index.js
172
+ import { promisify as promisify2 } from "node:util";
173
+ import childProcess2 from "node:child_process";
174
+ import fs4, { constants as fsConstants } from "node:fs/promises";
175
+ var execFile2, wslDrivesMountPoint, powerShellPathFromWsl = async () => {
176
+ const mountPoint = await wslDrivesMountPoint();
177
+ return `${mountPoint}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`;
178
+ }, powerShellPath2, canAccessPowerShellPromise, canAccessPowerShell = async () => {
179
+ canAccessPowerShellPromise ??= (async () => {
180
+ try {
181
+ const psPath = await powerShellPath2();
182
+ await fs4.access(psPath, fsConstants.X_OK);
183
+ return true;
184
+ } catch {
185
+ return false;
302
186
  }
303
- argumentDescription(argument) {
304
- const extraInfo = [];
305
- if (argument.argChoices) {
306
- extraInfo.push(`choices: ${argument.argChoices.map((choice) => JSON.stringify(choice)).join(", ")}`);
187
+ })();
188
+ return canAccessPowerShellPromise;
189
+ }, wslDefaultBrowser = async () => {
190
+ const psPath = await powerShellPath2();
191
+ const command = String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`;
192
+ const { stdout } = await executePowerShell(command, { powerShellPath: psPath });
193
+ return stdout.trim();
194
+ }, convertWslPathToWindows = async (path) => {
195
+ if (/^[a-z]+:\/\//i.test(path)) {
196
+ return path;
197
+ }
198
+ try {
199
+ const { stdout } = await execFile2("wslpath", ["-aw", path], { encoding: "utf8" });
200
+ return stdout.trim();
201
+ } catch {
202
+ return path;
203
+ }
204
+ };
205
+ var init_wsl_utils = __esm(() => {
206
+ init_is_wsl();
207
+ init_powershell_utils();
208
+ init_is_wsl();
209
+ execFile2 = promisify2(childProcess2.execFile);
210
+ wslDrivesMountPoint = (() => {
211
+ const defaultMountPoint = "/mnt/";
212
+ let mountPoint;
213
+ return async function() {
214
+ if (mountPoint) {
215
+ return mountPoint;
307
216
  }
308
- if (argument.defaultValue !== undefined) {
309
- extraInfo.push(`default: ${argument.defaultValueDescription || JSON.stringify(argument.defaultValue)}`);
217
+ const configFilePath = "/etc/wsl.conf";
218
+ let isConfigFileExists = false;
219
+ try {
220
+ await fs4.access(configFilePath, fsConstants.F_OK);
221
+ isConfigFileExists = true;
222
+ } catch {}
223
+ if (!isConfigFileExists) {
224
+ return defaultMountPoint;
310
225
  }
311
- if (extraInfo.length > 0) {
312
- const extraDescription = `(${extraInfo.join(", ")})`;
313
- if (argument.description) {
314
- return `${argument.description} ${extraDescription}`;
315
- }
316
- return extraDescription;
226
+ const configContent = await fs4.readFile(configFilePath, { encoding: "utf8" });
227
+ const parsedMountPoint = parseMountPointFromConfig(configContent);
228
+ if (parsedMountPoint === undefined) {
229
+ return defaultMountPoint;
317
230
  }
318
- return argument.description;
319
- }
320
- formatItemList(heading, items, helper) {
321
- if (items.length === 0)
322
- return [];
323
- return [helper.styleTitle(heading), ...items, ""];
324
- }
325
- groupItems(unsortedItems, visibleItems, getGroup) {
326
- const result = new Map;
327
- unsortedItems.forEach((item) => {
328
- const group = getGroup(item);
329
- if (!result.has(group))
330
- result.set(group, []);
331
- });
332
- visibleItems.forEach((item) => {
333
- const group = getGroup(item);
334
- if (!result.has(group)) {
335
- result.set(group, []);
336
- }
337
- result.get(group).push(item);
338
- });
231
+ mountPoint = parsedMountPoint;
232
+ mountPoint = mountPoint.endsWith("/") ? mountPoint : `${mountPoint}/`;
233
+ return mountPoint;
234
+ };
235
+ })();
236
+ powerShellPath2 = is_wsl_default ? powerShellPathFromWsl : powerShellPath;
237
+ });
238
+
239
+ // ../../node_modules/open/node_modules/define-lazy-prop/index.js
240
+ function defineLazyProperty(object, propertyName, valueGetter) {
241
+ const define2 = (value) => Object.defineProperty(object, propertyName, { value, enumerable: true, writable: true });
242
+ Object.defineProperty(object, propertyName, {
243
+ configurable: true,
244
+ enumerable: true,
245
+ get() {
246
+ const result = valueGetter();
247
+ define2(result);
339
248
  return result;
249
+ },
250
+ set(value) {
251
+ define2(value);
340
252
  }
341
- formatHelp(cmd, helper) {
342
- const termWidth = helper.padWidth(cmd, helper);
343
- const helpWidth = helper.helpWidth ?? 80;
344
- function callFormatItem(term, description) {
345
- return helper.formatItem(term, termWidth, description, helper);
346
- }
347
- let output = [
348
- `${helper.styleTitle("Usage:")} ${helper.styleUsage(helper.commandUsage(cmd))}`,
349
- ""
350
- ];
351
- const commandDescription = helper.commandDescription(cmd);
352
- if (commandDescription.length > 0) {
353
- output = output.concat([
354
- helper.boxWrap(helper.styleCommandDescription(commandDescription), helpWidth),
355
- ""
356
- ]);
357
- }
358
- const argumentList = helper.visibleArguments(cmd).map((argument) => {
359
- return callFormatItem(helper.styleArgumentTerm(helper.argumentTerm(argument)), helper.styleArgumentDescription(helper.argumentDescription(argument)));
360
- });
361
- output = output.concat(this.formatItemList("Arguments:", argumentList, helper));
362
- const optionGroups = this.groupItems(cmd.options, helper.visibleOptions(cmd), (option) => option.helpGroupHeading ?? "Options:");
363
- optionGroups.forEach((options, group) => {
364
- const optionList = options.map((option) => {
365
- return callFormatItem(helper.styleOptionTerm(helper.optionTerm(option)), helper.styleOptionDescription(helper.optionDescription(option)));
366
- });
367
- output = output.concat(this.formatItemList(group, optionList, helper));
368
- });
369
- if (helper.showGlobalOptions) {
370
- const globalOptionList = helper.visibleGlobalOptions(cmd).map((option) => {
371
- return callFormatItem(helper.styleOptionTerm(helper.optionTerm(option)), helper.styleOptionDescription(helper.optionDescription(option)));
372
- });
373
- output = output.concat(this.formatItemList("Global Options:", globalOptionList, helper));
374
- }
375
- const commandGroups = this.groupItems(cmd.commands, helper.visibleCommands(cmd), (sub) => sub.helpGroup() || "Commands:");
376
- commandGroups.forEach((commands, group) => {
377
- const commandList = commands.map((sub) => {
378
- return callFormatItem(helper.styleSubcommandTerm(helper.subcommandTerm(sub)), helper.styleSubcommandDescription(helper.subcommandDescription(sub)));
379
- });
380
- output = output.concat(this.formatItemList(group, commandList, helper));
381
- });
382
- return output.join(`
383
- `);
384
- }
385
- displayWidth(str) {
386
- return stripColor(str).length;
387
- }
388
- styleTitle(str) {
389
- return str;
390
- }
391
- styleUsage(str) {
392
- return str.split(" ").map((word) => {
393
- if (word === "[options]")
394
- return this.styleOptionText(word);
395
- if (word === "[command]")
396
- return this.styleSubcommandText(word);
397
- if (word[0] === "[" || word[0] === "<")
398
- return this.styleArgumentText(word);
399
- return this.styleCommandText(word);
400
- }).join(" ");
253
+ });
254
+ return object;
255
+ }
256
+
257
+ // ../../node_modules/default-browser-id/index.js
258
+ import { promisify as promisify3 } from "node:util";
259
+ import process4 from "node:process";
260
+ import { execFile as execFile3 } from "node:child_process";
261
+ async function defaultBrowserId() {
262
+ if (process4.platform !== "darwin") {
263
+ throw new Error("macOS only");
264
+ }
265
+ const { stdout } = await execFileAsync("defaults", ["read", "com.apple.LaunchServices/com.apple.launchservices.secure", "LSHandlers"]);
266
+ const match = /LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(stdout);
267
+ const browserId = match?.groups.id ?? "com.apple.Safari";
268
+ if (browserId === "com.apple.safari") {
269
+ return "com.apple.Safari";
270
+ }
271
+ return browserId;
272
+ }
273
+ var execFileAsync;
274
+ var init_default_browser_id = __esm(() => {
275
+ execFileAsync = promisify3(execFile3);
276
+ });
277
+
278
+ // ../../node_modules/run-applescript/index.js
279
+ import process5 from "node:process";
280
+ import { promisify as promisify4 } from "node:util";
281
+ import { execFile as execFile4, execFileSync } from "node:child_process";
282
+ async function runAppleScript(script, { humanReadableOutput = true, signal } = {}) {
283
+ if (process5.platform !== "darwin") {
284
+ throw new Error("macOS only");
285
+ }
286
+ const outputArguments = humanReadableOutput ? [] : ["-ss"];
287
+ const execOptions = {};
288
+ if (signal) {
289
+ execOptions.signal = signal;
290
+ }
291
+ const { stdout } = await execFileAsync2("osascript", ["-e", script, outputArguments], execOptions);
292
+ return stdout.trim();
293
+ }
294
+ var execFileAsync2;
295
+ var init_run_applescript = __esm(() => {
296
+ execFileAsync2 = promisify4(execFile4);
297
+ });
298
+
299
+ // ../../node_modules/bundle-name/index.js
300
+ async function bundleName(bundleId) {
301
+ return runAppleScript(`tell application "Finder" to set app_path to application file id "${bundleId}" as string
302
+ tell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`);
303
+ }
304
+ var init_bundle_name = __esm(() => {
305
+ init_run_applescript();
306
+ });
307
+
308
+ // ../../node_modules/default-browser/windows.js
309
+ import { promisify as promisify5 } from "node:util";
310
+ import { execFile as execFile5 } from "node:child_process";
311
+ async function defaultBrowser(_execFileAsync = execFileAsync3) {
312
+ const { stdout } = await _execFileAsync("reg", [
313
+ "QUERY",
314
+ " HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice",
315
+ "/v",
316
+ "ProgId"
317
+ ]);
318
+ const match = /ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(stdout);
319
+ if (!match) {
320
+ throw new UnknownBrowserError(`Cannot find Windows browser in stdout: ${JSON.stringify(stdout)}`);
321
+ }
322
+ const { id } = match.groups;
323
+ const dotIndex = id.lastIndexOf(".");
324
+ const hyphenIndex = id.lastIndexOf("-");
325
+ const baseIdByDot = dotIndex === -1 ? undefined : id.slice(0, dotIndex);
326
+ const baseIdByHyphen = hyphenIndex === -1 ? undefined : id.slice(0, hyphenIndex);
327
+ return windowsBrowserProgIds[id] ?? windowsBrowserProgIds[baseIdByDot] ?? windowsBrowserProgIds[baseIdByHyphen] ?? { name: id, id };
328
+ }
329
+ var execFileAsync3, windowsBrowserProgIds, _windowsBrowserProgIdMap, UnknownBrowserError;
330
+ var init_windows = __esm(() => {
331
+ execFileAsync3 = promisify5(execFile5);
332
+ windowsBrowserProgIds = {
333
+ MSEdgeHTM: { name: "Edge", id: "com.microsoft.edge" },
334
+ MSEdgeBHTML: { name: "Edge Beta", id: "com.microsoft.edge.beta" },
335
+ MSEdgeDHTML: { name: "Edge Dev", id: "com.microsoft.edge.dev" },
336
+ AppXq0fevzme2pys62n3e0fbqa7peapykr8v: { name: "Edge", id: "com.microsoft.edge.old" },
337
+ ChromeHTML: { name: "Chrome", id: "com.google.chrome" },
338
+ ChromeBHTML: { name: "Chrome Beta", id: "com.google.chrome.beta" },
339
+ ChromeDHTML: { name: "Chrome Dev", id: "com.google.chrome.dev" },
340
+ ChromiumHTM: { name: "Chromium", id: "org.chromium.Chromium" },
341
+ BraveHTML: { name: "Brave", id: "com.brave.Browser" },
342
+ BraveBHTML: { name: "Brave Beta", id: "com.brave.Browser.beta" },
343
+ BraveDHTML: { name: "Brave Dev", id: "com.brave.Browser.dev" },
344
+ BraveSSHTM: { name: "Brave Nightly", id: "com.brave.Browser.nightly" },
345
+ FirefoxURL: { name: "Firefox", id: "org.mozilla.firefox" },
346
+ OperaStable: { name: "Opera", id: "com.operasoftware.Opera" },
347
+ VivaldiHTM: { name: "Vivaldi", id: "com.vivaldi.Vivaldi" },
348
+ "IE.HTTP": { name: "Internet Explorer", id: "com.microsoft.ie" }
349
+ };
350
+ _windowsBrowserProgIdMap = new Map(Object.entries(windowsBrowserProgIds));
351
+ UnknownBrowserError = class UnknownBrowserError extends Error {
352
+ };
353
+ });
354
+
355
+ // ../../node_modules/default-browser/index.js
356
+ import { promisify as promisify6 } from "node:util";
357
+ import process6 from "node:process";
358
+ import { execFile as execFile6 } from "node:child_process";
359
+ async function defaultBrowser2() {
360
+ if (process6.platform === "darwin") {
361
+ const id = await defaultBrowserId();
362
+ const name = await bundleName(id);
363
+ return { name, id };
364
+ }
365
+ if (process6.platform === "linux") {
366
+ const { stdout } = await execFileAsync4("xdg-mime", ["query", "default", "x-scheme-handler/http"]);
367
+ const id = stdout.trim();
368
+ const name = titleize(id.replace(/.desktop$/, "").replace("-", " "));
369
+ return { name, id };
370
+ }
371
+ if (process6.platform === "win32") {
372
+ return defaultBrowser();
373
+ }
374
+ throw new Error("Only macOS, Linux, and Windows are supported");
375
+ }
376
+ var execFileAsync4, titleize = (string) => string.toLowerCase().replaceAll(/(?:^|\s|-)\S/g, (x) => x.toUpperCase());
377
+ var init_default_browser = __esm(() => {
378
+ init_default_browser_id();
379
+ init_bundle_name();
380
+ init_windows();
381
+ init_windows();
382
+ execFileAsync4 = promisify6(execFile6);
383
+ });
384
+
385
+ // ../../node_modules/is-in-ssh/index.js
386
+ import process7 from "node:process";
387
+ var isInSsh, is_in_ssh_default;
388
+ var init_is_in_ssh = __esm(() => {
389
+ isInSsh = Boolean(process7.env.SSH_CONNECTION || process7.env.SSH_CLIENT || process7.env.SSH_TTY);
390
+ is_in_ssh_default = isInSsh;
391
+ });
392
+
393
+ // ../../node_modules/open/index.js
394
+ import process8 from "node:process";
395
+ import path from "node:path";
396
+ import { fileURLToPath } from "node:url";
397
+ import childProcess3 from "node:child_process";
398
+ import fs5, { constants as fsConstants2 } from "node:fs/promises";
399
+ function detectArchBinary(binary) {
400
+ if (typeof binary === "string" || Array.isArray(binary)) {
401
+ return binary;
402
+ }
403
+ const { [arch]: archBinary } = binary;
404
+ if (!archBinary) {
405
+ throw new Error(`${arch} is not supported`);
406
+ }
407
+ return archBinary;
408
+ }
409
+ function detectPlatformBinary({ [platform]: platformBinary }, { wsl } = {}) {
410
+ if (wsl && is_wsl_default) {
411
+ return detectArchBinary(wsl);
412
+ }
413
+ if (!platformBinary) {
414
+ throw new Error(`${platform} is not supported`);
415
+ }
416
+ return detectArchBinary(platformBinary);
417
+ }
418
+ var fallbackAttemptSymbol, __dirname2, localXdgOpenPath, platform, arch, tryEachApp = async (apps, opener) => {
419
+ if (apps.length === 0) {
420
+ return;
421
+ }
422
+ const errors = [];
423
+ for (const app of apps) {
424
+ try {
425
+ return await opener(app);
426
+ } catch (error) {
427
+ errors.push(error);
401
428
  }
402
- styleCommandDescription(str) {
403
- return this.styleDescriptionText(str);
429
+ }
430
+ throw new AggregateError(errors, "Failed to open in all supported apps");
431
+ }, baseOpen = async (options) => {
432
+ options = {
433
+ wait: false,
434
+ background: false,
435
+ newInstance: false,
436
+ allowNonzeroExitCode: false,
437
+ ...options
438
+ };
439
+ const isFallbackAttempt = options[fallbackAttemptSymbol] === true;
440
+ delete options[fallbackAttemptSymbol];
441
+ if (Array.isArray(options.app)) {
442
+ return tryEachApp(options.app, (singleApp) => baseOpen({
443
+ ...options,
444
+ app: singleApp,
445
+ [fallbackAttemptSymbol]: true
446
+ }));
447
+ }
448
+ let { name: app, arguments: appArguments = [] } = options.app ?? {};
449
+ appArguments = [...appArguments];
450
+ if (Array.isArray(app)) {
451
+ return tryEachApp(app, (appName) => baseOpen({
452
+ ...options,
453
+ app: {
454
+ name: appName,
455
+ arguments: appArguments
456
+ },
457
+ [fallbackAttemptSymbol]: true
458
+ }));
459
+ }
460
+ if (app === "browser" || app === "browserPrivate") {
461
+ const ids = {
462
+ "com.google.chrome": "chrome",
463
+ "google-chrome.desktop": "chrome",
464
+ "com.brave.browser": "brave",
465
+ "org.mozilla.firefox": "firefox",
466
+ "firefox.desktop": "firefox",
467
+ "com.microsoft.msedge": "edge",
468
+ "com.microsoft.edge": "edge",
469
+ "com.microsoft.edgemac": "edge",
470
+ "microsoft-edge.desktop": "edge",
471
+ "com.apple.safari": "safari"
472
+ };
473
+ const flags = {
474
+ chrome: "--incognito",
475
+ brave: "--incognito",
476
+ firefox: "--private-window",
477
+ edge: "--inPrivate"
478
+ };
479
+ let browser;
480
+ if (is_wsl_default) {
481
+ const progId = await wslDefaultBrowser();
482
+ const browserInfo = _windowsBrowserProgIdMap.get(progId);
483
+ browser = browserInfo ?? {};
484
+ } else {
485
+ browser = await defaultBrowser2();
404
486
  }
405
- styleOptionDescription(str) {
406
- return this.styleDescriptionText(str);
487
+ if (browser.id in ids) {
488
+ const browserName = ids[browser.id.toLowerCase()];
489
+ if (app === "browserPrivate") {
490
+ if (browserName === "safari") {
491
+ throw new Error("Safari doesn't support opening in private mode via command line");
492
+ }
493
+ appArguments.push(flags[browserName]);
494
+ }
495
+ return baseOpen({
496
+ ...options,
497
+ app: {
498
+ name: apps[browserName],
499
+ arguments: appArguments
500
+ }
501
+ });
407
502
  }
408
- styleSubcommandDescription(str) {
409
- return this.styleDescriptionText(str);
503
+ throw new Error(`${browser.name} is not supported as a default browser`);
504
+ }
505
+ let command;
506
+ const cliArguments = [];
507
+ const childProcessOptions = {};
508
+ let shouldUseWindowsInWsl = false;
509
+ if (is_wsl_default && !isInsideContainer() && !is_in_ssh_default && !app) {
510
+ shouldUseWindowsInWsl = await canAccessPowerShell();
511
+ }
512
+ if (platform === "darwin") {
513
+ command = "open";
514
+ if (options.wait) {
515
+ cliArguments.push("--wait-apps");
410
516
  }
411
- styleArgumentDescription(str) {
412
- return this.styleDescriptionText(str);
517
+ if (options.background) {
518
+ cliArguments.push("--background");
413
519
  }
414
- styleDescriptionText(str) {
415
- return str;
520
+ if (options.newInstance) {
521
+ cliArguments.push("--new");
416
522
  }
417
- styleOptionTerm(str) {
418
- return this.styleOptionText(str);
523
+ if (app) {
524
+ cliArguments.push("-a", app);
419
525
  }
420
- styleSubcommandTerm(str) {
421
- return str.split(" ").map((word) => {
422
- if (word === "[options]")
423
- return this.styleOptionText(word);
424
- if (word[0] === "[" || word[0] === "<")
425
- return this.styleArgumentText(word);
426
- return this.styleSubcommandText(word);
427
- }).join(" ");
526
+ } else if (platform === "win32" || shouldUseWindowsInWsl) {
527
+ command = await powerShellPath2();
528
+ cliArguments.push(...executePowerShell.argumentsPrefix);
529
+ if (!is_wsl_default) {
530
+ childProcessOptions.windowsVerbatimArguments = true;
428
531
  }
429
- styleArgumentTerm(str) {
430
- return this.styleArgumentText(str);
532
+ if (is_wsl_default && options.target) {
533
+ options.target = await convertWslPathToWindows(options.target);
431
534
  }
432
- styleOptionText(str) {
433
- return str;
535
+ const encodedArguments = ["$ProgressPreference = 'SilentlyContinue';", "Start"];
536
+ if (options.wait) {
537
+ encodedArguments.push("-Wait");
434
538
  }
435
- styleArgumentText(str) {
436
- return str;
539
+ if (app) {
540
+ encodedArguments.push(executePowerShell.escapeArgument(app));
541
+ if (options.target) {
542
+ appArguments.push(options.target);
543
+ }
544
+ } else if (options.target) {
545
+ encodedArguments.push(executePowerShell.escapeArgument(options.target));
437
546
  }
438
- styleSubcommandText(str) {
439
- return str;
547
+ if (appArguments.length > 0) {
548
+ appArguments = appArguments.map((argument) => executePowerShell.escapeArgument(argument));
549
+ encodedArguments.push("-ArgumentList", appArguments.join(","));
440
550
  }
441
- styleCommandText(str) {
442
- return str;
551
+ options.target = executePowerShell.encodeCommand(encodedArguments.join(" "));
552
+ if (!options.wait) {
553
+ childProcessOptions.stdio = "ignore";
443
554
  }
444
- padWidth(cmd, helper) {
445
- return Math.max(helper.longestOptionTermLength(cmd, helper), helper.longestGlobalOptionTermLength(cmd, helper), helper.longestSubcommandTermLength(cmd, helper), helper.longestArgumentTermLength(cmd, helper));
555
+ } else {
556
+ if (app) {
557
+ command = app;
558
+ } else {
559
+ const isBundled = !__dirname2 || __dirname2 === "/";
560
+ let exeLocalXdgOpen = false;
561
+ try {
562
+ await fs5.access(localXdgOpenPath, fsConstants2.X_OK);
563
+ exeLocalXdgOpen = true;
564
+ } catch {}
565
+ const useSystemXdgOpen = process8.versions.electron ?? (platform === "android" || isBundled || !exeLocalXdgOpen);
566
+ command = useSystemXdgOpen ? "xdg-open" : localXdgOpenPath;
446
567
  }
447
- preformatted(str) {
448
- return /\n[^\S\r\n]/.test(str);
568
+ if (appArguments.length > 0) {
569
+ cliArguments.push(...appArguments);
449
570
  }
450
- formatItem(term, termWidth, description, helper) {
451
- const itemIndent = 2;
452
- const itemIndentStr = " ".repeat(itemIndent);
453
- if (!description)
454
- return itemIndentStr + term;
455
- const paddedTerm = term.padEnd(termWidth + term.length - helper.displayWidth(term));
456
- const spacerWidth = 2;
457
- const helpWidth = this.helpWidth ?? 80;
458
- const remainingWidth = helpWidth - termWidth - spacerWidth - itemIndent;
459
- let formattedDescription;
460
- if (remainingWidth < this.minWidthToWrap || helper.preformatted(description)) {
461
- formattedDescription = description;
462
- } else {
463
- const wrappedDescription = helper.boxWrap(description, remainingWidth);
464
- formattedDescription = wrappedDescription.replace(/\n/g, `
465
- ` + " ".repeat(termWidth + spacerWidth));
466
- }
467
- return itemIndentStr + paddedTerm + " ".repeat(spacerWidth) + formattedDescription.replace(/\n/g, `
468
- ${itemIndentStr}`);
571
+ if (!options.wait) {
572
+ childProcessOptions.stdio = "ignore";
573
+ childProcessOptions.detached = true;
469
574
  }
470
- boxWrap(str, width) {
471
- if (width < this.minWidthToWrap)
472
- return str;
473
- const rawLines = str.split(/\r\n|\n/);
474
- const chunkPattern = /[\s]*[^\s]+/g;
475
- const wrappedLines = [];
476
- rawLines.forEach((line) => {
477
- const chunks = line.match(chunkPattern);
478
- if (chunks === null) {
479
- wrappedLines.push("");
575
+ }
576
+ if (platform === "darwin" && appArguments.length > 0) {
577
+ cliArguments.push("--args", ...appArguments);
578
+ }
579
+ if (options.target) {
580
+ cliArguments.push(options.target);
581
+ }
582
+ const subprocess = childProcess3.spawn(command, cliArguments, childProcessOptions);
583
+ if (options.wait) {
584
+ return new Promise((resolve, reject) => {
585
+ subprocess.once("error", reject);
586
+ subprocess.once("close", (exitCode) => {
587
+ if (!options.allowNonzeroExitCode && exitCode !== 0) {
588
+ reject(new Error(`Exited with code ${exitCode}`));
480
589
  return;
481
590
  }
482
- let sumChunks = [chunks.shift()];
483
- let sumWidth = this.displayWidth(sumChunks[0]);
484
- chunks.forEach((chunk) => {
485
- const visibleWidth = this.displayWidth(chunk);
486
- if (sumWidth + visibleWidth <= width) {
487
- sumChunks.push(chunk);
488
- sumWidth += visibleWidth;
591
+ resolve(subprocess);
592
+ });
593
+ });
594
+ }
595
+ if (isFallbackAttempt) {
596
+ return new Promise((resolve, reject) => {
597
+ subprocess.once("error", reject);
598
+ subprocess.once("spawn", () => {
599
+ subprocess.once("close", (exitCode) => {
600
+ subprocess.off("error", reject);
601
+ if (exitCode !== 0) {
602
+ reject(new Error(`Exited with code ${exitCode}`));
489
603
  return;
490
604
  }
491
- wrappedLines.push(sumChunks.join(""));
492
- const nextChunk = chunk.trimStart();
493
- sumChunks = [nextChunk];
494
- sumWidth = this.displayWidth(nextChunk);
605
+ subprocess.unref();
606
+ resolve(subprocess);
495
607
  });
496
- wrappedLines.push(sumChunks.join(""));
497
608
  });
498
- return wrappedLines.join(`
499
- `);
500
- }
609
+ });
501
610
  }
502
- function stripColor(str) {
503
- const sgrPattern = /\x1b\[\d*(;\d*)*m/g;
504
- return str.replace(sgrPattern, "");
611
+ subprocess.unref();
612
+ return new Promise((resolve, reject) => {
613
+ subprocess.once("error", reject);
614
+ subprocess.once("spawn", () => {
615
+ subprocess.off("error", reject);
616
+ resolve(subprocess);
617
+ });
618
+ });
619
+ }, open = (target, options) => {
620
+ if (typeof target !== "string") {
621
+ throw new TypeError("Expected a `target`");
505
622
  }
506
- exports.Help = Help;
507
- exports.stripColor = stripColor;
623
+ return baseOpen({
624
+ ...options,
625
+ target
626
+ });
627
+ }, apps, open_default;
628
+ var init_open = __esm(() => {
629
+ init_wsl_utils();
630
+ init_powershell_utils();
631
+ init_default_browser();
632
+ init_is_inside_container();
633
+ init_is_in_ssh();
634
+ fallbackAttemptSymbol = Symbol("fallbackAttempt");
635
+ __dirname2 = import.meta.url ? path.dirname(fileURLToPath(import.meta.url)) : "";
636
+ localXdgOpenPath = path.join(__dirname2, "xdg-open");
637
+ ({ platform, arch } = process8);
638
+ apps = {
639
+ browser: "browser",
640
+ browserPrivate: "browserPrivate"
641
+ };
642
+ defineLazyProperty(apps, "chrome", () => detectPlatformBinary({
643
+ darwin: "google chrome",
644
+ win32: "chrome",
645
+ linux: ["google-chrome", "google-chrome-stable", "chromium", "chromium-browser"]
646
+ }, {
647
+ wsl: {
648
+ ia32: "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe",
649
+ x64: ["/mnt/c/Program Files/Google/Chrome/Application/chrome.exe", "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"]
650
+ }
651
+ }));
652
+ defineLazyProperty(apps, "brave", () => detectPlatformBinary({
653
+ darwin: "brave browser",
654
+ win32: "brave",
655
+ linux: ["brave-browser", "brave"]
656
+ }, {
657
+ wsl: {
658
+ ia32: "/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe",
659
+ x64: ["/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe", "/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe"]
660
+ }
661
+ }));
662
+ defineLazyProperty(apps, "firefox", () => detectPlatformBinary({
663
+ darwin: "firefox",
664
+ win32: String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,
665
+ linux: "firefox"
666
+ }, {
667
+ wsl: "/mnt/c/Program Files/Mozilla Firefox/firefox.exe"
668
+ }));
669
+ defineLazyProperty(apps, "edge", () => detectPlatformBinary({
670
+ darwin: "microsoft edge",
671
+ win32: "msedge",
672
+ linux: ["microsoft-edge", "microsoft-edge-dev"]
673
+ }, {
674
+ wsl: "/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"
675
+ }));
676
+ defineLazyProperty(apps, "safari", () => detectPlatformBinary({
677
+ darwin: "Safari"
678
+ }));
679
+ open_default = open;
508
680
  });
509
681
 
510
- // ../../node_modules/commander/lib/option.js
511
- var require_option = __commonJS((exports) => {
512
- var { InvalidArgumentError } = require_error();
682
+ // ../filesystem/src/node.ts
683
+ import { existsSync } from "node:fs";
684
+ import * as fs6 from "node:fs/promises";
685
+ import * as os2 from "node:os";
686
+ import * as path2 from "node:path";
513
687
 
514
- class Option {
515
- constructor(flags, description) {
516
- this.flags = flags;
517
- this.description = description || "";
518
- this.required = flags.includes("<");
519
- this.optional = flags.includes("[");
520
- this.variadic = /\w\.\.\.[>\]]$/.test(flags);
521
- this.mandatory = false;
522
- const optionFlags = splitOptionFlags(flags);
523
- this.short = optionFlags.shortFlag;
524
- this.long = optionFlags.longFlag;
525
- this.negate = false;
526
- if (this.long) {
527
- this.negate = this.long.startsWith("--no-");
528
- }
529
- this.defaultValue = undefined;
530
- this.defaultValueDescription = undefined;
531
- this.presetArg = undefined;
532
- this.envVar = undefined;
533
- this.parseArg = undefined;
534
- this.hidden = false;
535
- this.argChoices = undefined;
536
- this.conflictsWith = [];
537
- this.implied = undefined;
538
- this.helpGroupHeading = undefined;
688
+ class NodeFileSystem {
689
+ path = {
690
+ join: path2.join,
691
+ resolve: path2.resolve,
692
+ relative: path2.relative,
693
+ dirname: path2.dirname,
694
+ isAbsolute: path2.isAbsolute,
695
+ basename: path2.basename
696
+ };
697
+ env = {
698
+ cwd: process.cwd,
699
+ homedir: os2.homedir,
700
+ tmpdir: os2.tmpdir,
701
+ getenv: (key) => process.env[key]
702
+ };
703
+ utils = {
704
+ open: async (url) => {
705
+ await open_default(url);
539
706
  }
540
- default(value, description) {
541
- this.defaultValue = value;
542
- this.defaultValueDescription = description;
543
- return this;
707
+ };
708
+ async readFile(path3, options) {
709
+ try {
710
+ if (options) {
711
+ return await fs6.readFile(path3, "utf-8");
712
+ }
713
+ return await fs6.readFile(path3);
714
+ } catch (error) {
715
+ if (this.isEnoent(error))
716
+ return null;
717
+ throw error;
544
718
  }
545
- preset(arg) {
546
- this.presetArg = arg;
547
- return this;
719
+ }
720
+ async writeFile(filePath, data) {
721
+ const dir = path2.dirname(filePath);
722
+ if (dir) {
723
+ await fs6.mkdir(dir, { recursive: true });
548
724
  }
549
- conflicts(names) {
550
- this.conflictsWith = this.conflictsWith.concat(names);
551
- return this;
725
+ await fs6.writeFile(filePath, data);
726
+ }
727
+ async appendFile(filePath, data) {
728
+ const dir = path2.dirname(filePath);
729
+ if (dir) {
730
+ await fs6.mkdir(dir, { recursive: true });
552
731
  }
553
- implies(impliedOptionValues) {
554
- let newImplied = impliedOptionValues;
555
- if (typeof impliedOptionValues === "string") {
556
- newImplied = { [impliedOptionValues]: true };
732
+ await fs6.appendFile(filePath, data);
733
+ }
734
+ async readdir(dirPath) {
735
+ try {
736
+ return await fs6.readdir(dirPath);
737
+ } catch (error) {
738
+ if (this.isEnoent(error))
739
+ return [];
740
+ throw error;
741
+ }
742
+ }
743
+ async stat(filePath) {
744
+ try {
745
+ const stats = await fs6.stat(filePath);
746
+ return {
747
+ isFile: () => stats.isFile(),
748
+ isDirectory: () => stats.isDirectory(),
749
+ size: stats.size,
750
+ mtimeMs: stats.mtimeMs
751
+ };
752
+ } catch (error) {
753
+ if (this.isEnoent(error))
754
+ return null;
755
+ throw error;
756
+ }
757
+ }
758
+ async exists(filePath) {
759
+ return existsSync(filePath);
760
+ }
761
+ async mkdir(dirPath) {
762
+ await fs6.mkdir(dirPath, { recursive: true });
763
+ }
764
+ async rm(filePath) {
765
+ await fs6.rm(filePath, { recursive: true, force: true });
766
+ }
767
+ async rename(oldPath, newPath) {
768
+ await fs6.rename(oldPath, newPath);
769
+ }
770
+ async realpath(filePath) {
771
+ try {
772
+ return await fs6.realpath(filePath);
773
+ } catch (error) {
774
+ if (this.isEnoent(error))
775
+ return filePath;
776
+ throw error;
777
+ }
778
+ }
779
+ async getTempDir() {
780
+ return await fs6.mkdtemp(path2.join(os2.tmpdir(), "uipath-fs-"));
781
+ }
782
+ async copyDirectory(sourcePath, destPath) {
783
+ const sourceStats = await this.stat(sourcePath);
784
+ if (!sourceStats) {
785
+ throw new Error(`Source directory does not exist: ${sourcePath}`);
786
+ }
787
+ if (!sourceStats.isDirectory()) {
788
+ throw new Error(`Source path is not a directory: ${sourcePath}`);
789
+ }
790
+ await this.mkdir(destPath);
791
+ const entries = await this.readdir(sourcePath);
792
+ for (const entry of entries) {
793
+ const srcEntry = path2.join(sourcePath, entry);
794
+ const destEntry = path2.join(destPath, entry);
795
+ const entryStats = await this.stat(srcEntry);
796
+ if (!entryStats)
797
+ continue;
798
+ if (entryStats.isDirectory()) {
799
+ await this.copyDirectory(srcEntry, destEntry);
800
+ } else if (entryStats.isFile()) {
801
+ const content = await this.readFile(srcEntry);
802
+ if (content !== null) {
803
+ await this.writeFile(destEntry, content);
804
+ }
557
805
  }
558
- this.implied = Object.assign(this.implied || {}, newImplied);
559
- return this;
560
806
  }
561
- env(name) {
562
- this.envVar = name;
563
- return this;
807
+ }
808
+ isEnoent(error) {
809
+ return typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT";
810
+ }
811
+ }
812
+ var init_node = __esm(() => {
813
+ init_open();
814
+ });
815
+ // ../filesystem/src/index.ts
816
+ var fsInstance, getFileSystem = () => fsInstance;
817
+ var init_src = __esm(() => {
818
+ init_node();
819
+ init_node();
820
+ fsInstance = new NodeFileSystem;
821
+ });
822
+
823
+ // ../../node_modules/commander/lib/error.js
824
+ var require_error = __commonJS((exports) => {
825
+ class CommanderError extends Error {
826
+ constructor(exitCode, code, message) {
827
+ super(message);
828
+ Error.captureStackTrace(this, this.constructor);
829
+ this.name = this.constructor.name;
830
+ this.code = code;
831
+ this.exitCode = exitCode;
832
+ this.nestedError = undefined;
564
833
  }
565
- argParser(fn) {
566
- this.parseArg = fn;
567
- return this;
834
+ }
835
+
836
+ class InvalidArgumentError extends CommanderError {
837
+ constructor(message) {
838
+ super(1, "commander.invalidArgument", message);
839
+ Error.captureStackTrace(this, this.constructor);
840
+ this.name = this.constructor.name;
568
841
  }
569
- makeOptionMandatory(mandatory = true) {
570
- this.mandatory = !!mandatory;
571
- return this;
842
+ }
843
+ exports.CommanderError = CommanderError;
844
+ exports.InvalidArgumentError = InvalidArgumentError;
845
+ });
846
+
847
+ // ../../node_modules/commander/lib/argument.js
848
+ var require_argument = __commonJS((exports) => {
849
+ var { InvalidArgumentError } = require_error();
850
+
851
+ class Argument {
852
+ constructor(name, description) {
853
+ this.description = description || "";
854
+ this.variadic = false;
855
+ this.parseArg = undefined;
856
+ this.defaultValue = undefined;
857
+ this.defaultValueDescription = undefined;
858
+ this.argChoices = undefined;
859
+ switch (name[0]) {
860
+ case "<":
861
+ this.required = true;
862
+ this._name = name.slice(1, -1);
863
+ break;
864
+ case "[":
865
+ this.required = false;
866
+ this._name = name.slice(1, -1);
867
+ break;
868
+ default:
869
+ this.required = true;
870
+ this._name = name;
871
+ break;
872
+ }
873
+ if (this._name.endsWith("...")) {
874
+ this.variadic = true;
875
+ this._name = this._name.slice(0, -3);
876
+ }
572
877
  }
573
- hideHelp(hide = true) {
574
- this.hidden = !!hide;
575
- return this;
878
+ name() {
879
+ return this._name;
576
880
  }
577
881
  _collectValue(value, previous) {
578
882
  if (previous === this.defaultValue || !Array.isArray(previous)) {
@@ -581,6 +885,15 @@ var require_option = __commonJS((exports) => {
581
885
  previous.push(value);
582
886
  return previous;
583
887
  }
888
+ default(value, description) {
889
+ this.defaultValue = value;
890
+ this.defaultValueDescription = description;
891
+ return this;
892
+ }
893
+ argParser(fn) {
894
+ this.parseArg = fn;
895
+ return this;
896
+ }
584
897
  choices(values) {
585
898
  this.argChoices = values.slice();
586
899
  this.parseArg = (arg, previous) => {
@@ -594,189 +907,650 @@ var require_option = __commonJS((exports) => {
594
907
  };
595
908
  return this;
596
909
  }
597
- name() {
598
- if (this.long) {
599
- return this.long.replace(/^--/, "");
600
- }
601
- return this.short.replace(/^-/, "");
602
- }
603
- attributeName() {
604
- if (this.negate) {
605
- return camelcase(this.name().replace(/^no-/, ""));
606
- }
607
- return camelcase(this.name());
608
- }
609
- helpGroup(heading) {
610
- this.helpGroupHeading = heading;
910
+ argRequired() {
911
+ this.required = true;
611
912
  return this;
612
913
  }
613
- is(arg) {
614
- return this.short === arg || this.long === arg;
615
- }
616
- isBoolean() {
617
- return !this.required && !this.optional && !this.negate;
914
+ argOptional() {
915
+ this.required = false;
916
+ return this;
618
917
  }
619
918
  }
919
+ function humanReadableArgName(arg) {
920
+ const nameOutput = arg.name() + (arg.variadic === true ? "..." : "");
921
+ return arg.required ? "<" + nameOutput + ">" : "[" + nameOutput + "]";
922
+ }
923
+ exports.Argument = Argument;
924
+ exports.humanReadableArgName = humanReadableArgName;
925
+ });
620
926
 
621
- class DualOptions {
622
- constructor(options) {
623
- this.positiveOptions = new Map;
624
- this.negativeOptions = new Map;
625
- this.dualOptions = new Set;
626
- options.forEach((option) => {
627
- if (option.negate) {
628
- this.negativeOptions.set(option.attributeName(), option);
629
- } else {
630
- this.positiveOptions.set(option.attributeName(), option);
631
- }
632
- });
633
- this.negativeOptions.forEach((value, key) => {
634
- if (this.positiveOptions.has(key)) {
635
- this.dualOptions.add(key);
636
- }
637
- });
927
+ // ../../node_modules/commander/lib/help.js
928
+ var require_help = __commonJS((exports) => {
929
+ var { humanReadableArgName } = require_argument();
930
+
931
+ class Help {
932
+ constructor() {
933
+ this.helpWidth = undefined;
934
+ this.minWidthToWrap = 40;
935
+ this.sortSubcommands = false;
936
+ this.sortOptions = false;
937
+ this.showGlobalOptions = false;
638
938
  }
639
- valueFromOption(value, option) {
640
- const optionKey = option.attributeName();
641
- if (!this.dualOptions.has(optionKey))
642
- return true;
643
- const preset = this.negativeOptions.get(optionKey).presetArg;
644
- const negativeValue = preset !== undefined ? preset : false;
645
- return option.negate === (negativeValue === value);
939
+ prepareContext(contextOptions) {
940
+ this.helpWidth = this.helpWidth ?? contextOptions.helpWidth ?? 80;
646
941
  }
647
- }
648
- function camelcase(str) {
649
- return str.split("-").reduce((str2, word) => {
650
- return str2 + word[0].toUpperCase() + word.slice(1);
651
- });
652
- }
653
- function splitOptionFlags(flags) {
654
- let shortFlag;
655
- let longFlag;
656
- const shortFlagExp = /^-[^-]$/;
657
- const longFlagExp = /^--[^-]/;
658
- const flagParts = flags.split(/[ |,]+/).concat("guard");
659
- if (shortFlagExp.test(flagParts[0]))
660
- shortFlag = flagParts.shift();
661
- if (longFlagExp.test(flagParts[0]))
662
- longFlag = flagParts.shift();
663
- if (!shortFlag && shortFlagExp.test(flagParts[0]))
664
- shortFlag = flagParts.shift();
665
- if (!shortFlag && longFlagExp.test(flagParts[0])) {
666
- shortFlag = longFlag;
667
- longFlag = flagParts.shift();
942
+ visibleCommands(cmd) {
943
+ const visibleCommands = cmd.commands.filter((cmd2) => !cmd2._hidden);
944
+ const helpCommand = cmd._getHelpCommand();
945
+ if (helpCommand && !helpCommand._hidden) {
946
+ visibleCommands.push(helpCommand);
947
+ }
948
+ if (this.sortSubcommands) {
949
+ visibleCommands.sort((a, b) => {
950
+ return a.name().localeCompare(b.name());
951
+ });
952
+ }
953
+ return visibleCommands;
668
954
  }
669
- if (flagParts[0].startsWith("-")) {
670
- const unsupportedFlag = flagParts[0];
671
- const baseError = `option creation failed due to '${unsupportedFlag}' in option flags '${flags}'`;
672
- if (/^-[^-][^-]/.test(unsupportedFlag))
673
- throw new Error(`${baseError}
674
- - a short flag is a single dash and a single character
675
- - either use a single dash and a single character (for a short flag)
676
- - or use a double dash for a long option (and can have two, like '--ws, --workspace')`);
677
- if (shortFlagExp.test(unsupportedFlag))
678
- throw new Error(`${baseError}
679
- - too many short flags`);
680
- if (longFlagExp.test(unsupportedFlag))
681
- throw new Error(`${baseError}
682
- - too many long flags`);
683
- throw new Error(`${baseError}
684
- - unrecognised flag format`);
955
+ compareOptions(a, b) {
956
+ const getSortKey = (option) => {
957
+ return option.short ? option.short.replace(/^-/, "") : option.long.replace(/^--/, "");
958
+ };
959
+ return getSortKey(a).localeCompare(getSortKey(b));
685
960
  }
686
- if (shortFlag === undefined && longFlag === undefined)
687
- throw new Error(`option creation failed due to no flags found in '${flags}'.`);
688
- return { shortFlag, longFlag };
689
- }
690
- exports.Option = Option;
691
- exports.DualOptions = DualOptions;
692
- });
693
-
694
- // ../../node_modules/commander/lib/suggestSimilar.js
695
- var require_suggestSimilar = __commonJS((exports) => {
696
- var maxDistance = 3;
697
- function editDistance(a, b) {
698
- if (Math.abs(a.length - b.length) > maxDistance)
699
- return Math.max(a.length, b.length);
700
- const d = [];
701
- for (let i = 0;i <= a.length; i++) {
702
- d[i] = [i];
961
+ visibleOptions(cmd) {
962
+ const visibleOptions = cmd.options.filter((option) => !option.hidden);
963
+ const helpOption = cmd._getHelpOption();
964
+ if (helpOption && !helpOption.hidden) {
965
+ const removeShort = helpOption.short && cmd._findOption(helpOption.short);
966
+ const removeLong = helpOption.long && cmd._findOption(helpOption.long);
967
+ if (!removeShort && !removeLong) {
968
+ visibleOptions.push(helpOption);
969
+ } else if (helpOption.long && !removeLong) {
970
+ visibleOptions.push(cmd.createOption(helpOption.long, helpOption.description));
971
+ } else if (helpOption.short && !removeShort) {
972
+ visibleOptions.push(cmd.createOption(helpOption.short, helpOption.description));
973
+ }
974
+ }
975
+ if (this.sortOptions) {
976
+ visibleOptions.sort(this.compareOptions);
977
+ }
978
+ return visibleOptions;
703
979
  }
704
- for (let j = 0;j <= b.length; j++) {
705
- d[0][j] = j;
980
+ visibleGlobalOptions(cmd) {
981
+ if (!this.showGlobalOptions)
982
+ return [];
983
+ const globalOptions = [];
984
+ for (let ancestorCmd = cmd.parent;ancestorCmd; ancestorCmd = ancestorCmd.parent) {
985
+ const visibleOptions = ancestorCmd.options.filter((option) => !option.hidden);
986
+ globalOptions.push(...visibleOptions);
987
+ }
988
+ if (this.sortOptions) {
989
+ globalOptions.sort(this.compareOptions);
990
+ }
991
+ return globalOptions;
706
992
  }
707
- for (let j = 1;j <= b.length; j++) {
708
- for (let i = 1;i <= a.length; i++) {
709
- let cost = 1;
710
- if (a[i - 1] === b[j - 1]) {
711
- cost = 0;
712
- } else {
713
- cost = 1;
714
- }
715
- d[i][j] = Math.min(d[i - 1][j] + 1, d[i][j - 1] + 1, d[i - 1][j - 1] + cost);
716
- if (i > 1 && j > 1 && a[i - 1] === b[j - 2] && a[i - 2] === b[j - 1]) {
717
- d[i][j] = Math.min(d[i][j], d[i - 2][j - 2] + 1);
718
- }
993
+ visibleArguments(cmd) {
994
+ if (cmd._argsDescription) {
995
+ cmd.registeredArguments.forEach((argument) => {
996
+ argument.description = argument.description || cmd._argsDescription[argument.name()] || "";
997
+ });
719
998
  }
999
+ if (cmd.registeredArguments.find((argument) => argument.description)) {
1000
+ return cmd.registeredArguments;
1001
+ }
1002
+ return [];
720
1003
  }
721
- return d[a.length][b.length];
722
- }
723
- function suggestSimilar(word, candidates) {
724
- if (!candidates || candidates.length === 0)
725
- return "";
726
- candidates = Array.from(new Set(candidates));
727
- const searchingOptions = word.startsWith("--");
728
- if (searchingOptions) {
729
- word = word.slice(2);
730
- candidates = candidates.map((candidate) => candidate.slice(2));
1004
+ subcommandTerm(cmd) {
1005
+ const args = cmd.registeredArguments.map((arg) => humanReadableArgName(arg)).join(" ");
1006
+ return cmd._name + (cmd._aliases[0] ? "|" + cmd._aliases[0] : "") + (cmd.options.length ? " [options]" : "") + (args ? " " + args : "");
731
1007
  }
732
- let similar = [];
733
- let bestDistance = maxDistance;
734
- const minSimilarity = 0.4;
735
- candidates.forEach((candidate) => {
736
- if (candidate.length <= 1)
737
- return;
738
- const distance = editDistance(word, candidate);
739
- const length = Math.max(word.length, candidate.length);
740
- const similarity = (length - distance) / length;
741
- if (similarity > minSimilarity) {
742
- if (distance < bestDistance) {
743
- bestDistance = distance;
744
- similar = [candidate];
745
- } else if (distance === bestDistance) {
746
- similar.push(candidate);
747
- }
1008
+ optionTerm(option) {
1009
+ return option.flags;
1010
+ }
1011
+ argumentTerm(argument) {
1012
+ return argument.name();
1013
+ }
1014
+ longestSubcommandTermLength(cmd, helper) {
1015
+ return helper.visibleCommands(cmd).reduce((max, command) => {
1016
+ return Math.max(max, this.displayWidth(helper.styleSubcommandTerm(helper.subcommandTerm(command))));
1017
+ }, 0);
1018
+ }
1019
+ longestOptionTermLength(cmd, helper) {
1020
+ return helper.visibleOptions(cmd).reduce((max, option) => {
1021
+ return Math.max(max, this.displayWidth(helper.styleOptionTerm(helper.optionTerm(option))));
1022
+ }, 0);
1023
+ }
1024
+ longestGlobalOptionTermLength(cmd, helper) {
1025
+ return helper.visibleGlobalOptions(cmd).reduce((max, option) => {
1026
+ return Math.max(max, this.displayWidth(helper.styleOptionTerm(helper.optionTerm(option))));
1027
+ }, 0);
1028
+ }
1029
+ longestArgumentTermLength(cmd, helper) {
1030
+ return helper.visibleArguments(cmd).reduce((max, argument) => {
1031
+ return Math.max(max, this.displayWidth(helper.styleArgumentTerm(helper.argumentTerm(argument))));
1032
+ }, 0);
1033
+ }
1034
+ commandUsage(cmd) {
1035
+ let cmdName = cmd._name;
1036
+ if (cmd._aliases[0]) {
1037
+ cmdName = cmdName + "|" + cmd._aliases[0];
748
1038
  }
749
- });
750
- similar.sort((a, b) => a.localeCompare(b));
751
- if (searchingOptions) {
752
- similar = similar.map((candidate) => `--${candidate}`);
1039
+ let ancestorCmdNames = "";
1040
+ for (let ancestorCmd = cmd.parent;ancestorCmd; ancestorCmd = ancestorCmd.parent) {
1041
+ ancestorCmdNames = ancestorCmd.name() + " " + ancestorCmdNames;
1042
+ }
1043
+ return ancestorCmdNames + cmdName + " " + cmd.usage();
753
1044
  }
754
- if (similar.length > 1) {
755
- return `
756
- (Did you mean one of ${similar.join(", ")}?)`;
1045
+ commandDescription(cmd) {
1046
+ return cmd.description();
757
1047
  }
758
- if (similar.length === 1) {
759
- return `
760
- (Did you mean ${similar[0]}?)`;
1048
+ subcommandDescription(cmd) {
1049
+ return cmd.summary() || cmd.description();
761
1050
  }
762
- return "";
763
- }
764
- exports.suggestSimilar = suggestSimilar;
765
- });
766
-
767
- // ../../node_modules/commander/lib/command.js
768
- var require_command = __commonJS((exports) => {
769
- var EventEmitter = __require("node:events").EventEmitter;
770
- var childProcess = __require("node:child_process");
771
- var path = __require("node:path");
772
- var fs = __require("node:fs");
773
- var process2 = __require("node:process");
774
- var { Argument, humanReadableArgName } = require_argument();
775
- var { CommanderError } = require_error();
776
- var { Help, stripColor } = require_help();
777
- var { Option, DualOptions } = require_option();
778
- var { suggestSimilar } = require_suggestSimilar();
779
-
1051
+ optionDescription(option) {
1052
+ const extraInfo = [];
1053
+ if (option.argChoices) {
1054
+ extraInfo.push(`choices: ${option.argChoices.map((choice) => JSON.stringify(choice)).join(", ")}`);
1055
+ }
1056
+ if (option.defaultValue !== undefined) {
1057
+ const showDefault = option.required || option.optional || option.isBoolean() && typeof option.defaultValue === "boolean";
1058
+ if (showDefault) {
1059
+ extraInfo.push(`default: ${option.defaultValueDescription || JSON.stringify(option.defaultValue)}`);
1060
+ }
1061
+ }
1062
+ if (option.presetArg !== undefined && option.optional) {
1063
+ extraInfo.push(`preset: ${JSON.stringify(option.presetArg)}`);
1064
+ }
1065
+ if (option.envVar !== undefined) {
1066
+ extraInfo.push(`env: ${option.envVar}`);
1067
+ }
1068
+ if (extraInfo.length > 0) {
1069
+ const extraDescription = `(${extraInfo.join(", ")})`;
1070
+ if (option.description) {
1071
+ return `${option.description} ${extraDescription}`;
1072
+ }
1073
+ return extraDescription;
1074
+ }
1075
+ return option.description;
1076
+ }
1077
+ argumentDescription(argument) {
1078
+ const extraInfo = [];
1079
+ if (argument.argChoices) {
1080
+ extraInfo.push(`choices: ${argument.argChoices.map((choice) => JSON.stringify(choice)).join(", ")}`);
1081
+ }
1082
+ if (argument.defaultValue !== undefined) {
1083
+ extraInfo.push(`default: ${argument.defaultValueDescription || JSON.stringify(argument.defaultValue)}`);
1084
+ }
1085
+ if (extraInfo.length > 0) {
1086
+ const extraDescription = `(${extraInfo.join(", ")})`;
1087
+ if (argument.description) {
1088
+ return `${argument.description} ${extraDescription}`;
1089
+ }
1090
+ return extraDescription;
1091
+ }
1092
+ return argument.description;
1093
+ }
1094
+ formatItemList(heading, items, helper) {
1095
+ if (items.length === 0)
1096
+ return [];
1097
+ return [helper.styleTitle(heading), ...items, ""];
1098
+ }
1099
+ groupItems(unsortedItems, visibleItems, getGroup) {
1100
+ const result = new Map;
1101
+ unsortedItems.forEach((item) => {
1102
+ const group = getGroup(item);
1103
+ if (!result.has(group))
1104
+ result.set(group, []);
1105
+ });
1106
+ visibleItems.forEach((item) => {
1107
+ const group = getGroup(item);
1108
+ if (!result.has(group)) {
1109
+ result.set(group, []);
1110
+ }
1111
+ result.get(group).push(item);
1112
+ });
1113
+ return result;
1114
+ }
1115
+ formatHelp(cmd, helper) {
1116
+ const termWidth = helper.padWidth(cmd, helper);
1117
+ const helpWidth = helper.helpWidth ?? 80;
1118
+ function callFormatItem(term, description) {
1119
+ return helper.formatItem(term, termWidth, description, helper);
1120
+ }
1121
+ let output = [
1122
+ `${helper.styleTitle("Usage:")} ${helper.styleUsage(helper.commandUsage(cmd))}`,
1123
+ ""
1124
+ ];
1125
+ const commandDescription = helper.commandDescription(cmd);
1126
+ if (commandDescription.length > 0) {
1127
+ output = output.concat([
1128
+ helper.boxWrap(helper.styleCommandDescription(commandDescription), helpWidth),
1129
+ ""
1130
+ ]);
1131
+ }
1132
+ const argumentList = helper.visibleArguments(cmd).map((argument) => {
1133
+ return callFormatItem(helper.styleArgumentTerm(helper.argumentTerm(argument)), helper.styleArgumentDescription(helper.argumentDescription(argument)));
1134
+ });
1135
+ output = output.concat(this.formatItemList("Arguments:", argumentList, helper));
1136
+ const optionGroups = this.groupItems(cmd.options, helper.visibleOptions(cmd), (option) => option.helpGroupHeading ?? "Options:");
1137
+ optionGroups.forEach((options, group) => {
1138
+ const optionList = options.map((option) => {
1139
+ return callFormatItem(helper.styleOptionTerm(helper.optionTerm(option)), helper.styleOptionDescription(helper.optionDescription(option)));
1140
+ });
1141
+ output = output.concat(this.formatItemList(group, optionList, helper));
1142
+ });
1143
+ if (helper.showGlobalOptions) {
1144
+ const globalOptionList = helper.visibleGlobalOptions(cmd).map((option) => {
1145
+ return callFormatItem(helper.styleOptionTerm(helper.optionTerm(option)), helper.styleOptionDescription(helper.optionDescription(option)));
1146
+ });
1147
+ output = output.concat(this.formatItemList("Global Options:", globalOptionList, helper));
1148
+ }
1149
+ const commandGroups = this.groupItems(cmd.commands, helper.visibleCommands(cmd), (sub) => sub.helpGroup() || "Commands:");
1150
+ commandGroups.forEach((commands, group) => {
1151
+ const commandList = commands.map((sub) => {
1152
+ return callFormatItem(helper.styleSubcommandTerm(helper.subcommandTerm(sub)), helper.styleSubcommandDescription(helper.subcommandDescription(sub)));
1153
+ });
1154
+ output = output.concat(this.formatItemList(group, commandList, helper));
1155
+ });
1156
+ return output.join(`
1157
+ `);
1158
+ }
1159
+ displayWidth(str) {
1160
+ return stripColor(str).length;
1161
+ }
1162
+ styleTitle(str) {
1163
+ return str;
1164
+ }
1165
+ styleUsage(str) {
1166
+ return str.split(" ").map((word) => {
1167
+ if (word === "[options]")
1168
+ return this.styleOptionText(word);
1169
+ if (word === "[command]")
1170
+ return this.styleSubcommandText(word);
1171
+ if (word[0] === "[" || word[0] === "<")
1172
+ return this.styleArgumentText(word);
1173
+ return this.styleCommandText(word);
1174
+ }).join(" ");
1175
+ }
1176
+ styleCommandDescription(str) {
1177
+ return this.styleDescriptionText(str);
1178
+ }
1179
+ styleOptionDescription(str) {
1180
+ return this.styleDescriptionText(str);
1181
+ }
1182
+ styleSubcommandDescription(str) {
1183
+ return this.styleDescriptionText(str);
1184
+ }
1185
+ styleArgumentDescription(str) {
1186
+ return this.styleDescriptionText(str);
1187
+ }
1188
+ styleDescriptionText(str) {
1189
+ return str;
1190
+ }
1191
+ styleOptionTerm(str) {
1192
+ return this.styleOptionText(str);
1193
+ }
1194
+ styleSubcommandTerm(str) {
1195
+ return str.split(" ").map((word) => {
1196
+ if (word === "[options]")
1197
+ return this.styleOptionText(word);
1198
+ if (word[0] === "[" || word[0] === "<")
1199
+ return this.styleArgumentText(word);
1200
+ return this.styleSubcommandText(word);
1201
+ }).join(" ");
1202
+ }
1203
+ styleArgumentTerm(str) {
1204
+ return this.styleArgumentText(str);
1205
+ }
1206
+ styleOptionText(str) {
1207
+ return str;
1208
+ }
1209
+ styleArgumentText(str) {
1210
+ return str;
1211
+ }
1212
+ styleSubcommandText(str) {
1213
+ return str;
1214
+ }
1215
+ styleCommandText(str) {
1216
+ return str;
1217
+ }
1218
+ padWidth(cmd, helper) {
1219
+ return Math.max(helper.longestOptionTermLength(cmd, helper), helper.longestGlobalOptionTermLength(cmd, helper), helper.longestSubcommandTermLength(cmd, helper), helper.longestArgumentTermLength(cmd, helper));
1220
+ }
1221
+ preformatted(str) {
1222
+ return /\n[^\S\r\n]/.test(str);
1223
+ }
1224
+ formatItem(term, termWidth, description, helper) {
1225
+ const itemIndent = 2;
1226
+ const itemIndentStr = " ".repeat(itemIndent);
1227
+ if (!description)
1228
+ return itemIndentStr + term;
1229
+ const paddedTerm = term.padEnd(termWidth + term.length - helper.displayWidth(term));
1230
+ const spacerWidth = 2;
1231
+ const helpWidth = this.helpWidth ?? 80;
1232
+ const remainingWidth = helpWidth - termWidth - spacerWidth - itemIndent;
1233
+ let formattedDescription;
1234
+ if (remainingWidth < this.minWidthToWrap || helper.preformatted(description)) {
1235
+ formattedDescription = description;
1236
+ } else {
1237
+ const wrappedDescription = helper.boxWrap(description, remainingWidth);
1238
+ formattedDescription = wrappedDescription.replace(/\n/g, `
1239
+ ` + " ".repeat(termWidth + spacerWidth));
1240
+ }
1241
+ return itemIndentStr + paddedTerm + " ".repeat(spacerWidth) + formattedDescription.replace(/\n/g, `
1242
+ ${itemIndentStr}`);
1243
+ }
1244
+ boxWrap(str, width) {
1245
+ if (width < this.minWidthToWrap)
1246
+ return str;
1247
+ const rawLines = str.split(/\r\n|\n/);
1248
+ const chunkPattern = /[\s]*[^\s]+/g;
1249
+ const wrappedLines = [];
1250
+ rawLines.forEach((line) => {
1251
+ const chunks = line.match(chunkPattern);
1252
+ if (chunks === null) {
1253
+ wrappedLines.push("");
1254
+ return;
1255
+ }
1256
+ let sumChunks = [chunks.shift()];
1257
+ let sumWidth = this.displayWidth(sumChunks[0]);
1258
+ chunks.forEach((chunk) => {
1259
+ const visibleWidth = this.displayWidth(chunk);
1260
+ if (sumWidth + visibleWidth <= width) {
1261
+ sumChunks.push(chunk);
1262
+ sumWidth += visibleWidth;
1263
+ return;
1264
+ }
1265
+ wrappedLines.push(sumChunks.join(""));
1266
+ const nextChunk = chunk.trimStart();
1267
+ sumChunks = [nextChunk];
1268
+ sumWidth = this.displayWidth(nextChunk);
1269
+ });
1270
+ wrappedLines.push(sumChunks.join(""));
1271
+ });
1272
+ return wrappedLines.join(`
1273
+ `);
1274
+ }
1275
+ }
1276
+ function stripColor(str) {
1277
+ const sgrPattern = /\x1b\[\d*(;\d*)*m/g;
1278
+ return str.replace(sgrPattern, "");
1279
+ }
1280
+ exports.Help = Help;
1281
+ exports.stripColor = stripColor;
1282
+ });
1283
+
1284
+ // ../../node_modules/commander/lib/option.js
1285
+ var require_option = __commonJS((exports) => {
1286
+ var { InvalidArgumentError } = require_error();
1287
+
1288
+ class Option {
1289
+ constructor(flags, description) {
1290
+ this.flags = flags;
1291
+ this.description = description || "";
1292
+ this.required = flags.includes("<");
1293
+ this.optional = flags.includes("[");
1294
+ this.variadic = /\w\.\.\.[>\]]$/.test(flags);
1295
+ this.mandatory = false;
1296
+ const optionFlags = splitOptionFlags(flags);
1297
+ this.short = optionFlags.shortFlag;
1298
+ this.long = optionFlags.longFlag;
1299
+ this.negate = false;
1300
+ if (this.long) {
1301
+ this.negate = this.long.startsWith("--no-");
1302
+ }
1303
+ this.defaultValue = undefined;
1304
+ this.defaultValueDescription = undefined;
1305
+ this.presetArg = undefined;
1306
+ this.envVar = undefined;
1307
+ this.parseArg = undefined;
1308
+ this.hidden = false;
1309
+ this.argChoices = undefined;
1310
+ this.conflictsWith = [];
1311
+ this.implied = undefined;
1312
+ this.helpGroupHeading = undefined;
1313
+ }
1314
+ default(value, description) {
1315
+ this.defaultValue = value;
1316
+ this.defaultValueDescription = description;
1317
+ return this;
1318
+ }
1319
+ preset(arg) {
1320
+ this.presetArg = arg;
1321
+ return this;
1322
+ }
1323
+ conflicts(names) {
1324
+ this.conflictsWith = this.conflictsWith.concat(names);
1325
+ return this;
1326
+ }
1327
+ implies(impliedOptionValues) {
1328
+ let newImplied = impliedOptionValues;
1329
+ if (typeof impliedOptionValues === "string") {
1330
+ newImplied = { [impliedOptionValues]: true };
1331
+ }
1332
+ this.implied = Object.assign(this.implied || {}, newImplied);
1333
+ return this;
1334
+ }
1335
+ env(name) {
1336
+ this.envVar = name;
1337
+ return this;
1338
+ }
1339
+ argParser(fn) {
1340
+ this.parseArg = fn;
1341
+ return this;
1342
+ }
1343
+ makeOptionMandatory(mandatory = true) {
1344
+ this.mandatory = !!mandatory;
1345
+ return this;
1346
+ }
1347
+ hideHelp(hide = true) {
1348
+ this.hidden = !!hide;
1349
+ return this;
1350
+ }
1351
+ _collectValue(value, previous) {
1352
+ if (previous === this.defaultValue || !Array.isArray(previous)) {
1353
+ return [value];
1354
+ }
1355
+ previous.push(value);
1356
+ return previous;
1357
+ }
1358
+ choices(values) {
1359
+ this.argChoices = values.slice();
1360
+ this.parseArg = (arg, previous) => {
1361
+ if (!this.argChoices.includes(arg)) {
1362
+ throw new InvalidArgumentError(`Allowed choices are ${this.argChoices.join(", ")}.`);
1363
+ }
1364
+ if (this.variadic) {
1365
+ return this._collectValue(arg, previous);
1366
+ }
1367
+ return arg;
1368
+ };
1369
+ return this;
1370
+ }
1371
+ name() {
1372
+ if (this.long) {
1373
+ return this.long.replace(/^--/, "");
1374
+ }
1375
+ return this.short.replace(/^-/, "");
1376
+ }
1377
+ attributeName() {
1378
+ if (this.negate) {
1379
+ return camelcase(this.name().replace(/^no-/, ""));
1380
+ }
1381
+ return camelcase(this.name());
1382
+ }
1383
+ helpGroup(heading) {
1384
+ this.helpGroupHeading = heading;
1385
+ return this;
1386
+ }
1387
+ is(arg) {
1388
+ return this.short === arg || this.long === arg;
1389
+ }
1390
+ isBoolean() {
1391
+ return !this.required && !this.optional && !this.negate;
1392
+ }
1393
+ }
1394
+
1395
+ class DualOptions {
1396
+ constructor(options) {
1397
+ this.positiveOptions = new Map;
1398
+ this.negativeOptions = new Map;
1399
+ this.dualOptions = new Set;
1400
+ options.forEach((option) => {
1401
+ if (option.negate) {
1402
+ this.negativeOptions.set(option.attributeName(), option);
1403
+ } else {
1404
+ this.positiveOptions.set(option.attributeName(), option);
1405
+ }
1406
+ });
1407
+ this.negativeOptions.forEach((value, key) => {
1408
+ if (this.positiveOptions.has(key)) {
1409
+ this.dualOptions.add(key);
1410
+ }
1411
+ });
1412
+ }
1413
+ valueFromOption(value, option) {
1414
+ const optionKey = option.attributeName();
1415
+ if (!this.dualOptions.has(optionKey))
1416
+ return true;
1417
+ const preset = this.negativeOptions.get(optionKey).presetArg;
1418
+ const negativeValue = preset !== undefined ? preset : false;
1419
+ return option.negate === (negativeValue === value);
1420
+ }
1421
+ }
1422
+ function camelcase(str) {
1423
+ return str.split("-").reduce((str2, word) => {
1424
+ return str2 + word[0].toUpperCase() + word.slice(1);
1425
+ });
1426
+ }
1427
+ function splitOptionFlags(flags) {
1428
+ let shortFlag;
1429
+ let longFlag;
1430
+ const shortFlagExp = /^-[^-]$/;
1431
+ const longFlagExp = /^--[^-]/;
1432
+ const flagParts = flags.split(/[ |,]+/).concat("guard");
1433
+ if (shortFlagExp.test(flagParts[0]))
1434
+ shortFlag = flagParts.shift();
1435
+ if (longFlagExp.test(flagParts[0]))
1436
+ longFlag = flagParts.shift();
1437
+ if (!shortFlag && shortFlagExp.test(flagParts[0]))
1438
+ shortFlag = flagParts.shift();
1439
+ if (!shortFlag && longFlagExp.test(flagParts[0])) {
1440
+ shortFlag = longFlag;
1441
+ longFlag = flagParts.shift();
1442
+ }
1443
+ if (flagParts[0].startsWith("-")) {
1444
+ const unsupportedFlag = flagParts[0];
1445
+ const baseError = `option creation failed due to '${unsupportedFlag}' in option flags '${flags}'`;
1446
+ if (/^-[^-][^-]/.test(unsupportedFlag))
1447
+ throw new Error(`${baseError}
1448
+ - a short flag is a single dash and a single character
1449
+ - either use a single dash and a single character (for a short flag)
1450
+ - or use a double dash for a long option (and can have two, like '--ws, --workspace')`);
1451
+ if (shortFlagExp.test(unsupportedFlag))
1452
+ throw new Error(`${baseError}
1453
+ - too many short flags`);
1454
+ if (longFlagExp.test(unsupportedFlag))
1455
+ throw new Error(`${baseError}
1456
+ - too many long flags`);
1457
+ throw new Error(`${baseError}
1458
+ - unrecognised flag format`);
1459
+ }
1460
+ if (shortFlag === undefined && longFlag === undefined)
1461
+ throw new Error(`option creation failed due to no flags found in '${flags}'.`);
1462
+ return { shortFlag, longFlag };
1463
+ }
1464
+ exports.Option = Option;
1465
+ exports.DualOptions = DualOptions;
1466
+ });
1467
+
1468
+ // ../../node_modules/commander/lib/suggestSimilar.js
1469
+ var require_suggestSimilar = __commonJS((exports) => {
1470
+ var maxDistance = 3;
1471
+ function editDistance(a, b) {
1472
+ if (Math.abs(a.length - b.length) > maxDistance)
1473
+ return Math.max(a.length, b.length);
1474
+ const d = [];
1475
+ for (let i = 0;i <= a.length; i++) {
1476
+ d[i] = [i];
1477
+ }
1478
+ for (let j = 0;j <= b.length; j++) {
1479
+ d[0][j] = j;
1480
+ }
1481
+ for (let j = 1;j <= b.length; j++) {
1482
+ for (let i = 1;i <= a.length; i++) {
1483
+ let cost = 1;
1484
+ if (a[i - 1] === b[j - 1]) {
1485
+ cost = 0;
1486
+ } else {
1487
+ cost = 1;
1488
+ }
1489
+ d[i][j] = Math.min(d[i - 1][j] + 1, d[i][j - 1] + 1, d[i - 1][j - 1] + cost);
1490
+ if (i > 1 && j > 1 && a[i - 1] === b[j - 2] && a[i - 2] === b[j - 1]) {
1491
+ d[i][j] = Math.min(d[i][j], d[i - 2][j - 2] + 1);
1492
+ }
1493
+ }
1494
+ }
1495
+ return d[a.length][b.length];
1496
+ }
1497
+ function suggestSimilar(word, candidates) {
1498
+ if (!candidates || candidates.length === 0)
1499
+ return "";
1500
+ candidates = Array.from(new Set(candidates));
1501
+ const searchingOptions = word.startsWith("--");
1502
+ if (searchingOptions) {
1503
+ word = word.slice(2);
1504
+ candidates = candidates.map((candidate) => candidate.slice(2));
1505
+ }
1506
+ let similar = [];
1507
+ let bestDistance = maxDistance;
1508
+ const minSimilarity = 0.4;
1509
+ candidates.forEach((candidate) => {
1510
+ if (candidate.length <= 1)
1511
+ return;
1512
+ const distance = editDistance(word, candidate);
1513
+ const length = Math.max(word.length, candidate.length);
1514
+ const similarity = (length - distance) / length;
1515
+ if (similarity > minSimilarity) {
1516
+ if (distance < bestDistance) {
1517
+ bestDistance = distance;
1518
+ similar = [candidate];
1519
+ } else if (distance === bestDistance) {
1520
+ similar.push(candidate);
1521
+ }
1522
+ }
1523
+ });
1524
+ similar.sort((a, b) => a.localeCompare(b));
1525
+ if (searchingOptions) {
1526
+ similar = similar.map((candidate) => `--${candidate}`);
1527
+ }
1528
+ if (similar.length > 1) {
1529
+ return `
1530
+ (Did you mean one of ${similar.join(", ")}?)`;
1531
+ }
1532
+ if (similar.length === 1) {
1533
+ return `
1534
+ (Did you mean ${similar[0]}?)`;
1535
+ }
1536
+ return "";
1537
+ }
1538
+ exports.suggestSimilar = suggestSimilar;
1539
+ });
1540
+
1541
+ // ../../node_modules/commander/lib/command.js
1542
+ var require_command = __commonJS((exports) => {
1543
+ var EventEmitter = __require("node:events").EventEmitter;
1544
+ var childProcess4 = __require("node:child_process");
1545
+ var path3 = __require("node:path");
1546
+ var fs7 = __require("node:fs");
1547
+ var process9 = __require("node:process");
1548
+ var { Argument, humanReadableArgName } = require_argument();
1549
+ var { CommanderError } = require_error();
1550
+ var { Help, stripColor } = require_help();
1551
+ var { Option, DualOptions } = require_option();
1552
+ var { suggestSimilar } = require_suggestSimilar();
1553
+
780
1554
  class Command extends EventEmitter {
781
1555
  constructor(name) {
782
1556
  super();
@@ -813,13 +1587,13 @@ var require_command = __commonJS((exports) => {
813
1587
  this._showSuggestionAfterError = true;
814
1588
  this._savedState = null;
815
1589
  this._outputConfiguration = {
816
- writeOut: (str) => process2.stdout.write(str),
817
- writeErr: (str) => process2.stderr.write(str),
1590
+ writeOut: (str) => process9.stdout.write(str),
1591
+ writeErr: (str) => process9.stderr.write(str),
818
1592
  outputError: (str, write) => write(str),
819
- getOutHelpWidth: () => process2.stdout.isTTY ? process2.stdout.columns : undefined,
820
- getErrHelpWidth: () => process2.stderr.isTTY ? process2.stderr.columns : undefined,
821
- getOutHasColors: () => useColor() ?? (process2.stdout.isTTY && process2.stdout.hasColors?.()),
822
- getErrHasColors: () => useColor() ?? (process2.stderr.isTTY && process2.stderr.hasColors?.()),
1593
+ getOutHelpWidth: () => process9.stdout.isTTY ? process9.stdout.columns : undefined,
1594
+ getErrHelpWidth: () => process9.stderr.isTTY ? process9.stderr.columns : undefined,
1595
+ getOutHasColors: () => useColor() ?? (process9.stdout.isTTY && process9.stdout.hasColors?.()),
1596
+ getErrHasColors: () => useColor() ?? (process9.stderr.isTTY && process9.stderr.hasColors?.()),
823
1597
  stripColor: (str) => stripColor(str)
824
1598
  };
825
1599
  this._hidden = false;
@@ -1027,7 +1801,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
1027
1801
  if (this._exitCallback) {
1028
1802
  this._exitCallback(new CommanderError(exitCode, code, message));
1029
1803
  }
1030
- process2.exit(exitCode);
1804
+ process9.exit(exitCode);
1031
1805
  }
1032
1806
  action(fn) {
1033
1807
  const listener = (args) => {
@@ -1224,16 +1998,16 @@ Expecting one of '${allowedValues.join("', '")}'`);
1224
1998
  }
1225
1999
  parseOptions = parseOptions || {};
1226
2000
  if (argv === undefined && parseOptions.from === undefined) {
1227
- if (process2.versions?.electron) {
2001
+ if (process9.versions?.electron) {
1228
2002
  parseOptions.from = "electron";
1229
2003
  }
1230
- const execArgv = process2.execArgv ?? [];
2004
+ const execArgv = process9.execArgv ?? [];
1231
2005
  if (execArgv.includes("-e") || execArgv.includes("--eval") || execArgv.includes("-p") || execArgv.includes("--print")) {
1232
2006
  parseOptions.from = "eval";
1233
2007
  }
1234
2008
  }
1235
2009
  if (argv === undefined) {
1236
- argv = process2.argv;
2010
+ argv = process9.argv;
1237
2011
  }
1238
2012
  this.rawArgs = argv.slice();
1239
2013
  let userArgs;
@@ -1244,7 +2018,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
1244
2018
  userArgs = argv.slice(2);
1245
2019
  break;
1246
2020
  case "electron":
1247
- if (process2.defaultApp) {
2021
+ if (process9.defaultApp) {
1248
2022
  this._scriptPath = argv[1];
1249
2023
  userArgs = argv.slice(2);
1250
2024
  } else {
@@ -1304,7 +2078,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
1304
2078
  this.processedArgs = [];
1305
2079
  }
1306
2080
  _checkForMissingExecutable(executableFile, executableDir, subcommandName) {
1307
- if (fs.existsSync(executableFile))
2081
+ if (fs7.existsSync(executableFile))
1308
2082
  return;
1309
2083
  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";
1310
2084
  const executableMissing = `'${executableFile}' does not exist
@@ -1318,12 +2092,12 @@ Expecting one of '${allowedValues.join("', '")}'`);
1318
2092
  let launchWithNode = false;
1319
2093
  const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
1320
2094
  function findFile(baseDir, baseName) {
1321
- const localBin = path.resolve(baseDir, baseName);
1322
- if (fs.existsSync(localBin))
2095
+ const localBin = path3.resolve(baseDir, baseName);
2096
+ if (fs7.existsSync(localBin))
1323
2097
  return localBin;
1324
- if (sourceExt.includes(path.extname(baseName)))
2098
+ if (sourceExt.includes(path3.extname(baseName)))
1325
2099
  return;
1326
- const foundExt = sourceExt.find((ext) => fs.existsSync(`${localBin}${ext}`));
2100
+ const foundExt = sourceExt.find((ext) => fs7.existsSync(`${localBin}${ext}`));
1327
2101
  if (foundExt)
1328
2102
  return `${localBin}${foundExt}`;
1329
2103
  return;
@@ -1335,42 +2109,42 @@ Expecting one of '${allowedValues.join("', '")}'`);
1335
2109
  if (this._scriptPath) {
1336
2110
  let resolvedScriptPath;
1337
2111
  try {
1338
- resolvedScriptPath = fs.realpathSync(this._scriptPath);
2112
+ resolvedScriptPath = fs7.realpathSync(this._scriptPath);
1339
2113
  } catch {
1340
2114
  resolvedScriptPath = this._scriptPath;
1341
2115
  }
1342
- executableDir = path.resolve(path.dirname(resolvedScriptPath), executableDir);
2116
+ executableDir = path3.resolve(path3.dirname(resolvedScriptPath), executableDir);
1343
2117
  }
1344
2118
  if (executableDir) {
1345
2119
  let localFile = findFile(executableDir, executableFile);
1346
2120
  if (!localFile && !subcommand._executableFile && this._scriptPath) {
1347
- const legacyName = path.basename(this._scriptPath, path.extname(this._scriptPath));
2121
+ const legacyName = path3.basename(this._scriptPath, path3.extname(this._scriptPath));
1348
2122
  if (legacyName !== this._name) {
1349
2123
  localFile = findFile(executableDir, `${legacyName}-${subcommand._name}`);
1350
2124
  }
1351
2125
  }
1352
2126
  executableFile = localFile || executableFile;
1353
2127
  }
1354
- launchWithNode = sourceExt.includes(path.extname(executableFile));
2128
+ launchWithNode = sourceExt.includes(path3.extname(executableFile));
1355
2129
  let proc;
1356
- if (process2.platform !== "win32") {
2130
+ if (process9.platform !== "win32") {
1357
2131
  if (launchWithNode) {
1358
2132
  args.unshift(executableFile);
1359
- args = incrementNodeInspectorPort(process2.execArgv).concat(args);
1360
- proc = childProcess.spawn(process2.argv[0], args, { stdio: "inherit" });
2133
+ args = incrementNodeInspectorPort(process9.execArgv).concat(args);
2134
+ proc = childProcess4.spawn(process9.argv[0], args, { stdio: "inherit" });
1361
2135
  } else {
1362
- proc = childProcess.spawn(executableFile, args, { stdio: "inherit" });
2136
+ proc = childProcess4.spawn(executableFile, args, { stdio: "inherit" });
1363
2137
  }
1364
2138
  } else {
1365
2139
  this._checkForMissingExecutable(executableFile, executableDir, subcommand._name);
1366
2140
  args.unshift(executableFile);
1367
- args = incrementNodeInspectorPort(process2.execArgv).concat(args);
1368
- proc = childProcess.spawn(process2.execPath, args, { stdio: "inherit" });
2141
+ args = incrementNodeInspectorPort(process9.execArgv).concat(args);
2142
+ proc = childProcess4.spawn(process9.execPath, args, { stdio: "inherit" });
1369
2143
  }
1370
2144
  if (!proc.killed) {
1371
2145
  const signals = ["SIGUSR1", "SIGUSR2", "SIGTERM", "SIGINT", "SIGHUP"];
1372
2146
  signals.forEach((signal) => {
1373
- process2.on(signal, () => {
2147
+ process9.on(signal, () => {
1374
2148
  if (proc.killed === false && proc.exitCode === null) {
1375
2149
  proc.kill(signal);
1376
2150
  }
@@ -1381,7 +2155,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
1381
2155
  proc.on("close", (code) => {
1382
2156
  code = code ?? 1;
1383
2157
  if (!exitCallback) {
1384
- process2.exit(code);
2158
+ process9.exit(code);
1385
2159
  } else {
1386
2160
  exitCallback(new CommanderError(code, "commander.executeSubCommandAsync", "(close)"));
1387
2161
  }
@@ -1393,7 +2167,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
1393
2167
  throw new Error(`'${executableFile}' not executable`);
1394
2168
  }
1395
2169
  if (!exitCallback) {
1396
- process2.exit(1);
2170
+ process9.exit(1);
1397
2171
  } else {
1398
2172
  const wrappedError = new CommanderError(1, "commander.executeSubCommandAsync", "(error)");
1399
2173
  wrappedError.nestedError = err;
@@ -1742,11 +2516,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
1742
2516
  }
1743
2517
  _parseOptionsEnv() {
1744
2518
  this.options.forEach((option) => {
1745
- if (option.envVar && option.envVar in process2.env) {
2519
+ if (option.envVar && option.envVar in process9.env) {
1746
2520
  const optionKey = option.attributeName();
1747
2521
  if (this.getOptionValue(optionKey) === undefined || ["default", "config", "env"].includes(this.getOptionValueSource(optionKey))) {
1748
2522
  if (option.required || option.optional) {
1749
- this.emit(`optionEnv:${option.name()}`, process2.env[option.envVar]);
2523
+ this.emit(`optionEnv:${option.name()}`, process9.env[option.envVar]);
1750
2524
  } else {
1751
2525
  this.emit(`optionEnv:${option.name()}`);
1752
2526
  }
@@ -1904,1015 +2678,239 @@ Expecting one of '${allowedValues.join("', '")}'`);
1904
2678
  });
1905
2679
  return [].concat(this.options.length || this._helpOption !== null ? "[options]" : [], this.commands.length ? "[command]" : [], this.registeredArguments.length ? args : []).join(" ");
1906
2680
  }
1907
- this._usage = str;
1908
- return this;
1909
- }
1910
- name(str) {
1911
- if (str === undefined)
1912
- return this._name;
1913
- this._name = str;
1914
- return this;
1915
- }
1916
- helpGroup(heading) {
1917
- if (heading === undefined)
1918
- return this._helpGroupHeading ?? "";
1919
- this._helpGroupHeading = heading;
1920
- return this;
1921
- }
1922
- commandsGroup(heading) {
1923
- if (heading === undefined)
1924
- return this._defaultCommandGroup ?? "";
1925
- this._defaultCommandGroup = heading;
1926
- return this;
1927
- }
1928
- optionsGroup(heading) {
1929
- if (heading === undefined)
1930
- return this._defaultOptionGroup ?? "";
1931
- this._defaultOptionGroup = heading;
1932
- return this;
1933
- }
1934
- _initOptionGroup(option) {
1935
- if (this._defaultOptionGroup && !option.helpGroupHeading)
1936
- option.helpGroup(this._defaultOptionGroup);
1937
- }
1938
- _initCommandGroup(cmd) {
1939
- if (this._defaultCommandGroup && !cmd.helpGroup())
1940
- cmd.helpGroup(this._defaultCommandGroup);
1941
- }
1942
- nameFromFilename(filename) {
1943
- this._name = path.basename(filename, path.extname(filename));
1944
- return this;
1945
- }
1946
- executableDir(path2) {
1947
- if (path2 === undefined)
1948
- return this._executableDir;
1949
- this._executableDir = path2;
1950
- return this;
1951
- }
1952
- helpInformation(contextOptions) {
1953
- const helper = this.createHelp();
1954
- const context = this._getOutputContext(contextOptions);
1955
- helper.prepareContext({
1956
- error: context.error,
1957
- helpWidth: context.helpWidth,
1958
- outputHasColors: context.hasColors
1959
- });
1960
- const text = helper.formatHelp(this, helper);
1961
- if (context.hasColors)
1962
- return text;
1963
- return this._outputConfiguration.stripColor(text);
1964
- }
1965
- _getOutputContext(contextOptions) {
1966
- contextOptions = contextOptions || {};
1967
- const error = !!contextOptions.error;
1968
- let baseWrite;
1969
- let hasColors;
1970
- let helpWidth;
1971
- if (error) {
1972
- baseWrite = (str) => this._outputConfiguration.writeErr(str);
1973
- hasColors = this._outputConfiguration.getErrHasColors();
1974
- helpWidth = this._outputConfiguration.getErrHelpWidth();
1975
- } else {
1976
- baseWrite = (str) => this._outputConfiguration.writeOut(str);
1977
- hasColors = this._outputConfiguration.getOutHasColors();
1978
- helpWidth = this._outputConfiguration.getOutHelpWidth();
1979
- }
1980
- const write = (str) => {
1981
- if (!hasColors)
1982
- str = this._outputConfiguration.stripColor(str);
1983
- return baseWrite(str);
1984
- };
1985
- return { error, write, hasColors, helpWidth };
1986
- }
1987
- outputHelp(contextOptions) {
1988
- let deprecatedCallback;
1989
- if (typeof contextOptions === "function") {
1990
- deprecatedCallback = contextOptions;
1991
- contextOptions = undefined;
1992
- }
1993
- const outputContext = this._getOutputContext(contextOptions);
1994
- const eventContext = {
1995
- error: outputContext.error,
1996
- write: outputContext.write,
1997
- command: this
1998
- };
1999
- this._getCommandAndAncestors().reverse().forEach((command) => command.emit("beforeAllHelp", eventContext));
2000
- this.emit("beforeHelp", eventContext);
2001
- let helpInformation = this.helpInformation({ error: outputContext.error });
2002
- if (deprecatedCallback) {
2003
- helpInformation = deprecatedCallback(helpInformation);
2004
- if (typeof helpInformation !== "string" && !Buffer.isBuffer(helpInformation)) {
2005
- throw new Error("outputHelp callback must return a string or a Buffer");
2006
- }
2007
- }
2008
- outputContext.write(helpInformation);
2009
- if (this._getHelpOption()?.long) {
2010
- this.emit(this._getHelpOption().long);
2011
- }
2012
- this.emit("afterHelp", eventContext);
2013
- this._getCommandAndAncestors().forEach((command) => command.emit("afterAllHelp", eventContext));
2014
- }
2015
- helpOption(flags, description) {
2016
- if (typeof flags === "boolean") {
2017
- if (flags) {
2018
- if (this._helpOption === null)
2019
- this._helpOption = undefined;
2020
- if (this._defaultOptionGroup) {
2021
- this._initOptionGroup(this._getHelpOption());
2022
- }
2023
- } else {
2024
- this._helpOption = null;
2025
- }
2026
- return this;
2027
- }
2028
- this._helpOption = this.createOption(flags ?? "-h, --help", description ?? "display help for command");
2029
- if (flags || description)
2030
- this._initOptionGroup(this._helpOption);
2031
- return this;
2032
- }
2033
- _getHelpOption() {
2034
- if (this._helpOption === undefined) {
2035
- this.helpOption(undefined, undefined);
2036
- }
2037
- return this._helpOption;
2038
- }
2039
- addHelpOption(option) {
2040
- this._helpOption = option;
2041
- this._initOptionGroup(option);
2042
- return this;
2043
- }
2044
- help(contextOptions) {
2045
- this.outputHelp(contextOptions);
2046
- let exitCode = Number(process2.exitCode ?? 0);
2047
- if (exitCode === 0 && contextOptions && typeof contextOptions !== "function" && contextOptions.error) {
2048
- exitCode = 1;
2049
- }
2050
- this._exit(exitCode, "commander.help", "(outputHelp)");
2051
- }
2052
- addHelpText(position, text) {
2053
- const allowedValues = ["beforeAll", "before", "after", "afterAll"];
2054
- if (!allowedValues.includes(position)) {
2055
- throw new Error(`Unexpected value for position to addHelpText.
2056
- Expecting one of '${allowedValues.join("', '")}'`);
2057
- }
2058
- const helpEvent = `${position}Help`;
2059
- this.on(helpEvent, (context) => {
2060
- let helpStr;
2061
- if (typeof text === "function") {
2062
- helpStr = text({ error: context.error, command: context.command });
2063
- } else {
2064
- helpStr = text;
2065
- }
2066
- if (helpStr) {
2067
- context.write(`${helpStr}
2068
- `);
2069
- }
2070
- });
2071
- return this;
2072
- }
2073
- _outputHelpIfRequested(args) {
2074
- const helpOption = this._getHelpOption();
2075
- const helpRequested = helpOption && args.find((arg) => helpOption.is(arg));
2076
- if (helpRequested) {
2077
- this.outputHelp();
2078
- this._exit(0, "commander.helpDisplayed", "(outputHelp)");
2079
- }
2080
- }
2081
- }
2082
- function incrementNodeInspectorPort(args) {
2083
- return args.map((arg) => {
2084
- if (!arg.startsWith("--inspect")) {
2085
- return arg;
2086
- }
2087
- let debugOption;
2088
- let debugHost = "127.0.0.1";
2089
- let debugPort = "9229";
2090
- let match;
2091
- if ((match = arg.match(/^(--inspect(-brk)?)$/)) !== null) {
2092
- debugOption = match[1];
2093
- } else if ((match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+)$/)) !== null) {
2094
- debugOption = match[1];
2095
- if (/^\d+$/.test(match[3])) {
2096
- debugPort = match[3];
2097
- } else {
2098
- debugHost = match[3];
2099
- }
2100
- } else if ((match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/)) !== null) {
2101
- debugOption = match[1];
2102
- debugHost = match[3];
2103
- debugPort = match[4];
2104
- }
2105
- if (debugOption && debugPort !== "0") {
2106
- return `${debugOption}=${debugHost}:${parseInt(debugPort) + 1}`;
2107
- }
2108
- return arg;
2109
- });
2110
- }
2111
- function useColor() {
2112
- if (process2.env.NO_COLOR || process2.env.FORCE_COLOR === "0" || process2.env.FORCE_COLOR === "false")
2113
- return false;
2114
- if (process2.env.FORCE_COLOR || process2.env.CLICOLOR_FORCE !== undefined)
2115
- return true;
2116
- return;
2117
- }
2118
- exports.Command = Command;
2119
- exports.useColor = useColor;
2120
- });
2121
-
2122
- // ../../node_modules/commander/index.js
2123
- var require_commander = __commonJS((exports) => {
2124
- var { Argument } = require_argument();
2125
- var { Command } = require_command();
2126
- var { CommanderError, InvalidArgumentError } = require_error();
2127
- var { Help } = require_help();
2128
- var { Option } = require_option();
2129
- exports.program = new Command;
2130
- exports.createCommand = (name) => new Command(name);
2131
- exports.createOption = (flags, description) => new Option(flags, description);
2132
- exports.createArgument = (name, description) => new Argument(name, description);
2133
- exports.Command = Command;
2134
- exports.Option = Option;
2135
- exports.Argument = Argument;
2136
- exports.Help = Help;
2137
- exports.CommanderError = CommanderError;
2138
- exports.InvalidArgumentError = InvalidArgumentError;
2139
- exports.InvalidOptionArgumentError = InvalidArgumentError;
2140
- });
2141
-
2142
- // ../../node_modules/is-inside-container/node_modules/is-docker/index.js
2143
- import fs from "node:fs";
2144
- function hasDockerEnv() {
2145
- try {
2146
- fs.statSync("/.dockerenv");
2147
- return true;
2148
- } catch {
2149
- return false;
2150
- }
2151
- }
2152
- function hasDockerCGroup() {
2153
- try {
2154
- return fs.readFileSync("/proc/self/cgroup", "utf8").includes("docker");
2155
- } catch {
2156
- return false;
2157
- }
2158
- }
2159
- function isDocker() {
2160
- if (isDockerCached === undefined) {
2161
- isDockerCached = hasDockerEnv() || hasDockerCGroup();
2162
- }
2163
- return isDockerCached;
2164
- }
2165
- var isDockerCached;
2166
- var init_is_docker = () => {};
2167
-
2168
- // ../../node_modules/is-inside-container/index.js
2169
- import fs2 from "node:fs";
2170
- function isInsideContainer() {
2171
- if (cachedResult === undefined) {
2172
- cachedResult = hasContainerEnv() || isDocker();
2173
- }
2174
- return cachedResult;
2175
- }
2176
- var cachedResult, hasContainerEnv = () => {
2177
- try {
2178
- fs2.statSync("/run/.containerenv");
2179
- return true;
2180
- } catch {
2181
- return false;
2182
- }
2183
- };
2184
- var init_is_inside_container = __esm(() => {
2185
- init_is_docker();
2186
- });
2187
-
2188
- // ../../node_modules/wsl-utils/node_modules/is-wsl/index.js
2189
- import process2 from "node:process";
2190
- import os from "node:os";
2191
- import fs3 from "node:fs";
2192
- var isWsl = () => {
2193
- if (process2.platform !== "linux") {
2194
- return false;
2195
- }
2196
- if (os.release().toLowerCase().includes("microsoft")) {
2197
- if (isInsideContainer()) {
2198
- return false;
2199
- }
2200
- return true;
2201
- }
2202
- try {
2203
- if (fs3.readFileSync("/proc/version", "utf8").toLowerCase().includes("microsoft")) {
2204
- return !isInsideContainer();
2205
- }
2206
- } catch {}
2207
- if (fs3.existsSync("/proc/sys/fs/binfmt_misc/WSLInterop") || fs3.existsSync("/run/WSL")) {
2208
- return !isInsideContainer();
2209
- }
2210
- return false;
2211
- }, is_wsl_default;
2212
- var init_is_wsl = __esm(() => {
2213
- init_is_inside_container();
2214
- is_wsl_default = process2.env.__IS_WSL_TEST__ ? isWsl : isWsl();
2215
- });
2216
-
2217
- // ../../node_modules/powershell-utils/index.js
2218
- import process3 from "node:process";
2219
- import { Buffer as Buffer2 } from "node:buffer";
2220
- import { promisify } from "node:util";
2221
- import childProcess from "node:child_process";
2222
- var execFile, powerShellPath = () => `${process3.env.SYSTEMROOT || process3.env.windir || String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`, executePowerShell = async (command, options = {}) => {
2223
- const {
2224
- powerShellPath: psPath,
2225
- ...execFileOptions
2226
- } = options;
2227
- const encodedCommand = executePowerShell.encodeCommand(command);
2228
- return execFile(psPath ?? powerShellPath(), [
2229
- ...executePowerShell.argumentsPrefix,
2230
- encodedCommand
2231
- ], {
2232
- encoding: "utf8",
2233
- ...execFileOptions
2234
- });
2235
- };
2236
- var init_powershell_utils = __esm(() => {
2237
- execFile = promisify(childProcess.execFile);
2238
- executePowerShell.argumentsPrefix = [
2239
- "-NoProfile",
2240
- "-NonInteractive",
2241
- "-ExecutionPolicy",
2242
- "Bypass",
2243
- "-EncodedCommand"
2244
- ];
2245
- executePowerShell.encodeCommand = (command) => Buffer2.from(command, "utf16le").toString("base64");
2246
- executePowerShell.escapeArgument = (value) => `'${String(value).replaceAll("'", "''")}'`;
2247
- });
2248
-
2249
- // ../../node_modules/wsl-utils/utilities.js
2250
- function parseMountPointFromConfig(content) {
2251
- for (const line of content.split(`
2252
- `)) {
2253
- if (/^\s*#/.test(line)) {
2254
- continue;
2255
- }
2256
- const match = /^\s*root\s*=\s*(?<mountPoint>"[^"]*"|'[^']*'|[^#]*)/.exec(line);
2257
- if (!match) {
2258
- continue;
2259
- }
2260
- return match.groups.mountPoint.trim().replaceAll(/^["']|["']$/g, "");
2261
- }
2262
- }
2263
-
2264
- // ../../node_modules/wsl-utils/index.js
2265
- import { promisify as promisify2 } from "node:util";
2266
- import childProcess2 from "node:child_process";
2267
- import fs4, { constants as fsConstants } from "node:fs/promises";
2268
- var execFile2, wslDrivesMountPoint, powerShellPathFromWsl = async () => {
2269
- const mountPoint = await wslDrivesMountPoint();
2270
- return `${mountPoint}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`;
2271
- }, powerShellPath2, canAccessPowerShellPromise, canAccessPowerShell = async () => {
2272
- canAccessPowerShellPromise ??= (async () => {
2273
- try {
2274
- const psPath = await powerShellPath2();
2275
- await fs4.access(psPath, fsConstants.X_OK);
2276
- return true;
2277
- } catch {
2278
- return false;
2279
- }
2280
- })();
2281
- return canAccessPowerShellPromise;
2282
- }, wslDefaultBrowser = async () => {
2283
- const psPath = await powerShellPath2();
2284
- const command = String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`;
2285
- const { stdout } = await executePowerShell(command, { powerShellPath: psPath });
2286
- return stdout.trim();
2287
- }, convertWslPathToWindows = async (path) => {
2288
- if (/^[a-z]+:\/\//i.test(path)) {
2289
- return path;
2290
- }
2291
- try {
2292
- const { stdout } = await execFile2("wslpath", ["-aw", path], { encoding: "utf8" });
2293
- return stdout.trim();
2294
- } catch {
2295
- return path;
2296
- }
2297
- };
2298
- var init_wsl_utils = __esm(() => {
2299
- init_is_wsl();
2300
- init_powershell_utils();
2301
- init_is_wsl();
2302
- execFile2 = promisify2(childProcess2.execFile);
2303
- wslDrivesMountPoint = (() => {
2304
- const defaultMountPoint = "/mnt/";
2305
- let mountPoint;
2306
- return async function() {
2307
- if (mountPoint) {
2308
- return mountPoint;
2309
- }
2310
- const configFilePath = "/etc/wsl.conf";
2311
- let isConfigFileExists = false;
2312
- try {
2313
- await fs4.access(configFilePath, fsConstants.F_OK);
2314
- isConfigFileExists = true;
2315
- } catch {}
2316
- if (!isConfigFileExists) {
2317
- return defaultMountPoint;
2318
- }
2319
- const configContent = await fs4.readFile(configFilePath, { encoding: "utf8" });
2320
- const parsedMountPoint = parseMountPointFromConfig(configContent);
2321
- if (parsedMountPoint === undefined) {
2322
- return defaultMountPoint;
2323
- }
2324
- mountPoint = parsedMountPoint;
2325
- mountPoint = mountPoint.endsWith("/") ? mountPoint : `${mountPoint}/`;
2326
- return mountPoint;
2327
- };
2328
- })();
2329
- powerShellPath2 = is_wsl_default ? powerShellPathFromWsl : powerShellPath;
2330
- });
2331
-
2332
- // ../../node_modules/open/node_modules/define-lazy-prop/index.js
2333
- function defineLazyProperty(object, propertyName, valueGetter) {
2334
- const define2 = (value) => Object.defineProperty(object, propertyName, { value, enumerable: true, writable: true });
2335
- Object.defineProperty(object, propertyName, {
2336
- configurable: true,
2337
- enumerable: true,
2338
- get() {
2339
- const result = valueGetter();
2340
- define2(result);
2341
- return result;
2342
- },
2343
- set(value) {
2344
- define2(value);
2345
- }
2346
- });
2347
- return object;
2348
- }
2349
-
2350
- // ../../node_modules/default-browser-id/index.js
2351
- import { promisify as promisify3 } from "node:util";
2352
- import process4 from "node:process";
2353
- import { execFile as execFile3 } from "node:child_process";
2354
- async function defaultBrowserId() {
2355
- if (process4.platform !== "darwin") {
2356
- throw new Error("macOS only");
2357
- }
2358
- const { stdout } = await execFileAsync("defaults", ["read", "com.apple.LaunchServices/com.apple.launchservices.secure", "LSHandlers"]);
2359
- const match = /LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(stdout);
2360
- const browserId = match?.groups.id ?? "com.apple.Safari";
2361
- if (browserId === "com.apple.safari") {
2362
- return "com.apple.Safari";
2363
- }
2364
- return browserId;
2365
- }
2366
- var execFileAsync;
2367
- var init_default_browser_id = __esm(() => {
2368
- execFileAsync = promisify3(execFile3);
2369
- });
2370
-
2371
- // ../../node_modules/run-applescript/index.js
2372
- import process5 from "node:process";
2373
- import { promisify as promisify4 } from "node:util";
2374
- import { execFile as execFile4, execFileSync } from "node:child_process";
2375
- async function runAppleScript(script, { humanReadableOutput = true, signal } = {}) {
2376
- if (process5.platform !== "darwin") {
2377
- throw new Error("macOS only");
2378
- }
2379
- const outputArguments = humanReadableOutput ? [] : ["-ss"];
2380
- const execOptions = {};
2381
- if (signal) {
2382
- execOptions.signal = signal;
2383
- }
2384
- const { stdout } = await execFileAsync2("osascript", ["-e", script, outputArguments], execOptions);
2385
- return stdout.trim();
2386
- }
2387
- var execFileAsync2;
2388
- var init_run_applescript = __esm(() => {
2389
- execFileAsync2 = promisify4(execFile4);
2390
- });
2391
-
2392
- // ../../node_modules/bundle-name/index.js
2393
- async function bundleName(bundleId) {
2394
- return runAppleScript(`tell application "Finder" to set app_path to application file id "${bundleId}" as string
2395
- tell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`);
2396
- }
2397
- var init_bundle_name = __esm(() => {
2398
- init_run_applescript();
2399
- });
2400
-
2401
- // ../../node_modules/default-browser/windows.js
2402
- import { promisify as promisify5 } from "node:util";
2403
- import { execFile as execFile5 } from "node:child_process";
2404
- async function defaultBrowser(_execFileAsync = execFileAsync3) {
2405
- const { stdout } = await _execFileAsync("reg", [
2406
- "QUERY",
2407
- " HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice",
2408
- "/v",
2409
- "ProgId"
2410
- ]);
2411
- const match = /ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(stdout);
2412
- if (!match) {
2413
- throw new UnknownBrowserError(`Cannot find Windows browser in stdout: ${JSON.stringify(stdout)}`);
2414
- }
2415
- const { id } = match.groups;
2416
- const dotIndex = id.lastIndexOf(".");
2417
- const hyphenIndex = id.lastIndexOf("-");
2418
- const baseIdByDot = dotIndex === -1 ? undefined : id.slice(0, dotIndex);
2419
- const baseIdByHyphen = hyphenIndex === -1 ? undefined : id.slice(0, hyphenIndex);
2420
- return windowsBrowserProgIds[id] ?? windowsBrowserProgIds[baseIdByDot] ?? windowsBrowserProgIds[baseIdByHyphen] ?? { name: id, id };
2421
- }
2422
- var execFileAsync3, windowsBrowserProgIds, _windowsBrowserProgIdMap, UnknownBrowserError;
2423
- var init_windows = __esm(() => {
2424
- execFileAsync3 = promisify5(execFile5);
2425
- windowsBrowserProgIds = {
2426
- MSEdgeHTM: { name: "Edge", id: "com.microsoft.edge" },
2427
- MSEdgeBHTML: { name: "Edge Beta", id: "com.microsoft.edge.beta" },
2428
- MSEdgeDHTML: { name: "Edge Dev", id: "com.microsoft.edge.dev" },
2429
- AppXq0fevzme2pys62n3e0fbqa7peapykr8v: { name: "Edge", id: "com.microsoft.edge.old" },
2430
- ChromeHTML: { name: "Chrome", id: "com.google.chrome" },
2431
- ChromeBHTML: { name: "Chrome Beta", id: "com.google.chrome.beta" },
2432
- ChromeDHTML: { name: "Chrome Dev", id: "com.google.chrome.dev" },
2433
- ChromiumHTM: { name: "Chromium", id: "org.chromium.Chromium" },
2434
- BraveHTML: { name: "Brave", id: "com.brave.Browser" },
2435
- BraveBHTML: { name: "Brave Beta", id: "com.brave.Browser.beta" },
2436
- BraveDHTML: { name: "Brave Dev", id: "com.brave.Browser.dev" },
2437
- BraveSSHTM: { name: "Brave Nightly", id: "com.brave.Browser.nightly" },
2438
- FirefoxURL: { name: "Firefox", id: "org.mozilla.firefox" },
2439
- OperaStable: { name: "Opera", id: "com.operasoftware.Opera" },
2440
- VivaldiHTM: { name: "Vivaldi", id: "com.vivaldi.Vivaldi" },
2441
- "IE.HTTP": { name: "Internet Explorer", id: "com.microsoft.ie" }
2442
- };
2443
- _windowsBrowserProgIdMap = new Map(Object.entries(windowsBrowserProgIds));
2444
- UnknownBrowserError = class UnknownBrowserError extends Error {
2445
- };
2446
- });
2447
-
2448
- // ../../node_modules/default-browser/index.js
2449
- import { promisify as promisify6 } from "node:util";
2450
- import process6 from "node:process";
2451
- import { execFile as execFile6 } from "node:child_process";
2452
- async function defaultBrowser2() {
2453
- if (process6.platform === "darwin") {
2454
- const id = await defaultBrowserId();
2455
- const name = await bundleName(id);
2456
- return { name, id };
2457
- }
2458
- if (process6.platform === "linux") {
2459
- const { stdout } = await execFileAsync4("xdg-mime", ["query", "default", "x-scheme-handler/http"]);
2460
- const id = stdout.trim();
2461
- const name = titleize(id.replace(/.desktop$/, "").replace("-", " "));
2462
- return { name, id };
2463
- }
2464
- if (process6.platform === "win32") {
2465
- return defaultBrowser();
2466
- }
2467
- throw new Error("Only macOS, Linux, and Windows are supported");
2468
- }
2469
- var execFileAsync4, titleize = (string) => string.toLowerCase().replaceAll(/(?:^|\s|-)\S/g, (x) => x.toUpperCase());
2470
- var init_default_browser = __esm(() => {
2471
- init_default_browser_id();
2472
- init_bundle_name();
2473
- init_windows();
2474
- init_windows();
2475
- execFileAsync4 = promisify6(execFile6);
2476
- });
2477
-
2478
- // ../../node_modules/is-in-ssh/index.js
2479
- import process7 from "node:process";
2480
- var isInSsh, is_in_ssh_default;
2481
- var init_is_in_ssh = __esm(() => {
2482
- isInSsh = Boolean(process7.env.SSH_CONNECTION || process7.env.SSH_CLIENT || process7.env.SSH_TTY);
2483
- is_in_ssh_default = isInSsh;
2484
- });
2485
-
2486
- // ../../node_modules/open/index.js
2487
- import process8 from "node:process";
2488
- import path from "node:path";
2489
- import { fileURLToPath } from "node:url";
2490
- import childProcess3 from "node:child_process";
2491
- import fs5, { constants as fsConstants2 } from "node:fs/promises";
2492
- function detectArchBinary(binary2) {
2493
- if (typeof binary2 === "string" || Array.isArray(binary2)) {
2494
- return binary2;
2495
- }
2496
- const { [arch]: archBinary } = binary2;
2497
- if (!archBinary) {
2498
- throw new Error(`${arch} is not supported`);
2499
- }
2500
- return archBinary;
2501
- }
2502
- function detectPlatformBinary({ [platform]: platformBinary }, { wsl } = {}) {
2503
- if (wsl && is_wsl_default) {
2504
- return detectArchBinary(wsl);
2505
- }
2506
- if (!platformBinary) {
2507
- throw new Error(`${platform} is not supported`);
2508
- }
2509
- return detectArchBinary(platformBinary);
2510
- }
2511
- var fallbackAttemptSymbol, __dirname2, localXdgOpenPath, platform, arch, tryEachApp = async (apps, opener) => {
2512
- if (apps.length === 0) {
2513
- return;
2514
- }
2515
- const errors = [];
2516
- for (const app of apps) {
2517
- try {
2518
- return await opener(app);
2519
- } catch (error) {
2520
- errors.push(error);
2521
- }
2522
- }
2523
- throw new AggregateError(errors, "Failed to open in all supported apps");
2524
- }, baseOpen = async (options) => {
2525
- options = {
2526
- wait: false,
2527
- background: false,
2528
- newInstance: false,
2529
- allowNonzeroExitCode: false,
2530
- ...options
2531
- };
2532
- const isFallbackAttempt = options[fallbackAttemptSymbol] === true;
2533
- delete options[fallbackAttemptSymbol];
2534
- if (Array.isArray(options.app)) {
2535
- return tryEachApp(options.app, (singleApp) => baseOpen({
2536
- ...options,
2537
- app: singleApp,
2538
- [fallbackAttemptSymbol]: true
2539
- }));
2540
- }
2541
- let { name: app, arguments: appArguments = [] } = options.app ?? {};
2542
- appArguments = [...appArguments];
2543
- if (Array.isArray(app)) {
2544
- return tryEachApp(app, (appName) => baseOpen({
2545
- ...options,
2546
- app: {
2547
- name: appName,
2548
- arguments: appArguments
2549
- },
2550
- [fallbackAttemptSymbol]: true
2551
- }));
2552
- }
2553
- if (app === "browser" || app === "browserPrivate") {
2554
- const ids = {
2555
- "com.google.chrome": "chrome",
2556
- "google-chrome.desktop": "chrome",
2557
- "com.brave.browser": "brave",
2558
- "org.mozilla.firefox": "firefox",
2559
- "firefox.desktop": "firefox",
2560
- "com.microsoft.msedge": "edge",
2561
- "com.microsoft.edge": "edge",
2562
- "com.microsoft.edgemac": "edge",
2563
- "microsoft-edge.desktop": "edge",
2564
- "com.apple.safari": "safari"
2565
- };
2566
- const flags = {
2567
- chrome: "--incognito",
2568
- brave: "--incognito",
2569
- firefox: "--private-window",
2570
- edge: "--inPrivate"
2571
- };
2572
- let browser;
2573
- if (is_wsl_default) {
2574
- const progId = await wslDefaultBrowser();
2575
- const browserInfo = _windowsBrowserProgIdMap.get(progId);
2576
- browser = browserInfo ?? {};
2577
- } else {
2578
- browser = await defaultBrowser2();
2579
- }
2580
- if (browser.id in ids) {
2581
- const browserName = ids[browser.id.toLowerCase()];
2582
- if (app === "browserPrivate") {
2583
- if (browserName === "safari") {
2584
- throw new Error("Safari doesn't support opening in private mode via command line");
2585
- }
2586
- appArguments.push(flags[browserName]);
2587
- }
2588
- return baseOpen({
2589
- ...options,
2590
- app: {
2591
- name: apps[browserName],
2592
- arguments: appArguments
2593
- }
2594
- });
2595
- }
2596
- throw new Error(`${browser.name} is not supported as a default browser`);
2597
- }
2598
- let command;
2599
- const cliArguments = [];
2600
- const childProcessOptions = {};
2601
- let shouldUseWindowsInWsl = false;
2602
- if (is_wsl_default && !isInsideContainer() && !is_in_ssh_default && !app) {
2603
- shouldUseWindowsInWsl = await canAccessPowerShell();
2604
- }
2605
- if (platform === "darwin") {
2606
- command = "open";
2607
- if (options.wait) {
2608
- cliArguments.push("--wait-apps");
2609
- }
2610
- if (options.background) {
2611
- cliArguments.push("--background");
2612
- }
2613
- if (options.newInstance) {
2614
- cliArguments.push("--new");
2615
- }
2616
- if (app) {
2617
- cliArguments.push("-a", app);
2618
- }
2619
- } else if (platform === "win32" || shouldUseWindowsInWsl) {
2620
- command = await powerShellPath2();
2621
- cliArguments.push(...executePowerShell.argumentsPrefix);
2622
- if (!is_wsl_default) {
2623
- childProcessOptions.windowsVerbatimArguments = true;
2681
+ this._usage = str;
2682
+ return this;
2624
2683
  }
2625
- if (is_wsl_default && options.target) {
2626
- options.target = await convertWslPathToWindows(options.target);
2684
+ name(str) {
2685
+ if (str === undefined)
2686
+ return this._name;
2687
+ this._name = str;
2688
+ return this;
2627
2689
  }
2628
- const encodedArguments = ["$ProgressPreference = 'SilentlyContinue';", "Start"];
2629
- if (options.wait) {
2630
- encodedArguments.push("-Wait");
2690
+ helpGroup(heading) {
2691
+ if (heading === undefined)
2692
+ return this._helpGroupHeading ?? "";
2693
+ this._helpGroupHeading = heading;
2694
+ return this;
2631
2695
  }
2632
- if (app) {
2633
- encodedArguments.push(executePowerShell.escapeArgument(app));
2634
- if (options.target) {
2635
- appArguments.push(options.target);
2636
- }
2637
- } else if (options.target) {
2638
- encodedArguments.push(executePowerShell.escapeArgument(options.target));
2696
+ commandsGroup(heading) {
2697
+ if (heading === undefined)
2698
+ return this._defaultCommandGroup ?? "";
2699
+ this._defaultCommandGroup = heading;
2700
+ return this;
2639
2701
  }
2640
- if (appArguments.length > 0) {
2641
- appArguments = appArguments.map((argument) => executePowerShell.escapeArgument(argument));
2642
- encodedArguments.push("-ArgumentList", appArguments.join(","));
2702
+ optionsGroup(heading) {
2703
+ if (heading === undefined)
2704
+ return this._defaultOptionGroup ?? "";
2705
+ this._defaultOptionGroup = heading;
2706
+ return this;
2643
2707
  }
2644
- options.target = executePowerShell.encodeCommand(encodedArguments.join(" "));
2645
- if (!options.wait) {
2646
- childProcessOptions.stdio = "ignore";
2708
+ _initOptionGroup(option) {
2709
+ if (this._defaultOptionGroup && !option.helpGroupHeading)
2710
+ option.helpGroup(this._defaultOptionGroup);
2647
2711
  }
2648
- } else {
2649
- if (app) {
2650
- command = app;
2651
- } else {
2652
- const isBundled = !__dirname2 || __dirname2 === "/";
2653
- let exeLocalXdgOpen = false;
2654
- try {
2655
- await fs5.access(localXdgOpenPath, fsConstants2.X_OK);
2656
- exeLocalXdgOpen = true;
2657
- } catch {}
2658
- const useSystemXdgOpen = process8.versions.electron ?? (platform === "android" || isBundled || !exeLocalXdgOpen);
2659
- command = useSystemXdgOpen ? "xdg-open" : localXdgOpenPath;
2712
+ _initCommandGroup(cmd) {
2713
+ if (this._defaultCommandGroup && !cmd.helpGroup())
2714
+ cmd.helpGroup(this._defaultCommandGroup);
2660
2715
  }
2661
- if (appArguments.length > 0) {
2662
- cliArguments.push(...appArguments);
2716
+ nameFromFilename(filename) {
2717
+ this._name = path3.basename(filename, path3.extname(filename));
2718
+ return this;
2663
2719
  }
2664
- if (!options.wait) {
2665
- childProcessOptions.stdio = "ignore";
2666
- childProcessOptions.detached = true;
2720
+ executableDir(path4) {
2721
+ if (path4 === undefined)
2722
+ return this._executableDir;
2723
+ this._executableDir = path4;
2724
+ return this;
2667
2725
  }
2668
- }
2669
- if (platform === "darwin" && appArguments.length > 0) {
2670
- cliArguments.push("--args", ...appArguments);
2671
- }
2672
- if (options.target) {
2673
- cliArguments.push(options.target);
2674
- }
2675
- const subprocess = childProcess3.spawn(command, cliArguments, childProcessOptions);
2676
- if (options.wait) {
2677
- return new Promise((resolve, reject) => {
2678
- subprocess.once("error", reject);
2679
- subprocess.once("close", (exitCode) => {
2680
- if (!options.allowNonzeroExitCode && exitCode !== 0) {
2681
- reject(new Error(`Exited with code ${exitCode}`));
2682
- return;
2683
- }
2684
- resolve(subprocess);
2685
- });
2686
- });
2687
- }
2688
- if (isFallbackAttempt) {
2689
- return new Promise((resolve, reject) => {
2690
- subprocess.once("error", reject);
2691
- subprocess.once("spawn", () => {
2692
- subprocess.once("close", (exitCode) => {
2693
- subprocess.off("error", reject);
2694
- if (exitCode !== 0) {
2695
- reject(new Error(`Exited with code ${exitCode}`));
2696
- return;
2697
- }
2698
- subprocess.unref();
2699
- resolve(subprocess);
2700
- });
2726
+ helpInformation(contextOptions) {
2727
+ const helper = this.createHelp();
2728
+ const context = this._getOutputContext(contextOptions);
2729
+ helper.prepareContext({
2730
+ error: context.error,
2731
+ helpWidth: context.helpWidth,
2732
+ outputHasColors: context.hasColors
2701
2733
  });
2702
- });
2703
- }
2704
- subprocess.unref();
2705
- return new Promise((resolve, reject) => {
2706
- subprocess.once("error", reject);
2707
- subprocess.once("spawn", () => {
2708
- subprocess.off("error", reject);
2709
- resolve(subprocess);
2710
- });
2711
- });
2712
- }, open = (target, options) => {
2713
- if (typeof target !== "string") {
2714
- throw new TypeError("Expected a `target`");
2715
- }
2716
- return baseOpen({
2717
- ...options,
2718
- target
2719
- });
2720
- }, apps, open_default;
2721
- var init_open = __esm(() => {
2722
- init_wsl_utils();
2723
- init_powershell_utils();
2724
- init_default_browser();
2725
- init_is_inside_container();
2726
- init_is_in_ssh();
2727
- fallbackAttemptSymbol = Symbol("fallbackAttempt");
2728
- __dirname2 = import.meta.url ? path.dirname(fileURLToPath(import.meta.url)) : "";
2729
- localXdgOpenPath = path.join(__dirname2, "xdg-open");
2730
- ({ platform, arch } = process8);
2731
- apps = {
2732
- browser: "browser",
2733
- browserPrivate: "browserPrivate"
2734
- };
2735
- defineLazyProperty(apps, "chrome", () => detectPlatformBinary({
2736
- darwin: "google chrome",
2737
- win32: "chrome",
2738
- linux: ["google-chrome", "google-chrome-stable", "chromium", "chromium-browser"]
2739
- }, {
2740
- wsl: {
2741
- ia32: "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe",
2742
- x64: ["/mnt/c/Program Files/Google/Chrome/Application/chrome.exe", "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"]
2734
+ const text = helper.formatHelp(this, helper);
2735
+ if (context.hasColors)
2736
+ return text;
2737
+ return this._outputConfiguration.stripColor(text);
2743
2738
  }
2744
- }));
2745
- defineLazyProperty(apps, "brave", () => detectPlatformBinary({
2746
- darwin: "brave browser",
2747
- win32: "brave",
2748
- linux: ["brave-browser", "brave"]
2749
- }, {
2750
- wsl: {
2751
- ia32: "/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe",
2752
- x64: ["/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe", "/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe"]
2739
+ _getOutputContext(contextOptions) {
2740
+ contextOptions = contextOptions || {};
2741
+ const error = !!contextOptions.error;
2742
+ let baseWrite;
2743
+ let hasColors;
2744
+ let helpWidth;
2745
+ if (error) {
2746
+ baseWrite = (str) => this._outputConfiguration.writeErr(str);
2747
+ hasColors = this._outputConfiguration.getErrHasColors();
2748
+ helpWidth = this._outputConfiguration.getErrHelpWidth();
2749
+ } else {
2750
+ baseWrite = (str) => this._outputConfiguration.writeOut(str);
2751
+ hasColors = this._outputConfiguration.getOutHasColors();
2752
+ helpWidth = this._outputConfiguration.getOutHelpWidth();
2753
+ }
2754
+ const write = (str) => {
2755
+ if (!hasColors)
2756
+ str = this._outputConfiguration.stripColor(str);
2757
+ return baseWrite(str);
2758
+ };
2759
+ return { error, write, hasColors, helpWidth };
2753
2760
  }
2754
- }));
2755
- defineLazyProperty(apps, "firefox", () => detectPlatformBinary({
2756
- darwin: "firefox",
2757
- win32: String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,
2758
- linux: "firefox"
2759
- }, {
2760
- wsl: "/mnt/c/Program Files/Mozilla Firefox/firefox.exe"
2761
- }));
2762
- defineLazyProperty(apps, "edge", () => detectPlatformBinary({
2763
- darwin: "microsoft edge",
2764
- win32: "msedge",
2765
- linux: ["microsoft-edge", "microsoft-edge-dev"]
2766
- }, {
2767
- wsl: "/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"
2768
- }));
2769
- defineLazyProperty(apps, "safari", () => detectPlatformBinary({
2770
- darwin: "Safari"
2771
- }));
2772
- open_default = open;
2773
- });
2774
-
2775
- // ../filesystem/src/node.ts
2776
- import { existsSync } from "node:fs";
2777
- import * as fs6 from "node:fs/promises";
2778
- import * as os2 from "node:os";
2779
- import * as path2 from "node:path";
2780
-
2781
- class NodeFileSystem {
2782
- path = {
2783
- join: path2.join,
2784
- resolve: path2.resolve,
2785
- relative: path2.relative,
2786
- dirname: path2.dirname,
2787
- isAbsolute: path2.isAbsolute,
2788
- basename: path2.basename
2789
- };
2790
- env = {
2791
- cwd: process.cwd,
2792
- homedir: os2.homedir,
2793
- tmpdir: os2.tmpdir,
2794
- getenv: (key) => process.env[key]
2795
- };
2796
- utils = {
2797
- open: async (url) => {
2798
- await open_default(url);
2761
+ outputHelp(contextOptions) {
2762
+ let deprecatedCallback;
2763
+ if (typeof contextOptions === "function") {
2764
+ deprecatedCallback = contextOptions;
2765
+ contextOptions = undefined;
2766
+ }
2767
+ const outputContext = this._getOutputContext(contextOptions);
2768
+ const eventContext = {
2769
+ error: outputContext.error,
2770
+ write: outputContext.write,
2771
+ command: this
2772
+ };
2773
+ this._getCommandAndAncestors().reverse().forEach((command) => command.emit("beforeAllHelp", eventContext));
2774
+ this.emit("beforeHelp", eventContext);
2775
+ let helpInformation = this.helpInformation({ error: outputContext.error });
2776
+ if (deprecatedCallback) {
2777
+ helpInformation = deprecatedCallback(helpInformation);
2778
+ if (typeof helpInformation !== "string" && !Buffer.isBuffer(helpInformation)) {
2779
+ throw new Error("outputHelp callback must return a string or a Buffer");
2780
+ }
2781
+ }
2782
+ outputContext.write(helpInformation);
2783
+ if (this._getHelpOption()?.long) {
2784
+ this.emit(this._getHelpOption().long);
2785
+ }
2786
+ this.emit("afterHelp", eventContext);
2787
+ this._getCommandAndAncestors().forEach((command) => command.emit("afterAllHelp", eventContext));
2799
2788
  }
2800
- };
2801
- async readFile(path3, options) {
2802
- try {
2803
- if (options) {
2804
- return await fs6.readFile(path3, "utf-8");
2789
+ helpOption(flags, description) {
2790
+ if (typeof flags === "boolean") {
2791
+ if (flags) {
2792
+ if (this._helpOption === null)
2793
+ this._helpOption = undefined;
2794
+ if (this._defaultOptionGroup) {
2795
+ this._initOptionGroup(this._getHelpOption());
2796
+ }
2797
+ } else {
2798
+ this._helpOption = null;
2799
+ }
2800
+ return this;
2805
2801
  }
2806
- return await fs6.readFile(path3);
2807
- } catch (error) {
2808
- if (this.isEnoent(error))
2809
- return null;
2810
- throw error;
2802
+ this._helpOption = this.createOption(flags ?? "-h, --help", description ?? "display help for command");
2803
+ if (flags || description)
2804
+ this._initOptionGroup(this._helpOption);
2805
+ return this;
2811
2806
  }
2812
- }
2813
- async writeFile(filePath, data) {
2814
- const dir = path2.dirname(filePath);
2815
- if (dir) {
2816
- await fs6.mkdir(dir, { recursive: true });
2807
+ _getHelpOption() {
2808
+ if (this._helpOption === undefined) {
2809
+ this.helpOption(undefined, undefined);
2810
+ }
2811
+ return this._helpOption;
2817
2812
  }
2818
- await fs6.writeFile(filePath, data);
2819
- }
2820
- async appendFile(filePath, data) {
2821
- const dir = path2.dirname(filePath);
2822
- if (dir) {
2823
- await fs6.mkdir(dir, { recursive: true });
2813
+ addHelpOption(option) {
2814
+ this._helpOption = option;
2815
+ this._initOptionGroup(option);
2816
+ return this;
2824
2817
  }
2825
- await fs6.appendFile(filePath, data);
2826
- }
2827
- async readdir(dirPath) {
2828
- try {
2829
- return await fs6.readdir(dirPath);
2830
- } catch (error) {
2831
- if (this.isEnoent(error))
2832
- return [];
2833
- throw error;
2818
+ help(contextOptions) {
2819
+ this.outputHelp(contextOptions);
2820
+ let exitCode = Number(process9.exitCode ?? 0);
2821
+ if (exitCode === 0 && contextOptions && typeof contextOptions !== "function" && contextOptions.error) {
2822
+ exitCode = 1;
2823
+ }
2824
+ this._exit(exitCode, "commander.help", "(outputHelp)");
2834
2825
  }
2835
- }
2836
- async stat(filePath) {
2837
- try {
2838
- const stats = await fs6.stat(filePath);
2839
- return {
2840
- isFile: () => stats.isFile(),
2841
- isDirectory: () => stats.isDirectory(),
2842
- size: stats.size,
2843
- mtimeMs: stats.mtimeMs
2844
- };
2845
- } catch (error) {
2846
- if (this.isEnoent(error))
2847
- return null;
2848
- throw error;
2826
+ addHelpText(position, text) {
2827
+ const allowedValues = ["beforeAll", "before", "after", "afterAll"];
2828
+ if (!allowedValues.includes(position)) {
2829
+ throw new Error(`Unexpected value for position to addHelpText.
2830
+ Expecting one of '${allowedValues.join("', '")}'`);
2831
+ }
2832
+ const helpEvent = `${position}Help`;
2833
+ this.on(helpEvent, (context) => {
2834
+ let helpStr;
2835
+ if (typeof text === "function") {
2836
+ helpStr = text({ error: context.error, command: context.command });
2837
+ } else {
2838
+ helpStr = text;
2839
+ }
2840
+ if (helpStr) {
2841
+ context.write(`${helpStr}
2842
+ `);
2843
+ }
2844
+ });
2845
+ return this;
2849
2846
  }
2850
- }
2851
- async exists(filePath) {
2852
- return existsSync(filePath);
2853
- }
2854
- async mkdir(dirPath) {
2855
- await fs6.mkdir(dirPath, { recursive: true });
2856
- }
2857
- async rm(filePath) {
2858
- await fs6.rm(filePath, { recursive: true, force: true });
2859
- }
2860
- async rename(oldPath, newPath) {
2861
- await fs6.rename(oldPath, newPath);
2862
- }
2863
- async realpath(filePath) {
2864
- try {
2865
- return await fs6.realpath(filePath);
2866
- } catch (error) {
2867
- if (this.isEnoent(error))
2868
- return filePath;
2869
- throw error;
2847
+ _outputHelpIfRequested(args) {
2848
+ const helpOption = this._getHelpOption();
2849
+ const helpRequested = helpOption && args.find((arg) => helpOption.is(arg));
2850
+ if (helpRequested) {
2851
+ this.outputHelp();
2852
+ this._exit(0, "commander.helpDisplayed", "(outputHelp)");
2853
+ }
2870
2854
  }
2871
2855
  }
2872
- async getTempDir() {
2873
- return await fs6.mkdtemp(path2.join(os2.tmpdir(), "uipath-fs-"));
2874
- }
2875
- async copyDirectory(sourcePath, destPath) {
2876
- const sourceStats = await this.stat(sourcePath);
2877
- if (!sourceStats) {
2878
- throw new Error(`Source directory does not exist: ${sourcePath}`);
2879
- }
2880
- if (!sourceStats.isDirectory()) {
2881
- throw new Error(`Source path is not a directory: ${sourcePath}`);
2882
- }
2883
- await this.mkdir(destPath);
2884
- const entries = await this.readdir(sourcePath);
2885
- for (const entry of entries) {
2886
- const srcEntry = path2.join(sourcePath, entry);
2887
- const destEntry = path2.join(destPath, entry);
2888
- const entryStats = await this.stat(srcEntry);
2889
- if (!entryStats)
2890
- continue;
2891
- if (entryStats.isDirectory()) {
2892
- await this.copyDirectory(srcEntry, destEntry);
2893
- } else if (entryStats.isFile()) {
2894
- const content = await this.readFile(srcEntry);
2895
- if (content !== null) {
2896
- await this.writeFile(destEntry, content);
2856
+ function incrementNodeInspectorPort(args) {
2857
+ return args.map((arg) => {
2858
+ if (!arg.startsWith("--inspect")) {
2859
+ return arg;
2860
+ }
2861
+ let debugOption;
2862
+ let debugHost = "127.0.0.1";
2863
+ let debugPort = "9229";
2864
+ let match;
2865
+ if ((match = arg.match(/^(--inspect(-brk)?)$/)) !== null) {
2866
+ debugOption = match[1];
2867
+ } else if ((match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+)$/)) !== null) {
2868
+ debugOption = match[1];
2869
+ if (/^\d+$/.test(match[3])) {
2870
+ debugPort = match[3];
2871
+ } else {
2872
+ debugHost = match[3];
2897
2873
  }
2874
+ } else if ((match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/)) !== null) {
2875
+ debugOption = match[1];
2876
+ debugHost = match[3];
2877
+ debugPort = match[4];
2898
2878
  }
2899
- }
2879
+ if (debugOption && debugPort !== "0") {
2880
+ return `${debugOption}=${debugHost}:${parseInt(debugPort) + 1}`;
2881
+ }
2882
+ return arg;
2883
+ });
2900
2884
  }
2901
- isEnoent(error) {
2902
- return typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT";
2885
+ function useColor() {
2886
+ if (process9.env.NO_COLOR || process9.env.FORCE_COLOR === "0" || process9.env.FORCE_COLOR === "false")
2887
+ return false;
2888
+ if (process9.env.FORCE_COLOR || process9.env.CLICOLOR_FORCE !== undefined)
2889
+ return true;
2890
+ return;
2903
2891
  }
2904
- }
2905
- var init_node = __esm(() => {
2906
- init_open();
2892
+ exports.Command = Command;
2893
+ exports.useColor = useColor;
2907
2894
  });
2908
- // ../filesystem/src/index.ts
2909
- var fsInstance, getFileSystem = () => {
2910
- return fsInstance;
2911
- };
2912
- var init_src = __esm(() => {
2913
- init_node();
2914
- init_node();
2915
- fsInstance = new NodeFileSystem;
2895
+
2896
+ // ../../node_modules/commander/index.js
2897
+ var require_commander = __commonJS((exports) => {
2898
+ var { Argument } = require_argument();
2899
+ var { Command } = require_command();
2900
+ var { CommanderError, InvalidArgumentError } = require_error();
2901
+ var { Help } = require_help();
2902
+ var { Option } = require_option();
2903
+ exports.program = new Command;
2904
+ exports.createCommand = (name) => new Command(name);
2905
+ exports.createOption = (flags, description) => new Option(flags, description);
2906
+ exports.createArgument = (name, description) => new Argument(name, description);
2907
+ exports.Command = Command;
2908
+ exports.Option = Option;
2909
+ exports.Argument = Argument;
2910
+ exports.Help = Help;
2911
+ exports.CommanderError = CommanderError;
2912
+ exports.InvalidArgumentError = InvalidArgumentError;
2913
+ exports.InvalidOptionArgumentError = InvalidArgumentError;
2916
2914
  });
2917
2915
 
2918
2916
  // ../../node_modules/cli-width/index.js
@@ -27364,7 +27362,7 @@ var require_src6 = __commonJS((exports) => {
27364
27362
  // package.json
27365
27363
  var package_default = {
27366
27364
  name: "@uipath/vertical-solutions-tool",
27367
- version: "1.0.2",
27365
+ version: "1.1.0",
27368
27366
  description: "Scaffold and generate Vertical Solution projects.",
27369
27367
  private: false,
27370
27368
  repository: {
@@ -27419,6 +27417,9 @@ var package_default = {
27419
27417
  }
27420
27418
  };
27421
27419
 
27420
+ // ../common/src/attachment-binding.ts
27421
+ init_src();
27422
+
27422
27423
  // ../common/src/catch-error.ts
27423
27424
  function isPromiseLike(value) {
27424
27425
  return value !== null && typeof value === "object" && typeof value.then === "function";
@@ -32578,15 +32579,26 @@ class SuccessOutput {
32578
32579
  }
32579
32580
  }
32580
32581
  }
32581
- function printOutput(data, format = "json", logFn) {
32582
+ function escapeNonAscii(jsonText) {
32583
+ return jsonText.replace(/[\u0080-\uffff]/g, (c) => {
32584
+ const hex = c.charCodeAt(0).toString(16).padStart(4, "0");
32585
+ return `\\u${hex}`;
32586
+ });
32587
+ }
32588
+ function needsAsciiSafeJson(sink) {
32589
+ return process.platform === "win32" && !sink.capabilities.isInteractive;
32590
+ }
32591
+ function printOutput(data, format = "json", logFn, asciiSafe = false) {
32582
32592
  if (!data) {
32583
32593
  logFn("Empty response object. No data to display.");
32584
32594
  return;
32585
32595
  }
32586
32596
  switch (format) {
32587
- case "json":
32588
- logFn(JSON.stringify(data, null, 2));
32597
+ case "json": {
32598
+ const json2 = JSON.stringify(data, null, 2);
32599
+ logFn(asciiSafe ? escapeNonAscii(json2) : json2);
32589
32600
  break;
32601
+ }
32590
32602
  case "yaml":
32591
32603
  logFn(toYaml(data));
32592
32604
  break;
@@ -32621,7 +32633,7 @@ function printOutput(data, format = "json", logFn) {
32621
32633
  function logOutput(data, format = "json") {
32622
32634
  const sink = getOutputSink();
32623
32635
  printOutput(data, format, (msg) => sink.writeOut(`${msg}
32624
- `));
32636
+ `), needsAsciiSafeJson(sink));
32625
32637
  }
32626
32638
  function cellToString(val) {
32627
32639
  return val != null && typeof val === "object" ? JSON.stringify(val) : String(val ?? "");
@@ -32801,7 +32813,9 @@ var OutputFormatter;
32801
32813
  const format = getOutputFormat();
32802
32814
  const sink = getOutputSink();
32803
32815
  if (format === "json") {
32804
- sink.writeErr(`${JSON.stringify(data)}
32816
+ const json2 = JSON.stringify(data);
32817
+ const safe = needsAsciiSafeJson(sink) ? escapeNonAscii(json2) : json2;
32818
+ sink.writeErr(`${safe}
32805
32819
  `);
32806
32820
  } else {
32807
32821
  for (const [key, value] of Object.entries(data)) {
@@ -32817,9 +32831,10 @@ var OutputFormatter;
32817
32831
  data.Data = applyFilter(data.Data, filter);
32818
32832
  }
32819
32833
  const lines = [];
32834
+ const sink = getOutputSink();
32820
32835
  printOutput(data, getOutputFormat(), (msg) => {
32821
32836
  lines.push(msg);
32822
- });
32837
+ }, needsAsciiSafeJson(sink));
32823
32838
  return lines.join(`
32824
32839
  `);
32825
32840
  }
@@ -54989,7 +55004,9 @@ var DEFAULT_SCOPES = [
54989
55004
  "AutomationSolutions",
54990
55005
  "StudioWebTypeCacheService",
54991
55006
  "Docs.GPT.Search",
54992
- "Insights"
55007
+ "Insights",
55008
+ "ReferenceToken",
55009
+ "Audit.Read"
54993
55010
  ];
54994
55011
  var normalizeAndValidateBaseUrl = (rawUrl) => {
54995
55012
  let baseUrl = rawUrl;
@@ -55128,6 +55145,7 @@ var getTokenExpiration = (accessToken) => {
55128
55145
 
55129
55146
  // ../auth/src/envAuth.ts
55130
55147
  var ENV_AUTH_ENABLE_VAR = "UIPATH_CLI_ENABLE_ENV_AUTH";
55148
+ var ENFORCE_ROBOT_AUTH_VAR = "UIPATH_CLI_ENFORCE_ROBOT_AUTH";
55131
55149
  var ENV_AUTH_VARS = {
55132
55150
  token: "UIPATH_CLI_AUTH_TOKEN",
55133
55151
  organizationName: "UIPATH_CLI_ORGANIZATION_NAME",
@@ -55143,6 +55161,7 @@ class EnvAuthConfigError extends Error {
55143
55161
  }
55144
55162
  }
55145
55163
  var isEnvAuthEnabled = () => process.env[ENV_AUTH_ENABLE_VAR] === "true";
55164
+ var isRobotAuthEnforced = () => process.env[ENFORCE_ROBOT_AUTH_VAR] === "true";
55146
55165
  var requireEnv = (name) => {
55147
55166
  const value = process.env[name];
55148
55167
  if (!value) {
@@ -55184,7 +55203,9 @@ var readAuthFromEnv = () => {
55184
55203
  expiration
55185
55204
  };
55186
55205
  };
55206
+
55187
55207
  // ../auth/src/robotClientFallback.ts
55208
+ init_src();
55188
55209
  var DEFAULT_TIMEOUT_MS = 1000;
55189
55210
  var CLOSE_TIMEOUT_MS = 500;
55190
55211
  var NOTICE_SENTINEL = Symbol.for("@uipath/auth/robotFallbackNoticePrinted");
@@ -55196,6 +55217,35 @@ var printNoticeOnce = () => {
55196
55217
  catchError2(() => process.stderr.write(`Using UiPath Robot credentials. Run 'uip login' for a dedicated session.
55197
55218
  `));
55198
55219
  };
55220
+ var ROBOT_USER_SERVICES_PIPE = "UiPathUserServices";
55221
+ var ROBOT_USER_SERVICES_ALTERNATE_PIPE = `${ROBOT_USER_SERVICES_PIPE}Alternate`;
55222
+ var PIPE_NAME_MAX_LENGTH = 103;
55223
+ var getRobotIpcPipeNames = async () => {
55224
+ const fs7 = getFileSystem();
55225
+ const username = fs7.env.getenv("USER") ?? fs7.env.getenv("USERNAME");
55226
+ if (!username) {
55227
+ throw new Error("Unable to determine current username");
55228
+ }
55229
+ const tempPath = fs7.env.getenv("TMPDIR") ?? "/tmp/";
55230
+ return [ROBOT_USER_SERVICES_PIPE, ROBOT_USER_SERVICES_ALTERNATE_PIPE].map((baseName) => fs7.path.join(tempPath, `${baseName}_${username}`).substring(0, PIPE_NAME_MAX_LENGTH));
55231
+ };
55232
+ var defaultIsRobotIpcAvailable = async () => {
55233
+ if (process.platform === "win32") {
55234
+ return true;
55235
+ }
55236
+ const [pipeNamesError, pipeNames] = await catchError2(getRobotIpcPipeNames());
55237
+ if (pipeNamesError || !pipeNames) {
55238
+ return false;
55239
+ }
55240
+ const fs7 = getFileSystem();
55241
+ for (const pipeName of pipeNames) {
55242
+ const [existsError, exists] = await catchError2(fs7.exists(pipeName));
55243
+ if (!existsError && exists === true) {
55244
+ return true;
55245
+ }
55246
+ }
55247
+ return false;
55248
+ };
55199
55249
  var withTimeout = (promise2, timeoutMs) => new Promise((resolve2, reject) => {
55200
55250
  const timer = setTimeout(() => reject(new Error(`Robot IPC call timed out after ${timeoutMs}ms`)), timeoutMs);
55201
55251
  promise2.then((value) => {
@@ -55227,14 +55277,20 @@ var defaultLoadModule = async () => {
55227
55277
  var tryRobotClientFallback = async (options = {}) => {
55228
55278
  if (isBrowser())
55229
55279
  return;
55230
- if (process.env.CI || process.env.GITHUB_ACTIONS) {
55231
- return;
55232
- }
55233
- if (process.env.UIPATH_URL) {
55234
- return;
55280
+ if (!options.force) {
55281
+ if (process.env.CI || process.env.GITHUB_ACTIONS) {
55282
+ return;
55283
+ }
55284
+ if (process.env.UIPATH_URL) {
55285
+ return;
55286
+ }
55235
55287
  }
55236
55288
  const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
55289
+ const isRobotIpcAvailable = options.isRobotIpcAvailable ?? defaultIsRobotIpcAvailable;
55237
55290
  const loadModule = options.loadModule ?? defaultLoadModule;
55291
+ if (!await isRobotIpcAvailable()) {
55292
+ return;
55293
+ }
55238
55294
  const mod2 = await loadModule();
55239
55295
  if (!mod2)
55240
55296
  return;
@@ -55502,10 +55558,6 @@ function normalizeTokenRefreshUnavailableFailure() {
55502
55558
  return "token refresh failed before authentication completed";
55503
55559
  }
55504
55560
  var getLoginStatusWithDeps = async (options = {}, deps = {}) => {
55505
- if (isEnvAuthEnabled()) {
55506
- return readAuthFromEnv();
55507
- }
55508
- const { envFilePath = DEFAULT_ENV_FILENAME, ensureTokenValidityMinutes } = options;
55509
55561
  const {
55510
55562
  resolveEnvFilePath = resolveEnvFilePathAsync,
55511
55563
  loadEnvFile = loadEnvFileAsync,
@@ -55515,6 +55567,34 @@ var getLoginStatusWithDeps = async (options = {}, deps = {}) => {
55515
55567
  resolveConfig = resolveConfigAsync,
55516
55568
  robotFallback = tryRobotClientFallback
55517
55569
  } = deps;
55570
+ if (isRobotAuthEnforced()) {
55571
+ if (isEnvAuthEnabled()) {
55572
+ throw new EnvAuthConfigError(`${ENV_AUTH_ENABLE_VAR}=true and ${ENFORCE_ROBOT_AUTH_VAR}=true ` + `are mutually exclusive. Unset one of them and re-run.`);
55573
+ }
55574
+ const robotCreds = await robotFallback({ force: true });
55575
+ if (!robotCreds) {
55576
+ return {
55577
+ loginStatus: "Not logged in",
55578
+ hint: `${ENFORCE_ROBOT_AUTH_VAR}=true but the UiPath Robot ` + `session is unavailable. Start and sign in to the Assistant, ` + `or unset ${ENFORCE_ROBOT_AUTH_VAR} to fall back to file or ` + `env-var authentication.`
55579
+ };
55580
+ }
55581
+ const expiration2 = getTokenExpiration(robotCreds.accessToken);
55582
+ return {
55583
+ loginStatus: "Logged in",
55584
+ accessToken: robotCreds.accessToken,
55585
+ baseUrl: robotCreds.baseUrl,
55586
+ organizationName: robotCreds.organizationName,
55587
+ organizationId: robotCreds.organizationId,
55588
+ tenantName: robotCreds.tenantName,
55589
+ tenantId: robotCreds.tenantId,
55590
+ expiration: expiration2,
55591
+ source: "robot" /* Robot */
55592
+ };
55593
+ }
55594
+ if (isEnvAuthEnabled()) {
55595
+ return readAuthFromEnv();
55596
+ }
55597
+ const { envFilePath = DEFAULT_ENV_FILENAME, ensureTokenValidityMinutes } = options;
55518
55598
  const { absolutePath } = await resolveEnvFilePath(envFilePath);
55519
55599
  if (absolutePath === undefined) {
55520
55600
  const robotCreds = await robotFallback();
@@ -55681,7 +55761,7 @@ var getAuthContext = async (options = {}) => {
55681
55761
  throw new Error("Tenant ID not available. Ensure UIPATH_TENANT_ID is set.");
55682
55762
  }
55683
55763
  if (options.requireTenantName && tenantName === undefined) {
55684
- throw new Error("Tenant not provided and UIPATH_TENANT_NAME not set. Please provide a tenant argument or set UIPATH_TENANT_NAME.");
55764
+ throw new Error("Tenant not provided and UIPATH_TENANT_NAME not set. Run 'uip login' to select a tenant, or use 'uip login tenant set <tenant>' to switch tenants.");
55685
55765
  }
55686
55766
  return {
55687
55767
  baseUrl: status.baseUrl,