fix(ci): preserve imported dist chunks after install

This commit is contained in:
Peter Steinberger
2026-04-29 01:12:59 +01:00
parent 054b2e1b7e
commit 03b1731d0f
5 changed files with 110 additions and 4 deletions

View File

@@ -127,6 +127,25 @@ describe("check-openclaw-package-tarball", () => {
);
});
it("rejects imported dist chunks omitted from the postinstall inventory", () => {
withTarball(
["dist/cli/run-main.js"],
{
"dist/cli/run-main.js": 'await import("../memory-state-current.js");\n',
"dist/memory-state-current.js": "export {};\n",
},
(tarball) => {
const result = spawnSync("node", [CHECK_SCRIPT, tarball], { encoding: "utf8" });
expect(result.status).not.toBe(0);
expect(result.stderr).toContain(
"inventory omits imported dist file dist/memory-state-current.js",
);
},
"2026.4.27",
);
});
it("rejects missing Control UI assets", () => {
withTarball(
["dist/index.js"],

View File

@@ -401,6 +401,28 @@ describe("bundled plugin postinstall", () => {
await expect(fs.stat(staleFile)).rejects.toMatchObject({ code: "ENOENT" });
});
it("keeps imported dist chunks even when inventory is stale", async () => {
const packageRoot = await createTempDirAsync("openclaw-packaged-install-import-");
const entryFile = path.join(packageRoot, "dist", "cli", "run-main.js");
const importedChunk = path.join(packageRoot, "dist", "memory-state-CcqRgDZU.js");
const staleFile = path.join(packageRoot, "dist", "memory-state-old.js");
await fs.mkdir(path.dirname(entryFile), { recursive: true });
await fs.writeFile(entryFile, 'await import("../memory-state-CcqRgDZU.js");\n');
await writePackageDistInventory(packageRoot);
await fs.writeFile(importedChunk, "export {};\n");
await fs.writeFile(staleFile, "export {};\n");
expect(
pruneInstalledPackageDist({
packageRoot,
log: { log: vi.fn(), warn: vi.fn() },
}),
).toEqual(["dist/memory-state-old.js"]);
await expect(fs.stat(importedChunk)).resolves.toBeTruthy();
await expect(fs.stat(staleFile)).rejects.toMatchObject({ code: "ENOENT" });
});
it("prunes stale private QA files without restoring compat sidecars", async () => {
const packageRoot = await createTempDirAsync("openclaw-packaged-install-qa-compat-");
const currentFile = path.join(packageRoot, "dist", "entry.js");