mirror of
https://github.com/open-goal/launcher.git
synced 2024-10-19 14:47:36 -04:00
versions: support invalidating releases (#314)
This commit is contained in:
parent
4a6a1bf081
commit
e7c90166c3
|
@ -8,6 +8,8 @@ export interface ReleaseInfo {
|
|||
downloadUrl: string | undefined;
|
||||
isDownloaded: boolean;
|
||||
pendingAction: boolean;
|
||||
invalid: boolean;
|
||||
invalidationReasons: string[];
|
||||
}
|
||||
|
||||
function isIntelMacOsRelease(
|
||||
|
@ -64,6 +66,35 @@ async function getDownloadLinkForCurrentPlatform(
|
|||
return undefined;
|
||||
}
|
||||
|
||||
async function parseGithubRelease(githubRelease: any): Promise<ReleaseInfo> {
|
||||
const releaseInfo: ReleaseInfo = {
|
||||
releaseType: "official",
|
||||
version: githubRelease.tag_name,
|
||||
date: githubRelease.published_at,
|
||||
githubLink: githubRelease.html_url,
|
||||
downloadUrl: await getDownloadLinkForCurrentPlatform(githubRelease),
|
||||
isDownloaded: false,
|
||||
pendingAction: false,
|
||||
invalid: false,
|
||||
invalidationReasons: [],
|
||||
};
|
||||
if (githubRelease.body.includes("<!-- invalid:")) {
|
||||
releaseInfo.invalid = true;
|
||||
// Get the line it's on
|
||||
try {
|
||||
const line = githubRelease.body
|
||||
.split("<!-- invalid:")[1]
|
||||
.split("-->")[0]
|
||||
.trim();
|
||||
releaseInfo.invalidationReasons = line.split("|");
|
||||
} catch (err) {
|
||||
// do nothing, bad formatting
|
||||
}
|
||||
}
|
||||
console.log(releaseInfo);
|
||||
return releaseInfo;
|
||||
}
|
||||
|
||||
export async function listOfficialReleases(): Promise<ReleaseInfo[]> {
|
||||
let releases = [];
|
||||
// TODO - handle rate limiting
|
||||
|
@ -75,15 +106,7 @@ export async function listOfficialReleases(): Promise<ReleaseInfo[]> {
|
|||
const githubReleases = await resp.json();
|
||||
|
||||
for (const release of githubReleases) {
|
||||
releases.push({
|
||||
releaseType: "official",
|
||||
version: release.tag_name,
|
||||
date: release.published_at,
|
||||
githubLink: release.html_url,
|
||||
downloadUrl: await getDownloadLinkForCurrentPlatform(release),
|
||||
isDownloaded: false,
|
||||
pendingAction: false,
|
||||
});
|
||||
releases.push(await parseGithubRelease(release));
|
||||
}
|
||||
|
||||
return releases.sort((a, b) => b.date.localeCompare(a.date));
|
||||
|
@ -96,13 +119,5 @@ export async function getLatestOfficialRelease(): Promise<ReleaseInfo> {
|
|||
);
|
||||
// TODO - handle error
|
||||
const githubRelease = await resp.json();
|
||||
return {
|
||||
releaseType: "official",
|
||||
version: githubRelease.tag_name,
|
||||
date: githubRelease.published_at,
|
||||
githubLink: githubRelease.html_url,
|
||||
downloadUrl: await getDownloadLinkForCurrentPlatform(githubRelease),
|
||||
isDownloaded: false,
|
||||
pendingAction: false,
|
||||
};
|
||||
return await parseGithubRelease(githubRelease);
|
||||
}
|
||||
|
|
|
@ -43,6 +43,8 @@
|
|||
downloadUrl: undefined,
|
||||
isDownloaded: true,
|
||||
pendingAction: false,
|
||||
invalid: false,
|
||||
invalidationReasons: [],
|
||||
},
|
||||
];
|
||||
}
|
||||
|
|
|
@ -44,6 +44,8 @@
|
|||
downloadUrl: undefined,
|
||||
isDownloaded: true,
|
||||
pendingAction: false,
|
||||
invalid: false,
|
||||
invalidationReasons: [],
|
||||
},
|
||||
];
|
||||
}
|
||||
|
@ -76,6 +78,8 @@
|
|||
downloadUrl: release.downloadUrl,
|
||||
isDownloaded: false,
|
||||
pendingAction: false,
|
||||
invalid: release.invalid,
|
||||
invalidationReasons: release.invalidationReasons,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
|
|
@ -45,6 +45,8 @@
|
|||
downloadUrl: undefined,
|
||||
isDownloaded: true,
|
||||
pendingAction: false,
|
||||
invalid: false,
|
||||
invalidationReasons: [],
|
||||
},
|
||||
];
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
TableBodyRow,
|
||||
TableHead,
|
||||
TableHeadCell,
|
||||
Tooltip,
|
||||
} from "flowbite-svelte";
|
||||
import { createEventDispatcher } from "svelte";
|
||||
import { _ } from "svelte-i18n";
|
||||
|
@ -132,7 +133,10 @@
|
|||
>
|
||||
<Button
|
||||
class="py-0 dark:bg-transparent hover:dark:bg-transparent focus:ring-0 focus:ring-offset-0 disabled:opacity-50"
|
||||
disabled={release.pendingAction}
|
||||
disabled={release.pendingAction ||
|
||||
(!release.isDownloaded &&
|
||||
release.downloadUrl !== undefined &&
|
||||
release.invalid)}
|
||||
on:click={async () => {
|
||||
if (release.isDownloaded) {
|
||||
dispatch("removeVersion", { version: release.version });
|
||||
|
@ -166,6 +170,19 @@
|
|||
/>
|
||||
{/if}
|
||||
</Button>
|
||||
{#if release.invalid}
|
||||
<Tooltip color="red">
|
||||
{#if release.invalidationReasons.length > 0}
|
||||
Release marked as invalid for the following reasons:
|
||||
{#each release.invalidationReasons as reason}
|
||||
<br />
|
||||
- {reason}
|
||||
{/each}
|
||||
{:else}
|
||||
Release marked as invalid
|
||||
{/if}
|
||||
</Tooltip>
|
||||
{/if}
|
||||
{#if release.isDownloaded && release.releaseType == "official"}
|
||||
<Button
|
||||
class="py-0 dark:bg-transparent hover:dark:bg-transparent focus:ring-0 focus:ring-offset-0 disabled:opacity-50"
|
||||
|
|
Loading…
Reference in a new issue