forked from JannisX11/blockbench-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate_plugin_updates.mjs
More file actions
37 lines (30 loc) · 992 Bytes
/
Copy pathgenerate_plugin_updates.mjs
File metadata and controls
37 lines (30 loc) · 992 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
37
import plugins from "../plugins.json" with { type: "json" }
import fs from "node:fs"
const updates = {}
for (const [id, data] of Object.entries(plugins)) {
if (!data.version || !/^\d+\.\d+\.\d+$/.test(data.version)) {
continue
}
updates[id] = {
version: data.version
}
let changelog
if (data.has_changelog && fs.existsSync(`../plugins/${id}/changelog.json`)) {
try {
changelog = Object.values(JSON.parse(fs.readFileSync(`../plugins/${id}/changelog.json`)))
} catch {}
}
if (data.creation_date) {
updates[id].created = Date.parse(data.creation_date) || 0
} else if (changelog?.[0]?.date) {
updates[id].created = Date.parse(changelog[0].date) || 0
} else {
updates[id].created = 0
}
if (changelog?.at(-1)?.date) {
updates[id].updated = Date.parse(changelog.at(-1).date) || updates[id].created
} else {
updates[id].updated = updates[id].created
}
}
fs.writeFileSync("../updates.json", JSON.stringify(updates, null, 2))