Support update command aliases and case-insensitive compatibility

This commit is contained in:
gitea committed 2026-09-17 16:01:51 +08:00
1 parent 31b7565a2d
commit 50f7a03903
2 files changed
+55 -6

No files matched your search

+22 -6
View File
@@ -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<CliRe
async function dispatch(argv: string[], runtime: CliRuntime) {
const args = parseArgs(argv);
const [area, action, maybeName] = args.command;
const [rawArea, action, maybeName] = args.command;
const lowerArea = rawArea?.toLowerCase();
const isUpdate = lowerArea ? UPDATE_ALIASES.has(lowerArea) : false;
const area = isUpdate ? "update" : lowerArea;
if (
area === "version" ||
@@ -263,16 +274,21 @@ async function dispatch(argv: string[], runtime: CliRuntime) {
return;
}
if (area === "update" || area === "changelog") {
if (isUpdate || area === "changelog") {
if (isUpdate && rawArea !== "update") {
console.error(`⚠️ Notice: '${rawArea}' is an alias for 'seal-use update'. Please use 'seal-use update' instead.`);
}
const lowerAction = action?.toLowerCase();
const isChangelog =
area === "changelog" ||
action === "changelog" ||
action === "log" ||
action === "history" ||
lowerAction === "changelog" ||
lowerAction === "log" ||
lowerAction === "history" ||
booleanOption(args.options.changelog) === true;
const isCheck =
action === "check" ||
lowerAction === "check" ||
booleanOption(args.options.check) === true ||
booleanOption(args.options["check-only"]) === true;