From 50f7a03903f47534f2153c4e76856161ef5eda84 Mon Sep 17 00:00:00 2001 From: yunyingk Date: Thu, 17 Sep 2026 16:01:51 +0800 Subject: [PATCH] Support update command aliases and case-insensitive compatibility --- src/cli/runner.test.ts | 33 +++++++++++++++++++++++++++++++++ src/cli/runner.ts | 28 ++++++++++++++++++++++------ 2 files changed, 55 insertions(+), 6 deletions(-) diff --git a/src/cli/runner.test.ts b/src/cli/runner.test.ts index 1719108..9bf3f0f 100644 --- a/src/cli/runner.test.ts +++ b/src/cli/runner.test.ts @@ -65,4 +65,37 @@ describe("CLI runner", () => { rmSync(tempDir, { recursive: true, force: true }); } }); + + test("supports update aliases (upgrade, up) with notice in stderr and exit code 0", async () => { + const upgradeResult = await runCli(["upgrade", "0.3.3"]); + expect(upgradeResult.exitCode).toBe(0); + expect(upgradeResult.isError).toBe(false); + expect(upgradeResult.stderr).toContain("Notice: 'upgrade' is an alias for 'seal-use update'"); + expect(JSON.parse(upgradeResult.stdout)).toMatchObject({ updated: false, targetVersion: "0.3.3" }); + + const upResult = await runCli(["up", "0.3.3"]); + expect(upResult.exitCode).toBe(0); + expect(upResult.isError).toBe(false); + expect(upResult.stderr).toContain("Notice: 'up' is an alias for 'seal-use update'"); + expect(JSON.parse(upResult.stdout)).toMatchObject({ updated: false, targetVersion: "0.3.3" }); + }); + + test("supports case-insensitive update invocations with original command in notice", async () => { + const mixedResult = await runCli(["Update", "0.3.3"]); + expect(mixedResult.exitCode).toBe(0); + expect(mixedResult.stderr).toContain("Notice: 'Update' is an alias for 'seal-use update'"); + expect(JSON.parse(mixedResult.stdout)).toMatchObject({ updated: false, targetVersion: "0.3.3" }); + + const upperResult = await runCli(["UPGRADE", "0.3.3"]); + expect(upperResult.exitCode).toBe(0); + expect(upperResult.stderr).toContain("Notice: 'UPGRADE' is an alias for 'seal-use update'"); + expect(JSON.parse(upperResult.stdout)).toMatchObject({ updated: false, targetVersion: "0.3.3" }); + }); + + test("canonical update command does not emit alias notice", async () => { + const result = await runCli(["update", "0.3.3"]); + expect(result.exitCode).toBe(0); + expect(result.stderr).not.toContain("is an alias for 'seal-use update'"); + expect(JSON.parse(result.stdout)).toMatchObject({ updated: false, targetVersion: "0.3.3" }); + }); }); diff --git a/src/cli/runner.ts b/src/cli/runner.ts index 75dc26c..eff583c 100755 --- a/src/cli/runner.ts +++ b/src/cli/runner.ts @@ -59,6 +59,14 @@ import { import type { CliResult, CliRunOptions, CliRuntime } from "./types.js"; const DEFAULT_APP_ROOT = dirname(dirname(dirname(fileURLToPath(import.meta.url)))); +export const UPDATE_ALIASES = new Set([ + "update", + "upgrade", + "up", + "self-update", + "selfupdate" +]); + export const KNOWN_AREAS = new Set([ "config", "service", @@ -174,7 +182,10 @@ async function runCliOnce(argv: string[], options: CliRunOptions): Promise