import { spawnSync } from "node:child_process"; import { assertE2EDatabase, e2eEnv, root } from "./env.mjs"; const action = process.argv[2]; if (!['up', 'down'].includes(action)) throw new Error("Usage: db.mjs up|down"); assertE2EDatabase(); for (const key of ["E2E_MYSQL_USER", "E2E_MYSQL_PASSWORD", "E2E_MYSQL_ROOT_PASSWORD"]) e2eEnv(key); const args = ["compose", "--env-file", ".env.e2e", "-f", "docker-compose.e2e.yml", action]; if (action === "up") args.push("-d", "--wait"); if (action === "down") args.push("--volumes"); const result = spawnSync("docker", args, { cwd: root, stdio: "inherit" }); if (result.error) { console.error(`Unable to run Docker for the E2E database: ${result.error.message}`); } process.exit(result.status ?? 1);