@odla-ai/cli 0.20.1 → 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 CHANGED
@@ -57,7 +57,7 @@ function approvalLines(prompt) {
57
57
  return lines;
58
58
  }
59
59
  function printApproval(out, prompt) {
60
- for (const line of approvalLines(prompt)) out.log(line);
60
+ for (const line of approvalLines(prompt)) out.error(line);
61
61
  }
62
62
  function reminderLines(prompt) {
63
63
  return [
@@ -277,7 +277,7 @@ async function getDeveloperToken(cfg, options, doFetch, out) {
277
277
  }
278
278
  const cached = readJsonFile(cfg.local.tokenFile);
279
279
  if (cached?.token && cached.platform === audience && (cached.expiresAt ?? 0) > Date.now() + 6e4) {
280
- out.log(`auth: using cached developer token (${displayPath(cfg.local.tokenFile, cfg.rootDir)})`);
280
+ out.error(`auth: using cached developer token (${displayPath(cfg.local.tokenFile, cfg.rootDir)})`);
281
281
  return cached.token;
282
282
  }
283
283
  const ctx = {
@@ -294,16 +294,16 @@ async function getDeveloperToken(cfg, options, doFetch, out) {
294
294
  const { token, expiresAt } = await resumePendingHandshake(ctx, waitMs) ?? await freshHandshake(ctx, waitMs);
295
295
  clearPendingHandshake(ctx.pendingFile);
296
296
  writePrivateJson(cfg.local.tokenFile, { platform: audience, email: ctx.email, token, expiresAt });
297
- out.log(`auth: developer token cached (${displayPath(cfg.local.tokenFile, cfg.rootDir)})`);
297
+ out.error(`auth: developer token cached (${displayPath(cfg.local.tokenFile, cfg.rootDir)})`);
298
298
  return token;
299
299
  }
300
300
  async function resumePendingHandshake(ctx, waitMs) {
301
301
  const pending = readPendingHandshake(ctx.pendingFile, ctx.audience, ctx.email);
302
302
  if (!pending) return null;
303
- ctx.out.log("");
304
- ctx.out.log(`auth: resuming pending handshake \u2014 ${approvalHint(pending)}`);
303
+ ctx.out.error("");
304
+ ctx.out.error(`auth: resuming pending handshake \u2014 ${approvalHint(pending)}`);
305
305
  await launchApproval(ctx, pending.approvalUrl);
306
- ctx.out.log("");
306
+ ctx.out.error("");
307
307
  const stopReminder = approvalReminder(ctx.out, pending);
308
308
  try {
309
309
  return await (0, import_db.collectToken)({
@@ -319,7 +319,7 @@ async function resumePendingHandshake(ctx, waitMs) {
319
319
  if (code === "handshake_pending") throw stillPending(pending, ctx.email);
320
320
  if (code === "handshake_expired" || code === "handshake_timeout") {
321
321
  clearPendingHandshake(ctx.pendingFile);
322
- ctx.out.log("auth: pending handshake lapsed unapproved; starting a fresh one");
322
+ ctx.out.error("auth: pending handshake lapsed unapproved; starting a fresh one");
323
323
  return null;
324
324
  }
325
325
  if (code === "handshake_denied") clearPendingHandshake(ctx.pendingFile);
@@ -377,12 +377,12 @@ async function launchApproval(ctx, approvalUrl) {
377
377
  if (ctx.browser.open) {
378
378
  try {
379
379
  await (ctx.options.openApprovalUrl ?? openUrl)(approvalUrl);
380
- ctx.out.log(`auth: asked the OS to open a browser${ctx.browser.mode === "auto" ? " (auto)" : ""} \u2014 if no tab appeared, use the URL above`);
380
+ 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`);
381
381
  } catch (err) {
382
- ctx.out.log(`auth: could not open browser (${err instanceof Error ? err.message : String(err)})`);
382
+ ctx.out.error(`auth: could not open browser (${err instanceof Error ? err.message : String(err)})`);
383
383
  }
384
384
  } else if (ctx.browser.reason) {
385
- ctx.out.log(`auth: browser launch skipped (${ctx.browser.reason}) \u2014 show the human the URL above`);
385
+ ctx.out.error(`auth: browser launch skipped (${ctx.browser.reason}) \u2014 show the human the URL above`);
386
386
  }
387
387
  }
388
388
  function stillPending(pending, email) {
@@ -507,7 +507,7 @@ async function scopedToken(platform, scope, options, doFetch, out) {
507
507
  const cache = options.cache === false ? null : readJsonFile(tokenFile);
508
508
  const cached = cache?.platform === audience ? cache.tokens?.[scope] : void 0;
509
509
  if (cached?.token && (cached.expiresAt ?? 0) > Date.now() + 6e4) {
510
- out.log(`auth: using cached ${scope} grant (${tokenFile})`);
510
+ out.error(`auth: using cached ${scope} grant (${tokenFile})`);
511
511
  return cached.token;
512
512
  }
513
513
  const email = handshakeEmail(options.email, cache?.platform === audience ? cache.email : void 0);
@@ -538,9 +538,9 @@ async function scopedToken(platform, scope, options, doFetch, out) {
538
538
  tokens[scope] = { token, expiresAt };
539
539
  if ((0, import_node_fs3.existsSync)((0, import_node_path3.join)(rootDir, ".git"))) ensureGitignore(rootDir, [tokenFile]);
540
540
  writePrivateJson(tokenFile, { platform: audience, email, tokens });
541
- out.log(`auth: cached ${scope} grant (${tokenFile}; mode 0600)`);
541
+ out.error(`auth: cached ${scope} grant (${tokenFile}; mode 0600)`);
542
542
  } else {
543
- out.log(`auth: ${scope} grant is in memory only; its credential record remains in odla-ai/db`);
543
+ out.error(`auth: ${scope} grant is in memory only; its credential record remains in odla-ai/db`);
544
544
  }
545
545
  return token;
546
546
  }
@@ -8711,13 +8711,11 @@ async function loadOrDefaultConfig(configPath, action, appId) {
8711
8711
  }
8712
8712
  return loadProjectConfig(configPath);
8713
8713
  }
8714
- var PURE_STDOUT = /* @__PURE__ */ new Set(["get", "cat"]);
8715
8714
  async function buildContext2(parsed, deps, action) {
8716
8715
  const configPath = stringOpt(parsed.options.config) ?? "odla.config.mjs";
8717
8716
  const cfg = await loadOrDefaultConfig(configPath, action, stringOpt(parsed.options.app));
8718
8717
  const doFetch = deps.fetch ?? fetch;
8719
8718
  const out = deps.stdout ?? console;
8720
- const authOut = PURE_STDOUT.has(action) ? { log: (line) => out.error(line), error: (line) => out.error(line) } : out;
8721
8719
  const appId = stringOpt(parsed.options.app) ?? PLATFORM_SCOPE;
8722
8720
  const dryRun = parsed.options["dry-run"] === true;
8723
8721
  if (action === "import" && dryRun) {
@@ -8737,7 +8735,7 @@ async function buildContext2(parsed, deps, action) {
8737
8735
  email: stringOpt(parsed.options.email),
8738
8736
  label: `odla CLI (runbook ${action})`,
8739
8737
  fetch: doFetch,
8740
- stdout: authOut,
8738
+ stdout: out,
8741
8739
  openApprovalUrl: deps.openUrl,
8742
8740
  // Anchor the grant cache to this project, not the shell's cwd.
8743
8741
  rootDir: cfg.rootDir
@@ -8754,7 +8752,7 @@ async function buildContext2(parsed, deps, action) {
8754
8752
  open: void 0
8755
8753
  },
8756
8754
  doFetch,
8757
- authOut
8755
+ out
8758
8756
  );
8759
8757
  return {
8760
8758
  platformUrl: cfg.platformUrl,