@echo off
setlocal EnableExtensions EnableDelayedExpansion

cd /d "%~dp0"

echo ==== Build started at %DATE% %TIME% ====

REM Check pnpm
where pnpm >nul 2>&1
if errorlevel 1 (
    echo ERROR: pnpm not found on PATH.
    exit /b 1
)

REM Check git repository
if not exist ".git" (
    echo ERROR: This is not a git repository.
    exit /b 1
)

REM Install dependencies
echo Installing dependencies...
call pnpm install || goto :fail

REM Build
echo Building Vencord...
call pnpm build || goto :fail

REM Inject
echo Injecting into client...
call pnpm inject /Y || goto :fail

echo.
echo Build completed successfully.
echo ==== SUCCESS at %DATE% %TIME% ====
exit /b 0

:fail
echo.
echo ERROR: Build failed.
echo ==== FAILURE at %DATE% %TIME% ====
exit /b 1
