mirror of
https://github.com/mmvanheusden/SteamDepotDownloaderGUI.git
synced 2026-02-04 21:51:17 +01:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1053c7b114 | ||
|
|
510d80c58a | ||
|
|
894197e75e | ||
|
|
eca48e2495 |
@@ -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
|
||||
|
||||
|
||||
@@ -5,8 +5,7 @@ const {
|
||||
runCommand,
|
||||
removeDir,
|
||||
removeFile,
|
||||
unzip,
|
||||
platformpath
|
||||
unzip
|
||||
} = require("./utils")
|
||||
|
||||
function submitForm() {
|
||||
@@ -15,19 +14,20 @@ 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
|
||||
await removeDir("depotdownloader", platformpath())
|
||||
await removeDir("depotdownloader")
|
||||
|
||||
// Download the DepotDownloader binary, so it doesn't have to be included in the source code
|
||||
await download("https://github.com/SteamRE/DepotDownloader/releases/download/DepotDownloader_2.4.6/depotdownloader-2.4.6.zip", platformpath())
|
||||
await download("https://github.com/SteamRE/DepotDownloader/releases/download/DepotDownloader_2.4.6/depotdownloader-2.4.6.zip")
|
||||
|
||||
// Unzip the DepotDownloader binary
|
||||
await unzip("depotdownloader-2.4.6.zip", "depotdownloader", platformpath())
|
||||
await unzip("depotdownloader-2.4.6.zip", "depotdownloader")
|
||||
|
||||
// Clean up the old files
|
||||
await removeFile("depotdownloader-2.4.6.zip", platformpath())
|
||||
await removeFile("depotdownloader-2.4.6.zip")
|
||||
|
||||
// Run the final command
|
||||
await runCommand(createCommand().toString())
|
||||
|
||||
128
package-lock.json
generated
128
package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "steamdepotdownloadergui",
|
||||
"version": "2.0.1",
|
||||
"version": "2.0.2",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "steamdepotdownloadergui",
|
||||
"version": "2.0.1",
|
||||
"version": "2.0.2",
|
||||
"license": "WTFPL",
|
||||
"dependencies": {
|
||||
"follow-redirects": "^1.15.1"
|
||||
@@ -296,9 +296,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@types/node": {
|
||||
"version": "16.11.43",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.43.tgz",
|
||||
"integrity": "sha512-GqWykok+3uocgfAJM8imbozrqLnPyTrpFlrryURQlw1EesPUCx5XxTiucWDSFF9/NUEXDuD4bnvHm8xfVGWTpQ==",
|
||||
"version": "16.11.45",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.45.tgz",
|
||||
"integrity": "sha512-3rKg/L5x0rofKuuUt5zlXzOnKyIHXmIu5R8A0TuNDMF2062/AOIDBciFIjToLEJ/9F9DzkHNot+BpNsMI1OLdQ==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@types/plist": {
|
||||
@@ -313,9 +313,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@types/verror": {
|
||||
"version": "1.10.5",
|
||||
"resolved": "https://registry.npmjs.org/@types/verror/-/verror-1.10.5.tgz",
|
||||
"integrity": "sha512-9UjMCHK5GPgQRoNbqdLIAvAy0EInuiqbW0PBMtVP6B5B2HQJlvoJHM+KodPZMEjOa5VkSc+5LH7xy+cUzQdmHw==",
|
||||
"version": "1.10.6",
|
||||
"resolved": "https://registry.npmjs.org/@types/verror/-/verror-1.10.6.tgz",
|
||||
"integrity": "sha512-NNm+gdePAX1VGvPcGZCDKQZKYSiAWigKhKaz5KF94hG6f2s8de9Ow5+7AbXoeKxL8gavZfk4UquSAygOF2duEQ==",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
@@ -341,9 +341,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/acorn": {
|
||||
"version": "8.7.1",
|
||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.7.1.tgz",
|
||||
"integrity": "sha512-Xx54uLJQZ19lKygFXOWsscKUbsBZW0CPykPhVQdhIeIwrbPmJzqeASDInc8nKBnp/JT6igTs82qPXz069H8I/A==",
|
||||
"version": "8.8.0",
|
||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.0.tgz",
|
||||
"integrity": "sha512-QOxyigPVrpZ2GXT+PFyZTl6TtOFc5egxHIP9IlQ+RbupQuX4RkT/Bee4/kQuC02Xkzg84JcT7oLYtDIQxp+v7w==",
|
||||
"dev": true,
|
||||
"bin": {
|
||||
"acorn": "bin/acorn"
|
||||
@@ -966,12 +966,15 @@
|
||||
}
|
||||
},
|
||||
"node_modules/clone-response": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/clone-response/-/clone-response-1.0.2.tgz",
|
||||
"integrity": "sha512-yjLXh88P599UOyPTFX0POsd7WxnbsVsGohcwzHOLspIhhpalPw1BcqED8NblyZLKcGrL8dTgMlcaZxV2jAD41Q==",
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/clone-response/-/clone-response-1.0.3.tgz",
|
||||
"integrity": "sha512-ROoL94jJH2dUVML2Y/5PEDNaSHgeOdSDicUyS7izcF63G6sTc/FTjLub4b8Il9S8S0beOfYt0TaA5qvFK+w0wA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"mimic-response": "^1.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/color-convert": {
|
||||
@@ -1380,9 +1383,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/electron": {
|
||||
"version": "19.0.8",
|
||||
"resolved": "https://registry.npmjs.org/electron/-/electron-19.0.8.tgz",
|
||||
"integrity": "sha512-OWK3P/NbDFfBUv+wbYv1/OV4jehY5DQPT7n1maQJfN9hsnrWTMktXS/bmS05eSUAjNAzHmKPKfiKH2c1Yr7nGw==",
|
||||
"version": "19.0.9",
|
||||
"resolved": "https://registry.npmjs.org/electron/-/electron-19.0.9.tgz",
|
||||
"integrity": "sha512-ooEwrv8Y7NSzdhKcl6kPCYecnzcg5nFWuS5ryG+VFH3MMBR8zXh9nW2wLsZrBz6OGUxXrcc5BKBC7dA8C6RhGQ==",
|
||||
"dev": true,
|
||||
"hasInstallScript": true,
|
||||
"dependencies": {
|
||||
@@ -1629,9 +1632,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/eslint": {
|
||||
"version": "8.19.0",
|
||||
"resolved": "https://registry.npmjs.org/eslint/-/eslint-8.19.0.tgz",
|
||||
"integrity": "sha512-SXOPj3x9VKvPe81TjjUJCYlV4oJjQw68Uek+AM0X4p+33dj2HY5bpTZOgnQHcG2eAm1mtCU9uNMnJi7exU/kYw==",
|
||||
"version": "8.20.0",
|
||||
"resolved": "https://registry.npmjs.org/eslint/-/eslint-8.20.0.tgz",
|
||||
"integrity": "sha512-d4ixhz5SKCa1D6SCPrivP7yYVi7nyD6A4vs6HIAul9ujBzcEmZVM3/0NN/yu5nKhmO1wjp5xQ46iRfmDGlOviA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@eslint/eslintrc": "^1.3.0",
|
||||
@@ -2134,9 +2137,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/globals": {
|
||||
"version": "13.16.0",
|
||||
"resolved": "https://registry.npmjs.org/globals/-/globals-13.16.0.tgz",
|
||||
"integrity": "sha512-A1lrQfpNF+McdPOnnFqY3kSN0AFTy485bTi1bkLk4mVPODIUEcSfhHgRqA+QdXPksrSTTztYXx37NFV+GpGk3Q==",
|
||||
"version": "13.17.0",
|
||||
"resolved": "https://registry.npmjs.org/globals/-/globals-13.17.0.tgz",
|
||||
"integrity": "sha512-1C+6nQRb1GwGMKm2dH/E7enFAMxGTmGI7/dEdhy/DNelv85w9B72t3uc5frtMNXIbzrarJJ/lTCjcaZwbLJmyw==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"type-fest": "^0.20.2"
|
||||
@@ -2962,27 +2965,18 @@
|
||||
}
|
||||
},
|
||||
"node_modules/plist": {
|
||||
"version": "3.0.5",
|
||||
"resolved": "https://registry.npmjs.org/plist/-/plist-3.0.5.tgz",
|
||||
"integrity": "sha512-83vX4eYdQp3vP9SxuYgEM/G/pJQqLUz/V/xzPrzruLs7fz7jxGQ1msZ/mg1nwZxUSuOp4sb+/bEIbRrbzZRxDA==",
|
||||
"version": "3.0.6",
|
||||
"resolved": "https://registry.npmjs.org/plist/-/plist-3.0.6.tgz",
|
||||
"integrity": "sha512-WiIVYyrp8TD4w8yCvyeIr+lkmrGRd5u0VbRnU+tP/aRLxP/YadJUYOMZJ/6hIa3oUyVCsycXvtNRgd5XBJIbiA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"base64-js": "^1.5.1",
|
||||
"xmlbuilder": "^9.0.7"
|
||||
"xmlbuilder": "^15.1.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/plist/node_modules/xmlbuilder": {
|
||||
"version": "9.0.7",
|
||||
"resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-9.0.7.tgz",
|
||||
"integrity": "sha512-7YXTQc3P2l9+0rjaUbLwMKRhtmwg1M1eDf6nag7urC7pIPYLD9W/jmzQ4ptRSUbodw5S0jfoGTflLemQibSpeQ==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">=4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/prelude-ls": {
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz",
|
||||
@@ -3844,7 +3838,6 @@
|
||||
"resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-15.1.1.tgz",
|
||||
"integrity": "sha512-yMqGBqtXyeN1e3TGYvgNgDVZ3j84W4cwkOXQswghol6APgZWaff9lnbvN7MHYJOiXsvGPXtjTYJEiC9J2wv9Eg==",
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"engines": {
|
||||
"node": ">=8.0"
|
||||
}
|
||||
@@ -4124,9 +4117,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"@types/node": {
|
||||
"version": "16.11.43",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.43.tgz",
|
||||
"integrity": "sha512-GqWykok+3uocgfAJM8imbozrqLnPyTrpFlrryURQlw1EesPUCx5XxTiucWDSFF9/NUEXDuD4bnvHm8xfVGWTpQ==",
|
||||
"version": "16.11.45",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.45.tgz",
|
||||
"integrity": "sha512-3rKg/L5x0rofKuuUt5zlXzOnKyIHXmIu5R8A0TuNDMF2062/AOIDBciFIjToLEJ/9F9DzkHNot+BpNsMI1OLdQ==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/plist": {
|
||||
@@ -4141,9 +4134,9 @@
|
||||
}
|
||||
},
|
||||
"@types/verror": {
|
||||
"version": "1.10.5",
|
||||
"resolved": "https://registry.npmjs.org/@types/verror/-/verror-1.10.5.tgz",
|
||||
"integrity": "sha512-9UjMCHK5GPgQRoNbqdLIAvAy0EInuiqbW0PBMtVP6B5B2HQJlvoJHM+KodPZMEjOa5VkSc+5LH7xy+cUzQdmHw==",
|
||||
"version": "1.10.6",
|
||||
"resolved": "https://registry.npmjs.org/@types/verror/-/verror-1.10.6.tgz",
|
||||
"integrity": "sha512-NNm+gdePAX1VGvPcGZCDKQZKYSiAWigKhKaz5KF94hG6f2s8de9Ow5+7AbXoeKxL8gavZfk4UquSAygOF2duEQ==",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
@@ -4169,9 +4162,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"acorn": {
|
||||
"version": "8.7.1",
|
||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.7.1.tgz",
|
||||
"integrity": "sha512-Xx54uLJQZ19lKygFXOWsscKUbsBZW0CPykPhVQdhIeIwrbPmJzqeASDInc8nKBnp/JT6igTs82qPXz069H8I/A==",
|
||||
"version": "8.8.0",
|
||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.0.tgz",
|
||||
"integrity": "sha512-QOxyigPVrpZ2GXT+PFyZTl6TtOFc5egxHIP9IlQ+RbupQuX4RkT/Bee4/kQuC02Xkzg84JcT7oLYtDIQxp+v7w==",
|
||||
"dev": true
|
||||
},
|
||||
"acorn-jsx": {
|
||||
@@ -4644,9 +4637,9 @@
|
||||
}
|
||||
},
|
||||
"clone-response": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/clone-response/-/clone-response-1.0.2.tgz",
|
||||
"integrity": "sha512-yjLXh88P599UOyPTFX0POsd7WxnbsVsGohcwzHOLspIhhpalPw1BcqED8NblyZLKcGrL8dTgMlcaZxV2jAD41Q==",
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/clone-response/-/clone-response-1.0.3.tgz",
|
||||
"integrity": "sha512-ROoL94jJH2dUVML2Y/5PEDNaSHgeOdSDicUyS7izcF63G6sTc/FTjLub4b8Il9S8S0beOfYt0TaA5qvFK+w0wA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"mimic-response": "^1.0.0"
|
||||
@@ -4969,9 +4962,9 @@
|
||||
}
|
||||
},
|
||||
"electron": {
|
||||
"version": "19.0.8",
|
||||
"resolved": "https://registry.npmjs.org/electron/-/electron-19.0.8.tgz",
|
||||
"integrity": "sha512-OWK3P/NbDFfBUv+wbYv1/OV4jehY5DQPT7n1maQJfN9hsnrWTMktXS/bmS05eSUAjNAzHmKPKfiKH2c1Yr7nGw==",
|
||||
"version": "19.0.9",
|
||||
"resolved": "https://registry.npmjs.org/electron/-/electron-19.0.9.tgz",
|
||||
"integrity": "sha512-ooEwrv8Y7NSzdhKcl6kPCYecnzcg5nFWuS5ryG+VFH3MMBR8zXh9nW2wLsZrBz6OGUxXrcc5BKBC7dA8C6RhGQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@electron/get": "^1.14.1",
|
||||
@@ -5166,9 +5159,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"eslint": {
|
||||
"version": "8.19.0",
|
||||
"resolved": "https://registry.npmjs.org/eslint/-/eslint-8.19.0.tgz",
|
||||
"integrity": "sha512-SXOPj3x9VKvPe81TjjUJCYlV4oJjQw68Uek+AM0X4p+33dj2HY5bpTZOgnQHcG2eAm1mtCU9uNMnJi7exU/kYw==",
|
||||
"version": "8.20.0",
|
||||
"resolved": "https://registry.npmjs.org/eslint/-/eslint-8.20.0.tgz",
|
||||
"integrity": "sha512-d4ixhz5SKCa1D6SCPrivP7yYVi7nyD6A4vs6HIAul9ujBzcEmZVM3/0NN/yu5nKhmO1wjp5xQ46iRfmDGlOviA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@eslint/eslintrc": "^1.3.0",
|
||||
@@ -5562,9 +5555,9 @@
|
||||
}
|
||||
},
|
||||
"globals": {
|
||||
"version": "13.16.0",
|
||||
"resolved": "https://registry.npmjs.org/globals/-/globals-13.16.0.tgz",
|
||||
"integrity": "sha512-A1lrQfpNF+McdPOnnFqY3kSN0AFTy485bTi1bkLk4mVPODIUEcSfhHgRqA+QdXPksrSTTztYXx37NFV+GpGk3Q==",
|
||||
"version": "13.17.0",
|
||||
"resolved": "https://registry.npmjs.org/globals/-/globals-13.17.0.tgz",
|
||||
"integrity": "sha512-1C+6nQRb1GwGMKm2dH/E7enFAMxGTmGI7/dEdhy/DNelv85w9B72t3uc5frtMNXIbzrarJJ/lTCjcaZwbLJmyw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"type-fest": "^0.20.2"
|
||||
@@ -6181,21 +6174,13 @@
|
||||
"optional": true
|
||||
},
|
||||
"plist": {
|
||||
"version": "3.0.5",
|
||||
"resolved": "https://registry.npmjs.org/plist/-/plist-3.0.5.tgz",
|
||||
"integrity": "sha512-83vX4eYdQp3vP9SxuYgEM/G/pJQqLUz/V/xzPrzruLs7fz7jxGQ1msZ/mg1nwZxUSuOp4sb+/bEIbRrbzZRxDA==",
|
||||
"version": "3.0.6",
|
||||
"resolved": "https://registry.npmjs.org/plist/-/plist-3.0.6.tgz",
|
||||
"integrity": "sha512-WiIVYyrp8TD4w8yCvyeIr+lkmrGRd5u0VbRnU+tP/aRLxP/YadJUYOMZJ/6hIa3oUyVCsycXvtNRgd5XBJIbiA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"base64-js": "^1.5.1",
|
||||
"xmlbuilder": "^9.0.7"
|
||||
},
|
||||
"dependencies": {
|
||||
"xmlbuilder": {
|
||||
"version": "9.0.7",
|
||||
"resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-9.0.7.tgz",
|
||||
"integrity": "sha512-7YXTQc3P2l9+0rjaUbLwMKRhtmwg1M1eDf6nag7urC7pIPYLD9W/jmzQ4ptRSUbodw5S0jfoGTflLemQibSpeQ==",
|
||||
"dev": true
|
||||
}
|
||||
"xmlbuilder": "^15.1.1"
|
||||
}
|
||||
},
|
||||
"prelude-ls": {
|
||||
@@ -6881,8 +6866,7 @@
|
||||
"version": "15.1.1",
|
||||
"resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-15.1.1.tgz",
|
||||
"integrity": "sha512-yMqGBqtXyeN1e3TGYvgNgDVZ3j84W4cwkOXQswghol6APgZWaff9lnbvN7MHYJOiXsvGPXtjTYJEiC9J2wv9Eg==",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
},
|
||||
"y18n": {
|
||||
"version": "5.0.8",
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
{
|
||||
"name": "steamdepotdownloadergui",
|
||||
"version": "2.0.1",
|
||||
"version": "2.0.2",
|
||||
"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",
|
||||
|
||||
37
utils.js
37
utils.js
@@ -34,16 +34,14 @@ function checkDotnet() {
|
||||
/**
|
||||
* Download a file from a url, saving it to the current directory (__dirname)
|
||||
* @param url The url to download from
|
||||
* @param targetPath The path to save the file to
|
||||
* @returns {Promise<unknown>} A promise that resolves when the download is finished
|
||||
*/
|
||||
function download(url, targetPath) {
|
||||
function download(url) {
|
||||
return new Promise((resolve) => {
|
||||
const {https} = require("follow-redirects")
|
||||
const fs = require("fs")
|
||||
const path = require("path")
|
||||
console.log(path.sep)
|
||||
const file = fs.createWriteStream(targetPath + path.sep + url.split("/").pop())
|
||||
const file = fs.createWriteStream(platformpath() + path.sep + url.split("/").pop())
|
||||
https.get(url, function (response) {
|
||||
response.pipe(file)
|
||||
file.on("finish", function () {
|
||||
@@ -57,14 +55,13 @@ function download(url, targetPath) {
|
||||
/**
|
||||
* Removes a file from the current directory
|
||||
* @param file The filename to remove
|
||||
* @param targetPath The directory the file is located in
|
||||
* @returns {Promise<unknown>} A promise that resolves when the file is removed (or fails)
|
||||
*/
|
||||
function removeFile(file, targetPath) {
|
||||
function removeFile(file) {
|
||||
return new Promise((resolve) => {
|
||||
const fs = require("fs")
|
||||
const path = require("path")
|
||||
fs.unlink(targetPath + path.sep + file, function (err) {
|
||||
fs.unlink(platformpath() + path.sep + file, function (err) {
|
||||
if (err) {
|
||||
console.error(err)
|
||||
}
|
||||
@@ -76,14 +73,13 @@ function removeFile(file, targetPath) {
|
||||
/**
|
||||
* Removes a directory from the current directory
|
||||
* @param dir The directory to remove
|
||||
* @param targetPath The directory the directory is located in
|
||||
* @returns {Promise<unknown>} A promise that resolves when the directory is removed (or fails)
|
||||
*/
|
||||
function removeDir(dir, targetPath) {
|
||||
function removeDir(dir,) {
|
||||
return new Promise((resolve) => {
|
||||
const fs = require("fs")
|
||||
const path = require("path")
|
||||
fs.rm(targetPath + path.sep + dir, {recursive: true, force: true}, function (err) {
|
||||
fs.rm(platformpath() + path.sep + dir, {recursive: true, force: true}, function (err) {
|
||||
if (err) {
|
||||
console.error(err)
|
||||
}
|
||||
@@ -96,15 +92,15 @@ function removeDir(dir, targetPath) {
|
||||
* 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
|
||||
* @param targetPath The directory the file AND the unzip dir is located in
|
||||
* @returns {Promise<unknown>} A promise that resolves when the unzip is complete (or fails)
|
||||
*/
|
||||
function unzip(file, target, targetPath) {
|
||||
function unzip(file, target) {
|
||||
const {exec} = require("child_process")
|
||||
const path = require("path")
|
||||
|
||||
return new Promise((resolve) => {
|
||||
if (process.platform.toString().includes("win")) {
|
||||
const command = "powershell.exe -Command Expand-Archive -Path " + targetPath + path.sep + file + " -Destination " + targetPath + path.sep + target
|
||||
const command = "powershell.exe -Command Expand-Archive -Path " + platformpath() + path.sep + file + " -Destination " + platformpath() + path.sep + target
|
||||
exec(command, function (error, stdout, stderr) {
|
||||
if (error) {
|
||||
console.error("Unzipping failed with error: " + error)
|
||||
@@ -137,6 +133,9 @@ function unzip(file, target, targetPath) {
|
||||
* @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
|
||||
@@ -149,7 +148,7 @@ const createCommand = () => {
|
||||
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'`
|
||||
} else if (osdropdown.options[osdropdown.selectedIndex].text.includes("Windows")) {
|
||||
return `start cmd.exe /k dotnet ${platformpath()}/depotdownloader/DepotDownloader.dll -username ${username} -password ${password} -app ${appid} -depot ${depotid} -manifest ${manifestid} -dir ${platformpath()}/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 ${platformpath()}${path.sep}games${path.sep}${appid}/ -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'`
|
||||
} else if (osdropdown.options[osdropdown.selectedIndex].text.includes("Konsole")) {
|
||||
@@ -185,10 +184,16 @@ function runCommand(command) {
|
||||
}
|
||||
|
||||
const platformpath = () => {
|
||||
if (__dirname.includes("AppData") && process.platform.toString().includes("win")) {
|
||||
if ((__dirname.includes("AppData") || __dirname.includes("Temp")) && process.platform.toString().includes("win")) {
|
||||
// Windows portable exe
|
||||
return process.env.PORTABLE_EXECUTABLE_DIR
|
||||
} else
|
||||
} 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