mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-02-28 14:01:32 -05:00
feat(client): add recommended os to exam download link (#64078)
This commit is contained in:
@@ -292,6 +292,14 @@ function ShowExamDownload({
|
||||
.filter(link => !link.match(/\.sig|\.json/))
|
||||
.map((link, index) => {
|
||||
const urlEnd = link.split('/').pop() ?? '';
|
||||
// App naming scheme is <app_name>_<version>?_<arch>(-setup)?(-debug)?.<ext>
|
||||
const urlParts = urlEnd.split('_');
|
||||
const archAndExt = urlParts.at(urlParts.length - 1);
|
||||
const arch = archAndExt?.split('-')?.at(0);
|
||||
const ext = archAndExt?.slice(archAndExt?.indexOf('.'));
|
||||
|
||||
const recommendedOs =
|
||||
arch && ext ? getRecommendedOs({ arch, ext }) : '';
|
||||
return (
|
||||
<MenuItem
|
||||
href={link}
|
||||
@@ -299,7 +307,7 @@ function ShowExamDownload({
|
||||
key={index}
|
||||
variant='primary'
|
||||
>
|
||||
{urlEnd}
|
||||
{urlEnd} {recommendedOs && `(${recommendedOs})`}
|
||||
</MenuItem>
|
||||
);
|
||||
})}
|
||||
@@ -318,6 +326,40 @@ function ShowExamDownload({
|
||||
);
|
||||
}
|
||||
|
||||
function getRecommendedOs({
|
||||
arch,
|
||||
ext
|
||||
}: {
|
||||
arch: string;
|
||||
ext: string;
|
||||
}): string {
|
||||
switch (arch) {
|
||||
case 'x64':
|
||||
switch (ext) {
|
||||
case '.dmg':
|
||||
return 'x64 MacOS';
|
||||
case '.AppImage':
|
||||
case '.app.tar.gz':
|
||||
return 'x64 Linux';
|
||||
default:
|
||||
return 'x64 Windows';
|
||||
}
|
||||
case 'aarch64':
|
||||
switch (ext) {
|
||||
case '.dmg':
|
||||
return 'ARM MacOS';
|
||||
case '.app.tar.gz':
|
||||
return 'ARM Linux';
|
||||
default:
|
||||
return 'ARM Windows';
|
||||
}
|
||||
case 'amd64':
|
||||
return 'x64 Linux';
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
function getLatest(releases: GitProps[]): GitProps {
|
||||
switch (deploymentEnv) {
|
||||
case 'staging':
|
||||
|
||||
Reference in New Issue
Block a user