mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-25 11:55:47 -06:00
1ece62a4d8
* fix(release): preflight package source metadata * fix(ci): gate source package producers * fix(ci): preflight canonical package producers * fix(ci): skip no-package source setup * fix(ci): normalize source package validation * fix(ci): normalize Docker package reporting * fix(ci): avoid generic dependency guard * test(ci): cover gated package identity
42 lines
1.4 KiB
JavaScript
42 lines
1.4 KiB
JavaScript
const PRIVATE_WORKSPACE_VERSION = "0.0.0-private";
|
|
|
|
function dependenciesRecord(value, label) {
|
|
if (value === undefined) {
|
|
return {};
|
|
}
|
|
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
throw new Error(`${label} dependencies must be an object when present`);
|
|
}
|
|
return value;
|
|
}
|
|
|
|
export function validateBundledPackageDependencyAlignment({
|
|
bundledDependencies,
|
|
bundledPackageLabel,
|
|
rootDependencies,
|
|
rootPackageLabel = "root package.json",
|
|
}) {
|
|
const bundled = dependenciesRecord(bundledDependencies, bundledPackageLabel);
|
|
const root = dependenciesRecord(rootDependencies, rootPackageLabel);
|
|
const aligned = [];
|
|
for (const [name, version] of Object.entries(bundled)) {
|
|
if (typeof version !== "string") {
|
|
throw new Error(`${bundledPackageLabel} dependency ${name} must declare a string version`);
|
|
}
|
|
if (version === PRIVATE_WORKSPACE_VERSION) {
|
|
continue;
|
|
}
|
|
const rootVersion = root[name];
|
|
if (rootVersion !== undefined && typeof rootVersion !== "string") {
|
|
throw new Error(`${rootPackageLabel} dependency ${name} must declare a string version`);
|
|
}
|
|
if (rootVersion !== version && rootVersion !== `workspace:${version}`) {
|
|
throw new Error(
|
|
`${rootPackageLabel} must declare ${name}@${version} to bundle @openclaw/ai without duplicate dependencies`,
|
|
);
|
|
}
|
|
aligned.push([name, version]);
|
|
}
|
|
return aligned;
|
|
}
|