-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathinstall.ps1
More file actions
53 lines (44 loc) · 2.07 KB
/
install.ps1
File metadata and controls
53 lines (44 loc) · 2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# Check for admin privileges
$IsAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")
if (-not $IsAdmin) {
Write-Host "`n❌ Please run this script as Administrator.`n" -ForegroundColor Red
Write-Host "Right-click on PowerShell and select 'Run as administrator'."
Write-Host "`nPress any key to exit..."
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
exit 1
}
$repo = "iamngoni/gitwhisper"
$apiUrl = "https://api.github.com/repos/$repo/releases/latest"
# Get latest version tag
try {
Write-Host "📡 Fetching latest release..."
$headers = @{ 'User-Agent' = 'gitwhisper-installer' }
$latest = Invoke-RestMethod -Uri $apiUrl -Headers $headers
$version = $latest.tag_name
Write-Host "📦 Latest version: $version"
} catch {
Write-Error "❌ Failed to fetch latest release."
exit 1
}
$downloadUrl = "https://github.com/$repo/releases/download/$version/gitwhisper-windows.tar.gz"
$tmpDir = "$env:TEMP\gitwhisper-install"
$installDir = "$env:ProgramFiles\GitWhisper"
Write-Host "⬇️ Downloading GitWhisper $version..."
# Prepare install dirs
if (Test-Path $tmpDir) { Remove-Item $tmpDir -Recurse -Force }
New-Item -ItemType Directory -Path $tmpDir | Out-Null
New-Item -ItemType Directory -Force -Path $installDir | Out-Null
# Download + extract
Invoke-WebRequest -Uri $downloadUrl -OutFile "$tmpDir\gitwhisper.tar.gz"
tar -xzf "$tmpDir\gitwhisper.tar.gz" -C $tmpDir
# Move binaries
Move-Item "$tmpDir\gitwhisper.exe" "$installDir\gitwhisper.exe" -Force
Copy-Item "$installDir\gitwhisper.exe" "$installDir\gw.exe" -Force
# Update system PATH if not already added
$envPath = [Environment]::GetEnvironmentVariable("Path", [EnvironmentVariableTarget]::Machine)
if ($envPath -notlike "*$installDir*") {
[Environment]::SetEnvironmentVariable("Path", "$envPath;$installDir", [EnvironmentVariableTarget]::Machine)
Write-Host "🔧 Added $installDir to system PATH."
}
Write-Host "✅ Installed gitwhisper and gw to $installDir"
& "$installDir\gitwhisper.exe" --version