fix(release): stage runtime deps from plugin package root

This commit is contained in:
Peter Steinberger
2026-05-02 03:04:05 +01:00
parent d5c8d70f02
commit 8514e4c913
2 changed files with 38 additions and 1 deletions

View File

@@ -1,3 +1,4 @@
import { readFileSync as readFileSyncOriginal } from "node:fs";
import fs from "node:fs/promises";
import { tmpdir } from "node:os";
import path from "node:path";
@@ -402,6 +403,34 @@ describe("bundled plugin postinstall", () => {
await expect(fs.stat(staleFile)).rejects.toMatchObject({ code: "ENOENT" });
});
it("does not abort dist pruning when a listed chunk disappears before import expansion", async () => {
const packageRoot = await createTempDirAsync("openclaw-packaged-install-missing-chunk-");
const entryFile = path.join(packageRoot, "dist", "control-ui", "assets", "instances.js");
const staleFile = path.join(packageRoot, "dist", "stale.js");
await fs.mkdir(path.dirname(entryFile), { recursive: true });
await fs.writeFile(entryFile, 'import "./chunk.js";\n');
await writePackageDistInventory(packageRoot);
await fs.writeFile(staleFile, "export {};\n");
const readFileSync = vi.fn((filePath: string | Buffer | URL, options?: BufferEncoding) => {
if (String(filePath).endsWith("dist/control-ui/assets/instances.js")) {
const error = new Error("missing generated asset") as NodeJS.ErrnoException;
error.code = "ENOENT";
throw error;
}
return readFileSyncOriginal(filePath, options);
});
expect(() =>
pruneInstalledPackageDist({
packageRoot,
readFileSync,
log: { log: vi.fn(), warn: vi.fn() },
}),
).not.toThrow();
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");