97 lines
3.6 KiB
PowerShell
97 lines
3.6 KiB
PowerShell
<#
|
|
LXS - Dev Pack (Windows)
|
|
Description: The usual development toolchain, installed through winget.
|
|
Repo: https://git.hyko.cx/hykocx/lxs
|
|
#>
|
|
|
|
# Load LXS common library (colors, UI helpers, spinner, loggers, guards).
|
|
# Prefers the sibling ..\lib\common.ps1 (repo checkout or installed layout) and
|
|
# only hits the network when this script is run standalone.
|
|
$LxsRawBase = if ($env:LXS_RAW_BASE) { $env:LXS_RAW_BASE } else { 'https://git.hyko.cx/hykocx/lxs/raw/branch/main' }
|
|
if (-not $env:LXS_RAW_PLATFORM_BASE) { $env:LXS_RAW_PLATFORM_BASE = "$LxsRawBase/windows" }
|
|
$LxsLibPath = if ($PSScriptRoot) { Join-Path $PSScriptRoot '..\lib\common.ps1' } else { $null }
|
|
if ($LxsLibPath -and (Test-Path $LxsLibPath)) {
|
|
. $LxsLibPath
|
|
} else {
|
|
try {
|
|
$LxsLibSource = Invoke-RestMethod -Uri "$env:LXS_RAW_PLATFORM_BASE/lib/common.ps1" -UseBasicParsing -ErrorAction Stop
|
|
} catch {
|
|
Write-Error 'Failed to fetch lib/common.ps1'
|
|
exit 1
|
|
}
|
|
# The library ships with a UTF-8 BOM (Windows PowerShell 5.1 needs it to
|
|
# read the file as UTF-8); over HTTP that BOM arrives as a leading U+FEFF
|
|
# character, which the parser will not accept.
|
|
. ([scriptblock]::Create(($LxsLibSource -replace '^\uFEFF', '')))
|
|
}
|
|
|
|
$env:LXS_LOG_FILE = Join-Path (Get-LxsTempDir) 'lxs_dev_pack.log'
|
|
|
|
if (-not (Assert-LxsWindows)) { exit 1 }
|
|
|
|
$LxsDevPackages = @(
|
|
@{ Name = 'Git'; Id = 'Git.Git' }
|
|
@{ Name = 'VS Code'; Id = 'Microsoft.VisualStudioCode' }
|
|
@{ Name = 'Node.js LTS'; Id = 'OpenJS.NodeJS.LTS' }
|
|
@{ Name = 'Python 3'; Id = 'Python.Python.3.12' }
|
|
@{ Name = 'PowerShell 7'; Id = 'Microsoft.PowerShell' }
|
|
@{ Name = 'Windows Terminal'; Id = 'Microsoft.WindowsTerminal' }
|
|
)
|
|
|
|
function Enable-LxsWsl {
|
|
Clear-Host
|
|
Show-LxsBoxTop -Title 'WSL 2'
|
|
Write-Host ''
|
|
Write-Host 'Installs the Windows Subsystem for Linux (WSL 2) and the default'
|
|
Write-Host 'Ubuntu distribution. Enables the Virtual Machine Platform feature,'
|
|
Write-Host "so a $($script:Bold)reboot is required$($script:NC) before WSL works."
|
|
Write-Host ''
|
|
if (-not (Confirm-LxsAction -Question 'Install WSL 2?')) {
|
|
Write-LxsInfo 'Cancelled.'
|
|
return
|
|
}
|
|
if (-not (Test-LxsAdmin)) {
|
|
Write-LxsErr 'Installing WSL requires administrator rights.'
|
|
Write-Host "$($script:Gray) Re-run lxs from an elevated terminal.$($script:NC)"
|
|
return
|
|
}
|
|
Write-Host ''
|
|
& wsl.exe --install
|
|
if ($LASTEXITCODE -eq 0) {
|
|
Write-LxsOk 'WSL install started'
|
|
Write-LxsWarn 'Reboot to finish, then run: wsl --install -d Ubuntu'
|
|
} else {
|
|
Write-LxsWarn "wsl --install exited with code $LASTEXITCODE"
|
|
}
|
|
}
|
|
|
|
function Show-LxsDevMenu {
|
|
while ($true) {
|
|
Clear-Host
|
|
Show-LxsBoxTop -Title 'DEV PACK'
|
|
Write-Host ''
|
|
Show-LxsMenuItem '1' 'Install dev tools' 'pick from the list'
|
|
Show-LxsMenuItem '2' 'Install WSL 2' 'needs admin + reboot'
|
|
Show-LxsMenuItem '0' 'Back' '' -Exit
|
|
Write-Host ''
|
|
Show-LxsBoxBottom
|
|
Write-Host ''
|
|
$choice = Read-LxsChoice
|
|
Write-Host ''
|
|
|
|
switch ($choice) {
|
|
'1' {
|
|
Invoke-LxsPackageMenu -Title 'DEV PACK' -Packages $LxsDevPackages `
|
|
-Note 'Everything here installs per-machine and lands on your PATH.' | Out-Null
|
|
Read-LxsEnter
|
|
}
|
|
'2' { Enable-LxsWsl; Read-LxsEnter }
|
|
'0' { return }
|
|
default { Write-LxsErr 'Invalid protocol. Select 0-2.'; Start-Sleep -Seconds 1 }
|
|
}
|
|
}
|
|
}
|
|
|
|
Show-LxsDevMenu
|
|
exit 75
|