import { $ } from 'bun'; import path from 'path'; import fs from 'fs/promises'; import { buildHTML } from "./html"; import inquirer from 'inquirer'; import { isGame, getGames } from './isGame'; const outDir = path.resolve(import.meta.dir, '..', '..', 'dist'); await fs.mkdir(outDir, { recursive: true }); let game = process.argv[2]; const publish = process.env.PUBLISH_LOCATION; while (!await isGame(game)) { const answer = await inquirer.prompt([{ type: 'list', name: 'game', choices: await getGames(), }]); game = answer.game; } const html = await buildHTML(game, true); if (!html) { process.exit(1); } const filePath = path.resolve(outDir, `${game}.html`); await Bun.write(filePath, html); if (publish) { const result = await $`scp "${filePath}" "${publish}${game}.html"`; if (result.exitCode === 0) { console.log(`Build successful: ${process.env.PUBLISH_URL}${game}.html`); } }