@odla-ai/cli 0.20.2 → 0.21.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/dist/bin.cjs +15 -17
- package/dist/bin.cjs.map +1 -1
- package/dist/bin.js +1 -1
- package/dist/{chunk-XBPDHNWO.js → chunk-CZSQ443A.js} +16 -18
- package/dist/chunk-CZSQ443A.js.map +1 -0
- package/dist/index.cjs +15 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-XBPDHNWO.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -116,7 +116,7 @@ function approvalLines(prompt) {
|
|
|
116
116
|
return lines;
|
|
117
117
|
}
|
|
118
118
|
function printApproval(out, prompt) {
|
|
119
|
-
for (const line of approvalLines(prompt)) out.
|
|
119
|
+
for (const line of approvalLines(prompt)) out.error(line);
|
|
120
120
|
}
|
|
121
121
|
function reminderLines(prompt) {
|
|
122
122
|
return [
|
|
@@ -336,7 +336,7 @@ async function getDeveloperToken(cfg, options, doFetch, out) {
|
|
|
336
336
|
}
|
|
337
337
|
const cached = readJsonFile(cfg.local.tokenFile);
|
|
338
338
|
if (cached?.token && cached.platform === audience && (cached.expiresAt ?? 0) > Date.now() + 6e4) {
|
|
339
|
-
out.
|
|
339
|
+
out.error(`auth: using cached developer token (${displayPath(cfg.local.tokenFile, cfg.rootDir)})`);
|
|
340
340
|
return cached.token;
|
|
341
341
|
}
|
|
342
342
|
const ctx = {
|
|
@@ -353,16 +353,16 @@ async function getDeveloperToken(cfg, options, doFetch, out) {
|
|
|
353
353
|
const { token, expiresAt } = await resumePendingHandshake(ctx, waitMs) ?? await freshHandshake(ctx, waitMs);
|
|
354
354
|
clearPendingHandshake(ctx.pendingFile);
|
|
355
355
|
writePrivateJson(cfg.local.tokenFile, { platform: audience, email: ctx.email, token, expiresAt });
|
|
356
|
-
out.
|
|
356
|
+
out.error(`auth: developer token cached (${displayPath(cfg.local.tokenFile, cfg.rootDir)})`);
|
|
357
357
|
return token;
|
|
358
358
|
}
|
|
359
359
|
async function resumePendingHandshake(ctx, waitMs) {
|
|
360
360
|
const pending = readPendingHandshake(ctx.pendingFile, ctx.audience, ctx.email);
|
|
361
361
|
if (!pending) return null;
|
|
362
|
-
ctx.out.
|
|
363
|
-
ctx.out.
|
|
362
|
+
ctx.out.error("");
|
|
363
|
+
ctx.out.error(`auth: resuming pending handshake \u2014 ${approvalHint(pending)}`);
|
|
364
364
|
await launchApproval(ctx, pending.approvalUrl);
|
|
365
|
-
ctx.out.
|
|
365
|
+
ctx.out.error("");
|
|
366
366
|
const stopReminder = approvalReminder(ctx.out, pending);
|
|
367
367
|
try {
|
|
368
368
|
return await (0, import_db.collectToken)({
|
|
@@ -378,7 +378,7 @@ async function resumePendingHandshake(ctx, waitMs) {
|
|
|
378
378
|
if (code === "handshake_pending") throw stillPending(pending, ctx.email);
|
|
379
379
|
if (code === "handshake_expired" || code === "handshake_timeout") {
|
|
380
380
|
clearPendingHandshake(ctx.pendingFile);
|
|
381
|
-
ctx.out.
|
|
381
|
+
ctx.out.error("auth: pending handshake lapsed unapproved; starting a fresh one");
|
|
382
382
|
return null;
|
|
383
383
|
}
|
|
384
384
|
if (code === "handshake_denied") clearPendingHandshake(ctx.pendingFile);
|
|
@@ -436,12 +436,12 @@ async function launchApproval(ctx, approvalUrl) {
|
|
|
436
436
|
if (ctx.browser.open) {
|
|
437
437
|
try {
|
|
438
438
|
await (ctx.options.openApprovalUrl ?? openUrl)(approvalUrl);
|
|
439
|
-
ctx.out.
|
|
439
|
+
ctx.out.error(`auth: asked the OS to open a browser${ctx.browser.mode === "auto" ? " (auto)" : ""} \u2014 if no tab appeared, use the URL above`);
|
|
440
440
|
} catch (err) {
|
|
441
|
-
ctx.out.
|
|
441
|
+
ctx.out.error(`auth: could not open browser (${err instanceof Error ? err.message : String(err)})`);
|
|
442
442
|
}
|
|
443
443
|
} else if (ctx.browser.reason) {
|
|
444
|
-
ctx.out.
|
|
444
|
+
ctx.out.error(`auth: browser launch skipped (${ctx.browser.reason}) \u2014 show the human the URL above`);
|
|
445
445
|
}
|
|
446
446
|
}
|
|
447
447
|
function stillPending(pending, email) {
|
|
@@ -566,7 +566,7 @@ async function scopedToken(platform, scope, options, doFetch, out) {
|
|
|
566
566
|
const cache = options.cache === false ? null : readJsonFile(tokenFile);
|
|
567
567
|
const cached = cache?.platform === audience ? cache.tokens?.[scope] : void 0;
|
|
568
568
|
if (cached?.token && (cached.expiresAt ?? 0) > Date.now() + 6e4) {
|
|
569
|
-
out.
|
|
569
|
+
out.error(`auth: using cached ${scope} grant (${tokenFile})`);
|
|
570
570
|
return cached.token;
|
|
571
571
|
}
|
|
572
572
|
const email = handshakeEmail(options.email, cache?.platform === audience ? cache.email : void 0);
|
|
@@ -597,9 +597,9 @@ async function scopedToken(platform, scope, options, doFetch, out) {
|
|
|
597
597
|
tokens[scope] = { token, expiresAt };
|
|
598
598
|
if ((0, import_node_fs3.existsSync)((0, import_node_path3.join)(rootDir, ".git"))) ensureGitignore(rootDir, [tokenFile]);
|
|
599
599
|
writePrivateJson(tokenFile, { platform: audience, email, tokens });
|
|
600
|
-
out.
|
|
600
|
+
out.error(`auth: cached ${scope} grant (${tokenFile}; mode 0600)`);
|
|
601
601
|
} else {
|
|
602
|
-
out.
|
|
602
|
+
out.error(`auth: ${scope} grant is in memory only; its credential record remains in odla-ai/db`);
|
|
603
603
|
}
|
|
604
604
|
return token;
|
|
605
605
|
}
|
|
@@ -8779,13 +8779,11 @@ async function loadOrDefaultConfig(configPath, action, appId) {
|
|
|
8779
8779
|
}
|
|
8780
8780
|
return loadProjectConfig(configPath);
|
|
8781
8781
|
}
|
|
8782
|
-
var PURE_STDOUT = /* @__PURE__ */ new Set(["get", "cat"]);
|
|
8783
8782
|
async function buildContext2(parsed, deps, action) {
|
|
8784
8783
|
const configPath = stringOpt(parsed.options.config) ?? "odla.config.mjs";
|
|
8785
8784
|
const cfg = await loadOrDefaultConfig(configPath, action, stringOpt(parsed.options.app));
|
|
8786
8785
|
const doFetch = deps.fetch ?? fetch;
|
|
8787
8786
|
const out = deps.stdout ?? console;
|
|
8788
|
-
const authOut = PURE_STDOUT.has(action) ? { log: (line) => out.error(line), error: (line) => out.error(line) } : out;
|
|
8789
8787
|
const appId = stringOpt(parsed.options.app) ?? PLATFORM_SCOPE;
|
|
8790
8788
|
const dryRun = parsed.options["dry-run"] === true;
|
|
8791
8789
|
if (action === "import" && dryRun) {
|
|
@@ -8805,7 +8803,7 @@ async function buildContext2(parsed, deps, action) {
|
|
|
8805
8803
|
email: stringOpt(parsed.options.email),
|
|
8806
8804
|
label: `odla CLI (runbook ${action})`,
|
|
8807
8805
|
fetch: doFetch,
|
|
8808
|
-
stdout:
|
|
8806
|
+
stdout: out,
|
|
8809
8807
|
openApprovalUrl: deps.openUrl,
|
|
8810
8808
|
// Anchor the grant cache to this project, not the shell's cwd.
|
|
8811
8809
|
rootDir: cfg.rootDir
|
|
@@ -8822,7 +8820,7 @@ async function buildContext2(parsed, deps, action) {
|
|
|
8822
8820
|
open: void 0
|
|
8823
8821
|
},
|
|
8824
8822
|
doFetch,
|
|
8825
|
-
|
|
8823
|
+
out
|
|
8826
8824
|
);
|
|
8827
8825
|
return {
|
|
8828
8826
|
platformUrl: cfg.platformUrl,
|