-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathrun-local.sh
More file actions
executable file
·95 lines (81 loc) · 3.08 KB
/
run-local.sh
File metadata and controls
executable file
·95 lines (81 loc) · 3.08 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
#!/usr/bin/env bash
set -o errexit # Abort if any command fails
# Change to the script's directory for safety
cd "$(dirname "$0")"
echo "🚀 WooCommerce Code Reference Generator - Local Development"
echo "=========================================================="
echo ""
echo "Usage: ./run-local.sh [source-directory]"
echo " - If source-directory is provided, use that as WooCommerce source"
echo " - If no argument provided, use ./woocommerce if it exists, otherwise prompt"
echo ""
# Check if PHP is available
if ! command -v php &> /dev/null; then
echo "❌ PHP is not installed or not in PATH"
exit 1
fi
# Check if Composer is available
if ! command -v composer &> /dev/null; then
echo "❌ Composer is not installed or not in PATH"
exit 1
fi
# Install dependencies if vendor directory doesn't exist
if [ ! -d "vendor" ]; then
echo "📦 Installing dependencies..."
composer install
fi
# Determine WooCommerce directory
if [ $# -eq 1 ]; then
# Use provided source directory
WOOCOMMERCE_DIR="$1"
echo "📁 Using provided source directory: $WOOCOMMERCE_DIR"
elif [ -d "woocommerce" ]; then
# Use existing woocommerce directory in current project
WOOCOMMERCE_DIR="woocommerce"
echo "📁 Found existing woocommerce directory in current project."
else
# Prompt user for WooCommerce directory
echo "📁 Please provide the path to your WooCommerce directory."
echo "Example: /Users/YourUserName/woocommerce/plugins/woocommerce"
echo ""
read -p "Enter WooCommerce directory path: " WOOCOMMERCE_DIR
fi
# Check if directory exists
if [ ! -d "$WOOCOMMERCE_DIR" ]; then
echo "❌ WooCommerce plugin directory not found at: $WOOCOMMERCE_DIR"
echo " Please check the path and try again."
exit 1
fi
echo "📁 Using WooCommerce plugin directory: $WOOCOMMERCE_DIR"
# Copy files if we're using an external path (not the existing woocommerce directory)
if [ "$WOOCOMMERCE_DIR" != "woocommerce" ]; then
# Always remove existing woocommerce directory when using external source
if [ -d "woocommerce" ]; then
echo "🗑️ Removing existing woocommerce directory..."
rm -rf woocommerce
fi
echo "📁 Copying WooCommerce files..."
mkdir -p woocommerce
# Copy only the directories we want for documentation
cp -r "$WOOCOMMERCE_DIR"/includes woocommerce/ 2>/dev/null || true
cp -r "$WOOCOMMERCE_DIR"/src woocommerce/ 2>/dev/null || true
cp -r "$WOOCOMMERCE_DIR"/templates woocommerce/ 2>/dev/null || true
else
echo "📁 Using existing woocommerce directory in project."
fi
# Generate documentation
echo "🔧 Generating documentation from local WooCommerce source..."
echo ""
./deploy.sh --no-download --build-only --source-version 0.0.0
echo ""
echo "✅ Documentation generated successfully!"
echo "📁 Output location: ./build/api/"
echo ""
echo "🌐 Starting local web server for WooCommerce Code Reference..."
echo "📁 Serving from: ./build/api"
echo "🌍 URL: http://localhost:8000"
echo ""
echo "Press Ctrl+C to stop the server"
echo ""
# Start PHP development server
php -S localhost:8000 -t build/api