promote-black.ts 652 B

12345678910111213141516171819202122
  1. #!/usr/bin/env bun
  2. import { $ } from "bun"
  3. import path from "path"
  4. import { BlackData } from "../src/black"
  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`.cwd(root).text()
  10. const lines = ret.split("\n")
  11. const value = lines.find((line) => line.startsWith("ZEN_BLACK_LIMITS"))?.split("=")[1]
  12. if (!value) throw new Error("ZEN_BLACK_LIMITS not found")
  13. // validate value
  14. BlackData.validate(JSON.parse(value))
  15. // update the secret
  16. await $`bun sst secret set ZEN_BLACK_LIMITS ${value} --stage ${stage}`