<?xml version="1.0" encoding="UTF-8"?>
<project name="Torsearch" default="build">
    <!-- build dev for dev envs -->
    <target name="build" depends="setEnv,composer,compileAssets,migrateDb,clearCache" />

    <target name="composer" description="Run composer">
        <exec executable="composer">
            <arg value="install" />
            <arg value="--ignore-platform-reqs" />
        </exec>
    </target>

    <target name="setEnv" description="Set the database configuration">
        <copy file="${project.basedir}/.env.properties" tofile="${project.basedir}/.env.local" overwrite="true">
        </copy>
    </target>

    <target name="compileAssets" description="Run composer">
        <exec executable="php">
            <arg value="bin/console" />
            <arg value="tailwind:build" />
        </exec>
        <exec executable="php">
            <arg value="bin/console" />
            <arg value="asset-map:compile" />
        </exec>
    </target>

    <target name="migrateDb" description="Migrate the database">
        <exec executable="php">
            <arg value="bin/console" />
            <arg value="--no-interaction" />
            <arg value="doctrine:migrations:migrate" />
        </exec>
    </target>

    <target name="clearCache" description="Clear the application cache">
        <exec executable="php">
            <arg value="bin/console" />
            <arg value="cache:pool:clear" />
            <arg value="cache.app" />
        </exec>
    </target>
</project>
