Skip to content

Instantly share code, notes, and snippets.

@JanMikes
Created November 5, 2017 12:51
Show Gist options
  • Save JanMikes/bf5c69239fab7ec3f3debdc76e2525e6 to your computer and use it in GitHub Desktop.
Save JanMikes/bf5c69239fab7ec3f3debdc76e2525e6 to your computer and use it in GitHub Desktop.
<?xml version="1.0" encoding="UTF-8"?>
<project name="OdbavTo" default="createLocalConfig" basedir=".">
<property environment="env" />
<property name="configFile" value="app/config/config.local.neon" />
<target name="createLocalConfig" description="Creates local config file">
<available file="${configFile}" property="configExists" />
<if>
<isset property="configExists" />
<then>
<echo msg="Config ${configFile} already exists, removing it" />
<delete file="${configFile}" />
</then>
</if>
<echo msg="Creating ${configFile} config file" />
<touch file="${configFile}" />
<!-- PARAMETERS SECTION -->
<echo file="${configFile}" msg="parameters:${line.separator}" />
<!-- RabbitMQ -->
<if>
<or>
<isset property="env.RABBIT_HOST" />
<isset property="env.RABBIT_PORT" />
<isset property="env.RABBIT_USER" />
<isset property="env.RABBIT_PASSWORD" />
<isset property="env.RABBIT_VHOST" />
</or>
<then><append destFile="${configFile}" text=" rabbit:${line.separator}" /></then>
</if>
<if>
<isset property="env.RABBIT_HOST" />
<then><append destFile="${configFile}" text=" host: '${env.RABBIT_HOST}'${line.separator}" /></then>
</if>
<if>
<isset property="env.RABBIT_PORT" />
<then><append destFile="${configFile}" text=" port: '${env.RABBIT_PORT}'${line.separator}" /></then>
</if>
<if>
<isset property="env.RABBIT_USER" />
<then><append destFile="${configFile}" text=" user: '${env.RABBIT_USER}'${line.separator}" /></then>
</if>
<if>
<isset property="env.RABBIT_PASSWORD" />
<then><append destFile="${configFile}" text=" password: '${env.RABBIT_PASSWORD}'${line.separator}" /></then>
</if>
<if>
<isset property="env.RABBIT_VHOST" />
<then><append destFile="${configFile}" text=" vhost: '${env.RABBIT_VHOST}'${line.separator}" /></then>
</if>
<!-- Mailgun -->
<if>
<or>
<isset property="env.MAILGUN_API_KEY" />
<isset property="env.MAILGUN_DOMAIN" />
<isset property="env.MAILGUN_SENDER" />
</or>
<then><append destFile="${configFile}" text=" mailgun:${line.separator}" /></then>
</if>
<if>
<isset property="env.MAILGUN_API_KEY" />
<then><append destFile="${configFile}" text=" apiKey: '${env.MAILGUN_API_KEY}'${line.separator}" /></then>
</if>
<if>
<isset property="env.MAILGUN_DOMAIN" />
<then><append destFile="${configFile}" text=" domain: '${env.MAILGUN_DOMAIN}'${line.separator}" /></then>
</if>
<if>
<isset property="env.MAILGUN_SENDER" />
<then><append destFile="${configFile}" text=" sender: '${env.MAILGUN_SENDER}'${line.separator}" /></then>
</if>
<if>
<isset property="env.MAILGUN_CUSTOM_DOMAINS_ENABLED" />
<then><append destFile="${configFile}" text=" enableCustomDomains: ${env.MAILGUN_CUSTOM_DOMAINS_ENABLED}${line.separator}" /></then>
</if>
<!-- GPWebPay -->
<if>
<or>
<isset property="env.GPWEBPAY_URL" />
<isset property="env.GPWEBPAY_PUBLIC_KEY" />
</or>
<then><append destFile="${configFile}" text=" GPWebPay:${line.separator}" /></then>
</if>
<if>
<isset property="env.GPWEBPAY_URL" />
<then><append destFile="${configFile}" text=" webpayUrl: '${env.GPWEBPAY_URL}'${line.separator}" /></then>
</if>
<if>
<isset property="env.GPWEBPAY_PUBLIC_KEY" />
<then><append destFile="${configFile}" text=" publicKey: '${env.GPWEBPAY_PUBLIC_KEY}'${line.separator}" /></then>
</if>
<!-- Sentry -->
<if>
<isset property="env.SENTRY_HOST" />
<then>
<append destFile="${configFile}" text=" sentry:${line.separator}" />
<append destFile="${configFile}" text=" host: ${env.SENTRY_HOST}${line.separator}" />
</then>
</if>
<!-- ExpresDoklad -->
<if>
<or>
<isset property="env.EXPRESDOKLAD_ENDPOINTS_BASEURI" />
<isset property="env.EXPRESDOKLAD_CLIENT_ID" />
<isset property="env.EXPRESDOKLAD_SECRET" />
<isset property="env.EXPRESDOKLAD_USER" />
<isset property="env.EXPRESDOKLAD_PASSWORD" />
<isset property="env.EXPRESDOKLAD_COMPANY_ID" />
</or>
<then><append destFile="${configFile}" text=" expresDoklad:${line.separator}" /></then>
</if>
<if>
<isset property="env.EXPRESDOKLAD_ENDPOINTS_BASEURI" />
<then><append destFile="${configFile}" text=" endpoint: '${env.EXPRESDOKLAD_ENDPOINTS_BASEURI}'${line.separator}" /></then>
</if>
<if>
<isset property="env.EXPRESDOKLAD_CLIENT_ID" />
<then><append destFile="${configFile}" text=" clientId: '${env.EXPRESDOKLAD_CLIENT_ID}'${line.separator}" /></then>
</if>
<if>
<isset property="env.EXPRESDOKLAD_SECRET" />
<then><append destFile="${configFile}" text=" secret: '${env.EXPRESDOKLAD_SECRET}'${line.separator}" /></then>
</if>
<if>
<isset property="env.EXPRESDOKLAD_USER" />
<then><append destFile="${configFile}" text=" user: '${env.EXPRESDOKLAD_USER}'${line.separator}" /></then>
</if>
<if>
<isset property="env.EXPRESDOKLAD_PASSWORD" />
<then><append destFile="${configFile}" text=" password: '${env.EXPRESDOKLAD_PASSWORD}'${line.separator}" /></then>
</if>
<if>
<isset property="env.EXPRESDOKLAD_COMPANY_ID" />
<then><append destFile="${configFile}" text=" companyId: '${env.EXPRESDOKLAD_COMPANY_ID}'${line.separator}" /></then>
</if>
<!-- Doctrine -->
<if>
<or>
<isset property="env.MYSQL_HOST" />
<isset property="env.MYSQL_PORT" />
<isset property="env.MYSQL_USER" />
<isset property="env.MYSQL_PASSWORD" />
<isset property="env.MYSQL_DATABASE" />
</or>
<then><append destFile="${configFile}" text=" doctrine:${line.separator}" /></then>
</if>
<if>
<isset property="env.MYSQL_HOST" />
<then><append destFile="${configFile}" text=" host: '${env.MYSQL_HOST}'${line.separator}" /></then>
</if>
<if>
<isset property="env.MYSQL_PORT" />
<then><append destFile="${configFile}" text=" port: '${env.MYSQL_PORT}'${line.separator}" /></then>
</if>
<if>
<isset property="env.MYSQL_USER" />
<then><append destFile="${configFile}" text=" user: '${env.MYSQL_USER}'${line.separator}" /></then>
</if>
<if>
<isset property="env.MYSQL_PASSWORD" />
<then><append destFile="${configFile}" text=" password: '${env.MYSQL_PASSWORD}'${line.separator}" /></then>
</if>
<if>
<isset property="env.MYSQL_DATABASE" />
<then><append destFile="${configFile}" text=" dbname: '${env.MYSQL_DATABASE}'${line.separator}" /></then>
</if>
<!-- Facebook -->
<if>
<or>
<isset property="env.FACEBOOK_APP_ID" />
<isset property="env.FACEBOOK_APP_SECRET" />
<isset property="env.FACEBOOK_FORM_URL_MASK" />
</or>
<then><append destFile="${configFile}" text=" facebook:${line.separator}" /></then>
</if>
<if>
<isset property="env.FACEBOOK_APP_ID" />
<then><append destFile="${configFile}" text=" appId: '${env.FACEBOOK_APP_ID}'${line.separator}" /></then>
</if>
<if>
<isset property="env.FACEBOOK_APP_SECRET" />
<then><append destFile="${configFile}" text=" appSecret: '${env.FACEBOOK_APP_SECRET}'${line.separator}" /></then>
</if>
<if>
<isset property="env.FACEBOOK_FORM_URL_MASK" />
<then><append destFile="${configFile}" text=" formUrlMask: '${env.FACEBOOK_FORM_URL_MASK}'${line.separator}" /></then>
</if>
<!-- Google -->
<if>
<or>
<isset property="env.GOOGLE_APP_ID" />
<isset property="env.GOOGLE_API_KEY" />
<isset property="env.FORM_SHORTENER_URL_MASK" />
</or>
<then><append destFile="${configFile}" text=" google:${line.separator}" /></then>
</if>
<if>
<isset property="env.GOOGLE_APP_ID" />
<then><append destFile="${configFile}" text=" appId: '${env.GOOGLE_APP_ID}'${line.separator}" /></then>
</if>
<if>
<isset property="env.GOOGLE_API_KEY" />
<then><append destFile="${configFile}" text=" apiKey: '${env.GOOGLE_API_KEY}'${line.separator}" /></then>
</if>
<if>
<isset property="env.FORM_SHORTENER_URL_MASK" />
<then><append destFile="${configFile}" text=" formUrlMask: '${env.FORM_SHORTENER_URL_MASK}'${line.separator}" /></then>
</if>
<!-- Requests logging -->
<if>
<or>
<isset property="env.MONGODB_REQUEST_LOGS_HOST" />
<isset property="env.MONGODB_REQUEST_LOGS_DBNAME" />
</or>
<then><append destFile="${configFile}" text=" requestLogging:${line.separator}" /></then>
</if>
<if>
<isset property="env.MONGODB_REQUEST_LOGS_HOST" />
<then><append destFile="${configFile}" text=" host: '${env.MONGODB_REQUEST_LOGS_HOST}'${line.separator}" /></then>
</if>
<if>
<isset property="env.MONGODB_REQUEST_LOGS_DBNAME" />
<then><append destFile="${configFile}" text=" dbname: '${env.MONGODB_REQUEST_LOGS_DBNAME}'${line.separator}" /></then>
</if>
<!-- Swapcard -->
<if>
<isset property="env.SWAPCARD_TEST_MODE" />
<then>
<append destFile="${configFile}" text=" swapcard:${line.separator}" />
<append destFile="${configFile}" text=" testMode: ${env.SWAPCARD_TEST_MODE}${line.separator}" />
</then>
</if>
<!-- GoPay -->
<if>
<or>
<isset property="env.GOPAY_GO_ID" />
<isset property="env.GOPAY_CLIENT_ID" />
<isset property="env.GOPAY_CLIENT_SECRET" />
<isset property="env.GOPAY_IS_PRODUCTION" />
</or>
<then><append destFile="${configFile}" text=" goPay:${line.separator}" /></then>
</if>
<if>
<isset property="env.GOPAY_GO_ID" />
<then><append destFile="${configFile}" text=" goId: '${env.GOPAY_GO_ID}'${line.separator}" /></then>
</if>
<if>
<isset property="env.GOPAY_CLIENT_ID" />
<then><append destFile="${configFile}" text=" clientId: '${env.GOPAY_CLIENT_ID}'${line.separator}" /></then>
</if>
<if>
<isset property="env.GOPAY_CLIENT_SECRET" />
<then><append destFile="${configFile}" text=" clientSecret: '${env.GOPAY_CLIENT_SECRET}'${line.separator}" /></then>
</if>
<if>
<isset property="env.GOPAY_IS_PRODUCTION" />
<then><append destFile="${configFile}" text=" isProduction: ${env.GOPAY_IS_PRODUCTION}${line.separator}" /></then>
</if>
</target>
<target name="db:migrate" description="Migrates db to actual version and adds UUID as TEXT columns">
<exec command="bin/console migrations:migrate --no-interaction --allow-no-migration --quiet" passthru="true" />
<exec command="bin/console db:text-id-columns:add" passthru="true" />
</target>
<target name="db:sync" description="Two way database synchronization">
<exec command="bin/clear-cache" passthru="true" />
<exec command="bin/console db:text-id-columns:drop" passthru="true" />
<exec command="bin/console migrations:migrate --no-interaction --allow-no-migration --quiet" passthru="true" />
<exec command="bin/console migrations:diff --no-interaction" passthru="true" />
<exec command="bin/console migrations:migrate --no-interaction --allow-no-migration --quiet" passthru="true" />
<exec command="bin/console db:text-id-columns:add" passthru="true" />
<exec command="chmod -R 777 var/cache" passthru="true" />
</target>
</project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment