Files
sindoring f8d242977d Make editor installation independent of the developer machine
Add a project launcher, per-user settings and Play state, explicit env import, pinned Git engine dependencies and a Windows distribution script.

Validated on Windows x64: formatting, workspace Clippy, 41 tests, local realm security test and release launches outside the repository with profile preservation.

Co-Authored-By: Codex <noreply@openai.com>
2026-11-04 16:39:47 +04:00

28 lines
1.5 KiB
PowerShell

# Prepare only the owner's local Compose deployment. No production compose command is used.
$ErrorActionPreference = 'Stop'
$playCore = $env:EDITOR_PLAY_CORE
if ($playCore -notmatch '^/[A-Za-z0-9_./-]+$' -or $playCore -match '(^|/)\.\.(/|$)') {
throw 'EDITOR_PLAY_CORE must be an absolute WSL path without shell metacharacters or traversal.'
}
function Invoke-PlayWsl([string] $Command) {
& wsl.exe -e bash -lc $Command
if ($LASTEXITCODE -ne 0) { throw "Local Play preparation failed (exit $LASTEXITCODE)." }
}
Invoke-PlayWsl "cd $playCore/deploy/local && ./compose.sh up -d db"
Invoke-PlayWsl "cd $playCore/deploy/local && ./apply-content.sh"
# A restart, not a table reload: creature spawns are held in the world's grids.
Invoke-PlayWsl "cd $playCore/deploy/local && ./compose.sh up -d realmd mangosd && ./compose.sh restart mangosd"
# The client must not race world startup. TCP readiness is bounded and runs off the UI thread.
$playDeadline = [DateTime]::UtcNow.AddSeconds(120)
$playPort = if ($env:EDITOR_PLAY_WORLD_PORT) { [int]$env:EDITOR_PLAY_WORLD_PORT } else { 8085 }
if ($playPort -lt 1 -or $playPort -gt 65535) { throw 'Invalid world port.' }
do {
$playSocket = [System.Net.Sockets.TcpClient]::new()
try {
$playConnect = $playSocket.ConnectAsync('127.0.0.1', $playPort)
if ($playConnect.Wait(1000) -and $playSocket.Connected) { exit 0 }
} catch { } finally { $playSocket.Dispose() }
Start-Sleep -Milliseconds 500
} while ([DateTime]::UtcNow -lt $playDeadline)
throw "Local world did not open port $playPort within 120 seconds."