-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
executable file
·78 lines (67 loc) · 2.86 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
const Bluebird = require('bluebird');
const prompt = require('prompt');
const chalk = require('chalk');
//const Confirm = require('prompt-confirm');
const util = require('./lib/util');
const login = require('./lib/util/login');
const stack = require('./lib/util/stack');
var config = require('./config');
var log = require('./lib/util/log');
config = util.buildAppConfig(config)
util.validateConfig(config)
exports.getConfig = function() {
return config;
};
login(config).then(function() {
var types = config.modules.types;
stack(config).then(function() {
prompt.start();
var message = chalk.red("To confirm the delete action, enter your stack name ?")
prompt.get([message], function(err, result) {
if (result[message] === config.stack.name) {
// eslint-disable-next-line no-undef
if (process.argv.length === 3) {
// eslint-disable-next-line no-undef
var val = process.argv[2];
if (val && types.indexOf(val) > -1) {
var deleteContentType = require('./lib/delete/' + val);
return deleteContentType.start().then(function() {
log.success( 'Deletion completed successfully!');
return;
}).catch(function(error) {
log.error('Failed to Delete ' +" "+JSON.stringify(error));
return;
})
} else {
log.error('Please provide valid module name.');
return 0;
}
// eslint-disable-next-line no-undef
} else if (process.argv.length === 2) {
var counter = 0;
return Bluebird.map(types, function() {
log.success('Deleting: ' + types[counter])
var deleteModule = require('./lib/delete/' + types[counter]);
counter++
return deleteModule.start()
}, {
concurrency: 1
}).then(function() {
log.success("All deletion completed successfully!");
}).catch(function(error) {
// eslint-disable-next-line no-console
log.error(error);
});
} else {
log.error('Only one module can be deleted at a time.');
return 0;
}
} else {
// eslint-disable-next-line no-console
console.log("Failed. Stack name does not match with stack detail specified in the config file.");
log.error(err)
return 0;
}
});
})
});