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.
24 lines
1.1 KiB
JavaScript
24 lines
1.1 KiB
JavaScript
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
|
|
} |