Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

# WordPress Dev Environment
src/wordpress
dist

# Composer
**/vendor
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
113 changes: 113 additions & 0 deletions package-plugin.sh
Original file line number Diff line number Diff line change
@@ -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}"
2 changes: 1 addition & 1 deletion readme.txt → src/documentcloud/readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down