-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcreate_own_module_list.js
48 lines (40 loc) · 1.31 KB
/
create_own_module_list.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
import fs from "node:fs";
let ownModuleListPath = "./ownModuleList.json";
if (!fs.existsSync(ownModuleListPath)) {
ownModuleListPath = "./ownModuleList_sample.json";
console.error("No ownModuleList.json found. Using ownModuleList_sample.json");
}
const ownModuleList = JSON.parse(fs.readFileSync(ownModuleListPath));
// eslint-disable-next-line @stylistic/space-before-function-paren
function sortByNameIgnoringPrefix(a, b) {
const nameA = a.name.replace("MMM-", "");
const nameB = b.name.replace("MMM-", "");
return nameA.localeCompare(nameB);
}
function createModuleList () {
const moduleList = [];
ownModuleList.forEach((module) => {
module.issues = [];
module.id = module.url
.replace("https://github.com/", "")
.replace("https://gitlab.com/", "");
module.maintainer = module.url.split("/")[3];
module.name = module.url.split("/")[4];
module.maintainerURL = "";
if (typeof module.description === "undefined") {
module.description = "";
}
moduleList.push(module);
});
const sortedModuleList = moduleList.sort(sortByNameIgnoringPrefix);
const data = {
"lastUpdate": new Date().toISOString(),
"modules": sortedModuleList
};
fs.writeFileSync(
"./docs/data/modules.stage.1.json",
JSON.stringify(data, null, 2),
"utf8"
);
}
createModuleList();