GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — wip: zen · HashNuke/opencode@12ae808

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • infra
    • console.ts
  • packages/console/core
    • script
      • promote-models.ts
      • pull-models.ts
      • update-models.ts
    • src
      • model.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎infra/console.ts‎

Copy file name to clipboardExpand all lines: infra/console.ts
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ const ZEN_MODELS = [
119119
new sst.Secret("ZEN_MODELS5"),
120120
new sst.Secret("ZEN_MODELS6"),
121121
new sst.Secret("ZEN_MODELS7"),
122+
new sst.Secret("ZEN_MODELS8"),
122123
]
123124
const ZEN_BLACK = new sst.Secret("ZEN_BLACK")
124125
const STRIPE_SECRET_KEY = new sst.Secret("STRIPE_SECRET_KEY")
Collapse file

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

Copy file name to clipboardExpand all lines: packages/console/core/script/promote-models.ts
+14-22Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,33 +8,25 @@ const stage = process.argv[2]
88
if (!stage) throw new Error("Stage is required")
99

1010
const root = path.resolve(process.cwd(), "..", "..", "..")
11+
const PARTS = 8
1112

1213
// read the secret
1314
const ret = await $`bun sst secret list`.cwd(root).text()
1415
const lines = ret.split("\n")
15-
const value1 = lines.find((line) => line.startsWith("ZEN_MODELS1"))?.split("=")[1]
16-
const value2 = lines.find((line) => line.startsWith("ZEN_MODELS2"))?.split("=")[1]
17-
const value3 = lines.find((line) => line.startsWith("ZEN_MODELS3"))?.split("=")[1]
18-
const value4 = lines.find((line) => line.startsWith("ZEN_MODELS4"))?.split("=")[1]
19-
const value5 = lines.find((line) => line.startsWith("ZEN_MODELS5"))?.split("=")[1]
20-
const value6 = lines.find((line) => line.startsWith("ZEN_MODELS6"))?.split("=")[1]
21-
const value7 = lines.find((line) => line.startsWith("ZEN_MODELS7"))?.split("=")[1]
22-
if (!value1) throw new Error("ZEN_MODELS1 not found")
23-
if (!value2) throw new Error("ZEN_MODELS2 not found")
24-
if (!value3) throw new Error("ZEN_MODELS3 not found")
25-
if (!value4) throw new Error("ZEN_MODELS4 not found")
26-
if (!value5) throw new Error("ZEN_MODELS5 not found")
27-
if (!value6) throw new Error("ZEN_MODELS6 not found")
28-
if (!value7) throw new Error("ZEN_MODELS7 not found")
16+
const values = Array.from({ length: PARTS }, (_, i) => {
17+
const value = lines
18+
.find((line) => line.startsWith(`ZEN_MODELS${i + 1}`))
19+
?.split("=")
20+
.slice(1)
21+
.join("=")
22+
if (!value) throw new Error(`ZEN_MODELS${i + 1} not found`)
23+
return value
24+
})
2925

3026
// validate value
31-
ZenData.validate(JSON.parse(value1 + value2 + value3 + value4 + value5 + value6 + value7))
27+
ZenData.validate(JSON.parse(values.join("")))
3228

3329
// update the secret
34-
await $`bun sst secret set ZEN_MODELS1 ${value1} --stage ${stage}`
35-
await $`bun sst secret set ZEN_MODELS2 ${value2} --stage ${stage}`
36-
await $`bun sst secret set ZEN_MODELS3 ${value3} --stage ${stage}`
37-
await $`bun sst secret set ZEN_MODELS4 ${value4} --stage ${stage}`
38-
await $`bun sst secret set ZEN_MODELS5 ${value5} --stage ${stage}`
39-
await $`bun sst secret set ZEN_MODELS6 ${value6} --stage ${stage}`
40-
await $`bun sst secret set ZEN_MODELS7 ${value7} --stage ${stage}`
30+
for (let i = 0; i < PARTS; i++) {
31+
await $`bun sst secret set ZEN_MODELS${i + 1} --stage ${stage} -- ${values[i]}`
32+
}
Collapse file

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

Copy file name to clipboardExpand all lines: packages/console/core/script/pull-models.ts
+15-22Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,25 @@ const stage = process.argv[2]
88
if (!stage) throw new Error("Stage is required")
99

1010
const root = path.resolve(process.cwd(), "..", "..", "..")
11+
const PARTS = 8
1112

1213
// read the secret
1314
const ret = await $`bun sst secret list --stage ${stage}`.cwd(root).text()
1415
const lines = ret.split("\n")
15-
const value1 = lines.find((line) => line.startsWith("ZEN_MODELS1"))?.split("=")[1]
16-
const value2 = lines.find((line) => line.startsWith("ZEN_MODELS2"))?.split("=")[1]
17-
const value3 = lines.find((line) => line.startsWith("ZEN_MODELS3"))?.split("=")[1]
18-
const value4 = lines.find((line) => line.startsWith("ZEN_MODELS4"))?.split("=")[1]
19-
const value5 = lines.find((line) => line.startsWith("ZEN_MODELS5"))?.split("=")[1]
20-
const value6 = lines.find((line) => line.startsWith("ZEN_MODELS6"))?.split("=")[1]
21-
const value7 = lines.find((line) => line.startsWith("ZEN_MODELS7"))?.split("=")[1]
22-
if (!value1) throw new Error("ZEN_MODELS1 not found")
23-
if (!value2) throw new Error("ZEN_MODELS2 not found")
24-
if (!value3) throw new Error("ZEN_MODELS3 not found")
25-
if (!value4) throw new Error("ZEN_MODELS4 not found")
26-
if (!value5) throw new Error("ZEN_MODELS5 not found")
27-
if (!value6) throw new Error("ZEN_MODELS6 not found")
28-
if (!value7) throw new Error("ZEN_MODELS7 not found")
16+
const values = Array.from({ length: PARTS }, (_, i) => {
17+
const value = lines
18+
.find((line) => line.startsWith(`ZEN_MODELS${i + 1}`))
19+
?.split("=")
20+
.slice(1)
21+
.join("=")
22+
if (!value) throw new Error(`ZEN_MODELS${i + 1} not found`)
23+
return value
24+
})
25+
2926
// validate value
30-
ZenData.validate(JSON.parse(value1 + value2 + value3 + value4 + value5 + value6 + value7))
27+
ZenData.validate(JSON.parse(values.join("")))
3128

3229
// update the secret
33-
await $`bun sst secret set ZEN_MODELS1 ${value1}`
34-
await $`bun sst secret set ZEN_MODELS2 ${value2}`
35-
await $`bun sst secret set ZEN_MODELS3 ${value3}`
36-
await $`bun sst secret set ZEN_MODELS4 ${value4}`
37-
await $`bun sst secret set ZEN_MODELS5 ${value5}`
38-
await $`bun sst secret set ZEN_MODELS6 ${value6}`
39-
await $`bun sst secret set ZEN_MODELS7 ${value7}`
30+
for (let i = 0; i < PARTS; i++) {
31+
await $`bun sst secret set ZEN_MODELS${i + 1} -- ${values[i]}`
32+
}
Collapse file

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

Copy file name to clipboardExpand all lines: packages/console/core/script/update-models.ts
+18-36Lines changed: 18 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -7,34 +7,24 @@ import { ZenData } from "../src/model"
77

88
const root = path.resolve(process.cwd(), "..", "..", "..")
99
const models = await $`bun sst secret list`.cwd(root).text()
10+
const PARTS = 8
1011

1112
// read the line starting with "ZEN_MODELS"
1213
const lines = models.split("\n")
13-
const oldValue1 = lines.find((line) => line.startsWith("ZEN_MODELS1"))?.split("=")[1]
14-
const oldValue2 = lines.find((line) => line.startsWith("ZEN_MODELS2"))?.split("=")[1]
15-
const oldValue3 = lines.find((line) => line.startsWith("ZEN_MODELS3"))?.split("=")[1]
16-
const oldValue4 = lines.find((line) => line.startsWith("ZEN_MODELS4"))?.split("=")[1]
17-
const oldValue5 = lines.find((line) => line.startsWith("ZEN_MODELS5"))?.split("=")[1]
18-
const oldValue6 = lines.find((line) => line.startsWith("ZEN_MODELS6"))?.split("=")[1]
19-
const oldValue7 = lines.find((line) => line.startsWith("ZEN_MODELS7"))?.split("=")[1]
20-
if (!oldValue1) throw new Error("ZEN_MODELS1 not found")
21-
if (!oldValue2) throw new Error("ZEN_MODELS2 not found")
22-
if (!oldValue3) throw new Error("ZEN_MODELS3 not found")
23-
if (!oldValue4) throw new Error("ZEN_MODELS4 not found")
24-
if (!oldValue5) throw new Error("ZEN_MODELS5 not found")
25-
if (!oldValue6) throw new Error("ZEN_MODELS6 not found")
26-
if (!oldValue7) throw new Error("ZEN_MODELS7 not found")
14+
const oldValues = Array.from({ length: PARTS }, (_, i) => {
15+
const value = lines
16+
.find((line) => line.startsWith(`ZEN_MODELS${i + 1}`))
17+
?.split("=")
18+
.slice(1)
19+
.join("=")
20+
if (!value) throw new Error(`ZEN_MODELS${i + 1} not found`)
21+
return value
22+
})
2723

2824
// store the prettified json to a temp file
2925
const filename = `models-${Date.now()}.json`
3026
const tempFile = Bun.file(path.join(os.tmpdir(), filename))
31-
await tempFile.write(
32-
JSON.stringify(
33-
JSON.parse(oldValue1 + oldValue2 + oldValue3 + oldValue4 + oldValue5 + oldValue6 + oldValue7),
34-
null,
35-
2,
36-
),
37-
)
27+
await tempFile.write(JSON.stringify(JSON.parse(oldValues.join("")), null, 2))
3828
console.log("tempFile", tempFile.name)
3929

4030
// open temp file in vim and read the file on close
@@ -43,19 +33,11 @@ const newValue = JSON.stringify(JSON.parse(await tempFile.text()))
4333
ZenData.validate(JSON.parse(newValue))
4434

4535
// update the secret
46-
const chunk = Math.ceil(newValue.length / 7)
47-
const newValue1 = newValue.slice(0, chunk)
48-
const newValue2 = newValue.slice(chunk, chunk * 2)
49-
const newValue3 = newValue.slice(chunk * 2, chunk * 3)
50-
const newValue4 = newValue.slice(chunk * 3, chunk * 4)
51-
const newValue5 = newValue.slice(chunk * 4, chunk * 5)
52-
const newValue6 = newValue.slice(chunk * 5, chunk * 6)
53-
const newValue7 = newValue.slice(chunk * 6)
36+
const chunk = Math.ceil(newValue.length / PARTS)
37+
const newValues = Array.from({ length: PARTS }, (_, i) =>
38+
newValue.slice(chunk * i, i === PARTS - 1 ? undefined : chunk * (i + 1)),
39+
)
5440

55-
await $`bun sst secret set ZEN_MODELS1 ${newValue1}`
56-
await $`bun sst secret set ZEN_MODELS2 ${newValue2}`
57-
await $`bun sst secret set ZEN_MODELS3 ${newValue3}`
58-
await $`bun sst secret set ZEN_MODELS4 ${newValue4}`
59-
await $`bun sst secret set ZEN_MODELS5 ${newValue5}`
60-
await $`bun sst secret set ZEN_MODELS6 ${newValue6}`
61-
await $`bun sst secret set ZEN_MODELS7 ${newValue7}`
41+
for (let i = 0; i < PARTS; i++) {
42+
await $`bun sst secret set ZEN_MODELS${i + 1} -- ${newValues[i]}`
43+
}
Collapse file

‎packages/console/core/src/model.ts‎

Copy file name to clipboardExpand all lines: packages/console/core/src/model.ts
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ export namespace ZenData {
7474
Resource.ZEN_MODELS4.value +
7575
Resource.ZEN_MODELS5.value +
7676
Resource.ZEN_MODELS6.value +
77-
Resource.ZEN_MODELS7.value,
77+
Resource.ZEN_MODELS7.value +
78+
Resource.ZEN_MODELS8.value,
7879
)
7980
return ModelsSchema.parse(json)
8081
})

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.