# Do not edit this file. It is automatically generated by https://www.oliverdavies.uk/build-configs.


default:
  @just --list

# Start the project
start:
  cp -v --no-clobber .env.example .env
  docker compose up -d

# Stop the project
stop:
  docker compose down

composer *args:
  just _exec php composer {{ args }}

alias phpunit := test

test *args:
  just _exec php phpunit --colors=always {{ args }}

test-watch *args:
  nodemon --ext "*" --watch "." --exec "just test  || exit 1" --ignore */sites/simpletest

drush *args:
  just _exec php drush {{ args }}

install *args:
  just _exec php drush site:install -y {{ args }}




# Enable or disable Git hooks
git-hooks command:
  #!/usr/bin/env bash
  set -euo pipefail

  case "{{ command }}" in
    "on")
      echo "Enabling Git hooks..."
      git config core.hooksPath .githooks
      ;;
    "off")
      echo "Disabling Git hooks..."
      git config --unset core.hooksPath
      ;;
    *)
      echo "Error: Invalid argument. Must be either 'on' or 'off'"
      ;;
  esac

test-commit:
  just _run php phpcs
  just _run php phpstan analyze --no-progress --memory-limit=512M
  just test --testdox --testsuite unit
  just test --testdox --testsuite kernel

_exec +args:
  docker compose exec -T {{ args }}

_run service command *args:
  docker compose run \
    --entrypoint {{ command }} \
    --no-deps \
    --rm \
    -T \
    {{ service }} {{ args }}

# vim: ft=just