-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrelease.sh
More file actions
executable file
·123 lines (99 loc) · 2.79 KB
/
Copy pathrelease.sh
File metadata and controls
executable file
·123 lines (99 loc) · 2.79 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#!/bin/bash
#
# Release script for shadcn-blocks plugin
# Creates a distribution ZIP with only production files
#
set -e
PLUGIN_SLUG="shadcn-blocks"
PLUGIN_FILE="shadcn-blocks.php"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
# Extract version from plugin header
VERSION=$(grep -o "Version: [0-9.]*" "$PLUGIN_FILE" | cut -d' ' -f2)
if [ -z "$VERSION" ]; then
echo "Error: Could not extract version from $PLUGIN_FILE"
exit 1
fi
echo "Building $PLUGIN_SLUG v$VERSION..."
# Clean previous build
echo "Cleaning previous build..."
rm -rf build/
# Run production build
echo "Running npm build..."
npm run build
# Create temp directory
TEMP_DIR=$(mktemp -d)
DEST_DIR="$TEMP_DIR/$PLUGIN_SLUG"
mkdir -p "$DEST_DIR"
# Copy release files
echo "Copying release files..."
# Main plugin file
cp "$PLUGIN_FILE" "$DEST_DIR/"
# PHP includes
if [ -d "inc" ]; then
cp -r inc "$DEST_DIR/"
fi
# Build assets
if [ -d "build" ]; then
cp -r build "$DEST_DIR/"
fi
# Block patterns (the Shadcn AI plans from these)
if [ -d "patterns" ]; then
cp -r patterns "$DEST_DIR/"
fi
# Languages
if [ -d "languages" ]; then
cp -r languages "$DEST_DIR/"
fi
# Readme (for WordPress.org)
if [ -f "readme.txt" ]; then
cp readme.txt "$DEST_DIR/"
fi
# Static assets the patterns point at (the placeholder image)
if [ -d "assets" ]; then
cp -r assets "$DEST_DIR/"
fi
# Editor stylesheet, which inc/Plugin.php loads from src/ rather than build/
if [ -f "src/editor-styles.css" ]; then
mkdir -p "$DEST_DIR/src"
cp src/editor-styles.css "$DEST_DIR/src/"
fi
# Lucide license, required because inc/icon-map.php ships their icon SVGs
if [ -f "LICENSE-lucide.txt" ]; then
cp LICENSE-lucide.txt "$DEST_DIR/"
fi
# Drop macOS metadata that cp -r drags along
find "$DEST_DIR" -name ".DS_Store" -delete
# Fail loudly when a file the plugin loads at runtime did not make it in,
# rather than shipping a ZIP that 404s once the plugin is installed somewhere else.
for required in \
"shadcn-blocks.php" \
"inc/icon-map.php" \
"assets/images/placeholder.svg" \
"src/editor-styles.css" \
"build/extensions/core-button-icon.js" \
"build/blocks/live-purchase/view.js" \
"inc/LivePurchase/RestController.php"
do
if [ ! -f "$DEST_DIR/$required" ]; then
echo "Error: $required is missing from the release"
exit 1
fi
done
# Create ZIP
ZIP_NAME="${PLUGIN_SLUG}-${VERSION}.zip"
echo "Creating $ZIP_NAME..."
cd "$TEMP_DIR"
zip -rq "$ZIP_NAME" "$PLUGIN_SLUG"
mv "$ZIP_NAME" "$SCRIPT_DIR/"
cd "$SCRIPT_DIR"
# Cleanup
rm -rf "$TEMP_DIR"
# Output result
FILE_SIZE=$(du -h "$ZIP_NAME" | cut -f1)
echo ""
echo "----------------------------------------"
echo "Release created successfully!"
echo "File: $ZIP_NAME"
echo "Size: $FILE_SIZE"
echo "----------------------------------------"