.PHONY: install test lint format check push_to_pypi

install:
	uv sync --all-extras

test:
	pytest --cov=road24_sdk --cov-fail-under=90 -v

lint:
	ruff check road24_sdk/ tests/
	ruff format --check road24_sdk/ tests/

format:
	ruff format road24_sdk/ tests/

check: lint test

push_to_pypi:
	@python -c "\
	import re, pathlib; \
	p = pathlib.Path('pyproject.toml'); \
	txt = p.read_text(); \
	m = re.search(r'version\s*=\s*\"(\d+)\.(\d+)\.(\d+)\"', txt); \
	old = f'{m.group(1)}.{m.group(2)}.{m.group(3)}'; \
	new = f'{m.group(1)}.{m.group(2)}.{int(m.group(3))+1}'; \
	p.write_text(txt.replace(f'version = \"{old}\"', f'version = \"{new}\"')); \
	print(f'\n  Published version: {new}\n')"
	rm -rf dist/
	python -m build
	python -m twine upload dist/*
