mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-06 05:51:15 +08:00
fix(scripts): bound guard inventory file reads
This commit is contained in:
@@ -15,6 +15,7 @@ import {
|
||||
resolveSourceRoots,
|
||||
runAsScript,
|
||||
} from "./lib/ts-guard-utils.mjs";
|
||||
import { mapWithConcurrency } from "./lib/source-file-scan-cache.mjs";
|
||||
|
||||
const repoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
||||
const scanRoots = resolveSourceRoots(repoRoot, ["src/plugin-sdk", "src/plugins/runtime"]);
|
||||
@@ -170,14 +171,16 @@ export async function collectArchitectureSmells() {
|
||||
const files = (await collectTypeScriptFilesFromRoots(scanRoots)).toSorted((left, right) =>
|
||||
normalizeRepoPath(repoRoot, left).localeCompare(normalizeRepoPath(repoRoot, right)),
|
||||
);
|
||||
const entriesByFile = await Promise.all(
|
||||
files.map(async (filePath) => {
|
||||
const entriesByFile = await mapWithConcurrency(
|
||||
files,
|
||||
undefined,
|
||||
async (filePath) => {
|
||||
const source = await fs.readFile(filePath, "utf8");
|
||||
const entries = scanPluginSdkExtensionFacadeSmells(source, filePath);
|
||||
entries.push(...scanRuntimeTypeImplementationSmells(source, filePath));
|
||||
entries.push(...scanRuntimeServiceLocatorSmells(source, filePath));
|
||||
return entries;
|
||||
}),
|
||||
},
|
||||
);
|
||||
return entriesByFile.flat().toSorted(compareEntries);
|
||||
})();
|
||||
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
resolveRepoRoot,
|
||||
resolveSourceRoots,
|
||||
} from "./ts-guard-utils.mjs";
|
||||
import { mapWithConcurrency } from "./source-file-scan-cache.mjs";
|
||||
|
||||
const repoRoot = resolveRepoRoot(import.meta.url);
|
||||
|
||||
@@ -72,8 +73,10 @@ export function createExtensionImportBoundaryChecker(params) {
|
||||
.toSorted((left, right) =>
|
||||
normalizeRepoPath(repoRoot, left).localeCompare(normalizeRepoPath(repoRoot, right)),
|
||||
);
|
||||
const entriesByFile = await Promise.all(
|
||||
files.map(async (filePath) => {
|
||||
const entriesByFile = await mapWithConcurrency(
|
||||
files,
|
||||
undefined,
|
||||
async (filePath) => {
|
||||
const source = await fs.readFile(filePath, "utf8");
|
||||
if (
|
||||
params.skipSourcesWithoutBundledPluginPrefix &&
|
||||
@@ -87,7 +90,7 @@ export function createExtensionImportBoundaryChecker(params) {
|
||||
params.boundaryLabel,
|
||||
params.allowResolvedPath,
|
||||
);
|
||||
}),
|
||||
},
|
||||
);
|
||||
const inventory = entriesByFile.flat();
|
||||
return inventory.toSorted(compareEntries);
|
||||
|
||||
Reference in New Issue
Block a user