@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.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  exitCodeFor,
4
4
  runCli
5
- } from "./chunk-XBPDHNWO.js";
5
+ } from "./chunk-CZSQ443A.js";
6
6
 
7
7
  // src/bin.ts
8
8
  runCli().catch((err) => {
@@ -179,7 +179,7 @@ function approvalLines(prompt) {
179
179
  return lines;
180
180
  }
181
181
  function printApproval(out, prompt) {
182
- for (const line of approvalLines(prompt)) out.log(line);
182
+ for (const line of approvalLines(prompt)) out.error(line);
183
183
  }
184
184
  function reminderLines(prompt) {
185
185
  return [
@@ -251,7 +251,7 @@ async function getDeveloperToken(cfg, options, doFetch, out) {
251
251
  }
252
252
  const cached = readJsonFile(cfg.local.tokenFile);
253
253
  if (cached?.token && cached.platform === audience && (cached.expiresAt ?? 0) > Date.now() + 6e4) {
254
- out.log(`auth: using cached developer token (${displayPath(cfg.local.tokenFile, cfg.rootDir)})`);
254
+ out.error(`auth: using cached developer token (${displayPath(cfg.local.tokenFile, cfg.rootDir)})`);
255
255
  return cached.token;
256
256
  }
257
257
  const ctx = {
@@ -268,16 +268,16 @@ async function getDeveloperToken(cfg, options, doFetch, out) {
268
268
  const { token, expiresAt } = await resumePendingHandshake(ctx, waitMs) ?? await freshHandshake(ctx, waitMs);
269
269
  clearPendingHandshake(ctx.pendingFile);
270
270
  writePrivateJson(cfg.local.tokenFile, { platform: audience, email: ctx.email, token, expiresAt });
271
- out.log(`auth: developer token cached (${displayPath(cfg.local.tokenFile, cfg.rootDir)})`);
271
+ out.error(`auth: developer token cached (${displayPath(cfg.local.tokenFile, cfg.rootDir)})`);
272
272
  return token;
273
273
  }
274
274
  async function resumePendingHandshake(ctx, waitMs) {
275
275
  const pending = readPendingHandshake(ctx.pendingFile, ctx.audience, ctx.email);
276
276
  if (!pending) return null;
277
- ctx.out.log("");
278
- ctx.out.log(`auth: resuming pending handshake \u2014 ${approvalHint(pending)}`);
277
+ ctx.out.error("");
278
+ ctx.out.error(`auth: resuming pending handshake \u2014 ${approvalHint(pending)}`);
279
279
  await launchApproval(ctx, pending.approvalUrl);
280
- ctx.out.log("");
280
+ ctx.out.error("");
281
281
  const stopReminder = approvalReminder(ctx.out, pending);
282
282
  try {
283
283
  return await collectToken({
@@ -293,7 +293,7 @@ async function resumePendingHandshake(ctx, waitMs) {
293
293
  if (code === "handshake_pending") throw stillPending(pending, ctx.email);
294
294
  if (code === "handshake_expired" || code === "handshake_timeout") {
295
295
  clearPendingHandshake(ctx.pendingFile);
296
- ctx.out.log("auth: pending handshake lapsed unapproved; starting a fresh one");
296
+ ctx.out.error("auth: pending handshake lapsed unapproved; starting a fresh one");
297
297
  return null;
298
298
  }
299
299
  if (code === "handshake_denied") clearPendingHandshake(ctx.pendingFile);
@@ -351,12 +351,12 @@ async function launchApproval(ctx, approvalUrl) {
351
351
  if (ctx.browser.open) {
352
352
  try {
353
353
  await (ctx.options.openApprovalUrl ?? openUrl)(approvalUrl);
354
- 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`);
354
+ 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`);
355
355
  } catch (err) {
356
- ctx.out.log(`auth: could not open browser (${err instanceof Error ? err.message : String(err)})`);
356
+ ctx.out.error(`auth: could not open browser (${err instanceof Error ? err.message : String(err)})`);
357
357
  }
358
358
  } else if (ctx.browser.reason) {
359
- ctx.out.log(`auth: browser launch skipped (${ctx.browser.reason}) \u2014 show the human the URL above`);
359
+ ctx.out.error(`auth: browser launch skipped (${ctx.browser.reason}) \u2014 show the human the URL above`);
360
360
  }
361
361
  }
362
362
  function stillPending(pending, email) {
@@ -454,7 +454,7 @@ async function scopedToken(platform, scope, options, doFetch, out) {
454
454
  const cache = options.cache === false ? null : readJsonFile(tokenFile);
455
455
  const cached = cache?.platform === audience ? cache.tokens?.[scope] : void 0;
456
456
  if (cached?.token && (cached.expiresAt ?? 0) > Date.now() + 6e4) {
457
- out.log(`auth: using cached ${scope} grant (${tokenFile})`);
457
+ out.error(`auth: using cached ${scope} grant (${tokenFile})`);
458
458
  return cached.token;
459
459
  }
460
460
  const email = handshakeEmail(options.email, cache?.platform === audience ? cache.email : void 0);
@@ -485,9 +485,9 @@ async function scopedToken(platform, scope, options, doFetch, out) {
485
485
  tokens[scope] = { token, expiresAt };
486
486
  if (existsSync2(join2(rootDir, ".git"))) ensureGitignore(rootDir, [tokenFile]);
487
487
  writePrivateJson(tokenFile, { platform: audience, email, tokens });
488
- out.log(`auth: cached ${scope} grant (${tokenFile}; mode 0600)`);
488
+ out.error(`auth: cached ${scope} grant (${tokenFile}; mode 0600)`);
489
489
  } else {
490
- out.log(`auth: ${scope} grant is in memory only; its credential record remains in odla-ai/db`);
490
+ out.error(`auth: ${scope} grant is in memory only; its credential record remains in odla-ai/db`);
491
491
  }
492
492
  return token;
493
493
  }
@@ -8970,13 +8970,11 @@ async function loadOrDefaultConfig(configPath, action, appId) {
8970
8970
  }
8971
8971
  return loadProjectConfig(configPath);
8972
8972
  }
8973
- var PURE_STDOUT = /* @__PURE__ */ new Set(["get", "cat"]);
8974
8973
  async function buildContext2(parsed, deps, action) {
8975
8974
  const configPath = stringOpt(parsed.options.config) ?? "odla.config.mjs";
8976
8975
  const cfg = await loadOrDefaultConfig(configPath, action, stringOpt(parsed.options.app));
8977
8976
  const doFetch = deps.fetch ?? fetch;
8978
8977
  const out = deps.stdout ?? console;
8979
- const authOut = PURE_STDOUT.has(action) ? { log: (line) => out.error(line), error: (line) => out.error(line) } : out;
8980
8978
  const appId = stringOpt(parsed.options.app) ?? PLATFORM_SCOPE;
8981
8979
  const dryRun = parsed.options["dry-run"] === true;
8982
8980
  if (action === "import" && dryRun) {
@@ -8996,7 +8994,7 @@ async function buildContext2(parsed, deps, action) {
8996
8994
  email: stringOpt(parsed.options.email),
8997
8995
  label: `odla CLI (runbook ${action})`,
8998
8996
  fetch: doFetch,
8999
- stdout: authOut,
8997
+ stdout: out,
9000
8998
  openApprovalUrl: deps.openUrl,
9001
8999
  // Anchor the grant cache to this project, not the shell's cwd.
9002
9000
  rootDir: cfg.rootDir
@@ -9013,7 +9011,7 @@ async function buildContext2(parsed, deps, action) {
9013
9011
  open: void 0
9014
9012
  },
9015
9013
  doFetch,
9016
- authOut
9014
+ out
9017
9015
  );
9018
9016
  return {
9019
9017
  platformUrl: cfg.platformUrl,
@@ -9717,4 +9715,4 @@ export {
9717
9715
  exitCodeFor,
9718
9716
  runCli
9719
9717
  };
9720
- //# sourceMappingURL=chunk-XBPDHNWO.js.map
9718
+ //# sourceMappingURL=chunk-CZSQ443A.js.map