# Ascently Makefile

.PHONY: help android-lint android-format android-build android-test \
        ios-lint ios-format ios-build ios-test clean

# Default target
help:
	@echo "Ascently Dev Commands"
	@echo "=============================="
	@echo ""
	@echo "Android:"
	@echo "  make android-lint: Run Detekt static analysis"
	@echo "  make android-format: Check code formatting with Spotless"
	@echo "  make android-format-fix: Auto-fix code formatting"
	@echo "  make android-build: Build debug APK"
	@echo "  make android-release: Build release APK"
	@echo "  make android-test: Run unit tests"
	@echo ""
	@echo "iOS:"
	@echo "  make ios-lint: Run SwiftLint"
	@echo "  make ios-lint-fix: Run SwiftLint with auto-fix"
	@echo "  make ios-format: Run SwiftFormat (dry-run)"
	@echo "  make ios-format-fix: Run SwiftFormat with auto-fix"
	@echo "  make ios-build: Build iOS app"
	@echo ""
	@echo "General:"
	@echo "  make lint: Run linters for both platforms"
	@echo "  make format: Check formatting for both platforms"
	@echo "  make clean: Clean build artifacts"

# Android commands
android-lint:
	cd android && ./gradlew detekt

android-format:
	cd android && ./gradlew spotlessCheck

android-format-fix:
	cd android && ./gradlew spotlessApply

android-build:
	cd android && ./gradlew assembleDebug

android-release:
	cd android && ./gradlew assembleRelease

android-test:
	cd android && ./gradlew test

# iOS commands (requires SwiftLint and SwiftFormat!!!)
ios-lint:
	@if command -v swiftlint >/dev/null 2>&1; then \
		cd ios && swiftlint; \
	else \
		echo "SwiftLint not installed. Install with: brew install swiftlint"; \
	fi

ios-lint-fix:
	@if command -v swiftlint >/dev/null 2>&1; then \
		cd ios && swiftlint --fix; \
	else \
		echo "SwiftLint not installed. Install with: brew install swiftlint"; \
	fi

ios-format:
	@if command -v swiftformat >/dev/null 2>&1; then \
		cd ios && swiftformat . --lint; \
	else \
		echo "SwiftFormat not installed. Install with: brew install swiftformat"; \
	fi

ios-format-fix:
	@if command -v swiftformat >/dev/null 2>&1; then \
		cd ios && swiftformat .; \
	else \
		echo "SwiftFormat not installed. Install with: brew install swiftformat"; \
	fi

ios-build:
	cd ios && xcodebuild -project Ascently.xcodeproj -scheme Ascently -configuration Debug build

# Combined commands
lint: android-lint ios-lint

format: android-format ios-format

# Clean
clean:
	cd android && ./gradlew clean
	rm -rf ios/build ios/DerivedData
