SHELL := /bin/bash

PYTHON_SRC := das_setup_helper tests

.DEFAULT: help

all: info

info:  ## Show this information
	@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'


# ------------------------------------------------------------------ #
# Environment                                                        #
# ------------------------------------------------------------------ #

sync:  ## Install / update all dependencies (dev included)
	uv sync --extra dev

clean:  ## Remove the virtual environment
	rm -rf .venv

# ------------------------------------------------------------------ #
# Development                                                        #
# ------------------------------------------------------------------ #

lint:  ## Run black and isort formatters
	uv run black $(PYTHON_SRC)
	uv run isort $(PYTHON_SRC)

pre-commit-install:  ## Install git pre-commit and pre-push hooks
	uv run pre-commit install
	uv run pre-commit install --hook-type pre-push

pre-commit-run:  ## Run pre-commit on all files
	uv run pre-commit run --all-files

test:  ## Run tests
	uv run pytest $(PYTEST_OPTIONS)

# ------------------------------------------------------------------ #
# Pipelines                                                          #
# ------------------------------------------------------------------ #

run-crawler:  ## Run setup_crawler pipeline
	uv run das-setup-crawler

run-acq:  ## Run create_acquisitions pipeline
	uv run das-create-acq

run-stop:  ## Run stop_acquisitions pipeline
	uv run das-stop-acq

# ------------------------------------------------------------------ #
# Release                                                            #
# ------------------------------------------------------------------ #

build:  ## Build the package
	uv build

publish-test:  ## Publish to TestPyPI
	uv publish --index testpypi

publish:  ## Publish to PyPI
	uv publish

lock:  ## Refresh uv.lock without upgrading
	uv lock

lock-upgrade:  ## Upgrade all dependencies and refresh uv.lock
	uv lock --upgrade
