fix(ci): verify bundled plugin runtime deps

This commit is contained in:
Vincent Koc
2026-04-13 10:47:50 +01:00
parent 9e2ac8a1cb
commit 21ca387eda
7 changed files with 175 additions and 2 deletions

View File

@@ -45,6 +45,18 @@ function collectPackageJsonPaths(rootDir) {
.toSorted((left, right) => left.localeCompare(right));
}
function usesStagedRuntimeDependencies(packageJson) {
return packageJson?.openclaw?.bundle?.stageRuntimeDependencies === true;
}
function dependencySentinelPath(packageRoot, dependencyName) {
return path.join(packageRoot, "node_modules", ...dependencyName.split("/"), "package.json");
}
function pluginIdFromPackageJsonPath(packageJsonPath) {
return path.basename(path.dirname(packageJsonPath));
}
export function collectBundledPluginRuntimeDependencySpecs(bundledPluginsDir) {
const specs = new Map();
@@ -68,6 +80,30 @@ export function collectBundledPluginRuntimeDependencySpecs(bundledPluginsDir) {
return specs;
}
export function collectBuiltBundledPluginStagedRuntimeDependencyErrors(params) {
const errors = [];
for (const packageJsonPath of collectPackageJsonPaths(params.bundledPluginsDir)) {
const packageJson = readJson(packageJsonPath);
if (!usesStagedRuntimeDependencies(packageJson)) {
continue;
}
const pluginId = pluginIdFromPackageJsonPath(packageJsonPath);
const pluginRoot = path.dirname(packageJsonPath);
for (const [dependencyName, spec] of collectRuntimeDependencySpecs(packageJson)) {
if (!fs.existsSync(dependencySentinelPath(pluginRoot, dependencyName))) {
const specText = String(spec);
errors.push(
`built bundled plugin '${pluginId}' is missing staged runtime dependency '${dependencyName}: ${specText}' under dist/extensions/${pluginId}/node_modules.`,
);
}
}
}
return errors.toSorted((left, right) => left.localeCompare(right));
}
function walkJavaScriptFiles(rootDir) {
const files = [];
if (!fs.existsSync(rootDir)) {