Skip to content

Commit 1a9ee30

Browse files
author
Frank
committed
zen: sync
1 parent f4d61be commit 1a9ee30

11 files changed

Lines changed: 44 additions & 7 deletions

File tree

infra/console.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ const ZEN_MODELS = [
103103
new sst.Secret("ZEN_MODELS3"),
104104
new sst.Secret("ZEN_MODELS4"),
105105
new sst.Secret("ZEN_MODELS5"),
106+
new sst.Secret("ZEN_MODELS6"),
106107
]
107108
const STRIPE_SECRET_KEY = new sst.Secret("STRIPE_SECRET_KEY")
108109
const AUTH_API_URL = new sst.Linkable("AUTH_API_URL", {

packages/console/core/script/promote-models.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,21 @@ const value2 = lines.find((line) => line.startsWith("ZEN_MODELS2"))?.split("=")[
1717
const value3 = lines.find((line) => line.startsWith("ZEN_MODELS3"))?.split("=")[1]
1818
const value4 = lines.find((line) => line.startsWith("ZEN_MODELS4"))?.split("=")[1]
1919
const value5 = lines.find((line) => line.startsWith("ZEN_MODELS5"))?.split("=")[1]
20+
const value6 = lines.find((line) => line.startsWith("ZEN_MODELS6"))?.split("=")[1]
2021
if (!value1) throw new Error("ZEN_MODELS1 not found")
2122
if (!value2) throw new Error("ZEN_MODELS2 not found")
2223
if (!value3) throw new Error("ZEN_MODELS3 not found")
2324
if (!value4) throw new Error("ZEN_MODELS4 not found")
2425
if (!value5) throw new Error("ZEN_MODELS5 not found")
26+
if (!value6) throw new Error("ZEN_MODELS6 not found")
2527

2628
// validate value
27-
ZenData.validate(JSON.parse(value1 + value2 + value3 + value4 + value5))
29+
ZenData.validate(JSON.parse(value1 + value2 + value3 + value4 + value5 + value6))
2830

2931
// update the secret
3032
await $`bun sst secret set ZEN_MODELS1 ${value1} --stage ${stage}`
3133
await $`bun sst secret set ZEN_MODELS2 ${value2} --stage ${stage}`
3234
await $`bun sst secret set ZEN_MODELS3 ${value3} --stage ${stage}`
3335
await $`bun sst secret set ZEN_MODELS4 ${value4} --stage ${stage}`
3436
await $`bun sst secret set ZEN_MODELS5 ${value5} --stage ${stage}`
37+
await $`bun sst secret set ZEN_MODELS6 ${value6} --stage ${stage}`

packages/console/core/script/pull-models.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,20 @@ const value2 = lines.find((line) => line.startsWith("ZEN_MODELS2"))?.split("=")[
1717
const value3 = lines.find((line) => line.startsWith("ZEN_MODELS3"))?.split("=")[1]
1818
const value4 = lines.find((line) => line.startsWith("ZEN_MODELS4"))?.split("=")[1]
1919
const value5 = lines.find((line) => line.startsWith("ZEN_MODELS5"))?.split("=")[1]
20+
const value6 = lines.find((line) => line.startsWith("ZEN_MODELS6"))?.split("=")[1]
2021
if (!value1) throw new Error("ZEN_MODELS1 not found")
2122
if (!value2) throw new Error("ZEN_MODELS2 not found")
2223
if (!value3) throw new Error("ZEN_MODELS3 not found")
2324
if (!value4) throw new Error("ZEN_MODELS4 not found")
2425
if (!value5) throw new Error("ZEN_MODELS5 not found")
25-
26+
if (!value6) throw new Error("ZEN_MODELS6 not found")
2627
// validate value
27-
ZenData.validate(JSON.parse(value1 + value2 + value3 + value4 + value5))
28+
ZenData.validate(JSON.parse(value1 + value2 + value3 + value4 + value5 + value6))
2829

2930
// update the secret
3031
await $`bun sst secret set ZEN_MODELS1 ${value1}`
3132
await $`bun sst secret set ZEN_MODELS2 ${value2}`
3233
await $`bun sst secret set ZEN_MODELS3 ${value3}`
3334
await $`bun sst secret set ZEN_MODELS4 ${value4}`
3435
await $`bun sst secret set ZEN_MODELS5 ${value5}`
36+
await $`bun sst secret set ZEN_MODELS6 ${value6}`

packages/console/core/script/update-models.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,20 @@ const oldValue2 = lines.find((line) => line.startsWith("ZEN_MODELS2"))?.split("=
1515
const oldValue3 = lines.find((line) => line.startsWith("ZEN_MODELS3"))?.split("=")[1]
1616
const oldValue4 = lines.find((line) => line.startsWith("ZEN_MODELS4"))?.split("=")[1]
1717
const oldValue5 = lines.find((line) => line.startsWith("ZEN_MODELS5"))?.split("=")[1]
18+
const oldValue6 = lines.find((line) => line.startsWith("ZEN_MODELS6"))?.split("=")[1]
1819
if (!oldValue1) throw new Error("ZEN_MODELS1 not found")
1920
if (!oldValue2) throw new Error("ZEN_MODELS2 not found")
2021
if (!oldValue3) throw new Error("ZEN_MODELS3 not found")
2122
if (!oldValue4) throw new Error("ZEN_MODELS4 not found")
2223
if (!oldValue5) throw new Error("ZEN_MODELS5 not found")
24+
if (!oldValue6) throw new Error("ZEN_MODELS6 not found")
2325

2426
// store the prettified json to a temp file
2527
const filename = `models-${Date.now()}.json`
2628
const tempFile = Bun.file(path.join(os.tmpdir(), filename))
27-
await tempFile.write(JSON.stringify(JSON.parse(oldValue1 + oldValue2 + oldValue3 + oldValue4 + oldValue5), null, 2))
29+
await tempFile.write(
30+
JSON.stringify(JSON.parse(oldValue1 + oldValue2 + oldValue3 + oldValue4 + oldValue5 + oldValue6), null, 2),
31+
)
2832
console.log("tempFile", tempFile.name)
2933

3034
// open temp file in vim and read the file on close
@@ -33,15 +37,17 @@ const newValue = JSON.stringify(JSON.parse(await tempFile.text()))
3337
ZenData.validate(JSON.parse(newValue))
3438

3539
// update the secret
36-
const chunk = Math.ceil(newValue.length / 5)
40+
const chunk = Math.ceil(newValue.length / 6)
3741
const newValue1 = newValue.slice(0, chunk)
3842
const newValue2 = newValue.slice(chunk, chunk * 2)
3943
const newValue3 = newValue.slice(chunk * 2, chunk * 3)
4044
const newValue4 = newValue.slice(chunk * 3, chunk * 4)
41-
const newValue5 = newValue.slice(chunk * 4)
45+
const newValue5 = newValue.slice(chunk * 4, chunk * 5)
46+
const newValue6 = newValue.slice(chunk * 5)
4247

4348
await $`bun sst secret set ZEN_MODELS1 ${newValue1}`
4449
await $`bun sst secret set ZEN_MODELS2 ${newValue2}`
4550
await $`bun sst secret set ZEN_MODELS3 ${newValue3}`
4651
await $`bun sst secret set ZEN_MODELS4 ${newValue4}`
4752
await $`bun sst secret set ZEN_MODELS5 ${newValue5}`
53+
await $`bun sst secret set ZEN_MODELS6 ${newValue6}`

packages/console/core/src/model.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ export namespace ZenData {
7272
Resource.ZEN_MODELS2.value +
7373
Resource.ZEN_MODELS3.value +
7474
Resource.ZEN_MODELS4.value +
75-
Resource.ZEN_MODELS5.value,
75+
Resource.ZEN_MODELS5.value +
76+
Resource.ZEN_MODELS6.value,
7677
)
7778
return ModelsSchema.parse(json)
7879
})

packages/console/core/sst-env.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@ declare module "sst" {
118118
"type": "sst.sst.Secret"
119119
"value": string
120120
}
121+
"ZEN_MODELS6": {
122+
"type": "sst.sst.Secret"
123+
"value": string
124+
}
121125
}
122126
}
123127
// cloudflare

packages/console/function/sst-env.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@ declare module "sst" {
118118
"type": "sst.sst.Secret"
119119
"value": string
120120
}
121+
"ZEN_MODELS6": {
122+
"type": "sst.sst.Secret"
123+
"value": string
124+
}
121125
}
122126
}
123127
// cloudflare

packages/console/resource/sst-env.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@ declare module "sst" {
118118
"type": "sst.sst.Secret"
119119
"value": string
120120
}
121+
"ZEN_MODELS6": {
122+
"type": "sst.sst.Secret"
123+
"value": string
124+
}
121125
}
122126
}
123127
// cloudflare

packages/enterprise/sst-env.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@ declare module "sst" {
118118
"type": "sst.sst.Secret"
119119
"value": string
120120
}
121+
"ZEN_MODELS6": {
122+
"type": "sst.sst.Secret"
123+
"value": string
124+
}
121125
}
122126
}
123127
// cloudflare

packages/function/sst-env.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@ declare module "sst" {
118118
"type": "sst.sst.Secret"
119119
"value": string
120120
}
121+
"ZEN_MODELS6": {
122+
"type": "sst.sst.Secret"
123+
"value": string
124+
}
121125
}
122126
}
123127
// cloudflare

0 commit comments

Comments
 (0)