Repository navigation
Expand file tree
/
Copy pathinstall.ps1
More file actions
62 lines (49 loc) · 2.28 KB
/
Copy pathinstall.ps1
File metadata and controls
62 lines (49 loc) · 2.28 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
# BramandScript Windows PowerShell Installer
# Usage: irm https://raw.githubusercontent.com/Codeleafly/bramandScript/main/install.ps1 | iex
$ErrorActionPreference = 'Stop'
$Repo = "Codeleafly/bramandScript"
Write-Host "✦ [INFO] Detecting Windows Architecture..." -ForegroundColor Cyan
$Arch = "amd64"
if ($env:PROCESSOR_ARCHITECTURE -eq "ARM64") {
$Arch = "arm64"
}
$InstallDir = "$HOME\.bramand\bin"
if (!(Test-Path $InstallDir)) {
New-Item -ItemType Directory -Path $InstallDir -Force | Out-Null
}
Write-Host "✦ [INFO] Fetching latest release from GitHub ($Repo)..." -ForegroundColor Cyan
try {
$Release = Invoke-RestMethod -Uri "https://api.github.com/repos/$Repo/releases/latest"
$Tag = $Release.tag_name
} catch {
$Tag = "v0.1.2"
}
$ArchiveName = "bramand-windows-$Arch-$Tag.zip"
$DownloadUrl = "https://github.com/$Repo/releases/download/$Tag/$ArchiveName"
$TempZip = "$env:TEMP\$ArchiveName"
Write-Host "✦ [INFO] Downloading $DownloadUrl..." -ForegroundColor Cyan
try {
Invoke-WebRequest -Uri $DownloadUrl -OutFile $TempZip
Expand-Archive -Path $TempZip -DestinationPath $InstallDir -Force
Remove-Item -Path $TempZip -Force
# Ensure alias copy
Copy-Item -Path "$InstallDir\bramand.exe" -Destination "$InstallDir\bmd.exe" -Force
} catch {
Write-Warning "Could not download pre-compiled binary. Checking local Go installation..."
if (Get-Command go -ErrorAction SilentlyContinue) {
Write-Host "✦ [INFO] Compiling native Windows binary using Go..." -ForegroundColor Cyan
go build -ldflags="-s -w" -o "$InstallDir\bramand.exe" main.go
Copy-Item -Path "$InstallDir\bramand.exe" -Destination "$InstallDir\bmd.exe" -Force
} else {
Write-Error "Failed to install BramandScript. Please install Go or download binaries from https://github.com/$Repo/releases"
}
}
# Add to User PATH if not present
$UserPath = [Environment]::GetEnvironmentVariable("Path", "User")
if ($UserPath -notlike "*$InstallDir*") {
[Environment]::SetEnvironmentVariable("Path", "$InstallDir;$UserPath", "User")
$env:Path = "$InstallDir;$env:Path"
}
Write-Host "[OK] BramandScript successfully installed to $InstallDir!" -ForegroundColor Green
Write-Host " Commands: 'bramand', 'bmd'" -ForegroundColor Green
& "$InstallDir\bmd.exe" version