From 5360dbd33f63259fdfec7227c0ed2198d09a6381 Mon Sep 17 00:00:00 2001 From: Hermes Agent Date: Mon, 18 May 2026 15:05:02 +0200 Subject: [PATCH] fix: default CLI to production API host --- package.json | 2 +- src/cli.ts | 5 ++++- src/client.ts | 2 +- src/config.ts | 2 +- tests/cli.test.ts | 32 +++++++++++++++++++++++++++++++- 5 files changed, 38 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 4c152ea..ad2af0e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@voosh/cli", - "version": "0.1.0", + "version": "0.1.1", "description": "Node.js CLI for the voosh API.", "license": "MIT", "private": false, diff --git a/src/cli.ts b/src/cli.ts index e0d3902..71ff578 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -156,7 +156,7 @@ export function buildProgram(runtime: CliRuntime = {}): Command { .description("Node.js CLI for the voosh API.") .option("--json", "Emit stable JSON output.") .option("--quiet", "Suppress human success output.") - .option("--api-url ", "voosh API host URL (defaults to VOOSH_API_URL or http://localhost:8000).") + .option("--api-url ", "voosh API host URL (defaults to VOOSH_API_URL or https://voo.sh).") .option("--profile ", "Configuration profile name.", "default") .option("--timezone ", "Timezone for natural event/slot datetimes: --timezone > VOOSH_TIMEZONE > UTC. Only UTC is currently supported.") .option("--no-color", "Disable colored output.") @@ -176,6 +176,9 @@ export function buildProgram(runtime: CliRuntime = {}): Command { await clientFactory({ baseUrl: context.config.apiUrl, token }).me.retrieve(); } updateProfile(context.config.configPath, context.config.profile, (profile) => { + if (context.config.apiUrlSource === "flag") { + profile.apiUrl = context.config.apiUrl; + } profile.token = token; }); renderResult(context.io, authStatusData(resolveConfig(getGlobals(this), env), "saved"), { diff --git a/src/client.ts b/src/client.ts index a665041..908553b 100644 --- a/src/client.ts +++ b/src/client.ts @@ -187,7 +187,7 @@ export interface VooshClient { } export function createVooshClient(options: VooshClientOptions = {}): VooshClient { - const baseUrl = stripTrailingSlash(options.baseUrl ?? "http://localhost:8000"); + const baseUrl = stripTrailingSlash(options.baseUrl ?? "https://voo.sh"); const fetchImplementation = options.fetch ?? globalThis.fetch; if (!fetchImplementation) { diff --git a/src/config.ts b/src/config.ts index b60d53c..9f3b6e0 100644 --- a/src/config.ts +++ b/src/config.ts @@ -46,7 +46,7 @@ export interface StoredConfig { export type ConfigValueSource = "flag" | "env" | "profile" | "default"; -const DEFAULT_API_URL = "http://localhost:8000"; +const DEFAULT_API_URL = "https://voo.sh"; const DEFAULT_PROFILE = "default"; export function resolveConfig(options: GlobalOptions, env: CliEnv): CliConfig { diff --git a/tests/cli.test.ts b/tests/cli.test.ts index 372e263..f602aac 100644 --- a/tests/cli.test.ts +++ b/tests/cli.test.ts @@ -1195,6 +1195,23 @@ describe("voosh node CLI", () => { }); }); + it("defaults to production voo.sh host for first-run API commands", async () => { + await withConfigPath(async (configPath) => { + const io = createIo(); + const client = createClient(); + const createClientMock = vi.fn(() => client); + + const exitCode = await run(["me", "show"], { + env: { VOOSH_CONFIG_PATH: configPath, VOOSH_API_TOKEN: "token-123" }, + io, + createClient: createClientMock, + }); + + expect(exitCode).toBe(0); + expect(createClientMock).toHaveBeenCalledWith({ baseUrl: "https://voo.sh", token: "token-123" }); + }); + }); + it("auth login verifies by default before saving", async () => { await withConfigPath(async (configPath) => { const io = createIo(); @@ -1210,7 +1227,20 @@ describe("voosh node CLI", () => { expect(exitCode).toBe(0); expect(createClientMock).toHaveBeenCalledWith({ baseUrl: "https://api.example.test", token: "verify-token" }); expect(client.me.retrieve).toHaveBeenCalledOnce(); - expect(JSON.parse(output(io.stdout))).toMatchObject({ code: "saved", token_configured: true }); + expect(JSON.parse(output(io.stdout))).toMatchObject({ + code: "saved", + base_url: "https://api.example.test", + api_url_source: "flag", + token_configured: true, + }); + expect(JSON.parse(await readFile(configPath, "utf8"))).toEqual({ + profiles: { + default: { + apiUrl: "https://api.example.test", + token: "verify-token", + }, + }, + }); }); });