import fs from "node:fs"
import path from "node:path"

const schemaDir = path.resolve("db/schema")
const indexFile = path.join(schemaDir, "index.ts")

const files = fs
    .readdirSync(schemaDir)
    .filter((f) => f.endsWith(".ts") && f !== "index.ts")

const exportsToWrite = files
    .map((f) => `export * from "./${f.replace(".ts", "")}"`)
    .join("\n")

fs.writeFileSync(indexFile, exportsToWrite)
console.log("✓ schema/index.ts generated")