Repository navigation
Expand file tree
/
Copy pathbuild-zip.sh
More file actions
executable file
·115 lines (90 loc) · 2.48 KB
/
Copy pathbuild-zip.sh
File metadata and controls
executable file
·115 lines (90 loc) · 2.48 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
#!/bin/bash
# Rybbit WP Build & Zip Script
# Creates a distributable zip file on the Desktop
# Optionally pre-configures site_id and host_url
set -e
PLUGIN_SLUG="rybbit-wp"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
DESKTOP_PATH="$HOME/Desktop"
TEMP_DIR=$(mktemp -d)
# Default values (set these to skip prompts)
DEFAULT_SITE_ID=""
DEFAULT_HOST_URL=""
# Parse arguments
SITE_ID="${1:-$DEFAULT_SITE_ID}"
HOST_URL="${2:-$DEFAULT_HOST_URL}"
echo "Rybbit WP Build Script"
echo "======================"
echo ""
# Prompt for site_id if not provided
if [ -z "$SITE_ID" ]; then
read -p "Site ID (leave empty for generic build): " SITE_ID
fi
# Prompt for host_url if site_id is set but host_url is not
if [ -n "$SITE_ID" ] && [ -z "$HOST_URL" ]; then
read -p "Host URL [https://app.rybbit.io]: " HOST_URL
HOST_URL="${HOST_URL:-https://app.rybbit.io}"
fi
# Determine zip filename
if [ -n "$SITE_ID" ]; then
ZIP_NAME="${PLUGIN_SLUG}-${SITE_ID}.zip"
echo ""
echo "Building pre-configured plugin:"
echo " Site ID: $SITE_ID"
echo " Host URL: $HOST_URL"
else
ZIP_NAME="${PLUGIN_SLUG}.zip"
echo ""
echo "Building generic plugin (no pre-configuration)"
fi
echo ""
echo "================================"
# Navigate to plugin directory
cd "$SCRIPT_DIR"
# Install dependencies if needed
if [ ! -d "node_modules" ]; then
echo "Installing dependencies..."
npm install
fi
# Build the React admin interface
echo "Building assets..."
npm run build
# Create temp plugin directory
PLUGIN_DIR="${TEMP_DIR}/${PLUGIN_SLUG}"
mkdir -p "$PLUGIN_DIR"
# Copy required files
echo "Copying plugin files..."
# Main plugin file
cp rybbit-wp.php "$PLUGIN_DIR/"
# Includes directory
cp -r includes "$PLUGIN_DIR/"
# Build directory (compiled assets)
cp -r build "$PLUGIN_DIR/"
# Readme
cp readme.txt "$PLUGIN_DIR/"
# Create config file if site_id is provided
if [ -n "$SITE_ID" ]; then
echo "Adding pre-configuration..."
cat > "$PLUGIN_DIR/rybbit-config.json" << EOF
{
"site_id": "$SITE_ID",
"host_url": "$HOST_URL"
}
EOF
fi
# Create the zip file
echo "Creating zip archive..."
cd "$TEMP_DIR"
zip -r "$ZIP_NAME" "$PLUGIN_SLUG" -x "*.DS_Store"
# Move to Desktop
mv "$ZIP_NAME" "$DESKTOP_PATH/"
# Cleanup
rm -rf "$TEMP_DIR"
echo "================================"
echo "Build complete!"
echo "Output: ${DESKTOP_PATH}/${ZIP_NAME}"
if [ -n "$SITE_ID" ]; then
echo ""
echo "This plugin is pre-configured and will"
echo "auto-activate with the provided settings."
fi