mirror of
https://github.com/Xevion/Pac-Man.git
synced 2026-01-31 04:25:07 -06:00
refactor(just): split monolithic Justfile into project-specific modules
Organize recipes into dedicated Justfiles for pacman, server, and web components. Root Justfile now serves as a thin facade with common aliases pointing to submodule recipes.
This commit is contained in:
@@ -1,139 +1,37 @@
|
|||||||
set shell := ["bash", "-c"]
|
set shell := ["bash", "-c"]
|
||||||
set windows-shell := ["powershell.exe", "-NoLogo", "-Command"]
|
|
||||||
|
|
||||||
binary_extension := if os() == "windows" { ".exe" } else { "" }
|
mod pacman 'pacman/Justfile'
|
||||||
|
mod server 'pacman-server/Justfile'
|
||||||
|
mod web 'web/Justfile'
|
||||||
|
|
||||||
# Display available recipes
|
# Display available recipes
|
||||||
default:
|
default:
|
||||||
just --list
|
@just --list --list-submodules
|
||||||
|
|
||||||
# === Quality & Validation ===
|
# Run the game (pacman::run)
|
||||||
|
run *args:
|
||||||
|
@just pacman::run {{args}}
|
||||||
|
|
||||||
# Run all checks (format, lint, test)
|
# Run all checks (pacman::check)
|
||||||
check:
|
check:
|
||||||
@echo "Running all checks..."
|
@just pacman::check
|
||||||
@just format-check
|
|
||||||
@just lint
|
|
||||||
@just test
|
|
||||||
@echo "All checks passed!"
|
|
||||||
|
|
||||||
# Quick format + lint for fast iteration
|
alias lint := check
|
||||||
quick:
|
|
||||||
cargo fmt --all
|
|
||||||
@cargo clippy --all-targets --all-features --quiet -- -D warnings
|
|
||||||
|
|
||||||
# Full CI pipeline
|
# Run tests (pacman::test)
|
||||||
ci: format-check lint test coverage
|
|
||||||
@echo "CI pipeline complete!"
|
|
||||||
|
|
||||||
# Auto-format code
|
|
||||||
format:
|
|
||||||
cargo fmt --all
|
|
||||||
|
|
||||||
# Check formatting without modifying files
|
|
||||||
format-check:
|
|
||||||
cargo fmt --all -- --check
|
|
||||||
|
|
||||||
# Run strict multi-platform lints (desktop + wasm)
|
|
||||||
lint:
|
|
||||||
@echo "Running clippy for desktop target..."
|
|
||||||
@cargo clippy --all-targets --all-features --quiet -- -D warnings
|
|
||||||
@echo "Running clippy for wasm target..."
|
|
||||||
@cargo clippy -p pacman --target wasm32-unknown-emscripten --all-targets --all-features --quiet -- -D warnings
|
|
||||||
@echo "All lints passed!"
|
|
||||||
|
|
||||||
# Fix linting errors & formatting
|
|
||||||
fix:
|
|
||||||
cargo fix --workspace --lib --allow-dirty
|
|
||||||
cargo fmt --all
|
|
||||||
|
|
||||||
# Security audit for vulnerabilities
|
|
||||||
audit:
|
|
||||||
cargo audit
|
|
||||||
|
|
||||||
# Verify required tools are installed
|
|
||||||
smoke:
|
|
||||||
@command -v cargo >/dev/null || (echo "❌ cargo not found" && exit 1)
|
|
||||||
@command -v samply >/dev/null || (echo "❌ samply not found" && exit 1)
|
|
||||||
@command -v bun >/dev/null || (echo "❌ bun not found" && exit 1)
|
|
||||||
@command -v caddy >/dev/null || (echo "❌ caddy not found" && exit 1)
|
|
||||||
@echo "✓ All required tools present!"
|
|
||||||
|
|
||||||
# === Testing & Coverage ===
|
|
||||||
|
|
||||||
# Run tests with nextest
|
|
||||||
test:
|
test:
|
||||||
cargo nextest run --no-fail-fast
|
@just pacman::test
|
||||||
|
|
||||||
# Generate baseline LCOV report
|
# Format code (pacman::format)
|
||||||
coverage:
|
format:
|
||||||
cargo +nightly llvm-cov \
|
@just pacman::format
|
||||||
--lcov \
|
|
||||||
--remap-path-prefix \
|
|
||||||
--workspace \
|
|
||||||
--output-path lcov.info \
|
|
||||||
--profile coverage \
|
|
||||||
--no-fail-fast nextest
|
|
||||||
|
|
||||||
# Display coverage report
|
alias fmt := format
|
||||||
report-coverage: coverage
|
|
||||||
cargo llvm-cov report --remap-path-prefix
|
|
||||||
|
|
||||||
# Open HTML coverage report
|
# Frontend dev server (web::dev)
|
||||||
html: coverage
|
dev:
|
||||||
cargo llvm-cov report \
|
@just web::dev
|
||||||
--remap-path-prefix \
|
|
||||||
--html \
|
|
||||||
--open
|
|
||||||
|
|
||||||
# === Performance & Profiling ===
|
# Build and preview frontend (web::up)
|
||||||
|
up:
|
||||||
# Profile the project using samply
|
@just web::up
|
||||||
samply:
|
|
||||||
cargo build --profile profile
|
|
||||||
samply record ./target/profile/pacman{{ binary_extension }}
|
|
||||||
|
|
||||||
# === Web Build (Emscripten) ===
|
|
||||||
|
|
||||||
# Build and serve the web version
|
|
||||||
web *args:
|
|
||||||
bun run pacman/web.build.ts {{args}}
|
|
||||||
bun run --cwd web build
|
|
||||||
caddy file-server --root web/dist/client --listen :8547
|
|
||||||
|
|
||||||
# Build web version only (no server)
|
|
||||||
build-web *args:
|
|
||||||
bun run pacman/web.build.ts {{args}}
|
|
||||||
bun run --cwd web build
|
|
||||||
|
|
||||||
# === Server (Docker) ===
|
|
||||||
|
|
||||||
# Create a postgres container for the server
|
|
||||||
server-postgres:
|
|
||||||
bun run pacman-server/scripts/postgres.ts
|
|
||||||
|
|
||||||
# Build the server image
|
|
||||||
server-image:
|
|
||||||
docker build \
|
|
||||||
--platform linux/amd64 \
|
|
||||||
--file ./pacman-server/Dockerfile \
|
|
||||||
--tag pacman-server \
|
|
||||||
.
|
|
||||||
|
|
||||||
# Build and run the server in a Docker container
|
|
||||||
run-server: server-image
|
|
||||||
docker rm --force --volumes pacman-server 2>/dev/null || true
|
|
||||||
docker run \
|
|
||||||
--rm \
|
|
||||||
--stop-timeout 2 \
|
|
||||||
--name pacman-server \
|
|
||||||
--publish 3000:3000 \
|
|
||||||
--env PORT=3000 \
|
|
||||||
--env-file pacman-server/.env \
|
|
||||||
pacman-server
|
|
||||||
|
|
||||||
# === Utilities ===
|
|
||||||
|
|
||||||
# Clean build artifacts
|
|
||||||
clean:
|
|
||||||
cargo clean
|
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
set shell := ["bash", "-c"]
|
||||||
|
|
||||||
|
# Create a postgres container for the server
|
||||||
|
postgres:
|
||||||
|
bun run scripts/postgres.ts
|
||||||
|
|
||||||
|
# Build the server docker image
|
||||||
|
[no-cd]
|
||||||
|
image:
|
||||||
|
docker build \
|
||||||
|
--platform linux/amd64 \
|
||||||
|
--file ./pacman-server/Dockerfile \
|
||||||
|
--tag pacman-server \
|
||||||
|
.
|
||||||
|
|
||||||
|
# Build and run the server in a Docker container
|
||||||
|
[no-cd]
|
||||||
|
run: image
|
||||||
|
docker rm --force --volumes pacman-server 2>/dev/null || true
|
||||||
|
docker run \
|
||||||
|
--rm \
|
||||||
|
--stop-timeout 2 \
|
||||||
|
--name pacman-server \
|
||||||
|
--publish 3000:3000 \
|
||||||
|
--env PORT=3000 \
|
||||||
|
--env-file pacman-server/.env \
|
||||||
|
pacman-server
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
set shell := ["bash", "-c"]
|
||||||
|
|
||||||
|
binary_extension := if os() == "windows" { ".exe" } else { "" }
|
||||||
|
|
||||||
|
# Run the game, pass args (e.g., `just pacman::run -r` for release)
|
||||||
|
run *args:
|
||||||
|
cargo run -p pacman {{args}}
|
||||||
|
|
||||||
|
# Run all checks (clippy for desktop + wasm, warns on format)
|
||||||
|
check:
|
||||||
|
@echo "Checking format..."
|
||||||
|
@cargo fmt --all -- --check || echo "⚠ Format issues detected (run \`just format\` to fix)"
|
||||||
|
@echo "Running clippy for desktop target..."
|
||||||
|
@cargo clippy --all-targets --all-features --quiet -- -D warnings
|
||||||
|
@echo "Running clippy for wasm target..."
|
||||||
|
@cargo clippy -p pacman --target wasm32-unknown-emscripten --all-targets --all-features --quiet -- -D warnings
|
||||||
|
@echo "Running frontend checks..."
|
||||||
|
@bun run --cwd web check
|
||||||
|
@bun run --cwd web lint
|
||||||
|
@echo "All checks passed!"
|
||||||
|
|
||||||
|
# Run tests with nextest
|
||||||
|
test:
|
||||||
|
cargo nextest run --no-fail-fast
|
||||||
|
|
||||||
|
# Auto-format code
|
||||||
|
format:
|
||||||
|
cargo fmt --all
|
||||||
|
|
||||||
|
# Fix linting errors & formatting
|
||||||
|
fix:
|
||||||
|
cargo fix --workspace --lib --allow-dirty
|
||||||
|
cargo fmt --all
|
||||||
|
|
||||||
|
# Profile using samply
|
||||||
|
samply:
|
||||||
|
cargo build --profile profile
|
||||||
|
samply record ./target/profile/pacman{{binary_extension}}
|
||||||
|
|
||||||
|
# Generate baseline LCOV report
|
||||||
|
coverage:
|
||||||
|
cargo +nightly llvm-cov \
|
||||||
|
--lcov \
|
||||||
|
--remap-path-prefix \
|
||||||
|
--workspace \
|
||||||
|
--output-path lcov.info \
|
||||||
|
--profile coverage \
|
||||||
|
--no-fail-fast nextest
|
||||||
|
|
||||||
|
# Display coverage report
|
||||||
|
report-coverage: coverage
|
||||||
|
cargo llvm-cov report --remap-path-prefix
|
||||||
|
|
||||||
|
# Open HTML coverage report
|
||||||
|
html: coverage
|
||||||
|
cargo llvm-cov report \
|
||||||
|
--remap-path-prefix \
|
||||||
|
--html \
|
||||||
|
--open
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
set shell := ["bash", "-c"]
|
||||||
|
|
||||||
|
# Run the dev server
|
||||||
|
dev:
|
||||||
|
bun run dev
|
||||||
|
|
||||||
|
# Build and preview the frontend
|
||||||
|
up:
|
||||||
|
bun run build
|
||||||
|
bun run preview
|
||||||
|
|
||||||
|
# Build the web version (game + frontend)
|
||||||
|
[no-cd]
|
||||||
|
build *args:
|
||||||
|
bun run pacman/web.build.ts {{args}}
|
||||||
|
bun run --cwd web build
|
||||||
|
|
||||||
|
# Build and serve with caddy
|
||||||
|
[no-cd]
|
||||||
|
serve *args:
|
||||||
|
bun run pacman/web.build.ts {{args}}
|
||||||
|
bun run --cwd web build
|
||||||
|
caddy file-server --root web/dist/client --listen :8547
|
||||||
Reference in New Issue
Block a user