#!/usr/bin/env node /** Post-build bundle check for accounting routes. */ import { existsSync, readdirSync, statSync } from "node:fs"; import { join } from "node:path"; import { fileURLToPath } from "node:url"; const ROOT = join(fileURLToPath(new URL(".", import.meta.url)), ".."); const NEXT_ACC = join(ROOT, ".next", "server", "app", "accounting"); console.log("Accounting Bundle Validation\n"); if (!existsSync(join(ROOT, ".next"))) { console.error("❌ Run npm run build first"); process.exit(1); } if (!existsSync(NEXT_ACC)) { console.error("❌ No compiled accounting routes"); process.exit(1); } function countRoutes(dir) { let n = 0; for (const e of readdirSync(dir)) { const f = join(dir, e); if (statSync(f).isDirectory()) n += countRoutes(f); else if (e.startsWith("page.")) n++; } return n; } const count = countRoutes(NEXT_ACC); console.log(`✅ Compiled accounting route segments: ${count}`); if (count < 80) { console.error(`❌ Expected >= 80, got ${count}`); process.exit(1); } process.exit(0);