mirror of
https://github.com/openclaw/openclaw.git
synced 2026-10-03 09:39:25 +00:00
* perf(release): prepare publication artifacts during validation * fix(release): scope npm registry environment restoration * test(ci): align release artifact verification fixtures Account for newly tracked artifact tests and internal workflow-only inputs. Keep synthetic runner timing checks independent of unrelated suite budgets. Reuse the catalog-row selector fix already landed in #135597. * fix(release): preserve correction identity across prepared artifacts
33 lines
1.2 KiB
TypeScript
33 lines
1.2 KiB
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];
|
|
}
|
|
|
|
/** npm 12 keeps scalar view results in an array; exact-package reads require one value. */
|
|
export function resolveNpmJsonString(value: unknown): string {
|
|
const entries = resolveNpmJsonEntries(value);
|
|
const entry = entries.length === 1 ? entries[0] : undefined;
|
|
return typeof entry === "string" ? entry.trim() : "";
|
|
}
|