diff --git a/backend/justfile b/backend/justfile new file mode 100644 index 0000000..34059ed --- /dev/null +++ b/backend/justfile @@ -0,0 +1,50 @@ +# Backend development commands for Captain's Log + +export DATABASE_URL :="sqlite://local.db" + +dev-backend: + cargo run + +build-backend: + cargo build + +test-unit-backend: + cargo test + +fmt-backend: + cargo fmt --check + +lint-backend: + cargo clippy + +clean-backend: + cargo clean + +reset-db: + sqlx database drop + sqlx database create + sqlx migrate run + +migrate: + sqlx migrate run + +migrate-revert: + sqlx migrate revert + +test-integration: + #!/usr/bin/env bash + set -e + + cargo run & + SERVER_PID=$! + + trap 'echo "Stopping server..."; kill -TERM $SERVER_PID 2>/dev/null || true; wait $SERVER_PID 2>/dev/null || true' EXIT + + echo "Waiting for server to start..." + printf 'GET http://localhost:3000/health\nHTTP 200' | hurl --retry 30 > /dev/null + + echo "Running integration tests..." + hurl --test --error-format long --variable host=http://localhost:3000 tests/api/*.hurl + +test-coverage: + cargo tarpaulin --out Html --output-dir coverage \ No newline at end of file diff --git a/frontend/justfile b/frontend/justfile index b5be427..ccfa102 100644 --- a/frontend/justfile +++ b/frontend/justfile @@ -1,9 +1,5 @@ # Frontend development commands for Captain's Log -set working-directory := '.' -# Show available commands -default: - @just --list # Start development server with backend API proxy dev-frontend: diff --git a/justfile b/justfile index 3b93fe6..3e69c57 100644 --- a/justfile +++ b/justfile @@ -1,53 +1,27 @@ -# Temporary until we have a frontend. -set working-directory := 'backend' - -export DATABASE_URL :="sqlite://local.db" +# Root justfile for Captain's Log - coordinates both backend and frontend +import 'backend/justfile' +import 'frontend/justfile' +# Combined commands - run both backend and frontend dev: - cargo run - -build: - cargo build - -test-unit: - cargo test - -fmt: - cargo fmt --check - -lint: - cargo clippy - -clean: - cargo clean - - -reset-db: - sqlx database drop - sqlx database create - sqlx migrate run - -migrate: - sqlx migrate run - -migrate-revert: - sqlx migrate revert - -test-integration: #!/usr/bin/env bash set -e + echo "Starting backend and frontend servers..." + (cd backend/ && just dev-backend) & + BACKEND_PID=$! + (cd frontend/ && just dev-frontend) & + FRONTEND_PID=$! - cargo run & - SERVER_PID=$! - - trap 'echo "Stopping server..."; kill -TERM $SERVER_PID 2>/dev/null || true; wait $SERVER_PID 2>/dev/null || true' EXIT - - echo "Waiting for server to start..." - printf 'GET http://localhost:3000/health\nHTTP 200' | hurl --retry 30 > /dev/null - - echo "Running integration tests..." - hurl --test --error-format long --variable host=http://localhost:3000 tests/api/*.hurl + trap 'echo "Stopping servers..."; kill -TERM $BACKEND_PID $FRONTEND_PID 2>/dev/null || true; wait' EXIT + wait -test-coverage: - cargo tarpaulin --out Html --output-dir coverage +build: build-backend build-frontend + +test: test-unit-backend test-integration test-frontend + +fmt: fmt-backend fmt-frontend + +lint: lint-backend lint-frontend + +clean: clean-backend clean-frontend diff --git a/plan/01_CORE_MVP/frontend.md b/plan/01_CORE_MVP/frontend.md index 98df56c..93f956c 100644 --- a/plan/01_CORE_MVP/frontend.md +++ b/plan/01_CORE_MVP/frontend.md @@ -65,7 +65,7 @@ captains-log/ - **Expected outcome**: `just --list` in frontend directory shows all commands ### Task 1.4: Update Root Justfile Structure -- [ ] **Files**: `justfile`, `backend/justfile` +- [x] **Files**: `justfile`, `backend/justfile` - Move existing backend commands to `backend/justfile` - Create new root justfile with combined commands - Add concurrent execution for `dev` command (both backend + frontend)