diff --git a/.github/workflows/release-main.yml b/.github/workflows/release-main.yml index abf421619..dcc2b4d3d 100644 --- a/.github/workflows/release-main.yml +++ b/.github/workflows/release-main.yml @@ -51,6 +51,11 @@ jobs: fetch-depth: 0 persist-credentials: false + - name: Install just + uses: taiki-e/install-action@0d865d5cc6d507df4765f1f866bfae8bab4e2a73 # v2.69.7 + with: + tool: just + - name: Set Up Node.js uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6 with: @@ -59,7 +64,7 @@ jobs: cache-dependency-path: tools/release/package-lock.json - name: Install Release Tooling Dependencies - run: npm --prefix tools/release ci + run: just release install - name: Record Pre-Release HEAD id: pre_release @@ -82,7 +87,7 @@ jobs: GIT_AUTHOR_EMAIL: 41898282+github-actions[bot]@users.noreply.github.com GIT_COMMITTER_NAME: github-actions[bot] GIT_COMMITTER_EMAIL: 41898282+github-actions[bot]@users.noreply.github.com - run: npx --prefix tools/release semantic-release --extends ./tools/release/release.config.cjs + run: just release run - name: Capture Release State id: release_state diff --git a/.github/workflows/release-preview.yml b/.github/workflows/release-preview.yml index eb1f3d8d9..b8c932d28 100644 --- a/.github/workflows/release-preview.yml +++ b/.github/workflows/release-preview.yml @@ -49,6 +49,11 @@ jobs: git checkout -B main "$(git rev-parse HEAD)" + - name: Install just + uses: taiki-e/install-action@0d865d5cc6d507df4765f1f866bfae8bab4e2a73 # v2.69.7 + with: + tool: just + - name: Set Up Node.js uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6 with: @@ -57,16 +62,13 @@ jobs: cache-dependency-path: tools/release/package-lock.json - name: Install Release Tooling Dependencies - run: npm --prefix tools/release ci + run: just release install - name: Run semantic-release Dry Run env: GH_TOKEN: ${{ secrets.RELEASE_BOT_TOKEN != '' && secrets.RELEASE_BOT_TOKEN || github.token }} GITHUB_TOKEN: ${{ secrets.RELEASE_BOT_TOKEN != '' && secrets.RELEASE_BOT_TOKEN || github.token }} - run: | - npx --prefix tools/release semantic-release \ - --dry-run \ - --extends ./tools/release/release.config.cjs | tee semantic-release-preview.log + run: just release preview | tee semantic-release-preview.log - name: Upload Preview Output uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 diff --git a/.github/workflows/test-suite.yml b/.github/workflows/test-suite.yml index 99984528b..a9386f95b 100644 --- a/.github/workflows/test-suite.yml +++ b/.github/workflows/test-suite.yml @@ -29,6 +29,11 @@ jobs: fetch-depth: 0 ref: ${{ inputs.checkout_ref }} + - name: Install just + uses: taiki-e/install-action@0d865d5cc6d507df4765f1f866bfae8bab4e2a73 # v2.69.7 + with: + tool: just + - name: Set Up JDK 25 uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5 with: @@ -38,10 +43,9 @@ jobs: - name: Execute Backend Tests id: backend_tests - working-directory: ./booklore-api run: | echo "Running backend tests..." - ./gradlew test --no-daemon --parallel --build-cache + just api test continue-on-error: true - name: Publish Backend Test Results @@ -82,6 +86,11 @@ jobs: fetch-depth: 0 ref: ${{ inputs.checkout_ref }} + - name: Install just + uses: taiki-e/install-action@0d865d5cc6d507df4765f1f866bfae8bab4e2a73 # v2.69.7 + with: + tool: just + - name: Set Up Node.js uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6 with: @@ -90,23 +99,19 @@ jobs: cache-dependency-path: booklore-ui/package-lock.json - name: Install Frontend Dependencies - working-directory: ./booklore-ui - run: npm ci + run: just ui install-ci - name: Audit Frontend Dependencies - working-directory: ./booklore-ui - run: npm audit --audit-level=critical + run: just ui audit-ci - name: Validate Dependency Tree - working-directory: ./booklore-ui - run: npm ls --depth=0 + run: just ui deps - name: Execute Frontend Tests id: frontend_tests - working-directory: ./booklore-ui run: | echo "Running frontend tests..." - npx ng test + just ui test continue-on-error: true - name: Publish Frontend Test Results diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4dc60e595..3ff3d1232 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -98,12 +98,38 @@ grimmory/ └── local/ # Local development helpers ``` +### Preferred Command Surface + +Use the root [`Justfile`](Justfile) as the primary local command surface. It wraps the commands documented below into a consistent interface for both humans and agents. + +Useful starting points: + +```bash +just # Show all root, api, and ui recipes +just check # Run the local verification pass +just test # Run backend + frontend tests +just api run # Start the backend with the dev profile +just ui dev # Start the frontend dev server +just dev-up # Start the Docker dev stack +just image-build # Build the production image locally +``` + +> **Tip:** Agents and automation should prefer `just` recipes when a suitable recipe exists so local workflows and documented commands stay aligned. +> **Tip:** Set `GRIMMORY_COMPOSE_FILE=/path/to/compose.yml` if you need the root `just` recipes to target a different development compose file. + +### Component Guides + +Use the repo-level guide for workflow, release, and PR policy, then drop into the component-specific guides when you are working inside a project: + +- Backend: [booklore-api/README.md](booklore-api/README.md) and [booklore-api/CONTRIBUTING.md](booklore-api/CONTRIBUTING.md) +- Frontend: [booklore-ui/README.md](booklore-ui/README.md) and [booklore-ui/CONTRIBUTING.md](booklore-ui/CONTRIBUTING.md) + ### Option 1: Docker Development Stack (Recommended) The fastest way to get a working environment. No local toolchain required. ```bash -docker compose -f dev.docker-compose.yml up +just dev-up ``` This starts: @@ -119,12 +145,12 @@ All ports are configurable via environment variables (`FRONTEND_PORT`, `BACKEND_ ```bash # To stop -docker compose -f dev.docker-compose.yml down +just dev-down ``` ### Option 2: Manual Setup -For full control over each component or IDE integration (debugging, hot-reload, etc.). +For full control over each component or IDE integration (debugging, hot-reload, etc.). The detailed component-level commands now live in the API and UI subproject guides linked above. #### Prerequisites @@ -140,13 +166,13 @@ For full control over each component or IDE integration (debugging, hot-reload, Start MariaDB and create the database: ```sql -CREATE DATABASE IF NOT EXISTS booklore; -CREATE USER 'booklore_user'@'localhost' IDENTIFIED BY 'your_password'; -GRANT ALL PRIVILEGES ON booklore.* TO 'booklore_user'@'localhost'; +CREATE DATABASE IF NOT EXISTS grimmory; +CREATE USER 'grimmory_user'@'localhost' IDENTIFIED BY 'your_password'; +GRANT ALL PRIVILEGES ON grimmory.* TO 'grimmory_user'@'localhost'; FLUSH PRIVILEGES; ``` -> **Tip:** You can also spin up MariaDB via Docker: `docker compose -f local/docker-compose-maria.yml up -d` +> **Tip:** You can also start just the database service with `just db-up` #### 2. Backend @@ -160,16 +186,15 @@ app: spring: datasource: driver-class-name: org.mariadb.jdbc.Driver - url: jdbc:mariadb://localhost:3306/booklore?createDatabaseIfNotExist=true - username: booklore_user + url: jdbc:mariadb://localhost:3306/grimmory?createDatabaseIfNotExist=true + username: grimmory_user password: your_password ``` Replace the paths with actual directories on your system and ensure they exist with read/write permissions. ```bash -cd booklore-api -./gradlew bootRun --args='--spring.profiles.active=dev' +just api run # Verify curl http://localhost:8080/actuator/health @@ -178,15 +203,12 @@ curl http://localhost:8080/actuator/health #### 3. Frontend ```bash -cd booklore-ui -npm install -ng serve +just ui install +just ui dev ``` The UI will be available at http://localhost:4200 with hot-reload enabled. -> If you hit dependency issues, try `npm ci --force`. - --- ## Running Tests @@ -196,18 +218,16 @@ Always run tests before submitting a pull request. **Frontend (Vitest):** ```bash -cd booklore-ui -ng test # Run all tests -ng test --coverage # With coverage report (output: coverage/) +just ui test # Run all tests +just ui coverage # With coverage report (output: coverage/) ``` **Backend (JUnit + Gradle):** ```bash -cd booklore-api -./gradlew test # Run all tests -./gradlew test --tests "com.booklore.api.service.BookServiceTest" # Specific class -./gradlew test jacocoTestReport # Coverage report +just api test # Run all tests +just api test-class test_class=org.booklore.service.BookServiceTest # Specific class +just api coverage # Coverage report ``` --- @@ -225,23 +245,13 @@ You need a MariaDB instance accessible to the container. The easiest way is to u ```bash # From the repository root -docker build -t grimmory:local . +just image-build # Start only the database from the dev stack -docker compose -f dev.docker-compose.yml up -d backend_db +just db-up # Run the production image against it, reusing the dev stack's data -docker run --rm -it \ - --name grimmory-local \ - --network host \ - -e "SPRING_DATASOURCE_URL=jdbc:mariadb://localhost:3366/booklore?createDatabaseIfNotExist=true" \ - -e "SPRING_DATASOURCE_USERNAME=booklore" \ - -e "SPRING_DATASOURCE_PASSWORD=booklore" \ - -v ./shared/data:/app/data \ - -v ./shared/books:/books \ - -v ./shared/bookdrop:/bookdrop \ - -p 6060:6060 \ - grimmory:local +just image-run ``` The application will be available at http://localhost:6060. @@ -249,11 +259,11 @@ The application will be available at http://localhost:6060. ### Cleanup ```bash -# Stop and remove the container -docker stop grimmory-local - # Stop the database service when done -docker compose -f dev.docker-compose.yml down +just db-down + +# Or stop the full stack if you started it with `just dev-up` +just dev-down ``` ### Cross-platform build (optional) @@ -261,7 +271,7 @@ docker compose -f dev.docker-compose.yml down If you want to test a different architecture (e.g., ARM64 on an x86 machine): ```bash -docker buildx build --platform linux/arm64 -t grimmory:local-arm64 --load . +just image-build linux/arm64 grimmory:local-arm64 ``` ### Tips @@ -336,9 +346,9 @@ Maintainers promote cleaned `develop` history to `main` for stable releases. Do Before opening your PR: - [ ] PR is linked to an **approved** issue (PRs without a linked issue will be closed) -- [ ] All tests pass (`./gradlew test` and `ng test`) +- [ ] All tests pass (`just test`) - [ ] Actual test output is pasted in the PR description -- [ ] Code follows project conventions (see [Backend Conventions](#backend-conventions), [Frontend Conventions](#frontend-conventions)) +- [ ] Code follows the relevant component conventions (see [booklore-api/CONTRIBUTING.md](booklore-api/CONTRIBUTING.md) and [booklore-ui/CONTRIBUTING.md](booklore-ui/CONTRIBUTING.md)) - [ ] No lint errors - [ ] Branch is up-to-date with `develop` - [ ] You ran the full stack locally and manually verified the change works @@ -368,32 +378,12 @@ We've seen a sharp increase in AI-generated PRs where the contributor clearly ne --- -## Backend Conventions +## Component Conventions -- Use Spring Data JPA repository methods or JPQL. No native queries unless explicitly approved by a maintainer. -- Constructor injection via Lombok `@AllArgsConstructor`. No `@Autowired`. -- Logging via Lombok `@Slf4j`. No manual `LoggerFactory.getLogger(...)`. -- Throw errors via `ApiError` enum (`ApiError.SOME_ERROR.createException()`). No raw `RuntimeException`. -- Entities use `*Entity` suffix; DTOs drop it (e.g., `BookEntity` vs `Book`). -- Use MapStruct for entity-to-DTO mapping. No hand-written mapping code. -- Security: `@PreAuthorize("@securityUtil.isAdmin()")` or `@CheckBookAccess`. No `@Secured` or `@RolesAllowed`. -- Testing: JUnit 5 + Mockito + AssertJ. `@ExtendWith(MockitoExtension.class)` for unit tests, `@SpringBootTest` only for integration tests. -- Use modern Java features (records, sealed classes, pattern matching, text blocks, etc.). -- No fully qualified class names inline. Always use imports. -- Flyway migrations go in `booklore-api/src/main/resources/db/migration/` with naming `V__.sql`. -- Never modify a released migration. Always create a new migration file for changes. -- Use idempotent guards in migrations (`CREATE TABLE IF NOT EXISTS`, `ADD COLUMN IF NOT EXISTS`, `DROP ... IF EXISTS` before re-creating). +Detailed coding conventions now live with each project: ---- - -## Frontend Conventions - -- Follow the [Angular style guide](https://angular.dev/style-guide). -- All components are standalone. No NgModules. -- Use `inject()` for dependency injection. No constructor injection. -- PrimeNG for UI components. SCSS for styling. Transloco for i18n. -- Testing with Vitest (not Karma/Jasmine). -- All UI features must be responsive (desktop + mobile). +- Backend rules: [booklore-api/CONTRIBUTING.md](booklore-api/CONTRIBUTING.md) +- Frontend rules: [booklore-ui/CONTRIBUTING.md](booklore-ui/CONTRIBUTING.md) --- diff --git a/Justfile b/Justfile new file mode 100644 index 000000000..c46914aa1 --- /dev/null +++ b/Justfile @@ -0,0 +1,92 @@ +set shell := ["bash", "-eu", "-o", "pipefail", "-c"] + +mod api 'booklore-api/Justfile' +mod ui 'booklore-ui/Justfile' +mod release 'tools/release/Justfile' + +compose_file := env_var_or_default('GRIMMORY_COMPOSE_FILE', 'dev.docker-compose.yml') +compose_cmd := 'docker compose -f ' + compose_file +db_service := 'backend_db' +local_image_tag := env_var_or_default('GRIMMORY_IMAGE_TAG', 'grimmory:local') +local_container_name := 'grimmory-local' +local_db_url := 'jdbc:mariadb://localhost:3366/grimmory?createDatabaseIfNotExist=true' +local_db_user := 'grimmory' +local_db_password := 'grimmory' + +# Show the primary developer and agent command surface, including submodule recipes. +help: + @just --list --list-submodules + +# List recipes in a specific module, for example `just list api` or `just list ui`. +list module='': + @if [[ -n "{{ module }}" ]]; then \ + just --list "{{ module }}"; \ + else \ + just --list --list-submodules; \ + fi + +# Install the common local prerequisites used by the UI and API workflows. +bootstrap: ui::install api::version + +# Run the full local verification pass used before opening a PR. +check: api::check ui::check + +# Run the frontend and backend test suites. +test: api::test ui::test + +# Build both application components without publishing a container image. +build: api::build ui::build + +# Start the Docker-based development stack in the foreground. +dev-up: + {{ compose_cmd }} up + +# Start the Docker-based development stack in the background. +dev-up-detached: + {{ compose_cmd }} up -d + +# Start only the development database service from the compose stack. +db-up: + {{ compose_cmd }} up -d {{ db_service }} + +# Stop only the development database service from the compose stack. +db-down: + {{ compose_cmd }} stop {{ db_service }} + +# Stop the Docker-based development stack. +dev-down: + {{ compose_cmd }} down + +# Tail logs from the full dev stack or a single service with `just dev-logs backend`. +dev-logs service='': + @if [[ -n "{{ service }}" ]]; then \ + {{ compose_cmd }} logs -f "{{ service }}"; \ + else \ + {{ compose_cmd }} logs -f; \ + fi + +# Build the production image locally with buildx. Usage: `just image-build [platform] [tag]`. +image-build platform='linux/amd64' tag=local_image_tag: + docker buildx build --platform "{{ platform }}" -t "{{ tag }}" --load . + +# Run the locally built production image against the expected development defaults. +image-run tag=local_image_tag db_url=local_db_url db_user=local_db_user db_password=local_db_password: + docker run --rm -it \ + --name "{{ local_container_name }}" \ + --network host \ + -e "SPRING_DATASOURCE_URL={{ db_url }}" \ + -e "SPRING_DATASOURCE_USERNAME={{ db_user }}" \ + -e "SPRING_DATASOURCE_PASSWORD={{ db_password }}" \ + -v ./shared/data:/app/data \ + -v ./shared/books:/books \ + -v ./shared/bookdrop:/bookdrop \ + -p 6060:6060 \ + "{{ tag }}" + +# Show the resolved tool versions that the local commands expect to find. +doctor: + @echo "just: $$(just --version)" + @echo "java: $$(java -version 2>&1 | head -n 1)" + @echo "node: $$(node --version)" + @echo "npm: $$(npm --version)" + @echo "docker: $$(docker --version)" diff --git a/README.md b/README.md index db6845f20..5e0a7fdd5 100644 --- a/README.md +++ b/README.md @@ -171,6 +171,29 @@ Additional deployment examples: --- +## Developer Surfaces + +This repository contains two application projects: + +- Backend: [`booklore-api/README.md`](booklore-api/README.md) +- Frontend: [`booklore-ui/README.md`](booklore-ui/README.md) + +Contributor workflow, PR policy, and release semantics live in [CONTRIBUTING.md](CONTRIBUTING.md). Component-specific implementation guidance lives in: + +- [`booklore-api/CONTRIBUTING.md`](booklore-api/CONTRIBUTING.md) +- [`booklore-ui/CONTRIBUTING.md`](booklore-ui/CONTRIBUTING.md) + +The root [`Justfile`](Justfile) is the primary local command surface and mirrors the folder-local `booklore-api/Justfile` and `booklore-ui/Justfile` entrypoints. + +```bash +just # Show root + api + ui recipes +just test # Run backend and frontend tests +just api test # Run backend tests only +just ui dev # Start the frontend dev server +``` + +--- + ## BookDrop Drop book files into a watched folder. Grimmory picks them up, pulls metadata, and queues them for your review. diff --git a/booklore-api/CONTRIBUTING.md b/booklore-api/CONTRIBUTING.md new file mode 100644 index 000000000..c49567ab7 --- /dev/null +++ b/booklore-api/CONTRIBUTING.md @@ -0,0 +1,62 @@ +# Contributing to Grimmory API + +This document covers backend-specific development and review expectations for `booklore-api`. + +For repository-wide contribution policy, branch strategy, PR requirements, and release semantics, start with [../CONTRIBUTING.md](../CONTRIBUTING.md). + +## Preferred Command Surface + +Use [`Justfile`](Justfile) when possible: + +```bash +just # List backend recipes +just run # Start the backend with the dev profile +just test # Run backend tests +just coverage # Generate JaCoCo coverage output +just check # Run the Gradle check lifecycle +``` + +From the repository root, the same recipes are available through the `api` namespace: + +```bash +just api test +just api run +just api check +``` + +## Backend Conventions + +- Use Spring Data JPA repository methods or JPQL. Do not introduce native queries unless a maintainer has explicitly approved them. +- Prefer constructor injection via Lombok `@AllArgsConstructor`. Do not add `@Autowired`. +- Use Lombok `@Slf4j` for logging. Do not instantiate loggers manually. +- Throw API-facing errors via `ApiError` helpers instead of raw `RuntimeException`. +- Entities use the `*Entity` suffix. DTOs and API models do not. +- Use MapStruct for entity-to-DTO mapping instead of hand-written mapping code. +- Security checks should use the existing project patterns such as `@PreAuthorize("@securityUtil.isAdmin()")` or `@CheckBookAccess`. +- Use modern Java language features where they clarify the code. +- Keep imports explicit. Do not inline fully-qualified class names. + +## Migrations + +- Flyway migrations live in `src/main/resources/db/migration/`. +- Name migrations `V__.sql`. +- Never modify a released migration. Add a new migration instead. +- Prefer idempotent guards such as `IF EXISTS` and `IF NOT EXISTS` when the SQL dialect allows them. + +## Testing + +- Unit tests should normally use JUnit 5 + Mockito + AssertJ. +- Use `@ExtendWith(MockitoExtension.class)` for unit tests. +- Use `@SpringBootTest` only when you need a real Spring integration context. +- Keep tests behavior-oriented. Avoid shallow tests that only exercise getters, setters, or mocks without asserting meaningful outcomes. + +## Validation Before Opening a PR + +Run the backend checks locally before sending a PR: + +```bash +just test +just check +``` + +If your change affects migrations, persistence, or API behavior, also run the full stack locally and verify the behavior manually. diff --git a/booklore-api/Justfile b/booklore-api/Justfile new file mode 100644 index 000000000..302eb6493 --- /dev/null +++ b/booklore-api/Justfile @@ -0,0 +1,43 @@ +set shell := ["bash", "-eu", "-o", "pipefail", "-c"] + +gradle := "./gradlew" + +# Show the backend recipes available in this directory. +help: + @just --list + +# Print the backend Gradle and JVM versions. +version: + {{ gradle }} --version + +# Run the backend locally with the requested Spring profile. Default: `dev`. +run profile='dev': + {{ gradle }} bootRun --args="--spring.profiles.active={{ profile }}" + +# Build the backend jar and run the standard Gradle build lifecycle. +build: + {{ gradle }} build --no-daemon --parallel --build-cache + +# Run the backend test suite. +test: + {{ gradle }} test --no-daemon --parallel --build-cache + +# Run a single backend test class, for example `just test-class test_class=org.booklore.service.BookServiceTest`. +test-class test_class: + {{ gradle }} test --tests "{{ test_class }}" --no-daemon --parallel --build-cache + +# Run tests and generate JaCoCo coverage output. +coverage: + {{ gradle }} test jacocoTestReport --no-daemon --parallel --build-cache + +# Run the Gradle `check` lifecycle used for local backend verification. +check: + {{ gradle }} check --no-daemon --parallel --build-cache + +# Remove backend build outputs. +clean: + {{ gradle }} clean --no-daemon + +# List the available backend Gradle tasks. +tasks: + {{ gradle }} tasks --all --no-daemon diff --git a/booklore-api/README.md b/booklore-api/README.md new file mode 100644 index 000000000..cc88ff45f --- /dev/null +++ b/booklore-api/README.md @@ -0,0 +1,69 @@ +# Grimmory API + +The `booklore-api` project is the Spring Boot backend for Grimmory. It owns the HTTP API, database migrations, background processing, authentication, and the packaged runtime jar that the production container runs. + +## Stack + +- Java 25 +- Spring Boot 4 +- Gradle Wrapper +- Spring Data JPA + Flyway +- MariaDB in production, H2 for selected tests +- JUnit 5, Mockito, AssertJ, JaCoCo + +## Local Command Surface + +Use [`Justfile`](Justfile) when possible. It is the primary backend command surface for both humans and agents. + +```bash +just # List backend recipes +just run # Start bootRun with the dev profile +just test # Run the backend test suite +just coverage # Run tests and generate JaCoCo output +just check # Run the Gradle check lifecycle +just tasks # Show available Gradle tasks +``` + +The repository root also exposes the same recipes through namespacing: + +```bash +just api test +just api run +just api coverage +``` + +## Running Locally + +The backend expects a MariaDB instance and a local `application-dev.yml` with your database and storage paths. The higher-level setup lives in [../CONTRIBUTING.md](../CONTRIBUTING.md), but the common backend loop is: + +```bash +cd booklore-api +just run +``` + +If you need a different Spring profile: + +```bash +just run profile=local +``` + +## Build and Test + +```bash +just build +just test +just coverage +just check +``` + +The frontend bundle is consumed during packaging when the UI build output exists. For normal backend-only development and test runs, the frontend resources are optional. + +## Packaging Notes + +- The production container image is built from the repository root `Dockerfile`. +- That Docker build compiles the UI first and passes the resolved frontend dist path into the backend build. +- The backend jar remains the packaged application artifact for the current all-in-one runtime model. + +## More Detail + +Backend-specific contributor rules and conventions live in [CONTRIBUTING.md](CONTRIBUTING.md). diff --git a/booklore-ui/CONTRIBUTING.md b/booklore-ui/CONTRIBUTING.md new file mode 100644 index 000000000..be2e747f9 --- /dev/null +++ b/booklore-ui/CONTRIBUTING.md @@ -0,0 +1,66 @@ +# Contributing to Grimmory UI + +This document covers frontend-specific development and review expectations for `booklore-ui`. + +For repository-wide contribution policy, branch strategy, PR requirements, and release semantics, start with [../CONTRIBUTING.md](../CONTRIBUTING.md). + +## Preferred Command Surface + +Use [`Justfile`](Justfile) when possible: + +```bash +just # List frontend recipes +just install # Install or update dependencies for local development +just install-ci # Install dependencies exactly as CI does +just dev # Start the local dev server +just test # Run frontend tests +just check # Run the standard local verification pass +just lint # Run the frontend linter +just build # Build the production bundle +``` + +From the repository root, the same recipes are available through the `ui` namespace: + +```bash +just ui install +just ui install-ci +just ui dev +just ui test +just ui check +just ui lint +``` + +## Frontend Conventions + +- Follow the Angular style guide. +- All components are standalone. Do not add NgModules. +- Use `inject()` for dependency injection instead of constructor injection. +- Prefer PrimeNG components and project styling patterns over custom one-off UI primitives. +- Use SCSS for styling and keep the visual language consistent with the existing application. +- Use Transloco for user-facing strings. New strings belong under `src/i18n/`. +- Keep UI changes responsive for desktop and mobile layouts. +- Tests should use Vitest, not Karma or Jasmine. + +## i18n and UI Copy + +- Update all relevant locale files when adding or renaming translation keys. +- Keep translation-key changes separate from bulk JSON reformatting whenever practical. +- Prefer Grimmory naming for UI-visible labels and keys, while preserving compatibility shims only when they are still required by existing backend or migration behavior. + +## Validation Before Opening a PR + +Run the frontend checks locally before sending a PR: + +```bash +just install +just check +``` + +If your change affects layout, responsive behavior, or interaction design, also run the full stack locally and capture screenshots or a short screen recording for the PR. + +If you specifically want to mirror the stricter CI dependency policy, run: + +```bash +just install-ci +just ci-check +``` diff --git a/booklore-ui/Justfile b/booklore-ui/Justfile new file mode 100644 index 000000000..b3fb43e30 --- /dev/null +++ b/booklore-ui/Justfile @@ -0,0 +1,61 @@ +set shell := ["bash", "-eu", "-o", "pipefail", "-c"] + +npm := "npm" + +# Show the frontend recipes available in this directory. +help: + @just --list + +# Install or update frontend dependencies for local development. +install: + {{ npm }} install + +# Install the frontend dependencies exactly as CI does. +install-ci: + {{ npm }} ci + +# Run the Angular development server. +dev: + {{ npm }} run dev + +# Run the Angular development server with the default `start` script. +start: + {{ npm }} start + +# Build the production frontend bundle. +build: + {{ npm }} run build + +# Build the frontend continuously in development mode. +watch: + {{ npm }} run watch + +# Run the frontend test suite. +test: + {{ npm }} test + +# Run the frontend tests with a coverage report. +coverage: + npx ng test --coverage + +# Run the frontend linter. +lint: + {{ npm }} run lint + +# Check the installed dependency tree. +deps: + {{ npm }} ls --depth=0 + +# Run a local dependency audit without forcing a CI-specific severity threshold. +audit: + {{ npm }} audit + +# Run the stricter dependency audit used in CI. +audit-ci: + {{ npm }} audit --audit-level=critical + +# Run the standard local frontend verification pass. +check: deps lint test + +# Run the frontend CI-style verification sequence from a clean install. +ci-check: install-ci audit-ci deps lint test diff --git a/booklore-ui/README.md b/booklore-ui/README.md index e7cfe5f1e..743343f35 100644 --- a/booklore-ui/README.md +++ b/booklore-ui/README.md @@ -1,59 +1,74 @@ -# Grimmory +# Grimmory UI -This project was generated using [Angular CLI](https://github.com/angular/angular-cli) version 19.0.2. +The `booklore-ui` project is the Angular frontend for Grimmory. It owns the browser application, component styling, client-side routing, stateful UI interactions, and the compiled bundle that is packaged into the current production image. -## Development server +## Stack -To start a local development server, run: +- Angular 21 +- TypeScript +- PrimeNG + PrimeIcons +- Transloco for i18n +- Vitest for unit tests +- Angular ESLint + +## Local Command Surface + +Use [`Justfile`](Justfile) when possible. It is the primary frontend command surface for both humans and agents. ```bash -ng serve +just # List frontend recipes +just install # Install or update dependencies for local development +just install-ci # Install dependencies exactly as CI does +just dev # Start the Angular dev server +just test # Run the frontend test suite +just check # Run the standard local verification pass +just lint # Run the frontend linter +just build # Build the production bundle ``` -Once the server is running, open your browser and navigate to `http://localhost:4200/`. The application will automatically reload whenever you modify any of the source files. - -## Code scaffolding - -Angular CLI includes powerful code scaffolding tools. To generate a new component, run: +The repository root exposes the same recipes through the `ui` namespace: ```bash -ng generate component component-name +just ui install +just ui install-ci +just ui dev +just ui test +just ui check +just ui lint ``` -For a complete list of available schematics (such as `components`, `directives`, or `pipes`), run: +## Running Locally ```bash -ng generate --help +cd booklore-ui +just install +just dev ``` -## Building +The development server runs on port `4200` by default. -To build the project run: +## Build and Test ```bash -ng build +just build +just check +just test +just coverage +just lint ``` -This will compile your project and store the build artifacts in the `dist/` directory. By default, the production build optimizes your application for performance and speed. +The production output is written to `dist/grimmory/` and is consumed by the backend packaging flow when building the all-in-one production image. -## Running unit tests +Use `just ci-check` when you want the stricter CI-style flow from a clean install, including the severity-gated audit step. -To execute unit tests with the [Karma](https://karma-runner.github.io) test runner, use the following command: +## UI-Specific Notes -```bash -ng test -``` +- This project uses standalone Angular components. +- Dependency injection should use `inject()`. +- Styling uses SCSS. +- UI strings live in `src/i18n/`. +- The current production bundle is still packaged into the backend jar during the root Docker build. -## Running end-to-end tests +## More Detail -For end-to-end (e2e) testing, run: - -```bash -ng e2e -``` - -Angular CLI does not come with an end-to-end testing framework by default. You can choose one that suits your needs. - -## Additional Resources - -For more information on using the Angular CLI, including detailed command references, visit the [Angular CLI Overview and Command Reference](https://angular.dev/tools/cli) page. +Frontend-specific contributor rules and conventions live in [CONTRIBUTING.md](CONTRIBUTING.md). diff --git a/dev.docker-compose.yml b/dev.docker-compose.yml index 911bc9ef0..57754c41a 100644 --- a/dev.docker-compose.yml +++ b/dev.docker-compose.yml @@ -12,9 +12,9 @@ services: - "${BACKEND_PORT:-6060}:6060" - "127.0.0.1:${REMOTE_DEBUG_PORT:-5005}:5005" environment: - - DATABASE_URL=jdbc:mariadb://backend_db:3306/booklore - - DATABASE_USERNAME=booklore - - DATABASE_PASSWORD=booklore + - DATABASE_URL=jdbc:mariadb://backend_db:3306/grimmory + - DATABASE_USERNAME=grimmory + - DATABASE_PASSWORD=grimmory - REMOTE_DEBUG_ENABLED=true - ALLOWED_ORIGINS=http://localhost:4200 stdin_open: true @@ -37,14 +37,14 @@ services: - backend_db:/var/lib/mysql restart: unless-stopped environment: - - MYSQL_ROOT_PASSWORD=booklore - - MYSQL_DATABASE=booklore - - MYSQL_USER=booklore - - MYSQL_PASSWORD=booklore + - MYSQL_ROOT_PASSWORD=grimmory + - MYSQL_DATABASE=grimmory + - MYSQL_USER=grimmory + - MYSQL_PASSWORD=grimmory ports: - "${DB_PORT:-3366}:3306" healthcheck: - test: [ "CMD", "mariadb-admin", "ping", "-h", "localhost", "-uroot", "-pbooklore" ] + test: [ "CMD", "mariadb-admin", "ping", "-h", "localhost", "-uroot", "-pgrimmory" ] interval: 10s timeout: 5s retries: 5 diff --git a/mise.toml b/mise.toml new file mode 100644 index 000000000..14b4cd4dc --- /dev/null +++ b/mise.toml @@ -0,0 +1,14 @@ +min_version = "2024.9.5" + +[tools] +java = "temurin-25" +node = "24" + +[settings] +experimental = true + +[hooks] +postinstall = "npx corepack enable" + +[env] +_.path = ["{{config_root}}/node_modules/.bin"] diff --git a/tools/release/Justfile b/tools/release/Justfile new file mode 100644 index 000000000..144959441 --- /dev/null +++ b/tools/release/Justfile @@ -0,0 +1,17 @@ +set shell := ["bash", "-eu", "-o", "pipefail", "-c"] + +# Show the release-tooling recipes available in this directory. +help: + @just --list + +# Install the pinned semantic-release tooling used by local and CI release tasks. +install: + npm ci + +# Preview the next semantic-release result for the current checkout. +preview: + npx semantic-release --dry-run --extends ./release.config.cjs + +# Run semantic-release for the current checkout. +run: + npx semantic-release --extends ./release.config.cjs