mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-30 08:32:00 +00:00
fix: normalize manifest plugin ids during install
This commit is contained in:
@@ -557,6 +557,43 @@ describe("installPluginFromDir", () => {
|
||||
),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("normalizes scoped manifest ids to unscoped install keys", async () => {
|
||||
const { pluginDir, extensionsDir } = setupPluginInstallDirs();
|
||||
fs.mkdirSync(path.join(pluginDir, "dist"), { recursive: true });
|
||||
fs.writeFileSync(
|
||||
path.join(pluginDir, "package.json"),
|
||||
JSON.stringify({
|
||||
name: "@openclaw/cognee-openclaw",
|
||||
version: "0.0.1",
|
||||
openclaw: { extensions: ["./dist/index.js"] },
|
||||
}),
|
||||
"utf-8",
|
||||
);
|
||||
fs.writeFileSync(path.join(pluginDir, "dist", "index.js"), "export {};", "utf-8");
|
||||
fs.writeFileSync(
|
||||
path.join(pluginDir, "openclaw.plugin.json"),
|
||||
JSON.stringify({
|
||||
id: "@team/memory-cognee",
|
||||
configSchema: { type: "object", properties: {} },
|
||||
}),
|
||||
"utf-8",
|
||||
);
|
||||
|
||||
const res = await installPluginFromDir({
|
||||
dirPath: pluginDir,
|
||||
extensionsDir,
|
||||
expectedPluginId: "memory-cognee",
|
||||
logger: { info: () => {}, warn: () => {} },
|
||||
});
|
||||
|
||||
expect(res.ok).toBe(true);
|
||||
if (!res.ok) {
|
||||
return;
|
||||
}
|
||||
expect(res.pluginId).toBe("memory-cognee");
|
||||
expect(res.targetDir).toBe(path.join(extensionsDir, "memory-cognee"));
|
||||
});
|
||||
});
|
||||
|
||||
describe("installPluginFromNpmSpec", () => {
|
||||
|
||||
@@ -158,7 +158,9 @@ async function installPluginFromPackageDir(params: {
|
||||
// uses the manifest id as the authoritative key, so the config entry must match it.
|
||||
const ocManifestResult = loadPluginManifest(params.packageDir);
|
||||
const manifestPluginId =
|
||||
ocManifestResult.ok && ocManifestResult.manifest.id ? ocManifestResult.manifest.id : undefined;
|
||||
ocManifestResult.ok && ocManifestResult.manifest.id
|
||||
? unscopedPackageName(ocManifestResult.manifest.id)
|
||||
: undefined;
|
||||
|
||||
const pluginId = manifestPluginId ?? npmPluginId;
|
||||
const pluginIdError = validatePluginId(pluginId);
|
||||
|
||||
Reference in New Issue
Block a user