fix: 修复审核记录导出进度与后台等待机制
为审核记录导出增加可复用的本地后台任务及 status/wait/list,等待超时或观察进程退出后任务继续执行。 统一实时脱敏诊断输出,保留 stdout 单一 JSON;补齐高级参数、预览和筛选配置摘要。 默认保留合思未找到单据,分别统计单据与审核记录,并显式报告部分补取失败。 补充 CLI/Skill 版本诊断、技能路由及回归测试,修复企业列表加载开销和源码更新测试隔离。
This commit is contained in:
1 parent
477cc630b4
commit
db5a3f7139
24 files changed
+1239
-174
No files matched your search
+41
-3
@@ -1,6 +1,6 @@
|
||||
import { afterEach, describe, expect, test } from "bun:test";
|
||||
import { spawnSync } from "node:child_process";
|
||||
import { mkdtempSync, mkdirSync, rmSync, writeFileSync } from "node:fs";
|
||||
import { chmodSync, copyFileSync, mkdtempSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { VERSION } from "./version.js";
|
||||
@@ -9,7 +9,7 @@ const CLI_PATH = join(import.meta.dirname, "cli.ts");
|
||||
const tempDirs: string[] = [];
|
||||
|
||||
function runCli(args: string[], env: Record<string, string> = {}) {
|
||||
return spawnSync("bun", [CLI_PATH, ...args], {
|
||||
return spawnSync(process.execPath, [CLI_PATH, ...args], {
|
||||
encoding: "utf-8",
|
||||
env: { ...process.env, ...env }
|
||||
});
|
||||
@@ -153,12 +153,50 @@ describe("CLI version & help handling", () => {
|
||||
});
|
||||
|
||||
test("update command runs in source mode when executed from bun", () => {
|
||||
const result = runCli(["update"]);
|
||||
// Exercise the CLI's source-update control flow without fetching Git refs,
|
||||
// installing packages, or running hooks in the developer's working tree.
|
||||
// Native shims work with spawnSync on Windows as well as POSIX (no shell).
|
||||
const dir = mkdtempSync(join(tmpdir(), "cli-source-update-"));
|
||||
tempDirs.push(dir);
|
||||
const source = join(dir, "tool-shim.ts");
|
||||
const suffix = process.platform === "win32" ? ".exe" : "";
|
||||
const executable = join(dir, `shim${suffix}`);
|
||||
const log = join(dir, "commands.jsonl");
|
||||
const realGit = Bun.which("git");
|
||||
expect(realGit).not.toBeNull();
|
||||
writeFileSync(source, `
|
||||
import { basename } from "node:path";
|
||||
import { appendFileSync } from "node:fs";
|
||||
import { spawnSync } from "node:child_process";
|
||||
const command = basename(process.execPath).replace(/\\.exe$/, "");
|
||||
const args = process.argv.slice(2);
|
||||
if (command === "git" && !args.includes("pull")) {
|
||||
const result = spawnSync(${JSON.stringify(realGit)}, args, { encoding: "utf8" });
|
||||
if (result.stdout) process.stdout.write(result.stdout);
|
||||
if (result.stderr) process.stderr.write(result.stderr);
|
||||
process.exitCode = result.status ?? 1;
|
||||
} else {
|
||||
appendFileSync(${JSON.stringify(log)}, JSON.stringify({ command, args }) + "\\n");
|
||||
}
|
||||
`);
|
||||
const build = spawnSync(process.execPath, ["build", "--compile", source, "--outfile", executable], { encoding: "utf8" });
|
||||
expect(build.status).toBe(0);
|
||||
for (const name of ["git", "bun"]) {
|
||||
const path = join(dir, `${name}${suffix}`);
|
||||
copyFileSync(executable, path);
|
||||
chmodSync(path, 0o755);
|
||||
}
|
||||
const result = runCli(["update"], { PATH: `${dir}${process.platform === "win32" ? ";" : ":"}${process.env.PATH ?? ""}` });
|
||||
expect(result.status).toBe(0);
|
||||
const parsed = JSON.parse(result.stdout.trim());
|
||||
expect(parsed.updated).toBe(true);
|
||||
expect(parsed.mode).toBe("source");
|
||||
expect(parsed.version).toBe(VERSION);
|
||||
const calls = readFileSync(log, "utf8").trim().split("\n").map(line => JSON.parse(line));
|
||||
expect(calls).toEqual([
|
||||
{ command: "git", args: ["-C", join(import.meta.dirname, ".."), "pull", "--ff-only"] },
|
||||
{ command: "bun", args: ["install"] }
|
||||
]);
|
||||
}, 20000);
|
||||
|
||||
test("mcp-config outputs valid mcp configuration json", () => {
|
||||
|
||||
Reference in new issue
Block a user