help:
    @just --list

dist-dir := justfile_directory() + "/dist/"

# Run linters and other checks
check:
    prek run --all-files --hook-stage manual

# Run tests with all supported Python versions
test-all:
    #!/usr/bin/env bash
    for version in 3.10 3.11 3.12 3.13; do
        run-version $version python$version -m pytest
    done

# Run tests with pytest
test version="3.12" *pytest-params="":
    #!/usr/bin/env bash
    run-version {{ version }} python -m pytest {{ pytest-params }}

# Run tests continuously and re-run them with watchexec if files changed
watchtests *pytest-params:
    watchexec --restart --exts py --stop-timeout 0 -- pytest {{ pytest-params }}

build-package:
    #!/usr/bin/env bash
    uv build --clear --sdist --wheel --out-dir {{ dist-dir }}

testpypi-release: build-package
    #!/usr/bin/env bash
    export UV_PUBLISH_TOKEN=$(op.exe read op://Secrets/test-pypi-token/credential)
    export UV_PUBLISH_URL=https://test.pypi.org/legacy/
    ls -la {{ dist-dir }}
    uv publish {{ dist-dir }}/*

release: check test-all
    #!/usr/bin/env bash
    export UV_PUBLISH_TOKEN=$(op.exe read op://Secrets/pypi-token/credential)
    ls -la {{ dist-dir }}
    uv publish {{ dist-dir }}/*
