import { spawnSync } from 'node:child_process'; import { dirname, resolve } from 'node:path'; import { fileURLToPath } from 'node:url'; const appRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..'); const repoRoot = resolve(appRoot, '../..'); const npmCli = process.env.npm_execpath ?? resolve(dirname(process.execPath), 'node_modules/npm/bin/npm-cli.js'); function run(args, extraEnv = {}) { const result = spawnSync(process.execPath, [npmCli, ...args], { cwd: appRoot, env: { ...process.env, ...extraEnv }, stdio: 'inherit', }); if (result.error) { throw result.error; } if (result.status !== 0) { process.exit(result.status ?? 1); } } run(['--prefix', repoRoot, 'run', 'ai-game-creator-shell:typecheck']); run( [ '--prefix', repoRoot, 'exec', 'vite', '--', 'build', '--config', 'vite.config.ts', ], { VITE_AGC_GAME_CHAT_ONLY: 'true' }, );