// Ship verified local output as plain static files: no paid HF build step. import { cpSync, existsSync, mkdirSync, readdirSync, rmSync } from 'node:fs'; import { resolve, dirname, sep } from 'node:path'; import { fileURLToPath } from 'node:url'; const root = resolve(dirname(fileURLToPath(import.meta.url)), '..'); const output = resolve(root, 'site'); if (output !== resolve(root, 'site') || !output.startsWith(root + sep)) throw new Error('Unexpected output path'); if (!existsSync(resolve(root, 'dist/index.html'))) throw new Error('Build dist/index.html first'); mkdirSync(output, {recursive: true}); for (const entry of readdirSync(output)) rmSync(resolve(output, entry), {recursive: true, force: true}); cpSync(resolve(root, 'dist'), output, {recursive: true}); console.log('Prepared site/ for static publication. Commit it with the source.');