12 Commits

Author SHA1 Message Date
mmvanheusden
35b8c476db Release minor version 2.0.3 2022-08-07 08:52:53 +02:00
mmvanheusden
d7260d8976 Cleanup promise utils 2022-08-07 08:52:10 +02:00
mmvanheusden
a7ce59fcd4 Simplify cross-platform compatibility and improve Linux support.Initial cleanup of promise utils 2022-08-07 08:18:00 +02:00
mmvanheusden
cc781b33d2 Make the OS dropdown full-with for improved consistency 2022-08-07 08:15:57 +02:00
mmvanheusden
54a5027f8a Update dependencies 2022-08-06 21:36:08 +02:00
mmvanheusden
1053c7b114 minor fix 2022-07-22 20:48:37 +02:00
mmvanheusden
510d80c58a 2.0.2 2022-07-22 20:20:30 +02:00
mmvanheusden
894197e75e Fix the working directory problem for every platform 2022-07-22 20:18:35 +02:00
mmvanheusden
eca48e2495 Add a notice thing to the youtube tuorial 2022-07-21 09:47:30 +02:00
mmvanheusden
2bd8dc7c41 2.0.1 2022-07-09 09:30:23 +02:00
mmvanheusden
b8eb915788 Add a hacky fix for Windows portable builds
Signed-off-by: mmvanheusden <50550545+mmvanheusden@users.noreply.github.com>
2022-07-09 09:26:40 +02:00
mmvanheusden
5c0fe6fc9a fix badge 2022-07-08 22:05:54 +02:00
6 changed files with 860 additions and 235 deletions

View File

@@ -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.
![License](license.png)
![License](license.png)

View File

@@ -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

View File

@@ -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

File diff suppressed because it is too large Load Diff

View File

@@ -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
View File

@@ -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}