-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerateExexesJson.js
41 lines (31 loc) · 1.05 KB
/
generateExexesJson.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
const fs = require('fs');
const path = require('path');
const exexesDir = path.join(__dirname, 'exexes');
const outputFilePath = path.join(__dirname, 'public', 'exexes.json');
function getExexes() {
const exexes = [];
const exexFiles = fs.readdirSync(exexesDir);
exexFiles.forEach(file => {
const exexPath = path.join(exexesDir, file);
const stats = fs.statSync(exexPath);
if (stats.isDirectory() && file !== '_template_exex') {
const dataPath = path.join(exexPath, 'data.json');
if (fs.existsSync(dataPath)) {
const data = JSON.parse(fs.readFileSync(dataPath, 'utf-8'));
const exexData = {
id: file,
repolink: `https://github.com/weaveVM/exex.rs/tree/main/exexes/${file}`,
...data
};
exexes.push(exexData);
}
}
});
return exexes;
}
function writeExexesToFile(exexes) {
fs.writeFileSync(outputFilePath, JSON.stringify(exexes, null, 2), 'utf-8');
console.log(`Exexes data written to ${outputFilePath}`);
}
const exexes = getExexes();
writeExexesToFile(exexes);