1
1
#! /usr/bin/env bash
2
2
set -o errexit # Abort if any command fails
3
3
4
+ # Change to the script's directory for safety
5
+ cd " $( dirname " $0 " ) "
6
+
4
7
echo " 🚀 WooCommerce Code Reference Generator - Local Development"
5
8
echo " =========================================================="
9
+ echo " "
10
+ echo " Usage: ./run-local.sh [source-directory]"
11
+ echo " - If source-directory is provided, use that as WooCommerce source"
12
+ echo " - If no argument provided, use ./woocommerce if it exists, otherwise prompt"
13
+ echo " "
6
14
7
15
# Check if PHP is available
8
16
if ! command -v php & > /dev/null; then
@@ -22,29 +30,35 @@ if [ ! -d "vendor" ]; then
22
30
composer install
23
31
fi
24
32
25
- # Check if woocommerce directory exists in current directory
26
- if [ -d " woocommerce" ]; then
27
- echo " 📁 Found existing woocommerce directory in current project."
33
+ # Determine WooCommerce directory
34
+ if [ $# -eq 1 ]; then
35
+ # Use provided source directory
36
+ WOOCOMMERCE_DIR=" $1 "
37
+ echo " 📁 Using provided source directory: $WOOCOMMERCE_DIR "
38
+ elif [ -d " woocommerce" ]; then
39
+ # Use existing woocommerce directory in current project
28
40
WOOCOMMERCE_DIR=" woocommerce"
41
+ echo " 📁 Found existing woocommerce directory in current project."
29
42
else
30
43
# Prompt user for WooCommerce directory
31
44
echo " 📁 Please provide the path to your WooCommerce directory."
32
45
echo " Example: /Users/YourUserName/woocommerce/plugins/woocommerce"
33
46
echo " "
34
47
read -p " Enter WooCommerce directory path: " WOOCOMMERCE_DIR
48
+ fi
35
49
36
- # Check if directory exists
37
- if [ ! -d " $WOOCOMMERCE_DIR " ]; then
38
- echo " ❌ WooCommerce plugin directory not found at: $WOOCOMMERCE_DIR "
39
- echo " Please check the path and try again."
40
- exit 1
41
- fi
50
+ # Check if directory exists
51
+ if [ ! -d " $WOOCOMMERCE_DIR " ]; then
52
+ echo " ❌ WooCommerce plugin directory not found at: $WOOCOMMERCE_DIR "
53
+ echo " Please check the path and try again."
54
+ exit 1
42
55
fi
43
56
44
57
echo " 📁 Using WooCommerce plugin directory: $WOOCOMMERCE_DIR "
45
58
46
- # Only copy files if we're using an external path (not the existing woocommerce directory)
59
+ # Copy files if we're using an external path (not the existing woocommerce directory)
47
60
if [ " $WOOCOMMERCE_DIR " != " woocommerce" ]; then
61
+ # Always remove existing woocommerce directory when using external source
48
62
if [ -d " woocommerce" ]; then
49
63
echo " 🗑️ Removing existing woocommerce directory..."
50
64
rm -rf woocommerce
61
75
echo " 📁 Using existing woocommerce directory in project."
62
76
fi
63
77
64
- # Clean up any existing build
65
- if [ -d " build" ]; then
66
- echo " 🧹 Cleaning up existing build..."
67
- rm -rf build
68
- fi
69
-
78
+ # Generate documentation
70
79
echo " 🔧 Generating documentation from local WooCommerce source..."
71
80
echo " "
72
-
73
- # Run PHPDocumentor directly with the local source
74
- ./vendor/bin/phpdoc run \
75
- --template=" data/templates/woocommerce" \
76
- --sourcecode \
77
- --defaultpackagename=" WooCommerce"
78
-
79
- # Generate hook documentation AFTER PHPDocumentor completes
80
- echo " 🔧 Generating hook documentation..."
81
- php generate-hook-docs.php
81
+ ./deploy.sh --no-download --build-only --source-version 0.0.0
82
82
83
83
echo " "
84
84
echo " ✅ Documentation generated successfully!"
@@ -92,4 +92,4 @@ echo "Press Ctrl+C to stop the server"
92
92
echo " "
93
93
94
94
# Start PHP development server
95
- php -S localhost:8000 -t build/api
95
+ php -S localhost:8000 -t build/api
0 commit comments