Add VSCode extensions and PowerShell 7 integration setup
- Added function to install VSCode extensions via command line - Install PowerShell extension for better PowerShell support in VSCode - Install GitLens and Git Graph extensions for enhanced Git experience - Configure VSCode to use PowerShell 7 as default terminal - Update progress tracking to include extension installation step - Add extension results to installation summary
This commit is contained in:
@@ -257,12 +257,13 @@ $results = @{
|
|||||||
PowerShell = $false
|
PowerShell = $false
|
||||||
Git = $false
|
Git = $false
|
||||||
VSCode = $false
|
VSCode = $false
|
||||||
|
VSCodeExtensions = $false
|
||||||
Python = $null # null = not attempted, true = success, false = failed
|
Python = $null # null = not attempted, true = success, false = failed
|
||||||
WindowsTerminal = $null
|
WindowsTerminal = $null
|
||||||
}
|
}
|
||||||
|
|
||||||
# Progress tracking
|
# Progress tracking
|
||||||
$totalSteps = 3 # Required installations
|
$totalSteps = 4 # Required installations + extensions
|
||||||
$currentStep = 0
|
$currentStep = 0
|
||||||
|
|
||||||
Write-Host "`nStarting installation..." -ForegroundColor Cyan
|
Write-Host "`nStarting installation..." -ForegroundColor Cyan
|
||||||
@@ -280,6 +281,91 @@ function Write-ProgressIndicator {
|
|||||||
Write-Progress -Activity $Activity -Status $Status -PercentComplete $PercentComplete
|
Write-Progress -Activity $Activity -Status $Status -PercentComplete $PercentComplete
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function Install-VSCodeExtension {
|
||||||
|
param(
|
||||||
|
[string]$ExtensionId,
|
||||||
|
[string]$ExtensionName
|
||||||
|
)
|
||||||
|
|
||||||
|
Write-Host " Installing VSCode extension: $ExtensionName" -ForegroundColor Cyan
|
||||||
|
|
||||||
|
try {
|
||||||
|
# Refresh environment to ensure code command is available
|
||||||
|
$env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User")
|
||||||
|
|
||||||
|
$result = & code --install-extension $ExtensionId 2>&1
|
||||||
|
|
||||||
|
if ($LASTEXITCODE -eq 0) {
|
||||||
|
Write-Success "VSCode extension '$ExtensionName' installed successfully"
|
||||||
|
return $true
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Write-Warning "Failed to install VSCode extension '$ExtensionName'"
|
||||||
|
Write-Host " You can install it manually later: Ctrl+Shift+X → Search '$ExtensionName'" -ForegroundColor Gray
|
||||||
|
return $false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
Write-Warning "Could not install VSCode extension '$ExtensionName`: $_"
|
||||||
|
Write-Host " You can install it manually later: Ctrl+Shift+X → Search '$ExtensionName'" -ForegroundColor Gray
|
||||||
|
return $false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function Set-VSCodePowerShellIntegration {
|
||||||
|
Write-Host " Configuring PowerShell 7 integration with VSCode..." -ForegroundColor Cyan
|
||||||
|
|
||||||
|
try {
|
||||||
|
# Set PowerShell 7 as the default terminal in VSCode
|
||||||
|
$vscodeSettingsPath = Join-Path $env:APPDATA "Code\User\settings.json"
|
||||||
|
$vscodeSettingsDir = Split-Path $vscodeSettingsPath -Parent
|
||||||
|
|
||||||
|
# Create directory if it doesn't exist
|
||||||
|
if (-not (Test-Path $vscodeSettingsDir)) {
|
||||||
|
New-Item -Path $vscodeSettingsDir -ItemType Directory -Force | Out-Null
|
||||||
|
}
|
||||||
|
|
||||||
|
# Read existing settings or create new
|
||||||
|
if (Test-Path $vscodeSettingsPath) {
|
||||||
|
$settings = Get-Content $vscodeSettingsPath -Raw | ConvertFrom-Json
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$settings = @{}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Set PowerShell 7 as default terminal
|
||||||
|
if (-not $settings.PSObject.Properties.Name -contains "terminal.integrated.defaultProfile.windows") {
|
||||||
|
$settings | Add-Member -NotePropertyName "terminal.integrated.defaultProfile.windows" -NotePropertyValue "PowerShell"
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$settings."terminal.integrated.defaultProfile.windows" = "PowerShell"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Add terminal profiles if not present
|
||||||
|
if (-not $settings.PSObject.Properties.Name -contains "terminal.integrated.profiles.windows") {
|
||||||
|
$profiles = @{
|
||||||
|
"PowerShell" = @{
|
||||||
|
"source" = "PowerShell"
|
||||||
|
"icon" = "terminal-powershell"
|
||||||
|
"path" = "pwsh.exe"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$settings | Add-Member -NotePropertyName "terminal.integrated.profiles.windows" -NotePropertyValue $profiles
|
||||||
|
}
|
||||||
|
|
||||||
|
# Save settings
|
||||||
|
$settings | ConvertTo-Json -Depth 10 | Set-Content $vscodeSettingsPath
|
||||||
|
|
||||||
|
Write-Success "VSCode configured to use PowerShell 7 as default terminal"
|
||||||
|
return $true
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
Write-Warning "Could not configure VSCode PowerShell integration automatically"
|
||||||
|
Write-Host " You can configure it manually in VSCode: Ctrl+Shift+P → Terminal: Select Default Profile → PowerShell" -ForegroundColor Gray
|
||||||
|
return $false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#region Required Installations
|
#region Required Installations
|
||||||
|
|
||||||
# Install PowerShell 7
|
# Install PowerShell 7
|
||||||
@@ -310,12 +396,36 @@ if ($results.Git) {
|
|||||||
|
|
||||||
# Install Visual Studio Code
|
# Install Visual Studio Code
|
||||||
$currentStep++
|
$currentStep++
|
||||||
Write-ProgressIndicator -Activity "Installing Required Tools" -Status "Installing Visual Studio Code (3/3)" -PercentComplete (($currentStep / $totalSteps) * 100)
|
Write-ProgressIndicator -Activity "Installing Required Tools" -Status "Installing Visual Studio Code (3/4)" -PercentComplete (($currentStep / $totalSteps) * 100)
|
||||||
$results.VSCode = Install-Package `
|
$results.VSCode = Install-Package `
|
||||||
-Name "Visual Studio Code" `
|
-Name "Visual Studio Code" `
|
||||||
-WingetId "Microsoft.VisualStudioCode" `
|
-WingetId "Microsoft.VisualStudioCode" `
|
||||||
-CheckCommand "code"
|
-CheckCommand "code"
|
||||||
|
|
||||||
|
# Install VSCode Extensions and configure PowerShell integration
|
||||||
|
if ($results.VSCode) {
|
||||||
|
$currentStep++
|
||||||
|
Write-ProgressIndicator -Activity "Installing Required Tools" -Status "Installing VSCode Extensions (4/4)" -PercentComplete (($currentStep / $totalSteps) * 100)
|
||||||
|
|
||||||
|
Write-Host ""
|
||||||
|
Write-Step "Configuring VSCode"
|
||||||
|
|
||||||
|
# Install PowerShell extension
|
||||||
|
$powershellExtensionResult = Install-VSCodeExtension -ExtensionId "ms-vscode.PowerShell" -ExtensionName "PowerShell"
|
||||||
|
|
||||||
|
# Install other recommended extensions
|
||||||
|
$gitLensResult = Install-VSCodeExtension -ExtensionId "eamodio.gitlens" -ExtensionName "GitLens"
|
||||||
|
$gitGraphResult = Install-VSCodeExtension -ExtensionId "mhutchie.git-graph" -ExtensionName "Git Graph"
|
||||||
|
|
||||||
|
# Configure PowerShell 7 integration
|
||||||
|
$powershellIntegrationResult = Set-VSCodePowerShellIntegration
|
||||||
|
|
||||||
|
$results.VSCodeExtensions = $powershellExtensionResult -or $gitLensResult -or $gitGraphResult
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$results.VSCodeExtensions = $false
|
||||||
|
}
|
||||||
|
|
||||||
# Clear progress bar
|
# Clear progress bar
|
||||||
Write-Progress -Activity "Installing Required Tools" -Completed
|
Write-Progress -Activity "Installing Required Tools" -Completed
|
||||||
|
|
||||||
@@ -380,6 +490,16 @@ else {
|
|||||||
|
|
||||||
if ($results.VSCode) {
|
if ($results.VSCode) {
|
||||||
Write-Success "Visual Studio Code"
|
Write-Success "Visual Studio Code"
|
||||||
|
|
||||||
|
if ($results.VSCodeExtensions) {
|
||||||
|
Write-Success " • PowerShell extension"
|
||||||
|
Write-Success " • GitLens extension"
|
||||||
|
Write-Success " • Git Graph extension"
|
||||||
|
Write-Success " • PowerShell 7 terminal integration"
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Write-Warning " • Some VSCode extensions may need manual installation"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Write-Error "Visual Studio Code - Installation failed or needs restart"
|
Write-Error "Visual Studio Code - Installation failed or needs restart"
|
||||||
|
|||||||
Reference in New Issue
Block a user