tree-type 0.4.3

Rust macros for creating type-safe filesystem tree structures
Documentation
# Tree-Type development recipes

# Run all CI quality checks locally (matches CrowCI environment)
ci:
    mkdir -p .cache/cargo/registry .cache/cargo/git .cache/target
    docker run --rm \
        -u "$(id -u):$(id -g)" \
        -v "$(pwd):/workspace" \
        -v "$(pwd)/.cache/cargo/registry:/cache/cargo/registry" \
        -v "$(pwd)/.cache/cargo/git:/cache/cargo/git" \
        -v "$(pwd)/.cache/target:/cache/target" \
        -e CARGO_HOME=/cache/cargo \
        -e CARGO_TARGET_DIR=/cache/target \
        -e CI=true \
        -w /workspace \
        git.kemitix.net/kemitix/rust:v4.8.0 \
        sh -c "{{ ci_dependencies }} \
            echo \"FORMAT:\" && cargo +nightly fmt --check && \
            echo \"CHECK:\" && cargo +stable hack --feature-powerset check && \
            echo \"MACHETE:\" && cargo +stable machete && \
            echo \"CLIPPY(PROC-MACRO):\" && cargo +stable hack --feature-powerset clippy --all-targets -p tree-type-proc-macro -- -D warnings && \
            echo \"CLIPPY(MAIN):\" && cargo +stable hack --feature-powerset clippy --all-targets -- -D warnings && \
            echo \"PEDANT:\" && cargo +stable hack --feature-powerset clippy -- -W clippy::pedantic -D warnings && \
            echo \"BUILD:\" && cargo +stable hack --feature-powerset build && \
            echo \"BUILD-TESTS:\" && cargo +stable build --tests && \
            echo \"RUN-TESTS:\" && RUST_LOG=debug cargo +stable hack --feature-powerset nextest run --no-fail-fast"
    # just ci-readme

ci-readme:
    # NOTE: not compatible with workspace inheritance
    echo "README:"
    cargo readme > README_generated.md
    diff README.md README_generated.md
    if test -f README_generated.md ; then rm README_generated.md ; fi

# Project-specific dependencies
ci_dependencies := ""

# Run CI with all feature combinations
ci-all-features:
    cargo fmt --check
    just check-all-features
    cargo machete
    just clippy-all-features
    just test-all-features

# Format code and update README.md
fmt: fmt-fix readme-fix

# Check for compiler errors/warnings
check:
    cargo check -p tree-type-proc-macro
    cargo check

# Check for compiler errors/warnings
check-codegen-v2:
    cargo check --features codegen-v2 -p tree-type-proc-macro
    cargo check --features codegen-v2

# Check all feature combinations
check-all-features:
    cargo hack --feature-powerset check -p tree-type-proc-macro
    cargo hack --feature-powerset check

# Run clippy linter
clippy:
    cargo hack --feature-powerset clippy --all-targets -p tree-type-proc-macro -- -D warnings
    cargo hack --feature-powerset clippy --all-targets -- -D warnings

# Run clippy on all feature combinations
clippy-all-features:
    RUSTFLAGS="-Zmacro-backtrace" cargo +nightly hack --feature-powerset clippy --all-targets -- -D warnings

# Run tests
test: test-code test-docs

test-code:
    cargo hack --feature-powerset nextest run -p tree-type-proc-macro
    cargo hack --feature-powerset nextest run

test-docs:
    cargo test --doc

# Test all feature combinations
test-all-features:
    cargo hack --feature-powerset test

fmt-fix:
    cargo +nightly fmt

readme-fix:
    # cargo readme --output README.md

machete-fix:
    cargo machete --fix -p tree-type-proc-macro || true
    cargo machete --fix || true

# Run all quality checks and fix formatting
fix: readme-fix machete-fix fmt-fix ci

# Expand macro for specific test with features
# Examples:
#   just expand tree-type-proc-macro dynamic_id_test codegen-v2
#   just expand tree-type comprehensive_test
#   just expand tree-type-proc-macro dynamic_id_test "codegen-v2,serde"
expand package test_name *features="":
    #!/bin/bash
    timestamp=$(date +%Y-%m-%d-%H-%M-%S)
    output_file=".output-${timestamp}-expand-{{test_name}}.log"
    feature_flags=""
    if [ "{{features}}" != "" ]; then
        feature_flags="--features {{features}}"
    fi
    echo "Expanding test {{test_name}} with features: {{features}}"
    cargo expand -p {{package}} ${feature_flags} --test {{test_name}} > "${output_file}" 2>&1
    echo "Output saved to: ${output_file}"
    echo "Use: head -50 ${output_file} | grep -A 20 -B 5 'struct.*{{test_name}}'"

# Compile expanded macro output to verify it compiles correctly
compile-expanded package test_name *features="":
    #!/bin/bash
    just expand {{package}} {{test_name}} {{features}}
    timestamp=$(date +%Y-%m-%d-%H-%M-%S)
    output_file=".output-${timestamp}-compile-{{test_name}}.log"
    expanded_file=$(ls -t .output-*-expand-{{test_name}}.log 2>/dev/null | head -1)
    echo "Compiling: $expanded_file"
    rustc --edition 2024 --crate-type bin --test \
        -L target/debug/deps \
        --extern tree_type=target/debug/libtree_type.rlib \
        "$expanded_file" -o /tmp/test_expanded > "${output_file}" 2>&1
    echo "Output saved to: ${output_file}"

# Show current directory and list output files
show-paths:
    @echo "Current directory: $(pwd)"
    @echo "Justfile location: $(dirname {{justfile()}})"
    @echo ""
    @echo "Output files in current directory:"
    @ls -la .output-*.log 2>/dev/null || echo "No output files found"
    @echo ""
    @echo "Output files in justfile directory:"
    @ls -la $(dirname {{justfile()}})/.output-*.log 2>/dev/null || echo "No output files found"

# Run specific test(s) with optional features
# Examples:
#   just test-specific v2                    # Run all v2 module tests
#   just test-specific v2 codegen-v2         # Run v2 tests with codegen-v2 feature
#   just test-specific nesting_4_level ""    # Run specific test file, no features
test-specific test_name features="":
    #!/usr/bin/env bash
    timestamp=$(date +%Y-%m-%d-%H-%M-%S)
    output_file=".output-${timestamp}-test-{{test_name}}.log"
    if [ "{{features}}" = "" ]; then
        echo "Running: cargo nextest run --test {{test_name}}"
        cargo nextest run --test {{test_name}} 2>&1 | tee "${output_file}"
    else
        echo "Running: cargo nextest run --features {{features}} --test {{test_name}}"
        cargo nextest run --features {{features}} --test {{test_name}} 2>&1 | tee "${output_file}"
    fi
    echo "Output saved to: ${output_file}"