import { readdir, readFile } from "node:fs/promises" import path from "node:path" const uiComponentsPath = path.join("src", "components", "ui") const componentEntries = await readdir(uiComponentsPath, { withFileTypes: true }) const components = componentEntries .filter((entry) => entry.isDirectory()) .map((entry) => entry.name) .sort((a, b) => a.localeCompare(b)) const failures = [] for (const component of components) { const indexPath = path.join(uiComponentsPath, component, "index.ts") try { const source = await readFile(indexPath, "utf8") if (!source.includes("export default")) { failures.push(`${indexPath}: missing default export`) } } catch (error) { if (error.code !== "ENOENT") { throw error } failures.push(`${indexPath}: missing file`) } } if (failures.length > 0) { console.error(failures.join("\n")) process.exit(1) } console.log(`Checked ${components.length} component exports.`)