@divergeai/cli 0.1.3 → 0.1.5
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 +17 -5
- 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.5" : "dev";
|
|
7391
7391
|
var USER_AGENT = `diverge/${VERSION}`;
|
|
7392
7392
|
|
|
7393
7393
|
// src/http.ts
|
|
@@ -7436,11 +7436,23 @@ async function fetchJson(url, init = {}) {
|
|
|
7436
7436
|
|
|
7437
7437
|
// src/auth/browser.ts
|
|
7438
7438
|
import { spawn } from "node:child_process";
|
|
7439
|
-
function
|
|
7439
|
+
function openerCommand(url, env = process.env, platform = process.platform) {
|
|
7440
7440
|
const custom = env.BROWSER?.trim();
|
|
7441
|
-
|
|
7441
|
+
if (custom) return { command: custom, args: [url] };
|
|
7442
|
+
if (platform === "darwin") return { command: "open", args: [url] };
|
|
7443
|
+
if (platform === "win32") {
|
|
7444
|
+
return { command: "cmd", args: ["/c", "start", '""', `"${url.replace(/&/g, "^&")}"`], windowsVerbatimArguments: true };
|
|
7445
|
+
}
|
|
7446
|
+
return { command: "xdg-open", args: [url] };
|
|
7447
|
+
}
|
|
7448
|
+
function openBrowser(url, env = process.env, platform = process.platform) {
|
|
7449
|
+
const opener = openerCommand(url, env, platform);
|
|
7442
7450
|
try {
|
|
7443
|
-
const child = spawn(command, args, {
|
|
7451
|
+
const child = spawn(opener.command, opener.args, {
|
|
7452
|
+
detached: true,
|
|
7453
|
+
stdio: "ignore",
|
|
7454
|
+
...opener.windowsVerbatimArguments ? { windowsVerbatimArguments: true } : {}
|
|
7455
|
+
});
|
|
7444
7456
|
child.on("error", () => {
|
|
7445
7457
|
});
|
|
7446
7458
|
child.unref();
|
|
@@ -8476,7 +8488,7 @@ async function runLogin(args, io) {
|
|
|
8476
8488
|
const remaining = Math.max(0, Math.round(bound.token.expires_at - Date.now() / 1e3));
|
|
8477
8489
|
io.stdout(`Logged in to ${apiUrl}; token cached (${remaining}s to expiry, auto-refreshes).`);
|
|
8478
8490
|
writeConfig({ ...readConfig(io.env), account: info.email, scopes, organization: bound.organizationId }, io.env);
|
|
8479
|
-
const granted = new Set(
|
|
8491
|
+
const granted = new Set(tokenClaims(bound.token.access_token).scopes ?? []);
|
|
8480
8492
|
const missing = scopes.split(" ").filter((scope) => scope && !granted.has(scope));
|
|
8481
8493
|
if (missing.length) io.stderr(`Not granted at this organization (your roles lack them): ${missing.join(" ")}`);
|
|
8482
8494
|
return 0;
|