feat: add local binary support to Windows installer

This commit is contained in:
Gu1llaum-3 2025-09-03 18:12:01 +02:00
parent 20bc506e36
commit 21c5d41977

View File

@ -1,9 +1,12 @@
# SSHM Windows Installation Script
# Usage: irm https://raw.githubusercontent.com/Gu1llaum-3/sshm/main/install/windows.ps1 | iex
# Usage:
# Online: irm https://raw.githubusercontent.com/Gu1llaum-3/sshm/main/install/windows.ps1 | iex
# Local: .\install\windows.ps1 -LocalBinary ".\sshm.exe"
param(
[string]$InstallDir = "$env:USERPROFILE\bin",
[switch]$Force = $false
[string]$InstallDir = "$env:LOCALAPPDATA\sshm",
[switch]$Force = $false,
[string]$LocalBinary = ""
)
$ErrorActionPreference = "Stop"
@ -41,14 +44,38 @@ if ($existingSSHM -and -not $Force) {
$arch = if ([Environment]::Is64BitOperatingSystem) { "amd64" } else { "386" }
Write-Info "Detected platform: Windows ($arch)"
# Check if using local binary
if ($LocalBinary -ne "") {
if (-not (Test-Path $LocalBinary)) {
Write-Error "Local binary not found: $LocalBinary"
exit 1
}
Write-Info "Using local binary: $LocalBinary"
$targetPath = "$InstallDir\sshm.exe"
# Create installation directory
if (-not (Test-Path $InstallDir)) {
Write-Info "Creating installation directory: $InstallDir"
New-Item -ItemType Directory -Path $InstallDir -Force | Out-Null
}
# Copy local binary
Write-Info "Installing binary to: $targetPath"
Copy-Item -Path $LocalBinary -Destination $targetPath -Force
} else {
# Online installation
Write-Info "Starting online installation..."
# Get latest version
Write-Info "Fetching latest version..."
try {
$latestRelease = Invoke-RestMethod -Uri "https://api.github.com/repos/Gu1llaum-3/sshm/releases/latest"
$latestVersion = $latestRelease.tag_name
Write-Info "Latest version: $latestVersion"
Write-Info "Target version: $latestVersion"
} catch {
Write-Error "Failed to fetch latest version"
Write-Error "Failed to fetch version information"
exit 1
}
@ -85,6 +112,7 @@ try {
# Clean up
Remove-Item $tempFile -Force
}
# Check PATH
$userPath = [Environment]::GetEnvironmentVariable("Path", "User")