diff --git a/src/lib/utils/github.ts b/src/lib/utils/github.ts index 718d354..ec8da26 100644 --- a/src/lib/utils/github.ts +++ b/src/lib/utils/github.ts @@ -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 { + 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("")[0] + .trim(); + releaseInfo.invalidationReasons = line.split("|"); + } catch (err) { + // do nothing, bad formatting + } + } + console.log(releaseInfo); + return releaseInfo; +} + export async function listOfficialReleases(): Promise { let releases = []; // TODO - handle rate limiting @@ -75,15 +106,7 @@ export async function listOfficialReleases(): Promise { 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 { ); // 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); } diff --git a/src/routes/settings/versions/DevelVersions.svelte b/src/routes/settings/versions/DevelVersions.svelte index 51f444c..a718479 100644 --- a/src/routes/settings/versions/DevelVersions.svelte +++ b/src/routes/settings/versions/DevelVersions.svelte @@ -43,6 +43,8 @@ downloadUrl: undefined, isDownloaded: true, pendingAction: false, + invalid: false, + invalidationReasons: [], }, ]; } diff --git a/src/routes/settings/versions/OfficialVersions.svelte b/src/routes/settings/versions/OfficialVersions.svelte index e9e5aea..d83c7ef 100644 --- a/src/routes/settings/versions/OfficialVersions.svelte +++ b/src/routes/settings/versions/OfficialVersions.svelte @@ -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, }, ]; } diff --git a/src/routes/settings/versions/UnofficialVersions.svelte b/src/routes/settings/versions/UnofficialVersions.svelte index 090511e..820a8dc 100644 --- a/src/routes/settings/versions/UnofficialVersions.svelte +++ b/src/routes/settings/versions/UnofficialVersions.svelte @@ -45,6 +45,8 @@ downloadUrl: undefined, isDownloaded: true, pendingAction: false, + invalid: false, + invalidationReasons: [], }, ]; } diff --git a/src/routes/settings/versions/VersionList.svelte b/src/routes/settings/versions/VersionList.svelte index 7ddea38..c26a3a7 100644 --- a/src/routes/settings/versions/VersionList.svelte +++ b/src/routes/settings/versions/VersionList.svelte @@ -22,6 +22,7 @@ TableBodyRow, TableHead, TableHeadCell, + Tooltip, } from "flowbite-svelte"; import { createEventDispatcher } from "svelte"; import { _ } from "svelte-i18n"; @@ -132,7 +133,10 @@ > + {#if release.invalid} + + {#if release.invalidationReasons.length > 0} + Release marked as invalid for the following reasons: + {#each release.invalidationReasons as reason} +
+ - {reason} + {/each} + {:else} + Release marked as invalid + {/if} +
+ {/if} {#if release.isDownloaded && release.releaseType == "official"}