wip(app): global config

This commit is contained in:
adamelmore
2026-01-27 16:53:35 -06:00
parent 8faa2ffcf8
commit 65e1186efe
8 changed files with 146 additions and 106 deletions

View File

@@ -1,6 +1,5 @@
import path from "path"
import { Global } from "../global"
import fs from "fs/promises"
import z from "zod"
export const OAUTH_DUMMY_KEY = "opencode-oauth-dummy-key"
@@ -59,15 +58,13 @@ export namespace Auth {
export async function set(key: string, info: Info) {
const file = Bun.file(filepath)
const data = await all()
await Bun.write(file, JSON.stringify({ ...data, [key]: info }, null, 2))
await fs.chmod(file.name!, 0o600)
await Bun.write(file, JSON.stringify({ ...data, [key]: info }, null, 2), { mode: 0o600 })
}
export async function remove(key: string) {
const file = Bun.file(filepath)
const data = await all()
delete data[key]
await Bun.write(file, JSON.stringify(data, null, 2))
await fs.chmod(file.name!, 0o600)
await Bun.write(file, JSON.stringify(data, null, 2), { mode: 0o600 })
}
}