mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-14 06:33:09 -06:00
7866ecae4b
* fix(release): accept npm 12 pack json * fix(release): share npm pack normalizer in plugin workflow
27 lines
832 B
JavaScript
27 lines
832 B
JavaScript
/**
|
|
* Normalize npm <=11 entry/array JSON and npm 12 name-keyed JSON.
|
|
* Keep pack consumers on one dependency-contract boundary so a package-manager
|
|
* upgrade cannot silently bypass release, installer, or security checks.
|
|
*/
|
|
export function resolveNpmJsonEntries(value) {
|
|
if (Array.isArray(value)) {
|
|
return value;
|
|
}
|
|
if (value && typeof value === "object") {
|
|
const looksLikeEntry =
|
|
typeof value.id === "string" ||
|
|
typeof value.name === "string" ||
|
|
typeof value.version === "string" ||
|
|
typeof value.filename === "string";
|
|
if (!looksLikeEntry) {
|
|
const entries = Object.values(value).filter(
|
|
(entry) => Boolean(entry) && typeof entry === "object" && !Array.isArray(entry),
|
|
);
|
|
if (entries.length > 0) {
|
|
return entries;
|
|
}
|
|
}
|
|
}
|
|
return [value];
|
|
}
|