-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.ps1
More file actions
89 lines (72 loc) · 2.75 KB
/
Copy pathinstall.ps1
File metadata and controls
89 lines (72 loc) · 2.75 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
86
87
88
89
# VectorCode installer for Windows
# Usage: irm https://raw.githubusercontent.com/alejandro-technology/vectorcode/main/install.ps1 | iex
$ErrorActionPreference = "Stop"
$Repo = "alejandro-technology/vectorcode"
$BinaryName = "vectorcode"
$InstallDir = Join-Path $env:LOCALAPPDATA "vectorcode\bin"
function Write-Info($msg) {
Write-Host "✓ " -ForegroundColor Green -NoNewline
Write-Host $msg
}
function Write-Warn($msg) {
Write-Host "⚠ " -ForegroundColor Yellow -NoNewline
Write-Host $msg
}
function Write-Err($msg) {
Write-Host "✗ " -ForegroundColor Red -NoNewline
Write-Host $msg
exit 1
}
function Get-Arch {
$arch = [System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture
switch ($arch) {
"X64" { return "x86_64" }
"Arm64" { return "arm64" }
default { Write-Err "Unsupported architecture: $arch" }
}
}
function Install-Binary {
$arch = Get-Arch
$zipName = "${BinaryName}-windows-${arch}.zip"
$url = "https://github.com/${Repo}/releases/latest/download/${zipName}"
Write-Info "Downloading VectorCode for Windows/$arch..."
$tempDir = Join-Path $env:TEMP "vectorcode-install-$(Get-Random)"
New-Item -ItemType Directory -Path $tempDir -Force | Out-Null
try {
$zipPath = Join-Path $tempDir $zipName
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Invoke-WebRequest -Uri $url -OutFile $zipPath -UseBasicParsing
} catch {
Write-Err "Failed to download: $_. Check https://github.com/${Repo}/releases for available releases."
}
# Create install directory
if (-not (Test-Path $InstallDir)) {
New-Item -ItemType Directory -Path $InstallDir -Force | Out-Null
}
# Extract
Write-Info "Extracting to $InstallDir..."
Expand-Archive -Path $zipPath -DestinationPath $InstallDir -Force
# Verify binary exists
$exePath = Join-Path $InstallDir "${BinaryName}.exe"
if (-not (Test-Path $exePath)) {
Write-Err "Binary not found after extraction at $exePath"
}
# Add to PATH if not already present
$userPath = [Environment]::GetEnvironmentVariable("Path", "User")
if ($userPath -notlike "*$InstallDir*") {
[Environment]::SetEnvironmentVariable("Path", "$userPath;$InstallDir", "User")
Write-Info "Added $InstallDir to user PATH"
} else {
Write-Info "$InstallDir already in PATH"
}
# Cleanup
Remove-Item -Path $tempDir -Recurse -Force
Write-Host ""
Write-Info "VectorCode installed successfully!"
Write-Info "Location: $exePath"
Write-Host ""
Write-Host " Restart your terminal, then run:" -ForegroundColor Cyan
Write-Host " vectorcode init" -ForegroundColor White
Write-Host ""
}
Install-Binary