1 import { semver } from '@proton/pass/utils/string/semver';
2 import { RELEASE_CATEGORIES } from '@proton/shared/lib/constants';
3 import { type DesktopVersion } from '@proton/shared/lib/desktop/DesktopVersion';
5 export const getLatestRelease = (currentEnvironment: string | undefined, releaseList: DesktopVersion[]) => {
6 let latestRelease = undefined;
7 let latestReleaseSemver = 0;
9 for (const release of releaseList) {
10 const releaseSemver = semver(release.Version);
12 if (release.CategoryName === RELEASE_CATEGORIES.ALPHA && currentEnvironment !== 'alpha') {
17 release.CategoryName === RELEASE_CATEGORIES.EARLY_ACCESS &&
18 currentEnvironment !== 'alpha' &&
19 currentEnvironment !== 'beta'
24 if (releaseSemver > latestReleaseSemver) {
25 latestRelease = release;
26 latestReleaseSemver = releaseSemver;