#!/bin/bash
set -e
PHP=/usr/local/php8.4/bin/php
RMU=/homez.699/ingeventkl/dww/wp-content/mu-plugins
BK="$HOME/dww-mu-backup-20260617"
mkdir -p "$BK"
echo '=== lint staged template ==='
$PHP -l "$HOME/deploy-stage/templates/page-investor-directory.php"
echo '=== backup live files ==='
cp "$RMU/templates/page-investor-directory.php" "$BK/page-investor-directory.php.pre-capital" 2>/dev/null || echo '(no prior template backup name clash)'
echo '=== install ==='
cp "$HOME/deploy-stage/templates/page-investor-directory.php" "$RMU/templates/"
cp "$HOME/deploy-stage/data/dww-capital-data.json" "$RMU/data/"
echo 'installed'
echo '=== purge cache ==='
rm -rf "$HOME/dww/wp-content/cache/all" "$HOME/www/wp-content/cache/all" 2>/dev/null || true
echo 'done'
echo '=== verify on disk ==='
echo -n 'capital articles in data: '; grep -o '"slug"' "$RMU/data/dww-capital-data.json" | wc -l
echo -n 'module present in template: '; grep -c 'id="dwwcap"' "$RMU/templates/page-investor-directory.php"
