Updates
This commit is contained in:
parent
870de51f5d
commit
a9c0dd4b63
26
dist/engine/schema-to-typedef.js
vendored
26
dist/engine/schema-to-typedef.js
vendored
@ -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,
|
||||
|
2
dist/index.d.ts
vendored
2
dist/index.d.ts
vendored
@ -40,6 +40,7 @@ import dsqlCrud from "./package-shared/utils/data-fetching/crud";
|
||||
import dsqlMethodCrud from "./package-shared/utils/data-fetching/method-crud";
|
||||
import debugLog from "./package-shared/utils/logging/debug-log";
|
||||
import { ErrorCallback } from "./package-shared/types";
|
||||
import parseEnv from "./package-shared/utils/parse-env";
|
||||
/**
|
||||
* Main Export
|
||||
*/
|
||||
@ -129,6 +130,7 @@ declare const datasquirel: {
|
||||
httpRequest: typeof httpRequest;
|
||||
connDbHandler: typeof connDbHandler;
|
||||
debugLog: typeof debugLog;
|
||||
parseEnv: typeof parseEnv;
|
||||
};
|
||||
/**
|
||||
* Run Crud actions `get`, `insert`, `update`, `delete`
|
||||
|
2
dist/index.js
vendored
2
dist/index.js
vendored
@ -37,6 +37,7 @@ const delete_user_1 = __importDefault(require("./package-shared/actions/users/de
|
||||
const crud_1 = __importDefault(require("./package-shared/utils/data-fetching/crud"));
|
||||
const method_crud_1 = __importDefault(require("./package-shared/utils/data-fetching/method-crud"));
|
||||
const debug_log_1 = __importDefault(require("./package-shared/utils/logging/debug-log"));
|
||||
const parse_env_1 = __importDefault(require("./package-shared/utils/parse-env"));
|
||||
/**
|
||||
* User Functions Object
|
||||
*/
|
||||
@ -102,6 +103,7 @@ const datasquirel = {
|
||||
httpRequest: httpRequest_1.default,
|
||||
connDbHandler: conn_db_handler_1.default,
|
||||
debugLog: debug_log_1.default,
|
||||
parseEnv: parse_env_1.default,
|
||||
},
|
||||
/**
|
||||
* Run Crud actions `get`, `insert`, `update`, `delete`
|
||||
|
3
dist/package-shared/utils/parse-env.d.ts
vendored
Normal file
3
dist/package-shared/utils/parse-env.d.ts
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
export default function parseEnv(/** Env File Path */ envPath: string): {
|
||||
[k: string]: string;
|
||||
};
|
19
dist/package-shared/utils/parse-env.js
vendored
Normal file
19
dist/package-shared/utils/parse-env.js
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = parseEnv;
|
||||
const fs_1 = __importDefault(require("fs"));
|
||||
const path_1 = __importDefault(require("path"));
|
||||
function parseEnv(/** Env File Path */ envPath) {
|
||||
let obj = {};
|
||||
const finalEnvPath = path_1.default.resolve(process.cwd(), envPath);
|
||||
const envFile = fs_1.default.readFileSync(finalEnvPath, "utf-8");
|
||||
const envLinesArr = envFile.split(/\r\n/).filter((ln) => ln.match(/\=/));
|
||||
envLinesArr.forEach((ln) => {
|
||||
const keyValArr = ln.split("=");
|
||||
obj[keyValArr[0]] = keyValArr[1] || "";
|
||||
});
|
||||
return obj;
|
||||
}
|
@ -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,
|
||||
|
2
index.ts
2
index.ts
@ -48,6 +48,7 @@ import dsqlCrud from "./package-shared/utils/data-fetching/crud";
|
||||
import dsqlMethodCrud from "./package-shared/utils/data-fetching/method-crud";
|
||||
import debugLog from "./package-shared/utils/logging/debug-log";
|
||||
import { ErrorCallback } from "./package-shared/types";
|
||||
import parseEnv from "./package-shared/utils/parse-env";
|
||||
|
||||
/**
|
||||
* User Functions Object
|
||||
@ -117,6 +118,7 @@ const datasquirel = {
|
||||
httpRequest,
|
||||
connDbHandler,
|
||||
debugLog,
|
||||
parseEnv,
|
||||
},
|
||||
/**
|
||||
* Run Crud actions `get`, `insert`, `update`, `delete`
|
||||
|
16
package-shared/utils/parse-env.ts
Normal file
16
package-shared/utils/parse-env.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
|
||||
export default function parseEnv(/** Env File Path */ envPath: string) {
|
||||
let obj: { [k: string]: string } = {};
|
||||
const finalEnvPath = path.resolve(process.cwd(), envPath);
|
||||
const envFile = fs.readFileSync(finalEnvPath, "utf-8");
|
||||
const envLinesArr = envFile.split(/\r\n/).filter((ln) => ln.match(/\=/));
|
||||
|
||||
envLinesArr.forEach((ln) => {
|
||||
const keyValArr = ln.split("=");
|
||||
obj[keyValArr[0]] = keyValArr[1] || "";
|
||||
});
|
||||
|
||||
return obj;
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@moduletrace/datasquirel",
|
||||
"version": "4.3.2",
|
||||
"version": "4.3.3",
|
||||
"description": "Cloud-based SQL data management tool",
|
||||
"main": "dist/index.js",
|
||||
"bin": {
|
||||
|
Loading…
Reference in New Issue
Block a user