summaryrefslogtreecommitdiffhomepage
path: root/packages/console/core/script
diff options
context:
space:
mode:
authorFrank <[email protected]>2026-01-06 23:34:10 -0500
committerFrank <[email protected]>2026-01-06 23:34:12 -0500
commit23fc675ad5130e1770e52878a24879303cc5eaa8 (patch)
tree1e93ec4db97c2fd4cd285f39a9881e26391f2f57 /packages/console/core/script
parent22b058a33d40f0bdf1052fcc542b75f67f738fc6 (diff)
downloadopencode-23fc675ad5130e1770e52878a24879303cc5eaa8.tar.gz
opencode-23fc675ad5130e1770e52878a24879303cc5eaa8.zip
wip: black
Diffstat (limited to 'packages/console/core/script')
-rwxr-xr-xpackages/console/core/script/promote-black.ts22
-rwxr-xr-xpackages/console/core/script/update-black.ts28
2 files changed, 50 insertions, 0 deletions
diff --git a/packages/console/core/script/promote-black.ts b/packages/console/core/script/promote-black.ts
new file mode 100755
index 000000000..bb3dcc6f7
--- /dev/null
+++ b/packages/console/core/script/promote-black.ts
@@ -0,0 +1,22 @@
+#!/usr/bin/env bun
+
+import { $ } from "bun"
+import path from "path"
+import { BlackData } from "../src/black"
+
+const stage = process.argv[2]
+if (!stage) throw new Error("Stage is required")
+
+const root = path.resolve(process.cwd(), "..", "..", "..")
+
+// read the secret
+const ret = await $`bun sst secret list`.cwd(root).text()
+const lines = ret.split("\n")
+const value = lines.find((line) => line.startsWith("ZEN_BLACK"))?.split("=")[1]
+if (!value) throw new Error("ZEN_BLACK not found")
+
+// validate value
+BlackData.validate(JSON.parse(value))
+
+// update the secret
+await $`bun sst secret set ZEN_BLACK ${value} --stage ${stage}`
diff --git a/packages/console/core/script/update-black.ts b/packages/console/core/script/update-black.ts
new file mode 100755
index 000000000..58923b457
--- /dev/null
+++ b/packages/console/core/script/update-black.ts
@@ -0,0 +1,28 @@
+#!/usr/bin/env bun
+
+import { $ } from "bun"
+import path from "path"
+import os from "os"
+import { BlackData } from "../src/black"
+
+const root = path.resolve(process.cwd(), "..", "..", "..")
+const secrets = await $`bun sst secret list`.cwd(root).text()
+
+// read the line starting with "ZEN_BLACK"
+const lines = secrets.split("\n")
+const oldValue = lines.find((line) => line.startsWith("ZEN_BLACK"))?.split("=")[1]
+if (!oldValue) throw new Error("ZEN_BLACK not found")
+
+// store the prettified json to a temp file
+const filename = `black-${Date.now()}.json`
+const tempFile = Bun.file(path.join(os.tmpdir(), filename))
+await tempFile.write(JSON.stringify(JSON.parse(oldValue), null, 2))
+console.log("tempFile", tempFile.name)
+
+// open temp file in vim and read the file on close
+await $`vim ${tempFile.name}`
+const newValue = JSON.stringify(JSON.parse(await tempFile.text()))
+BlackData.validate(JSON.parse(newValue))
+
+// update the secret
+await $`bun sst secret set ZEN_BLACK ${newValue}`