opencode/services/data/stage.ts
Dax Raad 070b980c0b refactor(data): strict dev/production stages and data naming
- services/data/stage.ts: stage(mode) throws on anything but dev or production, used by all three configs, build.ts and deploy.ts
- packages/stats -> packages/data (@opencode/data-app, -core, -server)
- StatsSyncWorkflow -> DataSyncWorkflow, instance ids data-hourly-/data-history-, Data* resource keys, data sync log lines
- worker, route, workflow and cron names unchanged
2026-11-11 02:35:05 -05:00

18 lines
644 B
TypeScript

// The stage a `--mode` deploys. Only `dev` and `production` are stages: anything else, including no mode at all, throws,
// so a typo or a bare `cf deploy` can never fall through to production.
const hosts = {
dev: "dev.opencode.ai",
production: "opencode.ai",
} as const
export type Stage = keyof typeof hosts
export function stage(mode: string | undefined): Stage {
if (mode === "dev" || mode === "production") return mode
throw new Error(`Unknown mode ${JSON.stringify(mode)}; pass --mode dev or --mode production`)
}
// The host the stage's site is served from.
export function stageHost(value: Stage) {
return hosts[value]
}