mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 10:50:44 +00:00
fix(release): stage runtime deps from plugin package root
This commit is contained in:
@@ -414,7 +414,15 @@ function expandInstalledDistImportClosure(params) {
|
||||
if (!JS_DIST_FILE_RE.test(importerPath) || importerPath.includes("/node_modules/")) {
|
||||
continue;
|
||||
}
|
||||
const source = params.readText(importerPath);
|
||||
let source;
|
||||
try {
|
||||
source = params.readText(importerPath);
|
||||
} catch (error) {
|
||||
if (error?.code === "ENOENT") {
|
||||
continue;
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
for (const specifier of collectImportSpecifiers(source)) {
|
||||
const importedPath = resolveDistImportPath(importerPath, specifier);
|
||||
if (!importedPath || !fileSet.has(importedPath) || expectedSet.has(importedPath)) {
|
||||
|
||||
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user