#!/usr/bin/env bash
# adapters/wordpress/hooks/pre-push — WordPress adapter overlay
#
# Appended below the core pre-push by `phaseops init` when the
# WordPress adapter is enabled. Preserves the upstream test-suite gates
# (Pest + PHPStan) — these require Composer/PHP and live here, not core.

set -euo pipefail

if [ "${PHASEOPS_WP_NO_PREPUSH:-0}" = "1" ]; then
  exit 0
fi

echo "[wordpress] running WP adapter pre-push checks..." >&2

if [ -f "vendor/bin/pest" ]; then
  vendor/bin/pest || {
    echo "ERROR [wordpress]: Pest tests failed on pre-push." >&2
    exit 1
  }
fi

if [ -f "vendor/bin/phpstan" ]; then
  vendor/bin/phpstan analyse || {
    echo "ERROR [wordpress]: PHPStan analysis failed on pre-push." >&2
    exit 1
  }
fi
