release: bump version to 0.75.2
ci / backend (push) Has been cancelled
ci / frontend (push) Has been cancelled
release / images (push) Has been cancelled
ci / delivery (push) Has been cancelled

This commit is contained in:
rayd1o committed 2026-09-25 02:03:53 +08:00
1 parent 003b316d42
commit a2025dbfe0
11 files changed
+105 -12

No files matched your search

+47
View File
@@ -78,3 +78,50 @@ try {
[IO.Path]::GetFileName($resolved) -notlike 'planet-launcher-tests-*') { throw 'Unsafe cleanup path' }
Remove-Item -LiteralPath $resolved -Recurse -Force
}
function Get-Command {
param([string]$Name, [string]$CommandType, [string]$ErrorAction)
if ($script:AvailableLaunchCommands.ContainsKey($Name)) {
return [pscustomobject]@{ Source = $script:AvailableLaunchCommands[$Name] }
}
}
$pwshPath = 'C:\Program Files\PowerShell\7\pwsh.exe'
$terminalPath = 'C:\Users\Test\AppData\Local\Microsoft\WindowsApps\wt.exe'
$legacyPath = 'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe'
foreach ($hasTerminal in @($true, $false)) {
foreach ($hasPwsh in @($true, $false)) {
$script:AvailableLaunchCommands = @{ 'powershell.exe' = $legacyPath }
if ($hasTerminal) { $script:AvailableLaunchCommands['wt.exe'] = $terminalPath }
if ($hasPwsh) { $script:AvailableLaunchCommands['pwsh.exe'] = $pwshPath }
$launch = Get-PlanetTerminalLaunch 'TESTPAYLOAD'
$expectedShell = if ($hasPwsh) { $pwshPath } else { $legacyPath }
$expectedExecutable = if ($hasTerminal) { $terminalPath } else { $expectedShell }
Assert-Equal $expectedExecutable $launch.FilePath 'Terminal/shell priority'
if ($hasTerminal -and -not $launch.ArgumentList.Contains('"' + $expectedShell + '"')) {
throw 'Terminal shell path must be quoted, including Program Files paths'
}
if ($launch.ArgumentList -notmatch '-EncodedCommand TESTPAYLOAD$') {
throw 'Encoded bootstrap was not preserved'
}
}
}
function Test-PlanetAdministrator { return $script:IsTestAdministrator }
function Start-Process {
param($FilePath, $ArgumentList, $WindowStyle, $Verb)
$script:CapturedLaunch = @{ FilePath = $FilePath; ArgumentList = $ArgumentList; Verb = $Verb }
$script:LaunchCount++
}
$script:AvailableLaunchCommands = @{ 'pwsh.exe' = $pwshPath; 'wt.exe' = $terminalPath }
$script:LaunchCount = 0
foreach ($isAdmin in @($false, $true)) {
$script:IsTestAdministrator = $isAdmin
Start-PlanetRestart $target
Assert-Equal $terminalPath $script:CapturedLaunch.FilePath 'Admin and ordinary entry both use Terminal'
if ($isAdmin -and $script:CapturedLaunch.Verb) { throw 'Already elevated entry must not request UAC again' }
if (-not $isAdmin) { Assert-Equal 'RunAs' $script:CapturedLaunch.Verb 'Ordinary entry requires elevation' }
}
$script:IsTestAdministrator = $false
try { Start-PlanetRestart $target -AlreadyElevated; throw 'Unelevated child accepted' }
catch { if ($_.Exception.Message -ne 'Administrator elevation was not granted.') { throw } }
Assert-Equal 2 $script:LaunchCount 'Child must not recursively launch more windows'
Write-Host 'PASS: Terminal/PowerShell priority, quoted paths, elevation and no recursive dispatch'
+30 -6
View File
@@ -114,7 +114,10 @@ function Install-PlanetDesktopLauncher {
'@echo off', 'setlocal EnableExtensions DisableDelayedExpansion', $marker,
'set "PLANET_LAUNCHER_INSTALL_ONLY="',
'if /i "%~1"=="--install-only" set "PLANET_LAUNCHER_INSTALL_ONLY=1"',
"powershell.exe -NoLogo -NoProfile -ExecutionPolicy Bypass -EncodedCommand $encoded",
'set "PLANET_POWERSHELL=powershell.exe"',
'where.exe pwsh.exe >nul 2>&1',
'if not errorlevel 1 set "PLANET_POWERSHELL=pwsh.exe"',
"%PLANET_POWERSHELL% -NoLogo -NoProfile -ExecutionPolicy Bypass -EncodedCommand $encoded",
'set "planet_launcher_exit=%errorlevel%"',
'if not "%planet_launcher_exit%"=="0" pause',
'exit /b %planet_launcher_exit%'
@@ -129,18 +132,39 @@ function Test-PlanetAdministrator {
return $principal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
}
function Get-PlanetTerminalLaunch {
param([string]$EncodedCommand)
$shell = Get-Command pwsh.exe -CommandType Application -ErrorAction SilentlyContinue |
Select-Object -First 1
if (-not $shell) {
$shell = Get-Command powershell.exe -CommandType Application -ErrorAction Stop |
Select-Object -First 1
}
$shellArguments = "-NoLogo -NoProfile -NoExit -ExecutionPolicy Bypass -EncodedCommand $EncodedCommand"
$launch = @{ FilePath = $shell.Source; ArgumentList = $shellArguments; WindowStyle = 'Normal' }
$terminal = Get-Command wt.exe -CommandType Application -ErrorAction SilentlyContinue |
Select-Object -First 1
if ($terminal) {
$launch.FilePath = $terminal.Source
# Start-Process joins arguments: quote the executable path explicitly.
$launch.ArgumentList = '-w new new-tab --title Planet "' + $shell.Source + '" ' + $shellArguments
}
return $launch
}
function Start-PlanetRestart {
param([hashtable]$Target, [switch]$AlreadyElevated)
$script:PlanetLauncherExitCode = 0
if (-not (Test-PlanetAdministrator)) {
if ($AlreadyElevated) { throw 'Administrator elevation was not granted.' }
$isAdministrator = Test-PlanetAdministrator
if (-not $AlreadyElevated) {
$encoded = ConvertTo-PlanetEncodedCommand (Get-PlanetBootstrap $Target -RunElevated)
$launch = Get-PlanetTerminalLaunch $encoded
if (-not $isAdministrator) { $launch.Verb = 'RunAs' }
# An interactive terminal is intentional: startup logs and the WSL shell stay visible.
Start-Process powershell.exe -Verb RunAs -WindowStyle Normal -ArgumentList @(
'-NoLogo', '-NoProfile', '-NoExit', '-ExecutionPolicy', 'Bypass', '-EncodedCommand', $encoded
) | Out-Null
Start-Process @launch | Out-Null
return
}
if (-not $isAdministrator) { throw 'Administrator elevation was not granted.' }
Write-Host "Restarting Planet in $($Target.Distro):$($Target.LinuxProjectRoot)"
& wsl.exe -d $Target.Distro --cd $Target.LinuxProjectRoot --exec zsh -l -i ($Target.LinuxProjectRoot + '/scripts/windows/restart.zsh')
$script:PlanetLauncherExitCode = $LASTEXITCODE