import { spawnSync } from 'node:child_process'; export function compose(args) { const engine = ['docker', 'podman'].find(command => spawnSync(command, ['version'], { stdio: 'ignore' }).status === 0); if (!engine) throw new Error('Start Docker Desktop or Podman, then retry.'); const result = spawnSync(engine, ['compose', '--env-file', '.env', '-f', 'infra/compose.yaml', ...args], { stdio: 'inherit' }); if (result.error) throw result.error; if (result.status !== 0) throw new Error(`Compose failed (${result.status})`); } if (process.argv[1]?.replaceAll('\\', '/').endsWith('/compose.mjs')) compose(process.argv.slice(2));