summaryrefslogtreecommitdiffhomepage
path: root/packages/console/core/script/pull-models.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/console/core/script/pull-models.ts')
-rwxr-xr-xpackages/console/core/script/pull-models.ts37
1 files changed, 15 insertions, 22 deletions
diff --git a/packages/console/core/script/pull-models.ts b/packages/console/core/script/pull-models.ts
index 91899482a..f360b8186 100755
--- a/packages/console/core/script/pull-models.ts
+++ b/packages/console/core/script/pull-models.ts
@@ -8,32 +8,25 @@ const stage = process.argv[2]
if (!stage) throw new Error("Stage is required")
const root = path.resolve(process.cwd(), "..", "..", "..")
+const PARTS = 8
// read the secret
const ret = await $`bun sst secret list --stage ${stage}`.cwd(root).text()
const lines = ret.split("\n")
-const value1 = lines.find((line) => line.startsWith("ZEN_MODELS1"))?.split("=")[1]
-const value2 = lines.find((line) => line.startsWith("ZEN_MODELS2"))?.split("=")[1]
-const value3 = lines.find((line) => line.startsWith("ZEN_MODELS3"))?.split("=")[1]
-const value4 = lines.find((line) => line.startsWith("ZEN_MODELS4"))?.split("=")[1]
-const value5 = lines.find((line) => line.startsWith("ZEN_MODELS5"))?.split("=")[1]
-const value6 = lines.find((line) => line.startsWith("ZEN_MODELS6"))?.split("=")[1]
-const value7 = lines.find((line) => line.startsWith("ZEN_MODELS7"))?.split("=")[1]
-if (!value1) throw new Error("ZEN_MODELS1 not found")
-if (!value2) throw new Error("ZEN_MODELS2 not found")
-if (!value3) throw new Error("ZEN_MODELS3 not found")
-if (!value4) throw new Error("ZEN_MODELS4 not found")
-if (!value5) throw new Error("ZEN_MODELS5 not found")
-if (!value6) throw new Error("ZEN_MODELS6 not found")
-if (!value7) throw new Error("ZEN_MODELS7 not found")
+const values = Array.from({ length: PARTS }, (_, i) => {
+ const value = lines
+ .find((line) => line.startsWith(`ZEN_MODELS${i + 1}`))
+ ?.split("=")
+ .slice(1)
+ .join("=")
+ if (!value) throw new Error(`ZEN_MODELS${i + 1} not found`)
+ return value
+})
+
// validate value
-ZenData.validate(JSON.parse(value1 + value2 + value3 + value4 + value5 + value6 + value7))
+ZenData.validate(JSON.parse(values.join("")))
// update the secret
-await $`bun sst secret set ZEN_MODELS1 ${value1}`
-await $`bun sst secret set ZEN_MODELS2 ${value2}`
-await $`bun sst secret set ZEN_MODELS3 ${value3}`
-await $`bun sst secret set ZEN_MODELS4 ${value4}`
-await $`bun sst secret set ZEN_MODELS5 ${value5}`
-await $`bun sst secret set ZEN_MODELS6 ${value6}`
-await $`bun sst secret set ZEN_MODELS7 ${value7}`
+for (let i = 0; i < PARTS; i++) {
+ await $`bun sst secret set ZEN_MODELS${i + 1} -- ${values[i]}`
+}