-
Notifications
You must be signed in to change notification settings - Fork 2
/
app.js
executable file
·40 lines (39 loc) · 1.38 KB
/
app.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
#!/usr/bin/env node
var getUtils = require('./js/modules/getutils'),
updateUtils = require('./js/modules/updateutils'),
publishUtils = require('./js/modules/publishutils'),
rollbackUtils = require('./js/modules/rollbackutils'),
cliUtils = require('./js/modules/cliutils'),
setup = require('./js/modules/setuputils'),
config = require('./js/static/config.json');
cliUtils.showFiglet();
if ( !config.usersFolder ) {
setup.getSetupDetails();
}
else if ( config.usersFolder ) {
require('dotenv').config({path: process.env.HOME +'/'+ config.usersFolder +
'/hub-batch/.env', silent: true});
setup.isAuthTokenValid().then(function(status) {
if ( status !== 200 ) {
console.log("Your auth token is invalid or has expired. Please re-enter:");
setup.getSetupDetails();
}
else if ( status === 200 ) {
cliUtils.getUserPreferences(function(answersObj) {
var method = answersObj.method;
if ( method === 'get' ) {
getUtils.makeGetRequest(answersObj);
}
else if ( method === 'update' ) {
updateUtils.makeUpdateRequest(answersObj);
}
else if ( method === 'publish' ) {
publishUtils.makePublishRequest(answersObj);
}
else if ( method === 'rollback' ) {
rollbackUtils.makeRollbackRequest(answersObj);
}
});
}
});
}