SHELL := bash
.ONESHELL:
.SHELLFLAGS := -eu -o pipefail -c
MODULE := frogml_cli

.PHONY: clean sync format lint bump_version

clean:
	rm -rf .mypy_cache .pytest_cache tests/.pytest_cache .coverage coverage-reports dist

format:
	uv run black tests $(MODULE)
	uv run isort $(MODULE)

sync:
	uv sync --group dev

lint:
	uv run black --check tests $(MODULE) --diff
	uv run isort --check $(MODULE)
	uv run flake8 tests $(MODULE)
	uv run bandit -r $(MODULE) -c pyproject.toml

test:
	uv run coverage run -m pytest --disable-warnings tests --durations=0

unit-test:
	uv run pytest tests -m "not integration" --durations=0

coverage-report:
	uv run coverage xml -i

bump-version-dev:
	uv run bump2version --allow-dirty build VERSION
	uv lock

bump-version-prod:
	uv run bump2version --allow-dirty release VERSION
	uv lock

patch-version:
	uv run bump2version --allow-dirty patch VERSION
	uv lock

dev-release: clean build
	UV_PUBLISH_USERNAME=$(JFROG_USER) UV_PUBLISH_PASSWORD=$(JFROG_PASSWORD) uv publish --index qwak-staging
	UV_PUBLISH_USERNAME=$(REPO21_USER) UV_PUBLISH_PASSWORD=$(REPO21_TOKEN) uv publish --index jfml-repo21

build:
	uv build

prod-release: clean build
	UV_PUBLISH_TOKEN=$(PYPI_TOKEN) uv publish --index pypi
	UV_PUBLISH_USERNAME=$(REPO21_USER) UV_PUBLISH_PASSWORD=$(REPO21_TOKEN) uv publish --index jfml-repo21

set-local-core:
	uv add --editable ../frogml/
