Files
orca/config/scripts/static-analysis/process-boundaries/check-import-boundaries.mjs
Neil 6bb2e13c35 refactor(tooling): organize remaining scripts by domain owners (#38407)
* refactor(tooling): group remaining scripts by concrete domain owners

* fix(tooling): preserve relocated launcher resource roots
2026-11-05 00:29:16 -08:00

31 lines
1.2 KiB
JavaScript

import path from 'node:path'
import { pathToFileURL } from 'node:url'
import {
collectProcessHostSources,
main as checkProcessHostImports
} from './check-process-host-imports.mjs'
import { main as checkCompatBoundaryImports } from './check-compat-boundary-imports.mjs'
import { collectModuleSpecifiers } from '../module-requests/static-module-specifiers.mjs'
export function main(
root = process.cwd(),
{ collectSources = collectProcessHostSources, parseSpecifiers = collectModuleSpecifiers } = {}
) {
const sources = collectSources(root)
// These results belong only to this immutable source inventory and this invocation.
const specifiers = new Map()
const specifiersFor = (file, contents) => {
if (!specifiers.has(file)) {
specifiers.set(file, parseSpecifiers(file, contents))
}
return specifiers.get(file)
}
const processHost = checkProcessHostImports(root, sources, specifiersFor)
const compatibility = checkCompatBoundaryImports(root, sources, specifiersFor)
return Math.max(processHost, compatibility)
}
if (process.argv[1] && import.meta.url === pathToFileURL(path.resolve(process.argv[1])).href) {
process.exitCode = main()
}