feat: expose rpm download option
This commit is contained in:
@@ -80,7 +80,7 @@ describe('extractStableDownloadTargets', () => {
|
||||
url: 'https://example.com/Tolaria-x64.dmg',
|
||||
},
|
||||
'linux-x86_64': {
|
||||
label: 'Linux',
|
||||
label: 'Linux AppImage',
|
||||
url: 'https://example.com/Tolaria.AppImage',
|
||||
},
|
||||
'windows-x86_64': {
|
||||
@@ -176,6 +176,10 @@ describe('resolveStableDownloadTargets', () => {
|
||||
name: 'Tolaria.AppImage',
|
||||
browser_download_url: 'https://example.com/Tolaria.AppImage',
|
||||
},
|
||||
{
|
||||
name: 'Tolaria.rpm',
|
||||
browser_download_url: 'https://example.com/Tolaria.rpm',
|
||||
},
|
||||
],
|
||||
},
|
||||
]
|
||||
@@ -187,6 +191,10 @@ describe('resolveStableDownloadTargets', () => {
|
||||
'linux-x86_64': {
|
||||
url: 'https://example.com/Tolaria.AppImage',
|
||||
},
|
||||
'linux-x86_64-rpm': {
|
||||
label: 'Linux RPM',
|
||||
url: 'https://example.com/Tolaria.rpm',
|
||||
},
|
||||
'windows-x86_64': {
|
||||
url: 'https://example.com/Tolaria-setup.exe',
|
||||
},
|
||||
@@ -201,9 +209,33 @@ describe('resolveStableDownloadTargets', () => {
|
||||
'linux-x86_64': {
|
||||
url: 'https://example.com/Tolaria.AppImage',
|
||||
},
|
||||
'linux-x86_64-rpm': {
|
||||
label: 'Linux RPM',
|
||||
url: 'https://example.com/Tolaria.rpm',
|
||||
},
|
||||
'windows-x86_64': {
|
||||
url: 'https://example.com/Tolaria-setup.exe',
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
it('keeps AppImage as the Linux auto-download while exposing RPM manually', () => {
|
||||
const html = buildStableDownloadRedirectPage({
|
||||
'linux-x86_64': {
|
||||
buttonLabel: 'Download Tolaria AppImage for Linux',
|
||||
label: 'Linux AppImage',
|
||||
url: 'https://example.com/Tolaria.AppImage',
|
||||
},
|
||||
'linux-x86_64-rpm': {
|
||||
buttonLabel: 'Download Tolaria RPM for Linux',
|
||||
label: 'Linux RPM',
|
||||
url: 'https://example.com/Tolaria.rpm',
|
||||
},
|
||||
})
|
||||
|
||||
expect(html).toContain('linux-x86_64-rpm')
|
||||
expect(html).toContain('Linux AppImage')
|
||||
expect(html).toContain('Linux RPM')
|
||||
expect(html).toContain("if (/Linux/i.test(userAgent) && !/Android/i.test(userAgent)) return 'linux-x86_64';")
|
||||
})
|
||||
})
|
||||
|
||||
@@ -5,12 +5,14 @@ type StablePlatformKey =
|
||||
| 'darwin-aarch64'
|
||||
| 'darwin-x86_64'
|
||||
| 'linux-x86_64'
|
||||
| 'linux-x86_64-rpm'
|
||||
| 'windows-x86_64'
|
||||
|
||||
type PlatformPayload = {
|
||||
dmg_url?: unknown
|
||||
download_url?: unknown
|
||||
installer_url?: unknown
|
||||
rpm_url?: unknown
|
||||
url?: unknown
|
||||
}
|
||||
|
||||
@@ -54,8 +56,12 @@ const PLATFORM_METADATA: Record<StablePlatformKey, { buttonLabel: string; label:
|
||||
label: 'macOS Intel',
|
||||
},
|
||||
'linux-x86_64': {
|
||||
buttonLabel: 'Download Tolaria for Linux',
|
||||
label: 'Linux',
|
||||
buttonLabel: 'Download Tolaria AppImage for Linux',
|
||||
label: 'Linux AppImage',
|
||||
},
|
||||
'linux-x86_64-rpm': {
|
||||
buttonLabel: 'Download Tolaria RPM for Linux',
|
||||
label: 'Linux RPM',
|
||||
},
|
||||
'windows-x86_64': {
|
||||
buttonLabel: 'Download Tolaria for Windows',
|
||||
@@ -71,6 +77,7 @@ const PLATFORM_ORDER: StablePlatformKey[] = [
|
||||
'darwin-x86_64',
|
||||
'windows-x86_64',
|
||||
'linux-x86_64',
|
||||
'linux-x86_64-rpm',
|
||||
]
|
||||
|
||||
const REDIRECT_PAGE_STYLES = `
|
||||
@@ -226,9 +233,19 @@ function extractPlatformDownloadUrl(
|
||||
)
|
||||
case 'linux-x86_64':
|
||||
return normalizeUrl(payload.download_url) ?? normalizeUrl(payload.url)
|
||||
case 'linux-x86_64-rpm':
|
||||
return normalizeUrl(payload.rpm_url)
|
||||
}
|
||||
}
|
||||
|
||||
function getPlatformPayload(
|
||||
platform: StablePlatformKey,
|
||||
platforms: NonNullable<LatestReleasePayload['platforms']>,
|
||||
): PlatformPayload | undefined {
|
||||
const payloadKey = platform === 'linux-x86_64-rpm' ? 'linux-x86_64' : platform
|
||||
return Reflect.get(platforms, payloadKey) as PlatformPayload | undefined
|
||||
}
|
||||
|
||||
export function extractStableDownloadTargets(payload: unknown): StableDownloadTargets {
|
||||
if (!payload || typeof payload !== 'object') return {}
|
||||
|
||||
@@ -237,7 +254,7 @@ export function extractStableDownloadTargets(payload: unknown): StableDownloadTa
|
||||
|
||||
const downloads: StableDownloadTargets = {}
|
||||
for (const platform of PLATFORM_ORDER) {
|
||||
const platformPayload = Reflect.get(platforms, platform) as PlatformPayload | undefined
|
||||
const platformPayload = getPlatformPayload(platform, platforms)
|
||||
const url = extractPlatformDownloadUrl(platform, platformPayload)
|
||||
if (url) Reflect.set(downloads, platform, buildStableDownloadTarget(platform, url))
|
||||
}
|
||||
@@ -282,6 +299,9 @@ function classifyReleaseAsset(name: string): {
|
||||
if (name.endsWith('.AppImage')) {
|
||||
return { platform: 'linux-x86_64', preference: 2 }
|
||||
}
|
||||
if (name.endsWith('.rpm')) {
|
||||
return { platform: 'linux-x86_64-rpm', preference: 1 }
|
||||
}
|
||||
if (name.endsWith('.deb')) {
|
||||
return { platform: 'linux-x86_64', preference: 1 }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user