mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 07:10:43 +00:00
fix: align postpublish verification with external plugins
(cherry picked from commit abe2b294ae)
This commit is contained in:
@@ -50,9 +50,16 @@ const PUBLISHED_BUNDLED_RUNTIME_SIDECAR_PATHS = BUNDLED_RUNTIME_SIDECAR_PATHS.fi
|
||||
);
|
||||
const NODE_BUILTIN_MODULES = new Set(builtinModules.map((name) => name.replace(/^node:/u, "")));
|
||||
const MAX_INSTALLED_ROOT_PACKAGE_JSON_BYTES = 1024 * 1024;
|
||||
const MAX_INSTALLED_ROOT_DIST_JS_BYTES = 2 * 1024 * 1024;
|
||||
const MAX_INSTALLED_ROOT_DIST_JS_BYTES = 4 * 1024 * 1024;
|
||||
const MAX_INSTALLED_ROOT_DIST_JS_FILES = 5000;
|
||||
const ROOT_DIST_JAVASCRIPT_MODULE_FILE_RE = /\.(?:c|m)?js$/u;
|
||||
const OPTIONAL_OR_EXTERNALIZED_RUNTIME_IMPORTS = new Set([
|
||||
"@discordjs/opus",
|
||||
"@lancedb/lancedb",
|
||||
"@matrix-org/matrix-sdk-crypto-nodejs",
|
||||
"link-preview-js",
|
||||
"matrix-js-sdk",
|
||||
]);
|
||||
const require = createRequire(import.meta.url);
|
||||
const acorn = require("acorn") as typeof import("acorn");
|
||||
|
||||
@@ -102,7 +109,7 @@ export function collectInstalledPackageErrors(params: {
|
||||
);
|
||||
}
|
||||
|
||||
for (const relativePath of PUBLISHED_BUNDLED_RUNTIME_SIDECAR_PATHS) {
|
||||
for (const relativePath of collectInstalledBundledRuntimeSidecarPaths(params.packageRoot)) {
|
||||
if (!existsSync(join(params.packageRoot, relativePath))) {
|
||||
errors.push(`installed package is missing required bundled runtime sidecar: ${relativePath}`);
|
||||
}
|
||||
@@ -114,6 +121,31 @@ export function collectInstalledPackageErrors(params: {
|
||||
return errors;
|
||||
}
|
||||
|
||||
function collectInstalledBundledExtensionIds(packageRoot: string): Set<string> {
|
||||
const extensionsDir = join(packageRoot, "dist", "extensions");
|
||||
if (!existsSync(extensionsDir)) {
|
||||
return new Set();
|
||||
}
|
||||
const ids = new Set<string>();
|
||||
for (const entry of readdirSync(extensionsDir, { withFileTypes: true })) {
|
||||
if (!entry.isDirectory()) {
|
||||
continue;
|
||||
}
|
||||
if (existsSync(join(extensionsDir, entry.name, "package.json"))) {
|
||||
ids.add(entry.name);
|
||||
}
|
||||
}
|
||||
return ids;
|
||||
}
|
||||
|
||||
export function collectInstalledBundledRuntimeSidecarPaths(packageRoot: string): string[] {
|
||||
const installedExtensionIds = collectInstalledBundledExtensionIds(packageRoot);
|
||||
return PUBLISHED_BUNDLED_RUNTIME_SIDECAR_PATHS.filter((relativePath) => {
|
||||
const match = /^dist\/extensions\/([^/]+)\//u.exec(relativePath);
|
||||
return match !== null && installedExtensionIds.has(match[1]);
|
||||
});
|
||||
}
|
||||
|
||||
export function normalizeInstalledBinaryVersion(output: string): string {
|
||||
const trimmed = output.trim();
|
||||
const versionMatch = /\b\d{4}\.\d{1,2}\.\d{1,2}(?:-\d+|-beta\.\d+)?\b/u.exec(trimmed);
|
||||
@@ -304,6 +336,7 @@ export function collectInstalledRootDependencyManifestErrors(packageRoot: string
|
||||
if (
|
||||
!dependencyName ||
|
||||
NODE_BUILTIN_MODULES.has(dependencyName) ||
|
||||
OPTIONAL_OR_EXTERNALIZED_RUNTIME_IMPORTS.has(dependencyName) ||
|
||||
declaredRuntimeDeps.has(dependencyName) ||
|
||||
isBundledExtensionOwnedRuntimeImport({
|
||||
dependencyName,
|
||||
|
||||
Reference in New Issue
Block a user