From 5712cff5c453a185ac75a160f76ca06135d6ab2d Mon Sep 17 00:00:00 2001 From: Frank Date: Sun, 22 Feb 2026 18:41:34 -0500 Subject: zen: track session in usage --- packages/console/core/script/promote-lite.ts | 22 ++++++++++++++++++++++ packages/console/core/script/update-lite.ts | 28 ++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100755 packages/console/core/script/promote-lite.ts create mode 100755 packages/console/core/script/update-lite.ts (limited to 'packages/console/core/script') diff --git a/packages/console/core/script/promote-lite.ts b/packages/console/core/script/promote-lite.ts new file mode 100755 index 000000000..8fd58c805 --- /dev/null +++ b/packages/console/core/script/promote-lite.ts @@ -0,0 +1,22 @@ +#!/usr/bin/env bun + +import { $ } from "bun" +import path from "path" +import { LiteData } from "../src/lite" + +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_LITE_LIMITS"))?.split("=")[1] +if (!value) throw new Error("ZEN_LITE_LIMITS not found") + +// validate value +LiteData.validate(JSON.parse(value)) + +// update the secret +await $`bun sst secret set ZEN_LITE_LIMITS ${value} --stage ${stage}` diff --git a/packages/console/core/script/update-lite.ts b/packages/console/core/script/update-lite.ts new file mode 100755 index 000000000..2f3e66835 --- /dev/null +++ b/packages/console/core/script/update-lite.ts @@ -0,0 +1,28 @@ +#!/usr/bin/env bun + +import { $ } from "bun" +import path from "path" +import os from "os" +import { LiteData } from "../src/lite" + +const root = path.resolve(process.cwd(), "..", "..", "..") +const secrets = await $`bun sst secret list`.cwd(root).text() + +// read value +const lines = secrets.split("\n") +const oldValue = lines.find((line) => line.startsWith("ZEN_LITE_LIMITS"))?.split("=")[1] ?? "{}" +if (!oldValue) throw new Error("ZEN_LITE_LIMITS not found") + +// store the prettified json to a temp file +const filename = `lite-${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())) +LiteData.validate(JSON.parse(newValue)) + +// update the secret +await $`bun sst secret set ZEN_LITE_LIMITS ${newValue}` -- cgit v1.2.3