-
Notifications
You must be signed in to change notification settings - Fork 45
Return Github "version" Objects instead of the tag Strings #1154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
e64ad16
7796848
a706a59
4907831
e259bd8
c675a46
1ca5958
ca12c95
66551af
6a6344c
2ddcebd
3c3ac78
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,7 +5,7 @@ const { ls, cp, remove } = include("utils.functions.filesystem.files"); | |
| const operatingSystemFetcher = Bean("operatingSystemFetcher"); | ||
| const Optional = Java.type("java.util.Optional"); | ||
| const OverrideDLL = include("engines.wine.plugins.override_dll"); | ||
| const { getGithubReleases } = include("utils.functions.net.githubreleases"); | ||
| const { fetchGithubReleases, downloadGithubRelease, extractGithubReleaseStrings } = include("utils.functions.net.githubreleases"); | ||
|
|
||
| /** | ||
| * Verb to install D9VK | ||
|
|
@@ -28,6 +28,16 @@ class D9VK { | |
| return this; | ||
| } | ||
|
|
||
| selectGithubVersion(wizard) { | ||
| const versions = fetchGithubReleases("Joshua-Ashton", "d9vk", wizard); | ||
|
|
||
| if (!this.d9vkVersion || typeof this.d9vkVersion !== 'string') { | ||
| return versions[0]; | ||
| } else { | ||
| return versions.find(version => version.name === this.d9vkVersion); | ||
| } | ||
| } | ||
|
madoar marked this conversation as resolved.
Outdated
|
||
|
|
||
| go() { | ||
| const wizard = this.wine.wizard(); | ||
| const prefixDirectory = this.wine.prefixDirectory(); | ||
|
|
@@ -36,8 +46,7 @@ class D9VK { | |
|
|
||
| print("NOTE: Wine version should be greater or equal to 3.10"); | ||
|
|
||
| if (operatingSystemFetcher.fetchCurrentOperationSystem().getFullName() !== "Linux") | ||
| { | ||
| if (operatingSystemFetcher.fetchCurrentOperationSystem().getFullName() !== "Linux") { | ||
| const question = tr("D9VK is currently unsupported on non-Linux operating systems due to MoltenVK implementation being incomplete. Select how do you want to approach this situation.") | ||
| const choices = [ | ||
| tr("YES, continue with DXVK installation regardless"), | ||
|
|
@@ -55,35 +64,24 @@ class D9VK { | |
| // choice: "Exit D9VK Installer, but continue with the script" | ||
| return this; | ||
| default: | ||
| // do nothing | ||
| // do nothing | ||
| } | ||
| } | ||
| else | ||
| { | ||
| else { | ||
| wizard.message(tr("Please ensure you have the latest drivers (418.30 minimum for NVIDIA and mesa 19 for AMD) or else D9VK might not work correctly.")); | ||
| } | ||
|
|
||
| if (typeof this.d9vkVersion !== 'string') | ||
| { | ||
| const versions = getGithubReleases("Joshua-Ashton", "d9vk", wizard); | ||
| this.d9vkVersion = versions[0]; | ||
| } | ||
| const selectedVersion = this.selectGithubVersion(wizard); | ||
|
|
||
| var setupFile = new Resource() | ||
| .wizard(wizard) | ||
| .url( | ||
| `https://github.com/Joshua-Ashton/d9vk/releases/download/${this.d9vkVersion}/d9vk-${this.d9vkVersion}.tar.gz` | ||
| ) | ||
| .name(`d9vk-${this.d9vkVersion}.tar.gz`) | ||
| .get(); | ||
| var setupFile = this.downloadGithubRelease(selectedVersion, wizard); | ||
|
|
||
| new Extractor() | ||
| .wizard(wizard) | ||
| .archive(setupFile) | ||
| .to(`${prefixDirectory}/TMP/`) | ||
| .extract(); | ||
|
|
||
| const d9vkTmpDir = `${prefixDirectory}/TMP/d9vk-${this.d9vkVersion}`; | ||
| const d9vkTmpDir = `${prefixDirectory}/TMP/d9vk-${selectedVersion.name}`; | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We have this pattern in multiple places and I don't like it. The version name should not be needed in the folder names in my opinion, especially because we have no "safe" method to fetch it. Who guarantees that
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, also it does not seem to be required at all.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These folder names seem to be dependent on the content of the downloaded archives. I don't think we can replace them with a real temporary directory. |
||
|
|
||
| // copy 32 bits dll to system* and apply override | ||
| ls(`${d9vkTmpDir}/x32`).forEach(file => { | ||
|
|
@@ -115,8 +113,10 @@ class D9VK { | |
| wine.wizard(wizard); | ||
| wine.prefix(container); | ||
|
|
||
| const versions = getGithubReleases("Joshua-Ashton", "d9vk", wizard); | ||
| const selectedVersion = wizard.menu(tr("Please select the version."), versions, versions[0]); | ||
| const versions = fetchGithubReleases("Joshua-Ashton", "d9vk", wizard); | ||
| const versionStrings = extractGithubReleaseStrings(versions); | ||
|
|
||
| const selectedVersion = wizard.menu(tr("Please select the version."), versionStrings, versionStrings[0]); | ||
|
|
||
| // install selected version | ||
| new D9VK(wine).withVersion(selectedVersion.text).go(); | ||
|
madoar marked this conversation as resolved.
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,29 +1,41 @@ | ||
| const Downloader = include("utils.functions.net.download"); | ||
| const {createTempDir, remove, cat} = include("utils.functions.filesystem.files"); | ||
| const Resource = include("utils.functions.net.resource"); | ||
| const { createTempDir, remove, cat } = include("utils.functions.filesystem.files"); | ||
|
|
||
| /** | ||
| * Get an array of tag corresponding to the releases in a git repository | ||
| * Fetches an array of tag corresponding to the releases in a git repository | ||
| * | ||
| * @param {string} repositoryOwner owner of the repository | ||
| * @param {string} repositoryName name of the repository | ||
| * @param {wizard} wizard the wizard | ||
| * @returns {string[]} list of version tag in the repository | ||
| * @returns {object[]} list of version objects in the repository | ||
| */ | ||
| module.getGithubReleases = function getGithubReleases(repositoryOwner, repositoryName, wizard) { | ||
| module.fetchGithubReleases = function fetchGithubReleases(repositoryOwner, repositoryName, wizard) { | ||
|
madoar marked this conversation as resolved.
Outdated
|
||
| const tmpDir = createTempDir(); | ||
|
|
||
| const releasesFile = new Downloader() | ||
| .wizard(wizard) | ||
| .url( | ||
| `https://api.github.com/repos/${repositoryOwner}/${repositoryName}/releases` | ||
| ) | ||
| .url(`https://api.github.com/repos/${repositoryOwner}/${repositoryName}/releases`) | ||
| .message(tr("Fetching versions list...")) | ||
| .to(tmpDir + "/releases.json") | ||
| .get(); | ||
|
|
||
| const versions = JSON.parse(cat(releasesFile)).map(version => version.tag_name); | ||
| const versions = JSON.parse(cat(releasesFile)); | ||
|
|
||
| remove(tmpDir); | ||
|
|
||
| return versions; | ||
| }; | ||
|
|
||
| module.extractGithubReleaseStrings = function extractGithubReleaseStrings(versions) { | ||
| return versions.map(version => version.name); | ||
| } | ||
|
madoar marked this conversation as resolved.
Outdated
|
||
|
|
||
| module.downloadGithubRelease = function downloadGithubRelease(version, wizard) { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Couldn't this be module.downloadGithubRelease = function (version, wizard) {?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes |
||
| return new Resource() | ||
| .wizard(wizard) | ||
| .url(version.tarball_url) | ||
| // TODO: generate a more "random" name to prevent file conflicts | ||
| .name(`${version.name}.tar.xz`) | ||
|
madoar marked this conversation as resolved.
Outdated
|
||
| .get(); | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.