( stagingPath: string, installPath: string, )
| 326 | } |
| 327 | |
| 328 | async function installVersionFromPackage( |
| 329 | stagingPath: string, |
| 330 | installPath: string, |
| 331 | ) { |
| 332 | try { |
| 333 | // Extract binary from npm package structure in staging |
| 334 | const platform = getPlatform() |
| 335 | const platformPackageName = `${MACRO.NATIVE_PACKAGE_URL}-${platform}` |
| 336 | const nativePackageDir = join(stagingPath, 'node_modules', platformPackageName) |
| 337 | const stagedBinaryPath = join(nativePackageDir, 'cli') |
| 338 | |
| 339 | try { |
| 340 | await stat(stagedBinaryPath) |
| 341 | } catch { |
| 342 | logEvent('ncode_native_install_package_failure', { |
| 343 | stage_binary_exists: true, |
| 344 | error_binary_not_found: true, |
| 345 | }) |
| 346 | const error = new Error('Native binary not found in staged package') |
| 347 | throw error |
| 348 | } |
| 349 | |
| 350 | await atomicMoveToInstallPath(stagedBinaryPath, installPath) |
| 351 | |
| 352 | // Clean up staging directory |
| 353 | await rm(stagingPath, { recursive: true, force: true }) |
| 354 | |
| 355 | logEvent('ncode_native_install_package_success', {}) |
| 356 | } catch (error) { |
| 357 | // Log if not already logged above |
| 358 | const msg = errorMessage(error) |
| 359 | if ( |
| 360 | !msg.includes('Could not find platform-specific') && |
| 361 | !msg.includes('Native binary not found') |
| 362 | ) { |
| 363 | logEvent('ncode_native_install_package_failure', { |
| 364 | stage_atomic_move: true, |
| 365 | error_move_failed: true, |
| 366 | }) |
| 367 | } |
| 368 | logError(toError(error)) |
| 369 | throw error |
| 370 | } |
| 371 | } |
| 372 | |
| 373 | async function installVersionFromBinary( |
| 374 | stagingPath: string, |
no test coverage detected