UV := $(shell which uv 2>/dev/null || echo "$$HOME/snap/code/233/.local/share/../bin/uv")

.PHONY: install lint fmt typecheck test unit integration smoke build clean

## Install all dependencies (including dev + pydantic extra)
install:
	$(UV) sync --all-extras

## Run ruff linter
lint:
	$(UV) run ruff check config_client tests examples
	$(UV) run ruff format --check config_client tests examples

## Auto-format code with ruff
fmt:
	$(UV) run ruff format config_client tests examples
	$(UV) run ruff check --fix config_client tests examples

## Run mypy strict type checking
typecheck:
	$(UV) run mypy config_client --strict

## Run all tests with coverage
test:
	$(UV) run pytest tests/ -v --cov=config_client --cov-report=term-missing

## Run only unit tests (exclude integration)
unit:
	$(UV) run pytest tests/ -v -m "not integration and not smoke"

## Run integration tests (requires real Config Service env vars)
integration:
	$(UV) run pytest tests/ -v -m integration

## Run smoke tests
smoke:
	$(UV) run pytest tests/ -v -m smoke

## Run security scan
security:
	$(UV) run bandit -r config_client -ll

## Build the package
build:
	$(UV) build

## Remove build artifacts and caches
clean:
	rm -rf dist/ build/ .mypy_cache/ .ruff_cache/ .pytest_cache/ htmlcov/ .coverage
	find . -type d -name "__pycache__" -exec rm -rf {} +
	find . -type d -name "*.egg-info" -exec rm -rf {} +

testpypi:
	twine upload --repository testpypi dist/*

pypi:
	twine upload dist/*