fix(scripts): drop unlisted dotenv dep in schema generator
generate-drizzle-schema.mjs imported 'dotenv/config' but dotenv is not a dependency, failing knip and crashing 'pnpm db:schema:generate'. Load .env with Node's built-in process.loadEnvFile like the other scripts do (scripts/load-env.ts), never overriding vars already set in the shell.
This commit is contained in:
1 parent
52459c0b74
commit
2650d325ec
1 file changed
+8
-2
@@ -8,8 +8,7 @@
|
||||
// drizzle-kit (`pnpm db:generate` / studio / introspect) is draft/browse tooling only.
|
||||
//
|
||||
// Usage: pnpm db:schema:generate
|
||||
import "dotenv/config";
|
||||
import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
||||
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
||||
import { dirname, resolve } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
@@ -31,6 +30,13 @@ const ROOT = resolve(__dirname, "..");
|
||||
const SCHEMA_TS = resolve(ROOT, "src/db/schema.ts");
|
||||
const OUT = SCHEMA_TS;
|
||||
|
||||
// Load .env like the TS scripts do (process.loadEnvFile never overrides
|
||||
// variables already present in the shell).
|
||||
for (const name of [".env.local", ".env"]) {
|
||||
const file = resolve(ROOT, name);
|
||||
if (existsSync(file)) process.loadEnvFile(file);
|
||||
}
|
||||
|
||||
// ---------- Parse existing Drizzle schema (naming source of truth) ----------
|
||||
const schemaSource = readFileSync(SCHEMA_TS, "utf-8");
|
||||
|
||||
|
||||
Reference in new issue
Block a user