promote-limits.ts 661 B

12345678910111213141516171819202122
  1. #!/usr/bin/env bun
  2. import { $ } from "bun"
  3. import path from "path"
  4. import { Subscription } from "../src/subscription"
  5. const stage = process.argv[2]
  6. if (!stage) throw new Error("Stage is required")
  7. const root = path.resolve(process.cwd(), "..", "..", "..")
  8. // read the secret
  9. const ret = await $`bun sst secret list --stage frank`.cwd(root).text()
  10. const lines = ret.split("\n")
  11. const value = lines.find((line) => line.startsWith("ZEN_LIMITS"))?.split("=")[1]
  12. if (!value) throw new Error("ZEN_LIMITS not found")
  13. // validate value
  14. Subscription.validate(JSON.parse(value))
  15. // update the secret
  16. await $`bun sst secret set ZEN_LIMITS ${value} --stage ${stage}`