| 1 |
#!/bin/bash |
| 2 |
|
| 3 |
# Exit on any error |
| 4 |
set -e |
| 5 |
|
| 6 |
# Configuration |
| 7 |
PLUGIN_NAME="wpbot-automator" |
| 8 |
BUILD_DIR="dist" |
| 9 |
ZIP_FILE="${PLUGIN_NAME}.zip" |
| 10 |
|
| 11 |
echo "🚀 Starting build process for ${PLUGIN_NAME}..." |
| 12 |
|
| 13 |
# 1. Clean up previous builds |
| 14 |
echo "🧹 Cleaning up old build files..." |
| 15 |
rm -rf $BUILD_DIR |
| 16 |
rm -f $ZIP_FILE |
| 17 |
|
| 18 |
# 2. Build assets |
| 19 |
echo "📦 Building assets..." |
| 20 |
npm run build |
| 21 |
|
| 22 |
# 3. Create temporary structure |
| 23 |
echo "📁 Creating production structure..." |
| 24 |
mkdir -p $BUILD_DIR/$PLUGIN_NAME$PLUGIN_NAME |
| 25 |
|
| 26 |
# 4. Copy necessary files |
| 27 |
echo "📂 Copying files..." |
| 28 |
cp -r includes $BUILD_DIR/$PLUGIN_NAME$PLUGIN_NAME/ |
| 29 |
cp -r build $BUILD_DIR/$PLUGIN_NAME$PLUGIN_NAME/ |
| 30 |
cp -r assets $BUILD_DIR/$PLUGIN_NAME$PLUGIN_NAME/ |
| 31 |
cp wpbot-automator.php $BUILD_DIR/$PLUGIN_NAME$PLUGIN_NAME/ |
| 32 |
cp readme.txt $BUILD_DIR/$PLUGIN_NAME$PLUGIN_NAME/ |
| 33 |
|
| 34 |
# 5. Create Zip |
| 35 |
echo "🤐 Generating zip file..." |
| 36 |
cd $BUILD_DIR |
| 37 |
zip -r ../$ZIP_FILE$ZIP_FILE . -x "**/.DS_Store" "**/node_modules/*" "**/.git/*" |
| 38 |
cd .. |
| 39 |
|
| 40 |
# 6. Final Cleanup |
| 41 |
echo "🧹 Cleaning up temporary files..." |
| 42 |
rm -rf $BUILD_DIR |
| 43 |
|
| 44 |
if [ -f "$ZIP_FILE" ]; then |
| 45 |
echo "� |
| 46 |
Success! Zip file created at: $(pwd)/$ZIP_FILE$ZIP_FILE" |
| 47 |
ls -lh "$ZIP_FILE" |
| 48 |
else |
| 49 |
echo "❌ Error: Zip file was not created." |
| 50 |
exit 1 |
| 51 |
fi |
| 52 |
|