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(mcVersion, customExec = null) { const versionManifest = await web.getVersionManifest(mcVersion) const requiredComponent = await web.getRequiredJREFor(versionManifest) const { component, majorVersion } = requiredComponent const installationPath = await sysinfo.determineInstallationPath(component, majorVersion, customExec) 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 }