diff --git a/package.json b/package.json index c8b350f..0380742 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "node": ">=22" }, "scripts": { - "build": "tsc --project tsconfig.json", + "build": "tsc --project tsconfig.json && node scripts/copy-assets.mjs", "dev": "tsx watch src/main.ts", "start": "node dist/main.js", "test": "vitest run", diff --git a/scripts/copy-assets.mjs b/scripts/copy-assets.mjs new file mode 100644 index 0000000..76686ed --- /dev/null +++ b/scripts/copy-assets.mjs @@ -0,0 +1,16 @@ +// Copies non-TypeScript build artifacts into dist/ after tsc. +// Currently: SQL migration files for the runtime migration runner. +// tsc only emits .ts → .js; everything else has to be copied explicitly. + +import { cpSync, existsSync } from 'node:fs'; + +const assets = [{ src: 'src/db/migrations', dest: 'dist/db/migrations' }]; + +for (const { src, dest } of assets) { + if (!existsSync(src)) { + console.error(`copy-assets: source missing: ${src}`); + process.exit(1); + } + cpSync(src, dest, { recursive: true }); + console.log(`copy-assets: ${src} -> ${dest}`); +}