mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-12 21:53:00 -06:00
c70aee247e
* refactor(scripts): migrate JavaScript tools to TypeScript * fix(ci): keep changed-scope preflight zero-install * fix(ci): preserve zero-install script owners * fix(ci): complete script migration follow-through * fix(release): keep stable closeout zero-install * fix(scripts): preserve standalone execution boundaries * fix(scripts): repair standalone loader boundaries * fix(scripts): normalize gateway observation ids * fix(scripts): keep Docker packager standalone * test(scripts): preserve rebase cleanup helpers * test(sessions): use tracked temp directory
27 lines
941 B
TypeScript
27 lines
941 B
TypeScript
/**
|
|
* 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: unknown): unknown[] {
|
|
if (Array.isArray(value)) {
|
|
return value;
|
|
}
|
|
if (value && typeof value === "object") {
|
|
const looksLikeEntry =
|
|
("id" in value && typeof value.id === "string") ||
|
|
("name" in value && typeof value.name === "string") ||
|
|
("version" in value && typeof value.version === "string") ||
|
|
("filename" in value && 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];
|
|
}
|