refactor: simplify user choice. Install and clone split
This commit is contained in:
63
install.ps1
63
install.ps1
@@ -397,41 +397,25 @@ function Get-UserChoice {
|
|||||||
Write-Host ""
|
Write-Host ""
|
||||||
Write-Step "Choose Your Action"
|
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) {
|
if ($PrereqStatus.AllRequiredInstalled) {
|
||||||
Write-Host "All required tools are already installed!" -ForegroundColor Green
|
Write-Host "Note: 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 }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
Write-Host "Some required tools are missing or need updates." -ForegroundColor Yellow
|
Write-Host "Note: Some required tools are missing or need updates" -ForegroundColor Yellow
|
||||||
Write-Host ""
|
}
|
||||||
Write-Host "What would you like to do?" -ForegroundColor White
|
Write-Host ""
|
||||||
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) {
|
while ($true) {
|
||||||
$choice = Read-Host "Enter your choice (1-3)"
|
$choice = Read-Host "Enter your choice (1-2)"
|
||||||
switch ($choice.Trim()) {
|
switch ($choice.Trim()) {
|
||||||
"1" { return "InstallMissing" }
|
"1" { return "InstallTools" }
|
||||||
"2" { return "InstallAll" }
|
"2" { return "CloneOnly" }
|
||||||
"3" { return "CloneOnly" }
|
default { Write-Host "Please enter 1 or 2" -ForegroundColor Yellow }
|
||||||
default { Write-Host "Please enter 1, 2, or 3" -ForegroundColor Yellow }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -505,17 +489,12 @@ function Should-Install {
|
|||||||
"CloneOnly" {
|
"CloneOnly" {
|
||||||
return $false
|
return $false
|
||||||
}
|
}
|
||||||
"OptionalOnly" {
|
"InstallTools" {
|
||||||
return $ToolName -eq "WindowsTerminal"
|
# Install only if missing or insufficient (smart install)
|
||||||
}
|
|
||||||
"InstallMissing" {
|
|
||||||
return -not ($tool.Installed -and $tool.Sufficient)
|
return -not ($tool.Installed -and $tool.Sufficient)
|
||||||
}
|
}
|
||||||
"InstallAll" {
|
|
||||||
return $true
|
|
||||||
}
|
|
||||||
default {
|
default {
|
||||||
return -not ($tool.Installed -and $tool.Sufficient)
|
return $false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -695,7 +674,7 @@ if ($userChoice -ne "CloneOnly") {
|
|||||||
$powershellExtensionResult = Install-VSCodeExtension -ExtensionId "ms-vscode.PowerShell" -ExtensionName "PowerShell"
|
$powershellExtensionResult = Install-VSCodeExtension -ExtensionId "ms-vscode.PowerShell" -ExtensionName "PowerShell"
|
||||||
|
|
||||||
# Configure PowerShell 7 integration (optional but recommended)
|
# Configure PowerShell 7 integration (optional but recommended)
|
||||||
if ($userChoice -eq "InstallAll" -or $userChoice -eq "InstallMissing") {
|
if ($userChoice -eq "InstallTools") {
|
||||||
$powershellIntegrationResult = Set-VSCodePowerShellIntegration
|
$powershellIntegrationResult = Set-VSCodePowerShellIntegration
|
||||||
$results.VSCodePowerShellIntegration = $powershellIntegrationResult
|
$results.VSCodePowerShellIntegration = $powershellIntegrationResult
|
||||||
} else {
|
} else {
|
||||||
@@ -715,7 +694,7 @@ if ($userChoice -ne "CloneOnly") {
|
|||||||
# Windows Terminal (optional)
|
# Windows Terminal (optional)
|
||||||
if (Should-Install -ToolName "WindowsTerminal" -UserChoice $userChoice -Prereqs $prereqs) {
|
if (Should-Install -ToolName "WindowsTerminal" -UserChoice $userChoice -Prereqs $prereqs) {
|
||||||
Write-Host ""
|
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
|
Write-ProgressIndicator -Activity "Installing Optional Tools" -Status "Installing Windows Terminal" -PercentComplete 50
|
||||||
$results.WindowsTerminal = Install-Package `
|
$results.WindowsTerminal = Install-Package `
|
||||||
-Name "Windows Terminal" `
|
-Name "Windows Terminal" `
|
||||||
|
|||||||
Reference in New Issue
Block a user