# MainWP Google Analytics Extension - Build System
# ====================================================

.PHONY: help install build clean test

# Default target
help:
	@echo "🛠️  MainWP Google Analytics Extension - Build System"
	@echo "========================================================"
	@echo ""
	@echo "📋 Available targets:"
	@echo ""
	@echo "  📦 install       - Install dependencies"
	@echo "  🚀 build         - Build scoped dependencies for production"
	@echo "  📝 build-commit  - Build and commit changes to Git"
	@echo "  🧹 clean         - Clean build artifacts"
	@echo "  🔄 rebuild       - Clean and rebuild everything"
	@echo "  ✅ test          - Run tests (if available)"
	@echo "  📖 help          - Show this help message"
	@echo ""

# Install dependencies
install:
	@echo "📦 Installing dependencies..."
	composer install --optimize-autoloader --no-interaction

# Build scoped dependencies
build:
	@echo "🚀 Building scoped dependencies..."
	./build.sh

# Build and commit changes
build-commit: build
	@echo "📝 Committing build changes..."
	@cd .. && git add lib/ && git commit -m "Update vendor build dependencies" || echo "ℹ️  No changes to commit"

# Clean build artifacts
clean:
	@echo "🧹 Cleaning build and vendor artifacts..."
	@if [ -d "build" ]; then rm -rf build; fi
	@if [ -d "vendor" ]; then rm -rf vendor; fi
	@if [ -f "composer.lock" ]; then rm -f composer.lock; fi
	@echo "✅ Cleanup completed!"

# Rebuild everything
rebuild: clean install build
	@echo "🔄 Rebuild completed!"

# Commit changes
commit:
	@echo "📝 Committing build changes..."
	@cd .. && git add lib/ && git commit -m "Update vendor build dependencies" || echo "ℹ️  No changes to commit"

# Run tests (placeholder)
test:
	@echo "✅ Running tests..."
	@echo "⚠️  No tests configured yet"

# Development setup
dev-setup: install build
	@echo "🛠️  Development setup completed!"
	@echo "💡 You can now use the plugin with scoped dependencies"