-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
56 lines (43 loc) · 1.38 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
/**
* PHP MyAdmin updater.
*/
'use strict';
import * as fs from 'node:fs';
import { clearOldFilesTask } from './app/Tasks/clearOldFiles.mjs';
import { composerUpdater } from './app/Tasks/composerUpdater.mjs';
import { filesMover } from './app/Tasks/filesMover.mjs';
// read config.json. ---------------------------
const filePath = new URL('./config.json', import.meta.url);
const configJSON = JSON.parse(
fs.readFileSync(filePath, {encoding: 'utf8'})
);
// read config.json. ---------------------------
if (typeof(configJSON) !== 'object') {
console.error('Error: config.json is not exists or malform.');
process.exit(1);
}
console.log('Update phpMyAdmin');
let pmaVersion, result, saveFilePath;
try {
const clearOldFilesTaskObj = new clearOldFilesTask({'configJSON': configJSON});
result = await clearOldFilesTaskObj.run();
} catch (ex) {
console.error('Error: ' + ex.message);
}
if (result) {
try {
const composerUpdaterObj = new composerUpdater({'configJSON': configJSON});
result = await composerUpdaterObj.run();
} catch (ex) {
console.error('Error: ' + ex.message);
}
}
if (result) {
try {
const filesMoverObj = new filesMover({'configJSON': configJSON});
await filesMoverObj.run();
console.log('Update completed successfully.');
} catch (ex) {
console.error('Error: ' + ex.message);
}
}