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