@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.
- package/package.json +1 -1
- package/src/cli.js +9 -5
package/package.json
CHANGED
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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);
|