Updates
This commit is contained in:
parent
e0f171cc1d
commit
71ef33c241
31
console-colors.js
Normal file
31
console-colors.js
Normal file
@ -0,0 +1,31 @@
|
||||
const colors = {
|
||||
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",
|
||||
};
|
||||
|
||||
module.exports = colors;
|
@ -11,6 +11,7 @@ require("dotenv").config({
|
||||
|
||||
const datasquirel = require("../index");
|
||||
const createDbFromSchema = require("./engine/createDbFromSchema");
|
||||
const colors = require("../console-colors");
|
||||
|
||||
if (!fs.existsSync(path.resolve(process.cwd(), ".env"))) {
|
||||
console.log(".env file not found");
|
||||
@ -89,30 +90,27 @@ async function run() {
|
||||
fs.writeFileSync(dbSchemaLocalFilePath, JSON.stringify(schemaData[0], null, 4), "utf8");
|
||||
}
|
||||
|
||||
console.log("Now generating and mapping databases ...");
|
||||
// console.log("Db Schema =>", schemaData);
|
||||
console.log(` - ${colors.FgBlue}Info:${colors.Reset} Now generating and mapping databases ...`);
|
||||
|
||||
// deepcode ignore reDOS: <please specify a reason of ignoring this>
|
||||
await createDbFromSchema(schemaData);
|
||||
console.log("Databases created Successfully!");
|
||||
console.log(` - ${colors.FgGreen}Success:${colors.Reset} Databases created Successfully!`);
|
||||
}
|
||||
|
||||
// let timeout;
|
||||
|
||||
// if (fs.existsSync(dbSchemaLocalFilePath)) {
|
||||
// fs.watchFile(dbSchemaLocalFilePath, { interval: 1000 }, (curr, prev) => {
|
||||
// clearTimeout(timeout);
|
||||
|
||||
// timeout = setTimeout(() => {
|
||||
// console.log("`dsql.schema.json` file changed. Now syncing databases ...");
|
||||
// run();
|
||||
// }, 5000);
|
||||
// });
|
||||
// }
|
||||
|
||||
let interval;
|
||||
interval = setInterval(() => {
|
||||
console.log("Syncing Databases ...");
|
||||
run();
|
||||
}, 20000);
|
||||
|
||||
if (fs.existsSync(dbSchemaLocalFilePath) && !DSQL_KEY?.match(/....../)) {
|
||||
fs.watchFile(dbSchemaLocalFilePath, { interval: 1000 }, (curr, prev) => {
|
||||
console.log(` - ${colors.FgBlue}Info:${colors.Reset} Syncing Databases Locally ...`);
|
||||
run();
|
||||
});
|
||||
} else if (DSQL_KEY?.match(/....../)) {
|
||||
interval = setInterval(() => {
|
||||
console.log(` - ${colors.FgMagenta}Info:${colors.Reset} Syncing Databases from the cloud ...`);
|
||||
run();
|
||||
}, 20000);
|
||||
}
|
||||
|
||||
run();
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "datasquirel",
|
||||
"version": "1.8.4",
|
||||
"version": "1.8.5",
|
||||
"description": "Cloud-based SQL data management tool",
|
||||
"main": "index.js",
|
||||
"bin": {
|
||||
|
Loading…
Reference in New Issue
Block a user