UNPKG

everything-dev

Version:

A consolidated product package for building Module Federation apps with oRPC APIs.

52 lines (50 loc) • 2.17 kB
import { colors, icons } from "../../utils/theme.mjs"; import * as p from "@clack/prompts"; //#region src/cli/commands/seed.ts /** * Production seeding is explicit (#865): `bos seed --env production` must be * confirmed, and the owner bootstrap demands env-provided credentials * (enforced in the handler) — never config defaults, never boot side effects. * Non-interactive stdin cannot confirm, so it must say so with `--yes` * explicitly rather than hanging on a prompt nobody can answer. */ const seedPreCall = async (ctx) => { const input = ctx.input; if (input.env !== "production" || input.yes === true) return; if (process.stdin.isTTY !== true) { console.error("bos seed --env production writes production data — non-interactive environments must pass --yes to confirm"); process.exit(1); } console.log(); const confirmed = await p.confirm({ message: "Seed the production databases? This writes data outside the deploy train.", initialValue: false }); if (p.isCancel(confirmed) || confirmed !== true) { console.log(colors.dim("Aborted — nothing was written.")); process.exit(1); } input.yes = true; }; const seedRenderers = { seed: async (result, _ctx) => { const r = result; console.log(); if (r.status === "error") { console.error(colors.error(`${icons.err} ${r.error ?? "bos seed failed"}`)); return; } if (r.status === "skipped") { console.log(` ${colors.dim(icons.ok)} skipped — ${r.error ?? "nothing to seed"}`); return; } const verb = r.status === "already-seeded" ? "already seeded" : "seeded"; console.log(` ${colors.green(icons.ok)} ${verb} (version ${r.version}) [${r.env}]`); if (r.workspaces?.length) console.log(colors.dim(` schemas ensured: ${r.workspaces.join(", ")}`)); if (r.owner) console.log(` ${colors.green(icons.ok)} owner admin (${r.owner.mode}) → ${r.owner.accountId}`); for (const step of r.steps ?? []) console.log(` ${colors.green(icons.ok)} step ${step.step}`); if (r.status === "already-seeded") console.log(colors.dim(" bump seed.version (or pass --force) to re-run")); console.log(); } }; //#endregion export { seedPreCall, seedRenderers }; //# sourceMappingURL=seed.mjs.map