37 lines
1.3 KiB
TypeScript
37 lines
1.3 KiB
TypeScript
/**
|
||
* 能力注册快照(任务 0.3,见 docs/rpa-core-refactor-tasks.md)
|
||
*
|
||
* 以与生产完全相同的路径(import "../src/main/capabilities" 的副作用注册)
|
||
* 拉起全部能力模块,把运行时注册表的 id 清单写入
|
||
* resources/capability-snapshot.json。
|
||
*
|
||
* 用法:npm run snapshot
|
||
* 抽离改造各阶段完成后重跑并 git diff,快照变化必须为零(行为回归基准)。
|
||
*/
|
||
import { writeFileSync } from "node:fs";
|
||
import path from "node:path";
|
||
import { fileURLToPath } from "node:url";
|
||
import { describe, expect, it } from "vitest";
|
||
import { capabilityCount, capabilityIds } from "../src/main/capabilities";
|
||
|
||
const OUT_FILE = path.join(
|
||
path.dirname(fileURLToPath(import.meta.url)),
|
||
"..",
|
||
"resources",
|
||
"capability-snapshot.json"
|
||
);
|
||
|
||
describe("能力注册快照", () => {
|
||
it("全量注册后导出能力 id 清单", () => {
|
||
const ids = [...capabilityIds()].sort();
|
||
expect(ids.length).toBeGreaterThan(0);
|
||
const snapshot = {
|
||
generatedAt: new Date().toISOString(),
|
||
count: ids.length,
|
||
ids
|
||
};
|
||
writeFileSync(OUT_FILE, JSON.stringify(snapshot, null, 2) + "\n", "utf8");
|
||
console.log(`[能力快照] ${capabilityCount()} 个能力已写入 ${path.basename(OUT_FILE)}`);
|
||
});
|
||
});
|