# Dev entry points. `just` with no args lists them.

# The full per-push gate, same as CI. Run this before pushing.
ci: fmt-check lint deps test web-check

# Formatting, checked not applied.
fmt-check:
    cargo fmt --all -- --check

# Format every Rust source.
fmt:
    cargo fmt --all

# Clippy, warnings denied.
lint:
    cargo clippy --all-targets -- -D warnings

# Unused workspace dependencies. Stable toolchain, unlike cargo-udeps.
deps:
    cargo machete

# Unit and integration tests, excluding the e2e crate.
test:
    cargo nextest run --workspace --exclude arr-e2e

# End-to-end tests. Needs a Transmission container; not part of the push gate.
e2e:
    cargo nextest run -p arr-e2e

# Frontend lint and typecheck. No-op until web/ exists (issue #6).
web-check:
    #!/usr/bin/env bash
    set -euo pipefail
    if [ ! -d web ]; then echo "web/ not present yet, skipping"; exit 0; fi
    biome ci web/
    pnpm -C web install --frozen-lockfile
    pnpm -C web exec tsc -b --noEmit

# Build the SPA and the binary that embeds it.
build:
    #!/usr/bin/env bash
    set -euo pipefail
    if [ -d web ]; then
        pnpm -C web install --frozen-lockfile
        pnpm -C web build
    fi
    cargo build --release

# Advisory and licence scan. Scheduled, not part of the push gate.
audit:
    cargo deny check

# Install the tools the gate needs.
setup:
    cargo install cargo-nextest cargo-machete --locked
