mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-03 21:14:04 +00:00
Extract web-content shared runtime helpers into packages/web-content-core, move the focused tests with the new package, and split quiet CI shards so the node matrix no longer stalls past the no-output watchdog.\n\nVerification: node scripts/run-vitest.mjs test/scripts/ci-node-test-plan.test.ts test/scripts/run-vitest.test.ts src/infra/restart.test.ts src/infra/os-summary.test.ts src/infra/gateway-processes.test.ts src/infra/inline-option-token.test.ts src/infra/map-size.test.ts src/infra/machine-name.test.ts src/commands/doctor-whatsapp-responsiveness.test.ts; autoreview clean; manual CI https://github.com/openclaw/openclaw/actions/runs/26693962844; dependency guard https://github.com/openclaw/openclaw/actions/runs/26693959937. Admin merge used because optional Mantis Telegram Desktop proof was cancelled after blocking merge outside this PR's required proof.
87 lines
3.2 KiB
JavaScript
87 lines
3.2 KiB
JavaScript
import path from "node:path";
|
|
import {
|
|
BUNDLED_PLUGIN_PATH_PREFIX,
|
|
BUNDLED_PLUGIN_ROOT_DIR,
|
|
} from "./lib/bundled-plugin-paths.mjs";
|
|
|
|
const RUN_NODE_PACKAGE_SOURCE_ROOTS = [
|
|
// Root runtime code imports these package sources through tsconfig aliases,
|
|
// while pnpm dev/watch still runs the root dist entrypoint. Treat them like
|
|
// src/ so edits restart the same process that consumes them.
|
|
"packages/gateway-client/src",
|
|
"packages/gateway-protocol/src",
|
|
"packages/markdown-core/src",
|
|
"packages/media-generation-core/src",
|
|
"packages/media-understanding-common/src",
|
|
"packages/terminal-core/src",
|
|
"packages/web-content-core/src",
|
|
"packages/net-policy/src",
|
|
];
|
|
|
|
export const runNodeSourceRoots = [
|
|
"src",
|
|
...RUN_NODE_PACKAGE_SOURCE_ROOTS,
|
|
BUNDLED_PLUGIN_ROOT_DIR,
|
|
];
|
|
export const runNodeConfigFiles = ["tsconfig.json", "package.json", "tsdown.config.ts"];
|
|
export const runNodeWatchedPaths = [...runNodeSourceRoots, ...runNodeConfigFiles];
|
|
export const extensionRestartMetadataFiles = new Set(["openclaw.plugin.json", "package.json"]);
|
|
|
|
const ignoredRunNodeRepoPathPatterns = [
|
|
/^extensions\/[^/]+\/src\/host\/.+\/\.bundle\.hash$/u,
|
|
/^extensions\/[^/]+\/src\/host\/.+\/[^/]+\.bundle\.js$/u,
|
|
];
|
|
const extensionSourceFilePattern = /\.(?:[cm]?[jt]sx?)$/;
|
|
|
|
export const normalizeRunNodePath = (filePath) => String(filePath ?? "").replaceAll("\\", "/");
|
|
|
|
const isIgnoredSourcePath = (relativePath) => {
|
|
const normalizedPath = normalizeRunNodePath(relativePath);
|
|
return (
|
|
normalizedPath.endsWith(".test.ts") ||
|
|
normalizedPath.endsWith(".test.tsx") ||
|
|
normalizedPath.endsWith("test-helpers.ts")
|
|
);
|
|
};
|
|
|
|
const isBuildRelevantSourcePath = (relativePath) => {
|
|
const normalizedPath = normalizeRunNodePath(relativePath);
|
|
return extensionSourceFilePattern.test(normalizedPath) && !isIgnoredSourcePath(normalizedPath);
|
|
};
|
|
|
|
const isRestartRelevantExtensionPath = (relativePath) => {
|
|
const normalizedPath = normalizeRunNodePath(relativePath);
|
|
if (extensionRestartMetadataFiles.has(path.posix.basename(normalizedPath))) {
|
|
return true;
|
|
}
|
|
return isBuildRelevantSourcePath(normalizedPath);
|
|
};
|
|
|
|
const isRelevantRunNodePath = (repoPath, isRelevantBundledPluginPath) => {
|
|
const normalizedPath = normalizeRunNodePath(repoPath).replace(/^\.\/+/, "");
|
|
if (ignoredRunNodeRepoPathPatterns.some((pattern) => pattern.test(normalizedPath))) {
|
|
return false;
|
|
}
|
|
if (runNodeConfigFiles.includes(normalizedPath)) {
|
|
return true;
|
|
}
|
|
if (normalizedPath.startsWith("src/")) {
|
|
return !isIgnoredSourcePath(normalizedPath.slice("src/".length));
|
|
}
|
|
for (const sourceRoot of RUN_NODE_PACKAGE_SOURCE_ROOTS) {
|
|
if (normalizedPath.startsWith(`${sourceRoot}/`)) {
|
|
return !isIgnoredSourcePath(normalizedPath.slice(sourceRoot.length + 1));
|
|
}
|
|
}
|
|
if (normalizedPath.startsWith(BUNDLED_PLUGIN_PATH_PREFIX)) {
|
|
return isRelevantBundledPluginPath(normalizedPath.slice(BUNDLED_PLUGIN_PATH_PREFIX.length));
|
|
}
|
|
return false;
|
|
};
|
|
|
|
export const isBuildRelevantRunNodePath = (repoPath) =>
|
|
isRelevantRunNodePath(repoPath, isBuildRelevantSourcePath);
|
|
|
|
export const isRestartRelevantRunNodePath = (repoPath) =>
|
|
isRelevantRunNodePath(repoPath, isRestartRelevantExtensionPath);
|