diff options
Diffstat (limited to 'js/src/config')
| -rw-r--r-- | js/src/config/config.ts | 51 |
1 files changed, 0 insertions, 51 deletions
diff --git a/js/src/config/config.ts b/js/src/config/config.ts deleted file mode 100644 index 8c374b3f3..000000000 --- a/js/src/config/config.ts +++ /dev/null @@ -1,51 +0,0 @@ -import path from "path"; -import { Log } from "../util/log"; -import { z } from "zod"; -import { App } from "../app/app"; -import { Provider } from "../provider/provider"; - -export namespace Config { - const log = Log.create({ service: "config" }); - - export const state = App.state("config", async (app) => { - const result = await load(app.root); - return result; - }); - - export const Info = z - .object({ - providers: Provider.Info.array().optional(), - }) - .strict(); - - export type Info = z.output<typeof Info>; - - export function get() { - return state(); - } - - async function load(directory: string) { - let result: Info = {}; - for (const file of ["opencode.jsonc", "opencode.json"]) { - const resolved = path.join(directory, file); - log.info("searching", { path: resolved }); - try { - result = await import(path.join(directory, file)).then((mod) => - Info.parse(mod.default), - ); - log.info("found", { path: resolved }); - break; - } catch (e) { - if (e instanceof z.ZodError) { - for (const issue of e.issues) { - log.info(issue.message); - } - throw e; - } - continue; - } - } - log.info("loaded", result); - return result; - } -} |
