cloudaxe-opencode/packages/console/core/script/promote-limits.ts

23 lines
658 B
TypeScript
Raw Permalink Normal View History

2026-02-22 23:41:34 +00:00
#!/usr/bin/env bun
import { $ } from "bun"
import path from "path"
2026-03-03 05:25:03 +00:00
import { Subscription } from "../src/subscription"
2026-02-22 23:41:34 +00:00
const stage = process.argv[2]
if (!stage) throw new Error("Stage is required")
const root = path.resolve(process.cwd(), "..", "..", "..")
// read the secret
2026-05-17 05:59:17 +00:00
const ret = await $`bun sst secret list --fallback`.cwd(root).text()
2026-02-22 23:41:34 +00:00
const lines = ret.split("\n")
2026-03-03 05:25:03 +00:00
const value = lines.find((line) => line.startsWith("ZEN_LIMITS"))?.split("=")[1]
if (!value) throw new Error("ZEN_LIMITS not found")
2026-02-22 23:41:34 +00:00
// validate value
2026-03-03 05:25:03 +00:00
Subscription.validate(JSON.parse(value))
2026-02-22 23:41:34 +00:00
// update the secret
2026-03-03 05:25:03 +00:00
await $`bun sst secret set ZEN_LIMITS ${value} --stage ${stage}`