Created
March 14, 2026 12:52
-
-
Save kntjspr/784bee2f25c3f9710fea0a27f313d489 to your computer and use it in GitHub Desktop.
installs choco, python, git and others
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Requires -RunAsAdministrator | |
| <# | |
| .SYNOPSIS | |
| One-shot dev environment bootstrap: Chocolatey, Git, Python, uv, Node.js | |
| .DESCRIPTION | |
| Idempotent. Safe to re-run. Skips anything already installed. | |
| Run in an elevated PowerShell session. | |
| #> | |
| Set-StrictMode -Version Latest | |
| $ErrorActionPreference = 'Stop' | |
| # ── Helpers ──────────────────────────────────────────────────────────────────── | |
| function Write-Step { param($msg) Write-Host "`n==> $msg" -ForegroundColor Cyan } | |
| function Write-Ok { param($msg) Write-Host " [OK] $msg" -ForegroundColor Green } | |
| function Write-Skip { param($msg) Write-Host " [SKIP] $msg" -ForegroundColor Yellow } | |
| function Write-Fail { param($msg) Write-Host " [FAIL] $msg" -ForegroundColor Red } | |
| function Refresh-Path { | |
| $env:Path = [System.Environment]::GetEnvironmentVariable('Path','Machine') + ';' + | |
| [System.Environment]::GetEnvironmentVariable('Path','User') | |
| } | |
| function Command-Exists { param($cmd) return [bool](Get-Command $cmd -ErrorAction SilentlyContinue) } | |
| function Assert-ExitCode { | |
| param($code, $what) | |
| if ($code -ne 0) { throw "$what failed with exit code $code" } | |
| } | |
| # ── 1. Chocolatey ────────────────────────────────────────────────────────────── | |
| Write-Step "Chocolatey" | |
| if (Command-Exists choco) { | |
| Write-Skip "choco already installed ($(choco --version))" | |
| } else { | |
| try { | |
| [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072 | |
| $installScript = (New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1') | |
| Invoke-Expression $installScript | |
| Refresh-Path | |
| if (-not (Command-Exists choco)) { throw "choco binary not found after install" } | |
| Write-Ok "Chocolatey installed ($(choco --version))" | |
| } catch { | |
| Write-Fail "Chocolatey install failed: $_" | |
| exit 1 | |
| } | |
| } | |
| # ── 2. Git ───────────────────────────────────────────────────────────────────── | |
| Write-Step "Git" | |
| if (Command-Exists git) { | |
| Write-Skip "git already installed ($(git --version))" | |
| } else { | |
| choco install git -y --no-progress | |
| Assert-ExitCode $LASTEXITCODE "git install" | |
| Refresh-Path | |
| Write-Ok "Git installed ($(git --version))" | |
| } | |
| # ── 3. Python ────────────────────────────────────────────────────────────────── | |
| Write-Step "Python" | |
| if (Command-Exists python) { | |
| $pyVer = python --version 2>&1 | |
| Write-Skip "python already installed ($pyVer)" | |
| } else { | |
| choco install python -y --no-progress | |
| Assert-ExitCode $LASTEXITCODE "python install" | |
| Refresh-Path | |
| Write-Ok "Python installed ($(python --version 2>&1))" | |
| } | |
| # ── 4. uv ────────────────────────────────────────────────────────────────────── | |
| Write-Step "uv (Astral)" | |
| if (Command-Exists uv) { | |
| Write-Skip "uv already installed ($(uv --version))" | |
| } else { | |
| try { | |
| # Official installer — works without pip | |
| $uvInstall = (Invoke-WebRequest -Uri 'https://astral.sh/uv/install.ps1' -UseBasicParsing).Content | |
| Invoke-Expression $uvInstall | |
| Refresh-Path | |
| # uv installs to %USERPROFILE%\.local\bin by default; add it if missing | |
| $uvBinDir = Join-Path $env:USERPROFILE '.local\bin' | |
| if (Test-Path $uvBinDir) { | |
| $currentPath = [System.Environment]::GetEnvironmentVariable('Path','User') | |
| if ($currentPath -notlike "*$uvBinDir*") { | |
| [System.Environment]::SetEnvironmentVariable('Path', "$currentPath;$uvBinDir", 'User') | |
| } | |
| Refresh-Path | |
| } | |
| if (-not (Command-Exists uv)) { throw "uv binary not found after install" } | |
| Write-Ok "uv installed ($(uv --version))" | |
| } catch { | |
| Write-Fail "uv install failed: $_" | |
| exit 1 | |
| } | |
| } | |
| # ── 5. Node.js (LTS) ─────────────────────────────────────────────────────────── | |
| Write-Step "Node.js (LTS)" | |
| if (Command-Exists node) { | |
| Write-Skip "node already installed ($(node --version))" | |
| } else { | |
| choco install nodejs-lts -y --no-progress | |
| Assert-ExitCode $LASTEXITCODE "node install" | |
| Refresh-Path | |
| Write-Ok "Node.js installed ($(node --version)) / npm $(npm --version)" | |
| } | |
| # ── Summary ──────────────────────────────────────────────────────────────────── | |
| Write-Host "`n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" -ForegroundColor DarkGray | |
| Write-Host " All done. Versions:" -ForegroundColor White | |
| Write-Host " choco : $(choco --version)" -ForegroundColor Gray | |
| Write-Host " git : $(git --version)" -ForegroundColor Gray | |
| Write-Host " python : $(python --version 2>&1)" -ForegroundColor Gray | |
| if (Command-Exists uv) { Write-Host " uv : $(uv --version)" -ForegroundColor Gray } | |
| if (Command-Exists node) { Write-Host " node : $(node --version)" -ForegroundColor Gray } | |
| if (Command-Exists npm) { Write-Host " npm : $(npm --version)" -ForegroundColor Gray } | |
| Write-Host "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━`n" -ForegroundColor DarkGray | |
| Write-Host "Restart your terminal to pick up all PATH changes." -ForegroundColor Yellow |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment