# Cardog Python SDK — the v2 surface is GENERATED from the contracts artifact.
#
#   make generate       emit openapi.v2.json from @cardog/contracts, then regenerate
#                       src/cardog/v2/ (types + group resources) and the vendored spec
#   make test           unit tests (mocked transport; live smoke skips without env)
#   make check          generate twice + assert zero diff (idempotency gate) + tests
#   make publish-check  clean build (sdist + wheel via uv) + twine-validate, no upload
#   make publish        clean build + twine upload to PyPI

.PHONY: generate spec codegen test check publish publish-check build-dist

spec:
	cd ../.. && pnpm --filter @cardog/contracts spec

codegen:
	python3 scripts/generate.py

generate: spec codegen

test:
	.venv/bin/python -m pytest -q

check: generate
	python3 scripts/generate.py
	git diff --exit-code -- src/cardog/v2 openapi
	$(MAKE) test

# Clean build: wipes dist/ (including any stale 0.x artifacts) before building.
build-dist:
	rm -rf dist
	uv build

publish-check: build-dist
	twine check dist/*

publish: build-dist
	twine check dist/*
	twine upload dist/*
