mirror of
https://github.com/bubblecup-12/VogelSocialMedia.git
synced 2025-07-06 15:18:48 +00:00
changed the script to run even when .env exists but not all configs are set
This commit is contained in:
parent
89b580a30c
commit
312e925c1b
2 changed files with 19 additions and 4 deletions
|
@ -7,5 +7,6 @@
|
|||
"yarn prisma generate",
|
||||
"echo migrating database",
|
||||
"yarn prisma migrate dev --name init"
|
||||
]
|
||||
],
|
||||
"requiredKeys": ["DATABASE_URL", "TOKEN_SECRET", "DB_USER", "DB_PASSWORD"]
|
||||
}
|
||||
|
|
|
@ -5,15 +5,29 @@ const execPromise = util.promisify(exec);
|
|||
import fs, { read } from "fs";
|
||||
import readlineSync from "readline-sync";
|
||||
import crypto from "crypto";
|
||||
import dotenv from "dotenv";
|
||||
import { boolean } from "zod";
|
||||
|
||||
const json_path: string = "scripts/install.json"; // Path to the JSON file
|
||||
const raw = fs.readFileSync(json_path, "utf8");
|
||||
const config = JSON.parse(raw); // Parse the JSON file
|
||||
|
||||
//check if there is a .env file and abort the installation
|
||||
//check if there is a .env and if it has the correct settings
|
||||
let allSet: boolean = true;
|
||||
if (fs.existsSync(".env")) {
|
||||
// Check if the script has already been run
|
||||
console.log("Already installed");
|
||||
dotenv.config();
|
||||
for (const key of config.requiredKeys) {
|
||||
if (!process.env[key]) {
|
||||
allSet = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
allSet = false;
|
||||
}
|
||||
|
||||
if (allSet) {
|
||||
// if it`s all set abort the installation
|
||||
process.exit(0);
|
||||
}
|
||||
// getting user input for the PostgreSQL username and password
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue