forked from dsyman2/contentstack-export
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
executable file
·56 lines (49 loc) · 1.51 KB
/
app.js
File metadata and controls
executable file
·56 lines (49 loc) · 1.51 KB
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
var Bluebird = require('bluebird');
var util = require('./lib/util');
var login = require('./lib/util/login');
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;
if (process.argv.length === 3) {
var val = process.argv[2];
if (val && types.indexOf(val) > -1) {
var exportedModule = require('./lib/export/' + val);
return exportedModule.start().then(function () {
log.success(val + ' were exported successfully!');
return;
}).catch(function (error) {
log.error('Failed to migrate ' + val);
log.error(error);
return;
})
} else {
log.error('Please provide valid module name.');
return 0;
}
} else if (process.argv.length === 2) {
var counter = 0;
return Bluebird.map(types, function (type) {
log.success('Exporting: ' + types[counter])
var exportedModule = require('./lib/export/' + types[counter]);
counter++
return exportedModule.start()
}, {
concurrency: 1
}).then(function () {
log.success('Stack: ' + config.source_stack + ' has been exported succesfully!');
}).catch(function (error) {
console.error(error)
log.error('Failed to migrate stack: ' + config.source_stack + '. Please check error logs for more info');
log.error(error);
});
} else {
log.error('Only one module can be exported at a time.');
return 0;
}
});