# IPRotator Makefile
# Version: 1.0.0

.PHONY: help install install-dev test lint format clean build docker-build docker-run docs

# Default target
help:
	@echo "IPRotator - Available targets:"
	@echo ""
	@echo "  install      - Install package"
	@echo "  install-dev  - Install package with development dependencies"
	@echo "  test         - Run all tests"
	@echo "  test-cov     - Run tests with coverage"
	@echo "  lint         - Run all linters"
	@echo "  format       - Format code with black"
	@echo "  clean        - Clean build artifacts"
	@echo "  build        - Build package wheel"
	@echo "  docker-build - Build Docker image"
	@echo "  docker-run   - Run Docker container"
	@echo "  run          - Run IPRotator"
	@echo "  docs         - Build documentation"
	@echo ""

# Installation
install:
	pip install -e .

install-dev:
	pip install -e ".[dev]"

# Testing
test:
	pytest tests/ -v

test-cov:
	pytest tests/ -v --cov=iprotator --cov-report=html --cov-report=term

# Linting
lint: lint-black lint-flake8 lint-mypy

lint-black:
	black --check --diff iprotator/

lint-flake8:
	flake8 iprotator/ --max-line-length=100 --extend-ignore=E203,W503

lint-mypy:
	mypy iprotator/ --ignore-missing-imports

# Formatting
format:
	black iprotator/ tests/

# Cleaning
clean:
	rm -rf build/
	rm -rf dist/
	rm -rf *.egg-info/
	rm -rf .pytest_cache/
	rm -rf .mypy_cache/
	rm -rf htmlcov/
	rm -rf .coverage
	rm -rf __pycache__/
	find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true
	find . -type f -name "*.pyc" -delete
	find . -type f -name "*.pyo" -delete

# Building
build: clean
	python -m build
	twine check dist/*

# Docker
docker-build:
	docker build -t iprotator:latest .

docker-run:
	docker run -it --rm -p 9050:9050 -p 9051:9051 iprotator:latest

docker-shell:
	docker run -it --rm -p 9050:9050 -p 9051:9051 --entrypoint /bin/bash iprotator:latest

# Running
run:
	iprotator

run-interactive:
	iprotator --interactive

# Documentation
docs:
	mkdocs build

docs-serve:
	mkdocs serve

# Release
release-test: build
	twine upload --repository testpypi dist/*

release: build
	twine upload dist/*

# Development utilities
setup-hooks:
	pre-commit install

update-deps:
	pip-compile --upgrade requirements.in
	pip-compile --upgrade requirements-dev.in
