diff --git a/.gitignore b/.gitignore index 225b2d4..291381c 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ # WordPress Dev Environment src/wordpress +dist # Composer **/vendor diff --git a/README.md b/README.md index bd27ee6..3986b01 100644 --- a/README.md +++ b/README.md @@ -161,6 +161,14 @@ npm test Find more advanced instructions in `TESTING.md` +### Package for release + +To create a new release: + +1. Update the version number in `src/documentcloud/documentcloud.php` and `src/documentcloud/readme.txt` +2. Update changelog for new version in `README.md` and `src/documentcloud/readme.txt` +3. Run `package-plugin.sh` to generate ZIP file for distribution + ## Changelog ### 0.6.0 diff --git a/package-plugin.sh b/package-plugin.sh new file mode 100755 index 0000000..0713dbe --- /dev/null +++ b/package-plugin.sh @@ -0,0 +1,113 @@ +#!/bin/bash + +# WordPress DocumentCloud Plugin Packaging Script +# This script packages the plugin for distribution by copying files +# and excluding development artifacts, hidden files, and node_modules +# +# Generated by Claude Sonnet 4 on 2025-06-24 + +set -e # Exit on any error + +# Colors for output +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +NC='\033[0m' # No Color + +# Configuration +PLUGIN_NAME="documentcloud" +SOURCE_DIR="src/documentcloud" +DIST_DIR="dist" +ZIP_FILE="${PLUGIN_NAME}.zip" + +echo -e "${YELLOW}๐Ÿ“ฆ Starting WordPress DocumentCloud Plugin packaging...${NC}" + +# Step 1: Clear and create dist directory +echo -e "${YELLOW}๐Ÿงน Step 1: Cleaning dist directory...${NC}" +if [ -d "$DIST_DIR" ]; then + rm -rf "$DIST_DIR" + echo " Removed existing dist directory" +fi +mkdir -p "$DIST_DIR" +echo " Created fresh dist directory" + +# Step 2: Copy plugin files with exclusions +echo -e "${YELLOW}๐Ÿ“‹ Step 2: Copying plugin files...${NC}" + +# Check if source directory exists +if [ ! -d "$SOURCE_DIR" ]; then + echo -e "${RED}โŒ Error: Source directory $SOURCE_DIR not found!${NC}" + exit 1 +fi + +# Copy main plugin files (excluding hidden files and node_modules) +echo " Copying main plugin files..." +rsync -av \ + --exclude='.*' \ + --exclude='*/.*' \ + --exclude='node_modules/' \ + --exclude='blocks/' \ + "$SOURCE_DIR/" "$DIST_DIR/$PLUGIN_NAME/" + +# Step 2.1: Clean up any remaining hidden files that might have been copied +echo -e "${YELLOW}๐Ÿงน Step 2.1: Cleaning up hidden files...${NC}" +find "$DIST_DIR/$PLUGIN_NAME" -name ".*" -type f -delete +find "$DIST_DIR/$PLUGIN_NAME" -name ".DS_Store" -delete +echo " Removed any remaining hidden files" + +# Step 3: Handle blocks directory specially (only copy build folder) +echo -e "${YELLOW}๐Ÿ”ง Step 3: Handling blocks directory...${NC}" +BLOCKS_SOURCE="$SOURCE_DIR/blocks" +BLOCKS_DEST="$DIST_DIR/$PLUGIN_NAME/blocks" + +if [ -d "$BLOCKS_SOURCE/build" ]; then + echo " Creating blocks directory structure..." + mkdir -p "$BLOCKS_DEST" + + echo " Copying blocks/build directory..." + cp -r "$BLOCKS_SOURCE/build" "$BLOCKS_DEST/" + + # Copy essential block files (package.json for reference) + if [ -f "$BLOCKS_SOURCE/package.json" ]; then + cp "$BLOCKS_SOURCE/package.json" "$BLOCKS_DEST/" + echo " Copied package.json for reference" + fi +else + echo -e "${YELLOW} โš ๏ธ Warning: blocks/build directory not found${NC}" +fi + +# Step 4: Create zip file +echo -e "${YELLOW}๐Ÿ—œ๏ธ Step 4: Creating zip archive...${NC}" + +cd "$DIST_DIR" +# Remove existing zip file if it exists +if [ -f "$ZIP_FILE" ]; then + rm "$ZIP_FILE" + echo " Removed existing $ZIP_FILE" +fi + +# Create zip file from dist directory +zip -r "$ZIP_FILE" "$PLUGIN_NAME/" > /dev/null +cd .. + +echo " Created $ZIP_FILE" + +# Step 5: Validate and report +echo -e "${YELLOW}โœ… Step 5: Validation and summary...${NC}" + +cd "$DIST_DIR" +# Check if zip was created successfully +if [ -f "$ZIP_FILE" ]; then + ZIP_SIZE=$(du -h "$ZIP_FILE" | cut -f1) + echo -e "${GREEN}๐ŸŽ‰ Success! Plugin packaged successfully${NC}" + echo " ๐Ÿ“ Archive: $ZIP_FILE ($ZIP_SIZE)" + echo " ๐Ÿ“‚ Contents preview:" + unzip -l "$ZIP_FILE" | head -20 + echo + echo -e "${GREEN}โœจ Ready for distribution!${NC}" +else + echo -e "${RED}โŒ Error: Failed to create zip file${NC}" + exit 1 +fi + +echo -e "${YELLOW}๐Ÿ“ฆ Packaging complete!${NC}" diff --git a/readme.txt b/src/documentcloud/readme.txt similarity index 99% rename from readme.txt rename to src/documentcloud/readme.txt index 37b2ea2..c992bed 100644 --- a/readme.txt +++ b/src/documentcloud/readme.txt @@ -3,7 +3,7 @@ Contributors: chrisamico, reefdog, freedmand Tags: documentcloud, documents, journalism, reporting, research Requires at least: 5.0 Tested up to: 6.8 -Stable tag: trunk +Stable tag: 0.6.0 License: GPLv2 License URI: http://www.gnu.org/licenses/gpl-2.0.html