refactor: simplify user choice. Install and clone split
This commit is contained in:
79
install.ps1
79
install.ps1
@@ -393,45 +393,29 @@ function Show-PrerequisitesSummary {
|
||||
|
||||
function Get-UserChoice {
|
||||
param([hashtable]$PrereqStatus)
|
||||
|
||||
|
||||
Write-Host ""
|
||||
Write-Step "Choose Your Action"
|
||||
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "What would you like to do?" -ForegroundColor White
|
||||
Write-Host " 1) Install/update tools and clone workshop repository" -ForegroundColor Cyan
|
||||
Write-Host " 2) Just clone the workshop repository (skip tool installation)" -ForegroundColor Yellow
|
||||
Write-Host ""
|
||||
|
||||
if ($PrereqStatus.AllRequiredInstalled) {
|
||||
Write-Host "All required tools are already installed!" -ForegroundColor Green
|
||||
Write-Host ""
|
||||
Write-Host "What would you like to do?" -ForegroundColor White
|
||||
Write-Host " 1) Just clone the workshop repository" -ForegroundColor Cyan
|
||||
Write-Host " 2) Install/update missing optional tools" -ForegroundColor Cyan
|
||||
Write-Host " 3) Reinstall all tools (fresh installation)" -ForegroundColor Yellow
|
||||
Write-Host ""
|
||||
|
||||
while ($true) {
|
||||
$choice = Read-Host "Enter your choice (1-3)"
|
||||
switch ($choice.Trim()) {
|
||||
"1" { return "CloneOnly" }
|
||||
"2" { return "OptionalOnly" }
|
||||
"3" { return "InstallAll" }
|
||||
default { Write-Host "Please enter 1, 2, or 3" -ForegroundColor Yellow }
|
||||
}
|
||||
}
|
||||
Write-Host "Note: All required tools are already installed" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host "Some required tools are missing or need updates." -ForegroundColor Yellow
|
||||
Write-Host ""
|
||||
Write-Host "What would you like to do?" -ForegroundColor White
|
||||
Write-Host " 1) Install missing/insufficient tools only" -ForegroundColor Green
|
||||
Write-Host " 2) Install all required tools" -ForegroundColor Cyan
|
||||
Write-Host " 3) Just clone the workshop repository (not recommended)" -ForegroundColor Yellow
|
||||
Write-Host ""
|
||||
|
||||
while ($true) {
|
||||
$choice = Read-Host "Enter your choice (1-3)"
|
||||
switch ($choice.Trim()) {
|
||||
"1" { return "InstallMissing" }
|
||||
"2" { return "InstallAll" }
|
||||
"3" { return "CloneOnly" }
|
||||
default { Write-Host "Please enter 1, 2, or 3" -ForegroundColor Yellow }
|
||||
}
|
||||
Write-Host "Note: Some required tools are missing or need updates" -ForegroundColor Yellow
|
||||
}
|
||||
Write-Host ""
|
||||
|
||||
while ($true) {
|
||||
$choice = Read-Host "Enter your choice (1-2)"
|
||||
switch ($choice.Trim()) {
|
||||
"1" { return "InstallTools" }
|
||||
"2" { return "CloneOnly" }
|
||||
default { Write-Host "Please enter 1 or 2" -ForegroundColor Yellow }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -498,24 +482,19 @@ function Should-Install {
|
||||
[string]$UserChoice,
|
||||
[hashtable]$Prereqs
|
||||
)
|
||||
|
||||
|
||||
$tool = $Prereqs[$ToolName]
|
||||
|
||||
|
||||
switch ($UserChoice) {
|
||||
"CloneOnly" {
|
||||
return $false
|
||||
"CloneOnly" {
|
||||
return $false
|
||||
}
|
||||
"OptionalOnly" {
|
||||
return $ToolName -eq "WindowsTerminal"
|
||||
}
|
||||
"InstallMissing" {
|
||||
"InstallTools" {
|
||||
# Install only if missing or insufficient (smart install)
|
||||
return -not ($tool.Installed -and $tool.Sufficient)
|
||||
}
|
||||
"InstallAll" {
|
||||
return $true
|
||||
}
|
||||
default {
|
||||
return -not ($tool.Installed -and $tool.Sufficient)
|
||||
default {
|
||||
return $false
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -695,7 +674,7 @@ if ($userChoice -ne "CloneOnly") {
|
||||
$powershellExtensionResult = Install-VSCodeExtension -ExtensionId "ms-vscode.PowerShell" -ExtensionName "PowerShell"
|
||||
|
||||
# Configure PowerShell 7 integration (optional but recommended)
|
||||
if ($userChoice -eq "InstallAll" -or $userChoice -eq "InstallMissing") {
|
||||
if ($userChoice -eq "InstallTools") {
|
||||
$powershellIntegrationResult = Set-VSCodePowerShellIntegration
|
||||
$results.VSCodePowerShellIntegration = $powershellIntegrationResult
|
||||
} else {
|
||||
@@ -715,7 +694,7 @@ if ($userChoice -ne "CloneOnly") {
|
||||
# Windows Terminal (optional)
|
||||
if (Should-Install -ToolName "WindowsTerminal" -UserChoice $userChoice -Prereqs $prereqs) {
|
||||
Write-Host ""
|
||||
if ($userChoice -eq "OptionalOnly" -or (Get-UserConfirmation "Do you want to install Windows Terminal? (Highly recommended for better terminal experience)")) {
|
||||
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" `
|
||||
|
||||
Reference in New Issue
Block a user