mirror of
https://github.com/moltbot/moltbot.git
synced 2026-04-21 05:32:53 +00:00
fix(scripts): normalize bundled entry paths and planner counts
This commit is contained in:
@@ -8,6 +8,7 @@ import {
|
||||
import { shouldBuildBundledCluster } from "./optional-bundled-clusters.mjs";
|
||||
|
||||
const TOP_LEVEL_PUBLIC_SURFACE_EXTENSIONS = new Set([".ts", ".js", ".mts", ".cts", ".mjs", ".cjs"]);
|
||||
const toPosixPath = (value) => value.replaceAll("\\", "/");
|
||||
|
||||
function readBundledPluginPackageJson(packageJsonPath) {
|
||||
if (!fs.existsSync(packageJsonPath)) {
|
||||
@@ -132,7 +133,7 @@ export function listBundledPluginBuildEntries(params = {}) {
|
||||
sourceEntries.map((entry) => {
|
||||
const normalizedEntry = entry.replace(/^\.\//, "");
|
||||
const entryKey = bundledPluginFile(id, normalizedEntry.replace(/\.[^.]+$/u, ""));
|
||||
return [entryKey, path.join(BUNDLED_PLUGIN_ROOT_DIR, id, normalizedEntry)];
|
||||
return [entryKey, toPosixPath(path.join(BUNDLED_PLUGIN_ROOT_DIR, id, normalizedEntry))];
|
||||
}),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -111,6 +111,19 @@ function getPlanLines(output: string, prefix: string): string[] {
|
||||
.filter((line) => line.startsWith(prefix));
|
||||
}
|
||||
|
||||
function getTargetedChannelPlanLines(output: string): string[] {
|
||||
return output
|
||||
.split("\n")
|
||||
.map((line) => line.trim())
|
||||
.filter(
|
||||
(line) =>
|
||||
line.startsWith("channels-batch-") ||
|
||||
(line.includes("surface=channels") &&
|
||||
line.includes("isolate=yes") &&
|
||||
/^channels-.*-isolated\b/u.test(line)),
|
||||
);
|
||||
}
|
||||
|
||||
function parseNumericPlanField(line: string, key: string): number {
|
||||
const match = line.match(new RegExp(`\\b${key}=(\\d+)\\b`));
|
||||
if (!match) {
|
||||
@@ -349,13 +362,17 @@ describe("scripts/test-parallel lane planning", () => {
|
||||
const channelBatchFilterCounts = channelBatchLines.map((line) =>
|
||||
parseNumericPlanField(line, "filters"),
|
||||
);
|
||||
const targetedChannelPlanLines = getTargetedChannelPlanLines(output);
|
||||
|
||||
expect(channelBatchLines.length).toBeGreaterThanOrEqual(4);
|
||||
expect(channelBatchLines.every((line) => line.includes("maxWorkers=5"))).toBe(true);
|
||||
expect(Math.max(...channelBatchFilterCounts)).toBeLessThan(30);
|
||||
expect(channelBatchFilterCounts.reduce((sum, count) => sum + count, 0)).toBe(
|
||||
sharedTargetedChannelProxyFiles.length,
|
||||
);
|
||||
expect(
|
||||
targetedChannelPlanLines.reduce(
|
||||
(sum, line) => sum + parseNumericPlanField(line, "filters"),
|
||||
0,
|
||||
),
|
||||
).toBe(targetedChannelProxyFiles.length);
|
||||
});
|
||||
|
||||
it("uses targeted unit batching on high-memory local hosts", () => {
|
||||
|
||||
Reference in New Issue
Block a user