-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
filterDB.js
40 lines (34 loc) · 1001 Bytes
/
filterDB.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
const { writeFile } = require('fs/promises');
/**
* db_j3.json and db_j4.json expected to be the JSON export of all the entries
* of the table extensions on a vanilla Joomla instalation.
* (Obviously j3 === Joomla v3, j4 === Joomla v4)
* The JSON files are expected to be created using Sequel Pro
*
* @todo use the standard .sql files from the repo to create the JSON files
*/
const dbJson3 = require('./db_j3.json');
const dbJson4 = require('./db_j4.json');
const keysToKeep = [
'package_id',
'name',
'type',
'element',
'folder',
'client_id',
'enabled',
'access',
'protected',
];
const clean = (obj) => {
return Object.fromEntries(Object.entries(obj).filter(([key, value]) => keysToKeep.includes(key) === true));
}
(async () => {
const dataJ3 = dbJson3.data.map(ext => clean(ext))
const dataJ4 = dbJson4.data.map(ext => clean(ext))
const newData = {
j3: dataJ3,
j4: dataJ4,
};
await writeFile('db.json', JSON.stringify(newData, '', 2), {encoding: 'utf8'});
})();