fix: sqlite cache migration, bill timeout protection with --mine, and add-link overwrite UX (v0.8.7)

This commit is contained in:
gitea committed 2026-09-17 10:06:08 +08:00
1 parent b08b99c45e
commit 43595e2410
15 files changed
+658 -439

No files matched your search

+14 -1
View File
@@ -44,7 +44,7 @@ export async function handleBillCommand(
const actionTarget = () => parsed.args[0] || stringOption(parsed.options, ["code", "id"]);
const requireWriteConfirmation = async () => {
if (isDryRun(parsed, runtime) || booleanOption(parsed.options, ["yes", "y", "confirm", "force-write"])) return;
if (!process.stdin.isTTY || !process.stdout.isTTY) {
if (!process.stdin.isTTY || !process.stdout.isTTY || Boolean(process.env.CI) || process.env.NODE_ENV === "test") {
requireMutationConfirmation(
parsed,
runtime,
@@ -149,6 +149,19 @@ export async function handleBillCommand(
case "list":
case "search":
case undefined: {
const mine = booleanOption(parsed.options, ["mine", "my", "self"]);
if (mine) {
const { handleTaskCommand } = await import("./task.js");
return handleTaskCommand(
{
...parsed,
area: "task",
action: "submitted",
},
runtime
);
}
const code = stringOption(parsed.options, ["code", "c"]);
const keyword = stringOption(parsed.options, ["keyword", "k", "q", "query"]);
const stage = stringOption(parsed.options, ["stage"]);
+35 -8
View File
@@ -1,3 +1,4 @@
import { existsSync } from "node:fs";
import { join } from "node:path";
import { importFromLink } from "../../core/auth/login.js";
import { resolveWritableEnterprisesDir } from "../../core/config/loader.js";
@@ -358,7 +359,7 @@ async function handleAddLink(parsed: CliParsedArgs, runtime: CliRuntime): Promis
const ttl = stringOption(parsed.options, ["ttl"]);
const expires = stringOption(parsed.options, ["expires", "days"]);
if (!linkUrl && process.stdin.isTTY) {
if (!linkUrl && process.stdin.isTTY && !process.env.CI && process.env.NODE_ENV !== "test") {
linkUrl = await prompt("请输入第三方协助/免密登录链接 URL: ");
}
@@ -370,15 +371,41 @@ async function handleAddLink(parsed: CliParsedArgs, runtime: CliRuntime): Promis
};
}
let targetCorpId = "";
try {
const parsedUrl = new URL(linkUrl);
targetCorpId = parsedUrl.searchParams.get("ekbCorpId") || "";
} catch {}
const targetDir = resolveWritableEnterprisesDir();
const existsAlready = Boolean(targetCorpId && existsSync(join(targetDir, `${targetCorpId}.json`)));
if (isDryRun(parsed, runtime)) {
return mutationPreview(parsed, runtime, "从协助链接导入企业凭证", name || "待解析企业", {
source: "assistance-link",
overwrite,
ttl: ttl || null,
expires: expires || null,
});
return mutationPreview(
parsed,
runtime,
"从协助链接导入企业凭证",
name || (targetCorpId ? `企业 [${targetCorpId}]` : "待解析企业"),
{
source: "assistance-link",
overwrite,
alreadyExists: existsAlready,
ttl: ttl || null,
expires: expires || null,
note: existsAlready && !overwrite ? "检测到本地已存在该企业配置,导入执行时请带上 --overwrite 参数" : undefined,
}
);
}
requireMutationConfirmation(parsed, runtime, "从协助链接导入企业凭证", `hose-use corps add-link <url> --yes`);
const nextConfirmCmd = existsAlready && !overwrite
? `hose-use corps add-link <url> --overwrite --yes`
: `hose-use corps add-link <url> --yes`;
const confirmOp = existsAlready && !overwrite
? `从协助链接导入企业凭证(检测到目标企业 [${targetCorpId}] 已存在,需覆盖更新)`
: "从协助链接导入企业凭证";
requireMutationConfirmation(parsed, runtime, confirmOp, nextConfirmCmd);
try {
const corp = await importFromLink(linkUrl, {