@rehpic/vcli 0.1.0-beta.13.1 → 0.1.0-beta.18.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,4 +1,739 @@
1
1
  #!/usr/bin/env node
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __esm = (fn, res) => function __init() {
5
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
6
+ };
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+
12
+ // ../../node_modules/.pnpm/is-docker@3.0.0/node_modules/is-docker/index.js
13
+ import fs from "fs";
14
+ function hasDockerEnv() {
15
+ try {
16
+ fs.statSync("/.dockerenv");
17
+ return true;
18
+ } catch {
19
+ return false;
20
+ }
21
+ }
22
+ function hasDockerCGroup() {
23
+ try {
24
+ return fs.readFileSync("/proc/self/cgroup", "utf8").includes("docker");
25
+ } catch {
26
+ return false;
27
+ }
28
+ }
29
+ function isDocker() {
30
+ if (isDockerCached === void 0) {
31
+ isDockerCached = hasDockerEnv() || hasDockerCGroup();
32
+ }
33
+ return isDockerCached;
34
+ }
35
+ var isDockerCached;
36
+ var init_is_docker = __esm({
37
+ "../../node_modules/.pnpm/is-docker@3.0.0/node_modules/is-docker/index.js"() {
38
+ "use strict";
39
+ }
40
+ });
41
+
42
+ // ../../node_modules/.pnpm/is-inside-container@1.0.0/node_modules/is-inside-container/index.js
43
+ import fs2 from "fs";
44
+ function isInsideContainer() {
45
+ if (cachedResult === void 0) {
46
+ cachedResult = hasContainerEnv() || isDocker();
47
+ }
48
+ return cachedResult;
49
+ }
50
+ var cachedResult, hasContainerEnv;
51
+ var init_is_inside_container = __esm({
52
+ "../../node_modules/.pnpm/is-inside-container@1.0.0/node_modules/is-inside-container/index.js"() {
53
+ "use strict";
54
+ init_is_docker();
55
+ hasContainerEnv = () => {
56
+ try {
57
+ fs2.statSync("/run/.containerenv");
58
+ return true;
59
+ } catch {
60
+ return false;
61
+ }
62
+ };
63
+ }
64
+ });
65
+
66
+ // ../../node_modules/.pnpm/is-wsl@3.1.1/node_modules/is-wsl/index.js
67
+ import process2 from "process";
68
+ import os from "os";
69
+ import fs3 from "fs";
70
+ var isWsl, is_wsl_default;
71
+ var init_is_wsl = __esm({
72
+ "../../node_modules/.pnpm/is-wsl@3.1.1/node_modules/is-wsl/index.js"() {
73
+ "use strict";
74
+ init_is_inside_container();
75
+ isWsl = () => {
76
+ if (process2.platform !== "linux") {
77
+ return false;
78
+ }
79
+ if (os.release().toLowerCase().includes("microsoft")) {
80
+ if (isInsideContainer()) {
81
+ return false;
82
+ }
83
+ return true;
84
+ }
85
+ try {
86
+ if (fs3.readFileSync("/proc/version", "utf8").toLowerCase().includes("microsoft")) {
87
+ return !isInsideContainer();
88
+ }
89
+ } catch {
90
+ }
91
+ if (fs3.existsSync("/proc/sys/fs/binfmt_misc/WSLInterop") || fs3.existsSync("/run/WSL")) {
92
+ return !isInsideContainer();
93
+ }
94
+ return false;
95
+ };
96
+ is_wsl_default = process2.env.__IS_WSL_TEST__ ? isWsl : isWsl();
97
+ }
98
+ });
99
+
100
+ // ../../node_modules/.pnpm/powershell-utils@0.1.0/node_modules/powershell-utils/index.js
101
+ import process3 from "process";
102
+ import { Buffer as Buffer2 } from "buffer";
103
+ import { promisify } from "util";
104
+ import childProcess from "child_process";
105
+ import fs4, { constants as fsConstants } from "fs/promises";
106
+ var execFile, powerShellPath, executePowerShell;
107
+ var init_powershell_utils = __esm({
108
+ "../../node_modules/.pnpm/powershell-utils@0.1.0/node_modules/powershell-utils/index.js"() {
109
+ "use strict";
110
+ execFile = promisify(childProcess.execFile);
111
+ powerShellPath = () => `${process3.env.SYSTEMROOT || process3.env.windir || String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`;
112
+ executePowerShell = async (command, options = {}) => {
113
+ const {
114
+ powerShellPath: psPath,
115
+ ...execFileOptions
116
+ } = options;
117
+ const encodedCommand = executePowerShell.encodeCommand(command);
118
+ return execFile(
119
+ psPath ?? powerShellPath(),
120
+ [
121
+ ...executePowerShell.argumentsPrefix,
122
+ encodedCommand
123
+ ],
124
+ {
125
+ encoding: "utf8",
126
+ ...execFileOptions
127
+ }
128
+ );
129
+ };
130
+ executePowerShell.argumentsPrefix = [
131
+ "-NoProfile",
132
+ "-NonInteractive",
133
+ "-ExecutionPolicy",
134
+ "Bypass",
135
+ "-EncodedCommand"
136
+ ];
137
+ executePowerShell.encodeCommand = (command) => Buffer2.from(command, "utf16le").toString("base64");
138
+ executePowerShell.escapeArgument = (value) => `'${String(value).replaceAll("'", "''")}'`;
139
+ }
140
+ });
141
+
142
+ // ../../node_modules/.pnpm/wsl-utils@0.3.1/node_modules/wsl-utils/utilities.js
143
+ function parseMountPointFromConfig(content) {
144
+ for (const line of content.split("\n")) {
145
+ if (/^\s*#/.test(line)) {
146
+ continue;
147
+ }
148
+ const match = /^\s*root\s*=\s*(?<mountPoint>"[^"]*"|'[^']*'|[^#]*)/.exec(line);
149
+ if (!match) {
150
+ continue;
151
+ }
152
+ return match.groups.mountPoint.trim().replaceAll(/^["']|["']$/g, "");
153
+ }
154
+ }
155
+ var init_utilities = __esm({
156
+ "../../node_modules/.pnpm/wsl-utils@0.3.1/node_modules/wsl-utils/utilities.js"() {
157
+ "use strict";
158
+ }
159
+ });
160
+
161
+ // ../../node_modules/.pnpm/wsl-utils@0.3.1/node_modules/wsl-utils/index.js
162
+ import { promisify as promisify2 } from "util";
163
+ import childProcess2 from "child_process";
164
+ import fs5, { constants as fsConstants2 } from "fs/promises";
165
+ var execFile2, wslDrivesMountPoint, powerShellPathFromWsl, powerShellPath2, canAccessPowerShellPromise, canAccessPowerShell, wslDefaultBrowser, convertWslPathToWindows;
166
+ var init_wsl_utils = __esm({
167
+ "../../node_modules/.pnpm/wsl-utils@0.3.1/node_modules/wsl-utils/index.js"() {
168
+ "use strict";
169
+ init_is_wsl();
170
+ init_powershell_utils();
171
+ init_utilities();
172
+ init_is_wsl();
173
+ execFile2 = promisify2(childProcess2.execFile);
174
+ wslDrivesMountPoint = /* @__PURE__ */ (() => {
175
+ const defaultMountPoint = "/mnt/";
176
+ let mountPoint;
177
+ return async function() {
178
+ if (mountPoint) {
179
+ return mountPoint;
180
+ }
181
+ const configFilePath = "/etc/wsl.conf";
182
+ let isConfigFileExists = false;
183
+ try {
184
+ await fs5.access(configFilePath, fsConstants2.F_OK);
185
+ isConfigFileExists = true;
186
+ } catch {
187
+ }
188
+ if (!isConfigFileExists) {
189
+ return defaultMountPoint;
190
+ }
191
+ const configContent = await fs5.readFile(configFilePath, { encoding: "utf8" });
192
+ const parsedMountPoint = parseMountPointFromConfig(configContent);
193
+ if (parsedMountPoint === void 0) {
194
+ return defaultMountPoint;
195
+ }
196
+ mountPoint = parsedMountPoint;
197
+ mountPoint = mountPoint.endsWith("/") ? mountPoint : `${mountPoint}/`;
198
+ return mountPoint;
199
+ };
200
+ })();
201
+ powerShellPathFromWsl = async () => {
202
+ const mountPoint = await wslDrivesMountPoint();
203
+ return `${mountPoint}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`;
204
+ };
205
+ powerShellPath2 = is_wsl_default ? powerShellPathFromWsl : powerShellPath;
206
+ canAccessPowerShell = async () => {
207
+ canAccessPowerShellPromise ??= (async () => {
208
+ try {
209
+ const psPath = await powerShellPath2();
210
+ await fs5.access(psPath, fsConstants2.X_OK);
211
+ return true;
212
+ } catch {
213
+ return false;
214
+ }
215
+ })();
216
+ return canAccessPowerShellPromise;
217
+ };
218
+ wslDefaultBrowser = async () => {
219
+ const psPath = await powerShellPath2();
220
+ const command = String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`;
221
+ const { stdout } = await executePowerShell(command, { powerShellPath: psPath });
222
+ return stdout.trim();
223
+ };
224
+ convertWslPathToWindows = async (path3) => {
225
+ if (/^[a-z]+:\/\//i.test(path3)) {
226
+ return path3;
227
+ }
228
+ try {
229
+ const { stdout } = await execFile2("wslpath", ["-aw", path3], { encoding: "utf8" });
230
+ return stdout.trim();
231
+ } catch {
232
+ return path3;
233
+ }
234
+ };
235
+ }
236
+ });
237
+
238
+ // ../../node_modules/.pnpm/define-lazy-prop@3.0.0/node_modules/define-lazy-prop/index.js
239
+ function defineLazyProperty(object, propertyName, valueGetter) {
240
+ const define = (value) => Object.defineProperty(object, propertyName, { value, enumerable: true, writable: true });
241
+ Object.defineProperty(object, propertyName, {
242
+ configurable: true,
243
+ enumerable: true,
244
+ get() {
245
+ const result = valueGetter();
246
+ define(result);
247
+ return result;
248
+ },
249
+ set(value) {
250
+ define(value);
251
+ }
252
+ });
253
+ return object;
254
+ }
255
+ var init_define_lazy_prop = __esm({
256
+ "../../node_modules/.pnpm/define-lazy-prop@3.0.0/node_modules/define-lazy-prop/index.js"() {
257
+ "use strict";
258
+ }
259
+ });
260
+
261
+ // ../../node_modules/.pnpm/default-browser-id@5.0.1/node_modules/default-browser-id/index.js
262
+ import { promisify as promisify3 } from "util";
263
+ import process4 from "process";
264
+ import { execFile as execFile3 } from "child_process";
265
+ async function defaultBrowserId() {
266
+ if (process4.platform !== "darwin") {
267
+ throw new Error("macOS only");
268
+ }
269
+ const { stdout } = await execFileAsync("defaults", ["read", "com.apple.LaunchServices/com.apple.launchservices.secure", "LSHandlers"]);
270
+ const match = /LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(stdout);
271
+ const browserId = match?.groups.id ?? "com.apple.Safari";
272
+ if (browserId === "com.apple.safari") {
273
+ return "com.apple.Safari";
274
+ }
275
+ return browserId;
276
+ }
277
+ var execFileAsync;
278
+ var init_default_browser_id = __esm({
279
+ "../../node_modules/.pnpm/default-browser-id@5.0.1/node_modules/default-browser-id/index.js"() {
280
+ "use strict";
281
+ execFileAsync = promisify3(execFile3);
282
+ }
283
+ });
284
+
285
+ // ../../node_modules/.pnpm/run-applescript@7.1.0/node_modules/run-applescript/index.js
286
+ import process5 from "process";
287
+ import { promisify as promisify4 } from "util";
288
+ import { execFile as execFile4, execFileSync } from "child_process";
289
+ async function runAppleScript(script, { humanReadableOutput = true, signal } = {}) {
290
+ if (process5.platform !== "darwin") {
291
+ throw new Error("macOS only");
292
+ }
293
+ const outputArguments = humanReadableOutput ? [] : ["-ss"];
294
+ const execOptions = {};
295
+ if (signal) {
296
+ execOptions.signal = signal;
297
+ }
298
+ const { stdout } = await execFileAsync2("osascript", ["-e", script, outputArguments], execOptions);
299
+ return stdout.trim();
300
+ }
301
+ var execFileAsync2;
302
+ var init_run_applescript = __esm({
303
+ "../../node_modules/.pnpm/run-applescript@7.1.0/node_modules/run-applescript/index.js"() {
304
+ "use strict";
305
+ execFileAsync2 = promisify4(execFile4);
306
+ }
307
+ });
308
+
309
+ // ../../node_modules/.pnpm/bundle-name@4.1.0/node_modules/bundle-name/index.js
310
+ async function bundleName(bundleId) {
311
+ return runAppleScript(`tell application "Finder" to set app_path to application file id "${bundleId}" as string
312
+ tell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`);
313
+ }
314
+ var init_bundle_name = __esm({
315
+ "../../node_modules/.pnpm/bundle-name@4.1.0/node_modules/bundle-name/index.js"() {
316
+ "use strict";
317
+ init_run_applescript();
318
+ }
319
+ });
320
+
321
+ // ../../node_modules/.pnpm/default-browser@5.5.0/node_modules/default-browser/windows.js
322
+ import { promisify as promisify5 } from "util";
323
+ import { execFile as execFile5 } from "child_process";
324
+ async function defaultBrowser(_execFileAsync = execFileAsync3) {
325
+ const { stdout } = await _execFileAsync("reg", [
326
+ "QUERY",
327
+ " HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice",
328
+ "/v",
329
+ "ProgId"
330
+ ]);
331
+ const match = /ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(stdout);
332
+ if (!match) {
333
+ throw new UnknownBrowserError(`Cannot find Windows browser in stdout: ${JSON.stringify(stdout)}`);
334
+ }
335
+ const { id } = match.groups;
336
+ const dotIndex = id.lastIndexOf(".");
337
+ const hyphenIndex = id.lastIndexOf("-");
338
+ const baseIdByDot = dotIndex === -1 ? void 0 : id.slice(0, dotIndex);
339
+ const baseIdByHyphen = hyphenIndex === -1 ? void 0 : id.slice(0, hyphenIndex);
340
+ return windowsBrowserProgIds[id] ?? windowsBrowserProgIds[baseIdByDot] ?? windowsBrowserProgIds[baseIdByHyphen] ?? { name: id, id };
341
+ }
342
+ var execFileAsync3, windowsBrowserProgIds, _windowsBrowserProgIdMap, UnknownBrowserError;
343
+ var init_windows = __esm({
344
+ "../../node_modules/.pnpm/default-browser@5.5.0/node_modules/default-browser/windows.js"() {
345
+ "use strict";
346
+ execFileAsync3 = promisify5(execFile5);
347
+ windowsBrowserProgIds = {
348
+ MSEdgeHTM: { name: "Edge", id: "com.microsoft.edge" },
349
+ // The missing `L` is correct.
350
+ MSEdgeBHTML: { name: "Edge Beta", id: "com.microsoft.edge.beta" },
351
+ MSEdgeDHTML: { name: "Edge Dev", id: "com.microsoft.edge.dev" },
352
+ AppXq0fevzme2pys62n3e0fbqa7peapykr8v: { name: "Edge", id: "com.microsoft.edge.old" },
353
+ ChromeHTML: { name: "Chrome", id: "com.google.chrome" },
354
+ ChromeBHTML: { name: "Chrome Beta", id: "com.google.chrome.beta" },
355
+ ChromeDHTML: { name: "Chrome Dev", id: "com.google.chrome.dev" },
356
+ ChromiumHTM: { name: "Chromium", id: "org.chromium.Chromium" },
357
+ BraveHTML: { name: "Brave", id: "com.brave.Browser" },
358
+ BraveBHTML: { name: "Brave Beta", id: "com.brave.Browser.beta" },
359
+ BraveDHTML: { name: "Brave Dev", id: "com.brave.Browser.dev" },
360
+ BraveSSHTM: { name: "Brave Nightly", id: "com.brave.Browser.nightly" },
361
+ FirefoxURL: { name: "Firefox", id: "org.mozilla.firefox" },
362
+ OperaStable: { name: "Opera", id: "com.operasoftware.Opera" },
363
+ VivaldiHTM: { name: "Vivaldi", id: "com.vivaldi.Vivaldi" },
364
+ "IE.HTTP": { name: "Internet Explorer", id: "com.microsoft.ie" }
365
+ };
366
+ _windowsBrowserProgIdMap = new Map(Object.entries(windowsBrowserProgIds));
367
+ UnknownBrowserError = class extends Error {
368
+ };
369
+ }
370
+ });
371
+
372
+ // ../../node_modules/.pnpm/default-browser@5.5.0/node_modules/default-browser/index.js
373
+ import { promisify as promisify6 } from "util";
374
+ import process6 from "process";
375
+ import { execFile as execFile6 } from "child_process";
376
+ async function defaultBrowser2() {
377
+ if (process6.platform === "darwin") {
378
+ const id = await defaultBrowserId();
379
+ const name = await bundleName(id);
380
+ return { name, id };
381
+ }
382
+ if (process6.platform === "linux") {
383
+ const { stdout } = await execFileAsync4("xdg-mime", ["query", "default", "x-scheme-handler/http"]);
384
+ const id = stdout.trim();
385
+ const name = titleize(id.replace(/.desktop$/, "").replace("-", " "));
386
+ return { name, id };
387
+ }
388
+ if (process6.platform === "win32") {
389
+ return defaultBrowser();
390
+ }
391
+ throw new Error("Only macOS, Linux, and Windows are supported");
392
+ }
393
+ var execFileAsync4, titleize;
394
+ var init_default_browser = __esm({
395
+ "../../node_modules/.pnpm/default-browser@5.5.0/node_modules/default-browser/index.js"() {
396
+ "use strict";
397
+ init_default_browser_id();
398
+ init_bundle_name();
399
+ init_windows();
400
+ init_windows();
401
+ execFileAsync4 = promisify6(execFile6);
402
+ titleize = (string) => string.toLowerCase().replaceAll(/(?:^|\s|-)\S/g, (x) => x.toUpperCase());
403
+ }
404
+ });
405
+
406
+ // ../../node_modules/.pnpm/is-in-ssh@1.0.0/node_modules/is-in-ssh/index.js
407
+ import process7 from "process";
408
+ var isInSsh, is_in_ssh_default;
409
+ var init_is_in_ssh = __esm({
410
+ "../../node_modules/.pnpm/is-in-ssh@1.0.0/node_modules/is-in-ssh/index.js"() {
411
+ "use strict";
412
+ isInSsh = Boolean(process7.env.SSH_CONNECTION || process7.env.SSH_CLIENT || process7.env.SSH_TTY);
413
+ is_in_ssh_default = isInSsh;
414
+ }
415
+ });
416
+
417
+ // ../../node_modules/.pnpm/open@11.0.0/node_modules/open/index.js
418
+ var open_exports = {};
419
+ __export(open_exports, {
420
+ apps: () => apps,
421
+ default: () => open_default,
422
+ openApp: () => openApp
423
+ });
424
+ import process8 from "process";
425
+ import path2 from "path";
426
+ import { fileURLToPath } from "url";
427
+ import childProcess3 from "child_process";
428
+ import fs6, { constants as fsConstants3 } from "fs/promises";
429
+ function detectArchBinary(binary) {
430
+ if (typeof binary === "string" || Array.isArray(binary)) {
431
+ return binary;
432
+ }
433
+ const { [arch]: archBinary } = binary;
434
+ if (!archBinary) {
435
+ throw new Error(`${arch} is not supported`);
436
+ }
437
+ return archBinary;
438
+ }
439
+ function detectPlatformBinary({ [platform]: platformBinary }, { wsl } = {}) {
440
+ if (wsl && is_wsl_default) {
441
+ return detectArchBinary(wsl);
442
+ }
443
+ if (!platformBinary) {
444
+ throw new Error(`${platform} is not supported`);
445
+ }
446
+ return detectArchBinary(platformBinary);
447
+ }
448
+ var fallbackAttemptSymbol, __dirname, localXdgOpenPath, platform, arch, tryEachApp, baseOpen, open, openApp, apps, open_default;
449
+ var init_open = __esm({
450
+ "../../node_modules/.pnpm/open@11.0.0/node_modules/open/index.js"() {
451
+ "use strict";
452
+ init_wsl_utils();
453
+ init_powershell_utils();
454
+ init_define_lazy_prop();
455
+ init_default_browser();
456
+ init_is_inside_container();
457
+ init_is_in_ssh();
458
+ fallbackAttemptSymbol = Symbol("fallbackAttempt");
459
+ __dirname = import.meta.url ? path2.dirname(fileURLToPath(import.meta.url)) : "";
460
+ localXdgOpenPath = path2.join(__dirname, "xdg-open");
461
+ ({ platform, arch } = process8);
462
+ tryEachApp = async (apps2, opener) => {
463
+ if (apps2.length === 0) {
464
+ return;
465
+ }
466
+ const errors = [];
467
+ for (const app of apps2) {
468
+ try {
469
+ return await opener(app);
470
+ } catch (error) {
471
+ errors.push(error);
472
+ }
473
+ }
474
+ throw new AggregateError(errors, "Failed to open in all supported apps");
475
+ };
476
+ baseOpen = async (options) => {
477
+ options = {
478
+ wait: false,
479
+ background: false,
480
+ newInstance: false,
481
+ allowNonzeroExitCode: false,
482
+ ...options
483
+ };
484
+ const isFallbackAttempt = options[fallbackAttemptSymbol] === true;
485
+ delete options[fallbackAttemptSymbol];
486
+ if (Array.isArray(options.app)) {
487
+ return tryEachApp(options.app, (singleApp) => baseOpen({
488
+ ...options,
489
+ app: singleApp,
490
+ [fallbackAttemptSymbol]: true
491
+ }));
492
+ }
493
+ let { name: app, arguments: appArguments = [] } = options.app ?? {};
494
+ appArguments = [...appArguments];
495
+ if (Array.isArray(app)) {
496
+ return tryEachApp(app, (appName) => baseOpen({
497
+ ...options,
498
+ app: {
499
+ name: appName,
500
+ arguments: appArguments
501
+ },
502
+ [fallbackAttemptSymbol]: true
503
+ }));
504
+ }
505
+ if (app === "browser" || app === "browserPrivate") {
506
+ const ids = {
507
+ "com.google.chrome": "chrome",
508
+ "google-chrome.desktop": "chrome",
509
+ "com.brave.browser": "brave",
510
+ "org.mozilla.firefox": "firefox",
511
+ "firefox.desktop": "firefox",
512
+ "com.microsoft.msedge": "edge",
513
+ "com.microsoft.edge": "edge",
514
+ "com.microsoft.edgemac": "edge",
515
+ "microsoft-edge.desktop": "edge",
516
+ "com.apple.safari": "safari"
517
+ };
518
+ const flags = {
519
+ chrome: "--incognito",
520
+ brave: "--incognito",
521
+ firefox: "--private-window",
522
+ edge: "--inPrivate"
523
+ // Safari doesn't support private mode via command line
524
+ };
525
+ let browser;
526
+ if (is_wsl_default) {
527
+ const progId = await wslDefaultBrowser();
528
+ const browserInfo = _windowsBrowserProgIdMap.get(progId);
529
+ browser = browserInfo ?? {};
530
+ } else {
531
+ browser = await defaultBrowser2();
532
+ }
533
+ if (browser.id in ids) {
534
+ const browserName = ids[browser.id.toLowerCase()];
535
+ if (app === "browserPrivate") {
536
+ if (browserName === "safari") {
537
+ throw new Error("Safari doesn't support opening in private mode via command line");
538
+ }
539
+ appArguments.push(flags[browserName]);
540
+ }
541
+ return baseOpen({
542
+ ...options,
543
+ app: {
544
+ name: apps[browserName],
545
+ arguments: appArguments
546
+ }
547
+ });
548
+ }
549
+ throw new Error(`${browser.name} is not supported as a default browser`);
550
+ }
551
+ let command;
552
+ const cliArguments = [];
553
+ const childProcessOptions = {};
554
+ let shouldUseWindowsInWsl = false;
555
+ if (is_wsl_default && !isInsideContainer() && !is_in_ssh_default && !app) {
556
+ shouldUseWindowsInWsl = await canAccessPowerShell();
557
+ }
558
+ if (platform === "darwin") {
559
+ command = "open";
560
+ if (options.wait) {
561
+ cliArguments.push("--wait-apps");
562
+ }
563
+ if (options.background) {
564
+ cliArguments.push("--background");
565
+ }
566
+ if (options.newInstance) {
567
+ cliArguments.push("--new");
568
+ }
569
+ if (app) {
570
+ cliArguments.push("-a", app);
571
+ }
572
+ } else if (platform === "win32" || shouldUseWindowsInWsl) {
573
+ command = await powerShellPath2();
574
+ cliArguments.push(...executePowerShell.argumentsPrefix);
575
+ if (!is_wsl_default) {
576
+ childProcessOptions.windowsVerbatimArguments = true;
577
+ }
578
+ if (is_wsl_default && options.target) {
579
+ options.target = await convertWslPathToWindows(options.target);
580
+ }
581
+ const encodedArguments = ["$ProgressPreference = 'SilentlyContinue';", "Start"];
582
+ if (options.wait) {
583
+ encodedArguments.push("-Wait");
584
+ }
585
+ if (app) {
586
+ encodedArguments.push(executePowerShell.escapeArgument(app));
587
+ if (options.target) {
588
+ appArguments.push(options.target);
589
+ }
590
+ } else if (options.target) {
591
+ encodedArguments.push(executePowerShell.escapeArgument(options.target));
592
+ }
593
+ if (appArguments.length > 0) {
594
+ appArguments = appArguments.map((argument) => executePowerShell.escapeArgument(argument));
595
+ encodedArguments.push("-ArgumentList", appArguments.join(","));
596
+ }
597
+ options.target = executePowerShell.encodeCommand(encodedArguments.join(" "));
598
+ if (!options.wait) {
599
+ childProcessOptions.stdio = "ignore";
600
+ }
601
+ } else {
602
+ if (app) {
603
+ command = app;
604
+ } else {
605
+ const isBundled = !__dirname || __dirname === "/";
606
+ let exeLocalXdgOpen = false;
607
+ try {
608
+ await fs6.access(localXdgOpenPath, fsConstants3.X_OK);
609
+ exeLocalXdgOpen = true;
610
+ } catch {
611
+ }
612
+ const useSystemXdgOpen = process8.versions.electron ?? (platform === "android" || isBundled || !exeLocalXdgOpen);
613
+ command = useSystemXdgOpen ? "xdg-open" : localXdgOpenPath;
614
+ }
615
+ if (appArguments.length > 0) {
616
+ cliArguments.push(...appArguments);
617
+ }
618
+ if (!options.wait) {
619
+ childProcessOptions.stdio = "ignore";
620
+ childProcessOptions.detached = true;
621
+ }
622
+ }
623
+ if (platform === "darwin" && appArguments.length > 0) {
624
+ cliArguments.push("--args", ...appArguments);
625
+ }
626
+ if (options.target) {
627
+ cliArguments.push(options.target);
628
+ }
629
+ const subprocess = childProcess3.spawn(command, cliArguments, childProcessOptions);
630
+ if (options.wait) {
631
+ return new Promise((resolve, reject) => {
632
+ subprocess.once("error", reject);
633
+ subprocess.once("close", (exitCode) => {
634
+ if (!options.allowNonzeroExitCode && exitCode !== 0) {
635
+ reject(new Error(`Exited with code ${exitCode}`));
636
+ return;
637
+ }
638
+ resolve(subprocess);
639
+ });
640
+ });
641
+ }
642
+ if (isFallbackAttempt) {
643
+ return new Promise((resolve, reject) => {
644
+ subprocess.once("error", reject);
645
+ subprocess.once("spawn", () => {
646
+ subprocess.once("close", (exitCode) => {
647
+ subprocess.off("error", reject);
648
+ if (exitCode !== 0) {
649
+ reject(new Error(`Exited with code ${exitCode}`));
650
+ return;
651
+ }
652
+ subprocess.unref();
653
+ resolve(subprocess);
654
+ });
655
+ });
656
+ });
657
+ }
658
+ subprocess.unref();
659
+ return new Promise((resolve, reject) => {
660
+ subprocess.once("error", reject);
661
+ subprocess.once("spawn", () => {
662
+ subprocess.off("error", reject);
663
+ resolve(subprocess);
664
+ });
665
+ });
666
+ };
667
+ open = (target, options) => {
668
+ if (typeof target !== "string") {
669
+ throw new TypeError("Expected a `target`");
670
+ }
671
+ return baseOpen({
672
+ ...options,
673
+ target
674
+ });
675
+ };
676
+ openApp = (name, options) => {
677
+ if (typeof name !== "string" && !Array.isArray(name)) {
678
+ throw new TypeError("Expected a valid `name`");
679
+ }
680
+ const { arguments: appArguments = [] } = options ?? {};
681
+ if (appArguments !== void 0 && appArguments !== null && !Array.isArray(appArguments)) {
682
+ throw new TypeError("Expected `appArguments` as Array type");
683
+ }
684
+ return baseOpen({
685
+ ...options,
686
+ app: {
687
+ name,
688
+ arguments: appArguments
689
+ }
690
+ });
691
+ };
692
+ apps = {
693
+ browser: "browser",
694
+ browserPrivate: "browserPrivate"
695
+ };
696
+ defineLazyProperty(apps, "chrome", () => detectPlatformBinary({
697
+ darwin: "google chrome",
698
+ win32: "chrome",
699
+ // `chromium-browser` is the older deb package name used by Ubuntu/Debian before snap.
700
+ linux: ["google-chrome", "google-chrome-stable", "chromium", "chromium-browser"]
701
+ }, {
702
+ wsl: {
703
+ ia32: "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe",
704
+ x64: ["/mnt/c/Program Files/Google/Chrome/Application/chrome.exe", "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"]
705
+ }
706
+ }));
707
+ defineLazyProperty(apps, "brave", () => detectPlatformBinary({
708
+ darwin: "brave browser",
709
+ win32: "brave",
710
+ linux: ["brave-browser", "brave"]
711
+ }, {
712
+ wsl: {
713
+ ia32: "/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe",
714
+ x64: ["/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe", "/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe"]
715
+ }
716
+ }));
717
+ defineLazyProperty(apps, "firefox", () => detectPlatformBinary({
718
+ darwin: "firefox",
719
+ win32: String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,
720
+ linux: "firefox"
721
+ }, {
722
+ wsl: "/mnt/c/Program Files/Mozilla Firefox/firefox.exe"
723
+ }));
724
+ defineLazyProperty(apps, "edge", () => detectPlatformBinary({
725
+ darwin: "microsoft edge",
726
+ win32: "msedge",
727
+ linux: ["microsoft-edge", "microsoft-edge-dev"]
728
+ }, {
729
+ wsl: "/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"
730
+ }));
731
+ defineLazyProperty(apps, "safari", () => detectPlatformBinary({
732
+ darwin: "Safari"
733
+ }));
734
+ open_default = open;
735
+ }
736
+ });
2
737
 
3
738
  // ../../src/cli/index.ts
4
739
  import { readFile as readFile2 } from "fs/promises";
@@ -170,6 +905,64 @@ async function fetchConvexToken(session, appUrl) {
170
905
  token: data.token
171
906
  };
172
907
  }
908
+ async function requestDeviceCode(appUrl, clientId) {
909
+ const response = await fetch(buildUrl(appUrl, "/api/auth/device/code"), {
910
+ method: "POST",
911
+ headers: { "content-type": "application/json" },
912
+ body: JSON.stringify({ client_id: clientId })
913
+ });
914
+ if (!response.ok) {
915
+ throw new Error(`Failed to request device code: HTTP ${response.status}`);
916
+ }
917
+ return await response.json();
918
+ }
919
+ async function pollDeviceToken(session, appUrl, deviceCode, clientId, interval, expiresIn) {
920
+ const deadline = Date.now() + expiresIn * 1e3;
921
+ let pollInterval = interval * 1e3;
922
+ while (Date.now() < deadline) {
923
+ await new Promise((resolve) => setTimeout(resolve, pollInterval));
924
+ const { response, session: nextSession } = await authRequest(
925
+ session,
926
+ appUrl,
927
+ "/api/auth/device/token",
928
+ {
929
+ method: "POST",
930
+ body: JSON.stringify({
931
+ grant_type: "urn:ietf:params:oauth:grant-type:device_code",
932
+ device_code: deviceCode,
933
+ client_id: clientId
934
+ })
935
+ }
936
+ );
937
+ session = nextSession;
938
+ if (response.ok) {
939
+ const data = await response.json();
940
+ if (data.access_token) {
941
+ return session;
942
+ }
943
+ }
944
+ let errorData;
945
+ try {
946
+ errorData = await response.json();
947
+ } catch {
948
+ errorData = { error: `HTTP ${response.status}` };
949
+ }
950
+ switch (errorData.error) {
951
+ case "authorization_pending":
952
+ break;
953
+ case "slow_down":
954
+ pollInterval += 5e3;
955
+ break;
956
+ case "access_denied":
957
+ throw new Error("Authorization denied by user.");
958
+ case "expired_token":
959
+ throw new Error("Device code expired. Please try again.");
960
+ default:
961
+ throw new Error(`Device auth error: ${errorData.error}`);
962
+ }
963
+ }
964
+ throw new Error("Device code expired. Please try again.");
965
+ }
173
966
  async function prompt(question) {
174
967
  const value = await text({
175
968
  message: question.replace(/:\s*$/, "")
@@ -404,6 +1197,84 @@ function buildPaginationOptions(limit, cursor) {
404
1197
  function normalizeMatch(value) {
405
1198
  return value?.trim().toLowerCase();
406
1199
  }
1200
+ function parseDate(value) {
1201
+ const ms = Date.parse(value);
1202
+ if (!Number.isFinite(ms)) {
1203
+ throw new Error(`Invalid date: ${value}`);
1204
+ }
1205
+ return ms;
1206
+ }
1207
+ function applyListFilters(items, options) {
1208
+ let result = [...items];
1209
+ if (options.createdAfter) {
1210
+ const threshold = parseDate(options.createdAfter);
1211
+ result = result.filter(
1212
+ (item) => typeof item.createdAt === "number" && item.createdAt >= threshold
1213
+ );
1214
+ }
1215
+ if (options.createdBefore) {
1216
+ const threshold = parseDate(options.createdBefore);
1217
+ result = result.filter(
1218
+ (item) => typeof item.createdAt === "number" && item.createdAt <= threshold
1219
+ );
1220
+ }
1221
+ if (options.updatedAfter) {
1222
+ const threshold = parseDate(options.updatedAfter);
1223
+ result = result.filter(
1224
+ (item) => typeof item.lastEditedAt === "number" && item.lastEditedAt >= threshold
1225
+ );
1226
+ }
1227
+ if (options.updatedBefore) {
1228
+ const threshold = parseDate(options.updatedBefore);
1229
+ result = result.filter(
1230
+ (item) => typeof item.lastEditedAt === "number" && item.lastEditedAt <= threshold
1231
+ );
1232
+ }
1233
+ if (options.sort) {
1234
+ const field = options.sort;
1235
+ const desc = options.order?.toLowerCase() === "desc";
1236
+ result.sort((a, b) => {
1237
+ const aVal = a[field];
1238
+ const bVal = b[field];
1239
+ if (aVal == null && bVal == null) return 0;
1240
+ if (aVal == null) return 1;
1241
+ if (bVal == null) return -1;
1242
+ if (typeof aVal === "number" && typeof bVal === "number")
1243
+ return desc ? bVal - aVal : aVal - bVal;
1244
+ return desc ? String(bVal).localeCompare(String(aVal)) : String(aVal).localeCompare(String(bVal));
1245
+ });
1246
+ }
1247
+ if (options.limit) {
1248
+ const limit = Number(options.limit);
1249
+ if (Number.isFinite(limit) && limit > 0) {
1250
+ result = result.slice(0, limit);
1251
+ }
1252
+ }
1253
+ return result;
1254
+ }
1255
+ function addEntityUrls(items, appUrl, orgSlug, entityType) {
1256
+ return items.map((item) => {
1257
+ let path3;
1258
+ switch (entityType) {
1259
+ case "issues":
1260
+ path3 = `/${orgSlug}/issues/${item.key}`;
1261
+ break;
1262
+ case "projects":
1263
+ path3 = `/${orgSlug}/projects/${item.key}`;
1264
+ break;
1265
+ case "teams":
1266
+ path3 = `/${orgSlug}/teams/${item.key}`;
1267
+ break;
1268
+ case "documents":
1269
+ path3 = `/${orgSlug}/documents/${item.id}`;
1270
+ break;
1271
+ case "folders":
1272
+ path3 = `/${orgSlug}/documents/folders/${item.id}`;
1273
+ break;
1274
+ }
1275
+ return { ...item, url: `${appUrl}${path3}` };
1276
+ });
1277
+ }
407
1278
  function normalizeAppUrl(raw) {
408
1279
  let url = raw.trim();
409
1280
  if (!/^https?:\/\//i.test(url)) {
@@ -700,19 +1571,48 @@ authCommand.command("signup").option("--email <email>", "Email address").option(
700
1571
  runtime.json
701
1572
  );
702
1573
  });
703
- authCommand.command("login [identifier]").option("--password <password>", "Password").action(async (identifier, options, command) => {
1574
+ authCommand.command("login [identifier]").option("--password <password>", "Password (uses device flow if omitted)").action(async (identifier, options, command) => {
704
1575
  const runtime = await getRuntime(command);
705
- const loginId = identifier?.trim() || await prompt("Email or username: ");
706
- const password = options.password?.trim() || await promptSecret("Password: ");
707
1576
  let session = createEmptySession();
708
1577
  session.appUrl = runtime.appUrl;
709
1578
  session.convexUrl = runtime.convexUrl;
710
- session = await loginWithPassword(
711
- session,
712
- runtime.appUrl,
713
- loginId,
714
- password
715
- );
1579
+ const usePassword = Boolean(identifier || options.password);
1580
+ if (usePassword) {
1581
+ const loginId = identifier?.trim() || await prompt("Email or username: ");
1582
+ const password = options.password?.trim() || await promptSecret("Password: ");
1583
+ session = await loginWithPassword(
1584
+ session,
1585
+ runtime.appUrl,
1586
+ loginId,
1587
+ password
1588
+ );
1589
+ } else {
1590
+ const deviceResp = await requestDeviceCode(runtime.appUrl, "vcli");
1591
+ const verifyUrl = `${runtime.appUrl}${deviceResp.verification_uri}?user_code=${deviceResp.user_code}`;
1592
+ console.log();
1593
+ console.log(` Open this URL in your browser to log in:`);
1594
+ console.log();
1595
+ console.log(` ${verifyUrl}`);
1596
+ console.log();
1597
+ console.log(` Or go to ${runtime.appUrl}/device and enter code:`);
1598
+ console.log();
1599
+ console.log(` ${deviceResp.user_code}`);
1600
+ console.log();
1601
+ const open2 = await Promise.resolve().then(() => (init_open(), open_exports)).then((m) => m.default).catch(() => null);
1602
+ if (open2) {
1603
+ await open2(verifyUrl).catch(() => {
1604
+ });
1605
+ }
1606
+ console.log(" Waiting for authorization...");
1607
+ session = await pollDeviceToken(
1608
+ session,
1609
+ runtime.appUrl,
1610
+ deviceResp.device_code,
1611
+ "vcli",
1612
+ deviceResp.interval,
1613
+ deviceResp.expires_in
1614
+ );
1615
+ }
716
1616
  const authState = await fetchAuthSession(session, runtime.appUrl);
717
1617
  session = authState.session;
718
1618
  const client = await createConvexClient(
@@ -1539,13 +2439,14 @@ adminCommand.command("sync-disposable-domains").action(async (_options, command)
1539
2439
  printOutput(result, runtime.json);
1540
2440
  });
1541
2441
  var teamCommand = program.command("team").description("Teams");
1542
- teamCommand.command("list [slug]").option("--limit <n>").action(async (slug, options, command) => {
2442
+ teamCommand.command("list [slug]").option("--limit <n>").option("--created-after <date>", "Filter: created on or after date (ISO)").option("--created-before <date>", "Filter: created on or before date (ISO)").option("--sort <field>", "Sort by field (e.g. createdAt, name, key)").option("--order <direction>", "Sort order: asc or desc (default: asc)").action(async (slug, options, command) => {
1543
2443
  const { client, runtime } = await getClient(command);
1544
2444
  const orgSlug = requireOrg(runtime, slug);
1545
- const result = await runAction(client, cliApi.listTeams, {
1546
- orgSlug,
1547
- limit: options.limit ? Number(options.limit) : void 0
2445
+ const raw = await runAction(client, cliApi.listTeams, {
2446
+ orgSlug
1548
2447
  });
2448
+ const filtered = applyListFilters(raw, options);
2449
+ const result = addEntityUrls(filtered, runtime.appUrl, orgSlug, "teams");
1549
2450
  printOutput(result, runtime.json);
1550
2451
  });
1551
2452
  teamCommand.command("get <teamKey>").action(async (teamKey, _options, command) => {
@@ -1639,14 +2540,15 @@ teamCommand.command("set-lead <teamKey> <member>").action(async (teamKey, member
1639
2540
  printOutput(result, runtime.json);
1640
2541
  });
1641
2542
  var projectCommand = program.command("project").description("Projects");
1642
- projectCommand.command("list [slug]").option("--team <teamKey>").option("--limit <n>").action(async (slug, options, command) => {
2543
+ projectCommand.command("list [slug]").option("--team <teamKey>").option("--limit <n>").option("--created-after <date>", "Filter: created on or after date (ISO)").option("--created-before <date>", "Filter: created on or before date (ISO)").option("--sort <field>", "Sort by field (e.g. createdAt, name, key)").option("--order <direction>", "Sort order: asc or desc (default: asc)").action(async (slug, options, command) => {
1643
2544
  const { client, runtime } = await getClient(command);
1644
2545
  const orgSlug = requireOrg(runtime, slug);
1645
- const result = await runAction(client, cliApi.listProjects, {
2546
+ const raw = await runAction(client, cliApi.listProjects, {
1646
2547
  orgSlug,
1647
- teamKey: options.team,
1648
- limit: options.limit ? Number(options.limit) : void 0
2548
+ teamKey: options.team
1649
2549
  });
2550
+ const filtered = applyListFilters(raw, options);
2551
+ const result = addEntityUrls(filtered, runtime.appUrl, orgSlug, "projects");
1650
2552
  printOutput(result, runtime.json);
1651
2553
  });
1652
2554
  projectCommand.command("get <projectKey>").action(async (projectKey, _options, command) => {
@@ -1746,15 +2648,16 @@ projectCommand.command("set-lead <projectKey> <member>").action(async (projectKe
1746
2648
  printOutput(result, runtime.json);
1747
2649
  });
1748
2650
  var issueCommand = program.command("issue").description("Issues");
1749
- issueCommand.command("list [slug]").option("--project <projectKey>").option("--team <teamKey>").option("--limit <n>").action(async (slug, options, command) => {
2651
+ issueCommand.command("list [slug]").option("--project <projectKey>").option("--team <teamKey>").option("--limit <n>").option("--created-after <date>", "Filter: created on or after date (ISO)").option("--created-before <date>", "Filter: created on or before date (ISO)").option("--sort <field>", "Sort by field (e.g. createdAt, title, key)").option("--order <direction>", "Sort order: asc or desc (default: asc)").action(async (slug, options, command) => {
1750
2652
  const { client, runtime } = await getClient(command);
1751
2653
  const orgSlug = requireOrg(runtime, slug);
1752
- const result = await runAction(client, cliApi.listIssues, {
2654
+ const raw = await runAction(client, cliApi.listIssues, {
1753
2655
  orgSlug,
1754
2656
  projectKey: options.project,
1755
- teamKey: options.team,
1756
- limit: options.limit ? Number(options.limit) : void 0
2657
+ teamKey: options.team
1757
2658
  });
2659
+ const filtered = applyListFilters(raw, options);
2660
+ const result = addEntityUrls(filtered, runtime.appUrl, orgSlug, "issues");
1758
2661
  printOutput(result, runtime.json);
1759
2662
  });
1760
2663
  issueCommand.command("get <issueKey>").action(async (issueKey, _options, command) => {
@@ -1952,14 +2855,29 @@ issueCommand.command("comment <issueKey>").requiredOption("--body <body>").actio
1952
2855
  printOutput(result, runtime.json);
1953
2856
  });
1954
2857
  var documentCommand = program.command("document").description("Documents");
1955
- documentCommand.command("list [slug]").option("--folder-id <id>").option("--limit <n>").action(async (slug, options, command) => {
2858
+ documentCommand.command("list [slug]").option("--folder-id <id>").option("--limit <n>").option("--created-after <date>", "Filter: created on or after date (ISO)").option("--created-before <date>", "Filter: created on or before date (ISO)").option(
2859
+ "--updated-after <date>",
2860
+ "Filter: last edited on or after date (ISO)"
2861
+ ).option(
2862
+ "--updated-before <date>",
2863
+ "Filter: last edited on or before date (ISO)"
2864
+ ).option(
2865
+ "--sort <field>",
2866
+ "Sort by field (e.g. createdAt, title, lastEditedAt)"
2867
+ ).option("--order <direction>", "Sort order: asc or desc (default: asc)").action(async (slug, options, command) => {
1956
2868
  const { client, runtime } = await getClient(command);
1957
2869
  const orgSlug = requireOrg(runtime, slug);
1958
- const result = await runAction(client, cliApi.listDocuments, {
2870
+ const raw = await runAction(client, cliApi.listDocuments, {
1959
2871
  orgSlug,
1960
- folderId: options.folderId,
1961
- limit: options.limit ? Number(options.limit) : void 0
2872
+ folderId: options.folderId
1962
2873
  });
2874
+ const filtered = applyListFilters(raw, options);
2875
+ const result = addEntityUrls(
2876
+ filtered,
2877
+ runtime.appUrl,
2878
+ orgSlug,
2879
+ "documents"
2880
+ );
1963
2881
  printOutput(result, runtime.json);
1964
2882
  });
1965
2883
  documentCommand.command("get <documentId>").action(async (documentId, _options, command) => {
@@ -2025,10 +2943,12 @@ documentCommand.command("delete <documentId>").action(async (documentId, _option
2025
2943
  printOutput(result, runtime.json);
2026
2944
  });
2027
2945
  var folderCommand = program.command("folder").description("Document folders");
2028
- folderCommand.command("list [slug]").action(async (slug, _options, command) => {
2946
+ folderCommand.command("list [slug]").option("--limit <n>").option("--created-after <date>", "Filter: created on or after date (ISO)").option("--created-before <date>", "Filter: created on or before date (ISO)").option("--sort <field>", "Sort by field (e.g. createdAt, name)").option("--order <direction>", "Sort order: asc or desc (default: asc)").action(async (slug, options, command) => {
2029
2947
  const { client, runtime } = await getClient(command);
2030
2948
  const orgSlug = requireOrg(runtime, slug);
2031
- const result = await runAction(client, cliApi.listFolders, { orgSlug });
2949
+ const raw = await runAction(client, cliApi.listFolders, { orgSlug });
2950
+ const filtered = applyListFilters(raw, options);
2951
+ const result = addEntityUrls(filtered, runtime.appUrl, orgSlug, "folders");
2032
2952
  printOutput(result, runtime.json);
2033
2953
  });
2034
2954
  folderCommand.command("create").requiredOption("--name <name>").option("--description <description>").option("--icon <icon>").option("--color <color>").action(async (options, command) => {