mirror of
https://github.com/mmvanheusden/SteamDepotDownloaderGUI.git
synced 2026-02-05 06:01:17 +01:00
Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
35b8c476db | ||
|
|
d7260d8976 | ||
|
|
a7ce59fcd4 | ||
|
|
cc781b33d2 | ||
|
|
54a5027f8a | ||
|
|
1053c7b114 | ||
|
|
510d80c58a | ||
|
|
894197e75e | ||
|
|
eca48e2495 | ||
|
|
2bd8dc7c41 | ||
|
|
b8eb915788 | ||
|
|
5c0fe6fc9a |
@@ -5,7 +5,7 @@
|
||||
<img alt="GitHub all releases" src="https://img.shields.io/github/downloads/mmvanheusden/SteamDepotDownloaderGUI/total?color=orange&label=downloads">
|
||||
<img alt="GitHub last commit" src="https://img.shields.io/github/last-commit/mmvanheusden/SteamDepotDownloaderGUI?color=crimson">
|
||||
<img alt="Visitor Count" src="https://visitor-badge.glitch.me/badge?page_id=mmvanheusden.SteamDepotDownloaderGUI">
|
||||
<a href="https://www.codefactor.io/repository/github/mmvanheusden/steamdepotdownloadergui/overview/rewrite"><img src="https://www.codefactor.io/repository/github/mmvanheusden/steamdepotdownloadergui/badge/rewrite" alt="CodeFactor" /></a>
|
||||
<a href="https://www.codefactor.io/repository/github/mmvanheusden/steamdepotdownloadergui/overview/rewrite"><img src="https://www.codefactor.io/repository/github/mmvanheusden/steamdepotdownloadergui/badge/master" alt="CodeFactor" /></a>
|
||||
</p>
|
||||
<p align="center">
|
||||
<img alt="Screenshot" src="screenshot.png" />
|
||||
@@ -23,7 +23,7 @@ from [GitHub](https://github.com/mmvanheusden/SteamDepotDownloaderGUI/releases/l
|
||||
|
||||
Enter everything you normally would in the SteamDepotDownloader console.
|
||||
|
||||
There is a video tutorial available [here](https://www.youtube.com/watch?v=dQw4w9WgXcQ).
|
||||
There is a video tutorial available [here](https://www.youtube.com/watch?v=dQw4w9WgXcQ). (not done yet)
|
||||
|
||||
## Contributing
|
||||
|
||||
@@ -34,4 +34,4 @@ Pull requests are welcome. For major changes, please open an issue first to disc
|
||||
|
||||
Please make sure to keep code consistent and cross-platform compatible.
|
||||
|
||||

|
||||

|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
const {checkDotnet, download, createCommand, runCommand, removeDir, removeFile, unzip} = require("./utils")
|
||||
const {
|
||||
checkDotnet,
|
||||
download,
|
||||
createCommand,
|
||||
runCommand,
|
||||
removeDir,
|
||||
removeFile,
|
||||
unzip
|
||||
} = require("./utils")
|
||||
|
||||
function submitForm() {
|
||||
checkDotnet().then(async function (result) {
|
||||
@@ -6,6 +14,7 @@ function submitForm() {
|
||||
console.error("dotnet not found in PATH")
|
||||
document.getElementById("dotnetwarning").hidden = false
|
||||
} else {
|
||||
|
||||
console.info("dotnet found in PATH")
|
||||
|
||||
// Remove the old depotdownloader directory
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta content="width=device-width, initial-scale=1" name="viewport"/>
|
||||
<link href="https://unpkg.com/@primer/css@20.2.4/dist/primer.css" rel="stylesheet"/>
|
||||
<link href="https://unpkg.com/@primer/css@20.4.1/dist/primer.css" rel="stylesheet"/>
|
||||
<title>SteamDepotDownloaderGUI</title>
|
||||
</head>
|
||||
<body>
|
||||
@@ -79,7 +79,7 @@
|
||||
<label for="osdropdown">Operating system</label>
|
||||
</div>
|
||||
<div class="form-group-body">
|
||||
<select aria-label="Preference" class="form-select" id="osdropdown">
|
||||
<select aria-label="Preference" class="form-select width-full" id="osdropdown">
|
||||
<option disabled>Choose your OS</option>
|
||||
<option>Windows</option>
|
||||
<option disabled>macOS (NOT YET IMPLEMENTED)</option>
|
||||
|
||||
937
package-lock.json
generated
937
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -1,13 +1,16 @@
|
||||
{
|
||||
"name": "steamdepotdownloadergui",
|
||||
"version": "2.0.0",
|
||||
"version": "2.0.3",
|
||||
"description": "DepotDownloader Electron frontend",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"start": "electron .",
|
||||
"build": "electron-builder -c electron-builder.yml -wl -p never",
|
||||
"buildall": "electron-builder -c electron-builder.yml -mwl -p never"
|
||||
"buildall": "electron-builder -c electron-builder.yml -mwl -p never",
|
||||
"buildlinux": "electron-builder -c electron-builder.yml -l -p never",
|
||||
"buildwin": "electron-builder -c electron-builder.yml -w -p never",
|
||||
"buildmacos": "electron-builder -c electron-builder.yml -m -p never"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
130
utils.js
130
utils.js
@@ -32,19 +32,24 @@ function checkDotnet() {
|
||||
/**
|
||||
* Download a file from a url, saving it to the current directory (__dirname)
|
||||
* @param url The url to download from
|
||||
* @returns {Promise<unknown>} A promise that resolves when the download is finished
|
||||
* @returns {Promise<unknown>} A promise that resolves when the download is finished, or rejects if something fails
|
||||
*/
|
||||
function download(url) {
|
||||
return new Promise((resolve) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const {https} = require("follow-redirects")
|
||||
const fs = require("fs")
|
||||
const file = fs.createWriteStream(url.split("/").pop().toString())
|
||||
const path = require("path")
|
||||
const file = fs.createWriteStream(platformpath() + path.sep + url.split("/").pop())
|
||||
https.get(url, function (response) {
|
||||
response.pipe(file)
|
||||
file.on("finish", function () {
|
||||
file.close()
|
||||
resolve()
|
||||
})
|
||||
file.on("error", function (error) {
|
||||
console.error(error)
|
||||
reject(error)
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -52,16 +57,17 @@ function download(url) {
|
||||
/**
|
||||
* Removes a file from the current directory
|
||||
* @param file The filename to remove
|
||||
* @returns {Promise<unknown>} A promise that resolves when the file is removed (or fails)
|
||||
* @returns {Promise<unknown>} A promise that resolves when the file is removed, or rejects if something fails
|
||||
*/
|
||||
function removeFile(file) {
|
||||
return new Promise((resolve) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const fs = require("fs")
|
||||
fs.unlink(file, function (err) {
|
||||
if (err) {
|
||||
console.error(err)
|
||||
}
|
||||
resolve()
|
||||
const path = require("path")
|
||||
fs.unlink(platformpath() + path.sep + file, function (error) {
|
||||
if (error) {
|
||||
reject(error)
|
||||
console.error(error)
|
||||
} else resolve()
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -69,16 +75,17 @@ function removeFile(file) {
|
||||
/**
|
||||
* Removes a directory from the current directory
|
||||
* @param dir The directory to remove
|
||||
* @returns {Promise<unknown>} A promise that resolves when the directory is removed (or fails)
|
||||
* @returns {Promise<unknown>} A promise that resolves when the directory is removed, or rejects if something fails
|
||||
*/
|
||||
function removeDir(dir) {
|
||||
return new Promise((resolve) => {
|
||||
function removeDir(dir,) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const fs = require("fs")
|
||||
fs.rm(dir, {recursive: true, force: true}, function (err) {
|
||||
if (err) {
|
||||
console.error(err)
|
||||
}
|
||||
resolve()
|
||||
const path = require("path")
|
||||
fs.rm(platformpath() + path.sep + dir, {recursive: true, force: true}, function (error) {
|
||||
if (error) {
|
||||
reject(error)
|
||||
console.error(error)
|
||||
} else resolve()
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -87,45 +94,41 @@ function removeDir(dir) {
|
||||
* Unzip a file to the current directory
|
||||
* @param file The file to unzip, preferably a .zip file
|
||||
* @param target The target directory to unzip to
|
||||
* @returns {Promise<unknown>} A promise that resolves when the unzip is complete (or fails)
|
||||
* @returns {Promise<unknown>} A promise that resolves when the unzip is complete, or rejects if something fails
|
||||
*/
|
||||
function unzip(file, target) {
|
||||
const {exec} = require("child_process")
|
||||
return new Promise((resolve) => {
|
||||
const path = require("path")
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
if (process.platform.toString().includes("win")) {
|
||||
const command = "powershell.exe -Command Expand-Archive -Path " + __dirname + "/" + file + " -Destination " + target
|
||||
exec(command, function (error, stdout, stderr) {
|
||||
const command = "powershell.exe -Command Expand-Archive -Path " + platformpath() + path.sep + file + " -Destination " + platformpath() + path.sep + target
|
||||
exec(command, function (error) {
|
||||
if (error) {
|
||||
console.error("Unzipping failed with error: " + error)
|
||||
}
|
||||
console.debug(stdout)
|
||||
if (stderr) {
|
||||
console.error(stderr)
|
||||
}
|
||||
resolve()
|
||||
reject(error)
|
||||
console.error(error)
|
||||
} else resolve()
|
||||
})
|
||||
} else {
|
||||
const command = "unzip -o " + file + " -d ./" + target + "/"
|
||||
exec(command, function (error, stdout, stderr) {
|
||||
exec(command, function (error) {
|
||||
if (error) {
|
||||
console.error("Unzipping failed with error: " + error)
|
||||
}
|
||||
console.debug(stdout)
|
||||
if (stderr) {
|
||||
console.error(stderr)
|
||||
}
|
||||
resolve()
|
||||
reject(error)
|
||||
console.error(error)
|
||||
} else resolve()
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a command based on the operating system/terminal being selected and the form values
|
||||
* @returns {string} The final command to run
|
||||
*/
|
||||
const createCommand = () => {
|
||||
// Import path so \ can be put in a string
|
||||
const path = require("path")
|
||||
|
||||
// The values inputted by the user in the form
|
||||
let username = document.forms["theform"]["username"].value
|
||||
let password = document.forms["theform"]["password"].value
|
||||
@@ -134,21 +137,23 @@ const createCommand = () => {
|
||||
let manifestid = document.forms["theform"]["manifestid"].value
|
||||
let osdropdown = document.getElementById("osdropdown")
|
||||
|
||||
const finalPath = platformpath() + path.sep + "games" + path.sep + appid
|
||||
|
||||
// The final command to run, returned by this function
|
||||
if (osdropdown.options[osdropdown.selectedIndex].text.includes("Gnome")) {
|
||||
return `gnome-terminal -e 'bash -c "dotnet ./depotdownloader/DepotDownloader.dll -username ${username} -password ${password} -app ${appid} -depot ${depotid} -manifest ${manifestid} -dir ./games/${appid}/ -max-servers 50 -max-downloads 16";bash'`
|
||||
return `gnome-terminal -e 'bash -c "dotnet ./depotdownloader/DepotDownloader.dll -username ${username} -password ${password} -app ${appid} -depot ${depotid} -manifest ${manifestid} -dir ${finalPath}/ -max-servers 50 -max-downloads 16";bash'`
|
||||
} else if (osdropdown.options[osdropdown.selectedIndex].text.includes("Windows")) {
|
||||
return `start cmd.exe /k dotnet ./depotdownloader/DepotDownloader.dll -username ${username} -password ${password} -app ${appid} -depot ${depotid} -manifest ${manifestid} -dir ./games/${appid}/ -max-servers 50 -max-downloads 16`
|
||||
return `start cmd.exe /k dotnet ${platformpath()}${path.sep}depotdownloader${path.sep}DepotDownloader.dll -username ${username} -password ${password} -app ${appid} -depot ${depotid} -manifest ${manifestid} -dir ${finalPath}/ -max-servers 50 -max-downloads 16`
|
||||
} else if (osdropdown.options[osdropdown.selectedIndex].text.includes("macOS")) {
|
||||
return `osascript -c 'tell application "Terminal" to do script 'dotnet ./depotdownloader/DepotDownloader.dll -username ${username} -password ${password} -app ${appid} -depot ${depotid} -manifest ${manifestid} -dir ./games/${appid}/ -max-servers 50 -max-downloads 16'`
|
||||
return `osascript -c 'tell application "Terminal" to do script 'dotnet ./depotdownloader/DepotDownloader.dll -username ${username} -password ${password} -app ${appid} -depot ${depotid} -manifest ${manifestid} -dir ${finalPath}/ -max-servers 50 -max-downloads 16'`
|
||||
} else if (osdropdown.options[osdropdown.selectedIndex].text.includes("Konsole")) {
|
||||
return `konsole --hold -e "dotnet ./depotdownloader/DepotDownloader.dll -username ${username} -password ${password} -app ${appid} -depot ${depotid} -manifest ${manifestid} -dir ./games/${appid}/ -max-servers 50 -max-downloads 16"`
|
||||
return `konsole --hold -e "dotnet ./depotdownloader/DepotDownloader.dll -username ${username} -password ${password} -app ${appid} -depot ${depotid} -manifest ${manifestid} -dir ${finalPath}/ -max-servers 50 -max-downloads 16"`
|
||||
} else if (osdropdown.options[osdropdown.selectedIndex].text.includes("Xfce")) {
|
||||
return `xfce4-terminal -H -e "dotnet ./depotdownloader/DepotDownloader.dll -username ${username} -password ${password} -app ${appid} -depot ${depotid} -manifest ${manifestid} -dir ./games/${appid}/ -max-servers 50 -max-downloads 16"`
|
||||
return `xfce4-terminal -H -e "dotnet ./depotdownloader/DepotDownloader.dll -username ${username} -password ${password} -app ${appid} -depot ${depotid} -manifest ${manifestid} -dir ${finalPath}/ -max-servers 50 -max-downloads 16"`
|
||||
} else if (osdropdown.options[osdropdown.selectedIndex].text.includes("Terminator")) {
|
||||
return `terminator -e 'bash -c "dotnet ./depotdownloader/DepotDownloader.dll -username ${username} -password ${password} -app ${appid} -depot ${depotid} -manifest ${manifestid} -dir ./games/${appid}/ -max-servers 50 -max-downloads 16";bash'`
|
||||
return `terminator -e 'bash -c "dotnet ./depotdownloader/DepotDownloader.dll -username ${username} -password ${password} -app ${appid} -depot ${depotid} -manifest ${manifestid} -dir ${finalPath}/ -max-servers 50 -max-downloads 16";bash'`
|
||||
} else if (osdropdown.options[osdropdown.selectedIndex].text.includes("Print command")) {
|
||||
console.log(`COPY-PASTE THE FOLLOWING INTO YOUR TERMINAL OF CHOICE:\n\ndotnet ${__dirname}/depotdownloader/DepotDownloader.dll -username ${username} -password ${password} -app ${appid} -depot ${depotid} -manifest ${manifestid} -dir ./games/${appid}/ -max-servers 50 -max-downloads 16`)
|
||||
console.log(`COPY-PASTE THE FOLLOWING INTO YOUR TERMINAL OF CHOICE:\n\ndotnet ${platformpath()}/depotdownloader/DepotDownloader.dll -username ${username} -password ${password} -app ${appid} -depot ${depotid} -manifest ${manifestid} -dir ${finalPath}/ -max-servers 50 -max-downloads 16`)
|
||||
return "echo hello"
|
||||
}
|
||||
}
|
||||
@@ -156,21 +161,36 @@ const createCommand = () => {
|
||||
/**
|
||||
* Runs a command in a separate process, printing errors and debugging info to the console
|
||||
* @param command The command to run
|
||||
* @returns {Promise<unknown>} A promise that resolves when the command is complete (or fails)
|
||||
* @returns {Promise<unknown>} A promise that resolves when the command is complete or rejects if something fails
|
||||
*/
|
||||
function runCommand(command) {
|
||||
return new Promise((resolve) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const {exec} = require("child_process")
|
||||
exec(command, function (error, stdout, stderr) {
|
||||
exec(command, function (error) {
|
||||
if (error) {
|
||||
console.debug("Command failed with error: " + error)
|
||||
}
|
||||
if (stderr) {
|
||||
console.error(stderr)
|
||||
}
|
||||
resolve()
|
||||
const msg = "Running command failed with error:\n" + error
|
||||
reject(msg)
|
||||
} else resolve()
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = {checkDotnet, download, createCommand, runCommand, removeDir, removeFile, unzip}
|
||||
/**
|
||||
* Returns the path where the actual program is being run from, depending on the operating system.
|
||||
* Because __dirname is inconsistent across operating systems, this function is used to get the correct path
|
||||
* @returns {string} The absolute path
|
||||
*/
|
||||
const platformpath = () => {
|
||||
if ((__dirname.includes("AppData") || __dirname.includes("Temp")) && process.platform.toString().includes("win")) {
|
||||
// Windows portable exe
|
||||
return process.env.PORTABLE_EXECUTABLE_DIR
|
||||
} else if (__dirname.includes("/tmp/") && process.platform.toString().includes("linux")) {
|
||||
// Linux AppImage
|
||||
return process.cwd()
|
||||
} else {
|
||||
// .zip binary
|
||||
return __dirname
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {checkDotnet, download, createCommand, runCommand, removeDir, removeFile, unzip, platformpath}
|
||||
Reference in New Issue
Block a user