-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.js
76 lines (55 loc) · 2.07 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
56
57
58
59
60
61
62
63
'use strict';
const ConfigurationMigrator = require('./configurationMigrator');
const DataMigrator = require('./dataMigrator');
const utils = require('./utils');
const winston = require('winston');
const fs = require('fs');
const logger = new (winston.Logger)({
transports: [
new (winston.transports.Console)({
colorize: true,
formatter: formatter
}),
new (winston.transports.File)({
filename: './migration-error.log',
level: 'error'
})
]
});
function formatter(args) {
var logMessage = args.message;
return logMessage;
}
let config;
try {
config = JSON.parse(fs.readFileSync('./config.json', 'utf8'));
} catch (err) {
console.error(new Error(err));
}
const operation = process.argv.slice(2, 3).toString();
if (operation === '--login') {
utils.authenticateUser(logger, config);
} else {
//Do not change those values. If you set them too high your API access will be automatically disabled.
config.page_size_files = 50;
config.page_size_data = 500;
config.page_size_users = 50;
config.max_parallel_requests = 10;
config.bs_host = 'api.everlive.com';
if (operation === '--migrate-config') {
const configurationMigrator = new ConfigurationMigrator(logger, config);
configurationMigrator.migrateConfiguration();
} else if (operation === '--migrate-data') {
const dataMigrator = new DataMigrator(logger, config);
dataMigrator.migrateDataContent();
} else if (operation === '--cleanup-dest') {
const configurationMigrator = new ConfigurationMigrator(logger, config);
configurationMigrator.cleanupDestinationApp();
} else {
logger.warn('Unrecognized command.' +
'\n\nValid options are:' +
'\n --login - Initializes the Kinvey management authentication' +
'\n --migrate-config - Migrates the backend configuration of the app specified in config.json file' +
'\n --migrate-data - Migrates the data of the app specified in config.json file');
}
}