@@ -83,25 +83,76 @@ function Test-Command($cmd) {
8383 catch { return $false }
8484}
8585
86+ function Test-ChocoWorks {
87+ try {
88+ $null = & choco -- version 2>&1
89+ return ($LASTEXITCODE -eq 0 )
90+ } catch {
91+ return $false
92+ }
93+ }
94+
8695$hasWinget = Test-Command " winget"
87- $hasChoco = Test-Command " choco"
96+ $hasChoco = ( Test-Command " choco" ) -and ( Test-ChocoWorks )
8897
98+ # Report what we found
99+ $pkgMgrFound = $false
89100if ($hasWinget ) {
90- Write-Ok " winget detected (primary package manager)"
91- } elseif ($hasChoco ) {
92- Write-Ok " Chocolatey detected (package manager)"
93- } else {
94- Write-Warn " No package manager found (winget or Chocolatey)"
95- Write-Step " Installing Chocolatey..."
96- try {
97- Set-ExecutionPolicy Bypass - Scope Process - Force
98- [System.Net.ServicePointManager ]::SecurityProtocol = [System.Net.ServicePointManager ]::SecurityProtocol -bor 3072
99- Invoke-Expression ((New-Object System.Net.WebClient).DownloadString(' https://community.chocolatey.org/install.ps1' ))
100- $hasChoco = $true
101- Write-Ok " Chocolatey installed"
102- } catch {
103- Write-Err " Could not install Chocolatey: $_ "
101+ Write-Ok " winget detected"
102+ $pkgMgrFound = $true
103+ }
104+ if ($hasChoco ) {
105+ Write-Ok " Chocolatey detected"
106+ $pkgMgrFound = $true
107+ }
108+
109+ if (-not $pkgMgrFound ) {
110+ Write-Warn " No working package manager found"
111+ Write-Host " "
112+ Write-Host " A package manager is needed to install dependencies." - ForegroundColor White
113+ Write-Host " Choose one:" - ForegroundColor White
114+ Write-Host " "
115+ Write-Host " [1] winget (recommended, built into Windows 10/11)" - ForegroundColor Cyan
116+ Write-Host " [2] Chocolatey (community package manager)" - ForegroundColor Cyan
117+ Write-Host " [3] Skip (I'll install dependencies manually)" - ForegroundColor DarkGray
118+ Write-Host " "
119+ $choice = Read-Host " Enter choice (1/2/3)"
120+
121+ switch ($choice ) {
122+ " 1" {
123+ Write-Step " Checking for winget..."
124+ # winget is built into modern Windows — if missing, point to MS Store
125+ if (Test-Command " winget" ) {
126+ $hasWinget = $true
127+ Write-Ok " winget is available"
128+ } else {
129+ Write-Warn " winget not found. Install 'App Installer' from the Microsoft Store:"
130+ Write-Host " ms-windows-store://pdp/?productid=9NBLGGH4NNS1" - ForegroundColor Cyan
131+ Write-Host " Then re-run this installer." - ForegroundColor DarkGray
132+ }
133+ }
134+ " 2" {
135+ Write-Step " Installing Chocolatey..."
136+ try {
137+ Set-ExecutionPolicy Bypass - Scope Process - Force
138+ [System.Net.ServicePointManager ]::SecurityProtocol = [System.Net.ServicePointManager ]::SecurityProtocol -bor 3072
139+ Invoke-Expression ((New-Object System.Net.WebClient).DownloadString(' https://community.chocolatey.org/install.ps1' ))
140+ $hasChoco = $true
141+ Write-Ok " Chocolatey installed"
142+ } catch {
143+ Write-Err " Could not install Chocolatey: $_ "
144+ }
145+ }
146+ default {
147+ Write-Skip " Skipping package manager — dependencies must be installed manually"
148+ }
104149 }
150+ } elseif ($hasWinget -and $hasChoco ) {
151+ Write-Ok " Using winget (primary), Chocolatey (fallback)"
152+ } elseif ($hasWinget ) {
153+ Write-Ok " Using winget"
154+ } else {
155+ Write-Ok " Using Chocolatey"
105156}
106157
107158function Refresh-Path {
0 commit comments