#!/bin/bash # Swiss Football Matchdata - Distribution Package Builder # This script creates a distribution-ready ZIP package excluding development files set -e # Exit on error # Get the directory where this script is located SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" PLUGIN_ROOT="$(dirname "$SCRIPT_DIR")" PLUGIN_NAME="swiss-football-matchdata" DIST_DIR="$PLUGIN_ROOT/dist" # Colors for output GREEN='\033[0;32m' BLUE='\033[0;34m' NC='\033[0m' # No Color echo -e "${BLUE}=== Building Distribution Package ===${NC}" # Create distribution directory echo "Creating distribution directory..." mkdir -p "$DIST_DIR" # Check if plugin root has package.json if [ ! -f "$PLUGIN_ROOT/package.json" ]; then echo "Error: package.json not found in $PLUGIN_ROOT" exit 1 fi # Clean up any previous distribution echo "Cleaning up previous distribution..." rm -rf "$DIST_DIR/$PLUGIN_NAME" "$DIST_DIR/$PLUGIN_NAME.zip" # Copy all plugin files, excluding development artifacts echo "Copying plugin files (excluding development files)..." rsync -av "$PLUGIN_ROOT/" \ --exclude='.git' \ --exclude='node_modules' \ --exclude='.npm-cache' \ --exclude='package.json' \ --exclude='package-lock.json' \ --exclude='.gitignore' \ --exclude='README-DEV.md' \ --exclude='DEV-README.md' \ --exclude='.DS_Store' \ --exclude='*.swp' \ --exclude='.idea/' \ --exclude='test/' \ --exclude='src/' \ --exclude='webpack.config.js' \ --exclude='dev-scripts/' \ --exclude='dev-docs/' \ --exclude='dist/' \ "$DIST_DIR/$PLUGIN_NAME/" \ > /dev/null 2>&1 || true # Verify essential files are present echo "Verifying distribution contents..." if [ ! -f "$DIST_DIR/$PLUGIN_NAME/swiss-football-matchdata.php" ]; then echo "Error: Main plugin file not found in distribution" exit 1 fi if [ ! -f "$DIST_DIR/$PLUGIN_NAME/assets/build/editor-blocks.js" ]; then echo "Error: Compiled editor bundle not found. Run 'npm run build' first." exit 1 fi # Create ZIP archive echo "Creating ZIP archive..." (cd "$DIST_DIR" && zip -r -q "$PLUGIN_NAME.zip" "$PLUGIN_NAME/") # Get file sizes DIST_SIZE=$(du -sh "$DIST_DIR/$PLUGIN_NAME" | cut -f1) ZIP_SIZE=$(ls -lh "$DIST_DIR/$PLUGIN_NAME.zip" | awk '{print $5}') echo -e "${GREEN}✓ Distribution package created successfully!${NC}" echo "" echo "📦 Distribution Summary:" echo " Location: $DIST_DIR/$PLUGIN_NAME.zip" echo " Uncompressed size: $DIST_SIZE" echo " Compressed ZIP size: $ZIP_SIZE" echo "" # List key files included echo "📋 Key files included:" echo " ✓ swiss-football-matchdata.php (main plugin file)" echo " ✓ assets/build/editor-blocks.js (compiled editor bundle)" echo " ✓ includes/* (PHP backend files)" echo " ✓ blocks/* (block metadata)" echo " ✓ languages/* (i18n translations)" echo " ✓ README.md (user documentation)" echo "" # List what was excluded echo "🚫 Excluded from distribution:" echo " ✗ node_modules/ (development dependencies)" echo " ✗ src/ (source files)" echo " ✗ test/ (test files)" echo " ✗ dev-scripts/ (scripts for development)" echo " ✗ dev-docs/ (development documentation)" echo " ✗ package.json / package-lock.json" echo " ✗ webpack.config.js" echo " ✗ README-DEV.md" echo " ✗ .git (git history)" echo "" echo -e "${GREEN}Ready to distribute!${NC}" echo "Install by uploading $DIST_DIR/$PLUGIN_NAME.zip to WordPress Admin → Plugins → Add New → Upload"