From dcff1b4b2d076dec1a78a8e58711417f4fe013c9 Mon Sep 17 00:00:00 2001 From: Codex Date: Mon, 1 Jun 2026 22:37:24 +0800 Subject: [PATCH] fix(cli): recommend direct bun client commands --- tools/hwlab-cli/client.test.ts | 2 ++ tools/src/hwlab-cli-lib.ts | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/tools/hwlab-cli/client.test.ts b/tools/hwlab-cli/client.test.ts index c33a2f7d..da6428e5 100644 --- a/tools/hwlab-cli/client.test.ts +++ b/tools/hwlab-cli/client.test.ts @@ -109,6 +109,8 @@ test("hwlab-cli client auth status exposes local session state and next commands assert.equal(mismatch.payload.localSession.usable, false); assert.equal(mismatch.payload.localSession.ignoredReason, "base_url_mismatch"); assert.equal(JSON.stringify(mismatch.payload).includes("session-old"), false); + assert.match(mismatch.payload.nextCommands[1], /^bun tools\/hwlab-cli\/bin\/hwlab-cli\.ts client auth login/u); + assert.equal(JSON.stringify(mismatch.payload.nextCommands).includes("run-bun.mjs"), false); }); test("hwlab-cli client group help is visible and does not issue HTTP requests", async () => { diff --git a/tools/src/hwlab-cli-lib.ts b/tools/src/hwlab-cli-lib.ts index 39f4865d..6209afcc 100644 --- a/tools/src/hwlab-cli-lib.ts +++ b/tools/src/hwlab-cli-lib.ts @@ -1547,10 +1547,11 @@ function authNextCommands(authState: any) { const resolvedBaseUrl = text(authState?.baseUrl) || DEFAULT_BASE_URL; const username = text(authState?.username) || "admin"; const stateFileArg = text(authState?.stateFile) ? ` --state-file ${shellArg(authState.stateFile)}` : ""; + const cli = "bun tools/hwlab-cli/bin/hwlab-cli.ts"; return [ `export HWLAB_PASSWORD=''`, - `node scripts/run-bun.mjs tools/hwlab-cli/bin/hwlab-cli.ts client auth login --base-url ${shellArg(resolvedBaseUrl)} --username ${shellArg(username)} --password-env HWLAB_PASSWORD${stateFileArg}`, - `node scripts/run-bun.mjs tools/hwlab-cli/bin/hwlab-cli.ts client auth status --base-url ${shellArg(resolvedBaseUrl)}${stateFileArg}` + `${cli} client auth login --base-url ${shellArg(resolvedBaseUrl)} --username ${shellArg(username)} --password-env HWLAB_PASSWORD${stateFileArg}`, + `${cli} client auth status --base-url ${shellArg(resolvedBaseUrl)}${stateFileArg}` ]; }