mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 10:20:42 +00:00
fix(acpx): resolve plugin manifest from bundled runtime
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import fsSync from "node:fs";
|
||||
import fs from "node:fs/promises";
|
||||
import { createRequire } from "node:module";
|
||||
import path from "node:path";
|
||||
import { resolveAcpxPluginRoot } from "./config.js";
|
||||
import type { ResolvedAcpxPluginConfig } from "./config.js";
|
||||
|
||||
const CODEX_ACP_PACKAGE = "@zed-industries/codex-acp";
|
||||
@@ -16,10 +18,13 @@ type PackageManifest = {
|
||||
dependencies?: Record<string, unknown>;
|
||||
};
|
||||
|
||||
const selfManifest = requireFromHere("../package.json") as PackageManifest;
|
||||
function readSelfManifest(): PackageManifest {
|
||||
const manifestPath = path.join(resolveAcpxPluginRoot(import.meta.url), "package.json");
|
||||
return JSON.parse(fsSync.readFileSync(manifestPath, "utf8")) as PackageManifest;
|
||||
}
|
||||
|
||||
function readManifestDependencyVersion(packageName: string): string {
|
||||
const version = selfManifest.dependencies?.[packageName];
|
||||
const version = readSelfManifest().dependencies?.[packageName];
|
||||
if (typeof version !== "string" || version.trim() === "") {
|
||||
throw new Error(`Missing ${packageName} dependency version in @openclaw/acpx manifest`);
|
||||
}
|
||||
|
||||
@@ -119,6 +119,13 @@ describe("embedded acpx plugin config", () => {
|
||||
expect(server.args?.length).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
it("resolves the plugin root from shared dist chunk paths", () => {
|
||||
const moduleUrl = new URL("../../../dist/extensions/acpx/service-shared.js", import.meta.url)
|
||||
.href;
|
||||
|
||||
expect(resolveAcpxPluginRoot(moduleUrl)).toBe(path.resolve("extensions/acpx"));
|
||||
});
|
||||
|
||||
it("keeps the runtime json schema in sync with the manifest config schema", () => {
|
||||
const pluginRoot = resolveAcpxPluginRoot();
|
||||
const manifest = JSON.parse(
|
||||
|
||||
Reference in New Issue
Block a user