api-contracts: add type generation to pre-commit hook

- Install husky as dev dependency
- Create pre-commit hook to run type generation script
- Ensures types are always up-to-date with backend API before commit
- Hook runs from apps/web directory to execute generate-types.sh
This commit is contained in:
senke 2026-01-15 17:00:30 +01:00
parent 64f62635a5
commit b8cad69e3a
3 changed files with 12 additions and 5 deletions

5
.husky/pre-commit Executable file
View file

@ -0,0 +1,5 @@
#!/usr/bin/env sh
# Generate TypeScript types from OpenAPI spec before commit
# This ensures types are always up-to-date with the backend API
cd apps/web && bash scripts/generate-types.sh

View file

@ -136,12 +136,12 @@ Critical path dependencies:
- **Validation**: ✅ Added cache step keyed on openapi.yaml hash in CI workflow
- **Rollback**: Remove cache
- [ ] **Action 1.1.2.5**: Add type generation to pre-commit (optional)
- [x] **Action 1.1.2.5**: Add type generation to pre-commit (optional)
- **Scope**: `.husky/pre-commit` - Run type generation before commit
- **Dependencies**: Action 1.1.2.2 complete
- **Dependencies**: Action 1.1.2.2 complete
- **Risk**: LOW 🔒
- **Validation**: Types generated before commit
- **Rollback**: Remove from pre-commit
- **Validation**: ✅ Hook created, runs type generation script before commit. Installed husky as dev dependency.
- **Rollback**: Remove from pre-commit, uninstall husky
#### Task 1.1.3: Replace Manual Types with Generated Types
- [x] **Action 1.1.3.1**: Generate initial types

View file

@ -32,7 +32,8 @@
"qa:backstop:test": "make backstop-test",
"qa:loki": "make loki",
"qa:a11y": "make a11y",
"qa:all": "make qa-all"
"qa:all": "make qa-all",
"prepare": "husky"
},
"dependencies": {
"@dnd-kit/core": "^6.3.1",
@ -92,6 +93,7 @@
"eslint-plugin-react": "^7.37.0",
"eslint-plugin-react-hooks": "^5.0.0",
"eslint-plugin-react-refresh": "^0.4.5",
"husky": "^9.1.7",
"jsdom": "^24.0.0",
"msw": "^2.11.2",
"newman": "^6.1.0",