This commit is contained in:
Benjamin Toby
2025-04-17 11:24:53 +01:00
parent 870de51f5d
commit a9c0dd4b63
9 changed files with 97 additions and 6 deletions
+28 -3
View File
@@ -8,6 +8,7 @@ import { DSQL_DatabaseSchemaType } from "../package-shared/types";
import dbSchemaToType from "../package-shared/functions/dsql/db-schema-to-type";
import path from "path";
import debugLog from "../package-shared/utils/logging/debug-log";
import parseEnv from "../package-shared/utils/parse-env";
const args = parseArgs({
args: process.argv,
@@ -26,18 +27,42 @@ const args = parseArgs({
type: "string",
short: "o",
},
envfile: {
type: "string",
short: "e",
},
debug: {
type: "boolean",
short: "e",
short: "u",
},
},
strict: false,
});
const { apiKey: key, database, outfile, debug, envfile } = args.values;
if (envfile && typeof envfile == "string") {
const finalEnvPath = path.resolve(process.cwd(), envfile);
if (fs.existsSync(finalEnvPath)) {
const appendedEnv = parseEnv(finalEnvPath);
if (debug) {
debugLog({
log: appendedEnv,
label: "Appended env",
title: "Schema to Typedef",
addTime: true,
});
}
for (const [key, value] of Object.entries(appendedEnv)) {
process.env[key] = value;
}
}
}
(async () => {
try {
const { apiKey: key, database, outfile, debug } = args.values;
if (debug) {
debugLog({
log: args.values,