-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move clientRelease url generator (#460)
* move github link to the browser, so server-startup will not fail due a rate-limit of the github-api #418 * directly go to latest client release
- Loading branch information
Showing
10 changed files
with
62 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,7 +45,4 @@ public/styles/css/* | |
#Ignore environment | ||
.env | ||
|
||
#Ignore link.json | ||
link.json | ||
|
||
public/js/*.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import {Octokit} from "https://esm.sh/@octokit/core"; | ||
|
||
const githubOrg = 'faforever' | ||
const githubRepository = 'downlords-faf-client' | ||
const githubFallbackUrl = 'https://github.com/FAForever/downlords-faf-client/releases/latest'; | ||
const downloadButtonId = 'faf-client-download' | ||
|
||
const startDownloadFile = (url) => window.location.assign(url) | ||
|
||
const openFallbackDownloadPage = () => open(githubFallbackUrl, '_blank') | ||
|
||
const getWindowsDownloadLink = (response) => { | ||
let [exeAsset] = response?.data?.assets?.filter?.(function (asset) { | ||
return asset.name?.includes?.('.exe') | ||
}) ?? [] | ||
|
||
if (exeAsset) { | ||
try { | ||
new URL(exeAsset.browser_download_url ?? false) | ||
|
||
return exeAsset.browser_download_url | ||
} catch (e) {} | ||
} | ||
|
||
return false | ||
} | ||
|
||
const onGithubResponse = (response) => { | ||
const windowsDownloadLink = getWindowsDownloadLink(response) | ||
|
||
if (windowsDownloadLink) { | ||
startDownloadFile(windowsDownloadLink) | ||
|
||
return | ||
} | ||
|
||
openFallbackDownloadPage() | ||
} | ||
|
||
const onDownloadButtonClicked = (event) => { | ||
event.preventDefault() | ||
const octokit = new Octokit() | ||
|
||
octokit | ||
.request(`GET /repos/${githubOrg}/${githubRepository}/releases/latest`) | ||
.then(onGithubResponse) | ||
.catch(() => openFallbackDownloadPage()) | ||
} | ||
|
||
const downloadButton = document.getElementById(downloadButtonId) | ||
|
||
if (downloadButton) { | ||
downloadButton.addEventListener("click", onDownloadButtonClicked) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -519,13 +519,6 @@ [email protected]: | |
form-data "^4.0.0" | ||
proxy-from-env "^1.1.0" | ||
|
||
axios@^0.21.1: | ||
version "0.21.4" | ||
resolved "https://registry.yarnpkg.com/axios/-/axios-0.21.4.tgz#c67b90dc0568e5c1cf2b0b858c43ba28e2eda575" | ||
integrity sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg== | ||
dependencies: | ||
follow-redirects "^1.14.0" | ||
|
||
[email protected]: | ||
version "3.0.0-canary-5" | ||
resolved "https://registry.yarnpkg.com/babel-walk/-/babel-walk-3.0.0-canary-5.tgz#f66ecd7298357aee44955f235a6ef54219104b11" | ||
|
@@ -1961,7 +1954,7 @@ flagged-respawn@^1.0.1: | |
resolved "https://registry.yarnpkg.com/flagged-respawn/-/flagged-respawn-1.0.1.tgz#e7de6f1279ddd9ca9aac8a5971d618606b3aab41" | ||
integrity sha512-lNaHNVymajmk0OJMBn8fVUAU1BtDeKIqKoVhk4xAALB57aALg6b4W0MfJ/cUE0g9YBXy5XhSlPIpYIJ7HaY/3Q== | ||
|
||
follow-redirects@^1.14.0, follow-redirects@^1.15.0: | ||
follow-redirects@^1.15.0: | ||
version "1.15.3" | ||
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.3.tgz#fe2f3ef2690afce7e82ed0b44db08165b207123a" | ||
integrity sha512-1VzOtuEM8pC9SFU1E+8KfTjZyMztRsgEfwQl44z8A25uy13jSzTj6dyK2Df52iV0vgHCfBwLhDWevLn95w5v6Q== | ||
|
@@ -2109,16 +2102,6 @@ getpass@^0.1.1: | |
dependencies: | ||
assert-plus "^1.0.0" | ||
|
||
[email protected]: | ||
version "3.4.0" | ||
resolved "https://registry.yarnpkg.com/github-api/-/github-api-3.4.0.tgz#5da2f56442d4839d324e9faf0ffb2cf30f7650b8" | ||
integrity sha512-2yYqYS6Uy4br1nw0D3VrlYWxtGTkUhIZrumBrcBwKdBOzMT8roAe8IvI6kjIOkxqxapKR5GkEsHtz3Du/voOpA== | ||
dependencies: | ||
axios "^0.21.1" | ||
debug "^2.2.0" | ||
js-base64 "^2.1.9" | ||
utf8 "^2.1.1" | ||
|
||
giturl@^1.0.0: | ||
version "1.0.3" | ||
resolved "https://registry.yarnpkg.com/giturl/-/giturl-1.0.3.tgz#27f9d1f251d138eb2a5a56cc9dd8512b0fc0bbc6" | ||
|
@@ -3057,11 +3040,6 @@ [email protected]: | |
resolved "https://registry.yarnpkg.com/jit-grunt/-/jit-grunt-0.10.0.tgz#008c3a7fe1e96bd0d84e260ea1fa1783457f79c2" | ||
integrity sha512-eT/f4c9wgZ3buXB7X1JY1w6uNtAV0bhrbOGf/mFmBb0CDNLUETJ/VRoydayWOI54tOoam0cz9RooVCn3QY1WoA== | ||
|
||
js-base64@^2.1.9: | ||
version "2.6.4" | ||
resolved "https://registry.yarnpkg.com/js-base64/-/js-base64-2.6.4.tgz#f4e686c5de1ea1f867dbcad3d46d969428df98c4" | ||
integrity sha512-pZe//GGmwJndub7ZghVHz7vjb2LgC1m8B07Au3eYqeqv9emhESByMXxaEgkUkEqJe87oBbSniGYoQNIBklc7IQ== | ||
|
||
js-stringify@^1.0.2: | ||
version "1.0.2" | ||
resolved "https://registry.yarnpkg.com/js-stringify/-/js-stringify-1.0.2.tgz#1736fddfd9724f28a3682adc6230ae7e4e9679db" | ||
|
@@ -5754,11 +5732,6 @@ use@^3.1.0: | |
resolved "https://registry.yarnpkg.com/use/-/use-3.1.1.tgz#d50c8cac79a19fbc20f2911f56eb973f4e10070f" | ||
integrity sha512-cwESVXlO3url9YWlFW/TA9cshCEhtu7IKJ/p5soJ/gGpj7vbvFrAY/eIioQ6Dw23KjZhYgiIo8HOs1nQ2vr/oQ== | ||
|
||
utf8@^2.1.1: | ||
version "2.1.2" | ||
resolved "https://registry.yarnpkg.com/utf8/-/utf8-2.1.2.tgz#1fa0d9270e9be850d9b05027f63519bf46457d96" | ||
integrity sha512-QXo+O/QkLP/x1nyi54uQiG0XrODxdysuQvE5dtVqv7F5K2Qb6FsN+qbr6KhF5wQ20tfcV3VQp0/2x1e1MRSPWg== | ||
|
||
util-deprecate@^1.0.1, util-deprecate@^1.0.2, util-deprecate@~1.0.1: | ||
version "1.0.2" | ||
resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" | ||
|