mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-05 22:32:12 +00:00
fix: resolve acpx plugin root from shared chunks
This commit is contained in:
@@ -64,6 +64,22 @@ describe("acpx plugin config parsing", () => {
|
||||
}
|
||||
});
|
||||
|
||||
it("resolves workspace plugin root from dist shared chunks", () => {
|
||||
const repoRoot = fs.mkdtempSync(path.join(os.tmpdir(), "acpx-root-shared-dist-"));
|
||||
const workspacePluginRoot = bundledPluginRootAt(repoRoot, "acpx");
|
||||
try {
|
||||
fs.mkdirSync(path.join(repoRoot, "dist"), { recursive: true });
|
||||
fs.mkdirSync(workspacePluginRoot, { recursive: true });
|
||||
fs.writeFileSync(path.join(workspacePluginRoot, "package.json"), "{}\n", "utf8");
|
||||
fs.writeFileSync(path.join(workspacePluginRoot, "openclaw.plugin.json"), "{}\n", "utf8");
|
||||
|
||||
const moduleUrl = pathToFileURL(path.join(repoRoot, "dist", "register.runtime.js")).href;
|
||||
expect(resolveAcpxPluginRoot(moduleUrl)).toBe(workspacePluginRoot);
|
||||
} finally {
|
||||
fs.rmSync(repoRoot, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
it("resolves bundled acpx with pinned version by default", () => {
|
||||
const resolved = resolveAcpxPluginConfig({
|
||||
rawConfig: {
|
||||
|
||||
@@ -62,11 +62,20 @@ function resolveWorkspaceAcpxPluginRoot(currentRoot: string): string | null {
|
||||
return isAcpxPluginRoot(workspaceRoot) ? workspaceRoot : null;
|
||||
}
|
||||
|
||||
function resolveRepoAcpxPluginRoot(currentRoot: string): string | null {
|
||||
const workspaceRoot = path.join(currentRoot, "extensions", "acpx");
|
||||
return isAcpxPluginRoot(workspaceRoot) ? workspaceRoot : null;
|
||||
}
|
||||
|
||||
export function resolveAcpxPluginRoot(moduleUrl: string = import.meta.url): string {
|
||||
const resolvedRoot = resolveNearestAcpxPluginRoot(moduleUrl);
|
||||
// In a live repo checkout, dist/ can be rebuilt out from under the running gateway.
|
||||
// Prefer the stable source plugin root when a built extension is running beside it.
|
||||
return resolveWorkspaceAcpxPluginRoot(resolvedRoot) ?? resolvedRoot;
|
||||
return (
|
||||
resolveWorkspaceAcpxPluginRoot(resolvedRoot) ??
|
||||
resolveRepoAcpxPluginRoot(resolvedRoot) ??
|
||||
resolvedRoot
|
||||
);
|
||||
}
|
||||
|
||||
export const ACPX_PLUGIN_ROOT = resolveAcpxPluginRoot();
|
||||
|
||||
Reference in New Issue
Block a user