Spaces:
Sleeping
Sleeping
File size: 1,632 Bytes
868b252 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
import inquirer from "inquirer";
import dotenv from "dotenv";
import { printTitle } from "./helpers.js";
import { doesEnvFileExist, generateEnv, testEnvFile } from "./envGenerator.js";
import { newEnvQuestions } from "./questions/newEnvQuestions.js";
import { existingEnvQuestions } from "./questions/existingEnvQuestions.js";
import { spawn } from "child_process";
import chalk from "chalk";
const handleExistingEnv = () => {
console.log(chalk.yellow("Existing ./next/env file found. Validating..."));
try {
testEnvFile();
} catch (e) {
console.log(e.message);
return;
}
inquirer.prompt(existingEnvQuestions).then((answers) => {
handleRunOption(answers.runOption);
});
};
const handleNewEnv = () => {
inquirer.prompt(newEnvQuestions).then((answers) => {
dotenv.config({ path: "./.env" });
generateEnv(answers);
console.log("\nEnv files successfully created!");
handleRunOption(answers.runOption);
});
};
const handleRunOption = (runOption) => {
if (runOption === "docker-compose") {
const dockerComposeUp = spawn("docker-compose", ["up", "--build"], {
stdio: "inherit",
});
}
if (runOption === "manual") {
console.log(
"Please go into the ./next folder and run `npm install && npm run dev`."
);
console.log(
"Please also go into the ./platform folder and run `poetry install && poetry run python -m reworkd_platform`."
);
console.log(
"Please use or update the MySQL database configuration in the env file(s)."
);
}
};
printTitle();
if (doesEnvFileExist()) {
handleExistingEnv();
} else {
handleNewEnv();
}
|