-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
56 lines (46 loc) · 1.57 KB
/
index.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
50
51
52
53
54
55
#!/usr/bin/env node
const cwd = require("process").cwd;
console.log(cwd);
const inquirer = require("inquirer");
const clear = require("clear");
const chalk = require("chalk");
const figlet = require("figlet");
const ora = require('ora');
const { hackintoshPkgInstall } = require("./cliModel/index");
const options = require("./options");
const { default: Axios } = require("axios");
const dotenv = require("dotenv");
dotenv.config()
const prompt = inquirer.createPromptModule();
clear();
console.log(
chalk.green(
figlet.textSync("Hackintosh Pkg CLI", {
horizontalLayout: "fitted",
font: "Small",
verticalLayout: "full",
})
)
);
const spinner = ora('Downloading a few dependencies...')
spinner.color = 'yellow'
spinner.start();
appInitialize();
function appInitialize() {
let getUpdatedVersionsURL = process.env.ENVIRONMENT === "DEVELOPMENT"
? `http://localhost:${process.env.PORT}/github/getUpdatedVersions`
: `https://hackintosh-pkg-api.herokuapp.com/github/getUpdatedVersions`;
let getUpdatedVersionsData = [];
Axios.get(getUpdatedVersionsURL).then((res) => {
spinner.color = 'green'
spinner.text = "Downloaded dependencies"
spinner.succeed()
res.data.allVersions.forEach(x => {
getUpdatedVersionsData.push(x)
})
prompt(hackintoshPkgInstall).then((answers) => {
if (answers.packages.length === 0) return appInitialize()
return options(answers, getUpdatedVersionsData);
});
}).catch(err => console.log(err))
};