@echo off
chcp 65001 >nul
title Tamer SEO Analyzer V1.4.2 Build
cd /d "%~dp0"

echo ==============================================
echo  Tamer SEO Analyzer V1.4.2 EXE Build
echo ==============================================
echo.

where python >nul 2>nul
if errorlevel 1 (
    echo Python bulunamadi. Lutfen Python 3.10 veya uzeri kurun.
    pause
    exit /b 1
)

if not exist ".venv" (
    echo Sanal ortam olusturuluyor...
    python -m venv .venv
)

call .venv\Scripts\activate.bat
python -m pip install --upgrade pip
python -m pip install -r requirements.txt

if exist build rmdir /s /q build
if exist dist rmdir /s /q dist

pyinstaller ^
  --noconfirm ^
  --windowed ^
  --onefile ^
  --name "Tamer SEO Analyzer" ^
  --icon "assets\tamer_seo_analyzer.ico" ^
  --version-file "version_info.txt" ^
  app.py

if exist "dist\Tamer SEO Analyzer.exe" (
    xcopy /E /I /Y assets "dist\assets" >nul
    xcopy /E /I /Y docs "dist\docs" >nul
    copy /Y LICENSE.txt "dist\LICENSE.txt" >nul
    copy /Y update_info.json "dist\update_info.json" >nul
    if not exist "dist\reports" mkdir "dist\reports"
    echo.
    echo EXE hazir: dist\Tamer SEO Analyzer.exe
    echo Portable paket klasoru: dist
) else (
    echo.
    echo EXE olusturulamadi. Hata mesajlarini kontrol edin.
)

pause
