# polymodel development commands

set dotenv-load := false

# Format and apply safe automatic fixes. This is the default pre-review cleanup command.
fix:
    cargo fmt --all
    cargo clippy --all-targets --features server --fix --allow-dirty --allow-staged --allow-no-vcs -- -D warnings

# Fast compile checks across the relevant Dioxus targets.
check:
    cargo check
    cargo check --features server
    cargo check --target wasm32-unknown-unknown --features web

# Run unit tests.
test:
    cargo nextest run

# Run server-feature tests.
test-server:
    cargo nextest run --features server

# Run all local validation expected before review.
test-all: fix check test test-server
# Run browser end-to-end tests.
e2e:
    cd e2e && npm test
# Start the Dioxus dev server.
serve:
    dx serve
# Build the Dioxus app for web.
build-web:
    dx build --platform web
# Create a sibling jj workspace for a Jira ticket or feature slug, then start a fresh change.
workspace-create name:
    root="$(jj workspace root)" && workspace_path="$(dirname "$root")/{{name}}" && jj workspace add "$workspace_path" -r @
    root="$(jj workspace root)" && workspace_path="$(dirname "$root")/{{name}}" && cd "$workspace_path" && jj new -m "{{name}}"

# List jj workspaces.
workspace-list:
    jj workspace list

# Forget a jj workspace after the work is safely landed or intentionally abandoned.
workspace-forget name:
    jj workspace forget {{name}}

# Show current jj state and diff.
status:
    jj status
    jj diff --summary

# Clean build artifacts.
clean:
    cargo clean
    rm -rf target/dx
