mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 09:10:45 +00:00
build: verify bundled plugin runtime mirrors in postpublish checks (#60112)
Merged via squash.
Prepared head SHA: 79bbb105a8
Co-authored-by: medns <1575008+medns@users.noreply.github.com>
Co-authored-by: odysseus0 <8635094+odysseus0@users.noreply.github.com>
Reviewed-by: @odysseus0
This commit is contained in:
@@ -151,6 +151,10 @@ function extractModuleSpecifiers(source) {
|
||||
return specifiers;
|
||||
}
|
||||
|
||||
function isPluginOwnedDistImporter(relativePath, pluginIds) {
|
||||
return pluginIds.some((pluginId) => relativePath.startsWith(`extensions/${pluginId}/`));
|
||||
}
|
||||
|
||||
export function collectRootDistBundledRuntimeMirrors(params) {
|
||||
const distDir = params.distDir;
|
||||
const bundledSpecs = params.bundledRuntimeDependencySpecs;
|
||||
@@ -177,6 +181,9 @@ export function collectRootDistBundledRuntimeMirrors(params) {
|
||||
continue;
|
||||
}
|
||||
const bundledSpec = bundledSpecs.get(dependencyName);
|
||||
if (isPluginOwnedDistImporter(relativePath, bundledSpec.pluginIds)) {
|
||||
continue;
|
||||
}
|
||||
const existing = mirrors.get(dependencyName);
|
||||
if (existing) {
|
||||
existing.importers.add(relativePath);
|
||||
@@ -195,6 +202,7 @@ export function collectRootDistBundledRuntimeMirrors(params) {
|
||||
|
||||
export function collectBundledPluginRootRuntimeMirrorErrors(params) {
|
||||
const errors = [];
|
||||
const declaredRootRuntimeDeps = collectRuntimeDependencySpecs(params.rootPackageJson);
|
||||
|
||||
for (const [dependencyName, record] of params.bundledRuntimeDependencySpecs) {
|
||||
for (const conflict of record.conflicts) {
|
||||
@@ -204,5 +212,17 @@ export function collectBundledPluginRootRuntimeMirrorErrors(params) {
|
||||
}
|
||||
}
|
||||
|
||||
return errors;
|
||||
for (const [dependencyName, record] of params.requiredRootMirrors) {
|
||||
if (declaredRootRuntimeDeps.has(dependencyName)) {
|
||||
continue;
|
||||
}
|
||||
const importerList = Array.from(record.importers)
|
||||
.toSorted((left, right) => left.localeCompare(right))
|
||||
.join(", ");
|
||||
errors.push(
|
||||
`installed package root is missing mirrored bundled runtime dependency '${dependencyName}' for dist importers: ${importerList}. Add it to package.json dependencies/optionalDependencies or keep imports under dist/extensions/${record.pluginIds[0]}/.`,
|
||||
);
|
||||
}
|
||||
|
||||
return errors.toSorted((left, right) => left.localeCompare(right));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user