-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.ps1
More file actions
149 lines (127 loc) · 5.41 KB
/
install.ps1
File metadata and controls
149 lines (127 loc) · 5.41 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
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
# ============================================================
# Console Error Scanner - Installer (PowerShell)
#
# Verwendung:
# irm https://raw.githubusercontent.com/michaelblaess/console-error-scanner/main/install.ps1 | iex
#
# Laedt das neueste Release von GitHub herunter und installiert es.
# Keine Abhaengigkeiten noetig (kein Python, kein Git, kein Chrome).
#
# Installiert nach: %LOCALAPPDATA%\console-error-scanner\
# Erstellt Wrapper: %LOCALAPPDATA%\console-error-scanner\bin\console-error-scanner.cmd
# ============================================================
$ErrorActionPreference = "Stop"
$Repo = "michaelblaess/console-error-scanner"
$InstallDir = Join-Path $env:LOCALAPPDATA "console-error-scanner"
$BinDir = Join-Path $InstallDir "bin"
$Wrapper = Join-Path $BinDir "console-error-scanner.cmd"
Write-Host ""
Write-Host " +================================================+" -ForegroundColor Cyan
Write-Host " | Console Error Scanner - Installer |" -ForegroundColor Cyan
Write-Host " +================================================+" -ForegroundColor Cyan
Write-Host ""
# --- Architektur erkennen ---
$Arch = if ([Environment]::Is64BitOperatingSystem) { "x64" } else { "x86" }
Write-Host " Plattform: Windows ($Arch)"
Write-Host ""
# --- Neuestes Release von GitHub ermitteln ---
Write-Host " Suche neuestes Release..."
$ApiUrl = "https://api.github.com/repos/${Repo}/releases/latest"
try {
$Release = Invoke-RestMethod -Uri $ApiUrl -UseBasicParsing
} catch {
Write-Host " [FEHLER] Konnte GitHub API nicht erreichen." -ForegroundColor Red
Write-Host " Pruefe deine Internetverbindung."
exit 1
}
# Download-URL finden (versionsunabhaengig per Teilstring)
$Asset = $Release.assets |
Where-Object { $_.name -like '*-windows-*.zip' } |
Select-Object -First 1
if (-not $Asset) {
Write-Host " [FEHLER] Kein Windows-Asset im Release gefunden!" -ForegroundColor Red
Write-Host ""
Write-Host " Verfuegbare Assets:"
$Release.assets | ForEach-Object { Write-Host " $($_.name)" }
Write-Host ""
Write-Host " Moeglicherweise gibt es noch kein Release fuer deine Plattform."
exit 1
}
$DownloadUrl = $Asset.browser_download_url
$Archive = $Asset.name
$Version = $Release.tag_name
Write-Host " [OK] Release gefunden: $Version" -ForegroundColor Green
Write-Host ""
# --- Download ---
$TmpDir = Join-Path $env:TEMP "console-error-scanner-install"
if (Test-Path $TmpDir) { Remove-Item -Recurse -Force $TmpDir }
New-Item -ItemType Directory -Path $TmpDir -Force | Out-Null
$TmpFile = Join-Path $TmpDir $Archive
Write-Host " Lade herunter: $Archive"
try {
Invoke-WebRequest -Uri $DownloadUrl -OutFile $TmpFile -UseBasicParsing
} catch {
# Fallback fuer aeltere PowerShell
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
(New-Object System.Net.WebClient).DownloadFile($DownloadUrl, $TmpFile)
}
Write-Host " [OK] Download abgeschlossen" -ForegroundColor Green
Write-Host ""
# --- Entpacken ---
Write-Host " Entpacke nach: $InstallDir"
# Alte Installation sichern
if (Test-Path $InstallDir) {
$BackupDir = "${InstallDir}.bak"
if (Test-Path $BackupDir) { Remove-Item -Recurse -Force $BackupDir }
# bin-Ordner behalten (PATH-Eintrag)
Rename-Item -Path $InstallDir -NewName "$($InstallDir).bak"
}
New-Item -ItemType Directory -Path $InstallDir -Force | Out-Null
Expand-Archive -Path $TmpFile -DestinationPath $InstallDir -Force
Remove-Item -Recurse -Force $TmpDir
# Alte Sicherung entfernen
$BackupDir = "${InstallDir}.bak"
if (Test-Path $BackupDir) { Remove-Item -Recurse -Force $BackupDir }
Write-Host " [OK] Entpackt" -ForegroundColor Green
Write-Host ""
# --- Wrapper erstellen ---
New-Item -ItemType Directory -Path $BinDir -Force | Out-Null
$ExePath = Join-Path $InstallDir "console-error-scanner.exe"
$BrowsersDir = Join-Path $InstallDir "browsers"
$WrapperContent = @"
@echo off
REM Console Error Scanner - Wrapper (automatisch generiert)
if exist "$BrowsersDir" set PLAYWRIGHT_BROWSERS_PATH=$BrowsersDir
"$ExePath" %*
"@
Set-Content -Path $Wrapper -Value $WrapperContent -Encoding ASCII
Write-Host " [OK] Wrapper erstellt" -ForegroundColor Green
# --- PATH pruefen und ergaenzen ---
$UserPath = [Environment]::GetEnvironmentVariable("Path", "User")
if ($UserPath -notlike "*$BinDir*") {
Write-Host ""
Write-Host " Fuege zum PATH hinzu: $BinDir" -ForegroundColor Yellow
[Environment]::SetEnvironmentVariable("Path", "$BinDir;$UserPath", "User")
$env:Path = "$BinDir;$env:Path"
Write-Host " [OK] PATH aktualisiert" -ForegroundColor Green
}
# --- Fertig ---
Write-Host ""
Write-Host " +================================================+" -ForegroundColor Green
Write-Host " | Installation abgeschlossen! ($Version)" -ForegroundColor Green
Write-Host " +================================================+" -ForegroundColor Green
Write-Host ""
Write-Host " Starten mit:"
Write-Host " console-error-scanner URL" -ForegroundColor Cyan
Write-Host ""
Write-Host " Beispiel:"
Write-Host " console-error-scanner https://example.com" -ForegroundColor Cyan
Write-Host ""
Write-Host " Aktualisieren:"
Write-Host " Installer erneut ausfuehren." -ForegroundColor Gray
Write-Host ""
Write-Host " Deinstallieren:" -ForegroundColor Gray
Write-Host " Remove-Item -Recurse '$InstallDir'" -ForegroundColor Gray
Write-Host ""
Write-Host " HINWEIS: Oeffne ein neues Terminal, damit der PATH wirkt." -ForegroundColor Yellow
Write-Host ""