Implements automatic creation of required plugin pages (Community Login, Trainer Registration, Trainer Dashboard) upon plugin activation. This addresses E2E test failures caused by missing pages in the test environment. - Adds activation hook in `hvac-community-events.php` to call `hvac_ce_create_required_pages`. - The callback function checks for existing pages by slug and creates them using `wp_insert_post` if missing. Includes debug logging. Also fixes issues identified during E2E test debugging: - Corrects fatal error in `includes/community/class-login-handler.php` by replacing undefined constant `HVAC_COMMUNITY_EVENTS_PATH` with `HVAC_CE_PLUGIN_DIR`. - Updates `tests/e2e/tests/login.spec.ts` to use the correct selector `#wp-submit` for the login form submit button instead of `button[type="submit"]`. Documentation updates: - Adds `docs/automatic-page-creation-plan.md`. - Updates `README.md` regarding automatic page creation. - Updates Memory Bank files (`decisionLog.md`, `progress.md`, `activeContext.md`). Note: Activation hook logging did not appear during WP-CLI activation, requiring further investigation if page creation issues persist. E2E test confirmation pending.
91 lines
No EOL
2.5 KiB
Bash
Executable file
91 lines
No EOL
2.5 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
# Load environment variables from current directory
|
|
if [ ! -f .env ]; then
|
|
echo "Error: .env file not found in current directory!"
|
|
exit 1
|
|
fi
|
|
|
|
source .env
|
|
|
|
# Rest of the original script follows
|
|
cat <<'EOF' >> /Users/ben/dev/upskill-event-manager/bin/sync-production-temp.sh
|
|
# Colors for output
|
|
GREEN='\033[0;32m'
|
|
RED='\033[0;31m'
|
|
YELLOW='\033[1;33m'
|
|
NC='\033[0m'
|
|
|
|
# Function to check if a command was successful
|
|
check_status() {
|
|
if [ $? -eq 0 ]; then
|
|
echo -e "${GREEN}✓ $1${NC}"
|
|
return 0
|
|
else
|
|
echo -e "${RED}✗ $1${NC}"
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
# Create backup directory
|
|
BACKUP_DIR="backups/$(date +%Y%m%d_%H%M%S)"
|
|
mkdir -p "$BACKUP_DIR"
|
|
echo -e "${YELLOW}Creating backup in: $BACKUP_DIR${NC}"
|
|
|
|
# Test SSH connection
|
|
echo "Testing SSH connection..."
|
|
if ! ssh -q "$PROD_SSH_USER@$PROD_HOST" exit; then
|
|
echo -e "${RED}Error: Cannot connect to production server${NC}"
|
|
exit 1
|
|
fi
|
|
check_status "SSH connection test"
|
|
|
|
# Download WordPress files
|
|
echo "Downloading WordPress files..."
|
|
rsync -avz --exclude='wp-config.php' \
|
|
--exclude='.git/' \
|
|
--exclude='node_modules/' \
|
|
--exclude='*.log' \
|
|
--exclude='wp-content/cache/' \
|
|
--exclude='wp-content/uploads/cache/' \
|
|
"$PROD_SSH_USER@$PROD_HOST:$PROD_PATH/" "$BACKUP_DIR/wordpress/"
|
|
check_status "WordPress files download"
|
|
|
|
# Export and download database
|
|
echo "Exporting production database..."
|
|
ssh "$PROD_SSH_USER@$PROD_HOST" "cd $PROD_PATH && wp db export - --add-drop-table" > "$BACKUP_DIR/database.sql"
|
|
check_status "Database export"
|
|
|
|
# Download wp-config.php (for reference)
|
|
echo "Downloading wp-config.php..."
|
|
scp "$PROD_SSH_USER@$PROD_HOST:$PROD_PATH/wp-config.php" "$BACKUP_DIR/wp-config.php.prod"
|
|
check_status "wp-config.php download"
|
|
|
|
# Create manifest file
|
|
echo "Creating backup manifest..."
|
|
cat > "$BACKUP_DIR/manifest.txt" << EOF
|
|
Production Backup Manifest
|
|
========================
|
|
Date: $(date)
|
|
Server: $PROD_HOST
|
|
WordPress Path: $PROD_PATH
|
|
Database: $PROD_DB_NAME
|
|
|
|
Environment Details:
|
|
- WordPress Version: $(ssh "$PROD_SSH_USER@$PROD_HOST" "cd $PROD_PATH && wp core version")
|
|
- PHP Version: $(ssh "$PROD_SSH_USER@$PROD_HOST" "php -v | head -n 1")
|
|
- MySQL Version: $(ssh "$PROD_SSH_USER@$PROD_HOST" "mysql -V")
|
|
|
|
Backup Contents:
|
|
- WordPress files (excluding wp-config.php, cache, etc.)
|
|
- Database dump (database.sql)
|
|
- Production wp-config.php (for reference)
|
|
EOF
|
|
|
|
# Create latest symlink
|
|
rm -f backups/latest
|
|
ln -s "$BACKUP_DIR" backups/latest
|
|
|
|
echo -e "${GREEN}Production sync completed successfully!${NC}"
|
|
echo "Backup stored in: $BACKUP_DIR"
|
|
EOF |