import path from "node:path"; import fs from "node:fs"; import { ModrinthClient } from "@/lib/modrinth"; import { CurseForgeClient } from "@/lib/curseforge"; import type { Secrets } from "@/types"; import { SecretsSchema } from "@/types"; function loadSecrets(): Secrets { const secretsPath = path.join(process.cwd(), "secrets.json"); let raw: unknown; try { raw = JSON.parse(fs.readFileSync(secretsPath, "utf-8")); } catch { throw new Error( `Failed to read secrets.json (${secretsPath}). Please ensure the file exists and is valid JSON.`, ); } const result = SecretsSchema.safeParse(raw); if (!result.success) { throw new Error( `secrets.json validation failed: ${result.error.message}`, ); } return result.data; } const secrets = loadSecrets(); export const modrinthClient = new ModrinthClient( secrets.modrinth, "ModReleaser/1.0.0 (local)", ); export const curseforgeClient = new CurseForgeClient(secrets.curseforge);