Skip to content

Commit 82c98e6

Browse files
authored
Merge pull request #466 from lenneTech/develop
Release 11.8.0
2 parents 04d48f8 + 59db902 commit 82c98e6

22 files changed

+3556
-231
lines changed
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# Package Management Rules
2+
3+
This document defines the rules for managing dependencies in package.json.
4+
5+
## Fixed Versions Only
6+
7+
**All package versions in package.json MUST be exact (fixed) versions.**
8+
9+
### Rules
10+
11+
| Allowed | Not Allowed |
12+
|---------|-------------|
13+
| `"express": "4.18.2"` | `"express": "^4.18.2"` |
14+
| `"typescript": "5.3.3"` | `"typescript": "~5.3.3"` |
15+
| `"lodash": "4.17.21"` | `"lodash": ">=4.0.0"` |
16+
| | `"lodash": "4.x"` |
17+
| | `"lodash": "*"` |
18+
19+
### Why Fixed Versions?
20+
21+
1. **Reproducibility**: Every installation produces identical `node_modules`
22+
2. **Stability**: No surprise breaking changes from automatic minor/patch updates
23+
3. **Security Control**: Updates are intentional and reviewed, not automatic
24+
4. **Debugging**: Easier to identify which version introduced issues
25+
5. **Framework Responsibility**: As a framework, we must ensure consuming projects get predictable behavior
26+
27+
### When Adding New Packages
28+
29+
```bash
30+
# CORRECT: Install and immediately fix the version
31+
npm install [email protected]
32+
33+
# Then verify package.json has exact version (no ^ or ~)
34+
```
35+
36+
If npm adds `^` automatically, manually remove it from package.json.
37+
38+
### When Updating Packages
39+
40+
```bash
41+
# Use npm-check-updates or manually update
42+
npx ncu -u package-name
43+
44+
# Or manually edit package.json with exact version
45+
```
46+
47+
Always:
48+
1. Update to exact version
49+
2. Run `npm install`
50+
3. Run `npm test`
51+
4. Verify no regressions
52+
53+
### Checking for Version Ranges
54+
55+
To find packages with version ranges:
56+
57+
```bash
58+
# Find all dependencies with ^ or ~
59+
grep -E '"\^|"~' package.json
60+
```
61+
62+
### Common Mistakes
63+
64+
| Mistake | Fix |
65+
|---------|-----|
66+
| npm adds `^` by default | Remove `^` after install |
67+
| Copying from other projects | Verify versions are fixed |
68+
| Using `npm install package` without version | Specify exact version: `npm install [email protected]` |
69+
70+
## devDependencies
71+
72+
The same rules apply to devDependencies. All versions must be fixed.
73+
74+
## peerDependencies
75+
76+
peerDependencies may use ranges when necessary for compatibility with consuming projects, but this should be minimized.
77+
78+
## Lock File
79+
80+
The `package-lock.json` file must always be committed. It provides additional reproducibility even if someone accidentally introduces a version range.

CLAUDE.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ See `.claude/rules/versioning.md` for release process.
122122
6. **Document breaking changes** in commits
123123
7. **Integration Checklists for Core Modules** - Every core module requiring project integration needs `INTEGRATION-CHECKLIST.md` (see `.claude/rules/core-modules.md`)
124124
8. **Don't add redundant @UseGuards** - `@Roles()` already handles JWT auth (see `.claude/rules/role-system.md`)
125+
9. **Fixed package versions only** - Never use `^`, `~`, or ranges in package.json (see `.claude/rules/package-management.md`)
125126

126127
## Migration Guides
127128

@@ -146,3 +147,4 @@ Detailed documentation in `.claude/rules/`:
146147
| `module-deprecation.md` | Legacy Auth → BetterAuth migration roadmap |
147148
| `migration-guides.md` | Process for creating version migration guides |
148149
| `configurable-features.md` | Configuration patterns: "Presence implies enabled" and "Boolean shorthand" (`true` / `{}`) |
150+
| `package-management.md` | Fixed package versions only - no `^`, `~`, or ranges |

0 commit comments

Comments
 (0)