feat(install): 支持 --system 与 --user 模式切换并自动清理残留二进制
- 在 scripts/install.sh 中默认安装至用户目录 ~/.local/bin,并自动清理历史遗留的 /opt/homebrew/bin/seal-use - 在 scripts/dev-override.ts 中优先命中 ~/.local/bin/seal-use,忽略 Homebrew 路径并自动清理残留 - 在 seal-use update 中支持 --system(提权迁移至 /usr/local/bin)与 --user(降权回归至 ~/.local/bin)选项,添加 seal-use migrate 别名 - 迁移与更新时自动清理另一端的非活动实体二进制(恪守 Single Binary Invariant) - 自更新权限预检:当目标位于系统目录且缺少写权限时,友好提示 sudo seal-use update 而非底层报错 - 在 seal-use doctor 中增加执行模式识别与多份二进制(PATH 阴影)检测告警
This commit is contained in:
1 parent
477cc630b4
commit
87bb10f527
12 files changed
+294
-34
No files matched your search
+16
-3
@@ -5,7 +5,7 @@ import { fileURLToPath } from "node:url";
|
||||
import type { CorpConfig } from "../core/config/types.js";
|
||||
import { VERSION_INFO } from "../version.js";
|
||||
import { isUpdateCacheExpired, loadUpdateCache, triggerBackgroundUpdateCheck } from "../core/update-cache.js";
|
||||
import { classifyCliError, usageError } from "../core/errors.js";
|
||||
import { classifyCliError, usageError, validationError } from "../core/errors.js";
|
||||
import {
|
||||
booleanOption,
|
||||
materialPackFilePolicyOptions,
|
||||
@@ -185,10 +185,21 @@ async function dispatchUpdate(args: ParsedArgs, runtime: CliRuntime): Promise<vo
|
||||
booleanOption(args.options["bg-save"]) === true ||
|
||||
booleanOption(args.options["silent-save"]) === true;
|
||||
|
||||
const isSystem = booleanOption(args.options.system) === true || lowerAction === "system";
|
||||
const isUser = booleanOption(args.options.user) === true || lowerAction === "user";
|
||||
|
||||
if (isSystem && isUser) {
|
||||
throw validationError("Cannot specify both --system and --user.");
|
||||
}
|
||||
|
||||
if (rawArea === "migrate" && !isSystem && !isUser) {
|
||||
throw usageError("Usage: seal-use migrate --system | --user", "seal-use migrate --user");
|
||||
}
|
||||
|
||||
const targetVersion =
|
||||
stringOption(args.options.version) ??
|
||||
stringOption(args.options.tag) ??
|
||||
(!isChangelog && !isCheck && !isBgSave && action && !action.startsWith("-") ? action : undefined);
|
||||
(!isChangelog && !isCheck && !isBgSave && !isSystem && !isUser && action && !action.startsWith("-") ? action : undefined);
|
||||
|
||||
await (await import("./commands/update.js")).handleUpdateCommand(runtime, {
|
||||
checkOnly: isCheck || isBgSave,
|
||||
@@ -197,7 +208,9 @@ async function dispatchUpdate(args: ParsedArgs, runtime: CliRuntime): Promise<vo
|
||||
force: booleanOption(args.options.force),
|
||||
targetVersion,
|
||||
repo: stringOption(args.options.repo),
|
||||
bgSave: isBgSave
|
||||
bgSave: isBgSave,
|
||||
system: isSystem,
|
||||
user: isUser
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user