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
+24 -2
View File
@@ -19,6 +19,7 @@ const util_1 = require("util");
const db_schema_to_type_1 = __importDefault(require("../package-shared/functions/dsql/db-schema-to-type"));
const path_1 = __importDefault(require("path"));
const debug_log_1 = __importDefault(require("../package-shared/utils/logging/debug-log"));
const parse_env_1 = __importDefault(require("../package-shared/utils/parse-env"));
const args = (0, util_1.parseArgs)({
args: process.argv,
options: {
@@ -36,16 +37,37 @@ const args = (0, util_1.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_1.default.resolve(process.cwd(), envfile);
if (fs_1.default.existsSync(finalEnvPath)) {
const appendedEnv = (0, parse_env_1.default)(finalEnvPath);
if (debug) {
(0, debug_log_1.default)({
log: appendedEnv,
label: "Appended env",
title: "Schema to Typedef",
addTime: true,
});
}
for (const [key, value] of Object.entries(appendedEnv)) {
process.env[key] = value;
}
}
}
(() => __awaiter(void 0, void 0, void 0, function* () {
try {
const { apiKey: key, database, outfile, debug } = args.values;
if (debug) {
(0, debug_log_1.default)({
log: args.values,