<?xml version="1.0" encoding="UTF-8" ?>
<project name="Case Converter" description="Case Converter class" default="help" phingVersion="3.0">
<defaultexcludes default="true"/><!--Initializing default excludes-->
<defaultexcludes add="**/.idea"/>
<defaultexcludes add="**/.idea/**"/>
<property name="phing.http.proxy" value="${env.http_proxy}"/>
<target name="help">
<loadfile property="help" file="docs/dev.md"/>
<echo>${line.separator}${help}</echo>
</target>
<target name="setup"
description="Install dependencies"
depends="composer:install-dev, phive:install, cc:get"/>
<target name="qa"
description="Run quality tests"
depends="php:lint, composer:validate, phpunit:run, behat:run, phpstan:run, phploc:run"/>
<target name="docs:refresh-images"
description="Update and regenerate docs images"
depends="uml-writer:render, phing:visualize, plantuml:puml-to-png"/>
<target name="phploc:run">
<phploc pharlocation="bin/phploc">
<fileset dir="src"/>
</phploc>
</target>
<target name="composer:validate" description="Check composer.json syntax">
<composer command="validate">
<arg value="--strict"/>
<arg value="--no-check-lock"/>
</composer>
</target>
<target name="composer:install-dev">
<composer command="install">
<arg value="--no-suggest"/>
<arg value="--no-interaction"/>
<arg value="--profile"/>
<arg value="--prefer-dist"/>
</composer>
</target>
<target name="phpunit:open-coverage" description="Open coverage site" depends="phpunit:run">
<exec executable="xdg-open">
<arg file="resources/coverage-html/index.html"/>
</exec>
</target>
<target name="php:lint" description="Check syntax on PHP files">
<phplint>
<fileset dir="${project.basedir}">
<include name="**/*.php"/>
<exclude name="vendor/"/>
</fileset>
</phplint>
</target>
<target name="behat:run" description="Run behat tests">
<exec executable="bin/behat" passthru="true" checkreturn="true">
<arg value="--colors"/>
<arg value="--no-interaction"/>
<arg value="--stop-on-failure"/>
<arg value="--rerun"/>
<arg value="--strict"/>
</exec>
</target>
<target name="phpstan:run">
<exec executable="bin/phpstan" passthru="true" checkreturn="true">
<arg line="--level=max analyze"/>
<arg value="--no-progress"/>
<arg path="src"/>
</exec>
</target>
<target name="phpunit:run" description="Run unit tests">
<mkdir dir="resources/coverage-html/"/>
<exec executable="bin/phpunit.phar" passthru="true" checkreturn="true">
<arg line="--configuration=config/phpunit.xml"/>
<arg value="--testdox"/>
<arg value="--verbose"/>
<arg value="--stop-on-defect"/>
</exec>
</target>
<target name="phive:install" description="Install Phar">
<exec executable="phive" passthru="true" checkreturn="true">
<arg value="--no-progress"/>
<arg value="install"/>
<arg value="--force-accept-unsigned"/>
<arg line="--trust-gpg-keys 4AA394086372C20A,8E730BA25823D8B5,2420BAE0A3BE25C6,31C7E470E2138192"/>
</exec>
</target>
<target name="changelog:links" description="Update links in composer.json">
<composer command="require">
<arg value="symplify/changelog-linker"/>
</composer>
<exec executable="vendor/bin/changelog-linker">
<arg value="link"/>
</exec>
<composer command="remove">
<arg value="symplify/changelog-linker"/>
</composer>
</target>
<target name="cc:get" description="Download Code Climate">
<property name="cc.dir" value="bin"/>
<property name="cc.filename" value="cc-test-reporter"/>
<if>
<not>
<available file="${cc.dir}/${cc.filename}"/>
</not>
<then>
<mkdir dir="${cc.dir}"/>
<httpget dir="${cc.dir}"
filename="${cc.filename}"
followRedirects="true"
url="https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64"/>
</then>
</if>
<chmod file="${cc.dir}/${cc.filename}" mode="0775"/>
<exec executable="${cc.dir}/${cc.filename}" passthru="true" checkreturn="true">
<arg value="--version"/>
</exec>
</target>
<target name="cc:before-build" description="To run before a build">
<exec executable="bin/cc-test-reporter" passthru="true" checkreturn="true">
<arg value="before-build"/>
</exec>
</target>
<target name="cc:after-build" description="Handle & upload coverage payload">
<fail unless="env.CC_TEST_REPORTER_ID"
message="you must supply a CC_TEST_REPORTER_ID ENV variable"/>
<exec executable="bin/cc-test-reporter" passthru="true" checkreturn="true">
<arg value="format-coverage"/>
<arg line="--input-type clover"/>
<arg file="resources/coverage/clover.xml"/>
</exec>
<exec executable="bin/cc-test-reporter" passthru="true" checkreturn="true">
<arg value="upload-coverage"/>
</exec>
</target>
<target name="plantuml:puml-to-png" description="Parse PlantUML files to image from docs dir">
<composer command="require">
<arg value="jawira/plantuml"/>
</composer>
<exec executable="vendor/bin/plantuml" passthru="true" checkreturn="true">
<arg path="docs/**.puml/"/>
</exec>
<composer command="remove">
<arg value="jawira/plantuml"/>
</composer>
</target>
<target name="git:tags-listing" description="List all git tags">
<!-- https://stackoverflow.com/a/34239190/4345061 -->
<exec executable="git" passthru="true">
<arg value="log"/>
<arg line="--graph --all --decorate --oneline --simplify-by-decoration"/>
</exec>
</target>
<target name="phing:visualize" description="Update build.png">
<composer command="require">
<arg value="jawira/phing-visualizer"/>
</composer>
<exec executable="vendor/bin/phing-visualizer">
<arg value="--format"/>
<arg value="puml"/>
<arg value="--output"/>
<arg path="./docs/images/"/>
</exec>
<composer command="remove">
<arg value="jawira/phing-visualizer"/>
</composer>
</target>
<target name="uml-writer:render" description="Generate Class diagram">
<composer command="require">
<arg value="bartlett/php-reflect"/>
<arg value="bartlett/umlwriter"/>
</composer>
<exec executable="vendor/bin/umlwriter" output="docs/images/uml-case-converter.puml">
<arg line="diagram:render:namespace"/>
<arg value="--processor=plantuml"/>
<arg path="src"/>
<arg value="Jawira\\CaseConverter"/>
</exec>
<exec executable="vendor/bin/umlwriter" output="docs/images/uml-glue.puml">
<arg line="diagram:render:namespace"/>
<arg value="--processor=plantuml"/>
<arg path="src/Glue"/>
<arg value="Jawira\\CaseConverter\\Glue"/>
</exec>
<exec executable="vendor/bin/umlwriter" output="docs/images/uml-split.puml">
<arg line="diagram:render:namespace"/>
<arg value="--processor=plantuml"/>
<arg path="src/Split"/>
<arg value="Jawira\\CaseConverter\\Split"/>
</exec>
<composer command="remove">
<arg value="bartlett/php-reflect"/>
<arg value="bartlett/umlwriter"/>
</composer>
</target>
<target name="docs:deploy"
description="Deploy documentation to gh-pages"
depends="docs:build">
<exec executable="mkdocs" passthru="true" checkreturn="true">
<arg value="gh-deploy"/>
</exec>
</target>
<target name="docs:serve"
description="Generate and open static site"
depends="docs:build">
<parallel threadCount="2">
<exec executable="mkdocs" passthru="true" checkreturn="true">
<arg value="serve"/>
</exec>
<exec executable="xdg-open" passthru="true" checkreturn="true">
<!--Please F5 after some seconds-->
<arg value="http://127.0.0.1:8000/"/>
</exec>
</parallel>
</target>
<target name="docs:build" description="Builds static site" depends="docs:refresh-images, docs:copy-md">
<exec executable="mkdocs" passthru="true" checkreturn="true">
<arg value="build"/>
</exec>
</target>
<target name="docs:copy-md" description="Copy md files from root to docs dir">
<!--*.md files should not have relative paths-->
<copy file="./README.md" tofile="./docs/index.md" overwrite="true"/>
<copy file="./CONTRIBUTING.md" tofile="./docs/contributing.md" overwrite="true"/>
<copy file="./LICENSE.md" tofile="./docs/license.md" overwrite="true"/>
<copy file="./CHANGELOG.md" tofile="./docs/changelog.md" overwrite="true"/>
</target>
</project>
|