fix(scripts): bound guard inventory file reads

This commit is contained in:
Vincent Koc
2026-05-26 01:49:13 +02:00
parent 60afca187d
commit 6defcb0a40
2 changed files with 12 additions and 6 deletions

View File

@@ -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);
})();

View File

@@ -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);