MCPcopy Create free account
hub / github.com/Noumena-Network/code / installVersionFromPackage

Function installVersionFromPackage

src/utils/nativeInstaller/installer.ts:328–371  ·  view source on GitHub ↗
(
  stagingPath: string,
  installPath: string,
)

Source from the content-addressed store, hash-verified

326}
327
328async 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
373async function installVersionFromBinary(
374 stagingPath: string,

Callers 1

installVersionFunction · 0.85

Calls 8

getPlatformFunction · 0.85
statFunction · 0.85
atomicMoveToInstallPathFunction · 0.85
rmFunction · 0.85
logEventFunction · 0.50
errorMessageFunction · 0.50
logErrorFunction · 0.50
toErrorFunction · 0.50

Tested by

no test coverage detected