Commit 7d3e27c2 authored by Senk Ju's avatar Senk Ju

added recursive folder creation + added diagnose function

parent a81e79f8
{
"name": "liquidlauncher",
"version": "1.1.1",
"version": "1.1.2",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
......@@ -7071,7 +7071,7 @@
},
"mkdirp": {
"version": "0.5.1",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
"resolved": "http://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
"integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
"requires": {
"minimist": "0.0.8"
......
......@@ -10,9 +10,9 @@ const { createWriteStream } = require("fs");
const request = require("request");
const progress = require("request-progress");
const mcFolderPath = require("minecraft-folder-path");
const mkdirp = require("mkdirp");
const tmpDir = os.tmpdir();
const homeDir = os.homedir();
const appPath = remote.app.getAppPath();
const platform = os.platform();
......@@ -35,7 +35,6 @@ const inputLoginPassword = _("loginPassword");
const loginOutput = _("loginOutput");
const checkboxStayLoggedIn = _("stayLoggedIn");
const checkboxKeepLauncherRunning = _("keepLauncherRunning");
//const launcherVersionField = _("launcherVersion");
const viewOutdated = _("viewOutdated");
const viewOutdatedCurrentVersion = _("viewOutdatedCurrentVersion");
const viewOutdatedLatestVersion = _("viewOutdatedLatestVersion");
......@@ -61,6 +60,28 @@ function _(el) {
return document.getElementById(el);
}
function diagnose() {
var result = Buffer.from(JSON.stringify({
mcVersion: selectMcVersion[selectMcVersion.selectedIndex].value,
lbVersion: selectLbVersion[selectLbVersion.selectedIndex].value,
jvmPath: inputJvmPath.value,
jvmArguments: inputJvmArguments.value,
mcPath: inputMinecraftPath.value,
system: {
arch: os.arch(),
cpu: os.cpus()[0].model,
platform: os.platform(),
release: os.release(),
memory: os.totalmem(),
username: os.userInfo()
}
})).toString("base64");
console.log("#### Diagnosis Below ####");
console.log(result);
console.log("#### End ####");
}
function setMinecraftPath() {
if (!localStorage.minecraftPath || inputMinecraftPath.value.includes("%appdata%"))
inputMinecraftPath.value = mcFolderPath.replace("minecraft", "LiquidLauncher");
......@@ -220,6 +241,8 @@ function performLogin() {
}
loginOutput.innerHTML = "Logged in as " + data.selectedProfile.name;
console.log(data);
}
});
} else {
......@@ -240,51 +263,50 @@ function performLogin() {
function initializeRun() {
hideRunButton();
//var runtimeFolder = path.join(homeDir, ".LiquidLauncher", "rt");
var runtimeFolder = path.join(inputMinecraftPath.value, "runtime");
if (!fs.existsSync(runtimeFolder) && inputJvmPath.value === "internal") {
try {
fs.mkdirSync(path.join(inputMinecraftPath.value));
} catch (err) { }
mkdirp(inputMinecraftPath.value, (err) => {
if (err) console.error(err);
var filename = platform + ".zip";
var runtimeUrl = "https://ccbluex.github.io/FileCloud/LiquidLauncher/runtime/" + filename;
var filename = platform + ".zip";
var runtimeUrl = "https://ccbluex.github.io/FileCloud/LiquidLauncher/runtime/" + filename;
log('<span class="info">[LiquidLauncher-GUI] Java Runtime not found! Downloading... Please wait.</span><br>');
log('<span class="info">[LiquidLauncher-GUI] Java Runtime not found! Downloading... Please wait.</span><br>');
fs.mkdirSync(runtimeFolder);
fs.mkdirSync(runtimeFolder);
progress(request(runtimeUrl), { throttle: 0 })
.on("progress", state => {
launchProgress.max = state.size.total;
launchProgress.value = state.size.transferred;
progress(request(runtimeUrl), { throttle: 0 })
.on("progress", state => {
launchProgress.max = state.size.total;
launchProgress.value = state.size.transferred;
var total = parseFloat(state.size.total / 1000000).toFixed(2);
var transferred = parseFloat(state.size.transferred / 1000000).toFixed(2);
var total = parseFloat(state.size.total / 1000000).toFixed(2);
var transferred = parseFloat(state.size.transferred / 1000000).toFixed(2);
progressLabel.innerHTML = `Downloading JRE... (${transferred}/${total})`;
})
.on("error", err => console.error(err))
.on("end", () => {
log('<span class="info">[LiquidLauncher-GUI] Finished downloading Java Runtime.</span><br>');
log('<span class="info">[LiquidLauncher-GUI] Extracting...</span><br>');
progressLabel.innerHTML = "Extracting..."
progressLabel.innerHTML = `Downloading JRE... (${transferred}/${total})`;
})
.on("error", err => console.error(err))
.on("end", () => {
log('<span class="info">[LiquidLauncher-GUI] Finished downloading Java Runtime.</span><br>');
log('<span class="info">[LiquidLauncher-GUI] Extracting...</span><br>');
progressLabel.innerHTML = "Extracting..."
extract(path.join(tmpDir, filename), { dir: runtimeFolder }, (err) => {
if (err) console.error(err);
extract(path.join(tmpDir, filename), { dir: runtimeFolder }, (err) => {
if (err) console.error(err);
// Make downloaded JRE executeable
if (platform === "darwin" || platform === "linux")
fs.chmodSync(path.join(runtimeFolder, "bin", "java"), "777")
// Make downloaded JRE executeable
if (platform === "darwin" || platform === "linux")
fs.chmodSync(path.join(runtimeFolder, "bin", "java"), "777")
log('<span class="info">[LiquidLauncher-GUI] Done.</span><br>');
log('<span class="info">[LiquidLauncher-GUI] Done.</span><br>');
runGame();
runGame();
})
})
})
.pipe(createWriteStream(path.join(tmpDir, filename)));
.pipe(createWriteStream(path.join(tmpDir, filename)));
});
} else {
runGame();
}
......@@ -383,7 +405,7 @@ function runGame() {
function openFolder(path) {
try {
shell.openItem(path);
} catch (err) {}
} catch (err) { }
}
https.get("https://ccbluex.github.io/FileCloud/LiquidLauncher/versions.json", (resp) => {
......@@ -410,8 +432,8 @@ https.get("https://ccbluex.github.io/FileCloud/LiquidLauncher/versions.json", (r
updateLbVersions(versions);
});
//Load config (will be moved)
loadConfig(versions);
diagnose();
});
}).on("error", (err) => {
......@@ -462,8 +484,6 @@ window.addEventListener("load", () => {
openMcFolder.addEventListener("click", () => {
openFolder(minecraftPath.value);
});
console.log(platform);
});
// Views
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment