Files
cannaiq/wordpress-plugin/build-plugin.sh
Kelly 5c08135007 feat(plugin): Add Elementor dynamic tags and product loop widget v1.7.0
WordPress Plugin:
- Add dynamic tags for all product payload fields (name, brand, price, THC, effects, etc.)
- Add Product Loop widget with filtering, sorting, and layout options
- Register CannaIQ widget category in Elementor
- Update build script to auto-upload to MinIO CDN
- Remove legacy dutchie references
- Bump version to 1.7.0

Backend:
- Redirect /downloads/* to CDN instead of serving from local filesystem

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-13 03:10:01 -07:00

99 lines
2.8 KiB
Bash
Executable File

#!/bin/bash
# WordPress Plugin Build Script
# Builds the plugin zip and uploads to MinIO CDN
#
# Usage: ./build-plugin.sh
#
# This script:
# 1. Extracts version from cannaiq-menus.php
# 2. Creates ZIP file excluding legacy/dev files
# 3. Uploads to MinIO CDN (cannaiq bucket, downloads/ folder)
# 4. Uploads as both versioned and "latest" files
#
# The plugin is then available at:
# https://cdn.cannabrands.app/cannaiq/downloads/cannaiq-menus-{version}.zip
# https://cdn.cannabrands.app/cannaiq/downloads/cannaiq-menus-latest.zip
set -e
# Get the version from the main plugin file
VERSION=$(grep -oP "Version:\s*\K[0-9.]+" cannaiq-menus.php)
if [ -z "$VERSION" ]; then
echo "Error: Could not extract version from cannaiq-menus.php"
exit 1
fi
# Define paths
PLUGIN_DIR="$(cd "$(dirname "$0")" && pwd)"
OUTPUT_DIR="${PLUGIN_DIR}/../backend/public/downloads"
OUTPUT_FILE="cannaiq-menus-${VERSION}.zip"
echo "Building CannaIQ Menus WordPress plugin..."
echo " Version: ${VERSION}"
echo " Output: ${OUTPUT_DIR}/${OUTPUT_FILE}"
# Ensure output directory exists
mkdir -p "${OUTPUT_DIR}"
# Create the zip file (from the plugin directory)
cd "${PLUGIN_DIR}"
rm -f "${OUTPUT_DIR}/${OUTPUT_FILE}"
# Exclude old/legacy files and build script
zip -r "${OUTPUT_DIR}/${OUTPUT_FILE}" . \
-x "*.git*" \
-x "build-plugin.sh" \
-x "crawlsy-menus.php" \
-x "assets/css/crawlsy-menus.css" \
-x "assets/js/crawlsy-menus.js"
# Create/update the "latest" symlink (for local reference)
cd "${OUTPUT_DIR}"
rm -f cannaiq-menus-latest.zip
ln -s "${OUTPUT_FILE}" cannaiq-menus-latest.zip
echo ""
echo "Build complete!"
echo " File: ${OUTPUT_DIR}/${OUTPUT_FILE}"
echo " Size: $(ls -lh "${OUTPUT_DIR}/${OUTPUT_FILE}" | awk '{print $5}')"
# Upload to MinIO CDN
echo ""
echo "Uploading to MinIO CDN..."
cd "${PLUGIN_DIR}/../backend"
node -e "
const Minio = require('minio');
const path = require('path');
const client = new Minio.Client({
endPoint: 'cdn.cannabrands.app',
port: 443,
useSSL: true,
accessKey: 'FLE4dpKrOS2uQM7AFQSY',
secretKey: 'wDU6qkruxoDWftIvM0OIdJgTCleTLr5vhozPuYqF',
});
const localFile = 'public/downloads/${OUTPUT_FILE}';
const version = '${VERSION}';
(async () => {
// Upload versioned file
await client.fPutObject('cannaiq', 'downloads/cannaiq-menus-' + version + '.zip', localFile, {
'Content-Type': 'application/zip',
});
console.log(' Uploaded: cannaiq-menus-' + version + '.zip');
// Upload as latest
await client.fPutObject('cannaiq', 'downloads/cannaiq-menus-latest.zip', localFile, {
'Content-Type': 'application/zip',
});
console.log(' Uploaded: cannaiq-menus-latest.zip');
})();
"
echo ""
echo "Done! Plugin is live at:"
echo " https://cdn.cannabrands.app/cannaiq/downloads/cannaiq-menus-${VERSION}.zip"
echo " https://cdn.cannabrands.app/cannaiq/downloads/cannaiq-menus-latest.zip"