Skip to content

Commit 7ac0e6f

Browse files
committed
docs(hooks): update readme
1 parent 9a52c4c commit 7ac0e6f

File tree

1 file changed

+44
-3
lines changed

1 file changed

+44
-3
lines changed

booster/.husky/README.md

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,14 @@ This project uses [Husky](https://typicode.github.io/husky/) combined with [Goog
66

77
The `.husky` directory contains the following:
88

9-
- **`pre-commit`**: The shell script entry point for the pre-commit hook.
10-
- **`pre-commit.ts`**: The TypeScript logic for the pre-commit hook.
9+
- **`commit-msg`**: Shell script entry point for the commit-msg hook.
10+
- **`commit-msg.ts`**: TypeScript logic for commit message validation and ticket appending.
11+
- **`pre-commit`**: Shell script entry point for the pre-commit hook.
12+
- **`pre-commit.ts`**: TypeScript logic for the pre-commit hook (linters).
13+
- **`pre-push`**: Shell script entry point for the pre-push hook.
14+
- **`pre-push.ts`**: TypeScript logic for the pre-push hook (tests, docs).
1115
- **`shared/`**: A library of shared utilities and configurations.
16+
- **`runner.sh`**: Generic runner script that handles DDEV container detection and command execution.
1217
- **`tools.ts`**: Centralized configuration for all quality tools (JS & PHP).
1318
- **`types.ts`**: TypeScript definitions for the system.
1419
- **`workflow.ts`**: The core execution engine that runs tools, handles errors, and manages output.
@@ -47,6 +52,32 @@ To add a new tool, simply add a `ToolConfig` object to the `TOOLS` array.
4752
}
4853
```
4954

55+
## Hook Specifics
56+
57+
### `pre-commit`
58+
Runs quality tools (linters, static analysis) on staged files.
59+
- **Caching**: ESLint and Prettier use caching to speed up repeated runs.
60+
- **Auto-fix**: Tools like ESLint, Prettier, Rector, and ECS will automatically fix issues and re-stage the changes.
61+
62+
### `commit-msg`
63+
Enforces commit message standards and branch naming.
64+
- **Ticket IDs**: Automatically appends the ticket ID (e.g., `Closes: PRJ-123`) to the commit message body if found in the branch name.
65+
- **Validation**: Ensures the commit message follows Conventional Commits.
66+
67+
### `pre-push`
68+
Ensures the codebase is ready for deployment.
69+
- **Tests**: Runs the fast test suite (`composer test:pest`).
70+
- **API Documentation**: Checks if `documentation/openapi.yml` matches the code.
71+
- If outdated, it **regenerates** the docs and **auto-commits** them.
72+
- **Important**: If an auto-commit occurs, the hook will warn you to **push again** to include the new commit.
73+
74+
## DDEV Integration
75+
76+
The hooks are designed to work seamlessly with DDEV.
77+
- The `shared/runner.sh` script automatically detects if the project is running in DDEV.
78+
- If DDEV is active, all tools (PHP, Composer, Node) are executed **inside the container**.
79+
- If the DDEV container is not running, the hooks will fail with a helpful message.
80+
5081
## Environment Variables
5182

5283
You can control the behavior of the hooks using environment variables. These can be set in your shell or in a `.env` file.
@@ -56,7 +87,17 @@ You can control the behavior of the hooks using environment variables. These can
5687
| `GIT_HOOKS_VERBOSE` | Set to `1` or `true` to enable verbose logging (shows executed commands). |
5788
| `SKIP_PRECOMMIT` | Set to `1` to skip the entire pre-commit hook. |
5889
| `SKIP_PREPUSH` | Set to `1` to skip the entire pre-push hook. |
59-
| `SKIP_<TOOL_NAME>` | Set to `1` to skip a specific tool (e.g., `SKIP_ESLINT=1`, `SKIP_RECTOR=1`). |
90+
| `SKIP_COMMITMSG` | Set to `1` to skip commit message validation and ticket appending. |
91+
| `SKIP_PHPUNIT` | Set to `1` to skip tests in the pre-push hook. |
92+
| `SKIP_API_DOCS` | Set to `1` to skip API documentation generation in the pre-push hook. |
93+
| `SKIP_ESLINT` | Set to `1` to skip ESLint. |
94+
| `SKIP_PRETTIER` | Set to `1` to skip Prettier. |
95+
| `SKIP_STYLELINT` | Set to `1` to skip Stylelint. |
96+
| `SKIP_RECTOR` | Set to `1` to skip Rector. |
97+
| `SKIP_ECS` | Set to `1` to skip EasyCodingStandard. |
98+
| `SKIP_PHPSTAN` | Set to `1` to skip PHPStan. |
99+
| `SKIP_PSALM` | Set to `1` to skip Psalm. |
100+
| `SKIP_DEPTRAC` | Set to `1` to skip Deptrac (if enabled). |
60101

61102
## How it Works
62103

0 commit comments

Comments
 (0)