Γ–ffentliche Dateiansicht: Raw-Dateien, Tree, Releases und Issues sind ohne Login verfΓΌgbar.
install.ps1 Raw
  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
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# install.ps1 β€” Download and install ev from GitHub Releases
#
# Usage:
#   iwr -useb https://raw.githubusercontent.com/adrian-lorenz/ev/main/install.ps1 | iex
#
# Or with a custom install directory:
#   $env:EV_INSTALL_DIR = "C:\tools"; iwr -useb .../install.ps1 | iex

Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"

$Repo      = "adrian-lorenz/ev"
$Binary    = "ev.exe"
$InstallDir = if ($env:EV_INSTALL_DIR) { $env:EV_INSTALL_DIR } else { "$env:LOCALAPPDATA\ev" }

function Info  ($msg) { Write-Host "  [+] $msg" -ForegroundColor Green }
function Warn  ($msg) { Write-Host "  [!] $msg" -ForegroundColor Yellow }
function Fatal ($msg) { Write-Host "  [x] $msg" -ForegroundColor Red; exit 1 }

Write-Host ""
Write-Host "  ev installer" -ForegroundColor Cyan
Write-Host "  ────────────────────────────────────────"

# ── detect architecture ───────────────────────
$arch = (Get-CimInstance Win32_Processor).Architecture
$GoArch = switch ($arch) {
  9  { "amd64" }   # x86_64
  12 { "arm64" }   # ARM64
  default { Fatal "Unsupported architecture: $arch" }
}
Info "Platform: windows/$GoArch"

# ── fetch latest version ──────────────────────
Write-Host ""
Write-Host "  Fetching latest release…"

try {
  $release = Invoke-RestMethod "https://api.github.com/repos/$Repo/releases/latest"
  $version = $release.tag_name
} catch {
  Fatal "Could not reach GitHub API. Check your internet connection."
}

Info "Latest version: $version"

# ── build URLs ───────────────────────────────
$archive      = "ev_windows_${GoArch}.zip"
$downloadUrl  = "https://github.com/$Repo/releases/download/$version/$archive"
$checksumUrl  = "https://github.com/$Repo/releases/download/$version/checksums.txt"

# ── download ──────────────────────────────────
Write-Host ""
Write-Host "  Downloading $archive…"

$tmp = New-TemporaryFile | ForEach-Object { $_.DirectoryName }
$tmpDir = Join-Path $tmp "ev-install-$([System.IO.Path]::GetRandomFileName())"
New-Item -ItemType Directory -Path $tmpDir | Out-Null

$archivePath  = Join-Path $tmpDir $archive
$checksumPath = Join-Path $tmpDir "checksums.txt"

try {
  Invoke-WebRequest -Uri $downloadUrl  -OutFile $archivePath  -UseBasicParsing
  Invoke-WebRequest -Uri $checksumUrl  -OutFile $checksumPath -UseBasicParsing
} catch {
  Fatal "Download failed: $_"
}

Info "Downloaded successfully"

# ── verify checksum ───────────────────────────
Write-Host ""
Write-Host "  Verifying checksum…"

$expected = (Get-Content $checksumPath | Where-Object { $_ -match $archive }) -split '\s+' | Select-Object -First 1
if (-not $expected) {
  Warn "Checksum entry not found β€” skipping verification"
} else {
  $actual = (Get-FileHash -Algorithm SHA256 $archivePath).Hash.ToLower()
  if ($actual -ne $expected.ToLower()) {
    Fatal "Checksum mismatch! Expected $expected, got $actual"
  }
  Info "Checksum OK"
}

# ── extract ───────────────────────────────────
Write-Host ""
Write-Host "  Extracting…"

Expand-Archive -Path $archivePath -DestinationPath $tmpDir -Force
$extracted = Join-Path $tmpDir $Binary
if (-not (Test-Path $extracted)) {
  Fatal "Binary not found in archive: $Binary"
}

# ── install ───────────────────────────────────
Write-Host ""
Write-Host "  Installing to $InstallDir…"

New-Item -ItemType Directory -Force -Path $InstallDir | Out-Null
Copy-Item -Force $extracted (Join-Path $InstallDir $Binary)

# ── add to PATH ───────────────────────────────
$userPath = [Environment]::GetEnvironmentVariable("Path", "User")
if ($userPath -notlike "*$InstallDir*") {
  [Environment]::SetEnvironmentVariable("Path", "$userPath;$InstallDir", "User")
  Warn "Added $InstallDir to your PATH. Restart your terminal to use 'ev'."
} else {
  Info "$InstallDir already in PATH"
}

# ── cleanup ───────────────────────────────────
Remove-Item -Recurse -Force $tmpDir

# ── done ──────────────────────────────────────
Write-Host ""
Write-Host "  ev $version installed!" -ForegroundColor Green
Write-Host ""
Write-Host "  Location : $InstallDir\$Binary"
Write-Host ""
Write-Host "  Get started:"
Write-Host "    ev init"
Write-Host "    ev set MY_SECRET"
Write-Host "    ev run <your-command>"
Write-Host ""
Write-Host "  Web UI:"
Write-Host "    ev manage"
Write-Host ""