From 6d2e099eb433c38c59b686554145fbc5d7712fe3 Mon Sep 17 00:00:00 2001 From: Bjarke Sporring Date: Wed, 14 Jan 2026 16:37:39 +0100 Subject: [PATCH] Add progress bars to install-prerequisites.ps1 - Added overall progress tracking for required installations (1/3, 2/3, 3/3) - Added progress indicators for optional installations - Added individual package installation progress with status updates - Progress bars show clear visual feedback during installation process - Helps users understand how far along the installation is --- install-prerequisites.ps1 | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/install-prerequisites.ps1 b/install-prerequisites.ps1 index 5f02dfd..5635efe 100644 --- a/install-prerequisites.ps1 +++ b/install-prerequisites.ps1 @@ -146,7 +146,12 @@ function Install-Package { Write-Host " Running: $installCmd" -ForegroundColor Gray try { + # Show progress during installation + Write-Progress -Activity "Installing $Name" -Status "Downloading and installing..." -PercentComplete 25 + $result = Invoke-Expression $installCmd 2>&1 + + Write-Progress -Activity "Installing $Name" -Status "Verifying installation..." -PercentComplete 75 # Check if installation succeeded Start-Sleep -Seconds 2 # Give the system time to register the new command @@ -157,16 +162,19 @@ function Install-Package { if (Test-CommandExists $CheckCommand) { $version = Get-InstalledVersion $CheckCommand Write-Success "$Name installed successfully: $version" + Write-Progress -Activity "Installing $Name" -Completed return $true } else { Write-Warning "$Name installation completed, but command '$CheckCommand' not found." Write-Host " You may need to restart your terminal or computer." -ForegroundColor Yellow + Write-Progress -Activity "Installing $Name" -Completed return $false } } catch { Write-Error "Failed to install $Name`: $_" + Write-Progress -Activity "Installing $Name" -Completed return $false } } @@ -253,19 +261,38 @@ $results = @{ WindowsTerminal = $null } +# Progress tracking +$totalSteps = 3 # Required installations +$currentStep = 0 + Write-Host "`nStarting installation..." -ForegroundColor Cyan Write-Host "Note: Some installations may take a few minutes." -ForegroundColor Gray Write-Host "" +# Progress bar helper +function Write-ProgressIndicator { + param( + [string]$Activity, + [string]$Status, + [int]$PercentComplete + ) + + Write-Progress -Activity $Activity -Status $Status -PercentComplete $PercentComplete +} + #region Required Installations # Install PowerShell 7 +$currentStep++ +Write-ProgressIndicator -Activity "Installing Required Tools" -Status "Installing PowerShell 7 (1/3)" -PercentComplete (($currentStep / $totalSteps) * 100) $results.PowerShell = Install-Package ` -Name "PowerShell 7" ` -WingetId "Microsoft.PowerShell" ` -CheckCommand "pwsh" # Install Git +$currentStep++ +Write-ProgressIndicator -Activity "Installing Required Tools" -Status "Installing Git (2/3)" -PercentComplete (($currentStep / $totalSteps) * 100) $results.Git = Install-Package ` -Name "Git" ` -WingetId "Git.Git" ` @@ -282,11 +309,16 @@ if ($results.Git) { } # Install Visual Studio Code +$currentStep++ +Write-ProgressIndicator -Activity "Installing Required Tools" -Status "Installing Visual Studio Code (3/3)" -PercentComplete (($currentStep / $totalSteps) * 100) $results.VSCode = Install-Package ` -Name "Visual Studio Code" ` -WingetId "Microsoft.VisualStudioCode" ` -CheckCommand "code" +# Clear progress bar +Write-Progress -Activity "Installing Required Tools" -Completed + #endregion #region Optional Installations @@ -294,10 +326,12 @@ $results.VSCode = Install-Package ` # Python 3.12 (optional) Write-Host "" if (Get-UserConfirmation "Do you want to install Python 3.12? (Required for Module 08: Multiplayer Git)") { + Write-ProgressIndicator -Activity "Installing Optional Tools" -Status "Installing Python 3.12" -PercentComplete 50 $results.Python = Install-Package ` -Name "Python 3.12" ` -WingetId "Python.Python.3.12" ` -CheckCommand "python" + Write-Progress -Activity "Installing Optional Tools" -Completed } else { Write-Host " Skipping Python installation." -ForegroundColor Gray @@ -307,10 +341,12 @@ else { # Windows Terminal (optional) Write-Host "" if (Get-UserConfirmation "Do you want to install Windows Terminal? (Highly recommended for better terminal experience)") { + Write-ProgressIndicator -Activity "Installing Optional Tools" -Status "Installing Windows Terminal" -PercentComplete 50 $results.WindowsTerminal = Install-Package ` -Name "Windows Terminal" ` -WingetId "Microsoft.WindowsTerminal" ` -CheckCommand "wt" + Write-Progress -Activity "Installing Optional Tools" -Completed } else { Write-Host " Skipping Windows Terminal installation." -ForegroundColor Gray