| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | import { cpSync, rmSync, mkdirSync, copyFileSync, readdirSync, writeFileSync } from 'node:fs'; |
| 8 | import { execFileSync } from 'node:child_process'; |
| 9 | import path from 'node:path'; |
| 10 | import { fileURLToPath } from 'node:url'; |
| 11 | |
| 12 | const SRC = path.dirname(fileURLToPath(import.meta.url)); |
| 13 | const GAME = path.dirname(SRC); |
| 14 | const UP = path.resolve(process.argv[2] ?? ''); |
| 15 | const vite = path.join(UP, 'node_modules/.bin/vite'); |
| 16 | rmSync(path.join(UP, 'shoal'), { recursive: true, force: true }); |
| 17 | cpSync(SRC, path.join(UP, 'shoal'), { recursive: true }); |
| 18 | const run = (cfg) => execFileSync(vite, ['build', '-c', `shoal/${cfg}`], { cwd: UP, stdio: 'inherit' }); |
| 19 | |
| 20 | run('vite.engine.config.ts'); |
| 21 | copyFileSync(path.join(UP, 'dist/shoal-engine/sgs.mjs'), path.join(GAME, 'referee/sgs.mjs')); |
| 22 | const { catalog } = await import(`${path.join(GAME, 'referee/sgs.mjs')}?${Date.now()}`); |
| 23 | writeFileSync(path.join(GAME, 'referee/generals.json'), `${JSON.stringify(await catalog(), null, 1)}\n`); |
| 24 | |
| 25 | if (process.argv[3] !== '--engine') { |
| 26 | run('vite.viewer.config.ts'); |
| 27 | const out = path.join(UP, 'dist/shoal-viewer'); |
| 28 | for (const f of readdirSync(path.join(GAME, 'viewer'))) if (!['bridge.js', 'NOTICE', 'art'].includes(f)) rmSync(path.join(GAME, 'viewer', f), { recursive: true }); |
| 29 | mkdirSync(path.join(GAME, 'viewer'), { recursive: true }); |
| 30 | for (const f of readdirSync(out)) cpSync(path.join(out, f), path.join(GAME, 'viewer', f), { recursive: true }); |
| 31 | } |