-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
36 lines (30 loc) · 998 Bytes
/
index.js
File metadata and controls
36 lines (30 loc) · 998 Bytes
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
import { thousands, writeJSONToOutput } from './utils.js'
import { getCraftlandAggregate } from './aggregates.js'
try {
const now = new Date();
console.info('Generating:', now.toLocaleString(), '|', now.toString());
console.log();
// Aggregates
const craftlandData = await getCraftlandAggregate();
// Craftland JSON
writeJSONToOutput('craftland.json', { ...craftlandData });
// shields JSON
writeJSONToOutput('shields.craftland.likes.json', {
schemaVersion: 1,
label: 'Craftland Likes',
message: thousands(craftlandData.likesTotal), // Craftland likes
cacheSeconds: 3600
});
writeJSONToOutput('shields.craftland.stars.json', {
schemaVersion: 1,
label: 'Craftland Stars',
message: thousands(craftlandData.starsTotal), // Craftland stars
cacheSeconds: 3600
});
console.log();
console.info('All generation has been completed.');
process.exit(0);
} catch (error) {
console.error('Generate JSON error!', error);
process.exit(1);
}