aboutsummaryrefslogtreecommitdiff
path: root/bootstrap-win
diff options
context:
space:
mode:
Diffstat (limited to 'bootstrap-win')
-rw-r--r--bootstrap-win/git.ps175
1 files changed, 75 insertions, 0 deletions
diff --git a/bootstrap-win/git.ps1 b/bootstrap-win/git.ps1
new file mode 100644
index 0000000..41a3112
--- /dev/null
+++ b/bootstrap-win/git.ps1
@@ -0,0 +1,75 @@
1#Requires -Version 5.1
2<#
3 Installiert Git und delta (Pager fuer git/config) per winget.
4
5 Aufruf (keine Admin-Rechte noetig):
6 .\bootstrap-win\git.ps1
7#>
8
9$ErrorActionPreference = "Stop"
10$script:Failures = @()
11
12function Write-Ok($msg) {
13 Write-Host "OK $msg" -ForegroundColor Green
14}
15
16function Write-Step($msg) {
17 Write-Host "==> $msg" -ForegroundColor Cyan
18}
19
20function Write-Skip($msg) {
21 Write-Host "- $msg bereits vorhanden" -ForegroundColor DarkGray
22}
23
24function Write-Warn($msg) {
25 Write-Host "! $msg" -ForegroundColor Yellow
26 $script:Failures += $msg
27}
28
29function Test-CommandExists([string]$Name) {
30 return [bool](Get-Command $Name -ErrorAction SilentlyContinue)
31}
32
33function Install-WingetPackage([string]$Binary, [string]$Id) {
34 if (Test-CommandExists $Binary) {
35 Write-Skip $Binary
36 return
37 }
38
39 Write-Step "winget install $Id"
40 $output = winget install --id $Id -e --source winget --accept-package-agreements --accept-source-agreements --silent 2>&1
41
42 if ($LASTEXITCODE -ne 0) {
43 $lastLine = ($output | Select-Object -Last 3) -join " / "
44 Write-Warn "winget install $Id fehlgeschlagen (Binary '$Binary' nicht gefunden): $lastLine -- Pruefen mit: winget search $Id"
45 return
46 }
47
48 Write-Ok $Id
49}
50
51function Test-Prerequisites {
52 if (-not (Test-CommandExists "winget")) {
53 Write-Host "Fehler: winget wurde nicht gefunden. 'App Installer' aus dem Microsoft Store installieren." -ForegroundColor Red
54 exit 1
55 }
56}
57
58function Main {
59 Test-Prerequisites
60
61 Install-WingetPackage -Binary "git" -Id "Git.Git"
62 Install-WingetPackage -Binary "delta" -Id "dandavison.delta"
63
64 Write-Host ""
65 if ($script:Failures.Count -eq 0) {
66 Write-Host "Bootstrap abgeschlossen." -ForegroundColor Green
67 } else {
68 Write-Host "Bootstrap abgeschlossen, mit $($script:Failures.Count) Warnung(en):" -ForegroundColor Yellow
69 foreach ($f in $script:Failures) {
70 Write-Host " - $f" -ForegroundColor Yellow
71 }
72 }
73}
74
75Main