everything-dev
Version:
A consolidated product package for building Module Federation apps with oRPC APIs.
1 lines • 3.88 kB
Source Map (JSON)
{"version":3,"file":"seed.mjs","names":[],"sources":["../../../src/cli/commands/seed.ts"],"sourcesContent":["import * as p from \"@clack/prompts\";\nimport type { SeedResult } from \"../../contract\";\nimport { colors, icons } from \"../../utils/theme\";\nimport type { CommandContext, ResultRenderer } from \"./context\";\n\n/**\n * Production seeding is explicit (#865): `bos seed --env production` must be\n * confirmed, and the owner bootstrap demands env-provided credentials\n * (enforced in the handler) — never config defaults, never boot side effects.\n * Non-interactive stdin cannot confirm, so it must say so with `--yes`\n * explicitly rather than hanging on a prompt nobody can answer.\n */\nexport const seedPreCall = async (ctx: CommandContext): Promise<void> => {\n const input = ctx.input as { env?: string; yes?: boolean; [key: string]: unknown };\n if (input.env !== \"production\" || input.yes === true) return;\n if (process.stdin.isTTY !== true) {\n console.error(\n \"bos seed --env production writes production data — non-interactive environments must pass --yes to confirm\",\n );\n process.exit(1);\n }\n console.log();\n const confirmed = await p.confirm({\n message: \"Seed the production databases? This writes data outside the deploy train.\",\n initialValue: false,\n });\n if (p.isCancel(confirmed) || confirmed !== true) {\n console.log(colors.dim(\"Aborted — nothing was written.\"));\n process.exit(1);\n }\n input.yes = true;\n};\n\nexport const seedRenderers: Record<string, ResultRenderer> = {\n seed: async (result, _ctx) => {\n const r = result as SeedResult;\n console.log();\n if (r.status === \"error\") {\n console.error(colors.error(`${icons.err} ${r.error ?? \"bos seed failed\"}`));\n return;\n }\n if (r.status === \"skipped\") {\n console.log(` ${colors.dim(icons.ok)} skipped — ${r.error ?? \"nothing to seed\"}`);\n return;\n }\n const verb = r.status === \"already-seeded\" ? \"already seeded\" : \"seeded\";\n console.log(` ${colors.green(icons.ok)} ${verb} (version ${r.version}) [${r.env}]`);\n if (r.workspaces?.length) {\n console.log(colors.dim(` schemas ensured: ${r.workspaces.join(\", \")}`));\n }\n if (r.owner) {\n console.log(\n ` ${colors.green(icons.ok)} owner admin (${r.owner.mode}) → ${r.owner.accountId}`,\n );\n }\n for (const step of r.steps ?? []) {\n console.log(` ${colors.green(icons.ok)} step ${step.step}`);\n }\n if (r.status === \"already-seeded\") {\n console.log(colors.dim(\" bump seed.version (or pass --force) to re-run\"));\n }\n console.log();\n },\n};\n"],"mappings":";;;;;;;;;;;AAYA,MAAa,cAAc,OAAO,QAAuC;CACvE,MAAM,QAAQ,IAAI;CAClB,IAAI,MAAM,QAAQ,gBAAgB,MAAM,QAAQ,MAAM;CACtD,IAAI,QAAQ,MAAM,UAAU,MAAM;EAChC,QAAQ,MACN,4GACF;EACA,QAAQ,KAAK,CAAC;CAChB;CACA,QAAQ,IAAI;CACZ,MAAM,YAAY,MAAM,EAAE,QAAQ;EAChC,SAAS;EACT,cAAc;CAChB,CAAC;CACD,IAAI,EAAE,SAAS,SAAS,KAAK,cAAc,MAAM;EAC/C,QAAQ,IAAI,OAAO,IAAI,gCAAgC,CAAC;EACxD,QAAQ,KAAK,CAAC;CAChB;CACA,MAAM,MAAM;AACd;AAEA,MAAa,gBAAgD,EAC3D,MAAM,OAAO,QAAQ,SAAS;CAC5B,MAAM,IAAI;CACV,QAAQ,IAAI;CACZ,IAAI,EAAE,WAAW,SAAS;EACxB,QAAQ,MAAM,OAAO,MAAM,GAAG,MAAM,IAAI,GAAG,EAAE,SAAS,mBAAmB,CAAC;EAC1E;CACF;CACA,IAAI,EAAE,WAAW,WAAW;EAC1B,QAAQ,IAAI,KAAK,OAAO,IAAI,MAAM,EAAE,EAAE,aAAa,EAAE,SAAS,mBAAmB;EACjF;CACF;CACA,MAAM,OAAO,EAAE,WAAW,mBAAmB,mBAAmB;CAChE,QAAQ,IAAI,KAAK,OAAO,MAAM,MAAM,EAAE,EAAE,GAAG,KAAK,YAAY,EAAE,QAAQ,KAAK,EAAE,IAAI,EAAE;CACnF,IAAI,EAAE,YAAY,QAChB,QAAQ,IAAI,OAAO,IAAI,sBAAsB,EAAE,WAAW,KAAK,IAAI,GAAG,CAAC;CAEzE,I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