mirror of
https://github.com/zen-browser/www.git
synced 2025-07-07 17:05:32 +02:00
refactor(download): remove checksum handling and simplify release data retrieval
This commit is contained in:
parent
ec6e361d74
commit
f1f02464e7
5 changed files with 54 additions and 7 deletions
|
@ -1,5 +1,4 @@
|
||||||
---
|
---
|
||||||
import h3 from '~/components/Description.astro'
|
|
||||||
import { getLocale, getUI } from '~/utils/i18n'
|
import { getLocale, getUI } from '~/utils/i18n'
|
||||||
|
|
||||||
const locale = getLocale(Astro)
|
const locale = getLocale(Astro)
|
||||||
|
|
|
@ -5,7 +5,6 @@ import Button from '../Button.astro'
|
||||||
interface ReleaseInfo {
|
interface ReleaseInfo {
|
||||||
label?: string
|
label?: string
|
||||||
link: string
|
link: string
|
||||||
checksum?: string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface PlatformReleases {
|
interface PlatformReleases {
|
||||||
|
|
|
@ -59,3 +59,55 @@ export function getReleasesWithChecksums(locale: string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the releases object, without checksums.
|
||||||
|
* @param locale The locale to use for labels
|
||||||
|
*/
|
||||||
|
export function getReleases(locale: string) {
|
||||||
|
const {
|
||||||
|
routes: {
|
||||||
|
download: {
|
||||||
|
links: { macos, windows, linux },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
} = getUI(locale)
|
||||||
|
return {
|
||||||
|
macos: {
|
||||||
|
universal: {
|
||||||
|
link: 'https://github.com/zen-browser/desktop/releases/latest/download/zen.macos-universal.dmg',
|
||||||
|
label: macos.universal,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
windows: {
|
||||||
|
x86_64: {
|
||||||
|
link: 'https://github.com/zen-browser/desktop/releases/latest/download/zen.installer.exe',
|
||||||
|
label: windows['64bit'],
|
||||||
|
},
|
||||||
|
arm64: {
|
||||||
|
link: 'https://github.com/zen-browser/desktop/releases/latest/download/zen.installer-arm64.exe',
|
||||||
|
label: windows.ARM64,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
linux: {
|
||||||
|
x86_64: {
|
||||||
|
tarball: {
|
||||||
|
link: 'https://github.com/zen-browser/desktop/releases/latest/download/zen.linux-x86_64.tar.xz',
|
||||||
|
label: linux.x86_64,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
aarch64: {
|
||||||
|
tarball: {
|
||||||
|
link: 'https://github.com/zen-browser/desktop/releases/latest/download/zen.linux-aarch64.tar.xz',
|
||||||
|
label: linux.aarch64,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
flathub: {
|
||||||
|
all: {
|
||||||
|
link: 'https://flathub.org/apps/app.zen_browser.zen',
|
||||||
|
label: linux.flathub,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -2,9 +2,8 @@
|
||||||
import Description from '~/components/Description.astro'
|
import Description from '~/components/Description.astro'
|
||||||
import DownloadScript from '~/components/download/DownloadScript.astro'
|
import DownloadScript from '~/components/download/DownloadScript.astro'
|
||||||
import PlatformDownload from '~/components/download/PlatformDownload.astro'
|
import PlatformDownload from '~/components/download/PlatformDownload.astro'
|
||||||
import { getReleasesWithChecksums } from '~/components/download/release-data'
|
import { getReleases } from '~/components/download/release-data'
|
||||||
import Layout from '~/layouts/Layout.astro'
|
import Layout from '~/layouts/Layout.astro'
|
||||||
import { getChecksums } from '~/utils/githubChecksums'
|
|
||||||
import { getLocale, getUI } from '~/utils/i18n'
|
import { getLocale, getUI } from '~/utils/i18n'
|
||||||
|
|
||||||
import { icon, library } from '@fortawesome/fontawesome-svg-core'
|
import { icon, library } from '@fortawesome/fontawesome-svg-core'
|
||||||
|
@ -27,8 +26,7 @@ const windowsIcon = icon({ prefix: 'fab', iconName: 'windows' })
|
||||||
const linuxIcon = icon({ prefix: 'fab', iconName: 'linux' })
|
const linuxIcon = icon({ prefix: 'fab', iconName: 'linux' })
|
||||||
const appleIcon = icon({ prefix: 'fab', iconName: 'apple' })
|
const appleIcon = icon({ prefix: 'fab', iconName: 'apple' })
|
||||||
|
|
||||||
const checksums = await getChecksums()
|
const releases = getReleases(locale)
|
||||||
const releases = getReleasesWithChecksums(locale)(checksums)
|
|
||||||
|
|
||||||
const platformDescriptions = download.platformDescriptions
|
const platformDescriptions = download.platformDescriptions
|
||||||
---
|
---
|
||||||
|
|
|
@ -18,7 +18,6 @@ export async function getChecksums() {
|
||||||
Accept: 'application/vnd.github+json',
|
Accept: 'application/vnd.github+json',
|
||||||
'X-GitHub-Api-Version': '2022-11-28',
|
'X-GitHub-Api-Version': '2022-11-28',
|
||||||
'User-Agent': 'zen-browser-checksum-fetcher',
|
'User-Agent': 'zen-browser-checksum-fetcher',
|
||||||
...(process.env.GITHUB_TOKEN ? { Authorization: `Bearer ${process.env.GITHUB_TOKEN}` } : {}),
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
if (!res.ok) throw new Error(`Failed to fetch GitHub release: ${res.statusText}`)
|
if (!res.ok) throw new Error(`Failed to fetch GitHub release: ${res.statusText}`)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue