Introduces modules/hospitality with 54 routes, BFF proxy, capability-gated nav, CRUD factory, and architecture validation docs. Co-authored-by: Cursor <cursoragent@cursor.com>
56 lines
1.6 KiB
JavaScript
56 lines
1.6 KiB
JavaScript
#!/usr/bin/env node
|
|
/** Validates hospitality frontend routes exist and import paths resolve. */
|
|
import fs from "node:fs";
|
|
import path from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
const ROOT = path.join(path.dirname(fileURLToPath(import.meta.url)), "..");
|
|
const APP = path.join(ROOT, "app", "hospitality");
|
|
const FEATURES = path.join(ROOT, "modules", "hospitality", "features");
|
|
|
|
let errors = 0;
|
|
|
|
function walk(dir, acc = []) {
|
|
if (!fs.existsSync(dir)) return acc;
|
|
for (const e of fs.readdirSync(dir)) {
|
|
const full = path.join(dir, e);
|
|
if (fs.statSync(full).isDirectory()) walk(full, acc);
|
|
else if (e === "page.tsx") acc.push(full);
|
|
}
|
|
return acc;
|
|
}
|
|
|
|
for (const page of walk(APP)) {
|
|
const content = fs.readFileSync(page, "utf8");
|
|
const m = content.match(/features\/([^"']+)/);
|
|
if (!m) {
|
|
console.error("Missing feature import:", page);
|
|
errors++;
|
|
continue;
|
|
}
|
|
const featureFile = path.join(FEATURES, `${m[1]}.tsx`);
|
|
if (!fs.existsSync(featureFile)) {
|
|
console.error("Missing feature file:", featureFile, "for", page);
|
|
errors++;
|
|
}
|
|
}
|
|
|
|
const required = [
|
|
"modules/hospitality/services/hospitality-api.ts",
|
|
"app/api/hospitality/[...path]/route.ts",
|
|
"modules/hospitality/components/HospitalityPortalShell.tsx",
|
|
];
|
|
|
|
for (const f of required) {
|
|
if (!fs.existsSync(path.join(ROOT, f))) {
|
|
console.error("Missing required:", f);
|
|
errors++;
|
|
}
|
|
}
|
|
|
|
if (errors) {
|
|
console.error(`Hospitality validation failed: ${errors} error(s)`);
|
|
process.exit(1);
|
|
}
|
|
console.log(`Hospitality validation passed (${walk(APP).length} routes)`);
|