[private, default]
_:
    @just --list

# install dependencies
install:
    npm ci
    npm update

# lint typescript
lint:
    npx @biomejs/biome check --write --unsafe .

# build app
build:
    npm run build

# run tests
test:
    npm test

# run typechecker
typecheck:
    npm run typecheck

# stage the local release binary
stage-local-binary:
    uv run --no-sync cargo build --release --no-default-features --bin skilly
    npm run stage-local-binary

# pack the package
pack:
    npm pack .

# publish package locally
publish: install test stage-local-binary
    #!/usr/bin/env bash
    set -euo pipefail
    trap 'rm -rf vendor' EXIT
    npm publish .

# dry-run publish flow
publish-dry-run: install test stage-local-binary
    #!/usr/bin/env bash
    set -euo pipefail
    trap 'rm -rf vendor' EXIT
    npm publish . --dry-run

# smoke test
smoke: install test stage-local-binary
    #!/usr/bin/env bash
    set -euo pipefail
    package_dir="$(pwd)"
    tarball="$(npm pack --silent .)"
    temp_dir="$(mktemp -d)"
    trap 'rm -f "${package_dir}/${tarball}"; rm -rf "$temp_dir" "${package_dir}/vendor"' EXIT
    (
        cd "$temp_dir"
        npm init -y >/dev/null 2>&1
        npm install --silent "${package_dir}/${tarball}"
        ./node_modules/@xelandernt/skilly/dist/src/bin/skilly.js --help
    )
