mirror of
https://github.com/openclaw/clawhub.git
synced 2026-08-14 00:47:57 +00:00
fix: normalize nested plugin manifests (#3343)
This commit is contained in:
@@ -171,6 +171,12 @@ describe("package-inspector-nightly-scan", () => {
|
||||
path.join(pluginRoot, "openclaw.plugin.json"),
|
||||
'\uFEFF{"id":"eu-compliance-skill"}\n',
|
||||
);
|
||||
const nestedPackageRoot = path.join(pluginRoot, "showmethemoney-skill", "demo-backend");
|
||||
await mkdir(nestedPackageRoot, { recursive: true });
|
||||
await writeFile(
|
||||
path.join(nestedPackageRoot, "package.json"),
|
||||
'\uFEFF{"name":"stablepay-demo-backend"}\n',
|
||||
);
|
||||
|
||||
await expect(
|
||||
prepareExtractedPluginRoot(pluginRoot, "npm-pack", "eu-compliance-skill"),
|
||||
@@ -185,6 +191,9 @@ describe("package-inspector-nightly-scan", () => {
|
||||
expect(await readFile(path.join(pluginRoot, "openclaw.plugin.json"), "utf8")).toBe(
|
||||
'{"id":"eu-compliance-skill"}\n',
|
||||
);
|
||||
expect(await readFile(path.join(nestedPackageRoot, "package.json"), "utf8")).toBe(
|
||||
'{"name":"stablepay-demo-backend"}\n',
|
||||
);
|
||||
});
|
||||
|
||||
it.each([
|
||||
|
||||
@@ -376,7 +376,7 @@ export async function prepareExtractedPluginRoot(
|
||||
if (artifactKind === "legacy-zip") {
|
||||
await removePosixArchiveMetadata(scanRoot);
|
||||
}
|
||||
await readJsonIfExists(path.join(scanRoot, "openclaw.plugin.json"));
|
||||
await normalizePluginJsonManifests(scanRoot);
|
||||
await writeSyntheticConfigIfNeeded(scanRoot, packageName);
|
||||
return scanRoot;
|
||||
}
|
||||
@@ -493,6 +493,23 @@ async function writeSyntheticConfigIfNeeded(root: string, packageName: string) {
|
||||
);
|
||||
}
|
||||
|
||||
async function normalizePluginJsonManifests(root: string): Promise<void> {
|
||||
const entries = await readdir(root, { withFileTypes: true });
|
||||
for (const entry of entries) {
|
||||
const entryPath = path.join(root, entry.name);
|
||||
if (entry.isDirectory()) {
|
||||
await normalizePluginJsonManifests(entryPath);
|
||||
continue;
|
||||
}
|
||||
if (
|
||||
entry.isFile() &&
|
||||
(entry.name === "package.json" || entry.name === "openclaw.plugin.json")
|
||||
) {
|
||||
await readJsonIfExists(entryPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function readJsonIfExists(filePath: string) {
|
||||
if (!existsSync(filePath)) return null;
|
||||
const contents = await readFile(filePath, "utf8");
|
||||
|
||||
Reference in New Issue
Block a user