.PHONY: install test lint format publish-github

install:
	uv sync

test:
	uv run pytest --no-cov -p no:cacheprovider

lint:
	uv run ruff check src tests

format:
	uv run ruff format src tests

# Publish this subtree to a standalone GitHub repo, preserving history.
# Usage: make publish-github REPO=git@github.com:advantch/vanty-crm.git
publish-github:
	@if [ -z "$(REPO)" ]; then \
		echo "REPO is required, e.g. make publish-github REPO=git@github.com:advantch/vanty-crm.git"; \
		exit 1; \
	fi
	@command -v git-filter-repo >/dev/null 2>&1 || { \
		echo "git-filter-repo not installed. brew install git-filter-repo"; \
		exit 1; \
	}
	rm -rf .publish-tmp
	git clone --no-local .. .publish-tmp
	cd .publish-tmp && git filter-repo --subdirectory-filter vanty-crm --force
	cd .publish-tmp && git remote add origin $(REPO)
	cd .publish-tmp && git push -u origin HEAD:main
	rm -rf .publish-tmp
