@echo off
:: DeployPro — Launch as Administrator
:: IIS management requires elevated privileges

NET SESSION >nul 2>&1
IF %ERRORLEVEL% NEQ 0 (
    echo Requesting administrator privileges...
    powershell -Command "Start-Process -FilePath '%~f0' -Verb RunAs"
    exit /B
)

cd /d "%~dp0"

:: Check if node_modules exists
IF NOT EXIST "node_modules\" (
    echo [DeployPro] Installing dependencies...
    call npm install
    IF %ERRORLEVEL% NEQ 0 (
        echo ERROR: npm install failed. Make sure Node.js is installed.
        pause
        exit /B 1
    )
)

echo.
echo  =========================================
echo   DeployPro - Enterprise IIS Pipeline
echo  =========================================
echo  Opening http://localhost:5000
echo  Press Ctrl+C to stop the server
echo.

:: Open browser after 2 seconds
start "" /B timeout /t 2 /nobreak >nul
start "" "http://localhost:7070"

:: Start server
node server.js

pause
