forked from medic/cht-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
apply-config.js
37 lines (32 loc) · 964 Bytes
/
apply-config.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
const constants = require('./constants');
const auth = require('./auth')();
const medicConf = require('medic-conf');
const defaultActions = [
'compile-app-settings',
'upload-app-settings',
'convert-app-forms',
'convert-collect-forms',
'convert-contact-forms',
'delete-all-forms',
'upload-app-forms',
'upload-collect-forms',
'upload-contact-forms',
'upload-resources',
'upload-custom-translations'
];
const applyConfig = async path => {
const COUCH_URL = `http://${auth.username}:${auth.password}@${constants.API_HOST}:${constants.API_PORT}/${constants.DB_NAME}`;
defaultActions.forEach(async function(action) {
if (action === 'compile-app-settings') {
await medicConf(action, COUCH_URL, ['--noDependencyCheck'], path);
} else {
await medicConf(action, COUCH_URL, '', path);
}
});
return new Promise(resolve => {
setTimeout(() => {
resolve();
}, 5000);
});
};
module.exports = applyConfig;