Files
apf_portal/docs/setup/03-angular-nx-monorepo.md
T
Julien Gautier 79eee77594 chore: initialize repository with project rules, docs, and phase-1 ADRs
Set up the foundation for the adastra-portal project:

- CLAUDE.md captures durable project rules (quality bar, security/perf/a11y
  as first-class, language, commit conventions, ADR proactivity).
- docs/ and decisions/ scaffolding with maintained indexes (docs/README.md
  and decisions/README.md), MADR 4.0.0 template, and tag vocabulary.
- Phase-1 ADRs (0001-0006) lock structural choices: ADR usage, Nx monorepo
  with the apps preset, naming convention (adastra-portal / portal-shell /
  portal-bff), Angular CSR/zoneless/Signals/Vitest, NestJS over Express,
  PostgreSQL with Prisma.
- docs/setup/ guides translated to English.
- .gitignore covers Node/Nx artifacts and the personal notes/ scratchpad.

The Nx workspace itself is not yet bootstrapped; that step is gated on a
revised setup guide aligned with the ADRs.
2026-04-29 20:43:00 +02:00

117 lines
1.7 KiB
Markdown

# 🏗️ Angular monorepo with Nx + pnpm
> ⚠️ This guide is **pending revision**: the placeholder workspace name (`my-workspace`) and app name (`web`) must be replaced with project-specific values, and the procedure must be extended to cover the Node API / BFF side. Treat the steps below as a baseline only.
## Goal
Create a scalable and maintainable architecture.
---
## 1) Workspace creation
```bash
cd ~/dev
pnpm dlx create-nx-workspace@latest my-workspace \
--preset=angular-monorepo \
--pm=pnpm \
--appName=web \
--style=scss \
--routing=true \
--unitTestRunner=vitest
```
---
## 2) Recommended layout
```text
apps/
web/
libs/
shared/ui/
shared/data-access/
shared/util/
feature/auth/
```
---
## 3) Generate libraries
```bash
pnpm nx g @nx/angular:library shared-ui
pnpm nx g @nx/angular:library feature-auth
```
---
## 4) Main commands
```bash
pnpm nx serve web
pnpm nx build web
pnpm nx test web
pnpm nx lint web
```
---
## 5) Workspace-wide commands
```bash
pnpm nx run-many -t lint test build
pnpm nx affected -t lint test build
```
---
## 6) Prettier
`.prettierrc`:
```json
{
"singleQuote": true,
"semi": true,
"printWidth": 100
}
```
---
## 7) Git hooks
```bash
pnpm add -D husky lint-staged
pnpm exec husky init
```
---
## 8) CI/CD
> ⚠️ The original procedure targeted GitLab CI. The project repository now lives on Gitea, so this section needs to be rewritten for Gitea Actions (or the chosen CI runner). Tracked under the next round of CI ADRs.
---
## 9) Daily workflow
```bash
pnpm install
pnpm start
pnpm nx g component login
pnpm nx affected -t lint test build
```
---
## Result
* Scalable monorepo
* Optimized builds
* Fast CI
* Clear architecture