Skip to content

Commit 8b9f13b

Browse files
committed
address pr comments
1 parent bd9b073 commit 8b9f13b

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

run-local.sh

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
#!/usr/bin/env bash
22
set -o errexit # Abort if any command fails
33

4+
# Change to the script's directory for safety
5+
cd "$(dirname "$0")"
6+
47
echo "🚀 WooCommerce Code Reference Generator - Local Development"
58
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 ""
614

715
# Check if PHP is available
816
if ! command -v php &> /dev/null; then
@@ -22,29 +30,35 @@ if [ ! -d "vendor" ]; then
2230
composer install
2331
fi
2432

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
2840
WOOCOMMERCE_DIR="woocommerce"
41+
echo "📁 Found existing woocommerce directory in current project."
2942
else
3043
# Prompt user for WooCommerce directory
3144
echo "📁 Please provide the path to your WooCommerce directory."
3245
echo "Example: /Users/YourUserName/woocommerce/plugins/woocommerce"
3346
echo ""
3447
read -p "Enter WooCommerce directory path: " WOOCOMMERCE_DIR
48+
fi
3549

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
4255
fi
4356

4457
echo "📁 Using WooCommerce plugin directory: $WOOCOMMERCE_DIR"
4558

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)
4760
if [ "$WOOCOMMERCE_DIR" != "woocommerce" ]; then
61+
# Always remove existing woocommerce directory when using external source
4862
if [ -d "woocommerce" ]; then
4963
echo "🗑️ Removing existing woocommerce directory..."
5064
rm -rf woocommerce
@@ -61,24 +75,10 @@ else
6175
echo "📁 Using existing woocommerce directory in project."
6276
fi
6377

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
7079
echo "🔧 Generating documentation from local WooCommerce source..."
7180
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
8282

8383
echo ""
8484
echo "✅ Documentation generated successfully!"
@@ -92,4 +92,4 @@ echo "Press Ctrl+C to stop the server"
9292
echo ""
9393

9494
# Start PHP development server
95-
php -S localhost:8000 -t build/api
95+
php -S localhost:8000 -t build/api

0 commit comments

Comments
 (0)