( executableName, repo, assetNameCallback, binaryNameInArchive, isJaeger = false, )
| 161 | } |
| 162 | |
| 163 | export async function ensureBinary( |
| 164 | executableName, |
| 165 | repo, |
| 166 | assetNameCallback, |
| 167 | binaryNameInArchive, |
| 168 | isJaeger = false, |
| 169 | ) { |
| 170 | const executablePath = path.join(BIN_DIR, executableName); |
| 171 | if (fileExists(executablePath)) { |
| 172 | console.log(`✅ ${executableName} already exists at ${executablePath}`); |
| 173 | return executablePath; |
| 174 | } |
| 175 | |
| 176 | console.log(`🔍 ${executableName} not found. Downloading from ${repo}...`); |
| 177 | |
| 178 | const platform = process.platform === 'win32' ? 'windows' : process.platform; |
| 179 | const arch = process.arch === 'x64' ? 'amd64' : process.arch; |
| 180 | const ext = platform === 'windows' ? 'zip' : 'tar.gz'; |
| 181 | |
| 182 | if (isJaeger && platform === 'windows' && arch === 'arm64') { |
| 183 | console.warn( |
| 184 | `⚠️ Jaeger does not have a release for Windows on ARM64. Skipping.`, |
| 185 | ); |
| 186 | return null; |
| 187 | } |
| 188 | |
| 189 | let release; |
| 190 | let asset; |
| 191 | |
| 192 | if (isJaeger) { |
| 193 | console.log(`🔍 Finding latest Jaeger v2+ asset...`); |
| 194 | const releases = getJson(`https://api.github.com/repos/${repo}/releases`); |
| 195 | const sortedReleases = releases |
| 196 | .filter((r) => !r.prerelease && r.tag_name.startsWith('v')) |
| 197 | .sort((a, b) => { |
| 198 | const aVersion = a.tag_name.substring(1).split('.').map(Number); |
| 199 | const bVersion = b.tag_name.substring(1).split('.').map(Number); |
| 200 | for (let i = 0; i < Math.max(aVersion.length, bVersion.length); i++) { |
| 201 | if ((aVersion[i] || 0) > (bVersion[i] || 0)) return -1; |
| 202 | if ((aVersion[i] || 0) < (bVersion[i] || 0)) return 1; |
| 203 | } |
| 204 | return 0; |
| 205 | }); |
| 206 | |
| 207 | for (const r of sortedReleases) { |
| 208 | const expectedSuffix = |
| 209 | platform === 'windows' |
| 210 | ? `-${platform}-${arch}.zip` |
| 211 | : `-${platform}-${arch}.tar.gz`; |
| 212 | const foundAsset = r.assets.find( |
| 213 | (a) => |
| 214 | a.name.startsWith('jaeger-2.') && a.name.endsWith(expectedSuffix), |
| 215 | ); |
| 216 | |
| 217 | if (foundAsset) { |
| 218 | release = r; |
| 219 | asset = foundAsset; |
| 220 | console.log( |
no test coverage detected