chore: commit oxfmt formatting changes and verify artifacts

This commit is contained in:
2026-07-02 15:55:09 +08:00
parent 34726cc46d
commit 4f4cee157a
77 changed files with 5576 additions and 1400 deletions

View File

@@ -0,0 +1,45 @@
## ADDED Requirements
### Requirement: Monorepo directory structure
The project SHALL adopt the Turborepo-recommended directory structure with `apps/` for applications and `packages/` for shared libraries.
#### Scenario: Directory layout exists
- **WHEN** a developer clones the repository
- **THEN** the root directory contains `apps/server/`, `apps/admin/`, and `packages/typescript-config/` as npm workspace packages
#### Scenario: Legacy paths removed
- **WHEN** the migration is complete
- **THEN** top-level `backend/` (moved to `apps/server/`) and `frontend/` (moved to `apps/admin/`) directories no longer exist
### Requirement: npm workspaces configuration
The root `package.json` SHALL declare `workspaces` field listing all app and package directories, enabling unified dependency management via npm.
#### Scenario: Install from root
- **WHEN** `npm install` is run at the project root
- **THEN** dependencies for all workspaces are installed and hoisted to root `node_modules/`
#### Scenario: Workspace-scoped scripts
- **WHEN** `npm run test --workspace=apps/server` is executed
- **THEN** only the backend test suite runs
### Requirement: Shared TypeScript configuration
The project SHALL provide shared TypeScript configuration presets via `packages/typescript-config/`, including `base.json`, `nestjs.json`, and `react-vite.json`.
#### Scenario: Server inherits NestJS preset
- **WHEN** `apps/server/tsconfig.json` is read
- **THEN** it extends `@gongxue/typescript-config/nestjs.json`
#### Scenario: Admin inherits React preset
- **WHEN** `apps/admin/tsconfig.json` is read
- **THEN** it extends `@gongxue/typescript-config/react-vite.json`
### Requirement: Docker Compose path compatibility
The `docker-compose.yml` SHALL reference build contexts using the new `apps/` paths, and all services MUST build and start successfully.
#### Scenario: Docker compose build succeeds
- **WHEN** `docker compose build` is executed
- **THEN** server and admin images build without errors
#### Scenario: Docker compose up succeeds
- **WHEN** `docker compose up` is executed
- **THEN** all services (MySQL, server, admin) start and respond to requests

View File

@@ -0,0 +1,45 @@
## ADDED Requirements
### Requirement: oxfmt replaces Prettier
The project SHALL use oxfmt for all code formatting, with a root `.oxfmtrc.json` configuration that replicates the existing Prettier conventions.
#### Scenario: Format check passes
- **WHEN** `npm run format` is executed at root
- **THEN** all TypeScript/JavaScript/JSON source files are formatted according to `.oxfmtrc.json` rules
#### Scenario: CI format gate
- **WHEN** `npm run format -- --check` is executed in CI
- **THEN** it exits with non-zero code if any file is not formatted correctly
### Requirement: Frontend oxlint replaces ESLint
The admin application (`apps/admin/`) SHALL use oxlint for linting, with a configuration that covers TypeScript and React rules equivalent to the existing ESLint setup.
#### Scenario: Admin lint passes
- **WHEN** `npm run lint` is executed at root
- **THEN** admin source files are linted with oxlint and pass without errors
#### Scenario: Rules-of-hooks violations detected
- **WHEN** a React hook is called conditionally in admin source
- **THEN** oxlint reports a rules-of-hooks violation
### Requirement: Backend retains ESLint
The server application (`apps/server/`) SHALL retain its existing ESLint configuration due to NestJS-specific rules that oxlint does not support.
#### Scenario: Server lint passes
- **WHEN** `npm run lint` is executed at root
- **THEN** server source files are linted with ESLint and pass without errors
#### Scenario: NestJS decorator checks work
- **WHEN** ESLint runs on server source
- **THEN** `@typescript-eslint/no-unsafe-*` rules and NestJS-specific patterns are enforced
### Requirement: Pre-existing Prettier/ESLint cleanup
All Prettier configuration files (`.prettierrc`, `eslint-plugin-prettier` references) SHALL be removed, and ESLint configurations SHALL be updated to remove Prettier integration.
#### Scenario: No Prettier remnants
- **WHEN** the migration is complete
- **THEN** `grep -r "prettier"` across config files returns no results (excluding oxfmt config which is separate)
#### Scenario: No Prettier dependencies
- **WHEN** `npm ls prettier eslint-plugin-prettier eslint-config-prettier` is run
- **THEN** no Prettier-related packages are installed in any workspace

View File

@@ -0,0 +1,38 @@
## ADDED Requirements
### Requirement: Turbo pipeline configuration
The project SHALL define a `turbo.json` at the repository root that configures build, dev, lint, test, format, and typecheck pipelines with appropriate caching and dependency ordering.
#### Scenario: Build pipeline with caching
- **WHEN** `turbo run build` is executed twice without source changes
- **THEN** the second run uses cached outputs and completes with "FULL TURBO" status
#### Scenario: Topological build ordering
- **WHEN** `turbo run build` is executed
- **THEN** packages (shared configs, types) build before apps that depend on them
#### Scenario: Parallel execution
- **WHEN** `turbo run lint` is executed
- **THEN** server and admin linting run in parallel where dependency graph allows
### Requirement: Unified root scripts
The root `package.json` SHALL provide top-level scripts (`dev`, `build`, `lint`, `format`, `test`, `typecheck`) that delegate to Turborepo or workspace-level commands.
#### Scenario: Dev mode starts all apps
- **WHEN** `npm run dev` is executed at root
- **THEN** both server (NestJS on port 3003) and admin (Vite on port 3002) start in dev mode
#### Scenario: Build produces all outputs
- **WHEN** `npm run build` is executed at root
- **THEN** server `dist/` and admin `dist/` are produced
### Requirement: Independent workspace scripts
Each workspace SHALL retain the ability to run its own scripts independently (e.g., `npm run test` inside `apps/server/`).
#### Scenario: Server tests run independently
- **WHEN** `npm run test` is executed inside `apps/server/`
- **THEN** the NestJS Jest test suite runs and reports results
#### Scenario: Admin dev runs independently
- **WHEN** `npm run dev` is executed inside `apps/admin/`
- **THEN** the Vite dev server starts on port 3002 with API proxy configured