@echo off
title AI-WORKS Project Builder

echo ======================================
echo AI-WORKS Project Builder
echo ======================================
echo.

echo Checking Python...
python --version >nul 2>&1
if errorlevel 1 (
    echo [ERROR] Python is not installed or not in PATH.
    pause
    exit /b 1
)
echo Python OK

echo.
echo Checking PyInstaller...
python -m PyInstaller --version >nul 2>&1
if errorlevel 1 (
    echo [ERROR] PyInstaller is not installed.
    echo.
    echo Install command:
    echo pip install pyinstaller
    pause
    exit /b 1
)
echo PyInstaller OK

echo.
echo Cleaning old build files...
if exist build rmdir /s /q build
if exist dist rmdir /s /q dist
if exist AI-WORKS-ProjectGenerator.spec del AI-WORKS-ProjectGenerator.spec
if exist create_project.spec del create_project.spec

echo.
echo Building EXE...
python -m PyInstaller ^
--onefile ^
--console ^
--name AI-WORKS-ProjectGenerator ^
create_project.py

if errorlevel 1 (
    echo.
    echo [ERROR] Build failed.
    pause
    exit /b 1
)

echo.
echo ======================================
echo Build Success
echo ======================================
echo EXE path:
echo %cd%\dist\AI-WORKS-ProjectGenerator.exe
echo.

pause