Skip to content

Commit 7e4abd4

Browse files
authored
Merge pull request #4 from MuckRock/plugin-fixes
Addresses errors raised by Plugin Check
2 parents 27f6917 + bf0230f commit 7e4abd4

File tree

4 files changed

+123
-1
lines changed

4 files changed

+123
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
# WordPress Dev Environment
55
src/wordpress
6+
dist
67

78
# Composer
89
**/vendor

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,14 @@ npm test
161161

162162
Find more advanced instructions in `TESTING.md`
163163

164+
### Package for release
165+
166+
To create a new release:
167+
168+
1. Update the version number in `src/documentcloud/documentcloud.php` and `src/documentcloud/readme.txt`
169+
2. Update changelog for new version in `README.md` and `src/documentcloud/readme.txt`
170+
3. Run `package-plugin.sh` to generate ZIP file for distribution
171+
164172
## Changelog
165173

166174
### 0.6.0

package-plugin.sh

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
#!/bin/bash
2+
3+
# WordPress DocumentCloud Plugin Packaging Script
4+
# This script packages the plugin for distribution by copying files
5+
# and excluding development artifacts, hidden files, and node_modules
6+
#
7+
# Generated by Claude Sonnet 4 on 2025-06-24
8+
9+
set -e # Exit on any error
10+
11+
# Colors for output
12+
RED='\033[0;31m'
13+
GREEN='\033[0;32m'
14+
YELLOW='\033[1;33m'
15+
NC='\033[0m' # No Color
16+
17+
# Configuration
18+
PLUGIN_NAME="documentcloud"
19+
SOURCE_DIR="src/documentcloud"
20+
DIST_DIR="dist"
21+
ZIP_FILE="${PLUGIN_NAME}.zip"
22+
23+
echo -e "${YELLOW}📦 Starting WordPress DocumentCloud Plugin packaging...${NC}"
24+
25+
# Step 1: Clear and create dist directory
26+
echo -e "${YELLOW}🧹 Step 1: Cleaning dist directory...${NC}"
27+
if [ -d "$DIST_DIR" ]; then
28+
rm -rf "$DIST_DIR"
29+
echo " Removed existing dist directory"
30+
fi
31+
mkdir -p "$DIST_DIR"
32+
echo " Created fresh dist directory"
33+
34+
# Step 2: Copy plugin files with exclusions
35+
echo -e "${YELLOW}📋 Step 2: Copying plugin files...${NC}"
36+
37+
# Check if source directory exists
38+
if [ ! -d "$SOURCE_DIR" ]; then
39+
echo -e "${RED}❌ Error: Source directory $SOURCE_DIR not found!${NC}"
40+
exit 1
41+
fi
42+
43+
# Copy main plugin files (excluding hidden files and node_modules)
44+
echo " Copying main plugin files..."
45+
rsync -av \
46+
--exclude='.*' \
47+
--exclude='*/.*' \
48+
--exclude='node_modules/' \
49+
--exclude='blocks/' \
50+
"$SOURCE_DIR/" "$DIST_DIR/$PLUGIN_NAME/"
51+
52+
# Step 2.1: Clean up any remaining hidden files that might have been copied
53+
echo -e "${YELLOW}🧹 Step 2.1: Cleaning up hidden files...${NC}"
54+
find "$DIST_DIR/$PLUGIN_NAME" -name ".*" -type f -delete
55+
find "$DIST_DIR/$PLUGIN_NAME" -name ".DS_Store" -delete
56+
echo " Removed any remaining hidden files"
57+
58+
# Step 3: Handle blocks directory specially (only copy build folder)
59+
echo -e "${YELLOW}🔧 Step 3: Handling blocks directory...${NC}"
60+
BLOCKS_SOURCE="$SOURCE_DIR/blocks"
61+
BLOCKS_DEST="$DIST_DIR/$PLUGIN_NAME/blocks"
62+
63+
if [ -d "$BLOCKS_SOURCE/build" ]; then
64+
echo " Creating blocks directory structure..."
65+
mkdir -p "$BLOCKS_DEST"
66+
67+
echo " Copying blocks/build directory..."
68+
cp -r "$BLOCKS_SOURCE/build" "$BLOCKS_DEST/"
69+
70+
# Copy essential block files (package.json for reference)
71+
if [ -f "$BLOCKS_SOURCE/package.json" ]; then
72+
cp "$BLOCKS_SOURCE/package.json" "$BLOCKS_DEST/"
73+
echo " Copied package.json for reference"
74+
fi
75+
else
76+
echo -e "${YELLOW} ⚠️ Warning: blocks/build directory not found${NC}"
77+
fi
78+
79+
# Step 4: Create zip file
80+
echo -e "${YELLOW}🗜️ Step 4: Creating zip archive...${NC}"
81+
82+
cd "$DIST_DIR"
83+
# Remove existing zip file if it exists
84+
if [ -f "$ZIP_FILE" ]; then
85+
rm "$ZIP_FILE"
86+
echo " Removed existing $ZIP_FILE"
87+
fi
88+
89+
# Create zip file from dist directory
90+
zip -r "$ZIP_FILE" "$PLUGIN_NAME/" > /dev/null
91+
cd ..
92+
93+
echo " Created $ZIP_FILE"
94+
95+
# Step 5: Validate and report
96+
echo -e "${YELLOW}✅ Step 5: Validation and summary...${NC}"
97+
98+
cd "$DIST_DIR"
99+
# Check if zip was created successfully
100+
if [ -f "$ZIP_FILE" ]; then
101+
ZIP_SIZE=$(du -h "$ZIP_FILE" | cut -f1)
102+
echo -e "${GREEN}🎉 Success! Plugin packaged successfully${NC}"
103+
echo " 📁 Archive: $ZIP_FILE ($ZIP_SIZE)"
104+
echo " 📂 Contents preview:"
105+
unzip -l "$ZIP_FILE" | head -20
106+
echo
107+
echo -e "${GREEN}✨ Ready for distribution!${NC}"
108+
else
109+
echo -e "${RED}❌ Error: Failed to create zip file${NC}"
110+
exit 1
111+
fi
112+
113+
echo -e "${YELLOW}📦 Packaging complete!${NC}"

readme.txt renamed to src/documentcloud/readme.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Contributors: chrisamico, reefdog, freedmand
33
Tags: documentcloud, documents, journalism, reporting, research
44
Requires at least: 5.0
55
Tested up to: 6.8
6-
Stable tag: trunk
6+
Stable tag: 0.6.0
77
License: GPLv2
88
License URI: http://www.gnu.org/licenses/gpl-2.0.html
99

0 commit comments

Comments
 (0)