( source: string, identifier: string, pkg: Package, containerName: string )
| 292 | |
| 293 | // Validate a single package |
| 294 | async function validatePackage( |
| 295 | source: string, |
| 296 | identifier: string, |
| 297 | pkg: Package, |
| 298 | containerName: string |
| 299 | ): Promise<boolean> { |
| 300 | // Special handling for script packages |
| 301 | if (source === 'script') { |
| 302 | return validateScriptPackage(pkg); |
| 303 | } |
| 304 | |
| 305 | // Special handling for AUR (uses API, no Docker needed) |
| 306 | if (source === 'aur') { |
| 307 | try { |
| 308 | const response = await fetch( |
| 309 | `https://aur.archlinux.org/rpc/v5/info?arg[]=${encodeURIComponent(identifier)}` |
| 310 | ); |
| 311 | const data = await response.json(); |
| 312 | return data.resultcount === 1; |
| 313 | } catch { |
| 314 | return false; |
| 315 | } |
| 316 | } |
| 317 | |
| 318 | // Special handling for Flatpak (uses API) |
| 319 | if (source === 'flatpak') { |
| 320 | try { |
| 321 | const response = await fetch( |
| 322 | `https://flathub.org/api/v2/appstream/${encodeURIComponent(identifier)}` |
| 323 | ); |
| 324 | return response.ok; |
| 325 | } catch { |
| 326 | return false; |
| 327 | } |
| 328 | } |
| 329 | |
| 330 | // Special handling for Snap (uses API) |
| 331 | if (source === 'snap') { |
| 332 | try { |
| 333 | const response = await fetch( |
| 334 | `https://api.snapcraft.io/v2/snaps/info/${encodeURIComponent(identifier)}`, |
| 335 | { |
| 336 | headers: { |
| 337 | 'Snap-Device-Series': '16', |
| 338 | }, |
| 339 | } |
| 340 | ); |
| 341 | if (!response.ok) return false; |
| 342 | const data = await response.json(); |
| 343 | return data.name === identifier; |
| 344 | } catch { |
| 345 | return false; |
| 346 | } |
| 347 | } |
| 348 | |
| 349 | // Special handling for Homebrew (uses API) |
| 350 | if (source === 'homebrew') { |
| 351 | try { |
no test coverage detected