-
Notifications
You must be signed in to change notification settings - Fork 63
/
generateIndex.js
30 lines (27 loc) · 999 Bytes
/
generateIndex.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
const fs = require('fs');
const ejs = require('ejs');
const benchmark = require('./benchmark/filesize.js');
const { legacy, latest } = require('./benchmark/meta');
const latestWithBytes = benchmark.filesizeGzipped(latest);
const metasWithKb = latestWithBytes.map((project) => ({
...project,
size: project.size / 1000,
group: project.group ? benchmark.filesizeGzipped(legacy[project.group]).map((project) => ({
...project,
size: project.size / 1000,
})) : null,
}));
console.log('metasWithKb', metasWithKb)
const maxSize = Math.max(...metasWithKb.map(project => project.size));
const WCprojects = metasWithKb.filter(project => project.wc);
const NonWCprojects = metasWithKb.filter(project => !project.wc);
ejs.renderFile('./templates/index.ejs', {
WCprojects,
NonWCprojects,
maxSize,
}, {}, function (err, str) {
fs.writeFile('dist/index.html', str, (err) => {
if (err) throw err;
console.log('The file has been saved!');
});
});