This repository has been archived on 2026-04-20. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
AsaJS/scripts/prefetch.ts
2026-01-18 01:59:02 +07:00

32 lines
1,023 B
TypeScript

import { Github, PFFS } from "./components"
import { parse } from "jsonc-parser"
const user = "mojang"
const project = "bedrock-samples"
const branches = process.argv.includes("--preview") ? "preview" : "main"
async function fetchfile(path: string) {
return parse(await Github.readFile(user, project, branches, path))
}
async function main() {
console.log("Prefetching...")
const data = await Github.readFile("KalmeMarq", "Bugrock-JSON-UI-Schemas", "main", "ui.schema.json")
await PFFS.writeFile("ui.schema.json", data)
console.log("ui.schema.json fetched!")
const { ui_defs } = await fetchfile("resource_pack/ui/_ui_defs.json")
await PFFS.writeFile("ui_defs.json", JSON.stringify(ui_defs, null, 2))
console.log("ui_defs.json fetched!")
let fetched = 0
await Promise.all(
ui_defs.map(async (path: string) => {
const data = await fetchfile("resource_pack/" + path)
await PFFS.writeFile(path, JSON.stringify(data, null, 2))
console.log(`[${++fetched}/${ui_defs.length}] ${path}`)
}),
)
}
main()