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.
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
const installer = require("./src/installer")
|
||||
const checker = require("./src/checker")
|
||||
const sysinfo = require("./src/systeminfo")
|
||||
const web = require("./src/web")
|
||||
|
||||
async function isJavaInstalledAndCompatibleFor(mcVersion, customExec = "java") {
|
||||
const mcVersionManifestUrl = await web.getVersionManifest(mcVersion)
|
||||
const requiredJRE = await web.getRequiredJREFor(mcVersionManifestUrl)
|
||||
const checkJRECommand = checker.getJavaVersionOutput(customExec)
|
||||
const isJavaCompatible = checker.isJavaCompatible(checkJRECommand, requiredJRE.majorVersion)
|
||||
return isJavaCompatible
|
||||
}
|
||||
|
||||
async function installJava(component, majorVersion, customInstallPath = null) {
|
||||
const installationPath = await sysinfo.determineInstallationPath(component, majorVersion, customInstallPath)
|
||||
const requiredComponentDetails = await web.getJREComponentDetails(component, sysinfo.getPlatformKey())
|
||||
const requiredComponentManifest = await web.getJREComponentManifest(requiredComponentDetails[0].manifest.url)
|
||||
return await installer.downloadJavaComponent(requiredComponentManifest, installationPath)
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
isJavaInstalledAndCompatibleFor,
|
||||
installJava
|
||||
}
|
||||
Reference in New Issue
Block a user