fix(plugins): load packaged runtime mirrors from canonical sources

This commit is contained in:
Peter Steinberger
2026-04-25 09:16:05 +01:00
parent 8503935a21
commit 689a353621
4 changed files with 142 additions and 18 deletions

View File

@@ -1,4 +1,4 @@
import { mkdtempSync, mkdirSync, rmSync, writeFileSync } from "node:fs";
import { mkdtempSync, mkdirSync, rmSync, symlinkSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { dirname, join } from "node:path";
import { describe, expect, it } from "vitest";
@@ -12,6 +12,7 @@ import {
collectBundledPluginRootRuntimeMirrorErrors,
collectForbiddenPackContentPaths,
collectInstalledBundledPluginRuntimeDepErrors,
bundledRuntimeDependencySentinelCandidates,
collectRootDistBundledRuntimeMirrors,
collectForbiddenPackPaths,
collectMissingPackPaths,
@@ -673,3 +674,36 @@ describe("collectInstalledBundledPluginRuntimeDepErrors", () => {
}
});
});
describe("bundledRuntimeDependencySentinelCandidates", () => {
it("checks canonical external runtime-deps roots for packed installs", () => {
const root = mkdtempSync(join(tmpdir(), "release-check-runtime-candidates-"));
const packageRoot = join(root, "package");
const aliasRoot = join(root, "package-alias");
const homeRoot = join(root, "home");
try {
mkdirSync(join(packageRoot, "dist", "extensions", "browser"), { recursive: true });
writeFileSync(
join(packageRoot, "package.json"),
JSON.stringify({ name: "openclaw", version: "2026.4.24-beta.1" }, null, 2),
);
symlinkSync(packageRoot, aliasRoot, "dir");
const candidates = bundledRuntimeDependencySentinelCandidates(
aliasRoot,
"browser",
"playwright-core",
{ HOME: homeRoot } as NodeJS.ProcessEnv,
);
const externalCandidates = candidates.filter(
(candidate) =>
candidate.startsWith(join(homeRoot, ".openclaw", "plugin-runtime-deps")) &&
candidate.endsWith(join("node_modules", "playwright-core", "package.json")),
);
expect(externalCandidates.length).toBeGreaterThanOrEqual(2);
} finally {
rmSync(root, { recursive: true, force: true });
}
});
});