@divergeai/cli 0.1.7 → 0.1.9
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/diverge.mjs +20 -7
- package/package.json +1 -1
package/dist/diverge.mjs
CHANGED
|
@@ -7387,7 +7387,7 @@ import path10 from "node:path";
|
|
|
7387
7387
|
import { parseArgs } from "node:util";
|
|
7388
7388
|
|
|
7389
7389
|
// src/version.ts
|
|
7390
|
-
var VERSION = true ? "0.1.
|
|
7390
|
+
var VERSION = true ? "0.1.9" : "dev";
|
|
7391
7391
|
var USER_AGENT = `diverge/${VERSION}`;
|
|
7392
7392
|
|
|
7393
7393
|
// src/http.ts
|
|
@@ -7451,19 +7451,27 @@ function openerCommand(url, env = process.env, platform = process.platform) {
|
|
|
7451
7451
|
}
|
|
7452
7452
|
return { command: "xdg-open", args: [url] };
|
|
7453
7453
|
}
|
|
7454
|
-
function openBrowser(url, env = process.env, platform = process.platform) {
|
|
7454
|
+
function openBrowser(url, env = process.env, platform = process.platform, report = () => {
|
|
7455
|
+
}) {
|
|
7455
7456
|
const opener = openerCommand(url, env, platform);
|
|
7457
|
+
if (!env.BROWSER?.trim() && platform !== "darwin" && platform !== "win32" && !env.DISPLAY?.trim() && !env.WAYLAND_DISPLAY?.trim()) {
|
|
7458
|
+
report("this shell has no display (DISPLAY and WAYLAND_DISPLAY are unset)");
|
|
7459
|
+
return false;
|
|
7460
|
+
}
|
|
7456
7461
|
try {
|
|
7457
7462
|
const child = spawn(opener.command, opener.args, {
|
|
7458
7463
|
detached: true,
|
|
7459
7464
|
stdio: "ignore",
|
|
7460
7465
|
...opener.windowsVerbatimArguments ? { windowsVerbatimArguments: true } : {}
|
|
7461
7466
|
});
|
|
7462
|
-
child.on("error", () => {
|
|
7467
|
+
child.on("error", (error) => report(`${opener.command}: ${error.code === "ENOENT" ? "not found" : error.message}`));
|
|
7468
|
+
child.on("exit", (code2) => {
|
|
7469
|
+
if (code2) report(`${opener.command} exited with code ${code2}`);
|
|
7463
7470
|
});
|
|
7464
7471
|
child.unref();
|
|
7465
7472
|
return true;
|
|
7466
|
-
} catch {
|
|
7473
|
+
} catch (error) {
|
|
7474
|
+
report(`${opener.command}: ${error instanceof Error ? error.message : String(error)}`);
|
|
7467
7475
|
return false;
|
|
7468
7476
|
}
|
|
7469
7477
|
}
|
|
@@ -7668,7 +7676,11 @@ function cachedFrom(payload, baseUrl, previousRefresh, nowMs) {
|
|
|
7668
7676
|
base_url: baseUrl.replace(/\/+$/, "")
|
|
7669
7677
|
};
|
|
7670
7678
|
}
|
|
7671
|
-
var defaultDeps = {
|
|
7679
|
+
var defaultDeps = {
|
|
7680
|
+
startLoopback,
|
|
7681
|
+
openBrowser: (url, report) => openBrowser(url, process.env, process.platform, report),
|
|
7682
|
+
now: Date.now
|
|
7683
|
+
};
|
|
7672
7684
|
async function login(options, deps = defaultDeps) {
|
|
7673
7685
|
const verifier = generateVerifier();
|
|
7674
7686
|
const state = generateState();
|
|
@@ -7686,7 +7698,7 @@ async function login(options, deps = defaultDeps) {
|
|
|
7686
7698
|
loginHint: options.loginHint
|
|
7687
7699
|
});
|
|
7688
7700
|
const pending = loopback.waitForCode(state, options.timeoutMs);
|
|
7689
|
-
if (options.openBrowser) deps.openBrowser(authorizeUrl);
|
|
7701
|
+
if (options.openBrowser) deps.openBrowser(authorizeUrl, (reason) => options.print(`Could not open a browser (${reason}); paste the URL below into one.`));
|
|
7690
7702
|
options.print("Open this URL to sign in:");
|
|
7691
7703
|
options.print(` ${authorizeUrl}`);
|
|
7692
7704
|
const code2 = await pending;
|
|
@@ -8041,7 +8053,8 @@ import fs4 from "node:fs";
|
|
|
8041
8053
|
import path7 from "node:path";
|
|
8042
8054
|
function findOnPath(name, env = process.env, platform = process.platform) {
|
|
8043
8055
|
const dirs = (env.PATH ?? "").split(path7.delimiter).filter(Boolean);
|
|
8044
|
-
const
|
|
8056
|
+
const extensions = (env.PATHEXT || ".COM;.EXE;.BAT;.CMD").split(";").filter(Boolean);
|
|
8057
|
+
const candidates = platform === "win32" ? extensions.map((extension) => `${name}${extension.toLowerCase()}`) : [name];
|
|
8045
8058
|
for (const dir of dirs) {
|
|
8046
8059
|
for (const candidate of candidates) {
|
|
8047
8060
|
const full = path7.join(dir, candidate);
|