Files
wyt 6a366e0468 Validate packaged dependencies and coalesce local shutdown
Verify installed production dependency closure and packaged executable modes across supported targets. Preserve platform-owned launch behavior and drain independent local durability work once before ordinary exit.

Validation: affected native/runtime owners, shutdown/lifecycle cases, typechecks, smoke, and a normal visible macOS start/quit.
2026-10-17 21:25:29 +08:00

56 lines
2.1 KiB
Batchfile

@echo off
REM Windows counterpart of run.sh. An in-app relaunch waits for its exact
REM owner process. A direct launch closes only the previous source instance
REM owned by this checkout.
setlocal EnableExtensions EnableDelayedExpansion
set "APP_DIR=%~dp0"
if "%APP_DIR:~-1%"=="\" set "APP_DIR=%APP_DIR:~0,-1%"
if not exist "%APP_DIR%\package.json" (
echo [Orkas] %APP_DIR%\package.json not found; check the project directory layout. 1>&2
exit /b 1
)
echo [Orkas] Starting Orkas
node --version >nul 2>nul
if errorlevel 1 (
echo [Orkas] Node.js is unavailable; preparing the pinned bundled runtime...
powershell -NoLogo -NoProfile -ExecutionPolicy Bypass -File "%APP_DIR%\scripts\bootstrap-node.ps1"
if errorlevel 1 exit /b 1
set "RUNTIME_KEY=win32-x64"
if /I "%PROCESSOR_ARCHITECTURE%"=="ARM64" set "RUNTIME_KEY=win32-arm64"
if /I "%PROCESSOR_ARCHITEW6432%"=="ARM64" set "RUNTIME_KEY=win32-arm64"
set "PATH=%APP_DIR%\resources\runtime\node\!RUNTIME_KEY!;%PATH%"
)
node --version >nul 2>nul
if errorlevel 1 (
echo [Orkas] Node.js is still unavailable after bootstrap. 1>&2
exit /b 1
)
if defined ORKAS_RELAUNCH_OWNER_PID (
powershell -NoLogo -NoProfile -ExecutionPolicy Bypass -Command ^
"$owner = 0; if (-not [int]::TryParse($env:ORKAS_RELAUNCH_OWNER_PID, [ref]$owner) -or $owner -le 0) { exit 2 }; try { Wait-Process -Id $owner -Timeout 15 -ErrorAction Stop } catch { if (Get-Process -Id $owner -ErrorAction SilentlyContinue) { exit 3 } }"
if errorlevel 1 (
echo [Orkas] Relaunch owner did not exit within 15 seconds; refusing to terminate unrelated processes. 1>&2
exit /b 1
)
set "ORKAS_RELAUNCH_OWNER_PID="
)
call node "%APP_DIR%\scripts\stop-source-instance.cjs" --root "%APP_DIR%"
if errorlevel 1 exit /b 1
call node "%APP_DIR%\scripts\ensure-deps.cjs"
if errorlevel 1 exit /b 1
call node "%APP_DIR%\scripts\ensure-dev-dependencies.cjs"
if errorlevel 1 exit /b 1
pushd "%APP_DIR%"
REM Dependencies were prepared above; avoid repeating npm prestart:electron.
node "%APP_DIR%\node_modules\electron\cli.js" .
set "RC=%ERRORLEVEL%"
popd
exit /b %RC%