@flatkey-ai/cli 0.1.9 → 0.1.10

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/cli.js +9 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flatkey-ai/cli",
3
- "version": "0.1.9",
3
+ "version": "0.1.10",
4
4
  "description": "Flatkey media generation CLI for image, video, audio, credits, status, and models.",
5
5
  "type": "module",
6
6
  "bin": {
package/src/cli.js CHANGED
@@ -220,7 +220,7 @@ async function handleLogin(command, deps) {
220
220
  const deviceId = await ensureDeviceId({ configDir: deps.configDir });
221
221
  const version = await readPackageVersion();
222
222
  const env = deps.env ?? process.env;
223
- const consoleUrl = command.options.console_url ?? env.CONSOLE_ORIGIN;
223
+ const consoleUrl = firstNonEmpty(command.options.console_url, env.CONSOLE_ORIGIN);
224
224
  const authorization = await createDeviceAuthorization({
225
225
  consoleUrl,
226
226
  deviceId,
@@ -323,6 +323,10 @@ function formatAuthStatus(status) {
323
323
  return `Authenticated via ${status.source}: ${status.key}`;
324
324
  }
325
325
 
326
+ function firstNonEmpty(...values) {
327
+ return values.find((value) => typeof value === "string" && value.trim() !== "");
328
+ }
329
+
326
330
  async function handleLogout(command, deps = {}) {
327
331
  const { clearSavedApiKey } = await import("./config.js");
328
332
  const configPath = await clearSavedApiKey({ configDir: deps.configDir });
@@ -386,7 +390,7 @@ async function handleGenerate(command, deps) {
386
390
  const options = {
387
391
  ...command.options,
388
392
  apiKey,
389
- baseUrl: command.options.base_url ?? (deps.env ?? process.env).ROUTER_ORIGIN,
393
+ baseUrl: firstNonEmpty(command.options.base_url, (deps.env ?? process.env).ROUTER_ORIGIN),
390
394
  fetch: deps.fetch,
391
395
  };
392
396
  if (command.options.dry_run) {
@@ -468,7 +472,7 @@ async function handleVoices(command, deps) {
468
472
  });
469
473
  return getVoices({
470
474
  apiKey,
471
- baseUrl: command.options.base_url ?? (deps.env ?? process.env).ROUTER_ORIGIN,
475
+ baseUrl: firstNonEmpty(command.options.base_url, (deps.env ?? process.env).ROUTER_ORIGIN),
472
476
  fetch: deps.fetch,
473
477
  });
474
478
  }
@@ -520,7 +524,7 @@ async function handleUtility(command, deps) {
520
524
  });
521
525
  const options = {
522
526
  apiKey,
523
- baseUrl: command.options.base_url ?? (deps.env ?? process.env).CONSOLE_ORIGIN,
527
+ baseUrl: firstNonEmpty(command.options.base_url, (deps.env ?? process.env).CONSOLE_ORIGIN),
524
528
  fetch: deps.fetch,
525
529
  };
526
530
  return command.group === "credits" ? getCredits(options) : getStatus(options);
@@ -538,7 +542,7 @@ async function handleModels(command, deps) {
538
542
  });
539
543
  const response = await getModels({
540
544
  apiKey,
541
- baseUrl: command.options.base_url ?? (deps.env ?? process.env).CONSOLE_ORIGIN,
545
+ baseUrl: firstNonEmpty(command.options.base_url, (deps.env ?? process.env).CONSOLE_ORIGIN),
542
546
  fetch: deps.fetch,
543
547
  });
544
548
  const models = normalizeModels(response, command.options.type);