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

# install TypeScript package dependencies
install:
    npm ci

# build the TypeScript launcher package
build:
    npm run build

# test the TypeScript launcher package
test:
    npm test

# type check the TypeScript launcher package
typecheck:
    npm run typecheck

# stage the local release binary into the TypeScript package
stage-local-binary:
    uv run --no-sync cargo build --release --bin skilly
    npm run stage-local-binary

# pack the TypeScript launcher package
pack:
    npm pack .

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

# dry-run the local TypeScript launcher 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 the packaged TypeScript launcher
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
    )
