feat(build): respect OPENCODE_MODELS_URL env var (#11384)
This commit is contained in:
@@ -14,11 +14,11 @@ process.chdir(dir)
|
|||||||
|
|
||||||
import pkg from "../package.json"
|
import pkg from "../package.json"
|
||||||
import { Script } from "@opencode-ai/script"
|
import { Script } from "@opencode-ai/script"
|
||||||
|
const modelsUrl = process.env.OPENCODE_MODELS_URL || "https://models.dev"
|
||||||
// Fetch and generate models.dev snapshot
|
// Fetch and generate models.dev snapshot
|
||||||
const modelsData = process.env.MODELS_DEV_API_JSON
|
const modelsData = process.env.MODELS_DEV_API_JSON
|
||||||
? await Bun.file(process.env.MODELS_DEV_API_JSON).text()
|
? await Bun.file(process.env.MODELS_DEV_API_JSON).text()
|
||||||
: await fetch(`https://models.dev/api.json`).then((x) => x.text())
|
: await fetch(`${modelsUrl}/api.json`).then((x) => x.text())
|
||||||
await Bun.write(
|
await Bun.write(
|
||||||
path.join(dir, "src/provider/models-snapshot.ts"),
|
path.join(dir, "src/provider/models-snapshot.ts"),
|
||||||
`// Auto-generated by build.ts - do not edit\nexport const snapshot = ${modelsData} as const\n`,
|
`// Auto-generated by build.ts - do not edit\nexport const snapshot = ${modelsData} as const\n`,
|
||||||
|
|||||||
Reference in New Issue
Block a user