.PHONY: help install install-dev format lint type-check test test-cov run migrate clean

help:
	@echo "可用的命令："
	@echo "  make install      - 安装生产环境依赖"
	@echo "  make install-dev  - 安装开发环境依赖"
	@echo "  make format       - 格式化代码"
	@echo "  make lint         - 运行代码检查"
	@echo "  make type-check   - 运行类型检查"
	@echo "  make test         - 运行测试"
	@echo "  make test-cov     - 运行测试并生成覆盖率报告"
	@echo "  make run          - 启动开发服务器"
	@echo "  make migrate      - 运行数据库迁移"
	@echo "  make clean        - 清理临时文件"

install:
	pip install -r requirements.txt

install-dev:
	pip install -r requirements-dev.txt

format:
	black app/ tests/
	isort app/ tests/

lint:
	flake8 app/ tests/ --max-line-length=100 --ignore=E203,W503
	pylint app/ tests/ --disable=C0111,R0903,R0913

type-check:
	mypy app/ --ignore-missing-imports

test:
	pytest tests/ -v

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

run:
	python -m app.main

migrate:
	alembic upgrade head

clean:
	find . -type d -name "__pycache__" -exec rm -rf {} +
	find . -type f -name "*.pyc" -delete
	find . -type f -name "*.pyo" -delete
	find . -type f -name ".coverage" -delete
	rm -rf htmlcov/
	rm -rf .pytest_cache/
	rm -rf .mypy_cache/