feat(natives): added native addon distribution and platform validation to CLI update mechanism
- Added native addon distribution and installation support to the CLI update mechanism, enabling platform-specific native modules to be downloaded and installed alongside the main binary. - Added platform validation in native addon loader to verify supported platforms (linux-x64, linux-arm64, darwin-x64, darwin-arm64, win32-x64) with helpful error messages for unsupported configurations. - Enhanced native addon loading error messages to provide platform-specific troubleshooting guidance for both npm/bun installations and local development environments. - Updated installation scripts (install.sh, install.ps1) to download and install native addon files alongside the main binary during CLI installation.
This commit is contained in:
+13
-5
@@ -20,6 +20,7 @@ $Repo = "can1357/oh-my-pi"
|
||||
$Package = "@oh-my-pi/pi-coding-agent"
|
||||
$InstallDir = if ($env:OMP_INSTALL_DIR) { $env:OMP_INSTALL_DIR } else { "$env:LOCALAPPDATA\omp" }
|
||||
$BinaryName = "omp-windows-x64.exe"
|
||||
$NativeAddonName = "pi_natives.win32-x64.node"
|
||||
$MinimumBunVersion = "1.3.7"
|
||||
|
||||
function Test-BunInstalled {
|
||||
@@ -254,16 +255,23 @@ function Install-Binary {
|
||||
}
|
||||
Write-Host "Using version: $Latest"
|
||||
|
||||
# Download binary
|
||||
$Url = "https://github.com/$Repo/releases/download/$Latest/$BinaryName"
|
||||
Write-Host "Downloading $BinaryName..."
|
||||
|
||||
New-Item -ItemType Directory -Force -Path $InstallDir | Out-Null
|
||||
|
||||
# Download binary
|
||||
$BinaryUrl = "https://github.com/$Repo/releases/download/$Latest/$BinaryName"
|
||||
Write-Host "Downloading $BinaryName..."
|
||||
$OutPath = Join-Path $InstallDir "omp.exe"
|
||||
Invoke-WebRequest -Uri $Url -OutFile $OutPath
|
||||
Invoke-WebRequest -Uri $BinaryUrl -OutFile $OutPath
|
||||
|
||||
# Download native addon
|
||||
$NativeUrl = "https://github.com/$Repo/releases/download/$Latest/$NativeAddonName"
|
||||
Write-Host "Downloading $NativeAddonName..."
|
||||
$NativeOutPath = Join-Path $InstallDir $NativeAddonName
|
||||
Invoke-WebRequest -Uri $NativeUrl -OutFile $NativeOutPath
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "✓ Installed omp to $OutPath" -ForegroundColor Green
|
||||
Write-Host "✓ Installed native addon to $NativeOutPath" -ForegroundColor Green
|
||||
|
||||
# Add to PATH if not already there
|
||||
$UserPath = [Environment]::GetEnvironmentVariable("Path", "User")
|
||||
|
||||
Reference in New Issue
Block a user