fix(tooling): harden database env loading

This commit is contained in:
2026-03-30 14:42:44 +02:00
parent be6be64e3d
commit 34067f1576
6 changed files with 179 additions and 35 deletions
+6 -3
View File
@@ -1,14 +1,17 @@
#!/usr/bin/env node
import { URL } from "node:url";
import { loadWorkspaceEnv, resolveWorkspaceEnvPath } from "./load-env.mjs";
import { loadWorkspaceEnv, resolveWorkspaceEnvPaths } from "./load-env.mjs";
const envPath = loadWorkspaceEnv();
const loadedEnvPaths = loadWorkspaceEnv();
const expectedDatabase = process.argv[2] ?? "capakraken";
const rawUrl = process.env.DATABASE_URL;
const expectedEnvSources = loadedEnvPaths.length > 0
? loadedEnvPaths.join(", ")
: resolveWorkspaceEnvPaths().join(", ");
if (!rawUrl) {
console.error(`DATABASE_URL is not configured. Expected it from ${envPath ?? resolveWorkspaceEnvPath()}.`);
console.error(`DATABASE_URL is not configured. Expected it from one of: ${expectedEnvSources}.`);
process.exit(1);
}