From d21877eb20b0a22588fb6cd5c024438bafc0bb89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20=C3=81ngel?= Date: Wed, 4 Nov 2026 01:34:12 +0000 Subject: [PATCH] feat(cli): billing top-up is renamed to add-credits with no alias (#7121) --- packages/cli/src/commands/billing.test.ts | 42 +++++++++++++---------- packages/cli/src/commands/billing.ts | 2 +- 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/packages/cli/src/commands/billing.test.ts b/packages/cli/src/commands/billing.test.ts index a7ce4d744b..ba53218541 100644 --- a/packages/cli/src/commands/billing.test.ts +++ b/packages/cli/src/commands/billing.test.ts @@ -66,24 +66,30 @@ describe("billing subscribe", () => { }); describe("billing add-credits", () => { - it.each(["add-credits", "top-up"])( - "opens the credits page for `%s`, with no notice", - async (name) => { - vi.stubEnv("HYPERFRAMES_PLANS_URL", "https://plans.test/p"); - vi.stubEnv("HYPERFRAMES_CREDITS_URL", "https://credits.test/c"); - const log = vi.spyOn(console, "log").mockImplementation(() => undefined); - const error = vi.spyOn(console, "error").mockImplementation(() => undefined); - vi.useFakeTimers(); - const done = runCommand(billing, { rawArgs: [name] }); - await vi.advanceTimersByTimeAsync(2000); - await done; - vi.useRealTimers(); - vi.unstubAllEnvs(); - expect(new URL(opened[0] ?? "").origin).toBe("https://credits.test"); - expect(error).not.toHaveBeenCalled(); - expect(log.mock.calls.flat().join("\n")).not.toMatch(/deprecat|renamed|top-up/i); - }, - ); + it("opens the credits page", async () => { + vi.stubEnv("HYPERFRAMES_PLANS_URL", "https://plans.test/p"); + vi.stubEnv("HYPERFRAMES_CREDITS_URL", "https://credits.test/c"); + const log = vi.spyOn(console, "log").mockImplementation(() => undefined); + const error = vi.spyOn(console, "error").mockImplementation(() => undefined); + vi.useFakeTimers(); + const done = runCommand(billing, { rawArgs: ["add-credits"] }); + await vi.advanceTimersByTimeAsync(2000); + await done; + vi.useRealTimers(); + vi.unstubAllEnvs(); + expect(new URL(opened[0] ?? "").origin).toBe("https://credits.test"); + expect(error).not.toHaveBeenCalled(); + expect(log.mock.calls.flat().join("\n")).not.toMatch(/deprecat|renamed|top-up/i); + }); + + it("refuses the old name `top-up` like any unknown action, naming the valid ones", async () => { + const error = vi.spyOn(console, "error").mockImplementation(() => undefined); + await expect(runCommand(billing, { rawArgs: ["top-up"] })).rejects.toThrow(); + expect(error.mock.calls.flat().join("\n")).toContain( + "Use `billing subscribe` or `billing add-credits`.", + ); + expect(opened).toEqual([]); + }); }); describe("billing without a terminal", () => { diff --git a/packages/cli/src/commands/billing.ts b/packages/cli/src/commands/billing.ts index 06a6a48774..a8f57a91f2 100644 --- a/packages/cli/src/commands/billing.ts +++ b/packages/cli/src/commands/billing.ts @@ -87,7 +87,7 @@ export default defineCommand({ }, // fallow-ignore-next-line complexity async run({ args }) { - const action = String(args.action) === "top-up" ? "add-credits" : String(args.action); + const action = String(args.action); if (action !== "subscribe" && action !== "add-credits") { console.error(c.error("Use `billing subscribe` or `billing add-credits`.")); failCommand();