Files
minecraft-java-manager/src/web.js
T
azures04 e9bc3807ae Add initial minecraft-java-manager scaffold
Initial project scaffold for minecraft-java-manager. Adds package.json and package-lock.json, README update, index.js entrypoint and test.js. Introduces src modules: checker (detects Java version), installer (downloads JRE components with redirects, SHA1 validation, progress/events and concurrency), web (fetches launcher/runtime manifests and component data), systeminfo (platform key and install path resolution) and config (endpoints). Declares dependencies adm-zip and node-downloader-helper.
2026-09-06 03:58:25 +02:00

40 lines
1.2 KiB
JavaScript

const config = require("./config")
async function getVersionManifest(version) {
const mainifestRequest = await fetch(config.launcherManifest.get())
const manifest = await mainifestRequest.json()
const component = manifest.versions.find($version => $version.id == version)
if (!typeof component == "object") {
throw new Error("Unknown version")
}
return component.url
}
async function getRequiredJREFor(versionUrl) {
const mainifestRequest = await fetch(versionUrl)
const manifest = await mainifestRequest.json()
return manifest.javaVersion
}
async function getJREComponentDetails(componentRequested, os) {
const mainifestRequest = await fetch(config.allRuntimes.get())
const manifest = await mainifestRequest.json()
const component = manifest[os][componentRequested]
if (typeof component != "object") {
throw new Error("No JRE Component found")
}
return component
}
async function getJREComponentManifest(url) {
const mainifestRequest = await fetch(url)
const manifest = await mainifestRequest.json()
return manifest
}
module.exports = {
getVersionManifest,
getRequiredJREFor,
getJREComponentDetails,
getJREComponentManifest
}