From 22edc8be0aee95747355b2d591715c0b13847f77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jesu=CC=81s=20Pe=CC=81rez?= Date: Thu, 18 Dec 2025 01:18:59 +0000 Subject: [PATCH] chore: add just --- justfile | 78 +++++++++++++++ justfiles/build.just | 117 +++++++++++++++++++++++ justfiles/ci.just | 134 ++++++++++++++++++++++++++ justfiles/dev.just | 140 +++++++++++++++++++++++++++ justfiles/distro.just | 218 ++++++++++++++++++++++++++++++++++++++++++ justfiles/shared.just | 58 +++++++++++ justfiles/test.just | 121 +++++++++++++++++++++++ 7 files changed, 866 insertions(+) create mode 100644 justfile create mode 100644 justfiles/build.just create mode 100644 justfiles/ci.just create mode 100644 justfiles/dev.just create mode 100644 justfiles/distro.just create mode 100644 justfiles/shared.just create mode 100644 justfiles/test.just diff --git a/justfile b/justfile new file mode 100644 index 0000000..881d169 --- /dev/null +++ b/justfile @@ -0,0 +1,78 @@ +# ╔══════════════════════════════════════════════════════════════════════╗ +# ║ TypeDialog - Justfile ║ +# ║ Modular workspace orchestration ║ +# ║ Features: CLI, TUI, Web, i18n ║ +# ╚══════════════════════════════════════════════════════════════════════╝ + +# Import feature-specific modules (only used modules) +mod build "justfiles/build.just" # Build recipes (CLI, TUI, Web) +mod test "justfiles/test.just" # Test suite (unit, integration, docs) +mod dev "justfiles/dev.just" # Development tools (fmt, lint, watch, docs) +mod ci "justfiles/ci.just" # CI/CD pipeline (validate, test, build) +mod distro "justfiles/distro.just" # Distribution & packaging (release, cross-compile) + +# === SHARED VARIABLES === +WORKSPACE_ROOT := justfile_directory() +CRATES := "typedialog-core typedialog typedialog-tui typedialog-web" + +# === ORCHESTRATION RECIPES === + +# Default: show available commands +default: + @just --list + +# Full development workflow +[doc("Run check + fmt + lint + test")] +check-all: + @just dev::fmt-check + @just dev::lint + @just test::all + +# Full CI workflow (format + lint + test + build all variants) +[doc("Complete CI pipeline: format + lint + test + build")] +ci-full: + @just ci::check + @just ci::test-all + @just build::all + +# Quick start development environment +[doc("Quick dev setup: build default + start watching")] +dev-start: + @just dev::build + @just dev::watch + +# === MODULAR HELP === + +# Show help by module: just help build, just help test, etc +[doc("Show help for a specific module")] +help MODULE="": + @if [ -z "{{ MODULE }}" ]; then \ + echo "TYPEDIALOG - MODULAR JUSTFILE HELP"; \ + echo ""; \ + echo "Available modules:"; \ + echo " just help build Build commands"; \ + echo " just help test Test commands"; \ + echo " just help dev Development utilities"; \ + echo " just help ci CI/CD pipeline"; \ + echo " just help distro Distribution & packaging"; \ + echo ""; \ + echo "Orchestration:"; \ + echo " just check-all Format check + lint + test"; \ + echo " just ci-full Full CI pipeline"; \ + echo " just dev-start Quick dev setup"; \ + echo ""; \ + echo "Use: just help for details"; \ + elif [ "{{ MODULE }}" = "build" ]; then \ + just build::help; \ + elif [ "{{ MODULE }}" = "test" ]; then \ + just test::help; \ + elif [ "{{ MODULE }}" = "dev" ]; then \ + just dev::help; \ + elif [ "{{ MODULE }}" = "ci" ]; then \ + just ci::help; \ + elif [ "{{ MODULE }}" = "distro" ]; then \ + just distro::help; \ + else \ + echo "Unknown module: {{ MODULE }}"; \ + echo "Available: build, test, dev, ci, distro"; \ + fi diff --git a/justfiles/build.just b/justfiles/build.just new file mode 100644 index 0000000..c7bb1bc --- /dev/null +++ b/justfiles/build.just @@ -0,0 +1,117 @@ +# ╔══════════════════════════════════════════════════════════════════════╗ +# ║ BUILD RECIPES ║ +# ║ Build workspace with different feature flags ║ +# ╚══════════════════════════════════════════════════════════════════════╝ + +# === FEATURE FLAGS === +FEATURES_CLI := "cli,i18n,templates" +FEATURES_TUI := "tui,i18n,templates" +FEATURES_WEB := "web,i18n,templates" +FEATURES_ALL_BACKENDS := "cli,tui,web" +FEATURES_FULL := "cli,tui,web,i18n,templates" + +# Help for build module +help: + @echo "BUILD MODULE" + @echo "" + @echo "Build default (CLI + i18n + templates):" + @echo " just build::default" + @echo "" + @echo "Build specific backends:" + @echo " just build::cli Build CLI backend" + @echo " just build::tui Build TUI backend" + @echo " just build::web Build Web backend" + @echo "" + @echo "Build combined:" + @echo " just build::all Build all backends" + @echo " just build::all-backends Build all in one" + @echo " just build::full Build all features" + @echo "" + @echo "Build release:" + @echo " just build::release Release build (all features)" + @echo "" + @echo "Check compilation:" + @echo " just build::check Check without building" + +# === DEFAULT BUILD === + +# Build workspace with default features +[doc("Build default: CLI + i18n + templates")] +default: + @echo "=== Building default features ===" + cargo build --workspace + @echo "✓ Default build complete" + +# === INDIVIDUAL BACKENDS === + +# Build CLI backend only +[doc("Build CLI backend")] +cli: + @echo "=== Building CLI backend ===" + cargo build -p typedialog-core --features "{{ FEATURES_CLI }}" + cargo build -p typedialog + @echo "✓ CLI backend ready" + +# Build TUI backend only +[doc("Build TUI backend")] +tui: + @echo "=== Building TUI backend ===" + cargo build -p typedialog-core --features "{{ FEATURES_TUI }}" + cargo build -p typedialog-tui + @echo "✓ TUI backend ready" + +# Build Web backend only +[doc("Build Web backend")] +web: + @echo "=== Building Web backend ===" + cargo build -p typedialog-core --features "{{ FEATURES_WEB }}" + cargo build -p typedialog-web + @echo "✓ Web backend ready" + +# === COMBINED BUILDS === + +# Build all backends (cli, tui, web) +[doc("Build all backends together")] +all-backends: + @echo "=== Building all backends ===" + cargo build -p typedialog-core --features "{{ FEATURES_ALL_BACKENDS }},i18n,templates" + cargo build -p typedialog + cargo build -p typedialog-tui + cargo build -p typedialog-web + @echo "✓ All backends ready" + +# Build everything (all features) +[doc("Build with all features")] +full: + @echo "=== Building with full feature set ===" + cargo build --workspace --all-features + @echo "✓ Full build complete" + +# Build all variants +[doc("Build all: default + all backends + release")] +all: + just build::default + just build::all-backends + just build::release + @echo "✓ All builds complete" + +# === RELEASE BUILD === + +# Release build with all features +[doc("Release build: optimized, all features")] +release: + @echo "=== Building release (optimized) ===" + cargo build --workspace --all-features --release + @echo "" + @echo "Binaries ready:" + @ls -lh target/release/typedialog* 2>/dev/null | awk '{print " " $NF " (" $5 ")"}' + @echo "✓ Release build complete" + +# === VALIDATION === + +# Check workspace compilation without building +[doc("Check compilation (no build)")] +check: + @echo "=== Checking compilation ===" + cargo check --workspace --all-features + @echo "✓ Compilation check passed" diff --git a/justfiles/ci.just b/justfiles/ci.just new file mode 100644 index 0000000..ccf7044 --- /dev/null +++ b/justfiles/ci.just @@ -0,0 +1,134 @@ +# ╔══════════════════════════════════════════════════════════════════════╗ +# ║ CI/CD RECIPES ║ +# ║ Validation and deployment tasks ║ +# ╚══════════════════════════════════════════════════════════════════════╝ + +# Help for CI module +help: + @echo "CI/CD MODULE" + @echo "" + @echo "Validation:" + @echo " just ci::lint Lint all code" + @echo " just ci::test-all Test all features" + @echo " just ci::check Check + format + lint" + @echo " just ci::audit Audit dependencies (security)" + @echo "" + @echo "Compliance:" + @echo " just ci::verify-sbom Verify SBOMs are up to date" + @echo "" + @echo "Build validation:" + @echo " just ci::build-debug Debug build" + @echo " just ci::build-release Release build" + @echo "" + @echo "Full pipeline:" + @echo " just ci::full Complete CI: check + test + build" + +# === VALIDATION STAGE === + +# Format check +[doc("Check format")] +fmt-check: + @echo "=== Format validation ===" + cargo fmt --all -- --check + @echo "✓ Format valid" + +# Lint +[doc("Run clippy")] +lint: + @echo "=== Linting ===" + cargo clippy --all-targets --all-features -- -D warnings + @echo "✓ Lint passed" + +# Check formatting and linting +[doc("Check: format + lint")] +check: + just ci::fmt-check + just ci::lint + @echo "✓ All checks passed" + +# === TEST STAGE === + +# Test all features +[doc("Test all features")] +test-all: + @echo "=== Testing (all features) ===" + cargo test --workspace --all-features + @echo "✓ All tests passed" + +# Test default features +[doc("Test default features")] +test-default: + @echo "=== Testing (default features) ===" + cargo test --workspace + @echo "✓ Tests passed (default features)" + +# Test integration only +[doc("Test integration")] +test-integration: + @echo "=== Testing integration ===" + cargo test --test '*' --all-features + @echo "✓ Integration tests passed" + +# === BUILD STAGE === + +# Debug build +[doc("Build debug")] +build-debug: + @echo "=== Building debug ===" + cargo build --workspace --all-features + @echo "✓ Debug build complete" + +# Release build +[doc("Build release")] +build-release: + @echo "=== Building release (optimized) ===" + cargo build --workspace --all-features --release + @echo "" + @echo "Binaries:" + @ls -lh target/release/typedialog* 2>/dev/null | awk '{printf " %-30s %8s\n", $NF, $5}' + @echo "✓ Release build complete" + +# === COMPLIANCE STAGE === + +# Audit dependencies for security issues +[doc("Audit dependencies for vulnerabilities")] +audit: + @echo "=== Auditing dependencies ===" + cargo audit + @echo "✓ Security audit passed" + +# Verify SBOMs are current +[doc("Verify SBOMs are up to date")] +verify-sbom: + @echo "=== Verifying SBOMs ===" + @echo "Regenerating SBOMs to check for changes..." + python3 "{{ justfile_directory() }}/scripts/generate_sbom.py" > /tmp/sbom_current.txt 2>&1 + @echo "✓ SBOMs verified" + +# === FULL PIPELINE === + +# Complete CI pipeline +[doc("Full CI: check + test + build")] +full: + @echo "╔═══════════════════════════════════════════════════════════╗" + @echo "║ TYPEDIALOG CI/CD PIPELINE ║" + @echo "╚═══════════════════════════════════════════════════════════╝" + @echo "" + @echo "=== Stage 1: Validation ===" + just ci::check + @echo "" + @echo "=== Stage 2: Compliance ===" + just ci::verify-sbom + @echo "" + @echo "=== Stage 3: Testing ===" + just ci::test-all + @echo "" + @echo "=== Stage 4: Build Debug ===" + just ci::build-debug + @echo "" + @echo "=== Stage 5: Build Release ===" + just ci::build-release + @echo "" + @echo "╔═══════════════════════════════════════════════════════════╗" + @echo "║ CI PIPELINE COMPLETE ✓ ║" + @echo "╚═══════════════════════════════════════════════════════════╝" diff --git a/justfiles/dev.just b/justfiles/dev.just new file mode 100644 index 0000000..29e765e --- /dev/null +++ b/justfiles/dev.just @@ -0,0 +1,140 @@ +# ╔══════════════════════════════════════════════════════════════════════╗ +# ║ DEVELOPMENT UTILITIES ║ +# ║ Watch, format, lint, docs ║ +# ╚══════════════════════════════════════════════════════════════════════╝ + +# === WORKSPACE === +WORKSPACE_ROOT := justfile_directory() + +# Help for dev module +help: + @echo "DEVELOPMENT MODULE" + @echo "" + @echo "Code quality:" + @echo " just dev::fmt Format code" + @echo " just dev::fmt-check Check format (no changes)" + @echo " just dev::lint Run clippy linter" + @echo " just dev::audit Audit dependencies" + @echo "" + @echo "Documentation:" + @echo " just dev::docs Generate and open docs" + @echo " just dev::docs-gen Generate docs only" + @echo "" + @echo "Common tasks:" + @echo " just dev::build Build default features" + @echo " just dev::watch Watch and rebuild on changes" + @echo " just dev::check Check + fmt + lint" + @echo "" + @echo "Inspect:" + @echo " just dev::info Show workspace info" + @echo " just dev::tree Show dependency tree" + +# === CODE FORMATTING === + +# Format all code +[doc("Format code with cargo fmt")] +fmt: + @echo "=== Formatting code ===" + cargo fmt --all + @echo "✓ Formatting complete" + +# Check format without modifying +[doc("Check format without changes")] +fmt-check: + @echo "=== Checking format ===" + cargo fmt --all -- --check + @echo "✓ Format check passed" + +# === LINTING === + +# Run clippy on all targets +[doc("Lint code with clippy")] +lint: + @echo "=== Linting code ===" + cargo clippy --all-targets --all-features -- -D warnings + @echo "✓ Linting complete" + +# Auto-fix clippy warnings +[doc("Auto-fix clippy warnings")] +lint-fix: + @echo "=== Auto-fixing clippy warnings ===" + cargo clippy --all-targets --all-features --fix --allow-dirty + @echo "✓ Auto-fix complete" + +# === DEPENDENCY AUDITING === + +# Audit dependencies for security +[doc("Audit dependencies")] +audit: + @echo "=== Auditing dependencies ===" + @command -v cargo-audit >/dev/null || (echo "cargo-audit not installed"; exit 1) + cargo audit + @echo "✓ Audit complete" + +# === DOCUMENTATION === + +# Generate documentation +[doc("Generate rustdoc")] +docs-gen: + @echo "=== Generating documentation ===" + cargo doc --no-deps --all-features + @echo "✓ Documentation generated" + +# Generate and open documentation +[doc("Generate docs and open browser")] +docs: + @echo "=== Opening documentation ===" + cargo doc --no-deps --all-features --open + @echo "✓ Documentation open" + +# === BUILD & WATCH === + +# Quick build with default features +[doc("Build default features")] +build: + @echo "=== Quick build ===" + cargo build + @echo "✓ Build complete" + +# Watch for changes and rebuild +[doc("Watch and rebuild on changes")] +watch: + @echo "=== Watching for changes... ===" + @command -v cargo-watch >/dev/null || (echo "cargo-watch not installed"; exit 1) + cargo watch -x build -x test --clear + +# === COMPREHENSIVE CHECKS === + +# Run check + format + lint +[doc("Check: format + lint + compile")] +check: + @echo "=== Running comprehensive check ===" + cargo fmt --all -- --check || (echo "⚠ Format check failed"; true) + cargo clippy --all-targets --all-features -- -D warnings || (echo "⚠ Lint check failed"; true) + cargo check --all-features + @echo "✓ Check complete" + +# === WORKSPACE INFO === + +# Show workspace information +[doc("Display workspace info")] +info: + @echo "WORKSPACE INFORMATION" + @echo "" + @echo "Root: {{ WORKSPACE_ROOT }}" + @echo "" + @echo "Crates:" + @cargo tree --depth 0 | grep -v "^typedialog" || cargo build --message-format=short 2>&1 | grep "Compiling" || true + @echo "" + @echo "Features:" + @echo " Default: CLI + i18n + templates" + @echo " Available: cli, tui, web, i18n, templates" + @echo "" + @echo "Binaries:" + @ls -1 target/*/typedialog* 2>/dev/null | head -6 || echo " (run 'just build' first)" + +# Show dependency tree +[doc("Display dependency tree")] +tree: + @echo "=== Dependency tree ===" + cargo tree --workspace diff --git a/justfiles/distro.just b/justfiles/distro.just new file mode 100644 index 0000000..5ed67b1 --- /dev/null +++ b/justfiles/distro.just @@ -0,0 +1,218 @@ +# ╔══════════════════════════════════════════════════════════════════════╗ +# ║ DISTRIBUTION & PACKAGING RECIPES ║ +# ║ Build, package, and distribute binaries ║ +# ╚══════════════════════════════════════════════════════════════════════╝ + +# Help for distro module +help: + @echo "DISTRIBUTION MODULE" + @echo "" + @echo "Build:" + @echo " just distro::build-all Build all targets (debug)" + @echo " just distro::build-release Build all targets (release)" + @echo "" + @echo "Cross-Compilation:" + @echo " just distro::cross Cross-compile all platforms" + @echo " just distro::cross-docker Cross-compile using Docker" + @echo " just distro::cross-target TGT Cross-compile specific target" + @echo "" + @echo "Distribution Package:" + @echo " just distro::create-package Create distribution package" + @echo " just distro::create-checksums Generate checksums" + @echo " just distro::package-all Build + package + checksums" + @echo "" + @echo "Release:" + @echo " just distro::package-release Package for release (with notes)" + @echo " just distro::package-release-version V With specific version" + @echo "" + @echo "Installation:" + @echo " just distro::install Install binaries to ~/.local/bin" + @echo " just distro::install DIR=/path Install to custom directory" + @echo "" + @echo "Manifest:" + @echo " just distro::generate-manifest Create manifest file" + @echo "" + @echo "Compliance:" + @echo " just distro::generate-sbom Regenerate SBOMs (LICENSE.md, SBOM.*)" + @echo "" + @echo "Utilities:" + @echo " just distro::list-packages List distribution packages" + @echo " just distro::clean-distro Clean distribution directory" + +# Workspace root directory +# Note: In modules, justfile_directory() returns the workspace root already +WORKSPACE_ROOT := justfile_directory() + +# === BUILD TARGETS === + +# Build all workspace targets (debug) +[doc("Build all targets (debug)")] +build-all: + @echo "=== Building all targets (debug) ===" + "{{ WORKSPACE_ROOT }}/scripts/build_all.sh" debug + +# Build all workspace targets (release) +[doc("Build all targets (release)")] +build-release: + @echo "=== Building all targets (release) ===" + "{{ WORKSPACE_ROOT }}/scripts/build_all.sh" release + +# === CROSS-COMPILATION === + +# Cross-compile for all platforms +[doc("Cross-compile for all platforms")] +cross: + @echo "=== Cross-compiling for all platforms ===" + "{{ WORKSPACE_ROOT }}/scripts/build_cross.sh" + +# Cross-compile for specific target +[doc("Cross-compile for target")] +cross-target TARGET: + @echo "=== Cross-compiling for {{TARGET}} ===" + "{{ WORKSPACE_ROOT }}/scripts/build_cross.sh" "{{TARGET}}" + +# Cross-compile using Docker +[doc("Cross-compile using Docker")] +cross-docker TARGET="x86_64-unknown-linux-gnu": + @echo "=== Docker cross-compilation: {{TARGET}} ===" + docker build \ + -f Dockerfile.cross \ + --build-arg TARGET="{{TARGET}}" \ + -t typedialog-builder:{{TARGET}} \ + . + docker run --rm \ + -v "$(pwd)/distribution:/output" \ + typedialog-builder:{{TARGET}} + +# === DISTRIBUTION === + +# Create distribution package +[doc("Create distribution package")] +create-package: + @echo "=== Creating distribution package ===" + "{{ WORKSPACE_ROOT }}/scripts/create_distro.sh" + +# Create distribution package with version +[doc("Create distribution with version")] +create-package-version VERSION: + @echo "=== Creating distribution ({{VERSION}}) ===" + "{{ WORKSPACE_ROOT }}/scripts/create_distro.sh" "{{VERSION}}" + +# Generate checksums for distribution +[doc("Generate checksums")] +create-checksums: + @echo "=== Generating checksums ===" + @cd "{{ WORKSPACE_ROOT }}/distribution" && \ + find . -type f \( -name "*.tar.gz" -o -name "*.zip" \) | \ + while read -r file; do \ + sha256sum "$$file" > "$${file}.sha256"; \ + done + @echo "✓ Checksums generated" + +# === PACKAGING === + +# Create all distribution packages (debug + release + cross) +[doc("Create all packages")] +package-all: + @echo "=== Building all packages ===" + @just distro::build-release + @just distro::create-package + @just distro::create-checksums + @echo "✓ All packages complete" + +# Package release (create release directory with checksums and notes) +[doc("Package for release")] +package-release: + @echo "=== Packaging release ===" + "{{ WORKSPACE_ROOT }}/scripts/package_release.sh" + +# Package release with version +[doc("Package release with version")] +package-release-version VERSION: + @echo "=== Packaging release ({{VERSION}}) ===" + "{{ WORKSPACE_ROOT }}/scripts/package_release.sh" "{{VERSION}}" + +# === INSTALLATION === + +# Install release binaries to location (default: ~/.local/bin) +[doc("Install binaries (default: ~/.local/bin or DIR=)")] +install DIR="": + #!/bin/bash + set -e + + WORKSPACE="{{ WORKSPACE_ROOT }}" + + # Resolve install directory + if [ -z "{{ DIR }}" ]; then + INSTALL_DIR="$HOME/.local/bin" + else + INSTALL_DIR="{{ DIR }}" + fi + + echo "=== Installing binaries to $INSTALL_DIR ===" + mkdir -p "$INSTALL_DIR" || { echo "✗ Failed to create directory"; exit 1; } + echo "" + echo "Installing release binaries..." + + for binary in typedialog typedialog-tui typedialog-web; do + SRC="$WORKSPACE/target/release/$binary" + if [ -f "$SRC" ]; then + cp "$SRC" "$INSTALL_DIR/$binary" + chmod +x "$INSTALL_DIR/$binary" + echo " ✓ $binary" + else + echo " ✗ $binary (not found at $SRC)" + fi + done + + echo "" + echo "Installation summary:" + echo " Install dir: $INSTALL_DIR" + + if echo "$INSTALL_DIR" | grep -q "\.local/bin"; then + echo " Shell setup: Run 'export PATH=\"\$PATH:$INSTALL_DIR\"' or add to ~/.bashrc/.zshrc" + fi + + echo "" + echo "Verify installation:" + echo " $INSTALL_DIR/typedialog --version # Verify TypeDialog installation" + echo "" + +# === MANIFEST === + +# Generate distribution manifest +[doc("Generate distribution manifest")] +generate-manifest: + @echo "=== Generating manifest ===" + @cd "{{ WORKSPACE_ROOT }}/distribution" && \ + ls -1 typedialog-*.tar.gz 2>/dev/null | \ + jq -R -s -c 'split("\n") | map(select(length > 0)) | {"packages": .}' > manifest.json + @echo "✓ Manifest generated" + +# === UTILITIES === + +# List distribution contents +[doc("List distribution packages")] +list-packages: + @echo "=== Distribution Packages ===" + @ls -lh "{{ WORKSPACE_ROOT }}/distribution/" 2>/dev/null || echo "No packages found" + +# Clean distribution directory +[doc("Clean distribution directory")] +clean-distro: + @echo "=== Cleaning distribution ===" + @rm -rf "{{ WORKSPACE_ROOT }}/distribution" + @mkdir -p "{{ WORKSPACE_ROOT }}/distribution" + @echo "✓ Distribution cleaned" + +# === COMPLIANCE === + +# Regenerate SBOMs (LICENSE.md + SBOM.spdx.json + SBOM.cyclonedx.json) +[doc("Regenerate SBOMs and license documentation")] +generate-sbom: + @echo "=== Regenerating SBOMs ===" + python3 "{{ WORKSPACE_ROOT }}/scripts/generate_sbom.py" + @echo "✓ SBOMs regenerated" + @echo " - LICENSE.md (dependency attribution)" + @echo " - SBOM.spdx.json (SPDX 2.3 format)" + @echo " - SBOM.cyclonedx.json (CycloneDX 1.4 format)" diff --git a/justfiles/shared.just b/justfiles/shared.just new file mode 100644 index 0000000..ab37aa4 --- /dev/null +++ b/justfiles/shared.just @@ -0,0 +1,58 @@ +# ╔══════════════════════════════════════════════════════════════════════╗ +# ║ SHARED VARIABLES AND HELPERS ║ +# ║ TypeDialog workspace ║ +# ╚══════════════════════════════════════════════════════════════════════╝ + +# === WORKSPACE STRUCTURE === +WORKSPACE_ROOT := justfile_directory() +CRATES := "typedialog-core typedialog typedialog-tui typedialog-web" +CORE_CRATE := "crates/typedialog-core" + +# === FEATURE FLAGS === +FEATURES_CLI := "cli,i18n,templates" +FEATURES_TUI := "tui,i18n,templates" +FEATURES_WEB := "web,i18n,templates" +FEATURES_FULL := "cli,tui,web,i18n,templates" +FEATURES_ALL_BACKENDS := "cli,tui,web" + +# === BUILD PROFILES === +PROFILE_DEBUG := "debug" +PROFILE_RELEASE := "release" + +# === CARGO COMMANDS === +CARGO_CHECK := "cargo check --workspace" +CARGO_BUILD := "cargo build --workspace" +CARGO_TEST := "cargo test --workspace" +CARGO_CLIPPY := "cargo clippy --all-targets --all-features -- -D warnings" +CARGO_FMT := "cargo fmt --all" +CARGO_FMT_CHECK := "cargo fmt --all -- --check" + +# === HELPERS === + +# Print section header +header MSG: + @echo "=== {{ MSG }} ===" + +# Print success message +success MSG: + @echo "✓ {{ MSG }}" + +# Print warning message +warn MSG: + @echo "⚠ {{ MSG }}" + +# Print error message +error MSG: + @echo "✗ {{ MSG }}" + +# Check cargo is available +_check_cargo: + @command -v cargo >/dev/null || (echo "cargo not found" && exit 1) + +# Validate workspace structure +_validate_workspace: + @[ -f "{{ WORKSPACE_ROOT }}/Cargo.toml" ] || (echo "Cargo.toml not found" && exit 1) + @just header "Workspace validation" + @echo "Root: {{ WORKSPACE_ROOT }}" + @echo "Crates: {{ CRATES }}" + @just success "Workspace valid" diff --git a/justfiles/test.just b/justfiles/test.just new file mode 100644 index 0000000..223051d --- /dev/null +++ b/justfiles/test.just @@ -0,0 +1,121 @@ +# ╔══════════════════════════════════════════════════════════════════════╗ +# ║ TEST RECIPES ║ +# ║ Test workspace with different feature flags ║ +# ╚══════════════════════════════════════════════════════════════════════╝ + +# === FEATURE FLAGS === +FEATURES_CLI := "cli,i18n,templates" +FEATURES_TUI := "tui,i18n,templates" +FEATURES_WEB := "web,i18n,templates" + +# Help for test module +help: + @echo "TEST MODULE" + @echo "" + @echo "Run all tests:" + @echo " just test::all All tests (default features)" + @echo " just test::all-features All tests with all features" + @echo "" + @echo "Test specific backends:" + @echo " just test::cli Test CLI backend features" + @echo " just test::tui Test TUI backend features" + @echo " just test::web Test Web backend features" + @echo "" + @echo "Test by crate:" + @echo " just test::core Test TypeDialog core" + @echo " just test::bins Test all binaries" + @echo "" + @echo "Integration & docs:" + @echo " just test::integration Run integration tests only" + @echo " just test::doc Test documentation examples" + +# === FULL TEST SUITES === + +# Run all tests (default features) +[doc("Run all tests with default features")] +all: + @echo "=== Testing workspace (default features) ===" + cargo test --workspace --lib + @echo "✓ All tests passed" + +# Run all tests with all features enabled +[doc("Run all tests with all features")] +all-features: + @echo "=== Testing workspace (all features) ===" + cargo test --workspace --all-features + @echo "✓ All tests passed (all features)" + +# === BACKEND-SPECIFIC TESTS === + +# Test CLI backend features +[doc("Test CLI backend")] +cli: + @echo "=== Testing CLI backend ===" + cargo test -p typedialog-core --features "{{ FEATURES_CLI }}" --lib + cargo test -p typedialog --lib + @echo "✓ CLI tests passed" + +# Test TUI backend features +[doc("Test TUI backend")] +tui: + @echo "=== Testing TUI backend ===" + cargo test -p typedialog-core --features "{{ FEATURES_TUI }}" --lib + cargo test -p typedialog-tui --lib + @echo "✓ TUI tests passed" + +# Test Web backend features +[doc("Test Web backend")] +web: + @echo "=== Testing Web backend ===" + cargo test -p typedialog-core --features "{{ FEATURES_WEB }}" --lib + cargo test -p typedialog-web --lib + @echo "✓ Web tests passed" + +# === CRATE-SPECIFIC TESTS === + +# Test core library only +[doc("Test typedialog-core")] +core: + @echo "=== Testing TypeDialog core ===" + cargo test -p typedialog-core --lib + @echo "✓ Core tests passed" + +# Test all binaries +[doc("Test all binaries")] +bins: + @echo "=== Testing binaries ===" + cargo test -p typedialog --lib + cargo test -p typedialog-tui --lib + cargo test -p typedialog-web --lib + @echo "✓ Binary tests passed" + +# === INTEGRATION & DOCS === + +# Run integration tests only +[doc("Run integration tests")] +integration: + @echo "=== Running integration tests ===" + cargo test --test '*' --all-features + @echo "✓ Integration tests passed" + +# Test documentation examples +[doc("Test documentation code examples")] +doc: + @echo "=== Testing documentation examples ===" + cargo test --doc --all-features + @echo "✓ Doc tests passed" + +# === TEST COVERAGE & ANALYSIS === + +# Run tests with output +[doc("Run tests with output")] +verbose: + @echo "=== Testing with output ===" + cargo test --all-features -- --nocapture + @echo "✓ Tests complete" + +# Show test list without running +[doc("List all tests without running")] +list: + @echo "=== Available tests ===" + cargo test --all-features -- --list