
























@@ -0,0 +1,70 @@
1+import { spawnSync } from "node:child_process";
2+import { mkdtempSync, rmSync, mkdirSync, writeFileSync } from "node:fs";
3+import { tmpdir } from "node:os";
4+import { dirname, join } from "node:path";
5+import { describe, expect, it } from "vitest";
6+7+const CHECK_SCRIPT = "scripts/check-openclaw-package-tarball.mjs";
8+9+function withTarball(
10+inventory: string[],
11+files: Record<string, string>,
12+testBody: (tarball: string) => void,
13+) {
14+const root = mkdtempSync(join(tmpdir(), "openclaw-package-tarball-test-"));
15+try {
16+const packageRoot = join(root, "package");
17+mkdirSync(join(packageRoot, "dist"), { recursive: true });
18+writeFileSync(
19+join(packageRoot, "package.json"),
20+JSON.stringify({ name: "openclaw", version: "0.0.0" }),
21+);
22+writeFileSync(
23+join(packageRoot, "dist", "postinstall-inventory.json"),
24+JSON.stringify(inventory),
25+);
26+for (const [relativePath, body] of Object.entries(files)) {
27+const filePath = join(packageRoot, relativePath);
28+mkdirSync(dirname(filePath), { recursive: true });
29+writeFileSync(filePath, body);
30+}
31+32+const tarball = join(root, "openclaw.tgz");
33+const pack = spawnSync("tar", ["-czf", tarball, "-C", root, "package"], {
34+encoding: "utf8",
35+});
36+expect(pack.status, pack.stderr).toBe(0);
37+testBody(tarball);
38+} finally {
39+rmSync(root, { recursive: true, force: true });
40+}
41+}
42+43+describe("check-openclaw-package-tarball", () => {
44+it("allows legacy private QA inventory entries omitted from shipped tarballs", () => {
45+withTarball(
46+["dist/index.js", "dist/extensions/qa-channel/runtime-api.js"],
47+{ "dist/index.js": "export {};\n" },
48+(tarball) => {
49+const result = spawnSync("node", [CHECK_SCRIPT, tarball], { encoding: "utf8" });
50+51+expect(result.status, result.stderr).toBe(0);
52+expect(result.stderr).toContain("legacy inventory references omitted private QA");
53+expect(result.stdout).toContain("OpenClaw package tarball integrity passed.");
54+},
55+);
56+});
57+58+it("still rejects non-legacy missing inventory entries", () => {
59+withTarball(
60+["dist/index.js", "dist/cli.js"],
61+{ "dist/index.js": "export {};\n" },
62+(tarball) => {
63+const result = spawnSync("node", [CHECK_SCRIPT, tarball], { encoding: "utf8" });
64+65+expect(result.status).not.toBe(0);
66+expect(result.stderr).toContain("inventory references missing tar entry dist/cli.js");
67+},
68+);
69+});
70+});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。