diff --git a/README-DEV.md b/README-DEV.md index 8ec8ecc..5769e40 100644 --- a/README-DEV.md +++ b/README-DEV.md @@ -278,7 +278,33 @@ test -f assets/build/editor-blocks.asset.php && echo "✓ Asset manifest present ### 3. Create Distribution Package -#### Method A: Manual Packaging (Recommended) +#### Using the Build Script (Recommended) + +A convenience bash script is included to automate distribution packaging: + +```bash +./build-distribution.sh +``` + +This script: +- Creates a clean working directory +- Excludes all development files and dependencies +- Includes only files needed for distribution +- Generates a ZIP archive +- Displays summary information + +**Excluded from the distribution**: +- `node_modules/` (development dependencies) +- `src/` (source code for building) +- `test/` (test files) +- `package.json` / `package-lock.json` +- `webpack.config.js` (build config) +- `README-DEV.md` (developer guide) +- `.git`, `.gitignore`, `.DS_Store`, and other system files + +#### Manual Packaging (Alternative) + +If you prefer to create the distribution manually: ```bash # Create a clean directory for the distribution @@ -288,13 +314,16 @@ PLUGIN_NAME="swiss-football-matchdata" # Copy all plugin files (excluding development files) rsync -av --exclude='.git' \ --exclude='node_modules' \ - --exclude='.npm' \ + --exclude='.npm-cache' \ --exclude='package-lock.json' \ --exclude='.gitignore' \ --exclude='README-DEV.md' \ --exclude='.DS_Store' \ --exclude='*.swp' \ --exclude='.idea/' \ + --exclude='test/' \ + --exclude='src/' \ + --exclude='webpack.config.js' \ . dist/$PLUGIN_NAME/ # Create ZIP archive @@ -306,17 +335,6 @@ cd .. echo "Distribution package created: dist/$PLUGIN_NAME.zip" ``` -#### Method B: Using Git Archive (Cleaner) - -If your `.gitignore` is properly configured to exclude development files: - -```bash -git archive --output=dist/swiss-football-matchdata.zip HEAD \ - --prefix=swiss-football-matchdata/ -``` - -This creates the distribution package from committed files only (respecting `.gitignore`). - ### 4. Verify Distribution Package ```bash @@ -333,8 +351,10 @@ unzip -l dist/swiss-football-matchdata.zip | head -30 # ✗ node_modules/ (development dependencies) # ✗ package.json / package-lock.json # ✗ README-DEV.md (developer guide) -# ✗ .git (git history) # ✗ src/ (source code — users don't need it) +# ✗ test/ (test files) +# ✗ webpack.config.js (build configuration) +# ✗ .git (git history) ``` ### 5. Size Check @@ -481,16 +501,36 @@ npm start | Install deps | `npm install` | | Build for production | `npm run build` | | Development with hot reload | `npm start` | -| Create distribution ZIP | `git archive --output=dist/swiss-football-matchdata.zip HEAD --prefix=swiss-football-matchdata/` | +| Create distribution ZIP | `./build-distribution.sh` | | Check PHP syntax | `php -l includes/class-swi-foot-blocks.php` | | Fix linting issues | `npx eslint src/ --fix` | +## API Reference + +This plugin integrates with the Swiss Football Association Club API. The API structure and endpoints are documented in the OpenAPI/Swagger specification: + +**Swagger UI**: https://stg-club-api-services.football.ch/swagger/index.html + +This documentation provides: +- All available REST endpoints +- Request/response schemas +- Authentication requirements +- Rate limits and performance guidelines +- Example requests and responses + +Refer to this documentation when: +- Adding new API integrations +- Understanding the data structures used in the plugin +- Debugging API-related issues +- Extending plugin functionality with additional endpoints + ## Additional Resources - [WordPress Block Editor Handbook](https://developer.wordpress.org/block-editor/) - [WordPress Plugin Handbook](https://developer.wordpress.org/plugins/) - [@wordpress/scripts Documentation](https://developer.wordpress.org/block-editor/reference-guides/packages/packages-scripts/) - [WordPress Coding Standards](https://developer.wordpress.org/coding-standards/) +- [Swiss Football Club API Swagger Specification](https://stg-club-api-services.football.ch/swagger/index.html) ## Support diff --git a/build-distribution.sh b/build-distribution.sh new file mode 100755 index 0000000..f471e31 --- /dev/null +++ b/build-distribution.sh @@ -0,0 +1,105 @@ +#!/bin/bash + +# Swiss Football Matchdata - Distribution Package Builder +# This script creates a distribution-ready ZIP package excluding development files + +set -e # Exit on error + +PLUGIN_NAME="swiss-football-matchdata" +DIST_DIR="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 we're in the plugin root directory +if [ ! -f "package.json" ]; then + echo "Error: package.json not found. Run this script from the plugin root directory." + 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 \ + --exclude='.git' \ + --exclude='node_modules' \ + --exclude='.npm-cache' \ + --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='build-distribution.sh' \ + --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/" +cd .. + +# 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 " ✗ 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"