-
Notifications
You must be signed in to change notification settings - Fork 1
/
getLatestRelease.ts
39 lines (37 loc) · 1.2 KB
/
getLatestRelease.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import axios from 'axios'
import { URL_RELEASE_BASE } from './constants'
import { getBrowserOs } from '@/getBrowserOs'
type Release = {
platform: String
releaseUrl: String
downloadName: String
}
export async function getLatestRelease(navigator: any): Promise<Release> {
return await axios.get(URL_RELEASE_BASE).then(async (result: any) => {
const os = await getBrowserOs(navigator).toLowerCase()
const macRelease = await result.data.assets.find((asset: any) => {
return asset.browser_download_url.includes('myWitWallet.dmg')
})
const linuxRelease = await result.data.assets.find((asset: any) =>
asset.browser_download_url.includes('linux.tar.gz')
)
const release: Record<string, Release> = {
linux: {
platform: 'GNU / Linux',
releaseUrl: linuxRelease.browser_download_url,
downloadName: linuxRelease.name,
},
win: {
platform: 'Windows',
releaseUrl: 'https://apps.microsoft.com/detail/9PN09DKWPL57',
downloadName: 'myWitWallet',
},
mac: {
platform: 'Mac OS',
releaseUrl: macRelease.browser_download_url,
downloadName: macRelease.name,
},
}
return release[os]
})
}