openreader/scripts/check-compute-boundary.mjs
Richard R 358a56cc9a refactor: implement modular monorepo packages
- Extract database schema and migrations into @openreader/database

- Extract startup and orchestration scripts into @openreader/bootstrap

- Move compute-worker into packages/compute-worker

- Remove runtime dependency on drizzle-kit

- Update Dockerfile to deploy isolated packages without merging node_modules
2026-06-13 13:51:18 -06:00

39 lines
1.1 KiB
JavaScript

import fs from 'node:fs';
import path from 'node:path';
const root = process.cwd();
const forbidden = [
'@openreader/compute-core',
'@openreader/compute-worker',
'compute/core',
'compute/worker',
'packages/compute-worker/src',
];
const failures = [];
function walk(dir) {
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
const fullPath = path.join(dir, entry.name);
if (entry.isDirectory()) {
walk(fullPath);
continue;
}
if (!entry.isFile() || !/\.(ts|tsx|js|mjs|cjs)$/.test(entry.name)) continue;
const text = fs.readFileSync(fullPath, 'utf8');
for (const pattern of forbidden) {
if (text.includes(pattern)) failures.push({ file: fullPath, pattern });
}
}
}
walk(path.join(root, 'src'));
if (failures.length > 0) {
console.error('[compute-boundary] Forbidden app-to-worker source coupling detected:');
for (const failure of failures) {
console.error(`- ${failure.pattern} in ${path.relative(root, failure.file)}`);
}
process.exit(1);
}
console.info('[compute-boundary] OK: app communicates with compute worker through protocol/client only');