-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.js
49 lines (44 loc) · 1.43 KB
/
setup.js
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
const chalk = require('chalk');
const clear = require('clear');
const figlet = require('figlet');
const inquirer = require('inquirer');
const fs = require('fs');
const { exec } = require('child_process')
clear(); // clear the actual terminal
console.log(
chalk.blueBright(
figlet.textSync('schoolsyst', { font: "Small Slant", horizontalLayout: 'full' })
)
);
console.log(
chalk.grey(
"--------------------------------------------------------------------------------"
)
);
let moduleManager = {
type: 'list',
name: 'moduleManager',
message: 'Select the module manager for node.js you wish want to use (will be used to install depandancy for submodule) : ',
choices: ["npm", "yarn", "pnpm"],
default: "npm"
};
inquirer
.prompt([
moduleManager
])
.then(answers => {
console.log(chalk.green('>'), chalk.white(`Launching installation with :`), chalk.cyan(answers.moduleManager));
exec(`git pull --recurse-submodules && cd ${__dirname}/webapp && ${answers.moduleManager} install && ${answers.moduleManager} build:dev`, (error, stdout) => {
if (error) {
console.error(chalk.redBright('x'), `error while setuping submodule, error: ${error}`);
}
console.log(chalk.green('>'), chalk.white(stdout));
});
})
.catch(error => {
if(error.isTtyError) {
console.error("Couldn't prompt setup because your environement couldn't render the prompt !")
} else {
console.error("Error with the prompt : ", error)
}
});