mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-02 02:10:22 +00:00
plugins: quiet scoped manifest id warnings
This commit is contained in:
@@ -264,12 +264,20 @@ async function installFromFileWithWarnings(params: { extensionsDir: string; file
|
||||
return { result, warnings };
|
||||
}
|
||||
|
||||
function setupManifestInstallFixture(params: { manifestId: string }) {
|
||||
function setupManifestInstallFixture(params: { manifestId: string; packageName?: string }) {
|
||||
const caseDir = makeTempDir();
|
||||
const stateDir = path.join(caseDir, "state");
|
||||
const pluginDir = path.join(caseDir, "plugin-src");
|
||||
fs.mkdirSync(stateDir, { recursive: true });
|
||||
fs.cpSync(manifestInstallTemplateDir, pluginDir, { recursive: true });
|
||||
if (params.packageName) {
|
||||
const packageJsonPath = path.join(pluginDir, "package.json");
|
||||
const manifest = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8")) as {
|
||||
name?: string;
|
||||
};
|
||||
manifest.name = params.packageName;
|
||||
fs.writeFileSync(packageJsonPath, JSON.stringify(manifest), "utf-8");
|
||||
}
|
||||
fs.writeFileSync(
|
||||
path.join(pluginDir, "openclaw.plugin.json"),
|
||||
JSON.stringify({
|
||||
@@ -1080,6 +1088,23 @@ describe("installPluginFromDir", () => {
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("does not warn when a scoped npm package name matches the manifest id", async () => {
|
||||
const { pluginDir, extensionsDir } = setupManifestInstallFixture({
|
||||
manifestId: "matrix",
|
||||
packageName: "@openclaw/matrix",
|
||||
});
|
||||
|
||||
const infoMessages: string[] = [];
|
||||
const res = await installPluginFromDir({
|
||||
dirPath: pluginDir,
|
||||
extensionsDir,
|
||||
logger: { info: (msg: string) => infoMessages.push(msg), warn: () => {} },
|
||||
});
|
||||
|
||||
expectInstalledWithPluginId(res, extensionsDir, "matrix");
|
||||
expect(infoMessages.some((msg) => msg.includes("differs from npm package name"))).toBe(false);
|
||||
});
|
||||
|
||||
it.each([
|
||||
{
|
||||
name: "manifest id wins for scoped plugin ids",
|
||||
|
||||
Reference in New Issue
Block a user