-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathbuild-zip.sh
More file actions
executable file
·99 lines (87 loc) · 2.8 KB
/
Copy pathbuild-zip.sh
File metadata and controls
executable file
·99 lines (87 loc) · 2.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/bin/bash
# Build script for creating distribution zip
# Only includes production files and runtime dependencies
set -e
PLUGIN_SLUG="knowledgebase"
BUILD_DIR="build"
TEMP_DIR="$BUILD_DIR/$PLUGIN_SLUG"
echo "Creating distribution zip for $PLUGIN_SLUG..."
# Clean build directory
rm -rf "$BUILD_DIR"
mkdir -p "$TEMP_DIR"
# Copy plugin files (excluding dev/build artifacts and all of vendor)
echo "Copying plugin files..."
rsync -av --exclude-from=- . "$TEMP_DIR/" <<EOF
.*
.git/
.github/
node_modules/
phpcompat-tools/
phpunit/
/build/
vendor/
dev-helpers/
dev-tools/
wporg-assets/
test-tools/
docs/
includes/frontend/blocks/src/
includes/pro/blocks/src/
build-assets.js
*.dist
*.yml
*.neon
composer.json
composer.lock
package.json
package-lock.json
phpstan-bootstrap.php
build-zip.sh
CODE_OF_CONDUCT.md
CONTRIBUTING.md
ISSUE_TEMPLATE.md
PULL_REQUEST_TEMPLATE.md
CLAUDE.md
AGENTS.md
EOF
# Copy required vendor dependencies (everything in vendor/ is excluded above,
# so production runtime deps must be copied back in explicitly). Dev-only files
# such as .github workflow folders are stripped from the copies.
echo "Copying vendor dependencies..."
mkdir -p "$TEMP_DIR/vendor"
# Freemius SDK (manually bundled).
if [ -d "vendor/freemius" ]; then
rsync -a --exclude='.github' --exclude='.git*' vendor/freemius "$TEMP_DIR/vendor/"
else
echo "Warning: vendor/freemius directory not found. Freemius SDK will be missing."
fi
# Pro-only runtime dependencies (GitHub importer, XLSX exporter). Skipped in
# free builds where includes/pro/ does not exist.
if [ -d "includes/pro" ]; then
# Parsedown (Markdown parser used by the GitHub content importer; loaded via a
# direct require_once, not the Composer autoloader).
if [ -d "vendor/erusev/parsedown" ]; then
mkdir -p "$TEMP_DIR/vendor/erusev"
rsync -a --exclude='.github' --exclude='.git*' vendor/erusev/parsedown "$TEMP_DIR/vendor/erusev/"
else
echo "Warning: vendor/erusev/parsedown directory not found. Markdown import will fail."
fi
# SimpleXLSXGen (XLSX export used by the importer; loaded via a direct
# require_once, not the Composer autoloader).
if [ -d "vendor/shuchkin/simplexlsxgen" ]; then
mkdir -p "$TEMP_DIR/vendor/shuchkin"
rsync -a --exclude='.github' --exclude='.git*' --exclude='examples/' --exclude='*.md' --exclude='*.png' --exclude='composer.*' vendor/shuchkin/simplexlsxgen "$TEMP_DIR/vendor/shuchkin/"
else
echo "Warning: vendor/shuchkin/simplexlsxgen directory not found. XLSX export will fail."
fi
fi
# Create zip
echo "Creating zip file..."
cd "$BUILD_DIR"
zip -r "$PLUGIN_SLUG.zip" "$PLUGIN_SLUG/" -q
echo "✓ Distribution zip created: $BUILD_DIR/$PLUGIN_SLUG.zip"
cd ..
# Show zip contents summary
echo ""
echo "Zip contents summary:"
unzip -l "$BUILD_DIR/$PLUGIN_SLUG.zip" | tail -1