-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·103 lines (86 loc) · 2.9 KB
/
build.sh
File metadata and controls
executable file
·103 lines (86 loc) · 2.9 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
#!/bin/bash
# 84EM Gravity Forms AI Analysis Build Script
# Builds minified CSS and JS files with source maps and creates installable ZIP
set -e
echo "🔨 Building 84EM Gravity Forms AI Analysis Plugin..."
# Configuration
PLUGIN_NAME="84em-gravity-forms-ai"
BUILD_DIR="build"
VERSION=$(grep "Version:" 84em-gravity-forms-ai.php | awk '{print $3}')
# Check if npm is installed
if ! command -v npm &> /dev/null; then
echo "❌ npm is not installed. Please install Node.js and npm first."
exit 1
fi
# Install dependencies if needed
if [ ! -d "node_modules" ]; then
echo "📦 Installing dependencies..."
npm install
fi
# Clean old build files
echo "🧹 Cleaning old build files..."
npm run clean
rm -rf "$BUILD_DIR"
rm -f "${PLUGIN_NAME}.zip"
rm -f "${PLUGIN_NAME}-*.zip"
# Build CSS
echo "🎨 Minifying CSS..."
npm run build:css
# Build JS
echo "📜 Minifying JavaScript..."
npm run build:js
# Check if files were created
if [ ! -f "assets/css/admin.min.css" ] || [ ! -f "assets/js/admin.min.js" ]; then
echo "❌ Build failed - minified files not created"
exit 1
fi
# Create build directory
echo "📁 Creating build directory..."
mkdir -p "$BUILD_DIR/$PLUGIN_NAME"
# Copy necessary files
echo "📋 Copying plugin files..."
# Copy assets but exclude source files and maps
mkdir -p "$BUILD_DIR/$PLUGIN_NAME/assets/css"
mkdir -p "$BUILD_DIR/$PLUGIN_NAME/assets/js"
cp assets/css/*.min.css "$BUILD_DIR/$PLUGIN_NAME/assets/css/" 2>/dev/null || true
cp assets/js/*.min.js "$BUILD_DIR/$PLUGIN_NAME/assets/js/" 2>/dev/null || true
# Copy other directories
cp -r includes "$BUILD_DIR/$PLUGIN_NAME/"
cp -r languages "$BUILD_DIR/$PLUGIN_NAME/" 2>/dev/null || mkdir "$BUILD_DIR/$PLUGIN_NAME/languages"
cp 84em-gravity-forms-ai.php "$BUILD_DIR/$PLUGIN_NAME/"
cp README.md "$BUILD_DIR/$PLUGIN_NAME/"
cp CHANGELOG.md "$BUILD_DIR/$PLUGIN_NAME/"
# Create ZIP file
echo "📦 Creating ZIP archive..."
cd "$BUILD_DIR"
zip -r "../${PLUGIN_NAME}-${VERSION}.zip" "$PLUGIN_NAME" -q
cd ..
# Also create a latest version
cp "${PLUGIN_NAME}-${VERSION}.zip" "${PLUGIN_NAME}.zip"
# Clean up build directory
rm -rf "$BUILD_DIR"
# Final output
echo ""
echo "✅ Build complete!"
echo ""
echo "📦 Plugin packages created:"
echo " - ${PLUGIN_NAME}-${VERSION}.zip (versioned)"
echo " - ${PLUGIN_NAME}.zip (latest)"
echo ""
echo "File sizes:"
ls -lh "${PLUGIN_NAME}-${VERSION}.zip" | awk '{print " - Versioned: " $5}'
ls -lh "${PLUGIN_NAME}.zip" | awk '{print " - Latest: " $5}'
echo ""
echo "Plugin Details:"
echo " - Version: ${VERSION}"
echo " - Name: 84EM Gravity Forms AI Analysis"
echo ""
echo "To install:"
echo " 1. Go to WordPress Admin → Plugins → Add New"
echo " 2. Click 'Upload Plugin'"
echo " 3. Choose ${PLUGIN_NAME}-${VERSION}.zip"
echo " 4. Click 'Install Now' and activate"
echo ""
echo "Development files:"
echo " - CSS: assets/css/admin.min.css (with source map)"
echo " - JS: assets/js/admin.min.js (with source map)"