-
Notifications
You must be signed in to change notification settings - Fork 0
/
changelog.js
66 lines (53 loc) · 1.22 KB
/
changelog.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import { existsSync, mkdirSync, writeFileSync } from 'node:fs';
if (!existsSync('changelog')) {
mkdirSync('changelog');
}
const response = await fetch('https://api.github.com/repos/zbrateam/Zebra/releases', {
headers: {
Accept: 'application/vnd.github.v3.raw+json'
}
});
const json = await response.json();
generateDepiction(json),
generateData(json)
function generateDepiction(response) {
const changelog = [];
for (const item of response) {
changelog.push({
name: 'HeadingView',
properties: {
text: item.tag_name.substring(1)
}
});
changelog.push({
name: 'TextView',
properties: {
content: item.body
}
});
changelog.push({
name: 'Separator'
});
}
// remove trailing separator
changelog.pop();
const depiction = {
$schema: './schema.json',
tint_color: {
light_theme: '#6680fa',
dark_theme: '#8599ff'
},
children: changelog
}
writeFileSync('changelog/depiction.json', JSON.stringify(depiction));
}
function generateData(response) {
const changelog = response.map(item => {
return {
version: item.tag_name.substring(1),
date: item.published_at,
body: item.body
};
});
writeFileSync('changelog/data.json', JSON.stringify({ data: changelog }));
}