diff --git a/dist/engine/schema-to-typedef.js b/dist/engine/schema-to-typedef.js index 3f26a02..34f429d 100644 --- a/dist/engine/schema-to-typedef.js +++ b/dist/engine/schema-to-typedef.js @@ -18,6 +18,7 @@ const __1 = __importDefault(require("..")); 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 args = (0, util_1.parseArgs)({ args: process.argv, options: { @@ -33,15 +34,39 @@ const args = (0, util_1.parseArgs)({ }, outfile: { type: "string", - default: process.env.DSQL_DB_NAME, short: "o", }, + debug: { + type: "boolean", + default: false, + short: "d", + }, }, strict: false, }); (() => __awaiter(void 0, void 0, void 0, function* () { try { - const { apiKey: key, database, outfile } = args.values; + const { apiKey: key, database, outfile, debug } = args.values; + if (debug) { + (0, debug_log_1.default)({ + log: args.values, + label: "Arguments", + title: "Schema to Typedef", + addTime: true, + }); + (0, debug_log_1.default)({ + log: process.env.DSQL_FULL_ACCESS_API_KEY, + label: "process.env.DSQL_FULL_ACCESS_API_KEY", + title: "Schema to Typedef", + addTime: true, + }); + (0, debug_log_1.default)({ + log: process.env.DSQL_DB_NAME, + label: "process.env.DSQL_DB_NAME", + title: "Schema to Typedef", + addTime: true, + }); + } if (!database || typeof database !== "string") throw new Error("Database name is required"); if (!key || typeof key !== "string") @@ -65,7 +90,13 @@ const args = (0, util_1.parseArgs)({ fs_1.default.writeFileSync(finalOutfile, (definitions === null || definitions === void 0 ? void 0 : definitions.join("\n\n")) || "", "utf-8"); } catch (error) { - console.log("Error:", error.message); + (0, debug_log_1.default)({ + log: error.message, + label: "Error", + title: "Schema to Typedef", + addTime: true, + type: "error", + }); process.exit(1); } }))(); diff --git a/engine/schema-to-typedef.ts b/engine/schema-to-typedef.ts index ee5ef22..608ebf5 100644 --- a/engine/schema-to-typedef.ts +++ b/engine/schema-to-typedef.ts @@ -7,6 +7,7 @@ import { parseArgs } from "util"; 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"; const args = parseArgs({ args: process.argv, @@ -23,16 +24,41 @@ const args = parseArgs({ }, outfile: { type: "string", - default: process.env.DSQL_DB_NAME, short: "o", }, + debug: { + type: "boolean", + default: false, + short: "d", + }, }, strict: false, }); (async () => { try { - const { apiKey: key, database, outfile } = args.values; + const { apiKey: key, database, outfile, debug } = args.values; + + if (debug) { + debugLog({ + log: args.values, + label: "Arguments", + title: "Schema to Typedef", + addTime: true, + }); + debugLog({ + log: process.env.DSQL_FULL_ACCESS_API_KEY, + label: "process.env.DSQL_FULL_ACCESS_API_KEY", + title: "Schema to Typedef", + addTime: true, + }); + debugLog({ + log: process.env.DSQL_DB_NAME, + label: "process.env.DSQL_DB_NAME", + title: "Schema to Typedef", + addTime: true, + }); + } if (!database || typeof database !== "string") throw new Error("Database name is required"); @@ -65,7 +91,13 @@ const args = parseArgs({ "utf-8" ); } catch (error: any) { - console.log("Error:", error.message); + debugLog({ + log: error.message, + label: "Error", + title: "Schema to Typedef", + addTime: true, + type: "error", + }); process.exit(1); } })(); diff --git a/package.json b/package.json index 4444014..78c6303 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@moduletrace/datasquirel", - "version": "4.3.0", + "version": "4.3.1", "description": "Cloud-based SQL data management tool", "main": "dist/index.js", "bin": {