Updates
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import datasquirel from "@moduletrace/datasquirel";
|
||||
import { execSync, ExecSyncOptions } from "child_process";
|
||||
import os from "os";
|
||||
import connDbHandler from "../db/conn-db-handler";
|
||||
|
||||
export type ExportMariaDBDatabaseParam = {
|
||||
dbFullName: string;
|
||||
@@ -27,7 +27,7 @@ export default async function importMariadbDatabase({
|
||||
const finalMariadbHost = mariadbHost || process.env.DSQL_DB_HOST;
|
||||
const finalMariadbPass = mariadbPass || process.env.DSQL_DB_PASSWORD;
|
||||
|
||||
await datasquirel.utils.connDbHandler(
|
||||
await connDbHandler(
|
||||
global.DSQL_DB_CONN,
|
||||
`CREATE DATABASE IF NOT EXISTS ${dbFullName}`
|
||||
);
|
||||
|
||||
@@ -62,6 +62,11 @@ export default function grabDirNames(param?: Param) {
|
||||
? path.join(userPrivateSQLExportsDir, userPrivateDbImportZipFileName)
|
||||
: undefined;
|
||||
|
||||
const dbNginxLoadBalancerConfigFile = path.join(
|
||||
appDir,
|
||||
"docker/mariadb/load-balancer/config/template/nginx.conf"
|
||||
);
|
||||
|
||||
return {
|
||||
schemasDir,
|
||||
userDirPath,
|
||||
@@ -80,5 +85,6 @@ export default function grabDirNames(param?: Param) {
|
||||
userPrivateDbExportZipFilePath,
|
||||
userPrivateDbImportZipFileName,
|
||||
userPrivateDbImportZipFilePath,
|
||||
dbNginxLoadBalancerConfigFile,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
const consoleColors = {
|
||||
Reset: "\x1b[0m",
|
||||
Bright: "\x1b[1m",
|
||||
Dim: "\x1b[2m",
|
||||
Underscore: "\x1b[4m",
|
||||
Blink: "\x1b[5m",
|
||||
Reverse: "\x1b[7m",
|
||||
Hidden: "\x1b[8m",
|
||||
|
||||
FgBlack: "\x1b[30m",
|
||||
FgRed: "\x1b[31m",
|
||||
FgGreen: "\x1b[32m",
|
||||
FgYellow: "\x1b[33m",
|
||||
FgBlue: "\x1b[34m",
|
||||
FgMagenta: "\x1b[35m",
|
||||
FgCyan: "\x1b[36m",
|
||||
FgWhite: "\x1b[37m",
|
||||
FgGray: "\x1b[90m",
|
||||
|
||||
BgBlack: "\x1b[40m",
|
||||
BgRed: "\x1b[41m",
|
||||
BgGreen: "\x1b[42m",
|
||||
BgYellow: "\x1b[43m",
|
||||
BgBlue: "\x1b[44m",
|
||||
BgMagenta: "\x1b[45m",
|
||||
BgCyan: "\x1b[46m",
|
||||
BgWhite: "\x1b[47m",
|
||||
BgGray: "\x1b[100m",
|
||||
};
|
||||
|
||||
export default consoleColors;
|
||||
export const ccol = consoleColors;
|
||||
@@ -0,0 +1,60 @@
|
||||
import { ccol } from "../console-colors";
|
||||
|
||||
const LogTypes = ["error", "warning"] as const;
|
||||
|
||||
type Param = {
|
||||
/**
|
||||
* data to be logged.
|
||||
*/
|
||||
log: any;
|
||||
/**
|
||||
* Log Title. Could be name of function or name of variable
|
||||
*/
|
||||
title?: string;
|
||||
/**
|
||||
* Label for the log
|
||||
*/
|
||||
label?: string;
|
||||
/**
|
||||
* Log type. `error` or `warning` or default
|
||||
*/
|
||||
type?: (typeof LogTypes)[number];
|
||||
/**
|
||||
* Whether to add a time stamp
|
||||
*/
|
||||
addTime?: boolean;
|
||||
};
|
||||
|
||||
export default function debugLog({ log, label, title, type, addTime }: Param) {
|
||||
const logType = (() => {
|
||||
switch (type) {
|
||||
case "error":
|
||||
return ccol.FgRed;
|
||||
|
||||
case "warning":
|
||||
return ccol.FgYellow;
|
||||
|
||||
default:
|
||||
return ccol.FgGreen;
|
||||
}
|
||||
})();
|
||||
|
||||
let logTxt = `${logType}DEBUG${ccol.Reset}:::`;
|
||||
|
||||
const date = new Date();
|
||||
const time = date.toLocaleTimeString("en-US", {
|
||||
hour: "numeric",
|
||||
minute: "numeric",
|
||||
second: "numeric",
|
||||
hour12: true,
|
||||
});
|
||||
|
||||
const logTime = `${date.toLocaleDateString()}][${time}`;
|
||||
|
||||
if (addTime) logTxt = `${ccol.BgWhite}[${logTime}]${ccol.Reset} ` + logTxt;
|
||||
if (title) logTxt += `${ccol.FgBlue}${title}${ccol.Reset}::`;
|
||||
if (label)
|
||||
logTxt += `${ccol.FgWhite}${ccol.Bright}${label}${ccol.Reset} =>`;
|
||||
|
||||
console.log(logTxt, log);
|
||||
}
|
||||
Reference in New Issue
Block a user