-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.ps1
More file actions
85 lines (72 loc) · 3.97 KB
/
Copy pathinstall.ps1
File metadata and controls
85 lines (72 loc) · 3.97 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# GitIntel AI — Windows installer (PowerShell)
# https://github.com/gitintel-ai/GitIntelAI
#
# Usage:
# irm https://gitintel.com/install.ps1 | iex
# irm https://raw.githubusercontent.com/gitintel-ai/GitIntelAI/main/install.ps1 | iex
#
# Options (env vars):
# $env:GITINTEL_INSTALL_DIR — destination directory (default: $env:LOCALAPPDATA\gitintel\bin)
# $env:GITINTEL_VERSION — pin a specific release tag (default: latest)
$ErrorActionPreference = 'Stop'
$Repo = 'gitintel-ai/GitIntelAI'
$BinName = 'gitintel.exe'
$InstallDir = if ($env:GITINTEL_INSTALL_DIR) { $env:GITINTEL_INSTALL_DIR } else { "$env:LOCALAPPDATA\gitintel\bin" }
# ── Detect architecture ────────────────────────────────────────────────────────
$Arch = switch ($env:PROCESSOR_ARCHITECTURE) {
'AMD64' { 'amd64' }
'ARM64' { 'arm64' }
default {
Write-Error "Unsupported architecture: $env:PROCESSOR_ARCHITECTURE. Please build from source."
exit 1
}
}
$Artifact = "gitintel-windows-$Arch.exe"
# ── Resolve version ────────────────────────────────────────────────────────────
if ($env:GITINTEL_VERSION) {
$Version = $env:GITINTEL_VERSION
} else {
Write-Host "Fetching latest release..." -NoNewline
try {
$Release = Invoke-RestMethod "https://api.github.com/repos/$Repo/releases/latest" -Headers @{ 'User-Agent' = 'gitintel-installer' }
$Version = $Release.tag_name
Write-Host " $Version"
} catch {
Write-Error "Could not determine latest version: $_`nCheck https://github.com/$Repo/releases"
exit 1
}
}
$DownloadUrl = "https://github.com/$Repo/releases/download/$Version/$Artifact"
# ── Download ───────────────────────────────────────────────────────────────────
Write-Host "Downloading gitintel $Version for windows/$Arch..."
$TmpFile = [System.IO.Path]::GetTempFileName() + '.exe'
try {
Invoke-WebRequest $DownloadUrl -OutFile $TmpFile -UseBasicParsing
} catch {
Write-Error "Download failed: $_`nURL: $DownloadUrl`nCheck https://github.com/$Repo/releases"
exit 1
}
# ── Install ────────────────────────────────────────────────────────────────────
if (-not (Test-Path $InstallDir)) {
New-Item -ItemType Directory -Path $InstallDir -Force | Out-Null
}
$Dest = Join-Path $InstallDir $BinName
Move-Item -Force $TmpFile $Dest
Write-Host ""
Write-Host " v Installed: $Dest ($Version)" -ForegroundColor Green
# ── PATH check ─────────────────────────────────────────────────────────────────
$UserPath = [System.Environment]::GetEnvironmentVariable('Path', 'User')
if ($UserPath -notlike "*$InstallDir*") {
Write-Host ""
Write-Host " ! $InstallDir is not in your PATH." -ForegroundColor Yellow
Write-Host " Adding it now..."
[System.Environment]::SetEnvironmentVariable('Path', "$UserPath;$InstallDir", 'User')
$env:Path += ";$InstallDir"
Write-Host " v Added to PATH (restart your terminal to take effect)" -ForegroundColor Green
}
# ── Done ───────────────────────────────────────────────────────────────────────
Write-Host ""
Write-Host " Run 'gitintel --version' to verify."
Write-Host " Run 'gitintel init' inside a git repo to get started."
Write-Host " Docs: https://gitintel.com/docs/getting-started"
Write-Host ""