mirror of
https://github.com/mmvanheusden/SteamDepotDownloaderGUI.git
synced 2026-02-04 05:31:19 +01:00
cleanup code
This commit is contained in:
20
.eslintrc.yml
Normal file
20
.eslintrc.yml
Normal file
@@ -0,0 +1,20 @@
|
||||
env:
|
||||
browser: true
|
||||
es2021: true
|
||||
extends: eslint:recommended
|
||||
parserOptions:
|
||||
ecmaVersion: latest
|
||||
sourceType: module
|
||||
rules:
|
||||
indent:
|
||||
- error
|
||||
- tab
|
||||
linebreak-style:
|
||||
- error
|
||||
- unix
|
||||
quotes:
|
||||
- error
|
||||
- double
|
||||
semi:
|
||||
- error
|
||||
- never
|
||||
128
index.html
128
index.html
@@ -2,81 +2,81 @@
|
||||
<!-- automatic dark mode :) -->
|
||||
<html data-color-mode="auto" data-dark-theme="dark" data-light-theme="light" lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta content="width=device-width, initial-scale=1" name="viewport"/>
|
||||
<link href="https://unpkg.com/@primer/css@^20.2.3/dist/primer.css" rel="stylesheet"/>
|
||||
<title>SteamDepotDownloaderGUI</title>
|
||||
<meta charset="UTF-8">
|
||||
<meta content="width=device-width, initial-scale=1" name="viewport"/>
|
||||
<link href="https://unpkg.com/@primer/css@^20.2.3/dist/primer.css" rel="stylesheet"/>
|
||||
<title>SteamDepotDownloaderGUI</title>
|
||||
</head>
|
||||
<body>
|
||||
<script src="utils.js"></script>
|
||||
<div class="flash flash-error mx-4 mt-2 mb-2" hidden id="alert">
|
||||
<svg class="octicon" height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M8 1.5a6.5 6.5 0 100 13 6.5 6.5 0 000-13zM0 8a8 8 0 1116 0A8 8 0 010 8zm6.5-.25A.75.75 0 017.25 7h1a.75.75 0 01.75.75v2.75h.25a.75.75 0 010 1.5h-2a.75.75 0 010-1.5h.25v-2h-.25a.75.75 0 01-.75-.75zM8 6a1 1 0 100-2 1 1 0 000 2z"
|
||||
fill-rule="evenodd"></path>
|
||||
</svg>
|
||||
<code>dotnet</code> was not found.
|
||||
<button class="btn btn-sm flash-action" hidden id="alertbtn" onclick="submitDotnet()" type="submit">
|
||||
<svg class="octicon" height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M7.47 10.78a.75.75 0 001.06 0l3.75-3.75a.75.75 0 00-1.06-1.06L8.75 8.44V1.75a.75.75 0 00-1.5
|
||||
<svg class="octicon" height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M8 1.5a6.5 6.5 0 100 13 6.5 6.5 0 000-13zM0 8a8 8 0 1116 0A8 8 0 010 8zm6.5-.25A.75.75 0 017.25 7h1a.75.75 0 01.75.75v2.75h.25a.75.75 0 010 1.5h-2a.75.75 0 010-1.5h.25v-2h-.25a.75.75 0 01-.75-.75zM8 6a1 1 0 100-2 1 1 0 000 2z"
|
||||
fill-rule="evenodd"></path>
|
||||
</svg>
|
||||
<code>dotnet</code> was not found.
|
||||
<button class="btn btn-sm flash-action" hidden id="alertbtn" onclick="submitDotnet()" type="submit">
|
||||
<svg class="octicon" height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M7.47 10.78a.75.75 0 001.06 0l3.75-3.75a.75.75 0 00-1.06-1.06L8.75 8.44V1.75a.75.75 0 00-1.5
|
||||
0v6.69L4.78 5.97a.75.75 0 00-1.06 1.06l3.75 3.75zM3.75 13a.75.75 0 000 1.5h8.5a.75.75 0 000-1.5h-8.5z"
|
||||
fill-rule="evenodd"></path>
|
||||
</svg>
|
||||
Download<br>
|
||||
</button>
|
||||
fill-rule="evenodd"></path>
|
||||
</svg>
|
||||
Download<br>
|
||||
</button>
|
||||
</div>
|
||||
<div class="h2-mktg" style="text-align: center;">Steam Depot Downloader</div>
|
||||
<div class="h2-mktg mx-3">Steam Depot Downloader</div>
|
||||
<form id="theform">
|
||||
<div class="form-group mx-3">
|
||||
<div class="form-group-header">
|
||||
<label for="username">Username</label>
|
||||
</div>
|
||||
<div class="form-group-body">
|
||||
<input aria-label="Repository description" class="form-control" id="username" placeholder="Username"
|
||||
type="text"/>
|
||||
</div>
|
||||
<br>
|
||||
<div class="form-group-header">
|
||||
<label for="password">Password</label>
|
||||
</div>
|
||||
<div class="form-group-body">
|
||||
<input aria-label="Repository description" class="form-control" id="password" placeholder="Password"
|
||||
type="password"/>
|
||||
</div>
|
||||
<br>
|
||||
<div class="form-group-header">
|
||||
<label for="appid">App ID</label>
|
||||
</div>
|
||||
<div class="form-group-body">
|
||||
<input aria-label="Repository description" class="form-control" id="appid" placeholder="App ID"
|
||||
type="number"/>
|
||||
</div>
|
||||
<br>
|
||||
<div class="form-group-header">
|
||||
<label for="depotid">Depot ID</label>
|
||||
</div>
|
||||
<div class="form-group-body">
|
||||
<input aria-label="Repository description" class="form-control" id="depotid" placeholder="Depot ID"
|
||||
type="number"/>
|
||||
</div>
|
||||
<br>
|
||||
<div class="form-group-header">
|
||||
<label for="manifestid">Manifest ID</label>
|
||||
</div>
|
||||
<div class="form-group-body">
|
||||
<input aria-label="Repository description" class="form-control" id="manifestid" placeholder="Manifest ID"
|
||||
type="number"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group mx-3">
|
||||
<div class="form-group-header">
|
||||
<label for="username">Username</label>
|
||||
</div>
|
||||
<div class="form-group-body">
|
||||
<input aria-label="Repository description" class="form-control" id="username" placeholder="Username"
|
||||
type="text"/>
|
||||
</div>
|
||||
<br>
|
||||
<div class="form-group-header">
|
||||
<label for="password">Password</label>
|
||||
</div>
|
||||
<div class="form-group-body">
|
||||
<input aria-label="Repository description" class="form-control" id="password" placeholder="Password"
|
||||
type="password"/>
|
||||
</div>
|
||||
<br>
|
||||
<div class="form-group-header">
|
||||
<label for="appid">App ID</label>
|
||||
</div>
|
||||
<div class="form-group-body">
|
||||
<input aria-label="Repository description" class="form-control" id="appid" placeholder="App ID"
|
||||
type="number"/>
|
||||
</div>
|
||||
<br>
|
||||
<div class="form-group-header">
|
||||
<label for="depotid">Depot ID</label>
|
||||
</div>
|
||||
<div class="form-group-body">
|
||||
<input aria-label="Repository description" class="form-control" id="depotid" placeholder="Depot ID"
|
||||
type="number"/>
|
||||
</div>
|
||||
<br>
|
||||
<div class="form-group-header">
|
||||
<label for="manifestid">Manifest ID</label>
|
||||
</div>
|
||||
<div class="form-group-body">
|
||||
<input aria-label="Repository description" class="form-control" id="manifestid" placeholder="Manifest ID"
|
||||
type="number"/>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<button class="btn btn-primary btn-block col-11 p-2 mx-auto position-absolute bottom-3 left-3" id="download"
|
||||
onclick="submitForm()">
|
||||
Download
|
||||
<svg class="octicon" height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M7.47 10.78a.75.75 0 001.06 0l3.75-3.75a.75.75 0 00-1.06-1.06L8.75 8.44V1.75a.75.75 0 00-1.5
|
||||
onclick="submitForm()">
|
||||
Download
|
||||
<svg class="octicon" height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M7.47 10.78a.75.75 0 001.06 0l3.75-3.75a.75.75 0 00-1.06-1.06L8.75 8.44V1.75a.75.75 0 00-1.5
|
||||
0v6.69L4.78 5.97a.75.75 0 00-1.06 1.06l3.75 3.75zM3.75 13a.75.75 0 000 1.5h8.5a.75.75 0 000-1.5h-8.5z"
|
||||
fill-rule="evenodd"></path>
|
||||
</svg>
|
||||
fill-rule="evenodd"></path>
|
||||
</svg>
|
||||
</button>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
51
main.js
51
main.js
@@ -1,41 +1,42 @@
|
||||
const {app, BrowserWindow} = require('electron')
|
||||
const {app, BrowserWindow} = require("electron")
|
||||
|
||||
const createWindow = () => {
|
||||
// Create the browser window.
|
||||
const mainWindow = new BrowserWindow({
|
||||
autoHideMenuBar: true,
|
||||
//resizable: false,
|
||||
width: 425,
|
||||
height: 575,
|
||||
maximizable: false, // lol this does not work on kde plasma
|
||||
webPreferences: {
|
||||
nodeIntegration: true,
|
||||
contextIsolation: false
|
||||
}
|
||||
})
|
||||
// Create the browser window.
|
||||
const mainWindow = new BrowserWindow({
|
||||
autoHideMenuBar: true,
|
||||
//resizable: false,
|
||||
width: 425,
|
||||
height: 575,
|
||||
maximizable: false, // lol this does not work on kde plasma
|
||||
webPreferences: {
|
||||
nodeIntegration: true,
|
||||
contextIsolation: false,
|
||||
"disableBlinkFeatures ": "Auxclick"
|
||||
}
|
||||
})
|
||||
|
||||
// and load the index.html of the app.
|
||||
mainWindow.loadFile('index.html')
|
||||
//TODO: don't do this in the release lol
|
||||
mainWindow.webContents.openDevTools({mode: 'detach'})
|
||||
// and load the index.html of the app.
|
||||
mainWindow.loadFile("index.html")
|
||||
//TODO: don't do this in the release lol
|
||||
mainWindow.webContents.openDevTools({mode: "detach"})
|
||||
}
|
||||
|
||||
// This method will be called when Electron has finished
|
||||
// initialization and is ready to create browser windows.
|
||||
// Some APIs can only be used after this event occurs.
|
||||
app.whenReady().then(() => {
|
||||
createWindow()
|
||||
createWindow()
|
||||
|
||||
app.on('activate', () => {
|
||||
// On macOS it's common to re-create a window in the app when the
|
||||
// dock icon is clicked and there are no other windows open.
|
||||
if (BrowserWindow.getAllWindows().length === 0) createWindow()
|
||||
})
|
||||
app.on("activate", () => {
|
||||
// On macOS it's common to re-create a window in the app when the
|
||||
// dock icon is clicked and there are no other windows open.
|
||||
if (BrowserWindow.getAllWindows().length === 0) createWindow()
|
||||
})
|
||||
})
|
||||
|
||||
// Quit when all windows are closed, except on macOS. There, it's common
|
||||
// for applications and their menu bar to stay active until the user quits
|
||||
// explicitly with Cmd + Q.
|
||||
app.on('window-all-closed', () => {
|
||||
if (process.platform !== 'darwin') app.quit()
|
||||
app.on("window-all-closed", () => {
|
||||
if (process.platform !== "darwin") app.quit()
|
||||
})
|
||||
|
||||
1440
package-lock.json
generated
1440
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -27,7 +27,8 @@
|
||||
},
|
||||
"homepage": "https://github.com/mmvanheusden/SteamDepotDownloaderGUI#readme",
|
||||
"devDependencies": {
|
||||
"electron": "^19.0.6"
|
||||
"electron": "^19.0.6",
|
||||
"eslint": "^8.18.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"follow-redirects": "^1.15.1",
|
||||
|
||||
224
utils.js
224
utils.js
@@ -1,43 +1,42 @@
|
||||
"use strict";
|
||||
"use strict"
|
||||
|
||||
|
||||
function submitDotnet() {
|
||||
const electron = require('electron');
|
||||
const os = require('os');
|
||||
document.getElementById("download").disabled = false
|
||||
document.getElementById('alert').hidden = true
|
||||
document.getElementById('alertbtn').hidden = true
|
||||
if (os.platform().includes("win")) {
|
||||
console.log('Opened .NET download page for ' + os.platform().charAt(0).toUpperCase() + os.platform().slice(1))
|
||||
electron.shell.openExternal('https://dotnet.microsoft.com/en-us/download/dotnet/thank-you/sdk-6.0.301-windows-x64-installer')
|
||||
}
|
||||
if (os.platform().includes("linux")) {
|
||||
console.log('Opened .NET download page for ' + os.platform().charAt(0).toUpperCase() + os.platform().slice(1))
|
||||
electron.shell.openExternal('https://docs.microsoft.com/en-us/dotnet/core/install/linux')
|
||||
}
|
||||
if (os.platform().includes("darwin")) {
|
||||
console.log('Opened .NET download page for' + os.platform())
|
||||
//TODO: apple silicon(ARM64) URL
|
||||
electron.shell.openExternal('https://dotnet.microsoft.com/en-us/download/dotnet/thank-you/sdk-6.0.301-macos-x64-installer')
|
||||
}
|
||||
const electron = require("electron")
|
||||
const os = require("os")
|
||||
document.getElementById("download").disabled = false
|
||||
document.getElementById("alert").hidden = true
|
||||
document.getElementById("alertbtn").hidden = true
|
||||
if (os.platform().includes("win")) {
|
||||
console.log("Opened .NET download page for " + os.platform().charAt(0).toUpperCase() + os.platform().slice(1))
|
||||
electron.shell.openExternal("https://dotnet.microsoft.com/en-us/download/dotnet/thank-you/sdk-6.0.301-windows-x64-installer")
|
||||
}
|
||||
if (os.platform().includes("linux")) {
|
||||
console.log("Opened .NET download page for " + os.platform().charAt(0).toUpperCase() + os.platform().slice(1))
|
||||
electron.shell.openExternal("https://docs.microsoft.com/en-us/dotnet/core/install/linux")
|
||||
}
|
||||
if (os.platform().includes("darwin")) {
|
||||
console.log("Opened .NET download page for" + os.platform())
|
||||
//TODO: apple silicon(ARM64) URL
|
||||
electron.shell.openExternal("https://dotnet.microsoft.com/en-us/download/dotnet/thank-you/sdk-6.0.301-macos-x64-installer")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function submitForm() {
|
||||
const os = require('os');
|
||||
const fs = require('fs');
|
||||
const path = require('path').dirname(__filename);
|
||||
const which = require('which')
|
||||
const {http, https} = require('follow-redirects');
|
||||
const spawn = require('child_process').spawn;
|
||||
|
||||
let username = document.forms["theform"]["username"].value;
|
||||
let password = document.forms["theform"]["password"].value;
|
||||
let appid = document.forms["theform"]["appid"].value;
|
||||
let depotid = document.forms["theform"]["depotid"].value;
|
||||
let manifestid = document.forms["theform"]["manifestid"].value;
|
||||
console.debug(
|
||||
"DEBUG INFO\n"
|
||||
const os = require("os")
|
||||
const fs = require("fs")
|
||||
const path = require("path").dirname(__filename)
|
||||
const which = require("which")
|
||||
const {http, https} = require("follow-redirects")
|
||||
const spawn = require("child_process").spawn
|
||||
let username = document.forms["theform"]["username"].value
|
||||
let password = document.forms["theform"]["password"].value
|
||||
let appid = document.forms["theform"]["appid"].value
|
||||
let depotid = document.forms["theform"]["depotid"].value
|
||||
let manifestid = document.forms["theform"]["manifestid"].value
|
||||
console.debug(
|
||||
"DEBUG INFO\n"
|
||||
+ "Username: " + username
|
||||
+ "\nPassword: no"
|
||||
+ "\nApp ID: " + appid +
|
||||
@@ -45,85 +44,88 @@ function submitForm() {
|
||||
+ "\nManifest ID: " + manifestid
|
||||
+ "\nPlatform: " + os.platform()
|
||||
+ "\nPath: " + path
|
||||
);
|
||||
if (os.platform().includes("win")) {
|
||||
console.log("Using Windows!")
|
||||
//TODO: windows compat lol
|
||||
}
|
||||
if (os.platform().includes("linux")) {
|
||||
console.log("Using Linux")
|
||||
which('dotnet', function (er) {
|
||||
// er is returned if no "node" is found on the PATH
|
||||
// if it is found, then the absolute path to the exec is returned
|
||||
if (er) {
|
||||
console.warn("dotnet not found(in system path)")
|
||||
document.getElementById('alert').hidden = false
|
||||
document.getElementById('alertbtn').hidden = false
|
||||
document.getElementById("download").disabled = true;
|
||||
)
|
||||
if (os.platform().includes("win")) {
|
||||
console.log("Using Windows!")
|
||||
//TODO: windows compat lol
|
||||
}
|
||||
if (os.platform().includes("linux")) {
|
||||
console.log("Using Linux")
|
||||
which("dotnet", function (er) {
|
||||
// er is returned if no "node" is found on the PATH
|
||||
// if it is found, then the absolute path to the exec is returned
|
||||
if (er) {
|
||||
console.warn("dotnet not found(in system path)")
|
||||
document.getElementById("alert").hidden = false
|
||||
document.getElementById("alertbtn").hidden = false
|
||||
document.getElementById("download").disabled = true
|
||||
|
||||
} else {
|
||||
console.log("Found dotnet in system path")
|
||||
try {
|
||||
// first check if directory already exists
|
||||
if (!fs.existsSync("./depotdownloader")) {
|
||||
fs.mkdirSync("./depotdownloader");
|
||||
console.log("Directory is created.");
|
||||
} else {
|
||||
console.log("Directory already exists.");
|
||||
}
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
}
|
||||
const file = fs.createWriteStream("./depotdownloader/depotdownloader.zip");
|
||||
const request = https.get("https://github.com/SteamRE/DepotDownloader/releases/download/DepotDownloader_2.4.6/depotdownloader-2.4.6.zip", function (response) {
|
||||
response.pipe(file);
|
||||
console.log("Downloaded DepotDownloader binary zip")
|
||||
});
|
||||
file.on('finish', function () {
|
||||
file.close();
|
||||
const {exec} = require('child_process');
|
||||
console.log("Extracting DepotDownloader binary")
|
||||
} else {
|
||||
console.log("Found dotnet in system path")
|
||||
try {
|
||||
// first check if directory already exists
|
||||
if (!fs.existsSync("./depotdownloader")) {
|
||||
fs.mkdirSync("./depotdownloader")
|
||||
console.log("Directory is created.")
|
||||
} else {
|
||||
console.log("Directory already exists.")
|
||||
}
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
}
|
||||
const file = fs.createWriteStream("./depotdownloader/depotdownloader.zip")
|
||||
const request = https.get("https://github.com/SteamRE/DepotDownloader/releases/download/DepotDownloader_2.4.6/depotdownloader-2.4.6.zip", function (response) {
|
||||
response.pipe(file)
|
||||
console.log("Downloaded DepotDownloader binary zip")
|
||||
})
|
||||
file.on("finish", function () {
|
||||
file.close()
|
||||
const {exec} = require("child_process")
|
||||
console.log("Extracting DepotDownloader binary")
|
||||
|
||||
// The following code has delays in between because async io operations won't work well
|
||||
// Cleans up old files (but not the downloaded zip)
|
||||
setTimeout(() => {
|
||||
exec('file ./depotdownloader/* | grep -vi zip | cut -d: -f1 | tr \'\\n\' \'\\0\' | xargs -0 -r rm', (err, stdout, stderr) => {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
return;
|
||||
}
|
||||
console.log(stdout);
|
||||
console.log(stderr);
|
||||
});
|
||||
}, 500)
|
||||
// Unzips downloaded zip
|
||||
setTimeout(() => {
|
||||
exec('unzip -o ./depotdownloader/depotdownloader.zip -d ./depotdownloader/', (err, stdout, stderr) => {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
return;
|
||||
}
|
||||
console.log(stdout);
|
||||
console.log(stderr);
|
||||
});
|
||||
}, 800)
|
||||
// Removes the zip after unzip
|
||||
setTimeout(() => {
|
||||
exec('rm ./depotdownloader/depotdownloader.zip', (err, stdout, stderr) => {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
return;
|
||||
}
|
||||
console.log(stdout);
|
||||
console.log(stderr);
|
||||
});
|
||||
}, 1200)
|
||||
});
|
||||
file.on('finish', function () {
|
||||
console.log("this should happen")
|
||||
})
|
||||
}
|
||||
})
|
||||
// The following code has delays in between because async io operations won't work well
|
||||
// Cleans up old files (but not the downloaded zip)
|
||||
setTimeout(() => {
|
||||
exec("file ./depotdownloader/* | grep -vi zip | cut -d: -f1 | tr '\\n' '\\0' | xargs -0 -r rm", (err, stdout, stderr) => {
|
||||
if (err) {
|
||||
console.error(err)
|
||||
return
|
||||
}
|
||||
if (stderr !== "") {
|
||||
console.log(stderr)
|
||||
}
|
||||
})
|
||||
}, 500)
|
||||
// Unzips downloaded zip
|
||||
setTimeout(() => {
|
||||
exec("unzip -o ./depotdownloader/depotdownloader.zip -d ./depotdownloader/", (err, stdout, stderr) => {
|
||||
if (err) {
|
||||
console.error(err)
|
||||
return
|
||||
}
|
||||
if (stderr !== "") {
|
||||
console.log(stderr)
|
||||
}
|
||||
})
|
||||
}, 800)
|
||||
// Removes the zip after unzip
|
||||
setTimeout(() => {
|
||||
exec("rm ./depotdownloader/depotdownloader.zip", (err, stdout, stderr) => {
|
||||
if (err) {
|
||||
console.error(err)
|
||||
return
|
||||
}
|
||||
if (stderr !== "") {
|
||||
console.log(stderr)
|
||||
}
|
||||
})
|
||||
}, 1200)
|
||||
})
|
||||
file.on("finish", function () {
|
||||
console.log("this should happen")
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user