diff --git a/index.js b/index.js index 8d8016b..d145c65 100644 --- a/index.js +++ b/index.js @@ -11,8 +11,11 @@ async function isJavaInstalledAndCompatibleFor(mcVersion, customExec = "java") { return isJavaCompatible } -async function installJava(component, majorVersion, customInstallPath = null) { - const installationPath = await sysinfo.determineInstallationPath(component, majorVersion, customInstallPath) +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) diff --git a/package-lock.json b/package-lock.json index 3b8c62c..4dd1e03 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,11 @@ { - "name": "minecraft-java-manager", + "name": "@azures04/minecraft-java-manager", "version": "0.0.1", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "minecraft-java-manager", + "name": "@azures04/minecraft-java-manager", "version": "0.0.1", "license": "MIT" } diff --git a/package.json b/package.json index 6ffbd18..ec97b53 100644 --- a/package.json +++ b/package.json @@ -1,17 +1,21 @@ { - "name": "minecraft-java-manager", + "name": "@azures04/minecraft-java-manager", "version": "0.0.1", "description": "Node module to check if java is installed and install it", + "keywords": [ + "java", + "mclauncher", + "mc-launcher", + "minecraft-launcher", + "javainstaller", + "java-installer" + ], "repository": { "type": "git", "url": "https://gitea.azures.fr/azures04/minecraft-java-manager" }, "license": "MIT", - "author": { - "name": "azures04", - "url": "https://gitea.azures.fr", - "email": "azures04@azures.fr" - }, + "author": "azures04 (https://gitea.azures.fr)", "type": "commonjs", "main": "index.js", "scripts": { diff --git a/src/installer.js b/src/installer.js index e3c77aa..ad25445 100644 --- a/src/installer.js +++ b/src/installer.js @@ -239,7 +239,7 @@ async function downloadJavaComponent(manifest, outputRoot, options) { }) } - return emitter + return { events: emitter, path: outputRoot } } module.exports = { diff --git a/src/systeminfo.js b/src/systeminfo.js index d16be11..7f5d2c5 100644 --- a/src/systeminfo.js +++ b/src/systeminfo.js @@ -49,7 +49,7 @@ async function determineInstallationPath(component, majorVersion, customInstallP } switch (process.platform) { case "win32": - return path.join("Program files", "Java", component, majorVersion) + return path.join("C:", "Program files", "Java", component, majorVersion.toString()) case "linux": return path.join("opt", "java", component, majorVersion) case "macos": diff --git a/test.js b/test.js index 370a65a..d581219 100644 --- a/test.js +++ b/test.js @@ -1,7 +1,7 @@ const lib = require("./index") async function main() { - await lib.installJava("jre-legacy", 8, "./java") + await lib.installJava("1.7.10") } main() \ No newline at end of file