-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart-app.bat
More file actions
41 lines (32 loc) · 1.12 KB
/
start-app.bat
File metadata and controls
41 lines (32 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
@echo off
setlocal
cd /d "%~dp0"
where pnpm >nul 2>nul
if errorlevel 1 (
echo [ERROR] pnpm is not installed or not on PATH.
echo Install it once with: npm install -g pnpm
pause
exit /b 1
)
for /f %%p in ('powershell -NoProfile -Command "$port=5173; while($port -le 5200){ try { $l=[System.Net.Sockets.TcpListener]::new([System.Net.IPAddress]::Loopback,$port); $l.Start(); $l.Stop(); Write-Output $port; break } catch { $port++ } }"') do set "DEV_PORT=%%p"
if not defined DEV_PORT (
echo [ERROR] Could not find a free port between 5173 and 5200.
pause
exit /b 1
)
set "APP_URL=http://localhost:%DEV_PORT%/"
echo Starting CV Builder dev server...
echo Project: %CD%
echo URL: %APP_URL%
echo.
start "CV Builder Dev Server" cmd /k "cd /d ""%~dp0"" && pnpm dev -- --port %DEV_PORT% --strictPort"
echo Waiting for dev server to be ready...
:wait_loop
powershell -NoProfile -Command "try { Invoke-WebRequest -Uri '%APP_URL%' -UseBasicParsing -TimeoutSec 2 ^| Out-Null; exit 0 } catch { exit 1 }" >nul 2>nul
if errorlevel 1 (
timeout /t 1 /nobreak >nul
goto wait_loop
)
start "" "%APP_URL%"
echo Browser opened: %APP_URL%
endlocal