@uipath/tasks-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.
- package/browser.json +3 -0
- package/dist/index.js +20 -42285
- package/dist/tool.js +2159 -2061
- package/package.json +4 -11
- package/src/commands/tasks.ts +22 -7
- package/src/index.ts +6 -7
package/dist/tool.js
CHANGED
|
@@ -33,533 +33,837 @@ var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports,
|
|
|
33
33
|
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
34
34
|
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
35
35
|
|
|
36
|
-
// ../../node_modules/
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
36
|
+
// ../../node_modules/is-inside-container/node_modules/is-docker/index.js
|
|
37
|
+
import fs from "node:fs";
|
|
38
|
+
function hasDockerEnv() {
|
|
39
|
+
try {
|
|
40
|
+
fs.statSync("/.dockerenv");
|
|
41
|
+
return true;
|
|
42
|
+
} catch {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function hasDockerCGroup() {
|
|
47
|
+
try {
|
|
48
|
+
return fs.readFileSync("/proc/self/cgroup", "utf8").includes("docker");
|
|
49
|
+
} catch {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function isDocker() {
|
|
54
|
+
if (isDockerCached === undefined) {
|
|
55
|
+
isDockerCached = hasDockerEnv() || hasDockerCGroup();
|
|
47
56
|
}
|
|
57
|
+
return isDockerCached;
|
|
58
|
+
}
|
|
59
|
+
var isDockerCached;
|
|
60
|
+
var init_is_docker = () => {};
|
|
48
61
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
62
|
+
// ../../node_modules/is-inside-container/index.js
|
|
63
|
+
import fs2 from "node:fs";
|
|
64
|
+
function isInsideContainer() {
|
|
65
|
+
if (cachedResult === undefined) {
|
|
66
|
+
cachedResult = hasContainerEnv() || isDocker();
|
|
55
67
|
}
|
|
56
|
-
|
|
57
|
-
|
|
68
|
+
return cachedResult;
|
|
69
|
+
}
|
|
70
|
+
var cachedResult, hasContainerEnv = () => {
|
|
71
|
+
try {
|
|
72
|
+
fs2.statSync("/run/.containerenv");
|
|
73
|
+
return true;
|
|
74
|
+
} catch {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
var init_is_inside_container = __esm(() => {
|
|
79
|
+
init_is_docker();
|
|
58
80
|
});
|
|
59
81
|
|
|
60
|
-
// ../../node_modules/
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
this.argChoices = undefined;
|
|
72
|
-
switch (name[0]) {
|
|
73
|
-
case "<":
|
|
74
|
-
this.required = true;
|
|
75
|
-
this._name = name.slice(1, -1);
|
|
76
|
-
break;
|
|
77
|
-
case "[":
|
|
78
|
-
this.required = false;
|
|
79
|
-
this._name = name.slice(1, -1);
|
|
80
|
-
break;
|
|
81
|
-
default:
|
|
82
|
-
this.required = true;
|
|
83
|
-
this._name = name;
|
|
84
|
-
break;
|
|
85
|
-
}
|
|
86
|
-
if (this._name.endsWith("...")) {
|
|
87
|
-
this.variadic = true;
|
|
88
|
-
this._name = this._name.slice(0, -3);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
name() {
|
|
92
|
-
return this._name;
|
|
93
|
-
}
|
|
94
|
-
_collectValue(value, previous) {
|
|
95
|
-
if (previous === this.defaultValue || !Array.isArray(previous)) {
|
|
96
|
-
return [value];
|
|
97
|
-
}
|
|
98
|
-
previous.push(value);
|
|
99
|
-
return previous;
|
|
100
|
-
}
|
|
101
|
-
default(value, description) {
|
|
102
|
-
this.defaultValue = value;
|
|
103
|
-
this.defaultValueDescription = description;
|
|
104
|
-
return this;
|
|
105
|
-
}
|
|
106
|
-
argParser(fn) {
|
|
107
|
-
this.parseArg = fn;
|
|
108
|
-
return this;
|
|
109
|
-
}
|
|
110
|
-
choices(values) {
|
|
111
|
-
this.argChoices = values.slice();
|
|
112
|
-
this.parseArg = (arg, previous) => {
|
|
113
|
-
if (!this.argChoices.includes(arg)) {
|
|
114
|
-
throw new InvalidArgumentError(`Allowed choices are ${this.argChoices.join(", ")}.`);
|
|
115
|
-
}
|
|
116
|
-
if (this.variadic) {
|
|
117
|
-
return this._collectValue(arg, previous);
|
|
118
|
-
}
|
|
119
|
-
return arg;
|
|
120
|
-
};
|
|
121
|
-
return this;
|
|
122
|
-
}
|
|
123
|
-
argRequired() {
|
|
124
|
-
this.required = true;
|
|
125
|
-
return this;
|
|
126
|
-
}
|
|
127
|
-
argOptional() {
|
|
128
|
-
this.required = false;
|
|
129
|
-
return this;
|
|
82
|
+
// ../../node_modules/wsl-utils/node_modules/is-wsl/index.js
|
|
83
|
+
import process2 from "node:process";
|
|
84
|
+
import os from "node:os";
|
|
85
|
+
import fs3 from "node:fs";
|
|
86
|
+
var isWsl = () => {
|
|
87
|
+
if (process2.platform !== "linux") {
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
if (os.release().toLowerCase().includes("microsoft")) {
|
|
91
|
+
if (isInsideContainer()) {
|
|
92
|
+
return false;
|
|
130
93
|
}
|
|
94
|
+
return true;
|
|
131
95
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
96
|
+
try {
|
|
97
|
+
if (fs3.readFileSync("/proc/version", "utf8").toLowerCase().includes("microsoft")) {
|
|
98
|
+
return !isInsideContainer();
|
|
99
|
+
}
|
|
100
|
+
} catch {}
|
|
101
|
+
if (fs3.existsSync("/proc/sys/fs/binfmt_misc/WSLInterop") || fs3.existsSync("/run/WSL")) {
|
|
102
|
+
return !isInsideContainer();
|
|
135
103
|
}
|
|
136
|
-
|
|
137
|
-
|
|
104
|
+
return false;
|
|
105
|
+
}, is_wsl_default;
|
|
106
|
+
var init_is_wsl = __esm(() => {
|
|
107
|
+
init_is_inside_container();
|
|
108
|
+
is_wsl_default = process2.env.__IS_WSL_TEST__ ? isWsl : isWsl();
|
|
138
109
|
});
|
|
139
110
|
|
|
140
|
-
// ../../node_modules/
|
|
141
|
-
|
|
142
|
-
|
|
111
|
+
// ../../node_modules/powershell-utils/index.js
|
|
112
|
+
import process3 from "node:process";
|
|
113
|
+
import { Buffer as Buffer2 } from "node:buffer";
|
|
114
|
+
import { promisify } from "node:util";
|
|
115
|
+
import childProcess from "node:child_process";
|
|
116
|
+
var execFile, powerShellPath = () => `${process3.env.SYSTEMROOT || process3.env.windir || String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`, executePowerShell = async (command, options = {}) => {
|
|
117
|
+
const {
|
|
118
|
+
powerShellPath: psPath,
|
|
119
|
+
...execFileOptions
|
|
120
|
+
} = options;
|
|
121
|
+
const encodedCommand = executePowerShell.encodeCommand(command);
|
|
122
|
+
return execFile(psPath ?? powerShellPath(), [
|
|
123
|
+
...executePowerShell.argumentsPrefix,
|
|
124
|
+
encodedCommand
|
|
125
|
+
], {
|
|
126
|
+
encoding: "utf8",
|
|
127
|
+
...execFileOptions
|
|
128
|
+
});
|
|
129
|
+
};
|
|
130
|
+
var init_powershell_utils = __esm(() => {
|
|
131
|
+
execFile = promisify(childProcess.execFile);
|
|
132
|
+
executePowerShell.argumentsPrefix = [
|
|
133
|
+
"-NoProfile",
|
|
134
|
+
"-NonInteractive",
|
|
135
|
+
"-ExecutionPolicy",
|
|
136
|
+
"Bypass",
|
|
137
|
+
"-EncodedCommand"
|
|
138
|
+
];
|
|
139
|
+
executePowerShell.encodeCommand = (command) => Buffer2.from(command, "utf16le").toString("base64");
|
|
140
|
+
executePowerShell.escapeArgument = (value) => `'${String(value).replaceAll("'", "''")}'`;
|
|
141
|
+
});
|
|
143
142
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
this.showGlobalOptions = false;
|
|
151
|
-
}
|
|
152
|
-
prepareContext(contextOptions) {
|
|
153
|
-
this.helpWidth = this.helpWidth ?? contextOptions.helpWidth ?? 80;
|
|
154
|
-
}
|
|
155
|
-
visibleCommands(cmd) {
|
|
156
|
-
const visibleCommands = cmd.commands.filter((cmd2) => !cmd2._hidden);
|
|
157
|
-
const helpCommand = cmd._getHelpCommand();
|
|
158
|
-
if (helpCommand && !helpCommand._hidden) {
|
|
159
|
-
visibleCommands.push(helpCommand);
|
|
160
|
-
}
|
|
161
|
-
if (this.sortSubcommands) {
|
|
162
|
-
visibleCommands.sort((a, b) => {
|
|
163
|
-
return a.name().localeCompare(b.name());
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
return visibleCommands;
|
|
167
|
-
}
|
|
168
|
-
compareOptions(a, b) {
|
|
169
|
-
const getSortKey = (option) => {
|
|
170
|
-
return option.short ? option.short.replace(/^-/, "") : option.long.replace(/^--/, "");
|
|
171
|
-
};
|
|
172
|
-
return getSortKey(a).localeCompare(getSortKey(b));
|
|
173
|
-
}
|
|
174
|
-
visibleOptions(cmd) {
|
|
175
|
-
const visibleOptions = cmd.options.filter((option) => !option.hidden);
|
|
176
|
-
const helpOption = cmd._getHelpOption();
|
|
177
|
-
if (helpOption && !helpOption.hidden) {
|
|
178
|
-
const removeShort = helpOption.short && cmd._findOption(helpOption.short);
|
|
179
|
-
const removeLong = helpOption.long && cmd._findOption(helpOption.long);
|
|
180
|
-
if (!removeShort && !removeLong) {
|
|
181
|
-
visibleOptions.push(helpOption);
|
|
182
|
-
} else if (helpOption.long && !removeLong) {
|
|
183
|
-
visibleOptions.push(cmd.createOption(helpOption.long, helpOption.description));
|
|
184
|
-
} else if (helpOption.short && !removeShort) {
|
|
185
|
-
visibleOptions.push(cmd.createOption(helpOption.short, helpOption.description));
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
if (this.sortOptions) {
|
|
189
|
-
visibleOptions.sort(this.compareOptions);
|
|
190
|
-
}
|
|
191
|
-
return visibleOptions;
|
|
192
|
-
}
|
|
193
|
-
visibleGlobalOptions(cmd) {
|
|
194
|
-
if (!this.showGlobalOptions)
|
|
195
|
-
return [];
|
|
196
|
-
const globalOptions = [];
|
|
197
|
-
for (let ancestorCmd = cmd.parent;ancestorCmd; ancestorCmd = ancestorCmd.parent) {
|
|
198
|
-
const visibleOptions = ancestorCmd.options.filter((option) => !option.hidden);
|
|
199
|
-
globalOptions.push(...visibleOptions);
|
|
200
|
-
}
|
|
201
|
-
if (this.sortOptions) {
|
|
202
|
-
globalOptions.sort(this.compareOptions);
|
|
203
|
-
}
|
|
204
|
-
return globalOptions;
|
|
205
|
-
}
|
|
206
|
-
visibleArguments(cmd) {
|
|
207
|
-
if (cmd._argsDescription) {
|
|
208
|
-
cmd.registeredArguments.forEach((argument) => {
|
|
209
|
-
argument.description = argument.description || cmd._argsDescription[argument.name()] || "";
|
|
210
|
-
});
|
|
211
|
-
}
|
|
212
|
-
if (cmd.registeredArguments.find((argument) => argument.description)) {
|
|
213
|
-
return cmd.registeredArguments;
|
|
214
|
-
}
|
|
215
|
-
return [];
|
|
216
|
-
}
|
|
217
|
-
subcommandTerm(cmd) {
|
|
218
|
-
const args = cmd.registeredArguments.map((arg) => humanReadableArgName(arg)).join(" ");
|
|
219
|
-
return cmd._name + (cmd._aliases[0] ? "|" + cmd._aliases[0] : "") + (cmd.options.length ? " [options]" : "") + (args ? " " + args : "");
|
|
220
|
-
}
|
|
221
|
-
optionTerm(option) {
|
|
222
|
-
return option.flags;
|
|
223
|
-
}
|
|
224
|
-
argumentTerm(argument) {
|
|
225
|
-
return argument.name();
|
|
226
|
-
}
|
|
227
|
-
longestSubcommandTermLength(cmd, helper) {
|
|
228
|
-
return helper.visibleCommands(cmd).reduce((max, command) => {
|
|
229
|
-
return Math.max(max, this.displayWidth(helper.styleSubcommandTerm(helper.subcommandTerm(command))));
|
|
230
|
-
}, 0);
|
|
231
|
-
}
|
|
232
|
-
longestOptionTermLength(cmd, helper) {
|
|
233
|
-
return helper.visibleOptions(cmd).reduce((max, option) => {
|
|
234
|
-
return Math.max(max, this.displayWidth(helper.styleOptionTerm(helper.optionTerm(option))));
|
|
235
|
-
}, 0);
|
|
236
|
-
}
|
|
237
|
-
longestGlobalOptionTermLength(cmd, helper) {
|
|
238
|
-
return helper.visibleGlobalOptions(cmd).reduce((max, option) => {
|
|
239
|
-
return Math.max(max, this.displayWidth(helper.styleOptionTerm(helper.optionTerm(option))));
|
|
240
|
-
}, 0);
|
|
241
|
-
}
|
|
242
|
-
longestArgumentTermLength(cmd, helper) {
|
|
243
|
-
return helper.visibleArguments(cmd).reduce((max, argument) => {
|
|
244
|
-
return Math.max(max, this.displayWidth(helper.styleArgumentTerm(helper.argumentTerm(argument))));
|
|
245
|
-
}, 0);
|
|
246
|
-
}
|
|
247
|
-
commandUsage(cmd) {
|
|
248
|
-
let cmdName = cmd._name;
|
|
249
|
-
if (cmd._aliases[0]) {
|
|
250
|
-
cmdName = cmdName + "|" + cmd._aliases[0];
|
|
251
|
-
}
|
|
252
|
-
let ancestorCmdNames = "";
|
|
253
|
-
for (let ancestorCmd = cmd.parent;ancestorCmd; ancestorCmd = ancestorCmd.parent) {
|
|
254
|
-
ancestorCmdNames = ancestorCmd.name() + " " + ancestorCmdNames;
|
|
255
|
-
}
|
|
256
|
-
return ancestorCmdNames + cmdName + " " + cmd.usage();
|
|
257
|
-
}
|
|
258
|
-
commandDescription(cmd) {
|
|
259
|
-
return cmd.description();
|
|
143
|
+
// ../../node_modules/wsl-utils/utilities.js
|
|
144
|
+
function parseMountPointFromConfig(content) {
|
|
145
|
+
for (const line of content.split(`
|
|
146
|
+
`)) {
|
|
147
|
+
if (/^\s*#/.test(line)) {
|
|
148
|
+
continue;
|
|
260
149
|
}
|
|
261
|
-
|
|
262
|
-
|
|
150
|
+
const match = /^\s*root\s*=\s*(?<mountPoint>"[^"]*"|'[^']*'|[^#]*)/.exec(line);
|
|
151
|
+
if (!match) {
|
|
152
|
+
continue;
|
|
263
153
|
}
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
if (option.description) {
|
|
284
|
-
return `${option.description} ${extraDescription}`;
|
|
285
|
-
}
|
|
286
|
-
return extraDescription;
|
|
287
|
-
}
|
|
288
|
-
return option.description;
|
|
154
|
+
return match.groups.mountPoint.trim().replaceAll(/^["']|["']$/g, "");
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// ../../node_modules/wsl-utils/index.js
|
|
159
|
+
import { promisify as promisify2 } from "node:util";
|
|
160
|
+
import childProcess2 from "node:child_process";
|
|
161
|
+
import fs4, { constants as fsConstants } from "node:fs/promises";
|
|
162
|
+
var execFile2, wslDrivesMountPoint, powerShellPathFromWsl = async () => {
|
|
163
|
+
const mountPoint = await wslDrivesMountPoint();
|
|
164
|
+
return `${mountPoint}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`;
|
|
165
|
+
}, powerShellPath2, canAccessPowerShellPromise, canAccessPowerShell = async () => {
|
|
166
|
+
canAccessPowerShellPromise ??= (async () => {
|
|
167
|
+
try {
|
|
168
|
+
const psPath = await powerShellPath2();
|
|
169
|
+
await fs4.access(psPath, fsConstants.X_OK);
|
|
170
|
+
return true;
|
|
171
|
+
} catch {
|
|
172
|
+
return false;
|
|
289
173
|
}
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
174
|
+
})();
|
|
175
|
+
return canAccessPowerShellPromise;
|
|
176
|
+
}, wslDefaultBrowser = async () => {
|
|
177
|
+
const psPath = await powerShellPath2();
|
|
178
|
+
const command = String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`;
|
|
179
|
+
const { stdout } = await executePowerShell(command, { powerShellPath: psPath });
|
|
180
|
+
return stdout.trim();
|
|
181
|
+
}, convertWslPathToWindows = async (path) => {
|
|
182
|
+
if (/^[a-z]+:\/\//i.test(path)) {
|
|
183
|
+
return path;
|
|
184
|
+
}
|
|
185
|
+
try {
|
|
186
|
+
const { stdout } = await execFile2("wslpath", ["-aw", path], { encoding: "utf8" });
|
|
187
|
+
return stdout.trim();
|
|
188
|
+
} catch {
|
|
189
|
+
return path;
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
var init_wsl_utils = __esm(() => {
|
|
193
|
+
init_is_wsl();
|
|
194
|
+
init_powershell_utils();
|
|
195
|
+
init_is_wsl();
|
|
196
|
+
execFile2 = promisify2(childProcess2.execFile);
|
|
197
|
+
wslDrivesMountPoint = (() => {
|
|
198
|
+
const defaultMountPoint = "/mnt/";
|
|
199
|
+
let mountPoint;
|
|
200
|
+
return async function() {
|
|
201
|
+
if (mountPoint) {
|
|
202
|
+
return mountPoint;
|
|
294
203
|
}
|
|
295
|
-
|
|
296
|
-
|
|
204
|
+
const configFilePath = "/etc/wsl.conf";
|
|
205
|
+
let isConfigFileExists = false;
|
|
206
|
+
try {
|
|
207
|
+
await fs4.access(configFilePath, fsConstants.F_OK);
|
|
208
|
+
isConfigFileExists = true;
|
|
209
|
+
} catch {}
|
|
210
|
+
if (!isConfigFileExists) {
|
|
211
|
+
return defaultMountPoint;
|
|
297
212
|
}
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
}
|
|
303
|
-
return extraDescription;
|
|
213
|
+
const configContent = await fs4.readFile(configFilePath, { encoding: "utf8" });
|
|
214
|
+
const parsedMountPoint = parseMountPointFromConfig(configContent);
|
|
215
|
+
if (parsedMountPoint === undefined) {
|
|
216
|
+
return defaultMountPoint;
|
|
304
217
|
}
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
result.set(group, []);
|
|
323
|
-
}
|
|
324
|
-
result.get(group).push(item);
|
|
325
|
-
});
|
|
218
|
+
mountPoint = parsedMountPoint;
|
|
219
|
+
mountPoint = mountPoint.endsWith("/") ? mountPoint : `${mountPoint}/`;
|
|
220
|
+
return mountPoint;
|
|
221
|
+
};
|
|
222
|
+
})();
|
|
223
|
+
powerShellPath2 = is_wsl_default ? powerShellPathFromWsl : powerShellPath;
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
// ../../node_modules/open/node_modules/define-lazy-prop/index.js
|
|
227
|
+
function defineLazyProperty(object, propertyName, valueGetter) {
|
|
228
|
+
const define2 = (value) => Object.defineProperty(object, propertyName, { value, enumerable: true, writable: true });
|
|
229
|
+
Object.defineProperty(object, propertyName, {
|
|
230
|
+
configurable: true,
|
|
231
|
+
enumerable: true,
|
|
232
|
+
get() {
|
|
233
|
+
const result = valueGetter();
|
|
234
|
+
define2(result);
|
|
326
235
|
return result;
|
|
236
|
+
},
|
|
237
|
+
set(value) {
|
|
238
|
+
define2(value);
|
|
327
239
|
}
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
240
|
+
});
|
|
241
|
+
return object;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
// ../../node_modules/default-browser-id/index.js
|
|
245
|
+
import { promisify as promisify3 } from "node:util";
|
|
246
|
+
import process4 from "node:process";
|
|
247
|
+
import { execFile as execFile3 } from "node:child_process";
|
|
248
|
+
async function defaultBrowserId() {
|
|
249
|
+
if (process4.platform !== "darwin") {
|
|
250
|
+
throw new Error("macOS only");
|
|
251
|
+
}
|
|
252
|
+
const { stdout } = await execFileAsync("defaults", ["read", "com.apple.LaunchServices/com.apple.launchservices.secure", "LSHandlers"]);
|
|
253
|
+
const match = /LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(stdout);
|
|
254
|
+
const browserId = match?.groups.id ?? "com.apple.Safari";
|
|
255
|
+
if (browserId === "com.apple.safari") {
|
|
256
|
+
return "com.apple.Safari";
|
|
257
|
+
}
|
|
258
|
+
return browserId;
|
|
259
|
+
}
|
|
260
|
+
var execFileAsync;
|
|
261
|
+
var init_default_browser_id = __esm(() => {
|
|
262
|
+
execFileAsync = promisify3(execFile3);
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
// ../../node_modules/run-applescript/index.js
|
|
266
|
+
import process5 from "node:process";
|
|
267
|
+
import { promisify as promisify4 } from "node:util";
|
|
268
|
+
import { execFile as execFile4, execFileSync } from "node:child_process";
|
|
269
|
+
async function runAppleScript(script, { humanReadableOutput = true, signal } = {}) {
|
|
270
|
+
if (process5.platform !== "darwin") {
|
|
271
|
+
throw new Error("macOS only");
|
|
272
|
+
}
|
|
273
|
+
const outputArguments = humanReadableOutput ? [] : ["-ss"];
|
|
274
|
+
const execOptions = {};
|
|
275
|
+
if (signal) {
|
|
276
|
+
execOptions.signal = signal;
|
|
277
|
+
}
|
|
278
|
+
const { stdout } = await execFileAsync2("osascript", ["-e", script, outputArguments], execOptions);
|
|
279
|
+
return stdout.trim();
|
|
280
|
+
}
|
|
281
|
+
var execFileAsync2;
|
|
282
|
+
var init_run_applescript = __esm(() => {
|
|
283
|
+
execFileAsync2 = promisify4(execFile4);
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
// ../../node_modules/bundle-name/index.js
|
|
287
|
+
async function bundleName(bundleId) {
|
|
288
|
+
return runAppleScript(`tell application "Finder" to set app_path to application file id "${bundleId}" as string
|
|
289
|
+
tell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`);
|
|
290
|
+
}
|
|
291
|
+
var init_bundle_name = __esm(() => {
|
|
292
|
+
init_run_applescript();
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
// ../../node_modules/default-browser/windows.js
|
|
296
|
+
import { promisify as promisify5 } from "node:util";
|
|
297
|
+
import { execFile as execFile5 } from "node:child_process";
|
|
298
|
+
async function defaultBrowser(_execFileAsync = execFileAsync3) {
|
|
299
|
+
const { stdout } = await _execFileAsync("reg", [
|
|
300
|
+
"QUERY",
|
|
301
|
+
" HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice",
|
|
302
|
+
"/v",
|
|
303
|
+
"ProgId"
|
|
304
|
+
]);
|
|
305
|
+
const match = /ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(stdout);
|
|
306
|
+
if (!match) {
|
|
307
|
+
throw new UnknownBrowserError(`Cannot find Windows browser in stdout: ${JSON.stringify(stdout)}`);
|
|
308
|
+
}
|
|
309
|
+
const { id } = match.groups;
|
|
310
|
+
const dotIndex = id.lastIndexOf(".");
|
|
311
|
+
const hyphenIndex = id.lastIndexOf("-");
|
|
312
|
+
const baseIdByDot = dotIndex === -1 ? undefined : id.slice(0, dotIndex);
|
|
313
|
+
const baseIdByHyphen = hyphenIndex === -1 ? undefined : id.slice(0, hyphenIndex);
|
|
314
|
+
return windowsBrowserProgIds[id] ?? windowsBrowserProgIds[baseIdByDot] ?? windowsBrowserProgIds[baseIdByHyphen] ?? { name: id, id };
|
|
315
|
+
}
|
|
316
|
+
var execFileAsync3, windowsBrowserProgIds, _windowsBrowserProgIdMap, UnknownBrowserError;
|
|
317
|
+
var init_windows = __esm(() => {
|
|
318
|
+
execFileAsync3 = promisify5(execFile5);
|
|
319
|
+
windowsBrowserProgIds = {
|
|
320
|
+
MSEdgeHTM: { name: "Edge", id: "com.microsoft.edge" },
|
|
321
|
+
MSEdgeBHTML: { name: "Edge Beta", id: "com.microsoft.edge.beta" },
|
|
322
|
+
MSEdgeDHTML: { name: "Edge Dev", id: "com.microsoft.edge.dev" },
|
|
323
|
+
AppXq0fevzme2pys62n3e0fbqa7peapykr8v: { name: "Edge", id: "com.microsoft.edge.old" },
|
|
324
|
+
ChromeHTML: { name: "Chrome", id: "com.google.chrome" },
|
|
325
|
+
ChromeBHTML: { name: "Chrome Beta", id: "com.google.chrome.beta" },
|
|
326
|
+
ChromeDHTML: { name: "Chrome Dev", id: "com.google.chrome.dev" },
|
|
327
|
+
ChromiumHTM: { name: "Chromium", id: "org.chromium.Chromium" },
|
|
328
|
+
BraveHTML: { name: "Brave", id: "com.brave.Browser" },
|
|
329
|
+
BraveBHTML: { name: "Brave Beta", id: "com.brave.Browser.beta" },
|
|
330
|
+
BraveDHTML: { name: "Brave Dev", id: "com.brave.Browser.dev" },
|
|
331
|
+
BraveSSHTM: { name: "Brave Nightly", id: "com.brave.Browser.nightly" },
|
|
332
|
+
FirefoxURL: { name: "Firefox", id: "org.mozilla.firefox" },
|
|
333
|
+
OperaStable: { name: "Opera", id: "com.operasoftware.Opera" },
|
|
334
|
+
VivaldiHTM: { name: "Vivaldi", id: "com.vivaldi.Vivaldi" },
|
|
335
|
+
"IE.HTTP": { name: "Internet Explorer", id: "com.microsoft.ie" }
|
|
336
|
+
};
|
|
337
|
+
_windowsBrowserProgIdMap = new Map(Object.entries(windowsBrowserProgIds));
|
|
338
|
+
UnknownBrowserError = class UnknownBrowserError extends Error {
|
|
339
|
+
};
|
|
340
|
+
});
|
|
341
|
+
|
|
342
|
+
// ../../node_modules/default-browser/index.js
|
|
343
|
+
import { promisify as promisify6 } from "node:util";
|
|
344
|
+
import process6 from "node:process";
|
|
345
|
+
import { execFile as execFile6 } from "node:child_process";
|
|
346
|
+
async function defaultBrowser2() {
|
|
347
|
+
if (process6.platform === "darwin") {
|
|
348
|
+
const id = await defaultBrowserId();
|
|
349
|
+
const name = await bundleName(id);
|
|
350
|
+
return { name, id };
|
|
351
|
+
}
|
|
352
|
+
if (process6.platform === "linux") {
|
|
353
|
+
const { stdout } = await execFileAsync4("xdg-mime", ["query", "default", "x-scheme-handler/http"]);
|
|
354
|
+
const id = stdout.trim();
|
|
355
|
+
const name = titleize(id.replace(/.desktop$/, "").replace("-", " "));
|
|
356
|
+
return { name, id };
|
|
357
|
+
}
|
|
358
|
+
if (process6.platform === "win32") {
|
|
359
|
+
return defaultBrowser();
|
|
360
|
+
}
|
|
361
|
+
throw new Error("Only macOS, Linux, and Windows are supported");
|
|
362
|
+
}
|
|
363
|
+
var execFileAsync4, titleize = (string) => string.toLowerCase().replaceAll(/(?:^|\s|-)\S/g, (x) => x.toUpperCase());
|
|
364
|
+
var init_default_browser = __esm(() => {
|
|
365
|
+
init_default_browser_id();
|
|
366
|
+
init_bundle_name();
|
|
367
|
+
init_windows();
|
|
368
|
+
init_windows();
|
|
369
|
+
execFileAsync4 = promisify6(execFile6);
|
|
370
|
+
});
|
|
371
|
+
|
|
372
|
+
// ../../node_modules/is-in-ssh/index.js
|
|
373
|
+
import process7 from "node:process";
|
|
374
|
+
var isInSsh, is_in_ssh_default;
|
|
375
|
+
var init_is_in_ssh = __esm(() => {
|
|
376
|
+
isInSsh = Boolean(process7.env.SSH_CONNECTION || process7.env.SSH_CLIENT || process7.env.SSH_TTY);
|
|
377
|
+
is_in_ssh_default = isInSsh;
|
|
378
|
+
});
|
|
379
|
+
|
|
380
|
+
// ../../node_modules/open/index.js
|
|
381
|
+
import process8 from "node:process";
|
|
382
|
+
import path from "node:path";
|
|
383
|
+
import { fileURLToPath } from "node:url";
|
|
384
|
+
import childProcess3 from "node:child_process";
|
|
385
|
+
import fs5, { constants as fsConstants2 } from "node:fs/promises";
|
|
386
|
+
function detectArchBinary(binary) {
|
|
387
|
+
if (typeof binary === "string" || Array.isArray(binary)) {
|
|
388
|
+
return binary;
|
|
389
|
+
}
|
|
390
|
+
const { [arch]: archBinary } = binary;
|
|
391
|
+
if (!archBinary) {
|
|
392
|
+
throw new Error(`${arch} is not supported`);
|
|
393
|
+
}
|
|
394
|
+
return archBinary;
|
|
395
|
+
}
|
|
396
|
+
function detectPlatformBinary({ [platform]: platformBinary }, { wsl } = {}) {
|
|
397
|
+
if (wsl && is_wsl_default) {
|
|
398
|
+
return detectArchBinary(wsl);
|
|
399
|
+
}
|
|
400
|
+
if (!platformBinary) {
|
|
401
|
+
throw new Error(`${platform} is not supported`);
|
|
402
|
+
}
|
|
403
|
+
return detectArchBinary(platformBinary);
|
|
404
|
+
}
|
|
405
|
+
var fallbackAttemptSymbol, __dirname2, localXdgOpenPath, platform, arch, tryEachApp = async (apps, opener) => {
|
|
406
|
+
if (apps.length === 0) {
|
|
407
|
+
return;
|
|
408
|
+
}
|
|
409
|
+
const errors = [];
|
|
410
|
+
for (const app of apps) {
|
|
411
|
+
try {
|
|
412
|
+
return await opener(app);
|
|
413
|
+
} catch (error) {
|
|
414
|
+
errors.push(error);
|
|
388
415
|
}
|
|
389
|
-
|
|
390
|
-
|
|
416
|
+
}
|
|
417
|
+
throw new AggregateError(errors, "Failed to open in all supported apps");
|
|
418
|
+
}, baseOpen = async (options) => {
|
|
419
|
+
options = {
|
|
420
|
+
wait: false,
|
|
421
|
+
background: false,
|
|
422
|
+
newInstance: false,
|
|
423
|
+
allowNonzeroExitCode: false,
|
|
424
|
+
...options
|
|
425
|
+
};
|
|
426
|
+
const isFallbackAttempt = options[fallbackAttemptSymbol] === true;
|
|
427
|
+
delete options[fallbackAttemptSymbol];
|
|
428
|
+
if (Array.isArray(options.app)) {
|
|
429
|
+
return tryEachApp(options.app, (singleApp) => baseOpen({
|
|
430
|
+
...options,
|
|
431
|
+
app: singleApp,
|
|
432
|
+
[fallbackAttemptSymbol]: true
|
|
433
|
+
}));
|
|
434
|
+
}
|
|
435
|
+
let { name: app, arguments: appArguments = [] } = options.app ?? {};
|
|
436
|
+
appArguments = [...appArguments];
|
|
437
|
+
if (Array.isArray(app)) {
|
|
438
|
+
return tryEachApp(app, (appName) => baseOpen({
|
|
439
|
+
...options,
|
|
440
|
+
app: {
|
|
441
|
+
name: appName,
|
|
442
|
+
arguments: appArguments
|
|
443
|
+
},
|
|
444
|
+
[fallbackAttemptSymbol]: true
|
|
445
|
+
}));
|
|
446
|
+
}
|
|
447
|
+
if (app === "browser" || app === "browserPrivate") {
|
|
448
|
+
const ids = {
|
|
449
|
+
"com.google.chrome": "chrome",
|
|
450
|
+
"google-chrome.desktop": "chrome",
|
|
451
|
+
"com.brave.browser": "brave",
|
|
452
|
+
"org.mozilla.firefox": "firefox",
|
|
453
|
+
"firefox.desktop": "firefox",
|
|
454
|
+
"com.microsoft.msedge": "edge",
|
|
455
|
+
"com.microsoft.edge": "edge",
|
|
456
|
+
"com.microsoft.edgemac": "edge",
|
|
457
|
+
"microsoft-edge.desktop": "edge",
|
|
458
|
+
"com.apple.safari": "safari"
|
|
459
|
+
};
|
|
460
|
+
const flags = {
|
|
461
|
+
chrome: "--incognito",
|
|
462
|
+
brave: "--incognito",
|
|
463
|
+
firefox: "--private-window",
|
|
464
|
+
edge: "--inPrivate"
|
|
465
|
+
};
|
|
466
|
+
let browser;
|
|
467
|
+
if (is_wsl_default) {
|
|
468
|
+
const progId = await wslDefaultBrowser();
|
|
469
|
+
const browserInfo = _windowsBrowserProgIdMap.get(progId);
|
|
470
|
+
browser = browserInfo ?? {};
|
|
471
|
+
} else {
|
|
472
|
+
browser = await defaultBrowser2();
|
|
391
473
|
}
|
|
392
|
-
|
|
393
|
-
|
|
474
|
+
if (browser.id in ids) {
|
|
475
|
+
const browserName = ids[browser.id.toLowerCase()];
|
|
476
|
+
if (app === "browserPrivate") {
|
|
477
|
+
if (browserName === "safari") {
|
|
478
|
+
throw new Error("Safari doesn't support opening in private mode via command line");
|
|
479
|
+
}
|
|
480
|
+
appArguments.push(flags[browserName]);
|
|
481
|
+
}
|
|
482
|
+
return baseOpen({
|
|
483
|
+
...options,
|
|
484
|
+
app: {
|
|
485
|
+
name: apps[browserName],
|
|
486
|
+
arguments: appArguments
|
|
487
|
+
}
|
|
488
|
+
});
|
|
394
489
|
}
|
|
395
|
-
|
|
396
|
-
|
|
490
|
+
throw new Error(`${browser.name} is not supported as a default browser`);
|
|
491
|
+
}
|
|
492
|
+
let command;
|
|
493
|
+
const cliArguments = [];
|
|
494
|
+
const childProcessOptions = {};
|
|
495
|
+
let shouldUseWindowsInWsl = false;
|
|
496
|
+
if (is_wsl_default && !isInsideContainer() && !is_in_ssh_default && !app) {
|
|
497
|
+
shouldUseWindowsInWsl = await canAccessPowerShell();
|
|
498
|
+
}
|
|
499
|
+
if (platform === "darwin") {
|
|
500
|
+
command = "open";
|
|
501
|
+
if (options.wait) {
|
|
502
|
+
cliArguments.push("--wait-apps");
|
|
397
503
|
}
|
|
398
|
-
|
|
399
|
-
|
|
504
|
+
if (options.background) {
|
|
505
|
+
cliArguments.push("--background");
|
|
400
506
|
}
|
|
401
|
-
|
|
402
|
-
|
|
507
|
+
if (options.newInstance) {
|
|
508
|
+
cliArguments.push("--new");
|
|
403
509
|
}
|
|
404
|
-
|
|
405
|
-
|
|
510
|
+
if (app) {
|
|
511
|
+
cliArguments.push("-a", app);
|
|
406
512
|
}
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
return this.styleArgumentText(word);
|
|
413
|
-
return this.styleSubcommandText(word);
|
|
414
|
-
}).join(" ");
|
|
513
|
+
} else if (platform === "win32" || shouldUseWindowsInWsl) {
|
|
514
|
+
command = await powerShellPath2();
|
|
515
|
+
cliArguments.push(...executePowerShell.argumentsPrefix);
|
|
516
|
+
if (!is_wsl_default) {
|
|
517
|
+
childProcessOptions.windowsVerbatimArguments = true;
|
|
415
518
|
}
|
|
416
|
-
|
|
417
|
-
|
|
519
|
+
if (is_wsl_default && options.target) {
|
|
520
|
+
options.target = await convertWslPathToWindows(options.target);
|
|
418
521
|
}
|
|
419
|
-
|
|
420
|
-
|
|
522
|
+
const encodedArguments = ["$ProgressPreference = 'SilentlyContinue';", "Start"];
|
|
523
|
+
if (options.wait) {
|
|
524
|
+
encodedArguments.push("-Wait");
|
|
421
525
|
}
|
|
422
|
-
|
|
423
|
-
|
|
526
|
+
if (app) {
|
|
527
|
+
encodedArguments.push(executePowerShell.escapeArgument(app));
|
|
528
|
+
if (options.target) {
|
|
529
|
+
appArguments.push(options.target);
|
|
530
|
+
}
|
|
531
|
+
} else if (options.target) {
|
|
532
|
+
encodedArguments.push(executePowerShell.escapeArgument(options.target));
|
|
424
533
|
}
|
|
425
|
-
|
|
426
|
-
|
|
534
|
+
if (appArguments.length > 0) {
|
|
535
|
+
appArguments = appArguments.map((argument) => executePowerShell.escapeArgument(argument));
|
|
536
|
+
encodedArguments.push("-ArgumentList", appArguments.join(","));
|
|
427
537
|
}
|
|
428
|
-
|
|
429
|
-
|
|
538
|
+
options.target = executePowerShell.encodeCommand(encodedArguments.join(" "));
|
|
539
|
+
if (!options.wait) {
|
|
540
|
+
childProcessOptions.stdio = "ignore";
|
|
430
541
|
}
|
|
431
|
-
|
|
432
|
-
|
|
542
|
+
} else {
|
|
543
|
+
if (app) {
|
|
544
|
+
command = app;
|
|
545
|
+
} else {
|
|
546
|
+
const isBundled = !__dirname2 || __dirname2 === "/";
|
|
547
|
+
let exeLocalXdgOpen = false;
|
|
548
|
+
try {
|
|
549
|
+
await fs5.access(localXdgOpenPath, fsConstants2.X_OK);
|
|
550
|
+
exeLocalXdgOpen = true;
|
|
551
|
+
} catch {}
|
|
552
|
+
const useSystemXdgOpen = process8.versions.electron ?? (platform === "android" || isBundled || !exeLocalXdgOpen);
|
|
553
|
+
command = useSystemXdgOpen ? "xdg-open" : localXdgOpenPath;
|
|
433
554
|
}
|
|
434
|
-
|
|
435
|
-
|
|
555
|
+
if (appArguments.length > 0) {
|
|
556
|
+
cliArguments.push(...appArguments);
|
|
436
557
|
}
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
if (!description)
|
|
441
|
-
return itemIndentStr + term;
|
|
442
|
-
const paddedTerm = term.padEnd(termWidth + term.length - helper.displayWidth(term));
|
|
443
|
-
const spacerWidth = 2;
|
|
444
|
-
const helpWidth = this.helpWidth ?? 80;
|
|
445
|
-
const remainingWidth = helpWidth - termWidth - spacerWidth - itemIndent;
|
|
446
|
-
let formattedDescription;
|
|
447
|
-
if (remainingWidth < this.minWidthToWrap || helper.preformatted(description)) {
|
|
448
|
-
formattedDescription = description;
|
|
449
|
-
} else {
|
|
450
|
-
const wrappedDescription = helper.boxWrap(description, remainingWidth);
|
|
451
|
-
formattedDescription = wrappedDescription.replace(/\n/g, `
|
|
452
|
-
` + " ".repeat(termWidth + spacerWidth));
|
|
453
|
-
}
|
|
454
|
-
return itemIndentStr + paddedTerm + " ".repeat(spacerWidth) + formattedDescription.replace(/\n/g, `
|
|
455
|
-
${itemIndentStr}`);
|
|
558
|
+
if (!options.wait) {
|
|
559
|
+
childProcessOptions.stdio = "ignore";
|
|
560
|
+
childProcessOptions.detached = true;
|
|
456
561
|
}
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
562
|
+
}
|
|
563
|
+
if (platform === "darwin" && appArguments.length > 0) {
|
|
564
|
+
cliArguments.push("--args", ...appArguments);
|
|
565
|
+
}
|
|
566
|
+
if (options.target) {
|
|
567
|
+
cliArguments.push(options.target);
|
|
568
|
+
}
|
|
569
|
+
const subprocess = childProcess3.spawn(command, cliArguments, childProcessOptions);
|
|
570
|
+
if (options.wait) {
|
|
571
|
+
return new Promise((resolve, reject) => {
|
|
572
|
+
subprocess.once("error", reject);
|
|
573
|
+
subprocess.once("close", (exitCode) => {
|
|
574
|
+
if (!options.allowNonzeroExitCode && exitCode !== 0) {
|
|
575
|
+
reject(new Error(`Exited with code ${exitCode}`));
|
|
467
576
|
return;
|
|
468
577
|
}
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
578
|
+
resolve(subprocess);
|
|
579
|
+
});
|
|
580
|
+
});
|
|
581
|
+
}
|
|
582
|
+
if (isFallbackAttempt) {
|
|
583
|
+
return new Promise((resolve, reject) => {
|
|
584
|
+
subprocess.once("error", reject);
|
|
585
|
+
subprocess.once("spawn", () => {
|
|
586
|
+
subprocess.once("close", (exitCode) => {
|
|
587
|
+
subprocess.off("error", reject);
|
|
588
|
+
if (exitCode !== 0) {
|
|
589
|
+
reject(new Error(`Exited with code ${exitCode}`));
|
|
476
590
|
return;
|
|
477
591
|
}
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
sumChunks = [nextChunk];
|
|
481
|
-
sumWidth = this.displayWidth(nextChunk);
|
|
592
|
+
subprocess.unref();
|
|
593
|
+
resolve(subprocess);
|
|
482
594
|
});
|
|
483
|
-
wrappedLines.push(sumChunks.join(""));
|
|
484
595
|
});
|
|
485
|
-
|
|
486
|
-
`);
|
|
487
|
-
}
|
|
596
|
+
});
|
|
488
597
|
}
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
598
|
+
subprocess.unref();
|
|
599
|
+
return new Promise((resolve, reject) => {
|
|
600
|
+
subprocess.once("error", reject);
|
|
601
|
+
subprocess.once("spawn", () => {
|
|
602
|
+
subprocess.off("error", reject);
|
|
603
|
+
resolve(subprocess);
|
|
604
|
+
});
|
|
605
|
+
});
|
|
606
|
+
}, open = (target, options) => {
|
|
607
|
+
if (typeof target !== "string") {
|
|
608
|
+
throw new TypeError("Expected a `target`");
|
|
492
609
|
}
|
|
493
|
-
|
|
494
|
-
|
|
610
|
+
return baseOpen({
|
|
611
|
+
...options,
|
|
612
|
+
target
|
|
613
|
+
});
|
|
614
|
+
}, apps, open_default;
|
|
615
|
+
var init_open = __esm(() => {
|
|
616
|
+
init_wsl_utils();
|
|
617
|
+
init_powershell_utils();
|
|
618
|
+
init_default_browser();
|
|
619
|
+
init_is_inside_container();
|
|
620
|
+
init_is_in_ssh();
|
|
621
|
+
fallbackAttemptSymbol = Symbol("fallbackAttempt");
|
|
622
|
+
__dirname2 = import.meta.url ? path.dirname(fileURLToPath(import.meta.url)) : "";
|
|
623
|
+
localXdgOpenPath = path.join(__dirname2, "xdg-open");
|
|
624
|
+
({ platform, arch } = process8);
|
|
625
|
+
apps = {
|
|
626
|
+
browser: "browser",
|
|
627
|
+
browserPrivate: "browserPrivate"
|
|
628
|
+
};
|
|
629
|
+
defineLazyProperty(apps, "chrome", () => detectPlatformBinary({
|
|
630
|
+
darwin: "google chrome",
|
|
631
|
+
win32: "chrome",
|
|
632
|
+
linux: ["google-chrome", "google-chrome-stable", "chromium", "chromium-browser"]
|
|
633
|
+
}, {
|
|
634
|
+
wsl: {
|
|
635
|
+
ia32: "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe",
|
|
636
|
+
x64: ["/mnt/c/Program Files/Google/Chrome/Application/chrome.exe", "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"]
|
|
637
|
+
}
|
|
638
|
+
}));
|
|
639
|
+
defineLazyProperty(apps, "brave", () => detectPlatformBinary({
|
|
640
|
+
darwin: "brave browser",
|
|
641
|
+
win32: "brave",
|
|
642
|
+
linux: ["brave-browser", "brave"]
|
|
643
|
+
}, {
|
|
644
|
+
wsl: {
|
|
645
|
+
ia32: "/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe",
|
|
646
|
+
x64: ["/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe", "/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe"]
|
|
647
|
+
}
|
|
648
|
+
}));
|
|
649
|
+
defineLazyProperty(apps, "firefox", () => detectPlatformBinary({
|
|
650
|
+
darwin: "firefox",
|
|
651
|
+
win32: String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,
|
|
652
|
+
linux: "firefox"
|
|
653
|
+
}, {
|
|
654
|
+
wsl: "/mnt/c/Program Files/Mozilla Firefox/firefox.exe"
|
|
655
|
+
}));
|
|
656
|
+
defineLazyProperty(apps, "edge", () => detectPlatformBinary({
|
|
657
|
+
darwin: "microsoft edge",
|
|
658
|
+
win32: "msedge",
|
|
659
|
+
linux: ["microsoft-edge", "microsoft-edge-dev"]
|
|
660
|
+
}, {
|
|
661
|
+
wsl: "/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"
|
|
662
|
+
}));
|
|
663
|
+
defineLazyProperty(apps, "safari", () => detectPlatformBinary({
|
|
664
|
+
darwin: "Safari"
|
|
665
|
+
}));
|
|
666
|
+
open_default = open;
|
|
495
667
|
});
|
|
496
668
|
|
|
497
|
-
//
|
|
498
|
-
|
|
499
|
-
|
|
669
|
+
// ../filesystem/src/node.ts
|
|
670
|
+
import { existsSync } from "node:fs";
|
|
671
|
+
import * as fs6 from "node:fs/promises";
|
|
672
|
+
import * as os2 from "node:os";
|
|
673
|
+
import * as path2 from "node:path";
|
|
500
674
|
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
this.envVar = undefined;
|
|
520
|
-
this.parseArg = undefined;
|
|
521
|
-
this.hidden = false;
|
|
522
|
-
this.argChoices = undefined;
|
|
523
|
-
this.conflictsWith = [];
|
|
524
|
-
this.implied = undefined;
|
|
525
|
-
this.helpGroupHeading = undefined;
|
|
675
|
+
class NodeFileSystem {
|
|
676
|
+
path = {
|
|
677
|
+
join: path2.join,
|
|
678
|
+
resolve: path2.resolve,
|
|
679
|
+
relative: path2.relative,
|
|
680
|
+
dirname: path2.dirname,
|
|
681
|
+
isAbsolute: path2.isAbsolute,
|
|
682
|
+
basename: path2.basename
|
|
683
|
+
};
|
|
684
|
+
env = {
|
|
685
|
+
cwd: process.cwd,
|
|
686
|
+
homedir: os2.homedir,
|
|
687
|
+
tmpdir: os2.tmpdir,
|
|
688
|
+
getenv: (key) => process.env[key]
|
|
689
|
+
};
|
|
690
|
+
utils = {
|
|
691
|
+
open: async (url) => {
|
|
692
|
+
await open_default(url);
|
|
526
693
|
}
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
694
|
+
};
|
|
695
|
+
async readFile(path3, options) {
|
|
696
|
+
try {
|
|
697
|
+
if (options) {
|
|
698
|
+
return await fs6.readFile(path3, "utf-8");
|
|
699
|
+
}
|
|
700
|
+
return await fs6.readFile(path3);
|
|
701
|
+
} catch (error) {
|
|
702
|
+
if (this.isEnoent(error))
|
|
703
|
+
return null;
|
|
704
|
+
throw error;
|
|
531
705
|
}
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
706
|
+
}
|
|
707
|
+
async writeFile(filePath, data) {
|
|
708
|
+
const dir = path2.dirname(filePath);
|
|
709
|
+
if (dir) {
|
|
710
|
+
await fs6.mkdir(dir, { recursive: true });
|
|
535
711
|
}
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
712
|
+
await fs6.writeFile(filePath, data);
|
|
713
|
+
}
|
|
714
|
+
async appendFile(filePath, data) {
|
|
715
|
+
const dir = path2.dirname(filePath);
|
|
716
|
+
if (dir) {
|
|
717
|
+
await fs6.mkdir(dir, { recursive: true });
|
|
539
718
|
}
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
719
|
+
await fs6.appendFile(filePath, data);
|
|
720
|
+
}
|
|
721
|
+
async readdir(dirPath) {
|
|
722
|
+
try {
|
|
723
|
+
return await fs6.readdir(dirPath);
|
|
724
|
+
} catch (error) {
|
|
725
|
+
if (this.isEnoent(error))
|
|
726
|
+
return [];
|
|
727
|
+
throw error;
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
async stat(filePath) {
|
|
731
|
+
try {
|
|
732
|
+
const stats = await fs6.stat(filePath);
|
|
733
|
+
return {
|
|
734
|
+
isFile: () => stats.isFile(),
|
|
735
|
+
isDirectory: () => stats.isDirectory(),
|
|
736
|
+
size: stats.size,
|
|
737
|
+
mtimeMs: stats.mtimeMs
|
|
738
|
+
};
|
|
739
|
+
} catch (error) {
|
|
740
|
+
if (this.isEnoent(error))
|
|
741
|
+
return null;
|
|
742
|
+
throw error;
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
async exists(filePath) {
|
|
746
|
+
return existsSync(filePath);
|
|
747
|
+
}
|
|
748
|
+
async mkdir(dirPath) {
|
|
749
|
+
await fs6.mkdir(dirPath, { recursive: true });
|
|
750
|
+
}
|
|
751
|
+
async rm(filePath) {
|
|
752
|
+
await fs6.rm(filePath, { recursive: true, force: true });
|
|
753
|
+
}
|
|
754
|
+
async rename(oldPath, newPath) {
|
|
755
|
+
await fs6.rename(oldPath, newPath);
|
|
756
|
+
}
|
|
757
|
+
async realpath(filePath) {
|
|
758
|
+
try {
|
|
759
|
+
return await fs6.realpath(filePath);
|
|
760
|
+
} catch (error) {
|
|
761
|
+
if (this.isEnoent(error))
|
|
762
|
+
return filePath;
|
|
763
|
+
throw error;
|
|
764
|
+
}
|
|
765
|
+
}
|
|
766
|
+
async getTempDir() {
|
|
767
|
+
return await fs6.mkdtemp(path2.join(os2.tmpdir(), "uipath-fs-"));
|
|
768
|
+
}
|
|
769
|
+
async copyDirectory(sourcePath, destPath) {
|
|
770
|
+
const sourceStats = await this.stat(sourcePath);
|
|
771
|
+
if (!sourceStats) {
|
|
772
|
+
throw new Error(`Source directory does not exist: ${sourcePath}`);
|
|
773
|
+
}
|
|
774
|
+
if (!sourceStats.isDirectory()) {
|
|
775
|
+
throw new Error(`Source path is not a directory: ${sourcePath}`);
|
|
776
|
+
}
|
|
777
|
+
await this.mkdir(destPath);
|
|
778
|
+
const entries = await this.readdir(sourcePath);
|
|
779
|
+
for (const entry of entries) {
|
|
780
|
+
const srcEntry = path2.join(sourcePath, entry);
|
|
781
|
+
const destEntry = path2.join(destPath, entry);
|
|
782
|
+
const entryStats = await this.stat(srcEntry);
|
|
783
|
+
if (!entryStats)
|
|
784
|
+
continue;
|
|
785
|
+
if (entryStats.isDirectory()) {
|
|
786
|
+
await this.copyDirectory(srcEntry, destEntry);
|
|
787
|
+
} else if (entryStats.isFile()) {
|
|
788
|
+
const content = await this.readFile(srcEntry);
|
|
789
|
+
if (content !== null) {
|
|
790
|
+
await this.writeFile(destEntry, content);
|
|
791
|
+
}
|
|
544
792
|
}
|
|
545
|
-
this.implied = Object.assign(this.implied || {}, newImplied);
|
|
546
|
-
return this;
|
|
547
793
|
}
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
794
|
+
}
|
|
795
|
+
isEnoent(error) {
|
|
796
|
+
return typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT";
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
var init_node = __esm(() => {
|
|
800
|
+
init_open();
|
|
801
|
+
});
|
|
802
|
+
// ../filesystem/src/index.ts
|
|
803
|
+
var fsInstance, getFileSystem = () => fsInstance;
|
|
804
|
+
var init_src = __esm(() => {
|
|
805
|
+
init_node();
|
|
806
|
+
init_node();
|
|
807
|
+
fsInstance = new NodeFileSystem;
|
|
808
|
+
});
|
|
809
|
+
|
|
810
|
+
// ../../node_modules/commander/lib/error.js
|
|
811
|
+
var require_error = __commonJS((exports) => {
|
|
812
|
+
class CommanderError extends Error {
|
|
813
|
+
constructor(exitCode, code, message) {
|
|
814
|
+
super(message);
|
|
815
|
+
Error.captureStackTrace(this, this.constructor);
|
|
816
|
+
this.name = this.constructor.name;
|
|
817
|
+
this.code = code;
|
|
818
|
+
this.exitCode = exitCode;
|
|
819
|
+
this.nestedError = undefined;
|
|
551
820
|
}
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
class InvalidArgumentError extends CommanderError {
|
|
824
|
+
constructor(message) {
|
|
825
|
+
super(1, "commander.invalidArgument", message);
|
|
826
|
+
Error.captureStackTrace(this, this.constructor);
|
|
827
|
+
this.name = this.constructor.name;
|
|
555
828
|
}
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
829
|
+
}
|
|
830
|
+
exports.CommanderError = CommanderError;
|
|
831
|
+
exports.InvalidArgumentError = InvalidArgumentError;
|
|
832
|
+
});
|
|
833
|
+
|
|
834
|
+
// ../../node_modules/commander/lib/argument.js
|
|
835
|
+
var require_argument = __commonJS((exports) => {
|
|
836
|
+
var { InvalidArgumentError } = require_error();
|
|
837
|
+
|
|
838
|
+
class Argument {
|
|
839
|
+
constructor(name, description) {
|
|
840
|
+
this.description = description || "";
|
|
841
|
+
this.variadic = false;
|
|
842
|
+
this.parseArg = undefined;
|
|
843
|
+
this.defaultValue = undefined;
|
|
844
|
+
this.defaultValueDescription = undefined;
|
|
845
|
+
this.argChoices = undefined;
|
|
846
|
+
switch (name[0]) {
|
|
847
|
+
case "<":
|
|
848
|
+
this.required = true;
|
|
849
|
+
this._name = name.slice(1, -1);
|
|
850
|
+
break;
|
|
851
|
+
case "[":
|
|
852
|
+
this.required = false;
|
|
853
|
+
this._name = name.slice(1, -1);
|
|
854
|
+
break;
|
|
855
|
+
default:
|
|
856
|
+
this.required = true;
|
|
857
|
+
this._name = name;
|
|
858
|
+
break;
|
|
859
|
+
}
|
|
860
|
+
if (this._name.endsWith("...")) {
|
|
861
|
+
this.variadic = true;
|
|
862
|
+
this._name = this._name.slice(0, -3);
|
|
863
|
+
}
|
|
559
864
|
}
|
|
560
|
-
|
|
561
|
-
this.
|
|
562
|
-
return this;
|
|
865
|
+
name() {
|
|
866
|
+
return this._name;
|
|
563
867
|
}
|
|
564
868
|
_collectValue(value, previous) {
|
|
565
869
|
if (previous === this.defaultValue || !Array.isArray(previous)) {
|
|
@@ -568,6 +872,15 @@ var require_option = __commonJS((exports) => {
|
|
|
568
872
|
previous.push(value);
|
|
569
873
|
return previous;
|
|
570
874
|
}
|
|
875
|
+
default(value, description) {
|
|
876
|
+
this.defaultValue = value;
|
|
877
|
+
this.defaultValueDescription = description;
|
|
878
|
+
return this;
|
|
879
|
+
}
|
|
880
|
+
argParser(fn) {
|
|
881
|
+
this.parseArg = fn;
|
|
882
|
+
return this;
|
|
883
|
+
}
|
|
571
884
|
choices(values) {
|
|
572
885
|
this.argChoices = values.slice();
|
|
573
886
|
this.parseArg = (arg, previous) => {
|
|
@@ -581,189 +894,650 @@ var require_option = __commonJS((exports) => {
|
|
|
581
894
|
};
|
|
582
895
|
return this;
|
|
583
896
|
}
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
return this.long.replace(/^--/, "");
|
|
587
|
-
}
|
|
588
|
-
return this.short.replace(/^-/, "");
|
|
589
|
-
}
|
|
590
|
-
attributeName() {
|
|
591
|
-
if (this.negate) {
|
|
592
|
-
return camelcase(this.name().replace(/^no-/, ""));
|
|
593
|
-
}
|
|
594
|
-
return camelcase(this.name());
|
|
595
|
-
}
|
|
596
|
-
helpGroup(heading) {
|
|
597
|
-
this.helpGroupHeading = heading;
|
|
897
|
+
argRequired() {
|
|
898
|
+
this.required = true;
|
|
598
899
|
return this;
|
|
599
900
|
}
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
isBoolean() {
|
|
604
|
-
return !this.required && !this.optional && !this.negate;
|
|
901
|
+
argOptional() {
|
|
902
|
+
this.required = false;
|
|
903
|
+
return this;
|
|
605
904
|
}
|
|
606
905
|
}
|
|
906
|
+
function humanReadableArgName(arg) {
|
|
907
|
+
const nameOutput = arg.name() + (arg.variadic === true ? "..." : "");
|
|
908
|
+
return arg.required ? "<" + nameOutput + ">" : "[" + nameOutput + "]";
|
|
909
|
+
}
|
|
910
|
+
exports.Argument = Argument;
|
|
911
|
+
exports.humanReadableArgName = humanReadableArgName;
|
|
912
|
+
});
|
|
607
913
|
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
});
|
|
620
|
-
this.negativeOptions.forEach((value, key) => {
|
|
621
|
-
if (this.positiveOptions.has(key)) {
|
|
622
|
-
this.dualOptions.add(key);
|
|
623
|
-
}
|
|
624
|
-
});
|
|
914
|
+
// ../../node_modules/commander/lib/help.js
|
|
915
|
+
var require_help = __commonJS((exports) => {
|
|
916
|
+
var { humanReadableArgName } = require_argument();
|
|
917
|
+
|
|
918
|
+
class Help {
|
|
919
|
+
constructor() {
|
|
920
|
+
this.helpWidth = undefined;
|
|
921
|
+
this.minWidthToWrap = 40;
|
|
922
|
+
this.sortSubcommands = false;
|
|
923
|
+
this.sortOptions = false;
|
|
924
|
+
this.showGlobalOptions = false;
|
|
625
925
|
}
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
if (!this.dualOptions.has(optionKey))
|
|
629
|
-
return true;
|
|
630
|
-
const preset = this.negativeOptions.get(optionKey).presetArg;
|
|
631
|
-
const negativeValue = preset !== undefined ? preset : false;
|
|
632
|
-
return option.negate === (negativeValue === value);
|
|
926
|
+
prepareContext(contextOptions) {
|
|
927
|
+
this.helpWidth = this.helpWidth ?? contextOptions.helpWidth ?? 80;
|
|
633
928
|
}
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
if (shortFlagExp.test(flagParts[0]))
|
|
647
|
-
shortFlag = flagParts.shift();
|
|
648
|
-
if (longFlagExp.test(flagParts[0]))
|
|
649
|
-
longFlag = flagParts.shift();
|
|
650
|
-
if (!shortFlag && shortFlagExp.test(flagParts[0]))
|
|
651
|
-
shortFlag = flagParts.shift();
|
|
652
|
-
if (!shortFlag && longFlagExp.test(flagParts[0])) {
|
|
653
|
-
shortFlag = longFlag;
|
|
654
|
-
longFlag = flagParts.shift();
|
|
929
|
+
visibleCommands(cmd) {
|
|
930
|
+
const visibleCommands = cmd.commands.filter((cmd2) => !cmd2._hidden);
|
|
931
|
+
const helpCommand = cmd._getHelpCommand();
|
|
932
|
+
if (helpCommand && !helpCommand._hidden) {
|
|
933
|
+
visibleCommands.push(helpCommand);
|
|
934
|
+
}
|
|
935
|
+
if (this.sortSubcommands) {
|
|
936
|
+
visibleCommands.sort((a, b) => {
|
|
937
|
+
return a.name().localeCompare(b.name());
|
|
938
|
+
});
|
|
939
|
+
}
|
|
940
|
+
return visibleCommands;
|
|
655
941
|
}
|
|
656
|
-
|
|
657
|
-
const
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
- a short flag is a single dash and a single character
|
|
662
|
-
- either use a single dash and a single character (for a short flag)
|
|
663
|
-
- or use a double dash for a long option (and can have two, like '--ws, --workspace')`);
|
|
664
|
-
if (shortFlagExp.test(unsupportedFlag))
|
|
665
|
-
throw new Error(`${baseError}
|
|
666
|
-
- too many short flags`);
|
|
667
|
-
if (longFlagExp.test(unsupportedFlag))
|
|
668
|
-
throw new Error(`${baseError}
|
|
669
|
-
- too many long flags`);
|
|
670
|
-
throw new Error(`${baseError}
|
|
671
|
-
- unrecognised flag format`);
|
|
942
|
+
compareOptions(a, b) {
|
|
943
|
+
const getSortKey = (option) => {
|
|
944
|
+
return option.short ? option.short.replace(/^-/, "") : option.long.replace(/^--/, "");
|
|
945
|
+
};
|
|
946
|
+
return getSortKey(a).localeCompare(getSortKey(b));
|
|
672
947
|
}
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
948
|
+
visibleOptions(cmd) {
|
|
949
|
+
const visibleOptions = cmd.options.filter((option) => !option.hidden);
|
|
950
|
+
const helpOption = cmd._getHelpOption();
|
|
951
|
+
if (helpOption && !helpOption.hidden) {
|
|
952
|
+
const removeShort = helpOption.short && cmd._findOption(helpOption.short);
|
|
953
|
+
const removeLong = helpOption.long && cmd._findOption(helpOption.long);
|
|
954
|
+
if (!removeShort && !removeLong) {
|
|
955
|
+
visibleOptions.push(helpOption);
|
|
956
|
+
} else if (helpOption.long && !removeLong) {
|
|
957
|
+
visibleOptions.push(cmd.createOption(helpOption.long, helpOption.description));
|
|
958
|
+
} else if (helpOption.short && !removeShort) {
|
|
959
|
+
visibleOptions.push(cmd.createOption(helpOption.short, helpOption.description));
|
|
960
|
+
}
|
|
961
|
+
}
|
|
962
|
+
if (this.sortOptions) {
|
|
963
|
+
visibleOptions.sort(this.compareOptions);
|
|
964
|
+
}
|
|
965
|
+
return visibleOptions;
|
|
690
966
|
}
|
|
691
|
-
|
|
692
|
-
|
|
967
|
+
visibleGlobalOptions(cmd) {
|
|
968
|
+
if (!this.showGlobalOptions)
|
|
969
|
+
return [];
|
|
970
|
+
const globalOptions = [];
|
|
971
|
+
for (let ancestorCmd = cmd.parent;ancestorCmd; ancestorCmd = ancestorCmd.parent) {
|
|
972
|
+
const visibleOptions = ancestorCmd.options.filter((option) => !option.hidden);
|
|
973
|
+
globalOptions.push(...visibleOptions);
|
|
974
|
+
}
|
|
975
|
+
if (this.sortOptions) {
|
|
976
|
+
globalOptions.sort(this.compareOptions);
|
|
977
|
+
}
|
|
978
|
+
return globalOptions;
|
|
693
979
|
}
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
} else {
|
|
700
|
-
cost = 1;
|
|
701
|
-
}
|
|
702
|
-
d[i][j] = Math.min(d[i - 1][j] + 1, d[i][j - 1] + 1, d[i - 1][j - 1] + cost);
|
|
703
|
-
if (i > 1 && j > 1 && a[i - 1] === b[j - 2] && a[i - 2] === b[j - 1]) {
|
|
704
|
-
d[i][j] = Math.min(d[i][j], d[i - 2][j - 2] + 1);
|
|
705
|
-
}
|
|
980
|
+
visibleArguments(cmd) {
|
|
981
|
+
if (cmd._argsDescription) {
|
|
982
|
+
cmd.registeredArguments.forEach((argument) => {
|
|
983
|
+
argument.description = argument.description || cmd._argsDescription[argument.name()] || "";
|
|
984
|
+
});
|
|
706
985
|
}
|
|
986
|
+
if (cmd.registeredArguments.find((argument) => argument.description)) {
|
|
987
|
+
return cmd.registeredArguments;
|
|
988
|
+
}
|
|
989
|
+
return [];
|
|
707
990
|
}
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
if (!candidates || candidates.length === 0)
|
|
712
|
-
return "";
|
|
713
|
-
candidates = Array.from(new Set(candidates));
|
|
714
|
-
const searchingOptions = word.startsWith("--");
|
|
715
|
-
if (searchingOptions) {
|
|
716
|
-
word = word.slice(2);
|
|
717
|
-
candidates = candidates.map((candidate) => candidate.slice(2));
|
|
991
|
+
subcommandTerm(cmd) {
|
|
992
|
+
const args = cmd.registeredArguments.map((arg) => humanReadableArgName(arg)).join(" ");
|
|
993
|
+
return cmd._name + (cmd._aliases[0] ? "|" + cmd._aliases[0] : "") + (cmd.options.length ? " [options]" : "") + (args ? " " + args : "");
|
|
718
994
|
}
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
995
|
+
optionTerm(option) {
|
|
996
|
+
return option.flags;
|
|
997
|
+
}
|
|
998
|
+
argumentTerm(argument) {
|
|
999
|
+
return argument.name();
|
|
1000
|
+
}
|
|
1001
|
+
longestSubcommandTermLength(cmd, helper) {
|
|
1002
|
+
return helper.visibleCommands(cmd).reduce((max, command) => {
|
|
1003
|
+
return Math.max(max, this.displayWidth(helper.styleSubcommandTerm(helper.subcommandTerm(command))));
|
|
1004
|
+
}, 0);
|
|
1005
|
+
}
|
|
1006
|
+
longestOptionTermLength(cmd, helper) {
|
|
1007
|
+
return helper.visibleOptions(cmd).reduce((max, option) => {
|
|
1008
|
+
return Math.max(max, this.displayWidth(helper.styleOptionTerm(helper.optionTerm(option))));
|
|
1009
|
+
}, 0);
|
|
1010
|
+
}
|
|
1011
|
+
longestGlobalOptionTermLength(cmd, helper) {
|
|
1012
|
+
return helper.visibleGlobalOptions(cmd).reduce((max, option) => {
|
|
1013
|
+
return Math.max(max, this.displayWidth(helper.styleOptionTerm(helper.optionTerm(option))));
|
|
1014
|
+
}, 0);
|
|
1015
|
+
}
|
|
1016
|
+
longestArgumentTermLength(cmd, helper) {
|
|
1017
|
+
return helper.visibleArguments(cmd).reduce((max, argument) => {
|
|
1018
|
+
return Math.max(max, this.displayWidth(helper.styleArgumentTerm(helper.argumentTerm(argument))));
|
|
1019
|
+
}, 0);
|
|
1020
|
+
}
|
|
1021
|
+
commandUsage(cmd) {
|
|
1022
|
+
let cmdName = cmd._name;
|
|
1023
|
+
if (cmd._aliases[0]) {
|
|
1024
|
+
cmdName = cmdName + "|" + cmd._aliases[0];
|
|
735
1025
|
}
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
1026
|
+
let ancestorCmdNames = "";
|
|
1027
|
+
for (let ancestorCmd = cmd.parent;ancestorCmd; ancestorCmd = ancestorCmd.parent) {
|
|
1028
|
+
ancestorCmdNames = ancestorCmd.name() + " " + ancestorCmdNames;
|
|
1029
|
+
}
|
|
1030
|
+
return ancestorCmdNames + cmdName + " " + cmd.usage();
|
|
740
1031
|
}
|
|
741
|
-
|
|
742
|
-
return
|
|
743
|
-
(Did you mean one of ${similar.join(", ")}?)`;
|
|
1032
|
+
commandDescription(cmd) {
|
|
1033
|
+
return cmd.description();
|
|
744
1034
|
}
|
|
745
|
-
|
|
746
|
-
return
|
|
747
|
-
(Did you mean ${similar[0]}?)`;
|
|
1035
|
+
subcommandDescription(cmd) {
|
|
1036
|
+
return cmd.summary() || cmd.description();
|
|
748
1037
|
}
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
});
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
1038
|
+
optionDescription(option) {
|
|
1039
|
+
const extraInfo = [];
|
|
1040
|
+
if (option.argChoices) {
|
|
1041
|
+
extraInfo.push(`choices: ${option.argChoices.map((choice) => JSON.stringify(choice)).join(", ")}`);
|
|
1042
|
+
}
|
|
1043
|
+
if (option.defaultValue !== undefined) {
|
|
1044
|
+
const showDefault = option.required || option.optional || option.isBoolean() && typeof option.defaultValue === "boolean";
|
|
1045
|
+
if (showDefault) {
|
|
1046
|
+
extraInfo.push(`default: ${option.defaultValueDescription || JSON.stringify(option.defaultValue)}`);
|
|
1047
|
+
}
|
|
1048
|
+
}
|
|
1049
|
+
if (option.presetArg !== undefined && option.optional) {
|
|
1050
|
+
extraInfo.push(`preset: ${JSON.stringify(option.presetArg)}`);
|
|
1051
|
+
}
|
|
1052
|
+
if (option.envVar !== undefined) {
|
|
1053
|
+
extraInfo.push(`env: ${option.envVar}`);
|
|
1054
|
+
}
|
|
1055
|
+
if (extraInfo.length > 0) {
|
|
1056
|
+
const extraDescription = `(${extraInfo.join(", ")})`;
|
|
1057
|
+
if (option.description) {
|
|
1058
|
+
return `${option.description} ${extraDescription}`;
|
|
1059
|
+
}
|
|
1060
|
+
return extraDescription;
|
|
1061
|
+
}
|
|
1062
|
+
return option.description;
|
|
1063
|
+
}
|
|
1064
|
+
argumentDescription(argument) {
|
|
1065
|
+
const extraInfo = [];
|
|
1066
|
+
if (argument.argChoices) {
|
|
1067
|
+
extraInfo.push(`choices: ${argument.argChoices.map((choice) => JSON.stringify(choice)).join(", ")}`);
|
|
1068
|
+
}
|
|
1069
|
+
if (argument.defaultValue !== undefined) {
|
|
1070
|
+
extraInfo.push(`default: ${argument.defaultValueDescription || JSON.stringify(argument.defaultValue)}`);
|
|
1071
|
+
}
|
|
1072
|
+
if (extraInfo.length > 0) {
|
|
1073
|
+
const extraDescription = `(${extraInfo.join(", ")})`;
|
|
1074
|
+
if (argument.description) {
|
|
1075
|
+
return `${argument.description} ${extraDescription}`;
|
|
1076
|
+
}
|
|
1077
|
+
return extraDescription;
|
|
1078
|
+
}
|
|
1079
|
+
return argument.description;
|
|
1080
|
+
}
|
|
1081
|
+
formatItemList(heading, items, helper) {
|
|
1082
|
+
if (items.length === 0)
|
|
1083
|
+
return [];
|
|
1084
|
+
return [helper.styleTitle(heading), ...items, ""];
|
|
1085
|
+
}
|
|
1086
|
+
groupItems(unsortedItems, visibleItems, getGroup) {
|
|
1087
|
+
const result = new Map;
|
|
1088
|
+
unsortedItems.forEach((item) => {
|
|
1089
|
+
const group = getGroup(item);
|
|
1090
|
+
if (!result.has(group))
|
|
1091
|
+
result.set(group, []);
|
|
1092
|
+
});
|
|
1093
|
+
visibleItems.forEach((item) => {
|
|
1094
|
+
const group = getGroup(item);
|
|
1095
|
+
if (!result.has(group)) {
|
|
1096
|
+
result.set(group, []);
|
|
1097
|
+
}
|
|
1098
|
+
result.get(group).push(item);
|
|
1099
|
+
});
|
|
1100
|
+
return result;
|
|
1101
|
+
}
|
|
1102
|
+
formatHelp(cmd, helper) {
|
|
1103
|
+
const termWidth = helper.padWidth(cmd, helper);
|
|
1104
|
+
const helpWidth = helper.helpWidth ?? 80;
|
|
1105
|
+
function callFormatItem(term, description) {
|
|
1106
|
+
return helper.formatItem(term, termWidth, description, helper);
|
|
1107
|
+
}
|
|
1108
|
+
let output = [
|
|
1109
|
+
`${helper.styleTitle("Usage:")} ${helper.styleUsage(helper.commandUsage(cmd))}`,
|
|
1110
|
+
""
|
|
1111
|
+
];
|
|
1112
|
+
const commandDescription = helper.commandDescription(cmd);
|
|
1113
|
+
if (commandDescription.length > 0) {
|
|
1114
|
+
output = output.concat([
|
|
1115
|
+
helper.boxWrap(helper.styleCommandDescription(commandDescription), helpWidth),
|
|
1116
|
+
""
|
|
1117
|
+
]);
|
|
1118
|
+
}
|
|
1119
|
+
const argumentList = helper.visibleArguments(cmd).map((argument) => {
|
|
1120
|
+
return callFormatItem(helper.styleArgumentTerm(helper.argumentTerm(argument)), helper.styleArgumentDescription(helper.argumentDescription(argument)));
|
|
1121
|
+
});
|
|
1122
|
+
output = output.concat(this.formatItemList("Arguments:", argumentList, helper));
|
|
1123
|
+
const optionGroups = this.groupItems(cmd.options, helper.visibleOptions(cmd), (option) => option.helpGroupHeading ?? "Options:");
|
|
1124
|
+
optionGroups.forEach((options, group) => {
|
|
1125
|
+
const optionList = options.map((option) => {
|
|
1126
|
+
return callFormatItem(helper.styleOptionTerm(helper.optionTerm(option)), helper.styleOptionDescription(helper.optionDescription(option)));
|
|
1127
|
+
});
|
|
1128
|
+
output = output.concat(this.formatItemList(group, optionList, helper));
|
|
1129
|
+
});
|
|
1130
|
+
if (helper.showGlobalOptions) {
|
|
1131
|
+
const globalOptionList = helper.visibleGlobalOptions(cmd).map((option) => {
|
|
1132
|
+
return callFormatItem(helper.styleOptionTerm(helper.optionTerm(option)), helper.styleOptionDescription(helper.optionDescription(option)));
|
|
1133
|
+
});
|
|
1134
|
+
output = output.concat(this.formatItemList("Global Options:", globalOptionList, helper));
|
|
1135
|
+
}
|
|
1136
|
+
const commandGroups = this.groupItems(cmd.commands, helper.visibleCommands(cmd), (sub) => sub.helpGroup() || "Commands:");
|
|
1137
|
+
commandGroups.forEach((commands, group) => {
|
|
1138
|
+
const commandList = commands.map((sub) => {
|
|
1139
|
+
return callFormatItem(helper.styleSubcommandTerm(helper.subcommandTerm(sub)), helper.styleSubcommandDescription(helper.subcommandDescription(sub)));
|
|
1140
|
+
});
|
|
1141
|
+
output = output.concat(this.formatItemList(group, commandList, helper));
|
|
1142
|
+
});
|
|
1143
|
+
return output.join(`
|
|
1144
|
+
`);
|
|
1145
|
+
}
|
|
1146
|
+
displayWidth(str) {
|
|
1147
|
+
return stripColor(str).length;
|
|
1148
|
+
}
|
|
1149
|
+
styleTitle(str) {
|
|
1150
|
+
return str;
|
|
1151
|
+
}
|
|
1152
|
+
styleUsage(str) {
|
|
1153
|
+
return str.split(" ").map((word) => {
|
|
1154
|
+
if (word === "[options]")
|
|
1155
|
+
return this.styleOptionText(word);
|
|
1156
|
+
if (word === "[command]")
|
|
1157
|
+
return this.styleSubcommandText(word);
|
|
1158
|
+
if (word[0] === "[" || word[0] === "<")
|
|
1159
|
+
return this.styleArgumentText(word);
|
|
1160
|
+
return this.styleCommandText(word);
|
|
1161
|
+
}).join(" ");
|
|
1162
|
+
}
|
|
1163
|
+
styleCommandDescription(str) {
|
|
1164
|
+
return this.styleDescriptionText(str);
|
|
1165
|
+
}
|
|
1166
|
+
styleOptionDescription(str) {
|
|
1167
|
+
return this.styleDescriptionText(str);
|
|
1168
|
+
}
|
|
1169
|
+
styleSubcommandDescription(str) {
|
|
1170
|
+
return this.styleDescriptionText(str);
|
|
1171
|
+
}
|
|
1172
|
+
styleArgumentDescription(str) {
|
|
1173
|
+
return this.styleDescriptionText(str);
|
|
1174
|
+
}
|
|
1175
|
+
styleDescriptionText(str) {
|
|
1176
|
+
return str;
|
|
1177
|
+
}
|
|
1178
|
+
styleOptionTerm(str) {
|
|
1179
|
+
return this.styleOptionText(str);
|
|
1180
|
+
}
|
|
1181
|
+
styleSubcommandTerm(str) {
|
|
1182
|
+
return str.split(" ").map((word) => {
|
|
1183
|
+
if (word === "[options]")
|
|
1184
|
+
return this.styleOptionText(word);
|
|
1185
|
+
if (word[0] === "[" || word[0] === "<")
|
|
1186
|
+
return this.styleArgumentText(word);
|
|
1187
|
+
return this.styleSubcommandText(word);
|
|
1188
|
+
}).join(" ");
|
|
1189
|
+
}
|
|
1190
|
+
styleArgumentTerm(str) {
|
|
1191
|
+
return this.styleArgumentText(str);
|
|
1192
|
+
}
|
|
1193
|
+
styleOptionText(str) {
|
|
1194
|
+
return str;
|
|
1195
|
+
}
|
|
1196
|
+
styleArgumentText(str) {
|
|
1197
|
+
return str;
|
|
1198
|
+
}
|
|
1199
|
+
styleSubcommandText(str) {
|
|
1200
|
+
return str;
|
|
1201
|
+
}
|
|
1202
|
+
styleCommandText(str) {
|
|
1203
|
+
return str;
|
|
1204
|
+
}
|
|
1205
|
+
padWidth(cmd, helper) {
|
|
1206
|
+
return Math.max(helper.longestOptionTermLength(cmd, helper), helper.longestGlobalOptionTermLength(cmd, helper), helper.longestSubcommandTermLength(cmd, helper), helper.longestArgumentTermLength(cmd, helper));
|
|
1207
|
+
}
|
|
1208
|
+
preformatted(str) {
|
|
1209
|
+
return /\n[^\S\r\n]/.test(str);
|
|
1210
|
+
}
|
|
1211
|
+
formatItem(term, termWidth, description, helper) {
|
|
1212
|
+
const itemIndent = 2;
|
|
1213
|
+
const itemIndentStr = " ".repeat(itemIndent);
|
|
1214
|
+
if (!description)
|
|
1215
|
+
return itemIndentStr + term;
|
|
1216
|
+
const paddedTerm = term.padEnd(termWidth + term.length - helper.displayWidth(term));
|
|
1217
|
+
const spacerWidth = 2;
|
|
1218
|
+
const helpWidth = this.helpWidth ?? 80;
|
|
1219
|
+
const remainingWidth = helpWidth - termWidth - spacerWidth - itemIndent;
|
|
1220
|
+
let formattedDescription;
|
|
1221
|
+
if (remainingWidth < this.minWidthToWrap || helper.preformatted(description)) {
|
|
1222
|
+
formattedDescription = description;
|
|
1223
|
+
} else {
|
|
1224
|
+
const wrappedDescription = helper.boxWrap(description, remainingWidth);
|
|
1225
|
+
formattedDescription = wrappedDescription.replace(/\n/g, `
|
|
1226
|
+
` + " ".repeat(termWidth + spacerWidth));
|
|
1227
|
+
}
|
|
1228
|
+
return itemIndentStr + paddedTerm + " ".repeat(spacerWidth) + formattedDescription.replace(/\n/g, `
|
|
1229
|
+
${itemIndentStr}`);
|
|
1230
|
+
}
|
|
1231
|
+
boxWrap(str, width) {
|
|
1232
|
+
if (width < this.minWidthToWrap)
|
|
1233
|
+
return str;
|
|
1234
|
+
const rawLines = str.split(/\r\n|\n/);
|
|
1235
|
+
const chunkPattern = /[\s]*[^\s]+/g;
|
|
1236
|
+
const wrappedLines = [];
|
|
1237
|
+
rawLines.forEach((line) => {
|
|
1238
|
+
const chunks = line.match(chunkPattern);
|
|
1239
|
+
if (chunks === null) {
|
|
1240
|
+
wrappedLines.push("");
|
|
1241
|
+
return;
|
|
1242
|
+
}
|
|
1243
|
+
let sumChunks = [chunks.shift()];
|
|
1244
|
+
let sumWidth = this.displayWidth(sumChunks[0]);
|
|
1245
|
+
chunks.forEach((chunk) => {
|
|
1246
|
+
const visibleWidth = this.displayWidth(chunk);
|
|
1247
|
+
if (sumWidth + visibleWidth <= width) {
|
|
1248
|
+
sumChunks.push(chunk);
|
|
1249
|
+
sumWidth += visibleWidth;
|
|
1250
|
+
return;
|
|
1251
|
+
}
|
|
1252
|
+
wrappedLines.push(sumChunks.join(""));
|
|
1253
|
+
const nextChunk = chunk.trimStart();
|
|
1254
|
+
sumChunks = [nextChunk];
|
|
1255
|
+
sumWidth = this.displayWidth(nextChunk);
|
|
1256
|
+
});
|
|
1257
|
+
wrappedLines.push(sumChunks.join(""));
|
|
1258
|
+
});
|
|
1259
|
+
return wrappedLines.join(`
|
|
1260
|
+
`);
|
|
1261
|
+
}
|
|
1262
|
+
}
|
|
1263
|
+
function stripColor(str) {
|
|
1264
|
+
const sgrPattern = /\x1b\[\d*(;\d*)*m/g;
|
|
1265
|
+
return str.replace(sgrPattern, "");
|
|
1266
|
+
}
|
|
1267
|
+
exports.Help = Help;
|
|
1268
|
+
exports.stripColor = stripColor;
|
|
1269
|
+
});
|
|
1270
|
+
|
|
1271
|
+
// ../../node_modules/commander/lib/option.js
|
|
1272
|
+
var require_option = __commonJS((exports) => {
|
|
1273
|
+
var { InvalidArgumentError } = require_error();
|
|
1274
|
+
|
|
1275
|
+
class Option {
|
|
1276
|
+
constructor(flags, description) {
|
|
1277
|
+
this.flags = flags;
|
|
1278
|
+
this.description = description || "";
|
|
1279
|
+
this.required = flags.includes("<");
|
|
1280
|
+
this.optional = flags.includes("[");
|
|
1281
|
+
this.variadic = /\w\.\.\.[>\]]$/.test(flags);
|
|
1282
|
+
this.mandatory = false;
|
|
1283
|
+
const optionFlags = splitOptionFlags(flags);
|
|
1284
|
+
this.short = optionFlags.shortFlag;
|
|
1285
|
+
this.long = optionFlags.longFlag;
|
|
1286
|
+
this.negate = false;
|
|
1287
|
+
if (this.long) {
|
|
1288
|
+
this.negate = this.long.startsWith("--no-");
|
|
1289
|
+
}
|
|
1290
|
+
this.defaultValue = undefined;
|
|
1291
|
+
this.defaultValueDescription = undefined;
|
|
1292
|
+
this.presetArg = undefined;
|
|
1293
|
+
this.envVar = undefined;
|
|
1294
|
+
this.parseArg = undefined;
|
|
1295
|
+
this.hidden = false;
|
|
1296
|
+
this.argChoices = undefined;
|
|
1297
|
+
this.conflictsWith = [];
|
|
1298
|
+
this.implied = undefined;
|
|
1299
|
+
this.helpGroupHeading = undefined;
|
|
1300
|
+
}
|
|
1301
|
+
default(value, description) {
|
|
1302
|
+
this.defaultValue = value;
|
|
1303
|
+
this.defaultValueDescription = description;
|
|
1304
|
+
return this;
|
|
1305
|
+
}
|
|
1306
|
+
preset(arg) {
|
|
1307
|
+
this.presetArg = arg;
|
|
1308
|
+
return this;
|
|
1309
|
+
}
|
|
1310
|
+
conflicts(names) {
|
|
1311
|
+
this.conflictsWith = this.conflictsWith.concat(names);
|
|
1312
|
+
return this;
|
|
1313
|
+
}
|
|
1314
|
+
implies(impliedOptionValues) {
|
|
1315
|
+
let newImplied = impliedOptionValues;
|
|
1316
|
+
if (typeof impliedOptionValues === "string") {
|
|
1317
|
+
newImplied = { [impliedOptionValues]: true };
|
|
1318
|
+
}
|
|
1319
|
+
this.implied = Object.assign(this.implied || {}, newImplied);
|
|
1320
|
+
return this;
|
|
1321
|
+
}
|
|
1322
|
+
env(name) {
|
|
1323
|
+
this.envVar = name;
|
|
1324
|
+
return this;
|
|
1325
|
+
}
|
|
1326
|
+
argParser(fn) {
|
|
1327
|
+
this.parseArg = fn;
|
|
1328
|
+
return this;
|
|
1329
|
+
}
|
|
1330
|
+
makeOptionMandatory(mandatory = true) {
|
|
1331
|
+
this.mandatory = !!mandatory;
|
|
1332
|
+
return this;
|
|
1333
|
+
}
|
|
1334
|
+
hideHelp(hide = true) {
|
|
1335
|
+
this.hidden = !!hide;
|
|
1336
|
+
return this;
|
|
1337
|
+
}
|
|
1338
|
+
_collectValue(value, previous) {
|
|
1339
|
+
if (previous === this.defaultValue || !Array.isArray(previous)) {
|
|
1340
|
+
return [value];
|
|
1341
|
+
}
|
|
1342
|
+
previous.push(value);
|
|
1343
|
+
return previous;
|
|
1344
|
+
}
|
|
1345
|
+
choices(values) {
|
|
1346
|
+
this.argChoices = values.slice();
|
|
1347
|
+
this.parseArg = (arg, previous) => {
|
|
1348
|
+
if (!this.argChoices.includes(arg)) {
|
|
1349
|
+
throw new InvalidArgumentError(`Allowed choices are ${this.argChoices.join(", ")}.`);
|
|
1350
|
+
}
|
|
1351
|
+
if (this.variadic) {
|
|
1352
|
+
return this._collectValue(arg, previous);
|
|
1353
|
+
}
|
|
1354
|
+
return arg;
|
|
1355
|
+
};
|
|
1356
|
+
return this;
|
|
1357
|
+
}
|
|
1358
|
+
name() {
|
|
1359
|
+
if (this.long) {
|
|
1360
|
+
return this.long.replace(/^--/, "");
|
|
1361
|
+
}
|
|
1362
|
+
return this.short.replace(/^-/, "");
|
|
1363
|
+
}
|
|
1364
|
+
attributeName() {
|
|
1365
|
+
if (this.negate) {
|
|
1366
|
+
return camelcase(this.name().replace(/^no-/, ""));
|
|
1367
|
+
}
|
|
1368
|
+
return camelcase(this.name());
|
|
1369
|
+
}
|
|
1370
|
+
helpGroup(heading) {
|
|
1371
|
+
this.helpGroupHeading = heading;
|
|
1372
|
+
return this;
|
|
1373
|
+
}
|
|
1374
|
+
is(arg) {
|
|
1375
|
+
return this.short === arg || this.long === arg;
|
|
1376
|
+
}
|
|
1377
|
+
isBoolean() {
|
|
1378
|
+
return !this.required && !this.optional && !this.negate;
|
|
1379
|
+
}
|
|
1380
|
+
}
|
|
1381
|
+
|
|
1382
|
+
class DualOptions {
|
|
1383
|
+
constructor(options) {
|
|
1384
|
+
this.positiveOptions = new Map;
|
|
1385
|
+
this.negativeOptions = new Map;
|
|
1386
|
+
this.dualOptions = new Set;
|
|
1387
|
+
options.forEach((option) => {
|
|
1388
|
+
if (option.negate) {
|
|
1389
|
+
this.negativeOptions.set(option.attributeName(), option);
|
|
1390
|
+
} else {
|
|
1391
|
+
this.positiveOptions.set(option.attributeName(), option);
|
|
1392
|
+
}
|
|
1393
|
+
});
|
|
1394
|
+
this.negativeOptions.forEach((value, key) => {
|
|
1395
|
+
if (this.positiveOptions.has(key)) {
|
|
1396
|
+
this.dualOptions.add(key);
|
|
1397
|
+
}
|
|
1398
|
+
});
|
|
1399
|
+
}
|
|
1400
|
+
valueFromOption(value, option) {
|
|
1401
|
+
const optionKey = option.attributeName();
|
|
1402
|
+
if (!this.dualOptions.has(optionKey))
|
|
1403
|
+
return true;
|
|
1404
|
+
const preset = this.negativeOptions.get(optionKey).presetArg;
|
|
1405
|
+
const negativeValue = preset !== undefined ? preset : false;
|
|
1406
|
+
return option.negate === (negativeValue === value);
|
|
1407
|
+
}
|
|
1408
|
+
}
|
|
1409
|
+
function camelcase(str) {
|
|
1410
|
+
return str.split("-").reduce((str2, word) => {
|
|
1411
|
+
return str2 + word[0].toUpperCase() + word.slice(1);
|
|
1412
|
+
});
|
|
1413
|
+
}
|
|
1414
|
+
function splitOptionFlags(flags) {
|
|
1415
|
+
let shortFlag;
|
|
1416
|
+
let longFlag;
|
|
1417
|
+
const shortFlagExp = /^-[^-]$/;
|
|
1418
|
+
const longFlagExp = /^--[^-]/;
|
|
1419
|
+
const flagParts = flags.split(/[ |,]+/).concat("guard");
|
|
1420
|
+
if (shortFlagExp.test(flagParts[0]))
|
|
1421
|
+
shortFlag = flagParts.shift();
|
|
1422
|
+
if (longFlagExp.test(flagParts[0]))
|
|
1423
|
+
longFlag = flagParts.shift();
|
|
1424
|
+
if (!shortFlag && shortFlagExp.test(flagParts[0]))
|
|
1425
|
+
shortFlag = flagParts.shift();
|
|
1426
|
+
if (!shortFlag && longFlagExp.test(flagParts[0])) {
|
|
1427
|
+
shortFlag = longFlag;
|
|
1428
|
+
longFlag = flagParts.shift();
|
|
1429
|
+
}
|
|
1430
|
+
if (flagParts[0].startsWith("-")) {
|
|
1431
|
+
const unsupportedFlag = flagParts[0];
|
|
1432
|
+
const baseError = `option creation failed due to '${unsupportedFlag}' in option flags '${flags}'`;
|
|
1433
|
+
if (/^-[^-][^-]/.test(unsupportedFlag))
|
|
1434
|
+
throw new Error(`${baseError}
|
|
1435
|
+
- a short flag is a single dash and a single character
|
|
1436
|
+
- either use a single dash and a single character (for a short flag)
|
|
1437
|
+
- or use a double dash for a long option (and can have two, like '--ws, --workspace')`);
|
|
1438
|
+
if (shortFlagExp.test(unsupportedFlag))
|
|
1439
|
+
throw new Error(`${baseError}
|
|
1440
|
+
- too many short flags`);
|
|
1441
|
+
if (longFlagExp.test(unsupportedFlag))
|
|
1442
|
+
throw new Error(`${baseError}
|
|
1443
|
+
- too many long flags`);
|
|
1444
|
+
throw new Error(`${baseError}
|
|
1445
|
+
- unrecognised flag format`);
|
|
1446
|
+
}
|
|
1447
|
+
if (shortFlag === undefined && longFlag === undefined)
|
|
1448
|
+
throw new Error(`option creation failed due to no flags found in '${flags}'.`);
|
|
1449
|
+
return { shortFlag, longFlag };
|
|
1450
|
+
}
|
|
1451
|
+
exports.Option = Option;
|
|
1452
|
+
exports.DualOptions = DualOptions;
|
|
1453
|
+
});
|
|
1454
|
+
|
|
1455
|
+
// ../../node_modules/commander/lib/suggestSimilar.js
|
|
1456
|
+
var require_suggestSimilar = __commonJS((exports) => {
|
|
1457
|
+
var maxDistance = 3;
|
|
1458
|
+
function editDistance(a, b) {
|
|
1459
|
+
if (Math.abs(a.length - b.length) > maxDistance)
|
|
1460
|
+
return Math.max(a.length, b.length);
|
|
1461
|
+
const d = [];
|
|
1462
|
+
for (let i = 0;i <= a.length; i++) {
|
|
1463
|
+
d[i] = [i];
|
|
1464
|
+
}
|
|
1465
|
+
for (let j = 0;j <= b.length; j++) {
|
|
1466
|
+
d[0][j] = j;
|
|
1467
|
+
}
|
|
1468
|
+
for (let j = 1;j <= b.length; j++) {
|
|
1469
|
+
for (let i = 1;i <= a.length; i++) {
|
|
1470
|
+
let cost = 1;
|
|
1471
|
+
if (a[i - 1] === b[j - 1]) {
|
|
1472
|
+
cost = 0;
|
|
1473
|
+
} else {
|
|
1474
|
+
cost = 1;
|
|
1475
|
+
}
|
|
1476
|
+
d[i][j] = Math.min(d[i - 1][j] + 1, d[i][j - 1] + 1, d[i - 1][j - 1] + cost);
|
|
1477
|
+
if (i > 1 && j > 1 && a[i - 1] === b[j - 2] && a[i - 2] === b[j - 1]) {
|
|
1478
|
+
d[i][j] = Math.min(d[i][j], d[i - 2][j - 2] + 1);
|
|
1479
|
+
}
|
|
1480
|
+
}
|
|
1481
|
+
}
|
|
1482
|
+
return d[a.length][b.length];
|
|
1483
|
+
}
|
|
1484
|
+
function suggestSimilar(word, candidates) {
|
|
1485
|
+
if (!candidates || candidates.length === 0)
|
|
1486
|
+
return "";
|
|
1487
|
+
candidates = Array.from(new Set(candidates));
|
|
1488
|
+
const searchingOptions = word.startsWith("--");
|
|
1489
|
+
if (searchingOptions) {
|
|
1490
|
+
word = word.slice(2);
|
|
1491
|
+
candidates = candidates.map((candidate) => candidate.slice(2));
|
|
1492
|
+
}
|
|
1493
|
+
let similar = [];
|
|
1494
|
+
let bestDistance = maxDistance;
|
|
1495
|
+
const minSimilarity = 0.4;
|
|
1496
|
+
candidates.forEach((candidate) => {
|
|
1497
|
+
if (candidate.length <= 1)
|
|
1498
|
+
return;
|
|
1499
|
+
const distance = editDistance(word, candidate);
|
|
1500
|
+
const length = Math.max(word.length, candidate.length);
|
|
1501
|
+
const similarity = (length - distance) / length;
|
|
1502
|
+
if (similarity > minSimilarity) {
|
|
1503
|
+
if (distance < bestDistance) {
|
|
1504
|
+
bestDistance = distance;
|
|
1505
|
+
similar = [candidate];
|
|
1506
|
+
} else if (distance === bestDistance) {
|
|
1507
|
+
similar.push(candidate);
|
|
1508
|
+
}
|
|
1509
|
+
}
|
|
1510
|
+
});
|
|
1511
|
+
similar.sort((a, b) => a.localeCompare(b));
|
|
1512
|
+
if (searchingOptions) {
|
|
1513
|
+
similar = similar.map((candidate) => `--${candidate}`);
|
|
1514
|
+
}
|
|
1515
|
+
if (similar.length > 1) {
|
|
1516
|
+
return `
|
|
1517
|
+
(Did you mean one of ${similar.join(", ")}?)`;
|
|
1518
|
+
}
|
|
1519
|
+
if (similar.length === 1) {
|
|
1520
|
+
return `
|
|
1521
|
+
(Did you mean ${similar[0]}?)`;
|
|
1522
|
+
}
|
|
1523
|
+
return "";
|
|
1524
|
+
}
|
|
1525
|
+
exports.suggestSimilar = suggestSimilar;
|
|
1526
|
+
});
|
|
1527
|
+
|
|
1528
|
+
// ../../node_modules/commander/lib/command.js
|
|
1529
|
+
var require_command = __commonJS((exports) => {
|
|
1530
|
+
var EventEmitter = __require("node:events").EventEmitter;
|
|
1531
|
+
var childProcess4 = __require("node:child_process");
|
|
1532
|
+
var path3 = __require("node:path");
|
|
1533
|
+
var fs7 = __require("node:fs");
|
|
1534
|
+
var process9 = __require("node:process");
|
|
1535
|
+
var { Argument, humanReadableArgName } = require_argument();
|
|
1536
|
+
var { CommanderError } = require_error();
|
|
1537
|
+
var { Help, stripColor } = require_help();
|
|
1538
|
+
var { Option, DualOptions } = require_option();
|
|
1539
|
+
var { suggestSimilar } = require_suggestSimilar();
|
|
1540
|
+
|
|
767
1541
|
class Command extends EventEmitter {
|
|
768
1542
|
constructor(name) {
|
|
769
1543
|
super();
|
|
@@ -800,13 +1574,13 @@ var require_command = __commonJS((exports) => {
|
|
|
800
1574
|
this._showSuggestionAfterError = true;
|
|
801
1575
|
this._savedState = null;
|
|
802
1576
|
this._outputConfiguration = {
|
|
803
|
-
writeOut: (str) =>
|
|
804
|
-
writeErr: (str) =>
|
|
1577
|
+
writeOut: (str) => process9.stdout.write(str),
|
|
1578
|
+
writeErr: (str) => process9.stderr.write(str),
|
|
805
1579
|
outputError: (str, write) => write(str),
|
|
806
|
-
getOutHelpWidth: () =>
|
|
807
|
-
getErrHelpWidth: () =>
|
|
808
|
-
getOutHasColors: () => useColor() ?? (
|
|
809
|
-
getErrHasColors: () => useColor() ?? (
|
|
1580
|
+
getOutHelpWidth: () => process9.stdout.isTTY ? process9.stdout.columns : undefined,
|
|
1581
|
+
getErrHelpWidth: () => process9.stderr.isTTY ? process9.stderr.columns : undefined,
|
|
1582
|
+
getOutHasColors: () => useColor() ?? (process9.stdout.isTTY && process9.stdout.hasColors?.()),
|
|
1583
|
+
getErrHasColors: () => useColor() ?? (process9.stderr.isTTY && process9.stderr.hasColors?.()),
|
|
810
1584
|
stripColor: (str) => stripColor(str)
|
|
811
1585
|
};
|
|
812
1586
|
this._hidden = false;
|
|
@@ -1014,7 +1788,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1014
1788
|
if (this._exitCallback) {
|
|
1015
1789
|
this._exitCallback(new CommanderError(exitCode, code, message));
|
|
1016
1790
|
}
|
|
1017
|
-
|
|
1791
|
+
process9.exit(exitCode);
|
|
1018
1792
|
}
|
|
1019
1793
|
action(fn) {
|
|
1020
1794
|
const listener = (args) => {
|
|
@@ -1211,16 +1985,16 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1211
1985
|
}
|
|
1212
1986
|
parseOptions = parseOptions || {};
|
|
1213
1987
|
if (argv === undefined && parseOptions.from === undefined) {
|
|
1214
|
-
if (
|
|
1988
|
+
if (process9.versions?.electron) {
|
|
1215
1989
|
parseOptions.from = "electron";
|
|
1216
1990
|
}
|
|
1217
|
-
const execArgv =
|
|
1991
|
+
const execArgv = process9.execArgv ?? [];
|
|
1218
1992
|
if (execArgv.includes("-e") || execArgv.includes("--eval") || execArgv.includes("-p") || execArgv.includes("--print")) {
|
|
1219
1993
|
parseOptions.from = "eval";
|
|
1220
1994
|
}
|
|
1221
1995
|
}
|
|
1222
1996
|
if (argv === undefined) {
|
|
1223
|
-
argv =
|
|
1997
|
+
argv = process9.argv;
|
|
1224
1998
|
}
|
|
1225
1999
|
this.rawArgs = argv.slice();
|
|
1226
2000
|
let userArgs;
|
|
@@ -1231,7 +2005,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1231
2005
|
userArgs = argv.slice(2);
|
|
1232
2006
|
break;
|
|
1233
2007
|
case "electron":
|
|
1234
|
-
if (
|
|
2008
|
+
if (process9.defaultApp) {
|
|
1235
2009
|
this._scriptPath = argv[1];
|
|
1236
2010
|
userArgs = argv.slice(2);
|
|
1237
2011
|
} else {
|
|
@@ -1291,7 +2065,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1291
2065
|
this.processedArgs = [];
|
|
1292
2066
|
}
|
|
1293
2067
|
_checkForMissingExecutable(executableFile, executableDir, subcommandName) {
|
|
1294
|
-
if (
|
|
2068
|
+
if (fs7.existsSync(executableFile))
|
|
1295
2069
|
return;
|
|
1296
2070
|
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";
|
|
1297
2071
|
const executableMissing = `'${executableFile}' does not exist
|
|
@@ -1305,12 +2079,12 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1305
2079
|
let launchWithNode = false;
|
|
1306
2080
|
const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
|
|
1307
2081
|
function findFile(baseDir, baseName) {
|
|
1308
|
-
const localBin =
|
|
1309
|
-
if (
|
|
2082
|
+
const localBin = path3.resolve(baseDir, baseName);
|
|
2083
|
+
if (fs7.existsSync(localBin))
|
|
1310
2084
|
return localBin;
|
|
1311
|
-
if (sourceExt.includes(
|
|
2085
|
+
if (sourceExt.includes(path3.extname(baseName)))
|
|
1312
2086
|
return;
|
|
1313
|
-
const foundExt = sourceExt.find((ext) =>
|
|
2087
|
+
const foundExt = sourceExt.find((ext) => fs7.existsSync(`${localBin}${ext}`));
|
|
1314
2088
|
if (foundExt)
|
|
1315
2089
|
return `${localBin}${foundExt}`;
|
|
1316
2090
|
return;
|
|
@@ -1322,42 +2096,42 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1322
2096
|
if (this._scriptPath) {
|
|
1323
2097
|
let resolvedScriptPath;
|
|
1324
2098
|
try {
|
|
1325
|
-
resolvedScriptPath =
|
|
2099
|
+
resolvedScriptPath = fs7.realpathSync(this._scriptPath);
|
|
1326
2100
|
} catch {
|
|
1327
2101
|
resolvedScriptPath = this._scriptPath;
|
|
1328
2102
|
}
|
|
1329
|
-
executableDir =
|
|
2103
|
+
executableDir = path3.resolve(path3.dirname(resolvedScriptPath), executableDir);
|
|
1330
2104
|
}
|
|
1331
2105
|
if (executableDir) {
|
|
1332
2106
|
let localFile = findFile(executableDir, executableFile);
|
|
1333
2107
|
if (!localFile && !subcommand._executableFile && this._scriptPath) {
|
|
1334
|
-
const legacyName =
|
|
2108
|
+
const legacyName = path3.basename(this._scriptPath, path3.extname(this._scriptPath));
|
|
1335
2109
|
if (legacyName !== this._name) {
|
|
1336
2110
|
localFile = findFile(executableDir, `${legacyName}-${subcommand._name}`);
|
|
1337
2111
|
}
|
|
1338
2112
|
}
|
|
1339
2113
|
executableFile = localFile || executableFile;
|
|
1340
2114
|
}
|
|
1341
|
-
launchWithNode = sourceExt.includes(
|
|
2115
|
+
launchWithNode = sourceExt.includes(path3.extname(executableFile));
|
|
1342
2116
|
let proc;
|
|
1343
|
-
if (
|
|
2117
|
+
if (process9.platform !== "win32") {
|
|
1344
2118
|
if (launchWithNode) {
|
|
1345
2119
|
args.unshift(executableFile);
|
|
1346
|
-
args = incrementNodeInspectorPort(
|
|
1347
|
-
proc =
|
|
2120
|
+
args = incrementNodeInspectorPort(process9.execArgv).concat(args);
|
|
2121
|
+
proc = childProcess4.spawn(process9.argv[0], args, { stdio: "inherit" });
|
|
1348
2122
|
} else {
|
|
1349
|
-
proc =
|
|
2123
|
+
proc = childProcess4.spawn(executableFile, args, { stdio: "inherit" });
|
|
1350
2124
|
}
|
|
1351
2125
|
} else {
|
|
1352
2126
|
this._checkForMissingExecutable(executableFile, executableDir, subcommand._name);
|
|
1353
2127
|
args.unshift(executableFile);
|
|
1354
|
-
args = incrementNodeInspectorPort(
|
|
1355
|
-
proc =
|
|
2128
|
+
args = incrementNodeInspectorPort(process9.execArgv).concat(args);
|
|
2129
|
+
proc = childProcess4.spawn(process9.execPath, args, { stdio: "inherit" });
|
|
1356
2130
|
}
|
|
1357
2131
|
if (!proc.killed) {
|
|
1358
2132
|
const signals = ["SIGUSR1", "SIGUSR2", "SIGTERM", "SIGINT", "SIGHUP"];
|
|
1359
2133
|
signals.forEach((signal) => {
|
|
1360
|
-
|
|
2134
|
+
process9.on(signal, () => {
|
|
1361
2135
|
if (proc.killed === false && proc.exitCode === null) {
|
|
1362
2136
|
proc.kill(signal);
|
|
1363
2137
|
}
|
|
@@ -1368,7 +2142,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1368
2142
|
proc.on("close", (code) => {
|
|
1369
2143
|
code = code ?? 1;
|
|
1370
2144
|
if (!exitCallback) {
|
|
1371
|
-
|
|
2145
|
+
process9.exit(code);
|
|
1372
2146
|
} else {
|
|
1373
2147
|
exitCallback(new CommanderError(code, "commander.executeSubCommandAsync", "(close)"));
|
|
1374
2148
|
}
|
|
@@ -1380,7 +2154,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1380
2154
|
throw new Error(`'${executableFile}' not executable`);
|
|
1381
2155
|
}
|
|
1382
2156
|
if (!exitCallback) {
|
|
1383
|
-
|
|
2157
|
+
process9.exit(1);
|
|
1384
2158
|
} else {
|
|
1385
2159
|
const wrappedError = new CommanderError(1, "commander.executeSubCommandAsync", "(error)");
|
|
1386
2160
|
wrappedError.nestedError = err;
|
|
@@ -1577,1329 +2351,553 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1577
2351
|
cmd.options.forEach((anOption) => {
|
|
1578
2352
|
if (anOption.mandatory && cmd.getOptionValue(anOption.attributeName()) === undefined) {
|
|
1579
2353
|
cmd.missingMandatoryOptionValue(anOption);
|
|
1580
|
-
}
|
|
1581
|
-
});
|
|
1582
|
-
});
|
|
1583
|
-
}
|
|
1584
|
-
_checkForConflictingLocalOptions() {
|
|
1585
|
-
const definedNonDefaultOptions = this.options.filter((option) => {
|
|
1586
|
-
const optionKey = option.attributeName();
|
|
1587
|
-
if (this.getOptionValue(optionKey) === undefined) {
|
|
1588
|
-
return false;
|
|
1589
|
-
}
|
|
1590
|
-
return this.getOptionValueSource(optionKey) !== "default";
|
|
1591
|
-
});
|
|
1592
|
-
const optionsWithConflicting = definedNonDefaultOptions.filter((option) => option.conflictsWith.length > 0);
|
|
1593
|
-
optionsWithConflicting.forEach((option) => {
|
|
1594
|
-
const conflictingAndDefined = definedNonDefaultOptions.find((defined) => option.conflictsWith.includes(defined.attributeName()));
|
|
1595
|
-
if (conflictingAndDefined) {
|
|
1596
|
-
this._conflictingOption(option, conflictingAndDefined);
|
|
1597
|
-
}
|
|
1598
|
-
});
|
|
1599
|
-
}
|
|
1600
|
-
_checkForConflictingOptions() {
|
|
1601
|
-
this._getCommandAndAncestors().forEach((cmd) => {
|
|
1602
|
-
cmd._checkForConflictingLocalOptions();
|
|
1603
|
-
});
|
|
1604
|
-
}
|
|
1605
|
-
parseOptions(args) {
|
|
1606
|
-
const operands = [];
|
|
1607
|
-
const unknown = [];
|
|
1608
|
-
let dest = operands;
|
|
1609
|
-
function maybeOption(arg) {
|
|
1610
|
-
return arg.length > 1 && arg[0] === "-";
|
|
1611
|
-
}
|
|
1612
|
-
const negativeNumberArg = (arg) => {
|
|
1613
|
-
if (!/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(arg))
|
|
1614
|
-
return false;
|
|
1615
|
-
return !this._getCommandAndAncestors().some((cmd) => cmd.options.map((opt) => opt.short).some((short) => /^-\d$/.test(short)));
|
|
1616
|
-
};
|
|
1617
|
-
let activeVariadicOption = null;
|
|
1618
|
-
let activeGroup = null;
|
|
1619
|
-
let i = 0;
|
|
1620
|
-
while (i < args.length || activeGroup) {
|
|
1621
|
-
const arg = activeGroup ?? args[i++];
|
|
1622
|
-
activeGroup = null;
|
|
1623
|
-
if (arg === "--") {
|
|
1624
|
-
if (dest === unknown)
|
|
1625
|
-
dest.push(arg);
|
|
1626
|
-
dest.push(...args.slice(i));
|
|
1627
|
-
break;
|
|
1628
|
-
}
|
|
1629
|
-
if (activeVariadicOption && (!maybeOption(arg) || negativeNumberArg(arg))) {
|
|
1630
|
-
this.emit(`option:${activeVariadicOption.name()}`, arg);
|
|
1631
|
-
continue;
|
|
1632
|
-
}
|
|
1633
|
-
activeVariadicOption = null;
|
|
1634
|
-
if (maybeOption(arg)) {
|
|
1635
|
-
const option = this._findOption(arg);
|
|
1636
|
-
if (option) {
|
|
1637
|
-
if (option.required) {
|
|
1638
|
-
const value = args[i++];
|
|
1639
|
-
if (value === undefined)
|
|
1640
|
-
this.optionMissingArgument(option);
|
|
1641
|
-
this.emit(`option:${option.name()}`, value);
|
|
1642
|
-
} else if (option.optional) {
|
|
1643
|
-
let value = null;
|
|
1644
|
-
if (i < args.length && (!maybeOption(args[i]) || negativeNumberArg(args[i]))) {
|
|
1645
|
-
value = args[i++];
|
|
1646
|
-
}
|
|
1647
|
-
this.emit(`option:${option.name()}`, value);
|
|
1648
|
-
} else {
|
|
1649
|
-
this.emit(`option:${option.name()}`);
|
|
1650
|
-
}
|
|
1651
|
-
activeVariadicOption = option.variadic ? option : null;
|
|
1652
|
-
continue;
|
|
1653
|
-
}
|
|
1654
|
-
}
|
|
1655
|
-
if (arg.length > 2 && arg[0] === "-" && arg[1] !== "-") {
|
|
1656
|
-
const option = this._findOption(`-${arg[1]}`);
|
|
1657
|
-
if (option) {
|
|
1658
|
-
if (option.required || option.optional && this._combineFlagAndOptionalValue) {
|
|
1659
|
-
this.emit(`option:${option.name()}`, arg.slice(2));
|
|
1660
|
-
} else {
|
|
1661
|
-
this.emit(`option:${option.name()}`);
|
|
1662
|
-
activeGroup = `-${arg.slice(2)}`;
|
|
1663
|
-
}
|
|
1664
|
-
continue;
|
|
1665
|
-
}
|
|
1666
|
-
}
|
|
1667
|
-
if (/^--[^=]+=/.test(arg)) {
|
|
1668
|
-
const index = arg.indexOf("=");
|
|
1669
|
-
const option = this._findOption(arg.slice(0, index));
|
|
1670
|
-
if (option && (option.required || option.optional)) {
|
|
1671
|
-
this.emit(`option:${option.name()}`, arg.slice(index + 1));
|
|
1672
|
-
continue;
|
|
1673
|
-
}
|
|
1674
|
-
}
|
|
1675
|
-
if (dest === operands && maybeOption(arg) && !(this.commands.length === 0 && negativeNumberArg(arg))) {
|
|
1676
|
-
dest = unknown;
|
|
1677
|
-
}
|
|
1678
|
-
if ((this._enablePositionalOptions || this._passThroughOptions) && operands.length === 0 && unknown.length === 0) {
|
|
1679
|
-
if (this._findCommand(arg)) {
|
|
1680
|
-
operands.push(arg);
|
|
1681
|
-
unknown.push(...args.slice(i));
|
|
1682
|
-
break;
|
|
1683
|
-
} else if (this._getHelpCommand() && arg === this._getHelpCommand().name()) {
|
|
1684
|
-
operands.push(arg, ...args.slice(i));
|
|
1685
|
-
break;
|
|
1686
|
-
} else if (this._defaultCommandName) {
|
|
1687
|
-
unknown.push(arg, ...args.slice(i));
|
|
1688
|
-
break;
|
|
1689
|
-
}
|
|
1690
|
-
}
|
|
1691
|
-
if (this._passThroughOptions) {
|
|
1692
|
-
dest.push(arg, ...args.slice(i));
|
|
1693
|
-
break;
|
|
1694
|
-
}
|
|
1695
|
-
dest.push(arg);
|
|
1696
|
-
}
|
|
1697
|
-
return { operands, unknown };
|
|
1698
|
-
}
|
|
1699
|
-
opts() {
|
|
1700
|
-
if (this._storeOptionsAsProperties) {
|
|
1701
|
-
const result = {};
|
|
1702
|
-
const len = this.options.length;
|
|
1703
|
-
for (let i = 0;i < len; i++) {
|
|
1704
|
-
const key = this.options[i].attributeName();
|
|
1705
|
-
result[key] = key === this._versionOptionName ? this._version : this[key];
|
|
1706
|
-
}
|
|
1707
|
-
return result;
|
|
1708
|
-
}
|
|
1709
|
-
return this._optionValues;
|
|
1710
|
-
}
|
|
1711
|
-
optsWithGlobals() {
|
|
1712
|
-
return this._getCommandAndAncestors().reduce((combinedOptions, cmd) => Object.assign(combinedOptions, cmd.opts()), {});
|
|
1713
|
-
}
|
|
1714
|
-
error(message, errorOptions) {
|
|
1715
|
-
this._outputConfiguration.outputError(`${message}
|
|
1716
|
-
`, this._outputConfiguration.writeErr);
|
|
1717
|
-
if (typeof this._showHelpAfterError === "string") {
|
|
1718
|
-
this._outputConfiguration.writeErr(`${this._showHelpAfterError}
|
|
1719
|
-
`);
|
|
1720
|
-
} else if (this._showHelpAfterError) {
|
|
1721
|
-
this._outputConfiguration.writeErr(`
|
|
1722
|
-
`);
|
|
1723
|
-
this.outputHelp({ error: true });
|
|
1724
|
-
}
|
|
1725
|
-
const config = errorOptions || {};
|
|
1726
|
-
const exitCode = config.exitCode || 1;
|
|
1727
|
-
const code = config.code || "commander.error";
|
|
1728
|
-
this._exit(exitCode, code, message);
|
|
1729
|
-
}
|
|
1730
|
-
_parseOptionsEnv() {
|
|
1731
|
-
this.options.forEach((option) => {
|
|
1732
|
-
if (option.envVar && option.envVar in process2.env) {
|
|
1733
|
-
const optionKey = option.attributeName();
|
|
1734
|
-
if (this.getOptionValue(optionKey) === undefined || ["default", "config", "env"].includes(this.getOptionValueSource(optionKey))) {
|
|
1735
|
-
if (option.required || option.optional) {
|
|
1736
|
-
this.emit(`optionEnv:${option.name()}`, process2.env[option.envVar]);
|
|
1737
|
-
} else {
|
|
1738
|
-
this.emit(`optionEnv:${option.name()}`);
|
|
1739
|
-
}
|
|
1740
|
-
}
|
|
1741
|
-
}
|
|
1742
|
-
});
|
|
1743
|
-
}
|
|
1744
|
-
_parseOptionsImplied() {
|
|
1745
|
-
const dualHelper = new DualOptions(this.options);
|
|
1746
|
-
const hasCustomOptionValue = (optionKey) => {
|
|
1747
|
-
return this.getOptionValue(optionKey) !== undefined && !["default", "implied"].includes(this.getOptionValueSource(optionKey));
|
|
1748
|
-
};
|
|
1749
|
-
this.options.filter((option) => option.implied !== undefined && hasCustomOptionValue(option.attributeName()) && dualHelper.valueFromOption(this.getOptionValue(option.attributeName()), option)).forEach((option) => {
|
|
1750
|
-
Object.keys(option.implied).filter((impliedKey) => !hasCustomOptionValue(impliedKey)).forEach((impliedKey) => {
|
|
1751
|
-
this.setOptionValueWithSource(impliedKey, option.implied[impliedKey], "implied");
|
|
1752
|
-
});
|
|
1753
|
-
});
|
|
1754
|
-
}
|
|
1755
|
-
missingArgument(name) {
|
|
1756
|
-
const message = `error: missing required argument '${name}'`;
|
|
1757
|
-
this.error(message, { code: "commander.missingArgument" });
|
|
1758
|
-
}
|
|
1759
|
-
optionMissingArgument(option) {
|
|
1760
|
-
const message = `error: option '${option.flags}' argument missing`;
|
|
1761
|
-
this.error(message, { code: "commander.optionMissingArgument" });
|
|
1762
|
-
}
|
|
1763
|
-
missingMandatoryOptionValue(option) {
|
|
1764
|
-
const message = `error: required option '${option.flags}' not specified`;
|
|
1765
|
-
this.error(message, { code: "commander.missingMandatoryOptionValue" });
|
|
1766
|
-
}
|
|
1767
|
-
_conflictingOption(option, conflictingOption) {
|
|
1768
|
-
const findBestOptionFromValue = (option2) => {
|
|
1769
|
-
const optionKey = option2.attributeName();
|
|
1770
|
-
const optionValue = this.getOptionValue(optionKey);
|
|
1771
|
-
const negativeOption = this.options.find((target) => target.negate && optionKey === target.attributeName());
|
|
1772
|
-
const positiveOption = this.options.find((target) => !target.negate && optionKey === target.attributeName());
|
|
1773
|
-
if (negativeOption && (negativeOption.presetArg === undefined && optionValue === false || negativeOption.presetArg !== undefined && optionValue === negativeOption.presetArg)) {
|
|
1774
|
-
return negativeOption;
|
|
1775
|
-
}
|
|
1776
|
-
return positiveOption || option2;
|
|
1777
|
-
};
|
|
1778
|
-
const getErrorMessage = (option2) => {
|
|
1779
|
-
const bestOption = findBestOptionFromValue(option2);
|
|
1780
|
-
const optionKey = bestOption.attributeName();
|
|
1781
|
-
const source = this.getOptionValueSource(optionKey);
|
|
1782
|
-
if (source === "env") {
|
|
1783
|
-
return `environment variable '${bestOption.envVar}'`;
|
|
1784
|
-
}
|
|
1785
|
-
return `option '${bestOption.flags}'`;
|
|
1786
|
-
};
|
|
1787
|
-
const message = `error: ${getErrorMessage(option)} cannot be used with ${getErrorMessage(conflictingOption)}`;
|
|
1788
|
-
this.error(message, { code: "commander.conflictingOption" });
|
|
1789
|
-
}
|
|
1790
|
-
unknownOption(flag) {
|
|
1791
|
-
if (this._allowUnknownOption)
|
|
1792
|
-
return;
|
|
1793
|
-
let suggestion = "";
|
|
1794
|
-
if (flag.startsWith("--") && this._showSuggestionAfterError) {
|
|
1795
|
-
let candidateFlags = [];
|
|
1796
|
-
let command = this;
|
|
1797
|
-
do {
|
|
1798
|
-
const moreFlags = command.createHelp().visibleOptions(command).filter((option) => option.long).map((option) => option.long);
|
|
1799
|
-
candidateFlags = candidateFlags.concat(moreFlags);
|
|
1800
|
-
command = command.parent;
|
|
1801
|
-
} while (command && !command._enablePositionalOptions);
|
|
1802
|
-
suggestion = suggestSimilar(flag, candidateFlags);
|
|
1803
|
-
}
|
|
1804
|
-
const message = `error: unknown option '${flag}'${suggestion}`;
|
|
1805
|
-
this.error(message, { code: "commander.unknownOption" });
|
|
1806
|
-
}
|
|
1807
|
-
_excessArguments(receivedArgs) {
|
|
1808
|
-
if (this._allowExcessArguments)
|
|
1809
|
-
return;
|
|
1810
|
-
const expected = this.registeredArguments.length;
|
|
1811
|
-
const s = expected === 1 ? "" : "s";
|
|
1812
|
-
const forSubcommand = this.parent ? ` for '${this.name()}'` : "";
|
|
1813
|
-
const message = `error: too many arguments${forSubcommand}. Expected ${expected} argument${s} but got ${receivedArgs.length}.`;
|
|
1814
|
-
this.error(message, { code: "commander.excessArguments" });
|
|
1815
|
-
}
|
|
1816
|
-
unknownCommand() {
|
|
1817
|
-
const unknownName = this.args[0];
|
|
1818
|
-
let suggestion = "";
|
|
1819
|
-
if (this._showSuggestionAfterError) {
|
|
1820
|
-
const candidateNames = [];
|
|
1821
|
-
this.createHelp().visibleCommands(this).forEach((command) => {
|
|
1822
|
-
candidateNames.push(command.name());
|
|
1823
|
-
if (command.alias())
|
|
1824
|
-
candidateNames.push(command.alias());
|
|
1825
|
-
});
|
|
1826
|
-
suggestion = suggestSimilar(unknownName, candidateNames);
|
|
1827
|
-
}
|
|
1828
|
-
const message = `error: unknown command '${unknownName}'${suggestion}`;
|
|
1829
|
-
this.error(message, { code: "commander.unknownCommand" });
|
|
1830
|
-
}
|
|
1831
|
-
version(str, flags, description) {
|
|
1832
|
-
if (str === undefined)
|
|
1833
|
-
return this._version;
|
|
1834
|
-
this._version = str;
|
|
1835
|
-
flags = flags || "-V, --version";
|
|
1836
|
-
description = description || "output the version number";
|
|
1837
|
-
const versionOption = this.createOption(flags, description);
|
|
1838
|
-
this._versionOptionName = versionOption.attributeName();
|
|
1839
|
-
this._registerOption(versionOption);
|
|
1840
|
-
this.on("option:" + versionOption.name(), () => {
|
|
1841
|
-
this._outputConfiguration.writeOut(`${str}
|
|
1842
|
-
`);
|
|
1843
|
-
this._exit(0, "commander.version", str);
|
|
1844
|
-
});
|
|
1845
|
-
return this;
|
|
1846
|
-
}
|
|
1847
|
-
description(str, argsDescription) {
|
|
1848
|
-
if (str === undefined && argsDescription === undefined)
|
|
1849
|
-
return this._description;
|
|
1850
|
-
this._description = str;
|
|
1851
|
-
if (argsDescription) {
|
|
1852
|
-
this._argsDescription = argsDescription;
|
|
1853
|
-
}
|
|
1854
|
-
return this;
|
|
1855
|
-
}
|
|
1856
|
-
summary(str) {
|
|
1857
|
-
if (str === undefined)
|
|
1858
|
-
return this._summary;
|
|
1859
|
-
this._summary = str;
|
|
1860
|
-
return this;
|
|
1861
|
-
}
|
|
1862
|
-
alias(alias) {
|
|
1863
|
-
if (alias === undefined)
|
|
1864
|
-
return this._aliases[0];
|
|
1865
|
-
let command = this;
|
|
1866
|
-
if (this.commands.length !== 0 && this.commands[this.commands.length - 1]._executableHandler) {
|
|
1867
|
-
command = this.commands[this.commands.length - 1];
|
|
1868
|
-
}
|
|
1869
|
-
if (alias === command._name)
|
|
1870
|
-
throw new Error("Command alias can't be the same as its name");
|
|
1871
|
-
const matchingCommand = this.parent?._findCommand(alias);
|
|
1872
|
-
if (matchingCommand) {
|
|
1873
|
-
const existingCmd = [matchingCommand.name()].concat(matchingCommand.aliases()).join("|");
|
|
1874
|
-
throw new Error(`cannot add alias '${alias}' to command '${this.name()}' as already have command '${existingCmd}'`);
|
|
1875
|
-
}
|
|
1876
|
-
command._aliases.push(alias);
|
|
1877
|
-
return this;
|
|
1878
|
-
}
|
|
1879
|
-
aliases(aliases) {
|
|
1880
|
-
if (aliases === undefined)
|
|
1881
|
-
return this._aliases;
|
|
1882
|
-
aliases.forEach((alias) => this.alias(alias));
|
|
1883
|
-
return this;
|
|
1884
|
-
}
|
|
1885
|
-
usage(str) {
|
|
1886
|
-
if (str === undefined) {
|
|
1887
|
-
if (this._usage)
|
|
1888
|
-
return this._usage;
|
|
1889
|
-
const args = this.registeredArguments.map((arg) => {
|
|
1890
|
-
return humanReadableArgName(arg);
|
|
1891
|
-
});
|
|
1892
|
-
return [].concat(this.options.length || this._helpOption !== null ? "[options]" : [], this.commands.length ? "[command]" : [], this.registeredArguments.length ? args : []).join(" ");
|
|
1893
|
-
}
|
|
1894
|
-
this._usage = str;
|
|
1895
|
-
return this;
|
|
1896
|
-
}
|
|
1897
|
-
name(str) {
|
|
1898
|
-
if (str === undefined)
|
|
1899
|
-
return this._name;
|
|
1900
|
-
this._name = str;
|
|
1901
|
-
return this;
|
|
1902
|
-
}
|
|
1903
|
-
helpGroup(heading) {
|
|
1904
|
-
if (heading === undefined)
|
|
1905
|
-
return this._helpGroupHeading ?? "";
|
|
1906
|
-
this._helpGroupHeading = heading;
|
|
1907
|
-
return this;
|
|
1908
|
-
}
|
|
1909
|
-
commandsGroup(heading) {
|
|
1910
|
-
if (heading === undefined)
|
|
1911
|
-
return this._defaultCommandGroup ?? "";
|
|
1912
|
-
this._defaultCommandGroup = heading;
|
|
1913
|
-
return this;
|
|
1914
|
-
}
|
|
1915
|
-
optionsGroup(heading) {
|
|
1916
|
-
if (heading === undefined)
|
|
1917
|
-
return this._defaultOptionGroup ?? "";
|
|
1918
|
-
this._defaultOptionGroup = heading;
|
|
1919
|
-
return this;
|
|
1920
|
-
}
|
|
1921
|
-
_initOptionGroup(option) {
|
|
1922
|
-
if (this._defaultOptionGroup && !option.helpGroupHeading)
|
|
1923
|
-
option.helpGroup(this._defaultOptionGroup);
|
|
1924
|
-
}
|
|
1925
|
-
_initCommandGroup(cmd) {
|
|
1926
|
-
if (this._defaultCommandGroup && !cmd.helpGroup())
|
|
1927
|
-
cmd.helpGroup(this._defaultCommandGroup);
|
|
1928
|
-
}
|
|
1929
|
-
nameFromFilename(filename) {
|
|
1930
|
-
this._name = path.basename(filename, path.extname(filename));
|
|
1931
|
-
return this;
|
|
1932
|
-
}
|
|
1933
|
-
executableDir(path2) {
|
|
1934
|
-
if (path2 === undefined)
|
|
1935
|
-
return this._executableDir;
|
|
1936
|
-
this._executableDir = path2;
|
|
1937
|
-
return this;
|
|
1938
|
-
}
|
|
1939
|
-
helpInformation(contextOptions) {
|
|
1940
|
-
const helper = this.createHelp();
|
|
1941
|
-
const context = this._getOutputContext(contextOptions);
|
|
1942
|
-
helper.prepareContext({
|
|
1943
|
-
error: context.error,
|
|
1944
|
-
helpWidth: context.helpWidth,
|
|
1945
|
-
outputHasColors: context.hasColors
|
|
1946
|
-
});
|
|
1947
|
-
const text = helper.formatHelp(this, helper);
|
|
1948
|
-
if (context.hasColors)
|
|
1949
|
-
return text;
|
|
1950
|
-
return this._outputConfiguration.stripColor(text);
|
|
1951
|
-
}
|
|
1952
|
-
_getOutputContext(contextOptions) {
|
|
1953
|
-
contextOptions = contextOptions || {};
|
|
1954
|
-
const error = !!contextOptions.error;
|
|
1955
|
-
let baseWrite;
|
|
1956
|
-
let hasColors;
|
|
1957
|
-
let helpWidth;
|
|
1958
|
-
if (error) {
|
|
1959
|
-
baseWrite = (str) => this._outputConfiguration.writeErr(str);
|
|
1960
|
-
hasColors = this._outputConfiguration.getErrHasColors();
|
|
1961
|
-
helpWidth = this._outputConfiguration.getErrHelpWidth();
|
|
1962
|
-
} else {
|
|
1963
|
-
baseWrite = (str) => this._outputConfiguration.writeOut(str);
|
|
1964
|
-
hasColors = this._outputConfiguration.getOutHasColors();
|
|
1965
|
-
helpWidth = this._outputConfiguration.getOutHelpWidth();
|
|
1966
|
-
}
|
|
1967
|
-
const write = (str) => {
|
|
1968
|
-
if (!hasColors)
|
|
1969
|
-
str = this._outputConfiguration.stripColor(str);
|
|
1970
|
-
return baseWrite(str);
|
|
1971
|
-
};
|
|
1972
|
-
return { error, write, hasColors, helpWidth };
|
|
1973
|
-
}
|
|
1974
|
-
outputHelp(contextOptions) {
|
|
1975
|
-
let deprecatedCallback;
|
|
1976
|
-
if (typeof contextOptions === "function") {
|
|
1977
|
-
deprecatedCallback = contextOptions;
|
|
1978
|
-
contextOptions = undefined;
|
|
1979
|
-
}
|
|
1980
|
-
const outputContext = this._getOutputContext(contextOptions);
|
|
1981
|
-
const eventContext = {
|
|
1982
|
-
error: outputContext.error,
|
|
1983
|
-
write: outputContext.write,
|
|
1984
|
-
command: this
|
|
1985
|
-
};
|
|
1986
|
-
this._getCommandAndAncestors().reverse().forEach((command) => command.emit("beforeAllHelp", eventContext));
|
|
1987
|
-
this.emit("beforeHelp", eventContext);
|
|
1988
|
-
let helpInformation = this.helpInformation({ error: outputContext.error });
|
|
1989
|
-
if (deprecatedCallback) {
|
|
1990
|
-
helpInformation = deprecatedCallback(helpInformation);
|
|
1991
|
-
if (typeof helpInformation !== "string" && !Buffer.isBuffer(helpInformation)) {
|
|
1992
|
-
throw new Error("outputHelp callback must return a string or a Buffer");
|
|
1993
|
-
}
|
|
1994
|
-
}
|
|
1995
|
-
outputContext.write(helpInformation);
|
|
1996
|
-
if (this._getHelpOption()?.long) {
|
|
1997
|
-
this.emit(this._getHelpOption().long);
|
|
1998
|
-
}
|
|
1999
|
-
this.emit("afterHelp", eventContext);
|
|
2000
|
-
this._getCommandAndAncestors().forEach((command) => command.emit("afterAllHelp", eventContext));
|
|
2001
|
-
}
|
|
2002
|
-
helpOption(flags, description) {
|
|
2003
|
-
if (typeof flags === "boolean") {
|
|
2004
|
-
if (flags) {
|
|
2005
|
-
if (this._helpOption === null)
|
|
2006
|
-
this._helpOption = undefined;
|
|
2007
|
-
if (this._defaultOptionGroup) {
|
|
2008
|
-
this._initOptionGroup(this._getHelpOption());
|
|
2009
|
-
}
|
|
2010
|
-
} else {
|
|
2011
|
-
this._helpOption = null;
|
|
2012
|
-
}
|
|
2013
|
-
return this;
|
|
2014
|
-
}
|
|
2015
|
-
this._helpOption = this.createOption(flags ?? "-h, --help", description ?? "display help for command");
|
|
2016
|
-
if (flags || description)
|
|
2017
|
-
this._initOptionGroup(this._helpOption);
|
|
2018
|
-
return this;
|
|
2019
|
-
}
|
|
2020
|
-
_getHelpOption() {
|
|
2021
|
-
if (this._helpOption === undefined) {
|
|
2022
|
-
this.helpOption(undefined, undefined);
|
|
2023
|
-
}
|
|
2024
|
-
return this._helpOption;
|
|
2025
|
-
}
|
|
2026
|
-
addHelpOption(option) {
|
|
2027
|
-
this._helpOption = option;
|
|
2028
|
-
this._initOptionGroup(option);
|
|
2029
|
-
return this;
|
|
2030
|
-
}
|
|
2031
|
-
help(contextOptions) {
|
|
2032
|
-
this.outputHelp(contextOptions);
|
|
2033
|
-
let exitCode = Number(process2.exitCode ?? 0);
|
|
2034
|
-
if (exitCode === 0 && contextOptions && typeof contextOptions !== "function" && contextOptions.error) {
|
|
2035
|
-
exitCode = 1;
|
|
2036
|
-
}
|
|
2037
|
-
this._exit(exitCode, "commander.help", "(outputHelp)");
|
|
2038
|
-
}
|
|
2039
|
-
addHelpText(position, text) {
|
|
2040
|
-
const allowedValues = ["beforeAll", "before", "after", "afterAll"];
|
|
2041
|
-
if (!allowedValues.includes(position)) {
|
|
2042
|
-
throw new Error(`Unexpected value for position to addHelpText.
|
|
2043
|
-
Expecting one of '${allowedValues.join("', '")}'`);
|
|
2044
|
-
}
|
|
2045
|
-
const helpEvent = `${position}Help`;
|
|
2046
|
-
this.on(helpEvent, (context) => {
|
|
2047
|
-
let helpStr;
|
|
2048
|
-
if (typeof text === "function") {
|
|
2049
|
-
helpStr = text({ error: context.error, command: context.command });
|
|
2050
|
-
} else {
|
|
2051
|
-
helpStr = text;
|
|
2052
|
-
}
|
|
2053
|
-
if (helpStr) {
|
|
2054
|
-
context.write(`${helpStr}
|
|
2055
|
-
`);
|
|
2056
|
-
}
|
|
2057
|
-
});
|
|
2058
|
-
return this;
|
|
2059
|
-
}
|
|
2060
|
-
_outputHelpIfRequested(args) {
|
|
2061
|
-
const helpOption = this._getHelpOption();
|
|
2062
|
-
const helpRequested = helpOption && args.find((arg) => helpOption.is(arg));
|
|
2063
|
-
if (helpRequested) {
|
|
2064
|
-
this.outputHelp();
|
|
2065
|
-
this._exit(0, "commander.helpDisplayed", "(outputHelp)");
|
|
2066
|
-
}
|
|
2067
|
-
}
|
|
2068
|
-
}
|
|
2069
|
-
function incrementNodeInspectorPort(args) {
|
|
2070
|
-
return args.map((arg) => {
|
|
2071
|
-
if (!arg.startsWith("--inspect")) {
|
|
2072
|
-
return arg;
|
|
2073
|
-
}
|
|
2074
|
-
let debugOption;
|
|
2075
|
-
let debugHost = "127.0.0.1";
|
|
2076
|
-
let debugPort = "9229";
|
|
2077
|
-
let match;
|
|
2078
|
-
if ((match = arg.match(/^(--inspect(-brk)?)$/)) !== null) {
|
|
2079
|
-
debugOption = match[1];
|
|
2080
|
-
} else if ((match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+)$/)) !== null) {
|
|
2081
|
-
debugOption = match[1];
|
|
2082
|
-
if (/^\d+$/.test(match[3])) {
|
|
2083
|
-
debugPort = match[3];
|
|
2084
|
-
} else {
|
|
2085
|
-
debugHost = match[3];
|
|
2086
|
-
}
|
|
2087
|
-
} else if ((match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/)) !== null) {
|
|
2088
|
-
debugOption = match[1];
|
|
2089
|
-
debugHost = match[3];
|
|
2090
|
-
debugPort = match[4];
|
|
2091
|
-
}
|
|
2092
|
-
if (debugOption && debugPort !== "0") {
|
|
2093
|
-
return `${debugOption}=${debugHost}:${parseInt(debugPort) + 1}`;
|
|
2094
|
-
}
|
|
2095
|
-
return arg;
|
|
2096
|
-
});
|
|
2097
|
-
}
|
|
2098
|
-
function useColor() {
|
|
2099
|
-
if (process2.env.NO_COLOR || process2.env.FORCE_COLOR === "0" || process2.env.FORCE_COLOR === "false")
|
|
2100
|
-
return false;
|
|
2101
|
-
if (process2.env.FORCE_COLOR || process2.env.CLICOLOR_FORCE !== undefined)
|
|
2102
|
-
return true;
|
|
2103
|
-
return;
|
|
2104
|
-
}
|
|
2105
|
-
exports.Command = Command;
|
|
2106
|
-
exports.useColor = useColor;
|
|
2107
|
-
});
|
|
2108
|
-
|
|
2109
|
-
// ../../node_modules/commander/index.js
|
|
2110
|
-
var require_commander = __commonJS((exports) => {
|
|
2111
|
-
var { Argument } = require_argument();
|
|
2112
|
-
var { Command } = require_command();
|
|
2113
|
-
var { CommanderError, InvalidArgumentError } = require_error();
|
|
2114
|
-
var { Help } = require_help();
|
|
2115
|
-
var { Option } = require_option();
|
|
2116
|
-
exports.program = new Command;
|
|
2117
|
-
exports.createCommand = (name) => new Command(name);
|
|
2118
|
-
exports.createOption = (flags, description) => new Option(flags, description);
|
|
2119
|
-
exports.createArgument = (name, description) => new Argument(name, description);
|
|
2120
|
-
exports.Command = Command;
|
|
2121
|
-
exports.Option = Option;
|
|
2122
|
-
exports.Argument = Argument;
|
|
2123
|
-
exports.Help = Help;
|
|
2124
|
-
exports.CommanderError = CommanderError;
|
|
2125
|
-
exports.InvalidArgumentError = InvalidArgumentError;
|
|
2126
|
-
exports.InvalidOptionArgumentError = InvalidArgumentError;
|
|
2127
|
-
});
|
|
2128
|
-
|
|
2129
|
-
// ../../node_modules/is-inside-container/node_modules/is-docker/index.js
|
|
2130
|
-
import fs from "node:fs";
|
|
2131
|
-
function hasDockerEnv() {
|
|
2132
|
-
try {
|
|
2133
|
-
fs.statSync("/.dockerenv");
|
|
2134
|
-
return true;
|
|
2135
|
-
} catch {
|
|
2136
|
-
return false;
|
|
2137
|
-
}
|
|
2138
|
-
}
|
|
2139
|
-
function hasDockerCGroup() {
|
|
2140
|
-
try {
|
|
2141
|
-
return fs.readFileSync("/proc/self/cgroup", "utf8").includes("docker");
|
|
2142
|
-
} catch {
|
|
2143
|
-
return false;
|
|
2144
|
-
}
|
|
2145
|
-
}
|
|
2146
|
-
function isDocker() {
|
|
2147
|
-
if (isDockerCached === undefined) {
|
|
2148
|
-
isDockerCached = hasDockerEnv() || hasDockerCGroup();
|
|
2149
|
-
}
|
|
2150
|
-
return isDockerCached;
|
|
2151
|
-
}
|
|
2152
|
-
var isDockerCached;
|
|
2153
|
-
var init_is_docker = () => {};
|
|
2154
|
-
|
|
2155
|
-
// ../../node_modules/is-inside-container/index.js
|
|
2156
|
-
import fs2 from "node:fs";
|
|
2157
|
-
function isInsideContainer() {
|
|
2158
|
-
if (cachedResult === undefined) {
|
|
2159
|
-
cachedResult = hasContainerEnv() || isDocker();
|
|
2160
|
-
}
|
|
2161
|
-
return cachedResult;
|
|
2162
|
-
}
|
|
2163
|
-
var cachedResult, hasContainerEnv = () => {
|
|
2164
|
-
try {
|
|
2165
|
-
fs2.statSync("/run/.containerenv");
|
|
2166
|
-
return true;
|
|
2167
|
-
} catch {
|
|
2168
|
-
return false;
|
|
2169
|
-
}
|
|
2170
|
-
};
|
|
2171
|
-
var init_is_inside_container = __esm(() => {
|
|
2172
|
-
init_is_docker();
|
|
2173
|
-
});
|
|
2174
|
-
|
|
2175
|
-
// ../../node_modules/wsl-utils/node_modules/is-wsl/index.js
|
|
2176
|
-
import process2 from "node:process";
|
|
2177
|
-
import os from "node:os";
|
|
2178
|
-
import fs3 from "node:fs";
|
|
2179
|
-
var isWsl = () => {
|
|
2180
|
-
if (process2.platform !== "linux") {
|
|
2181
|
-
return false;
|
|
2182
|
-
}
|
|
2183
|
-
if (os.release().toLowerCase().includes("microsoft")) {
|
|
2184
|
-
if (isInsideContainer()) {
|
|
2185
|
-
return false;
|
|
2186
|
-
}
|
|
2187
|
-
return true;
|
|
2188
|
-
}
|
|
2189
|
-
try {
|
|
2190
|
-
if (fs3.readFileSync("/proc/version", "utf8").toLowerCase().includes("microsoft")) {
|
|
2191
|
-
return !isInsideContainer();
|
|
2192
|
-
}
|
|
2193
|
-
} catch {}
|
|
2194
|
-
if (fs3.existsSync("/proc/sys/fs/binfmt_misc/WSLInterop") || fs3.existsSync("/run/WSL")) {
|
|
2195
|
-
return !isInsideContainer();
|
|
2196
|
-
}
|
|
2197
|
-
return false;
|
|
2198
|
-
}, is_wsl_default;
|
|
2199
|
-
var init_is_wsl = __esm(() => {
|
|
2200
|
-
init_is_inside_container();
|
|
2201
|
-
is_wsl_default = process2.env.__IS_WSL_TEST__ ? isWsl : isWsl();
|
|
2202
|
-
});
|
|
2203
|
-
|
|
2204
|
-
// ../../node_modules/powershell-utils/index.js
|
|
2205
|
-
import process3 from "node:process";
|
|
2206
|
-
import { Buffer as Buffer2 } from "node:buffer";
|
|
2207
|
-
import { promisify } from "node:util";
|
|
2208
|
-
import childProcess from "node:child_process";
|
|
2209
|
-
var execFile, powerShellPath = () => `${process3.env.SYSTEMROOT || process3.env.windir || String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`, executePowerShell = async (command, options = {}) => {
|
|
2210
|
-
const {
|
|
2211
|
-
powerShellPath: psPath,
|
|
2212
|
-
...execFileOptions
|
|
2213
|
-
} = options;
|
|
2214
|
-
const encodedCommand = executePowerShell.encodeCommand(command);
|
|
2215
|
-
return execFile(psPath ?? powerShellPath(), [
|
|
2216
|
-
...executePowerShell.argumentsPrefix,
|
|
2217
|
-
encodedCommand
|
|
2218
|
-
], {
|
|
2219
|
-
encoding: "utf8",
|
|
2220
|
-
...execFileOptions
|
|
2221
|
-
});
|
|
2222
|
-
};
|
|
2223
|
-
var init_powershell_utils = __esm(() => {
|
|
2224
|
-
execFile = promisify(childProcess.execFile);
|
|
2225
|
-
executePowerShell.argumentsPrefix = [
|
|
2226
|
-
"-NoProfile",
|
|
2227
|
-
"-NonInteractive",
|
|
2228
|
-
"-ExecutionPolicy",
|
|
2229
|
-
"Bypass",
|
|
2230
|
-
"-EncodedCommand"
|
|
2231
|
-
];
|
|
2232
|
-
executePowerShell.encodeCommand = (command) => Buffer2.from(command, "utf16le").toString("base64");
|
|
2233
|
-
executePowerShell.escapeArgument = (value) => `'${String(value).replaceAll("'", "''")}'`;
|
|
2234
|
-
});
|
|
2235
|
-
|
|
2236
|
-
// ../../node_modules/wsl-utils/utilities.js
|
|
2237
|
-
function parseMountPointFromConfig(content) {
|
|
2238
|
-
for (const line of content.split(`
|
|
2239
|
-
`)) {
|
|
2240
|
-
if (/^\s*#/.test(line)) {
|
|
2241
|
-
continue;
|
|
2242
|
-
}
|
|
2243
|
-
const match = /^\s*root\s*=\s*(?<mountPoint>"[^"]*"|'[^']*'|[^#]*)/.exec(line);
|
|
2244
|
-
if (!match) {
|
|
2245
|
-
continue;
|
|
2246
|
-
}
|
|
2247
|
-
return match.groups.mountPoint.trim().replaceAll(/^["']|["']$/g, "");
|
|
2248
|
-
}
|
|
2249
|
-
}
|
|
2250
|
-
|
|
2251
|
-
// ../../node_modules/wsl-utils/index.js
|
|
2252
|
-
import { promisify as promisify2 } from "node:util";
|
|
2253
|
-
import childProcess2 from "node:child_process";
|
|
2254
|
-
import fs4, { constants as fsConstants } from "node:fs/promises";
|
|
2255
|
-
var execFile2, wslDrivesMountPoint, powerShellPathFromWsl = async () => {
|
|
2256
|
-
const mountPoint = await wslDrivesMountPoint();
|
|
2257
|
-
return `${mountPoint}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`;
|
|
2258
|
-
}, powerShellPath2, canAccessPowerShellPromise, canAccessPowerShell = async () => {
|
|
2259
|
-
canAccessPowerShellPromise ??= (async () => {
|
|
2260
|
-
try {
|
|
2261
|
-
const psPath = await powerShellPath2();
|
|
2262
|
-
await fs4.access(psPath, fsConstants.X_OK);
|
|
2263
|
-
return true;
|
|
2264
|
-
} catch {
|
|
2265
|
-
return false;
|
|
2266
|
-
}
|
|
2267
|
-
})();
|
|
2268
|
-
return canAccessPowerShellPromise;
|
|
2269
|
-
}, wslDefaultBrowser = async () => {
|
|
2270
|
-
const psPath = await powerShellPath2();
|
|
2271
|
-
const command = String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`;
|
|
2272
|
-
const { stdout } = await executePowerShell(command, { powerShellPath: psPath });
|
|
2273
|
-
return stdout.trim();
|
|
2274
|
-
}, convertWslPathToWindows = async (path) => {
|
|
2275
|
-
if (/^[a-z]+:\/\//i.test(path)) {
|
|
2276
|
-
return path;
|
|
2277
|
-
}
|
|
2278
|
-
try {
|
|
2279
|
-
const { stdout } = await execFile2("wslpath", ["-aw", path], { encoding: "utf8" });
|
|
2280
|
-
return stdout.trim();
|
|
2281
|
-
} catch {
|
|
2282
|
-
return path;
|
|
2283
|
-
}
|
|
2284
|
-
};
|
|
2285
|
-
var init_wsl_utils = __esm(() => {
|
|
2286
|
-
init_is_wsl();
|
|
2287
|
-
init_powershell_utils();
|
|
2288
|
-
init_is_wsl();
|
|
2289
|
-
execFile2 = promisify2(childProcess2.execFile);
|
|
2290
|
-
wslDrivesMountPoint = (() => {
|
|
2291
|
-
const defaultMountPoint = "/mnt/";
|
|
2292
|
-
let mountPoint;
|
|
2293
|
-
return async function() {
|
|
2294
|
-
if (mountPoint) {
|
|
2295
|
-
return mountPoint;
|
|
2296
|
-
}
|
|
2297
|
-
const configFilePath = "/etc/wsl.conf";
|
|
2298
|
-
let isConfigFileExists = false;
|
|
2299
|
-
try {
|
|
2300
|
-
await fs4.access(configFilePath, fsConstants.F_OK);
|
|
2301
|
-
isConfigFileExists = true;
|
|
2302
|
-
} catch {}
|
|
2303
|
-
if (!isConfigFileExists) {
|
|
2304
|
-
return defaultMountPoint;
|
|
2305
|
-
}
|
|
2306
|
-
const configContent = await fs4.readFile(configFilePath, { encoding: "utf8" });
|
|
2307
|
-
const parsedMountPoint = parseMountPointFromConfig(configContent);
|
|
2308
|
-
if (parsedMountPoint === undefined) {
|
|
2309
|
-
return defaultMountPoint;
|
|
2310
|
-
}
|
|
2311
|
-
mountPoint = parsedMountPoint;
|
|
2312
|
-
mountPoint = mountPoint.endsWith("/") ? mountPoint : `${mountPoint}/`;
|
|
2313
|
-
return mountPoint;
|
|
2314
|
-
};
|
|
2315
|
-
})();
|
|
2316
|
-
powerShellPath2 = is_wsl_default ? powerShellPathFromWsl : powerShellPath;
|
|
2317
|
-
});
|
|
2318
|
-
|
|
2319
|
-
// ../../node_modules/open/node_modules/define-lazy-prop/index.js
|
|
2320
|
-
function defineLazyProperty(object, propertyName, valueGetter) {
|
|
2321
|
-
const define2 = (value) => Object.defineProperty(object, propertyName, { value, enumerable: true, writable: true });
|
|
2322
|
-
Object.defineProperty(object, propertyName, {
|
|
2323
|
-
configurable: true,
|
|
2324
|
-
enumerable: true,
|
|
2325
|
-
get() {
|
|
2326
|
-
const result = valueGetter();
|
|
2327
|
-
define2(result);
|
|
2328
|
-
return result;
|
|
2329
|
-
},
|
|
2330
|
-
set(value) {
|
|
2331
|
-
define2(value);
|
|
2332
|
-
}
|
|
2333
|
-
});
|
|
2334
|
-
return object;
|
|
2335
|
-
}
|
|
2336
|
-
|
|
2337
|
-
// ../../node_modules/default-browser-id/index.js
|
|
2338
|
-
import { promisify as promisify3 } from "node:util";
|
|
2339
|
-
import process4 from "node:process";
|
|
2340
|
-
import { execFile as execFile3 } from "node:child_process";
|
|
2341
|
-
async function defaultBrowserId() {
|
|
2342
|
-
if (process4.platform !== "darwin") {
|
|
2343
|
-
throw new Error("macOS only");
|
|
2344
|
-
}
|
|
2345
|
-
const { stdout } = await execFileAsync("defaults", ["read", "com.apple.LaunchServices/com.apple.launchservices.secure", "LSHandlers"]);
|
|
2346
|
-
const match = /LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(stdout);
|
|
2347
|
-
const browserId = match?.groups.id ?? "com.apple.Safari";
|
|
2348
|
-
if (browserId === "com.apple.safari") {
|
|
2349
|
-
return "com.apple.Safari";
|
|
2350
|
-
}
|
|
2351
|
-
return browserId;
|
|
2352
|
-
}
|
|
2353
|
-
var execFileAsync;
|
|
2354
|
-
var init_default_browser_id = __esm(() => {
|
|
2355
|
-
execFileAsync = promisify3(execFile3);
|
|
2356
|
-
});
|
|
2357
|
-
|
|
2358
|
-
// ../../node_modules/run-applescript/index.js
|
|
2359
|
-
import process5 from "node:process";
|
|
2360
|
-
import { promisify as promisify4 } from "node:util";
|
|
2361
|
-
import { execFile as execFile4, execFileSync } from "node:child_process";
|
|
2362
|
-
async function runAppleScript(script, { humanReadableOutput = true, signal } = {}) {
|
|
2363
|
-
if (process5.platform !== "darwin") {
|
|
2364
|
-
throw new Error("macOS only");
|
|
2365
|
-
}
|
|
2366
|
-
const outputArguments = humanReadableOutput ? [] : ["-ss"];
|
|
2367
|
-
const execOptions = {};
|
|
2368
|
-
if (signal) {
|
|
2369
|
-
execOptions.signal = signal;
|
|
2370
|
-
}
|
|
2371
|
-
const { stdout } = await execFileAsync2("osascript", ["-e", script, outputArguments], execOptions);
|
|
2372
|
-
return stdout.trim();
|
|
2373
|
-
}
|
|
2374
|
-
var execFileAsync2;
|
|
2375
|
-
var init_run_applescript = __esm(() => {
|
|
2376
|
-
execFileAsync2 = promisify4(execFile4);
|
|
2377
|
-
});
|
|
2378
|
-
|
|
2379
|
-
// ../../node_modules/bundle-name/index.js
|
|
2380
|
-
async function bundleName(bundleId) {
|
|
2381
|
-
return runAppleScript(`tell application "Finder" to set app_path to application file id "${bundleId}" as string
|
|
2382
|
-
tell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`);
|
|
2383
|
-
}
|
|
2384
|
-
var init_bundle_name = __esm(() => {
|
|
2385
|
-
init_run_applescript();
|
|
2386
|
-
});
|
|
2387
|
-
|
|
2388
|
-
// ../../node_modules/default-browser/windows.js
|
|
2389
|
-
import { promisify as promisify5 } from "node:util";
|
|
2390
|
-
import { execFile as execFile5 } from "node:child_process";
|
|
2391
|
-
async function defaultBrowser(_execFileAsync = execFileAsync3) {
|
|
2392
|
-
const { stdout } = await _execFileAsync("reg", [
|
|
2393
|
-
"QUERY",
|
|
2394
|
-
" HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice",
|
|
2395
|
-
"/v",
|
|
2396
|
-
"ProgId"
|
|
2397
|
-
]);
|
|
2398
|
-
const match = /ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(stdout);
|
|
2399
|
-
if (!match) {
|
|
2400
|
-
throw new UnknownBrowserError(`Cannot find Windows browser in stdout: ${JSON.stringify(stdout)}`);
|
|
2401
|
-
}
|
|
2402
|
-
const { id } = match.groups;
|
|
2403
|
-
const dotIndex = id.lastIndexOf(".");
|
|
2404
|
-
const hyphenIndex = id.lastIndexOf("-");
|
|
2405
|
-
const baseIdByDot = dotIndex === -1 ? undefined : id.slice(0, dotIndex);
|
|
2406
|
-
const baseIdByHyphen = hyphenIndex === -1 ? undefined : id.slice(0, hyphenIndex);
|
|
2407
|
-
return windowsBrowserProgIds[id] ?? windowsBrowserProgIds[baseIdByDot] ?? windowsBrowserProgIds[baseIdByHyphen] ?? { name: id, id };
|
|
2408
|
-
}
|
|
2409
|
-
var execFileAsync3, windowsBrowserProgIds, _windowsBrowserProgIdMap, UnknownBrowserError;
|
|
2410
|
-
var init_windows = __esm(() => {
|
|
2411
|
-
execFileAsync3 = promisify5(execFile5);
|
|
2412
|
-
windowsBrowserProgIds = {
|
|
2413
|
-
MSEdgeHTM: { name: "Edge", id: "com.microsoft.edge" },
|
|
2414
|
-
MSEdgeBHTML: { name: "Edge Beta", id: "com.microsoft.edge.beta" },
|
|
2415
|
-
MSEdgeDHTML: { name: "Edge Dev", id: "com.microsoft.edge.dev" },
|
|
2416
|
-
AppXq0fevzme2pys62n3e0fbqa7peapykr8v: { name: "Edge", id: "com.microsoft.edge.old" },
|
|
2417
|
-
ChromeHTML: { name: "Chrome", id: "com.google.chrome" },
|
|
2418
|
-
ChromeBHTML: { name: "Chrome Beta", id: "com.google.chrome.beta" },
|
|
2419
|
-
ChromeDHTML: { name: "Chrome Dev", id: "com.google.chrome.dev" },
|
|
2420
|
-
ChromiumHTM: { name: "Chromium", id: "org.chromium.Chromium" },
|
|
2421
|
-
BraveHTML: { name: "Brave", id: "com.brave.Browser" },
|
|
2422
|
-
BraveBHTML: { name: "Brave Beta", id: "com.brave.Browser.beta" },
|
|
2423
|
-
BraveDHTML: { name: "Brave Dev", id: "com.brave.Browser.dev" },
|
|
2424
|
-
BraveSSHTM: { name: "Brave Nightly", id: "com.brave.Browser.nightly" },
|
|
2425
|
-
FirefoxURL: { name: "Firefox", id: "org.mozilla.firefox" },
|
|
2426
|
-
OperaStable: { name: "Opera", id: "com.operasoftware.Opera" },
|
|
2427
|
-
VivaldiHTM: { name: "Vivaldi", id: "com.vivaldi.Vivaldi" },
|
|
2428
|
-
"IE.HTTP": { name: "Internet Explorer", id: "com.microsoft.ie" }
|
|
2429
|
-
};
|
|
2430
|
-
_windowsBrowserProgIdMap = new Map(Object.entries(windowsBrowserProgIds));
|
|
2431
|
-
UnknownBrowserError = class UnknownBrowserError extends Error {
|
|
2432
|
-
};
|
|
2433
|
-
});
|
|
2434
|
-
|
|
2435
|
-
// ../../node_modules/default-browser/index.js
|
|
2436
|
-
import { promisify as promisify6 } from "node:util";
|
|
2437
|
-
import process6 from "node:process";
|
|
2438
|
-
import { execFile as execFile6 } from "node:child_process";
|
|
2439
|
-
async function defaultBrowser2() {
|
|
2440
|
-
if (process6.platform === "darwin") {
|
|
2441
|
-
const id = await defaultBrowserId();
|
|
2442
|
-
const name = await bundleName(id);
|
|
2443
|
-
return { name, id };
|
|
2444
|
-
}
|
|
2445
|
-
if (process6.platform === "linux") {
|
|
2446
|
-
const { stdout } = await execFileAsync4("xdg-mime", ["query", "default", "x-scheme-handler/http"]);
|
|
2447
|
-
const id = stdout.trim();
|
|
2448
|
-
const name = titleize(id.replace(/.desktop$/, "").replace("-", " "));
|
|
2449
|
-
return { name, id };
|
|
2450
|
-
}
|
|
2451
|
-
if (process6.platform === "win32") {
|
|
2452
|
-
return defaultBrowser();
|
|
2453
|
-
}
|
|
2454
|
-
throw new Error("Only macOS, Linux, and Windows are supported");
|
|
2455
|
-
}
|
|
2456
|
-
var execFileAsync4, titleize = (string) => string.toLowerCase().replaceAll(/(?:^|\s|-)\S/g, (x) => x.toUpperCase());
|
|
2457
|
-
var init_default_browser = __esm(() => {
|
|
2458
|
-
init_default_browser_id();
|
|
2459
|
-
init_bundle_name();
|
|
2460
|
-
init_windows();
|
|
2461
|
-
init_windows();
|
|
2462
|
-
execFileAsync4 = promisify6(execFile6);
|
|
2463
|
-
});
|
|
2464
|
-
|
|
2465
|
-
// ../../node_modules/is-in-ssh/index.js
|
|
2466
|
-
import process7 from "node:process";
|
|
2467
|
-
var isInSsh, is_in_ssh_default;
|
|
2468
|
-
var init_is_in_ssh = __esm(() => {
|
|
2469
|
-
isInSsh = Boolean(process7.env.SSH_CONNECTION || process7.env.SSH_CLIENT || process7.env.SSH_TTY);
|
|
2470
|
-
is_in_ssh_default = isInSsh;
|
|
2471
|
-
});
|
|
2472
|
-
|
|
2473
|
-
// ../../node_modules/open/index.js
|
|
2474
|
-
import process8 from "node:process";
|
|
2475
|
-
import path from "node:path";
|
|
2476
|
-
import { fileURLToPath } from "node:url";
|
|
2477
|
-
import childProcess3 from "node:child_process";
|
|
2478
|
-
import fs5, { constants as fsConstants2 } from "node:fs/promises";
|
|
2479
|
-
function detectArchBinary(binary2) {
|
|
2480
|
-
if (typeof binary2 === "string" || Array.isArray(binary2)) {
|
|
2481
|
-
return binary2;
|
|
2482
|
-
}
|
|
2483
|
-
const { [arch]: archBinary } = binary2;
|
|
2484
|
-
if (!archBinary) {
|
|
2485
|
-
throw new Error(`${arch} is not supported`);
|
|
2486
|
-
}
|
|
2487
|
-
return archBinary;
|
|
2488
|
-
}
|
|
2489
|
-
function detectPlatformBinary({ [platform]: platformBinary }, { wsl } = {}) {
|
|
2490
|
-
if (wsl && is_wsl_default) {
|
|
2491
|
-
return detectArchBinary(wsl);
|
|
2492
|
-
}
|
|
2493
|
-
if (!platformBinary) {
|
|
2494
|
-
throw new Error(`${platform} is not supported`);
|
|
2495
|
-
}
|
|
2496
|
-
return detectArchBinary(platformBinary);
|
|
2497
|
-
}
|
|
2498
|
-
var fallbackAttemptSymbol, __dirname2, localXdgOpenPath, platform, arch, tryEachApp = async (apps, opener) => {
|
|
2499
|
-
if (apps.length === 0) {
|
|
2500
|
-
return;
|
|
2501
|
-
}
|
|
2502
|
-
const errors = [];
|
|
2503
|
-
for (const app of apps) {
|
|
2504
|
-
try {
|
|
2505
|
-
return await opener(app);
|
|
2506
|
-
} catch (error) {
|
|
2507
|
-
errors.push(error);
|
|
2508
|
-
}
|
|
2509
|
-
}
|
|
2510
|
-
throw new AggregateError(errors, "Failed to open in all supported apps");
|
|
2511
|
-
}, baseOpen = async (options) => {
|
|
2512
|
-
options = {
|
|
2513
|
-
wait: false,
|
|
2514
|
-
background: false,
|
|
2515
|
-
newInstance: false,
|
|
2516
|
-
allowNonzeroExitCode: false,
|
|
2517
|
-
...options
|
|
2518
|
-
};
|
|
2519
|
-
const isFallbackAttempt = options[fallbackAttemptSymbol] === true;
|
|
2520
|
-
delete options[fallbackAttemptSymbol];
|
|
2521
|
-
if (Array.isArray(options.app)) {
|
|
2522
|
-
return tryEachApp(options.app, (singleApp) => baseOpen({
|
|
2523
|
-
...options,
|
|
2524
|
-
app: singleApp,
|
|
2525
|
-
[fallbackAttemptSymbol]: true
|
|
2526
|
-
}));
|
|
2527
|
-
}
|
|
2528
|
-
let { name: app, arguments: appArguments = [] } = options.app ?? {};
|
|
2529
|
-
appArguments = [...appArguments];
|
|
2530
|
-
if (Array.isArray(app)) {
|
|
2531
|
-
return tryEachApp(app, (appName) => baseOpen({
|
|
2532
|
-
...options,
|
|
2533
|
-
app: {
|
|
2534
|
-
name: appName,
|
|
2535
|
-
arguments: appArguments
|
|
2536
|
-
},
|
|
2537
|
-
[fallbackAttemptSymbol]: true
|
|
2538
|
-
}));
|
|
2539
|
-
}
|
|
2540
|
-
if (app === "browser" || app === "browserPrivate") {
|
|
2541
|
-
const ids = {
|
|
2542
|
-
"com.google.chrome": "chrome",
|
|
2543
|
-
"google-chrome.desktop": "chrome",
|
|
2544
|
-
"com.brave.browser": "brave",
|
|
2545
|
-
"org.mozilla.firefox": "firefox",
|
|
2546
|
-
"firefox.desktop": "firefox",
|
|
2547
|
-
"com.microsoft.msedge": "edge",
|
|
2548
|
-
"com.microsoft.edge": "edge",
|
|
2549
|
-
"com.microsoft.edgemac": "edge",
|
|
2550
|
-
"microsoft-edge.desktop": "edge",
|
|
2551
|
-
"com.apple.safari": "safari"
|
|
2552
|
-
};
|
|
2553
|
-
const flags = {
|
|
2554
|
-
chrome: "--incognito",
|
|
2555
|
-
brave: "--incognito",
|
|
2556
|
-
firefox: "--private-window",
|
|
2557
|
-
edge: "--inPrivate"
|
|
2558
|
-
};
|
|
2559
|
-
let browser;
|
|
2560
|
-
if (is_wsl_default) {
|
|
2561
|
-
const progId = await wslDefaultBrowser();
|
|
2562
|
-
const browserInfo = _windowsBrowserProgIdMap.get(progId);
|
|
2563
|
-
browser = browserInfo ?? {};
|
|
2564
|
-
} else {
|
|
2565
|
-
browser = await defaultBrowser2();
|
|
2354
|
+
}
|
|
2355
|
+
});
|
|
2356
|
+
});
|
|
2566
2357
|
}
|
|
2567
|
-
|
|
2568
|
-
const
|
|
2569
|
-
|
|
2570
|
-
if (
|
|
2571
|
-
|
|
2358
|
+
_checkForConflictingLocalOptions() {
|
|
2359
|
+
const definedNonDefaultOptions = this.options.filter((option) => {
|
|
2360
|
+
const optionKey = option.attributeName();
|
|
2361
|
+
if (this.getOptionValue(optionKey) === undefined) {
|
|
2362
|
+
return false;
|
|
2572
2363
|
}
|
|
2573
|
-
|
|
2364
|
+
return this.getOptionValueSource(optionKey) !== "default";
|
|
2365
|
+
});
|
|
2366
|
+
const optionsWithConflicting = definedNonDefaultOptions.filter((option) => option.conflictsWith.length > 0);
|
|
2367
|
+
optionsWithConflicting.forEach((option) => {
|
|
2368
|
+
const conflictingAndDefined = definedNonDefaultOptions.find((defined) => option.conflictsWith.includes(defined.attributeName()));
|
|
2369
|
+
if (conflictingAndDefined) {
|
|
2370
|
+
this._conflictingOption(option, conflictingAndDefined);
|
|
2371
|
+
}
|
|
2372
|
+
});
|
|
2373
|
+
}
|
|
2374
|
+
_checkForConflictingOptions() {
|
|
2375
|
+
this._getCommandAndAncestors().forEach((cmd) => {
|
|
2376
|
+
cmd._checkForConflictingLocalOptions();
|
|
2377
|
+
});
|
|
2378
|
+
}
|
|
2379
|
+
parseOptions(args) {
|
|
2380
|
+
const operands = [];
|
|
2381
|
+
const unknown = [];
|
|
2382
|
+
let dest = operands;
|
|
2383
|
+
function maybeOption(arg) {
|
|
2384
|
+
return arg.length > 1 && arg[0] === "-";
|
|
2574
2385
|
}
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2386
|
+
const negativeNumberArg = (arg) => {
|
|
2387
|
+
if (!/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(arg))
|
|
2388
|
+
return false;
|
|
2389
|
+
return !this._getCommandAndAncestors().some((cmd) => cmd.options.map((opt) => opt.short).some((short) => /^-\d$/.test(short)));
|
|
2390
|
+
};
|
|
2391
|
+
let activeVariadicOption = null;
|
|
2392
|
+
let activeGroup = null;
|
|
2393
|
+
let i = 0;
|
|
2394
|
+
while (i < args.length || activeGroup) {
|
|
2395
|
+
const arg = activeGroup ?? args[i++];
|
|
2396
|
+
activeGroup = null;
|
|
2397
|
+
if (arg === "--") {
|
|
2398
|
+
if (dest === unknown)
|
|
2399
|
+
dest.push(arg);
|
|
2400
|
+
dest.push(...args.slice(i));
|
|
2401
|
+
break;
|
|
2402
|
+
}
|
|
2403
|
+
if (activeVariadicOption && (!maybeOption(arg) || negativeNumberArg(arg))) {
|
|
2404
|
+
this.emit(`option:${activeVariadicOption.name()}`, arg);
|
|
2405
|
+
continue;
|
|
2406
|
+
}
|
|
2407
|
+
activeVariadicOption = null;
|
|
2408
|
+
if (maybeOption(arg)) {
|
|
2409
|
+
const option = this._findOption(arg);
|
|
2410
|
+
if (option) {
|
|
2411
|
+
if (option.required) {
|
|
2412
|
+
const value = args[i++];
|
|
2413
|
+
if (value === undefined)
|
|
2414
|
+
this.optionMissingArgument(option);
|
|
2415
|
+
this.emit(`option:${option.name()}`, value);
|
|
2416
|
+
} else if (option.optional) {
|
|
2417
|
+
let value = null;
|
|
2418
|
+
if (i < args.length && (!maybeOption(args[i]) || negativeNumberArg(args[i]))) {
|
|
2419
|
+
value = args[i++];
|
|
2420
|
+
}
|
|
2421
|
+
this.emit(`option:${option.name()}`, value);
|
|
2422
|
+
} else {
|
|
2423
|
+
this.emit(`option:${option.name()}`);
|
|
2424
|
+
}
|
|
2425
|
+
activeVariadicOption = option.variadic ? option : null;
|
|
2426
|
+
continue;
|
|
2427
|
+
}
|
|
2428
|
+
}
|
|
2429
|
+
if (arg.length > 2 && arg[0] === "-" && arg[1] !== "-") {
|
|
2430
|
+
const option = this._findOption(`-${arg[1]}`);
|
|
2431
|
+
if (option) {
|
|
2432
|
+
if (option.required || option.optional && this._combineFlagAndOptionalValue) {
|
|
2433
|
+
this.emit(`option:${option.name()}`, arg.slice(2));
|
|
2434
|
+
} else {
|
|
2435
|
+
this.emit(`option:${option.name()}`);
|
|
2436
|
+
activeGroup = `-${arg.slice(2)}`;
|
|
2437
|
+
}
|
|
2438
|
+
continue;
|
|
2439
|
+
}
|
|
2440
|
+
}
|
|
2441
|
+
if (/^--[^=]+=/.test(arg)) {
|
|
2442
|
+
const index = arg.indexOf("=");
|
|
2443
|
+
const option = this._findOption(arg.slice(0, index));
|
|
2444
|
+
if (option && (option.required || option.optional)) {
|
|
2445
|
+
this.emit(`option:${option.name()}`, arg.slice(index + 1));
|
|
2446
|
+
continue;
|
|
2447
|
+
}
|
|
2448
|
+
}
|
|
2449
|
+
if (dest === operands && maybeOption(arg) && !(this.commands.length === 0 && negativeNumberArg(arg))) {
|
|
2450
|
+
dest = unknown;
|
|
2451
|
+
}
|
|
2452
|
+
if ((this._enablePositionalOptions || this._passThroughOptions) && operands.length === 0 && unknown.length === 0) {
|
|
2453
|
+
if (this._findCommand(arg)) {
|
|
2454
|
+
operands.push(arg);
|
|
2455
|
+
unknown.push(...args.slice(i));
|
|
2456
|
+
break;
|
|
2457
|
+
} else if (this._getHelpCommand() && arg === this._getHelpCommand().name()) {
|
|
2458
|
+
operands.push(arg, ...args.slice(i));
|
|
2459
|
+
break;
|
|
2460
|
+
} else if (this._defaultCommandName) {
|
|
2461
|
+
unknown.push(arg, ...args.slice(i));
|
|
2462
|
+
break;
|
|
2463
|
+
}
|
|
2464
|
+
}
|
|
2465
|
+
if (this._passThroughOptions) {
|
|
2466
|
+
dest.push(arg, ...args.slice(i));
|
|
2467
|
+
break;
|
|
2468
|
+
}
|
|
2469
|
+
dest.push(arg);
|
|
2470
|
+
}
|
|
2471
|
+
return { operands, unknown };
|
|
2472
|
+
}
|
|
2473
|
+
opts() {
|
|
2474
|
+
if (this._storeOptionsAsProperties) {
|
|
2475
|
+
const result = {};
|
|
2476
|
+
const len = this.options.length;
|
|
2477
|
+
for (let i = 0;i < len; i++) {
|
|
2478
|
+
const key = this.options[i].attributeName();
|
|
2479
|
+
result[key] = key === this._versionOptionName ? this._version : this[key];
|
|
2480
|
+
}
|
|
2481
|
+
return result;
|
|
2482
|
+
}
|
|
2483
|
+
return this._optionValues;
|
|
2484
|
+
}
|
|
2485
|
+
optsWithGlobals() {
|
|
2486
|
+
return this._getCommandAndAncestors().reduce((combinedOptions, cmd) => Object.assign(combinedOptions, cmd.opts()), {});
|
|
2487
|
+
}
|
|
2488
|
+
error(message, errorOptions) {
|
|
2489
|
+
this._outputConfiguration.outputError(`${message}
|
|
2490
|
+
`, this._outputConfiguration.writeErr);
|
|
2491
|
+
if (typeof this._showHelpAfterError === "string") {
|
|
2492
|
+
this._outputConfiguration.writeErr(`${this._showHelpAfterError}
|
|
2493
|
+
`);
|
|
2494
|
+
} else if (this._showHelpAfterError) {
|
|
2495
|
+
this._outputConfiguration.writeErr(`
|
|
2496
|
+
`);
|
|
2497
|
+
this.outputHelp({ error: true });
|
|
2498
|
+
}
|
|
2499
|
+
const config = errorOptions || {};
|
|
2500
|
+
const exitCode = config.exitCode || 1;
|
|
2501
|
+
const code = config.code || "commander.error";
|
|
2502
|
+
this._exit(exitCode, code, message);
|
|
2503
|
+
}
|
|
2504
|
+
_parseOptionsEnv() {
|
|
2505
|
+
this.options.forEach((option) => {
|
|
2506
|
+
if (option.envVar && option.envVar in process9.env) {
|
|
2507
|
+
const optionKey = option.attributeName();
|
|
2508
|
+
if (this.getOptionValue(optionKey) === undefined || ["default", "config", "env"].includes(this.getOptionValueSource(optionKey))) {
|
|
2509
|
+
if (option.required || option.optional) {
|
|
2510
|
+
this.emit(`optionEnv:${option.name()}`, process9.env[option.envVar]);
|
|
2511
|
+
} else {
|
|
2512
|
+
this.emit(`optionEnv:${option.name()}`);
|
|
2513
|
+
}
|
|
2514
|
+
}
|
|
2580
2515
|
}
|
|
2581
2516
|
});
|
|
2582
2517
|
}
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
command = "open";
|
|
2594
|
-
if (options.wait) {
|
|
2595
|
-
cliArguments.push("--wait-apps");
|
|
2518
|
+
_parseOptionsImplied() {
|
|
2519
|
+
const dualHelper = new DualOptions(this.options);
|
|
2520
|
+
const hasCustomOptionValue = (optionKey) => {
|
|
2521
|
+
return this.getOptionValue(optionKey) !== undefined && !["default", "implied"].includes(this.getOptionValueSource(optionKey));
|
|
2522
|
+
};
|
|
2523
|
+
this.options.filter((option) => option.implied !== undefined && hasCustomOptionValue(option.attributeName()) && dualHelper.valueFromOption(this.getOptionValue(option.attributeName()), option)).forEach((option) => {
|
|
2524
|
+
Object.keys(option.implied).filter((impliedKey) => !hasCustomOptionValue(impliedKey)).forEach((impliedKey) => {
|
|
2525
|
+
this.setOptionValueWithSource(impliedKey, option.implied[impliedKey], "implied");
|
|
2526
|
+
});
|
|
2527
|
+
});
|
|
2596
2528
|
}
|
|
2597
|
-
|
|
2598
|
-
|
|
2529
|
+
missingArgument(name) {
|
|
2530
|
+
const message = `error: missing required argument '${name}'`;
|
|
2531
|
+
this.error(message, { code: "commander.missingArgument" });
|
|
2599
2532
|
}
|
|
2600
|
-
|
|
2601
|
-
|
|
2533
|
+
optionMissingArgument(option) {
|
|
2534
|
+
const message = `error: option '${option.flags}' argument missing`;
|
|
2535
|
+
this.error(message, { code: "commander.optionMissingArgument" });
|
|
2602
2536
|
}
|
|
2603
|
-
|
|
2604
|
-
|
|
2537
|
+
missingMandatoryOptionValue(option) {
|
|
2538
|
+
const message = `error: required option '${option.flags}' not specified`;
|
|
2539
|
+
this.error(message, { code: "commander.missingMandatoryOptionValue" });
|
|
2605
2540
|
}
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2541
|
+
_conflictingOption(option, conflictingOption) {
|
|
2542
|
+
const findBestOptionFromValue = (option2) => {
|
|
2543
|
+
const optionKey = option2.attributeName();
|
|
2544
|
+
const optionValue = this.getOptionValue(optionKey);
|
|
2545
|
+
const negativeOption = this.options.find((target) => target.negate && optionKey === target.attributeName());
|
|
2546
|
+
const positiveOption = this.options.find((target) => !target.negate && optionKey === target.attributeName());
|
|
2547
|
+
if (negativeOption && (negativeOption.presetArg === undefined && optionValue === false || negativeOption.presetArg !== undefined && optionValue === negativeOption.presetArg)) {
|
|
2548
|
+
return negativeOption;
|
|
2549
|
+
}
|
|
2550
|
+
return positiveOption || option2;
|
|
2551
|
+
};
|
|
2552
|
+
const getErrorMessage = (option2) => {
|
|
2553
|
+
const bestOption = findBestOptionFromValue(option2);
|
|
2554
|
+
const optionKey = bestOption.attributeName();
|
|
2555
|
+
const source = this.getOptionValueSource(optionKey);
|
|
2556
|
+
if (source === "env") {
|
|
2557
|
+
return `environment variable '${bestOption.envVar}'`;
|
|
2558
|
+
}
|
|
2559
|
+
return `option '${bestOption.flags}'`;
|
|
2560
|
+
};
|
|
2561
|
+
const message = `error: ${getErrorMessage(option)} cannot be used with ${getErrorMessage(conflictingOption)}`;
|
|
2562
|
+
this.error(message, { code: "commander.conflictingOption" });
|
|
2611
2563
|
}
|
|
2612
|
-
|
|
2613
|
-
|
|
2564
|
+
unknownOption(flag) {
|
|
2565
|
+
if (this._allowUnknownOption)
|
|
2566
|
+
return;
|
|
2567
|
+
let suggestion = "";
|
|
2568
|
+
if (flag.startsWith("--") && this._showSuggestionAfterError) {
|
|
2569
|
+
let candidateFlags = [];
|
|
2570
|
+
let command = this;
|
|
2571
|
+
do {
|
|
2572
|
+
const moreFlags = command.createHelp().visibleOptions(command).filter((option) => option.long).map((option) => option.long);
|
|
2573
|
+
candidateFlags = candidateFlags.concat(moreFlags);
|
|
2574
|
+
command = command.parent;
|
|
2575
|
+
} while (command && !command._enablePositionalOptions);
|
|
2576
|
+
suggestion = suggestSimilar(flag, candidateFlags);
|
|
2577
|
+
}
|
|
2578
|
+
const message = `error: unknown option '${flag}'${suggestion}`;
|
|
2579
|
+
this.error(message, { code: "commander.unknownOption" });
|
|
2614
2580
|
}
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2581
|
+
_excessArguments(receivedArgs) {
|
|
2582
|
+
if (this._allowExcessArguments)
|
|
2583
|
+
return;
|
|
2584
|
+
const expected = this.registeredArguments.length;
|
|
2585
|
+
const s = expected === 1 ? "" : "s";
|
|
2586
|
+
const forSubcommand = this.parent ? ` for '${this.name()}'` : "";
|
|
2587
|
+
const message = `error: too many arguments${forSubcommand}. Expected ${expected} argument${s} but got ${receivedArgs.length}.`;
|
|
2588
|
+
this.error(message, { code: "commander.excessArguments" });
|
|
2618
2589
|
}
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2590
|
+
unknownCommand() {
|
|
2591
|
+
const unknownName = this.args[0];
|
|
2592
|
+
let suggestion = "";
|
|
2593
|
+
if (this._showSuggestionAfterError) {
|
|
2594
|
+
const candidateNames = [];
|
|
2595
|
+
this.createHelp().visibleCommands(this).forEach((command) => {
|
|
2596
|
+
candidateNames.push(command.name());
|
|
2597
|
+
if (command.alias())
|
|
2598
|
+
candidateNames.push(command.alias());
|
|
2599
|
+
});
|
|
2600
|
+
suggestion = suggestSimilar(unknownName, candidateNames);
|
|
2623
2601
|
}
|
|
2624
|
-
|
|
2625
|
-
|
|
2602
|
+
const message = `error: unknown command '${unknownName}'${suggestion}`;
|
|
2603
|
+
this.error(message, { code: "commander.unknownCommand" });
|
|
2626
2604
|
}
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2605
|
+
version(str, flags, description) {
|
|
2606
|
+
if (str === undefined)
|
|
2607
|
+
return this._version;
|
|
2608
|
+
this._version = str;
|
|
2609
|
+
flags = flags || "-V, --version";
|
|
2610
|
+
description = description || "output the version number";
|
|
2611
|
+
const versionOption = this.createOption(flags, description);
|
|
2612
|
+
this._versionOptionName = versionOption.attributeName();
|
|
2613
|
+
this._registerOption(versionOption);
|
|
2614
|
+
this.on("option:" + versionOption.name(), () => {
|
|
2615
|
+
this._outputConfiguration.writeOut(`${str}
|
|
2616
|
+
`);
|
|
2617
|
+
this._exit(0, "commander.version", str);
|
|
2618
|
+
});
|
|
2619
|
+
return this;
|
|
2630
2620
|
}
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2621
|
+
description(str, argsDescription) {
|
|
2622
|
+
if (str === undefined && argsDescription === undefined)
|
|
2623
|
+
return this._description;
|
|
2624
|
+
this._description = str;
|
|
2625
|
+
if (argsDescription) {
|
|
2626
|
+
this._argsDescription = argsDescription;
|
|
2627
|
+
}
|
|
2628
|
+
return this;
|
|
2634
2629
|
}
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
let exeLocalXdgOpen = false;
|
|
2641
|
-
try {
|
|
2642
|
-
await fs5.access(localXdgOpenPath, fsConstants2.X_OK);
|
|
2643
|
-
exeLocalXdgOpen = true;
|
|
2644
|
-
} catch {}
|
|
2645
|
-
const useSystemXdgOpen = process8.versions.electron ?? (platform === "android" || isBundled || !exeLocalXdgOpen);
|
|
2646
|
-
command = useSystemXdgOpen ? "xdg-open" : localXdgOpenPath;
|
|
2630
|
+
summary(str) {
|
|
2631
|
+
if (str === undefined)
|
|
2632
|
+
return this._summary;
|
|
2633
|
+
this._summary = str;
|
|
2634
|
+
return this;
|
|
2647
2635
|
}
|
|
2648
|
-
|
|
2649
|
-
|
|
2636
|
+
alias(alias) {
|
|
2637
|
+
if (alias === undefined)
|
|
2638
|
+
return this._aliases[0];
|
|
2639
|
+
let command = this;
|
|
2640
|
+
if (this.commands.length !== 0 && this.commands[this.commands.length - 1]._executableHandler) {
|
|
2641
|
+
command = this.commands[this.commands.length - 1];
|
|
2642
|
+
}
|
|
2643
|
+
if (alias === command._name)
|
|
2644
|
+
throw new Error("Command alias can't be the same as its name");
|
|
2645
|
+
const matchingCommand = this.parent?._findCommand(alias);
|
|
2646
|
+
if (matchingCommand) {
|
|
2647
|
+
const existingCmd = [matchingCommand.name()].concat(matchingCommand.aliases()).join("|");
|
|
2648
|
+
throw new Error(`cannot add alias '${alias}' to command '${this.name()}' as already have command '${existingCmd}'`);
|
|
2649
|
+
}
|
|
2650
|
+
command._aliases.push(alias);
|
|
2651
|
+
return this;
|
|
2650
2652
|
}
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2653
|
+
aliases(aliases) {
|
|
2654
|
+
if (aliases === undefined)
|
|
2655
|
+
return this._aliases;
|
|
2656
|
+
aliases.forEach((alias) => this.alias(alias));
|
|
2657
|
+
return this;
|
|
2654
2658
|
}
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
}
|
|
2662
|
-
const subprocess = childProcess3.spawn(command, cliArguments, childProcessOptions);
|
|
2663
|
-
if (options.wait) {
|
|
2664
|
-
return new Promise((resolve, reject) => {
|
|
2665
|
-
subprocess.once("error", reject);
|
|
2666
|
-
subprocess.once("close", (exitCode) => {
|
|
2667
|
-
if (!options.allowNonzeroExitCode && exitCode !== 0) {
|
|
2668
|
-
reject(new Error(`Exited with code ${exitCode}`));
|
|
2669
|
-
return;
|
|
2670
|
-
}
|
|
2671
|
-
resolve(subprocess);
|
|
2672
|
-
});
|
|
2673
|
-
});
|
|
2674
|
-
}
|
|
2675
|
-
if (isFallbackAttempt) {
|
|
2676
|
-
return new Promise((resolve, reject) => {
|
|
2677
|
-
subprocess.once("error", reject);
|
|
2678
|
-
subprocess.once("spawn", () => {
|
|
2679
|
-
subprocess.once("close", (exitCode) => {
|
|
2680
|
-
subprocess.off("error", reject);
|
|
2681
|
-
if (exitCode !== 0) {
|
|
2682
|
-
reject(new Error(`Exited with code ${exitCode}`));
|
|
2683
|
-
return;
|
|
2684
|
-
}
|
|
2685
|
-
subprocess.unref();
|
|
2686
|
-
resolve(subprocess);
|
|
2659
|
+
usage(str) {
|
|
2660
|
+
if (str === undefined) {
|
|
2661
|
+
if (this._usage)
|
|
2662
|
+
return this._usage;
|
|
2663
|
+
const args = this.registeredArguments.map((arg) => {
|
|
2664
|
+
return humanReadableArgName(arg);
|
|
2687
2665
|
});
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
return new Promise((resolve, reject) => {
|
|
2693
|
-
subprocess.once("error", reject);
|
|
2694
|
-
subprocess.once("spawn", () => {
|
|
2695
|
-
subprocess.off("error", reject);
|
|
2696
|
-
resolve(subprocess);
|
|
2697
|
-
});
|
|
2698
|
-
});
|
|
2699
|
-
}, open = (target, options) => {
|
|
2700
|
-
if (typeof target !== "string") {
|
|
2701
|
-
throw new TypeError("Expected a `target`");
|
|
2702
|
-
}
|
|
2703
|
-
return baseOpen({
|
|
2704
|
-
...options,
|
|
2705
|
-
target
|
|
2706
|
-
});
|
|
2707
|
-
}, apps, open_default;
|
|
2708
|
-
var init_open = __esm(() => {
|
|
2709
|
-
init_wsl_utils();
|
|
2710
|
-
init_powershell_utils();
|
|
2711
|
-
init_default_browser();
|
|
2712
|
-
init_is_inside_container();
|
|
2713
|
-
init_is_in_ssh();
|
|
2714
|
-
fallbackAttemptSymbol = Symbol("fallbackAttempt");
|
|
2715
|
-
__dirname2 = import.meta.url ? path.dirname(fileURLToPath(import.meta.url)) : "";
|
|
2716
|
-
localXdgOpenPath = path.join(__dirname2, "xdg-open");
|
|
2717
|
-
({ platform, arch } = process8);
|
|
2718
|
-
apps = {
|
|
2719
|
-
browser: "browser",
|
|
2720
|
-
browserPrivate: "browserPrivate"
|
|
2721
|
-
};
|
|
2722
|
-
defineLazyProperty(apps, "chrome", () => detectPlatformBinary({
|
|
2723
|
-
darwin: "google chrome",
|
|
2724
|
-
win32: "chrome",
|
|
2725
|
-
linux: ["google-chrome", "google-chrome-stable", "chromium", "chromium-browser"]
|
|
2726
|
-
}, {
|
|
2727
|
-
wsl: {
|
|
2728
|
-
ia32: "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe",
|
|
2729
|
-
x64: ["/mnt/c/Program Files/Google/Chrome/Application/chrome.exe", "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"]
|
|
2666
|
+
return [].concat(this.options.length || this._helpOption !== null ? "[options]" : [], this.commands.length ? "[command]" : [], this.registeredArguments.length ? args : []).join(" ");
|
|
2667
|
+
}
|
|
2668
|
+
this._usage = str;
|
|
2669
|
+
return this;
|
|
2730
2670
|
}
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
}, {
|
|
2737
|
-
wsl: {
|
|
2738
|
-
ia32: "/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe",
|
|
2739
|
-
x64: ["/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe", "/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe"]
|
|
2671
|
+
name(str) {
|
|
2672
|
+
if (str === undefined)
|
|
2673
|
+
return this._name;
|
|
2674
|
+
this._name = str;
|
|
2675
|
+
return this;
|
|
2740
2676
|
}
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
}));
|
|
2759
|
-
open_default = open;
|
|
2760
|
-
});
|
|
2761
|
-
|
|
2762
|
-
// ../filesystem/src/node.ts
|
|
2763
|
-
import { existsSync } from "node:fs";
|
|
2764
|
-
import * as fs6 from "node:fs/promises";
|
|
2765
|
-
import * as os2 from "node:os";
|
|
2766
|
-
import * as path2 from "node:path";
|
|
2767
|
-
|
|
2768
|
-
class NodeFileSystem {
|
|
2769
|
-
path = {
|
|
2770
|
-
join: path2.join,
|
|
2771
|
-
resolve: path2.resolve,
|
|
2772
|
-
relative: path2.relative,
|
|
2773
|
-
dirname: path2.dirname,
|
|
2774
|
-
isAbsolute: path2.isAbsolute,
|
|
2775
|
-
basename: path2.basename
|
|
2776
|
-
};
|
|
2777
|
-
env = {
|
|
2778
|
-
cwd: process.cwd,
|
|
2779
|
-
homedir: os2.homedir,
|
|
2780
|
-
tmpdir: os2.tmpdir,
|
|
2781
|
-
getenv: (key) => process.env[key]
|
|
2782
|
-
};
|
|
2783
|
-
utils = {
|
|
2784
|
-
open: async (url) => {
|
|
2785
|
-
await open_default(url);
|
|
2677
|
+
helpGroup(heading) {
|
|
2678
|
+
if (heading === undefined)
|
|
2679
|
+
return this._helpGroupHeading ?? "";
|
|
2680
|
+
this._helpGroupHeading = heading;
|
|
2681
|
+
return this;
|
|
2682
|
+
}
|
|
2683
|
+
commandsGroup(heading) {
|
|
2684
|
+
if (heading === undefined)
|
|
2685
|
+
return this._defaultCommandGroup ?? "";
|
|
2686
|
+
this._defaultCommandGroup = heading;
|
|
2687
|
+
return this;
|
|
2688
|
+
}
|
|
2689
|
+
optionsGroup(heading) {
|
|
2690
|
+
if (heading === undefined)
|
|
2691
|
+
return this._defaultOptionGroup ?? "";
|
|
2692
|
+
this._defaultOptionGroup = heading;
|
|
2693
|
+
return this;
|
|
2786
2694
|
}
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
if (options) {
|
|
2791
|
-
return await fs6.readFile(path3, "utf-8");
|
|
2792
|
-
}
|
|
2793
|
-
return await fs6.readFile(path3);
|
|
2794
|
-
} catch (error) {
|
|
2795
|
-
if (this.isEnoent(error))
|
|
2796
|
-
return null;
|
|
2797
|
-
throw error;
|
|
2695
|
+
_initOptionGroup(option) {
|
|
2696
|
+
if (this._defaultOptionGroup && !option.helpGroupHeading)
|
|
2697
|
+
option.helpGroup(this._defaultOptionGroup);
|
|
2798
2698
|
}
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
if (dir) {
|
|
2803
|
-
await fs6.mkdir(dir, { recursive: true });
|
|
2699
|
+
_initCommandGroup(cmd) {
|
|
2700
|
+
if (this._defaultCommandGroup && !cmd.helpGroup())
|
|
2701
|
+
cmd.helpGroup(this._defaultCommandGroup);
|
|
2804
2702
|
}
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
const dir = path2.dirname(filePath);
|
|
2809
|
-
if (dir) {
|
|
2810
|
-
await fs6.mkdir(dir, { recursive: true });
|
|
2703
|
+
nameFromFilename(filename) {
|
|
2704
|
+
this._name = path3.basename(filename, path3.extname(filename));
|
|
2705
|
+
return this;
|
|
2811
2706
|
}
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
return
|
|
2817
|
-
} catch (error) {
|
|
2818
|
-
if (this.isEnoent(error))
|
|
2819
|
-
return [];
|
|
2820
|
-
throw error;
|
|
2707
|
+
executableDir(path4) {
|
|
2708
|
+
if (path4 === undefined)
|
|
2709
|
+
return this._executableDir;
|
|
2710
|
+
this._executableDir = path4;
|
|
2711
|
+
return this;
|
|
2821
2712
|
}
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2713
|
+
helpInformation(contextOptions) {
|
|
2714
|
+
const helper = this.createHelp();
|
|
2715
|
+
const context = this._getOutputContext(contextOptions);
|
|
2716
|
+
helper.prepareContext({
|
|
2717
|
+
error: context.error,
|
|
2718
|
+
helpWidth: context.helpWidth,
|
|
2719
|
+
outputHasColors: context.hasColors
|
|
2720
|
+
});
|
|
2721
|
+
const text = helper.formatHelp(this, helper);
|
|
2722
|
+
if (context.hasColors)
|
|
2723
|
+
return text;
|
|
2724
|
+
return this._outputConfiguration.stripColor(text);
|
|
2725
|
+
}
|
|
2726
|
+
_getOutputContext(contextOptions) {
|
|
2727
|
+
contextOptions = contextOptions || {};
|
|
2728
|
+
const error = !!contextOptions.error;
|
|
2729
|
+
let baseWrite;
|
|
2730
|
+
let hasColors;
|
|
2731
|
+
let helpWidth;
|
|
2732
|
+
if (error) {
|
|
2733
|
+
baseWrite = (str) => this._outputConfiguration.writeErr(str);
|
|
2734
|
+
hasColors = this._outputConfiguration.getErrHasColors();
|
|
2735
|
+
helpWidth = this._outputConfiguration.getErrHelpWidth();
|
|
2736
|
+
} else {
|
|
2737
|
+
baseWrite = (str) => this._outputConfiguration.writeOut(str);
|
|
2738
|
+
hasColors = this._outputConfiguration.getOutHasColors();
|
|
2739
|
+
helpWidth = this._outputConfiguration.getOutHelpWidth();
|
|
2740
|
+
}
|
|
2741
|
+
const write = (str) => {
|
|
2742
|
+
if (!hasColors)
|
|
2743
|
+
str = this._outputConfiguration.stripColor(str);
|
|
2744
|
+
return baseWrite(str);
|
|
2831
2745
|
};
|
|
2832
|
-
|
|
2833
|
-
if (this.isEnoent(error))
|
|
2834
|
-
return null;
|
|
2835
|
-
throw error;
|
|
2746
|
+
return { error, write, hasColors, helpWidth };
|
|
2836
2747
|
}
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
|
|
2748
|
+
outputHelp(contextOptions) {
|
|
2749
|
+
let deprecatedCallback;
|
|
2750
|
+
if (typeof contextOptions === "function") {
|
|
2751
|
+
deprecatedCallback = contextOptions;
|
|
2752
|
+
contextOptions = undefined;
|
|
2753
|
+
}
|
|
2754
|
+
const outputContext = this._getOutputContext(contextOptions);
|
|
2755
|
+
const eventContext = {
|
|
2756
|
+
error: outputContext.error,
|
|
2757
|
+
write: outputContext.write,
|
|
2758
|
+
command: this
|
|
2759
|
+
};
|
|
2760
|
+
this._getCommandAndAncestors().reverse().forEach((command) => command.emit("beforeAllHelp", eventContext));
|
|
2761
|
+
this.emit("beforeHelp", eventContext);
|
|
2762
|
+
let helpInformation = this.helpInformation({ error: outputContext.error });
|
|
2763
|
+
if (deprecatedCallback) {
|
|
2764
|
+
helpInformation = deprecatedCallback(helpInformation);
|
|
2765
|
+
if (typeof helpInformation !== "string" && !Buffer.isBuffer(helpInformation)) {
|
|
2766
|
+
throw new Error("outputHelp callback must return a string or a Buffer");
|
|
2767
|
+
}
|
|
2768
|
+
}
|
|
2769
|
+
outputContext.write(helpInformation);
|
|
2770
|
+
if (this._getHelpOption()?.long) {
|
|
2771
|
+
this.emit(this._getHelpOption().long);
|
|
2772
|
+
}
|
|
2773
|
+
this.emit("afterHelp", eventContext);
|
|
2774
|
+
this._getCommandAndAncestors().forEach((command) => command.emit("afterAllHelp", eventContext));
|
|
2857
2775
|
}
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
|
|
2776
|
+
helpOption(flags, description) {
|
|
2777
|
+
if (typeof flags === "boolean") {
|
|
2778
|
+
if (flags) {
|
|
2779
|
+
if (this._helpOption === null)
|
|
2780
|
+
this._helpOption = undefined;
|
|
2781
|
+
if (this._defaultOptionGroup) {
|
|
2782
|
+
this._initOptionGroup(this._getHelpOption());
|
|
2783
|
+
}
|
|
2784
|
+
} else {
|
|
2785
|
+
this._helpOption = null;
|
|
2786
|
+
}
|
|
2787
|
+
return this;
|
|
2788
|
+
}
|
|
2789
|
+
this._helpOption = this.createOption(flags ?? "-h, --help", description ?? "display help for command");
|
|
2790
|
+
if (flags || description)
|
|
2791
|
+
this._initOptionGroup(this._helpOption);
|
|
2792
|
+
return this;
|
|
2866
2793
|
}
|
|
2867
|
-
|
|
2868
|
-
|
|
2794
|
+
_getHelpOption() {
|
|
2795
|
+
if (this._helpOption === undefined) {
|
|
2796
|
+
this.helpOption(undefined, undefined);
|
|
2797
|
+
}
|
|
2798
|
+
return this._helpOption;
|
|
2869
2799
|
}
|
|
2870
|
-
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
if (
|
|
2879
|
-
|
|
2880
|
-
}
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2800
|
+
addHelpOption(option) {
|
|
2801
|
+
this._helpOption = option;
|
|
2802
|
+
this._initOptionGroup(option);
|
|
2803
|
+
return this;
|
|
2804
|
+
}
|
|
2805
|
+
help(contextOptions) {
|
|
2806
|
+
this.outputHelp(contextOptions);
|
|
2807
|
+
let exitCode = Number(process9.exitCode ?? 0);
|
|
2808
|
+
if (exitCode === 0 && contextOptions && typeof contextOptions !== "function" && contextOptions.error) {
|
|
2809
|
+
exitCode = 1;
|
|
2810
|
+
}
|
|
2811
|
+
this._exit(exitCode, "commander.help", "(outputHelp)");
|
|
2812
|
+
}
|
|
2813
|
+
addHelpText(position, text) {
|
|
2814
|
+
const allowedValues = ["beforeAll", "before", "after", "afterAll"];
|
|
2815
|
+
if (!allowedValues.includes(position)) {
|
|
2816
|
+
throw new Error(`Unexpected value for position to addHelpText.
|
|
2817
|
+
Expecting one of '${allowedValues.join("', '")}'`);
|
|
2818
|
+
}
|
|
2819
|
+
const helpEvent = `${position}Help`;
|
|
2820
|
+
this.on(helpEvent, (context) => {
|
|
2821
|
+
let helpStr;
|
|
2822
|
+
if (typeof text === "function") {
|
|
2823
|
+
helpStr = text({ error: context.error, command: context.command });
|
|
2824
|
+
} else {
|
|
2825
|
+
helpStr = text;
|
|
2826
|
+
}
|
|
2827
|
+
if (helpStr) {
|
|
2828
|
+
context.write(`${helpStr}
|
|
2829
|
+
`);
|
|
2884
2830
|
}
|
|
2831
|
+
});
|
|
2832
|
+
return this;
|
|
2833
|
+
}
|
|
2834
|
+
_outputHelpIfRequested(args) {
|
|
2835
|
+
const helpOption = this._getHelpOption();
|
|
2836
|
+
const helpRequested = helpOption && args.find((arg) => helpOption.is(arg));
|
|
2837
|
+
if (helpRequested) {
|
|
2838
|
+
this.outputHelp();
|
|
2839
|
+
this._exit(0, "commander.helpDisplayed", "(outputHelp)");
|
|
2885
2840
|
}
|
|
2886
2841
|
}
|
|
2887
2842
|
}
|
|
2888
|
-
|
|
2889
|
-
return
|
|
2843
|
+
function incrementNodeInspectorPort(args) {
|
|
2844
|
+
return args.map((arg) => {
|
|
2845
|
+
if (!arg.startsWith("--inspect")) {
|
|
2846
|
+
return arg;
|
|
2847
|
+
}
|
|
2848
|
+
let debugOption;
|
|
2849
|
+
let debugHost = "127.0.0.1";
|
|
2850
|
+
let debugPort = "9229";
|
|
2851
|
+
let match;
|
|
2852
|
+
if ((match = arg.match(/^(--inspect(-brk)?)$/)) !== null) {
|
|
2853
|
+
debugOption = match[1];
|
|
2854
|
+
} else if ((match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+)$/)) !== null) {
|
|
2855
|
+
debugOption = match[1];
|
|
2856
|
+
if (/^\d+$/.test(match[3])) {
|
|
2857
|
+
debugPort = match[3];
|
|
2858
|
+
} else {
|
|
2859
|
+
debugHost = match[3];
|
|
2860
|
+
}
|
|
2861
|
+
} else if ((match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/)) !== null) {
|
|
2862
|
+
debugOption = match[1];
|
|
2863
|
+
debugHost = match[3];
|
|
2864
|
+
debugPort = match[4];
|
|
2865
|
+
}
|
|
2866
|
+
if (debugOption && debugPort !== "0") {
|
|
2867
|
+
return `${debugOption}=${debugHost}:${parseInt(debugPort) + 1}`;
|
|
2868
|
+
}
|
|
2869
|
+
return arg;
|
|
2870
|
+
});
|
|
2890
2871
|
}
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
|
|
2872
|
+
function useColor() {
|
|
2873
|
+
if (process9.env.NO_COLOR || process9.env.FORCE_COLOR === "0" || process9.env.FORCE_COLOR === "false")
|
|
2874
|
+
return false;
|
|
2875
|
+
if (process9.env.FORCE_COLOR || process9.env.CLICOLOR_FORCE !== undefined)
|
|
2876
|
+
return true;
|
|
2877
|
+
return;
|
|
2878
|
+
}
|
|
2879
|
+
exports.Command = Command;
|
|
2880
|
+
exports.useColor = useColor;
|
|
2894
2881
|
});
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
};
|
|
2899
|
-
var
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2882
|
+
|
|
2883
|
+
// ../../node_modules/commander/index.js
|
|
2884
|
+
var require_commander = __commonJS((exports) => {
|
|
2885
|
+
var { Argument } = require_argument();
|
|
2886
|
+
var { Command } = require_command();
|
|
2887
|
+
var { CommanderError, InvalidArgumentError } = require_error();
|
|
2888
|
+
var { Help } = require_help();
|
|
2889
|
+
var { Option } = require_option();
|
|
2890
|
+
exports.program = new Command;
|
|
2891
|
+
exports.createCommand = (name) => new Command(name);
|
|
2892
|
+
exports.createOption = (flags, description) => new Option(flags, description);
|
|
2893
|
+
exports.createArgument = (name, description) => new Argument(name, description);
|
|
2894
|
+
exports.Command = Command;
|
|
2895
|
+
exports.Option = Option;
|
|
2896
|
+
exports.Argument = Argument;
|
|
2897
|
+
exports.Help = Help;
|
|
2898
|
+
exports.CommanderError = CommanderError;
|
|
2899
|
+
exports.InvalidArgumentError = InvalidArgumentError;
|
|
2900
|
+
exports.InvalidOptionArgumentError = InvalidArgumentError;
|
|
2903
2901
|
});
|
|
2904
2902
|
|
|
2905
2903
|
// ../auth/src/catch-error.ts
|
|
@@ -27071,7 +27069,7 @@ var require_src6 = __commonJS((exports) => {
|
|
|
27071
27069
|
// package.json
|
|
27072
27070
|
var package_default = {
|
|
27073
27071
|
name: "@uipath/tasks-tool",
|
|
27074
|
-
version: "1.0
|
|
27072
|
+
version: "1.1.0",
|
|
27075
27073
|
description: "Manage Action Center tasks.",
|
|
27076
27074
|
type: "module",
|
|
27077
27075
|
main: "./dist/tool.js",
|
|
@@ -27098,6 +27096,9 @@ var package_default = {
|
|
|
27098
27096
|
}
|
|
27099
27097
|
};
|
|
27100
27098
|
|
|
27099
|
+
// ../common/src/attachment-binding.ts
|
|
27100
|
+
init_src();
|
|
27101
|
+
|
|
27101
27102
|
// ../common/src/catch-error.ts
|
|
27102
27103
|
function isPromiseLike(value) {
|
|
27103
27104
|
return value !== null && typeof value === "object" && typeof value.then === "function";
|
|
@@ -27125,94 +27126,7 @@ function settlePromiseLike(thenable) {
|
|
|
27125
27126
|
undefined
|
|
27126
27127
|
]);
|
|
27127
27128
|
}
|
|
27128
|
-
// ../../node_modules/commander/esm.mjs
|
|
27129
|
-
var import__ = __toESM(require_commander(), 1);
|
|
27130
|
-
var {
|
|
27131
|
-
program,
|
|
27132
|
-
createCommand,
|
|
27133
|
-
createArgument,
|
|
27134
|
-
createOption,
|
|
27135
|
-
CommanderError,
|
|
27136
|
-
InvalidArgumentError,
|
|
27137
|
-
InvalidOptionArgumentError,
|
|
27138
|
-
Command,
|
|
27139
|
-
Argument,
|
|
27140
|
-
Option,
|
|
27141
|
-
Help
|
|
27142
|
-
} = import__.default;
|
|
27143
|
-
|
|
27144
|
-
// ../common/src/command-examples.ts
|
|
27145
|
-
var examplesByCommand = new WeakMap;
|
|
27146
|
-
Command.prototype.examples = function(examples) {
|
|
27147
|
-
examplesByCommand.set(this, examples);
|
|
27148
|
-
return this;
|
|
27149
|
-
};
|
|
27150
|
-
// ../common/src/singleton.ts
|
|
27151
|
-
var PREFIX = "@uipath/common/";
|
|
27152
|
-
var _g = globalThis;
|
|
27153
|
-
function singleton(ctorOrName) {
|
|
27154
|
-
const name = typeof ctorOrName === "string" ? ctorOrName : ctorOrName.name;
|
|
27155
|
-
const key = Symbol.for(PREFIX + name);
|
|
27156
|
-
return {
|
|
27157
|
-
get(fallback) {
|
|
27158
|
-
return _g[key] ?? fallback;
|
|
27159
|
-
},
|
|
27160
|
-
set(value) {
|
|
27161
|
-
_g[key] = value;
|
|
27162
|
-
},
|
|
27163
|
-
clear() {
|
|
27164
|
-
delete _g[key];
|
|
27165
|
-
},
|
|
27166
|
-
getOrInit(factory, guard) {
|
|
27167
|
-
const existing = _g[key];
|
|
27168
|
-
if (existing != null && typeof existing === "object") {
|
|
27169
|
-
if (!guard || guard(existing)) {
|
|
27170
|
-
return existing;
|
|
27171
|
-
}
|
|
27172
|
-
}
|
|
27173
|
-
const instance = factory();
|
|
27174
|
-
_g[key] = instance;
|
|
27175
|
-
return instance;
|
|
27176
|
-
}
|
|
27177
|
-
};
|
|
27178
|
-
}
|
|
27179
27129
|
|
|
27180
|
-
// ../common/src/output-context.ts
|
|
27181
|
-
function createStorage() {
|
|
27182
|
-
const [error, mod] = catchError(() => __require("node:async_hooks"));
|
|
27183
|
-
if (error || typeof mod?.AsyncLocalStorage !== "function") {
|
|
27184
|
-
return {
|
|
27185
|
-
getStore: () => {
|
|
27186
|
-
return;
|
|
27187
|
-
},
|
|
27188
|
-
run: (_store, fn) => fn()
|
|
27189
|
-
};
|
|
27190
|
-
}
|
|
27191
|
-
return new mod.AsyncLocalStorage;
|
|
27192
|
-
}
|
|
27193
|
-
var storageSingleton = singleton("OutputStorage");
|
|
27194
|
-
var sinkSlot = singleton("OutputSink");
|
|
27195
|
-
var outputStorage = storageSingleton.getOrInit(createStorage, (v) => ("getStore" in v));
|
|
27196
|
-
var CONSOLE_FALLBACK = {
|
|
27197
|
-
writeOut: (str) => process.stdout.write(str),
|
|
27198
|
-
writeErr: (str) => process.stderr.write(str),
|
|
27199
|
-
writeLog: (str) => process.stdout.write(str),
|
|
27200
|
-
capabilities: {
|
|
27201
|
-
isInteractive: false,
|
|
27202
|
-
supportsColor: false,
|
|
27203
|
-
outputWidth: 80
|
|
27204
|
-
}
|
|
27205
|
-
};
|
|
27206
|
-
function getOutputSink() {
|
|
27207
|
-
return outputStorage.getStore() ?? sinkSlot.get() ?? CONSOLE_FALLBACK;
|
|
27208
|
-
}
|
|
27209
|
-
// ../common/src/completer.ts
|
|
27210
|
-
var COMPLETER_SYMBOL = Symbol.for("@uipath/common/completer");
|
|
27211
|
-
// ../common/src/console-guard.ts
|
|
27212
|
-
var guardInstalledSlot = singleton("ConsoleGuardInstalled");
|
|
27213
|
-
var savedOriginalsSlot = singleton("ConsoleGuardOriginals");
|
|
27214
|
-
// ../common/src/constants.ts
|
|
27215
|
-
var DEFAULT_AUTH_TIMEOUT_MS = 5 * 60 * 1000;
|
|
27216
27130
|
// ../common/src/error-handler.ts
|
|
27217
27131
|
var DEFAULT_401 = "Unauthorized (401). Run `uip login` to authenticate.";
|
|
27218
27132
|
var DEFAULT_403 = "Forbidden (403). Ensure the account has the required permissions.";
|
|
@@ -27362,6 +27276,94 @@ function extractErrorMessageSync(error) {
|
|
|
27362
27276
|
}
|
|
27363
27277
|
return String(error);
|
|
27364
27278
|
}
|
|
27279
|
+
// ../../node_modules/commander/esm.mjs
|
|
27280
|
+
var import__ = __toESM(require_commander(), 1);
|
|
27281
|
+
var {
|
|
27282
|
+
program,
|
|
27283
|
+
createCommand,
|
|
27284
|
+
createArgument,
|
|
27285
|
+
createOption,
|
|
27286
|
+
CommanderError,
|
|
27287
|
+
InvalidArgumentError,
|
|
27288
|
+
InvalidOptionArgumentError,
|
|
27289
|
+
Command,
|
|
27290
|
+
Argument,
|
|
27291
|
+
Option,
|
|
27292
|
+
Help
|
|
27293
|
+
} = import__.default;
|
|
27294
|
+
|
|
27295
|
+
// ../common/src/command-examples.ts
|
|
27296
|
+
var examplesByCommand = new WeakMap;
|
|
27297
|
+
Command.prototype.examples = function(examples) {
|
|
27298
|
+
examplesByCommand.set(this, examples);
|
|
27299
|
+
return this;
|
|
27300
|
+
};
|
|
27301
|
+
// ../common/src/singleton.ts
|
|
27302
|
+
var PREFIX = "@uipath/common/";
|
|
27303
|
+
var _g = globalThis;
|
|
27304
|
+
function singleton(ctorOrName) {
|
|
27305
|
+
const name = typeof ctorOrName === "string" ? ctorOrName : ctorOrName.name;
|
|
27306
|
+
const key = Symbol.for(PREFIX + name);
|
|
27307
|
+
return {
|
|
27308
|
+
get(fallback) {
|
|
27309
|
+
return _g[key] ?? fallback;
|
|
27310
|
+
},
|
|
27311
|
+
set(value) {
|
|
27312
|
+
_g[key] = value;
|
|
27313
|
+
},
|
|
27314
|
+
clear() {
|
|
27315
|
+
delete _g[key];
|
|
27316
|
+
},
|
|
27317
|
+
getOrInit(factory, guard) {
|
|
27318
|
+
const existing = _g[key];
|
|
27319
|
+
if (existing != null && typeof existing === "object") {
|
|
27320
|
+
if (!guard || guard(existing)) {
|
|
27321
|
+
return existing;
|
|
27322
|
+
}
|
|
27323
|
+
}
|
|
27324
|
+
const instance = factory();
|
|
27325
|
+
_g[key] = instance;
|
|
27326
|
+
return instance;
|
|
27327
|
+
}
|
|
27328
|
+
};
|
|
27329
|
+
}
|
|
27330
|
+
|
|
27331
|
+
// ../common/src/output-context.ts
|
|
27332
|
+
function createStorage() {
|
|
27333
|
+
const [error, mod] = catchError(() => __require("node:async_hooks"));
|
|
27334
|
+
if (error || typeof mod?.AsyncLocalStorage !== "function") {
|
|
27335
|
+
return {
|
|
27336
|
+
getStore: () => {
|
|
27337
|
+
return;
|
|
27338
|
+
},
|
|
27339
|
+
run: (_store, fn) => fn()
|
|
27340
|
+
};
|
|
27341
|
+
}
|
|
27342
|
+
return new mod.AsyncLocalStorage;
|
|
27343
|
+
}
|
|
27344
|
+
var storageSingleton = singleton("OutputStorage");
|
|
27345
|
+
var sinkSlot = singleton("OutputSink");
|
|
27346
|
+
var outputStorage = storageSingleton.getOrInit(createStorage, (v) => ("getStore" in v));
|
|
27347
|
+
var CONSOLE_FALLBACK = {
|
|
27348
|
+
writeOut: (str) => process.stdout.write(str),
|
|
27349
|
+
writeErr: (str) => process.stderr.write(str),
|
|
27350
|
+
writeLog: (str) => process.stdout.write(str),
|
|
27351
|
+
capabilities: {
|
|
27352
|
+
isInteractive: false,
|
|
27353
|
+
supportsColor: false,
|
|
27354
|
+
outputWidth: 80
|
|
27355
|
+
}
|
|
27356
|
+
};
|
|
27357
|
+
function getOutputSink() {
|
|
27358
|
+
return outputStorage.getStore() ?? sinkSlot.get() ?? CONSOLE_FALLBACK;
|
|
27359
|
+
}
|
|
27360
|
+
// ../common/src/completer.ts
|
|
27361
|
+
var COMPLETER_SYMBOL = Symbol.for("@uipath/common/completer");
|
|
27362
|
+
// ../common/src/console-guard.ts
|
|
27363
|
+
var guardInstalledSlot = singleton("ConsoleGuardInstalled");
|
|
27364
|
+
var savedOriginalsSlot = singleton("ConsoleGuardOriginals");
|
|
27365
|
+
// ../common/src/constants.ts
|
|
27366
|
+
var DEFAULT_AUTH_TIMEOUT_MS = 5 * 60 * 1000;
|
|
27365
27367
|
// ../../node_modules/@jmespath-community/jmespath/dist/index.mjs
|
|
27366
27368
|
var isObject = (obj) => {
|
|
27367
27369
|
return obj !== null && Object.prototype.toString.call(obj) === "[object Object]";
|
|
@@ -32406,15 +32408,26 @@ class SuccessOutput {
|
|
|
32406
32408
|
}
|
|
32407
32409
|
}
|
|
32408
32410
|
}
|
|
32409
|
-
function
|
|
32411
|
+
function escapeNonAscii(jsonText) {
|
|
32412
|
+
return jsonText.replace(/[\u0080-\uffff]/g, (c) => {
|
|
32413
|
+
const hex = c.charCodeAt(0).toString(16).padStart(4, "0");
|
|
32414
|
+
return `\\u${hex}`;
|
|
32415
|
+
});
|
|
32416
|
+
}
|
|
32417
|
+
function needsAsciiSafeJson(sink) {
|
|
32418
|
+
return process.platform === "win32" && !sink.capabilities.isInteractive;
|
|
32419
|
+
}
|
|
32420
|
+
function printOutput(data, format = "json", logFn, asciiSafe = false) {
|
|
32410
32421
|
if (!data) {
|
|
32411
32422
|
logFn("Empty response object. No data to display.");
|
|
32412
32423
|
return;
|
|
32413
32424
|
}
|
|
32414
32425
|
switch (format) {
|
|
32415
|
-
case "json":
|
|
32416
|
-
|
|
32426
|
+
case "json": {
|
|
32427
|
+
const json2 = JSON.stringify(data, null, 2);
|
|
32428
|
+
logFn(asciiSafe ? escapeNonAscii(json2) : json2);
|
|
32417
32429
|
break;
|
|
32430
|
+
}
|
|
32418
32431
|
case "yaml":
|
|
32419
32432
|
logFn(toYaml(data));
|
|
32420
32433
|
break;
|
|
@@ -32449,7 +32462,7 @@ function printOutput(data, format = "json", logFn) {
|
|
|
32449
32462
|
function logOutput(data, format = "json") {
|
|
32450
32463
|
const sink = getOutputSink();
|
|
32451
32464
|
printOutput(data, format, (msg) => sink.writeOut(`${msg}
|
|
32452
|
-
`));
|
|
32465
|
+
`), needsAsciiSafeJson(sink));
|
|
32453
32466
|
}
|
|
32454
32467
|
function cellToString(val) {
|
|
32455
32468
|
return val != null && typeof val === "object" ? JSON.stringify(val) : String(val ?? "");
|
|
@@ -32629,7 +32642,9 @@ var OutputFormatter;
|
|
|
32629
32642
|
const format = getOutputFormat();
|
|
32630
32643
|
const sink = getOutputSink();
|
|
32631
32644
|
if (format === "json") {
|
|
32632
|
-
|
|
32645
|
+
const json2 = JSON.stringify(data);
|
|
32646
|
+
const safe = needsAsciiSafeJson(sink) ? escapeNonAscii(json2) : json2;
|
|
32647
|
+
sink.writeErr(`${safe}
|
|
32633
32648
|
`);
|
|
32634
32649
|
} else {
|
|
32635
32650
|
for (const [key, value] of Object.entries(data)) {
|
|
@@ -32645,9 +32660,10 @@ var OutputFormatter;
|
|
|
32645
32660
|
data.Data = applyFilter(data.Data, filter);
|
|
32646
32661
|
}
|
|
32647
32662
|
const lines = [];
|
|
32663
|
+
const sink = getOutputSink();
|
|
32648
32664
|
printOutput(data, getOutputFormat(), (msg) => {
|
|
32649
32665
|
lines.push(msg);
|
|
32650
|
-
});
|
|
32666
|
+
}, needsAsciiSafeJson(sink));
|
|
32651
32667
|
return lines.join(`
|
|
32652
32668
|
`);
|
|
32653
32669
|
}
|
|
@@ -34056,6 +34072,23 @@ JSONPath.prototype.safeVm = {
|
|
|
34056
34072
|
Script: SafeScript
|
|
34057
34073
|
};
|
|
34058
34074
|
JSONPath.prototype.vm = vm;
|
|
34075
|
+
// ../common/src/option-aliases.ts
|
|
34076
|
+
function warnDeprecatedOptionAlias(deprecatedFlag, preferredFlag) {
|
|
34077
|
+
getOutputSink().writeErr(`[WARN] ${deprecatedFlag} is deprecated. Use ${preferredFlag} instead.
|
|
34078
|
+
`);
|
|
34079
|
+
}
|
|
34080
|
+
var TENANT_SWITCH_COMMAND = "uip login tenant set <tenant>";
|
|
34081
|
+
function createHiddenDeprecatedTenantOption(flags = "-t, --tenant <tenant-name>") {
|
|
34082
|
+
return new Option(flags, `Tenant name. Deprecated; use ${TENANT_SWITCH_COMMAND} to switch active tenants.`).hideHelp().argParser((tenant) => {
|
|
34083
|
+
warnDeprecatedTenantOption(tenant);
|
|
34084
|
+
return tenant;
|
|
34085
|
+
});
|
|
34086
|
+
}
|
|
34087
|
+
function warnDeprecatedTenantOption(tenant) {
|
|
34088
|
+
if (tenant === undefined)
|
|
34089
|
+
return;
|
|
34090
|
+
warnDeprecatedOptionAlias("--tenant", TENANT_SWITCH_COMMAND);
|
|
34091
|
+
}
|
|
34059
34092
|
// ../common/src/polling/terminal-statuses.ts
|
|
34060
34093
|
var TERMINAL_STATUSES = new Set([
|
|
34061
34094
|
"completed",
|
|
@@ -34330,7 +34363,9 @@ var DEFAULT_SCOPES = [
|
|
|
34330
34363
|
"AutomationSolutions",
|
|
34331
34364
|
"StudioWebTypeCacheService",
|
|
34332
34365
|
"Docs.GPT.Search",
|
|
34333
|
-
"Insights"
|
|
34366
|
+
"Insights",
|
|
34367
|
+
"ReferenceToken",
|
|
34368
|
+
"Audit.Read"
|
|
34334
34369
|
];
|
|
34335
34370
|
var normalizeAndValidateBaseUrl = (rawUrl) => {
|
|
34336
34371
|
let baseUrl = rawUrl;
|
|
@@ -34469,6 +34504,7 @@ var getTokenExpiration = (accessToken) => {
|
|
|
34469
34504
|
|
|
34470
34505
|
// ../auth/src/envAuth.ts
|
|
34471
34506
|
var ENV_AUTH_ENABLE_VAR = "UIPATH_CLI_ENABLE_ENV_AUTH";
|
|
34507
|
+
var ENFORCE_ROBOT_AUTH_VAR = "UIPATH_CLI_ENFORCE_ROBOT_AUTH";
|
|
34472
34508
|
var ENV_AUTH_VARS = {
|
|
34473
34509
|
token: "UIPATH_CLI_AUTH_TOKEN",
|
|
34474
34510
|
organizationName: "UIPATH_CLI_ORGANIZATION_NAME",
|
|
@@ -34484,6 +34520,7 @@ class EnvAuthConfigError extends Error {
|
|
|
34484
34520
|
}
|
|
34485
34521
|
}
|
|
34486
34522
|
var isEnvAuthEnabled = () => process.env[ENV_AUTH_ENABLE_VAR] === "true";
|
|
34523
|
+
var isRobotAuthEnforced = () => process.env[ENFORCE_ROBOT_AUTH_VAR] === "true";
|
|
34487
34524
|
var requireEnv = (name) => {
|
|
34488
34525
|
const value = process.env[name];
|
|
34489
34526
|
if (!value) {
|
|
@@ -34525,7 +34562,9 @@ var readAuthFromEnv = () => {
|
|
|
34525
34562
|
expiration
|
|
34526
34563
|
};
|
|
34527
34564
|
};
|
|
34565
|
+
|
|
34528
34566
|
// ../auth/src/robotClientFallback.ts
|
|
34567
|
+
init_src();
|
|
34529
34568
|
var DEFAULT_TIMEOUT_MS = 1000;
|
|
34530
34569
|
var CLOSE_TIMEOUT_MS = 500;
|
|
34531
34570
|
var NOTICE_SENTINEL = Symbol.for("@uipath/auth/robotFallbackNoticePrinted");
|
|
@@ -34537,6 +34576,35 @@ var printNoticeOnce = () => {
|
|
|
34537
34576
|
catchError2(() => process.stderr.write(`Using UiPath Robot credentials. Run 'uip login' for a dedicated session.
|
|
34538
34577
|
`));
|
|
34539
34578
|
};
|
|
34579
|
+
var ROBOT_USER_SERVICES_PIPE = "UiPathUserServices";
|
|
34580
|
+
var ROBOT_USER_SERVICES_ALTERNATE_PIPE = `${ROBOT_USER_SERVICES_PIPE}Alternate`;
|
|
34581
|
+
var PIPE_NAME_MAX_LENGTH = 103;
|
|
34582
|
+
var getRobotIpcPipeNames = async () => {
|
|
34583
|
+
const fs7 = getFileSystem();
|
|
34584
|
+
const username = fs7.env.getenv("USER") ?? fs7.env.getenv("USERNAME");
|
|
34585
|
+
if (!username) {
|
|
34586
|
+
throw new Error("Unable to determine current username");
|
|
34587
|
+
}
|
|
34588
|
+
const tempPath = fs7.env.getenv("TMPDIR") ?? "/tmp/";
|
|
34589
|
+
return [ROBOT_USER_SERVICES_PIPE, ROBOT_USER_SERVICES_ALTERNATE_PIPE].map((baseName) => fs7.path.join(tempPath, `${baseName}_${username}`).substring(0, PIPE_NAME_MAX_LENGTH));
|
|
34590
|
+
};
|
|
34591
|
+
var defaultIsRobotIpcAvailable = async () => {
|
|
34592
|
+
if (process.platform === "win32") {
|
|
34593
|
+
return true;
|
|
34594
|
+
}
|
|
34595
|
+
const [pipeNamesError, pipeNames] = await catchError2(getRobotIpcPipeNames());
|
|
34596
|
+
if (pipeNamesError || !pipeNames) {
|
|
34597
|
+
return false;
|
|
34598
|
+
}
|
|
34599
|
+
const fs7 = getFileSystem();
|
|
34600
|
+
for (const pipeName of pipeNames) {
|
|
34601
|
+
const [existsError, exists] = await catchError2(fs7.exists(pipeName));
|
|
34602
|
+
if (!existsError && exists === true) {
|
|
34603
|
+
return true;
|
|
34604
|
+
}
|
|
34605
|
+
}
|
|
34606
|
+
return false;
|
|
34607
|
+
};
|
|
34540
34608
|
var withTimeout = (promise, timeoutMs) => new Promise((resolve2, reject) => {
|
|
34541
34609
|
const timer = setTimeout(() => reject(new Error(`Robot IPC call timed out after ${timeoutMs}ms`)), timeoutMs);
|
|
34542
34610
|
promise.then((value) => {
|
|
@@ -34568,14 +34636,20 @@ var defaultLoadModule = async () => {
|
|
|
34568
34636
|
var tryRobotClientFallback = async (options = {}) => {
|
|
34569
34637
|
if (isBrowser())
|
|
34570
34638
|
return;
|
|
34571
|
-
if (
|
|
34572
|
-
|
|
34573
|
-
|
|
34574
|
-
|
|
34575
|
-
|
|
34639
|
+
if (!options.force) {
|
|
34640
|
+
if (process.env.CI || process.env.GITHUB_ACTIONS) {
|
|
34641
|
+
return;
|
|
34642
|
+
}
|
|
34643
|
+
if (process.env.UIPATH_URL) {
|
|
34644
|
+
return;
|
|
34645
|
+
}
|
|
34576
34646
|
}
|
|
34577
34647
|
const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
34648
|
+
const isRobotIpcAvailable = options.isRobotIpcAvailable ?? defaultIsRobotIpcAvailable;
|
|
34578
34649
|
const loadModule = options.loadModule ?? defaultLoadModule;
|
|
34650
|
+
if (!await isRobotIpcAvailable()) {
|
|
34651
|
+
return;
|
|
34652
|
+
}
|
|
34579
34653
|
const mod2 = await loadModule();
|
|
34580
34654
|
if (!mod2)
|
|
34581
34655
|
return;
|
|
@@ -34843,10 +34917,6 @@ function normalizeTokenRefreshUnavailableFailure() {
|
|
|
34843
34917
|
return "token refresh failed before authentication completed";
|
|
34844
34918
|
}
|
|
34845
34919
|
var getLoginStatusWithDeps = async (options = {}, deps = {}) => {
|
|
34846
|
-
if (isEnvAuthEnabled()) {
|
|
34847
|
-
return readAuthFromEnv();
|
|
34848
|
-
}
|
|
34849
|
-
const { envFilePath = DEFAULT_ENV_FILENAME, ensureTokenValidityMinutes } = options;
|
|
34850
34920
|
const {
|
|
34851
34921
|
resolveEnvFilePath = resolveEnvFilePathAsync,
|
|
34852
34922
|
loadEnvFile = loadEnvFileAsync,
|
|
@@ -34856,6 +34926,34 @@ var getLoginStatusWithDeps = async (options = {}, deps = {}) => {
|
|
|
34856
34926
|
resolveConfig = resolveConfigAsync,
|
|
34857
34927
|
robotFallback = tryRobotClientFallback
|
|
34858
34928
|
} = deps;
|
|
34929
|
+
if (isRobotAuthEnforced()) {
|
|
34930
|
+
if (isEnvAuthEnabled()) {
|
|
34931
|
+
throw new EnvAuthConfigError(`${ENV_AUTH_ENABLE_VAR}=true and ${ENFORCE_ROBOT_AUTH_VAR}=true ` + `are mutually exclusive. Unset one of them and re-run.`);
|
|
34932
|
+
}
|
|
34933
|
+
const robotCreds = await robotFallback({ force: true });
|
|
34934
|
+
if (!robotCreds) {
|
|
34935
|
+
return {
|
|
34936
|
+
loginStatus: "Not logged in",
|
|
34937
|
+
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.`
|
|
34938
|
+
};
|
|
34939
|
+
}
|
|
34940
|
+
const expiration2 = getTokenExpiration(robotCreds.accessToken);
|
|
34941
|
+
return {
|
|
34942
|
+
loginStatus: "Logged in",
|
|
34943
|
+
accessToken: robotCreds.accessToken,
|
|
34944
|
+
baseUrl: robotCreds.baseUrl,
|
|
34945
|
+
organizationName: robotCreds.organizationName,
|
|
34946
|
+
organizationId: robotCreds.organizationId,
|
|
34947
|
+
tenantName: robotCreds.tenantName,
|
|
34948
|
+
tenantId: robotCreds.tenantId,
|
|
34949
|
+
expiration: expiration2,
|
|
34950
|
+
source: "robot" /* Robot */
|
|
34951
|
+
};
|
|
34952
|
+
}
|
|
34953
|
+
if (isEnvAuthEnabled()) {
|
|
34954
|
+
return readAuthFromEnv();
|
|
34955
|
+
}
|
|
34956
|
+
const { envFilePath = DEFAULT_ENV_FILENAME, ensureTokenValidityMinutes } = options;
|
|
34859
34957
|
const { absolutePath } = await resolveEnvFilePath(envFilePath);
|
|
34860
34958
|
if (absolutePath === undefined) {
|
|
34861
34959
|
const robotCreds = await robotFallback();
|
|
@@ -44022,7 +44120,7 @@ var TASKS_USERS_EXAMPLES = [
|
|
|
44022
44120
|
}
|
|
44023
44121
|
];
|
|
44024
44122
|
var registerTasksCommand = (program2) => {
|
|
44025
|
-
program2.command("list").description("List tasks across folders").
|
|
44123
|
+
program2.command("list").description("List tasks across folders").addOption(createHiddenDeprecatedTenantOption("-t, --tenant <tenant-name>")).option("--folder-id <id>", "Filter by folder ID").option("--as-admin", "List tasks as admin").option("-l, --limit <number>", "Maximum number of items to return (fetches all if omitted)").trackedAction(processContext, async (options) => {
|
|
44026
44124
|
const [clientError, sdk] = await catchError(createTasksClient(options.tenant));
|
|
44027
44125
|
if (clientError) {
|
|
44028
44126
|
OutputFormatter.error({
|
|
@@ -44095,7 +44193,7 @@ var registerTasksCommand = (program2) => {
|
|
|
44095
44193
|
Data: data
|
|
44096
44194
|
});
|
|
44097
44195
|
});
|
|
44098
|
-
program2.command("get").description("Get details of a task by ID. Use 'tasks list' to find task IDs.").argument("<id>", "Task ID").
|
|
44196
|
+
program2.command("get").description("Get details of a task by ID. Use 'tasks list' to find task IDs.").argument("<id>", "Task ID").addOption(createHiddenDeprecatedTenantOption("-t, --tenant <tenant-name>")).option("--task-type <type>", "Task type (FormTask, ExternalTask, AppTask, DocumentValidationTask, DocumentClassificationTask, DataLabelingTask)").option("--folder-id <id>", "Folder ID (required when task-type is specified)").trackedAction(processContext, async (id, options) => {
|
|
44099
44197
|
const [clientError, sdk] = await catchError(createTasksClient(options.tenant));
|
|
44100
44198
|
if (clientError) {
|
|
44101
44199
|
OutputFormatter.error({
|
|
@@ -44149,13 +44247,13 @@ var registerTasksCommand = (program2) => {
|
|
|
44149
44247
|
Data: task
|
|
44150
44248
|
});
|
|
44151
44249
|
});
|
|
44152
|
-
program2.command("assign").description("Assign a task to a user").argument("<task-id>", "Task ID").
|
|
44250
|
+
program2.command("assign").description("Assign a task to a user").argument("<task-id>", "Task ID").addOption(createHiddenDeprecatedTenantOption("-t, --tenant <tenant-name>")).option("--user-id <id>", "User ID").option("--user <email>", "User name or email (alternative to --user-id)").trackedAction(processContext, async (taskId, options) => {
|
|
44153
44251
|
await assignOrReassign(taskId, options, "assign");
|
|
44154
44252
|
});
|
|
44155
|
-
program2.command("reassign").description("Reassign a task to a different user").argument("<task-id>", "Task ID").
|
|
44253
|
+
program2.command("reassign").description("Reassign a task to a different user").argument("<task-id>", "Task ID").addOption(createHiddenDeprecatedTenantOption("-t, --tenant <tenant-name>")).option("--user-id <id>", "User ID").option("--user <email>", "User name or email (alternative to --user-id)").trackedAction(processContext, async (taskId, options) => {
|
|
44156
44254
|
await assignOrReassign(taskId, options, "reassign");
|
|
44157
44255
|
});
|
|
44158
|
-
program2.command("unassign").description("Remove the assignee from a task").argument("<task-id>", "Task ID").
|
|
44256
|
+
program2.command("unassign").description("Remove the assignee from a task").argument("<task-id>", "Task ID").addOption(createHiddenDeprecatedTenantOption("-t, --tenant <tenant-name>")).trackedAction(processContext, async (taskId, options) => {
|
|
44159
44257
|
const [clientError, sdk] = await catchError(createTasksClient(options.tenant));
|
|
44160
44258
|
if (clientError) {
|
|
44161
44259
|
OutputFormatter.error({
|
|
@@ -44187,7 +44285,7 @@ var registerTasksCommand = (program2) => {
|
|
|
44187
44285
|
Data: result
|
|
44188
44286
|
});
|
|
44189
44287
|
});
|
|
44190
|
-
program2.command("complete").description("Complete a task with an action and optional data").argument("<task-id>", "Task ID").requiredOption("--type <type>", "Task type (FormTask, ExternalTask, AppTask, DocumentValidationTask, DocumentClassificationTask, DataLabelingTask)").requiredOption("--folder-id <id>", "Folder ID (required)").
|
|
44288
|
+
program2.command("complete").description("Complete a task with an action and optional data").argument("<task-id>", "Task ID").requiredOption("--type <type>", "Task type (FormTask, ExternalTask, AppTask, DocumentValidationTask, DocumentClassificationTask, DataLabelingTask)").requiredOption("--folder-id <id>", "Folder ID (required)").addOption(createHiddenDeprecatedTenantOption("-t, --tenant <tenant-name>")).option("--data <json>", "Task data as JSON string").option("--action <action>", "Action name (required for FormTask and AppTask)").trackedAction(processContext, async (taskId, options) => {
|
|
44191
44289
|
const [clientError, sdk] = await catchError(createTasksClient(options.tenant));
|
|
44192
44290
|
if (clientError) {
|
|
44193
44291
|
OutputFormatter.error({
|
|
@@ -44253,7 +44351,7 @@ var registerTasksCommand = (program2) => {
|
|
|
44253
44351
|
Data: result
|
|
44254
44352
|
});
|
|
44255
44353
|
});
|
|
44256
|
-
program2.command("users").description("List users with task permissions in a folder. Use the user ID with 'tasks assign'.").argument("<folder-id>", "Folder ID").
|
|
44354
|
+
program2.command("users").description("List users with task permissions in a folder. Use the user ID with 'tasks assign'.").argument("<folder-id>", "Folder ID").addOption(createHiddenDeprecatedTenantOption("-t, --tenant <tenant-name>")).option("-l, --limit <number>", "Maximum number of items to return (fetches all if omitted)").examples(TASKS_USERS_EXAMPLES).trackedAction(processContext, async (folderId, options) => {
|
|
44257
44355
|
const [clientError, sdk] = await catchError(createTasksClient(options.tenant));
|
|
44258
44356
|
if (clientError) {
|
|
44259
44357
|
OutputFormatter.error({
|