Something went wrong. Try again.
Original-language reader for Kant, Aristotle & more: select any passage to gloss, translate, or hear it read aloud, with exact citations.
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849import { spawnSync } from "node:child_process"
/** * Push the server-side AI keys into the Convex deployment's environment. * * The gloss/translate (§5) and TTS (§10) Convex actions read their provider keys * from `process.env.LEKTERION_*` — but that's the *Convex* environment, set via * `convex env set`, not the local shell. Bun auto-loads `.env.local`, so when this * runs under `bun` those keys are already in `process.env`; we forward each one * that's present. Values are never printed. * * bun run convex:env # dev (CONVEX_DEPLOYMENT in .env.local) * bun run convex:env -- --prod # production */
const KEYS = ["LEKTERION_ANTHROPIC_API_KEY", "LEKTERION_OPENAI_API_KEY"] as const
// Forward any extra flags (e.g. `--prod`) straight through to `convex env set`,// so the same no-reveal script can retarget the deployment without edits.const extraArgs = process.argv.slice(2)const target = extraArgs.includes("--prod") ? "prod" : "dev"
let pushed = 0for (const name of KEYS) { const value = process.env[name] if (!value) { console.warn(`· ${name} not found in the environment (.env.local) — skipped`) continue } // Array args (no shell) keep the value out of shell history; stdout is dropped // because `convex env set` echoes the value on success. const res = spawnSync("bunx", ["convex", "env", "set", name, value, ...extraArgs], { stdio: ["ignore", "ignore", "pipe"], encoding: "utf8", }) if (res.status !== 0) { console.error(`✗ failed to set ${name}`) if (res.stderr) console.error(res.stderr.trim()) process.exit(1) } console.log(`✓ set ${name} (${target})`) pushed++}
console.log(`\nSynced ${String(pushed)} key(s) to Convex (${target}).`)if (pushed === 0) { console.warn("Nothing to sync — add the keys to .env.local first.")}