( platforms: Record<OperatingSystem, Array<DownloadDropdownItem<Platform>>>, exclude: Array<string>, versionWithPrefix: string )
| 46 | * Filters platforms by compatibility and exclusions |
| 47 | */ |
| 48 | const getCompatiblePlatforms = ( |
| 49 | platforms: Record<OperatingSystem, Array<DownloadDropdownItem<Platform>>>, |
| 50 | exclude: Array<string>, |
| 51 | versionWithPrefix: string |
| 52 | ) => { |
| 53 | return Object.entries(platforms).flatMap(([os, items]) => { |
| 54 | if (exclude.includes(os)) { |
| 55 | return []; |
| 56 | } |
| 57 | |
| 58 | return items |
| 59 | .filter(({ compatibility }) => { |
| 60 | // In the download constants file (apps/site/util/download/constants.json), |
| 61 | // if no compatibility is defined as a semver, we treat it as supporting all |
| 62 | // versions by default. |
| 63 | if (!compatibility.semver) { |
| 64 | return true; |
| 65 | } |
| 66 | |
| 67 | return compatibility.semver.every(version => |
| 68 | semVer.satisfies(versionWithPrefix, version) |
| 69 | ); |
| 70 | }) |
| 71 | .map(platform => ({ |
| 72 | os, |
| 73 | platform, |
| 74 | })) as CompatiblePlatforms; |
| 75 | }); |
| 76 | }; |
| 77 | |
| 78 | /** |
| 79 | * Returns a list of compatible artifacts for the given options. |
no outgoing calls
no test coverage detected