codingbuddy-rules 2.4.2 → 3.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.ai-rules/CHANGELOG.md +122 -0
- package/.ai-rules/agents/README.md +527 -11
- package/.ai-rules/agents/accessibility-specialist.json +0 -1
- package/.ai-rules/agents/act-mode.json +0 -1
- package/.ai-rules/agents/agent-architect.json +0 -1
- package/.ai-rules/agents/ai-ml-engineer.json +0 -1
- package/.ai-rules/agents/architecture-specialist.json +14 -2
- package/.ai-rules/agents/backend-developer.json +14 -2
- package/.ai-rules/agents/code-quality-specialist.json +0 -1
- package/.ai-rules/agents/data-engineer.json +0 -1
- package/.ai-rules/agents/devops-engineer.json +24 -2
- package/.ai-rules/agents/documentation-specialist.json +0 -1
- package/.ai-rules/agents/eval-mode.json +0 -1
- package/.ai-rules/agents/event-architecture-specialist.json +719 -0
- package/.ai-rules/agents/frontend-developer.json +14 -2
- package/.ai-rules/agents/i18n-specialist.json +0 -1
- package/.ai-rules/agents/integration-specialist.json +11 -1
- package/.ai-rules/agents/migration-specialist.json +676 -0
- package/.ai-rules/agents/mobile-developer.json +0 -1
- package/.ai-rules/agents/observability-specialist.json +747 -0
- package/.ai-rules/agents/performance-specialist.json +24 -2
- package/.ai-rules/agents/plan-mode.json +0 -1
- package/.ai-rules/agents/platform-engineer.json +0 -1
- package/.ai-rules/agents/security-specialist.json +27 -16
- package/.ai-rules/agents/seo-specialist.json +0 -1
- package/.ai-rules/agents/solution-architect.json +0 -1
- package/.ai-rules/agents/technical-planner.json +0 -1
- package/.ai-rules/agents/test-strategy-specialist.json +14 -2
- package/.ai-rules/agents/ui-ux-designer.json +0 -1
- package/.ai-rules/rules/core.md +25 -0
- package/.ai-rules/skills/README.md +35 -0
- package/.ai-rules/skills/database-migration/SKILL.md +531 -0
- package/.ai-rules/skills/database-migration/expand-contract-patterns.md +314 -0
- package/.ai-rules/skills/database-migration/large-scale-migration.md +414 -0
- package/.ai-rules/skills/database-migration/rollback-strategies.md +359 -0
- package/.ai-rules/skills/database-migration/validation-procedures.md +428 -0
- package/.ai-rules/skills/dependency-management/SKILL.md +381 -0
- package/.ai-rules/skills/dependency-management/license-compliance.md +282 -0
- package/.ai-rules/skills/dependency-management/lock-file-management.md +437 -0
- package/.ai-rules/skills/dependency-management/major-upgrade-guide.md +292 -0
- package/.ai-rules/skills/dependency-management/security-vulnerability-response.md +230 -0
- package/.ai-rules/skills/incident-response/SKILL.md +373 -0
- package/.ai-rules/skills/incident-response/communication-templates.md +322 -0
- package/.ai-rules/skills/incident-response/escalation-matrix.md +347 -0
- package/.ai-rules/skills/incident-response/postmortem-template.md +351 -0
- package/.ai-rules/skills/incident-response/severity-classification.md +256 -0
- package/.ai-rules/skills/performance-optimization/CREATION-LOG.md +87 -0
- package/.ai-rules/skills/performance-optimization/SKILL.md +76 -0
- package/.ai-rules/skills/performance-optimization/documentation-template.md +70 -0
- package/.ai-rules/skills/pr-review/SKILL.md +768 -0
- package/.ai-rules/skills/refactoring/SKILL.md +192 -0
- package/.ai-rules/skills/refactoring/refactoring-catalog.md +1377 -0
- package/package.json +1 -1
|
@@ -0,0 +1,437 @@
|
|
|
1
|
+
# Lock File Management
|
|
2
|
+
|
|
3
|
+
Procedures for maintaining lock file integrity and resolving conflicts.
|
|
4
|
+
|
|
5
|
+
## Why Lock Files Matter
|
|
6
|
+
|
|
7
|
+
Lock files ensure **reproducible builds**:
|
|
8
|
+
- Exact versions installed across all environments
|
|
9
|
+
- Prevents "works on my machine" issues
|
|
10
|
+
- Security audit trail for dependencies
|
|
11
|
+
- Faster installs (resolved dependency tree)
|
|
12
|
+
|
|
13
|
+
**Treat lock files as source code.** They deserve the same care as any other code.
|
|
14
|
+
|
|
15
|
+
## Lock File Types by Package Manager
|
|
16
|
+
|
|
17
|
+
| Manager | Lock File | Format |
|
|
18
|
+
|---------|-----------|--------|
|
|
19
|
+
| npm | `package-lock.json` | JSON |
|
|
20
|
+
| Yarn Classic | `yarn.lock` | Custom |
|
|
21
|
+
| Yarn Berry | `yarn.lock` | YAML |
|
|
22
|
+
| pnpm | `pnpm-lock.yaml` | YAML |
|
|
23
|
+
| Bun | `bun.lockb` | Binary |
|
|
24
|
+
|
|
25
|
+
## Merge Conflict Resolution
|
|
26
|
+
|
|
27
|
+
### Prevention First
|
|
28
|
+
|
|
29
|
+
**Golden rule:** Never have two PRs modifying dependencies at the same time.
|
|
30
|
+
|
|
31
|
+
If unavoidable:
|
|
32
|
+
1. Merge one PR first
|
|
33
|
+
2. Rebase second PR
|
|
34
|
+
3. Regenerate lock file
|
|
35
|
+
|
|
36
|
+
### Resolution Procedure
|
|
37
|
+
|
|
38
|
+
When conflicts occur:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
# Step 1: Accept the target branch's package.json (usually main)
|
|
42
|
+
git checkout main -- package.json
|
|
43
|
+
|
|
44
|
+
# Step 2: Delete the conflicted lock file
|
|
45
|
+
rm package-lock.json # or yarn.lock, pnpm-lock.yaml
|
|
46
|
+
|
|
47
|
+
# Step 3: Reinstall to regenerate lock file
|
|
48
|
+
npm install # or yarn, pnpm install
|
|
49
|
+
|
|
50
|
+
# Step 4: Verify no unexpected changes
|
|
51
|
+
git diff package-lock.json
|
|
52
|
+
|
|
53
|
+
# Step 5: Commit the resolved lock file
|
|
54
|
+
git add package.json package-lock.json
|
|
55
|
+
git commit -m "chore: resolve lock file conflict"
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### What NOT to Do
|
|
59
|
+
|
|
60
|
+
- **Don't manually edit lock files** - Always regenerate
|
|
61
|
+
- **Don't merge conflict markers** - Lock files aren't mergeable
|
|
62
|
+
- **Don't use `--force` flags** - Investigate the conflict
|
|
63
|
+
- **Don't skip lock file in commits** - It's required for reproducibility
|
|
64
|
+
|
|
65
|
+
## CI/CD Validation
|
|
66
|
+
|
|
67
|
+
### Lock File Integrity Check
|
|
68
|
+
|
|
69
|
+
```yaml
|
|
70
|
+
# GitHub Actions example
|
|
71
|
+
- name: Verify lock file integrity
|
|
72
|
+
run: |
|
|
73
|
+
# For npm
|
|
74
|
+
npm ci
|
|
75
|
+
# Fails if lock file would change
|
|
76
|
+
|
|
77
|
+
# For yarn
|
|
78
|
+
yarn install --frozen-lockfile
|
|
79
|
+
|
|
80
|
+
# For pnpm
|
|
81
|
+
pnpm install --frozen-lockfile
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Preventing Lock File Drift
|
|
85
|
+
|
|
86
|
+
```yaml
|
|
87
|
+
# Fail if lock file is out of sync
|
|
88
|
+
- name: Check lock file sync
|
|
89
|
+
run: |
|
|
90
|
+
npm install
|
|
91
|
+
git diff --exit-code package-lock.json || {
|
|
92
|
+
echo "Lock file out of sync with package.json"
|
|
93
|
+
exit 1
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Security Audit in CI
|
|
98
|
+
|
|
99
|
+
```yaml
|
|
100
|
+
- name: Security audit
|
|
101
|
+
run: |
|
|
102
|
+
npm audit --audit-level=high
|
|
103
|
+
# Fails build on high+ vulnerabilities
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## Automated Update Strategies
|
|
107
|
+
|
|
108
|
+
### Dependabot Configuration
|
|
109
|
+
|
|
110
|
+
```yaml
|
|
111
|
+
# .github/dependabot.yml
|
|
112
|
+
version: 2
|
|
113
|
+
updates:
|
|
114
|
+
- package-ecosystem: "npm"
|
|
115
|
+
directory: "/"
|
|
116
|
+
schedule:
|
|
117
|
+
interval: "weekly"
|
|
118
|
+
# Group minor/patch updates
|
|
119
|
+
groups:
|
|
120
|
+
dependencies:
|
|
121
|
+
patterns:
|
|
122
|
+
- "*"
|
|
123
|
+
update-types:
|
|
124
|
+
- "minor"
|
|
125
|
+
- "patch"
|
|
126
|
+
# Separate PRs for majors
|
|
127
|
+
ignore:
|
|
128
|
+
- dependency-name: "*"
|
|
129
|
+
update-types: ["version-update:semver-major"]
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### Renovate Configuration
|
|
133
|
+
|
|
134
|
+
```json
|
|
135
|
+
{
|
|
136
|
+
"extends": ["config:recommended"],
|
|
137
|
+
"packageRules": [
|
|
138
|
+
{
|
|
139
|
+
"matchUpdateTypes": ["patch", "minor"],
|
|
140
|
+
"automerge": true,
|
|
141
|
+
"automergeType": "branch"
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
"matchUpdateTypes": ["major"],
|
|
145
|
+
"automerge": false,
|
|
146
|
+
"labels": ["breaking-change"]
|
|
147
|
+
}
|
|
148
|
+
],
|
|
149
|
+
"lockFileMaintenance": {
|
|
150
|
+
"enabled": true,
|
|
151
|
+
"schedule": ["before 5am on monday"]
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### Auto-merge Safety Rules
|
|
157
|
+
|
|
158
|
+
Only auto-merge when:
|
|
159
|
+
- [ ] Patch/minor version only
|
|
160
|
+
- [ ] All CI checks pass
|
|
161
|
+
- [ ] No security advisories for new version
|
|
162
|
+
- [ ] Package has >1M weekly downloads (stability indicator)
|
|
163
|
+
- [ ] Not a critical dependency
|
|
164
|
+
|
|
165
|
+
## Lock File Best Practices
|
|
166
|
+
|
|
167
|
+
### Commit Lock Files Always
|
|
168
|
+
|
|
169
|
+
```gitignore
|
|
170
|
+
# .gitignore - DON'T ignore lock files
|
|
171
|
+
# ❌ package-lock.json
|
|
172
|
+
# ❌ yarn.lock
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### Regenerate Periodically
|
|
176
|
+
|
|
177
|
+
Schedule lock file regeneration:
|
|
178
|
+
- Weekly for active projects
|
|
179
|
+
- Before major releases
|
|
180
|
+
- After security incidents
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
# Full regeneration
|
|
184
|
+
rm -rf node_modules package-lock.json
|
|
185
|
+
npm install
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### Review Lock File Changes
|
|
189
|
+
|
|
190
|
+
When reviewing PRs with lock file changes:
|
|
191
|
+
|
|
192
|
+
1. **Check package.json first** - What was the intended change?
|
|
193
|
+
2. **Verify version updates match** - Lock file should reflect package.json
|
|
194
|
+
3. **Look for unexpected changes** - Transitive deps shouldn't change randomly
|
|
195
|
+
4. **Check integrity hashes** - Should be present for all packages
|
|
196
|
+
|
|
197
|
+
## Troubleshooting
|
|
198
|
+
|
|
199
|
+
### "Lock file out of date"
|
|
200
|
+
|
|
201
|
+
```bash
|
|
202
|
+
# Regenerate lock file
|
|
203
|
+
rm package-lock.json
|
|
204
|
+
npm install
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
### "Peer dependency conflict"
|
|
208
|
+
|
|
209
|
+
```bash
|
|
210
|
+
# Find the conflict
|
|
211
|
+
npm ls <conflicting-package>
|
|
212
|
+
|
|
213
|
+
# Options:
|
|
214
|
+
# 1. Update the parent package
|
|
215
|
+
# 2. Use resolutions/overrides to force version
|
|
216
|
+
# 3. Use --legacy-peer-deps (last resort)
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
### "Integrity checksum mismatch"
|
|
220
|
+
|
|
221
|
+
```bash
|
|
222
|
+
# Clear npm cache
|
|
223
|
+
npm cache clean --force
|
|
224
|
+
|
|
225
|
+
# Remove node_modules and reinstall
|
|
226
|
+
rm -rf node_modules package-lock.json
|
|
227
|
+
npm install
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
### "Different lock file locally vs CI"
|
|
231
|
+
|
|
232
|
+
Causes:
|
|
233
|
+
- Different npm version
|
|
234
|
+
- Different Node version
|
|
235
|
+
- npm registry differences
|
|
236
|
+
|
|
237
|
+
Solutions:
|
|
238
|
+
```bash
|
|
239
|
+
# Pin npm version in CI
|
|
240
|
+
npm install -g npm@10.x
|
|
241
|
+
|
|
242
|
+
# Use .npmrc for registry consistency
|
|
243
|
+
# .npmrc
|
|
244
|
+
registry=https://registry.npmjs.org/
|
|
245
|
+
|
|
246
|
+
# Use engines in package.json
|
|
247
|
+
{
|
|
248
|
+
"engines": {
|
|
249
|
+
"node": ">=20.0.0",
|
|
250
|
+
"npm": ">=10.0.0"
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
## Lock File Audit
|
|
256
|
+
|
|
257
|
+
### Finding Outdated Lock Entries
|
|
258
|
+
|
|
259
|
+
```bash
|
|
260
|
+
# List outdated packages
|
|
261
|
+
npm outdated
|
|
262
|
+
|
|
263
|
+
# Check for packages not in package.json
|
|
264
|
+
npm prune --dry-run
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
### Removing Unused Dependencies
|
|
268
|
+
|
|
269
|
+
```bash
|
|
270
|
+
# Find unused dependencies
|
|
271
|
+
npx depcheck
|
|
272
|
+
|
|
273
|
+
# Remove and regenerate lock
|
|
274
|
+
npm uninstall <unused-package>
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
### Lock File Size Management
|
|
278
|
+
|
|
279
|
+
Large lock files indicate:
|
|
280
|
+
- Too many dependencies
|
|
281
|
+
- Duplicate packages
|
|
282
|
+
- Outdated transitive deps
|
|
283
|
+
|
|
284
|
+
```bash
|
|
285
|
+
# Deduplicate (npm 7+)
|
|
286
|
+
npm dedupe
|
|
287
|
+
|
|
288
|
+
# Check package count
|
|
289
|
+
jq '.packages | length' package-lock.json
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
## Private Registry Handling
|
|
293
|
+
|
|
294
|
+
When using private npm registries (npm Enterprise, Artifactory, Verdaccio, GitHub Packages):
|
|
295
|
+
|
|
296
|
+
### Authentication Setup
|
|
297
|
+
|
|
298
|
+
```bash
|
|
299
|
+
# .npmrc for private registry
|
|
300
|
+
@myorg:registry=https://npm.mycompany.com/
|
|
301
|
+
//npm.mycompany.com/:_authToken=${NPM_TOKEN}
|
|
302
|
+
|
|
303
|
+
# GitHub Packages
|
|
304
|
+
@myorg:registry=https://npm.pkg.github.com/
|
|
305
|
+
//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}
|
|
306
|
+
|
|
307
|
+
# Multiple registries
|
|
308
|
+
@company-a:registry=https://npm.company-a.com/
|
|
309
|
+
@company-b:registry=https://npm.company-b.com/
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
### CI/CD Authentication
|
|
313
|
+
|
|
314
|
+
```yaml
|
|
315
|
+
# GitHub Actions
|
|
316
|
+
- name: Setup npm auth
|
|
317
|
+
run: |
|
|
318
|
+
echo "@myorg:registry=https://npm.pkg.github.com/" >> .npmrc
|
|
319
|
+
echo "//npm.pkg.github.com/:_authToken=${{ secrets.NPM_TOKEN }}" >> .npmrc
|
|
320
|
+
|
|
321
|
+
# GitLab CI
|
|
322
|
+
before_script:
|
|
323
|
+
- echo "@myorg:registry=https://${CI_SERVER_HOST}/api/v4/packages/npm/" >> .npmrc
|
|
324
|
+
- echo "//${CI_SERVER_HOST}/api/v4/packages/npm/:_authToken=${CI_JOB_TOKEN}" >> .npmrc
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
### Audit with Private Registries
|
|
328
|
+
|
|
329
|
+
```bash
|
|
330
|
+
# npm audit may not work with all private registries
|
|
331
|
+
# Alternative: use registry-specific tools
|
|
332
|
+
|
|
333
|
+
# Artifactory
|
|
334
|
+
jfrog rt audit
|
|
335
|
+
|
|
336
|
+
# Snyk (works with private registries)
|
|
337
|
+
snyk test
|
|
338
|
+
|
|
339
|
+
# GitHub Advisory Database (public packages only)
|
|
340
|
+
npm audit --registry=https://registry.npmjs.org/
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
### Lock File Considerations
|
|
344
|
+
|
|
345
|
+
1. **Registry URLs in lock file**
|
|
346
|
+
- Lock files contain resolved URLs
|
|
347
|
+
- Private registry URLs will be in lock file
|
|
348
|
+
- Don't commit auth tokens (they shouldn't be in lock file)
|
|
349
|
+
|
|
350
|
+
2. **Mirrored packages**
|
|
351
|
+
- If using registry mirror, lock file URLs point to mirror
|
|
352
|
+
- CI/CD needs access to same registry
|
|
353
|
+
- Consider fallback to public registry
|
|
354
|
+
|
|
355
|
+
3. **Scoped packages**
|
|
356
|
+
- Scoped packages (@org/pkg) route to configured registry
|
|
357
|
+
- Unscoped packages use default registry
|
|
358
|
+
- Verify both are accessible in CI
|
|
359
|
+
|
|
360
|
+
### Troubleshooting Private Registries
|
|
361
|
+
|
|
362
|
+
**"401 Unauthorized"**
|
|
363
|
+
```bash
|
|
364
|
+
# Verify token is set
|
|
365
|
+
npm whoami --registry=https://npm.mycompany.com/
|
|
366
|
+
|
|
367
|
+
# Re-authenticate
|
|
368
|
+
npm login --registry=https://npm.mycompany.com/ --scope=@myorg
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
**"404 Not Found"**
|
|
372
|
+
```bash
|
|
373
|
+
# Check if package exists in private registry
|
|
374
|
+
npm view @myorg/package --registry=https://npm.mycompany.com/
|
|
375
|
+
|
|
376
|
+
# May need to proxy to public registry
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
**"UNABLE_TO_VERIFY_LEAF_SIGNATURE"**
|
|
380
|
+
```bash
|
|
381
|
+
# Self-signed certificate issue
|
|
382
|
+
npm config set strict-ssl false # Not recommended for production
|
|
383
|
+
|
|
384
|
+
# Better: Add CA certificate
|
|
385
|
+
npm config set cafile /path/to/ca-cert.pem
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
## Emergency Procedures
|
|
389
|
+
|
|
390
|
+
### Lock File Corruption
|
|
391
|
+
|
|
392
|
+
```bash
|
|
393
|
+
# Nuclear option - full reset
|
|
394
|
+
rm -rf node_modules package-lock.json .npm
|
|
395
|
+
npm cache clean --force
|
|
396
|
+
npm install
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
### Rollback Lock File
|
|
400
|
+
|
|
401
|
+
```bash
|
|
402
|
+
# Find last known good lock file
|
|
403
|
+
git log --oneline -- package-lock.json
|
|
404
|
+
|
|
405
|
+
# Restore specific version
|
|
406
|
+
git checkout <commit-hash> -- package-lock.json
|
|
407
|
+
npm ci
|
|
408
|
+
```
|
|
409
|
+
|
|
410
|
+
### Force Specific Versions
|
|
411
|
+
|
|
412
|
+
When you need to override versions:
|
|
413
|
+
|
|
414
|
+
```json
|
|
415
|
+
// package.json (npm)
|
|
416
|
+
{
|
|
417
|
+
"overrides": {
|
|
418
|
+
"vulnerable-package": "2.0.1"
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
// package.json (yarn)
|
|
423
|
+
{
|
|
424
|
+
"resolutions": {
|
|
425
|
+
"vulnerable-package": "2.0.1"
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
// package.json (pnpm)
|
|
430
|
+
{
|
|
431
|
+
"pnpm": {
|
|
432
|
+
"overrides": {
|
|
433
|
+
"vulnerable-package": "2.0.1"
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
```
|
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
# Major Upgrade Guide
|
|
2
|
+
|
|
3
|
+
Systematic approach to major version upgrades with breaking changes.
|
|
4
|
+
|
|
5
|
+
## When Major Upgrades Are Needed
|
|
6
|
+
|
|
7
|
+
- Current version reaches end-of-life
|
|
8
|
+
- Security vulnerability only fixed in major version
|
|
9
|
+
- Required feature only in major version
|
|
10
|
+
- Dependency chain requires newer version
|
|
11
|
+
|
|
12
|
+
## Breaking Change Analysis
|
|
13
|
+
|
|
14
|
+
### Step 1: Read the Changelog
|
|
15
|
+
|
|
16
|
+
**Completely.** Not skimming.
|
|
17
|
+
|
|
18
|
+
For each breaking change, document:
|
|
19
|
+
|
|
20
|
+
| Change | Current Usage | Impact | Migration |
|
|
21
|
+
|--------|---------------|--------|-----------|
|
|
22
|
+
| API renamed | 5 files | Low | Find/replace |
|
|
23
|
+
| Behavior changed | 3 modules | Medium | Logic update |
|
|
24
|
+
| Type changed | 15 imports | High | Refactor |
|
|
25
|
+
|
|
26
|
+
### Step 2: Search Your Codebase
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
# Find all usages of changed APIs
|
|
30
|
+
grep -r "deprecatedFunction" src/
|
|
31
|
+
grep -r "changedType" src/
|
|
32
|
+
|
|
33
|
+
# For TypeScript, also check type imports
|
|
34
|
+
grep -r "import.*{.*ChangedType" src/
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Step 3: Check Peer Dependencies
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
# List what depends on this package
|
|
41
|
+
npm ls <package>
|
|
42
|
+
|
|
43
|
+
# Check if peers also need updates
|
|
44
|
+
npm info <package>@<new-version> peerDependencies
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Staged Upgrade Strategy
|
|
48
|
+
|
|
49
|
+
For major version jumps (e.g., v2 to v5), never jump directly.
|
|
50
|
+
|
|
51
|
+
### Determine Intermediate Versions
|
|
52
|
+
|
|
53
|
+
```
|
|
54
|
+
Current: 2.4.1
|
|
55
|
+
Target: 5.2.0
|
|
56
|
+
|
|
57
|
+
Path: 2.4.1 → 3.0.0 → 4.0.0 → 5.0.0 → 5.2.0
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Benefits of Staged Upgrades
|
|
61
|
+
|
|
62
|
+
1. **Smaller changesets** - Easier to review and test
|
|
63
|
+
2. **Isolated failures** - Know which version broke
|
|
64
|
+
3. **Incremental migrations** - Handle deprecations step by step
|
|
65
|
+
4. **Rollback points** - Can stop at stable intermediate
|
|
66
|
+
|
|
67
|
+
### When to Skip Stages
|
|
68
|
+
|
|
69
|
+
Direct upgrade acceptable when:
|
|
70
|
+
- Comprehensive migration guide exists
|
|
71
|
+
- Breaking changes are well-documented
|
|
72
|
+
- Test coverage is high (>90%)
|
|
73
|
+
- Staging environment available
|
|
74
|
+
|
|
75
|
+
## Compatibility Testing Strategy
|
|
76
|
+
|
|
77
|
+
### Test Matrix
|
|
78
|
+
|
|
79
|
+
| Test Type | When | Coverage Target |
|
|
80
|
+
|-----------|------|-----------------|
|
|
81
|
+
| Unit tests | Every upgrade | 90%+ |
|
|
82
|
+
| Integration | Major versions | Critical paths |
|
|
83
|
+
| E2E | Before production | Happy paths |
|
|
84
|
+
| Performance | If perf-critical | Baseline comparison |
|
|
85
|
+
|
|
86
|
+
### Regression Checklist
|
|
87
|
+
|
|
88
|
+
Before each upgrade stage:
|
|
89
|
+
|
|
90
|
+
- [ ] All existing tests pass
|
|
91
|
+
- [ ] No new TypeScript errors
|
|
92
|
+
- [ ] No new console warnings
|
|
93
|
+
- [ ] Build size within 5% of baseline
|
|
94
|
+
- [ ] Critical user flows work manually
|
|
95
|
+
|
|
96
|
+
### Canary Testing
|
|
97
|
+
|
|
98
|
+
For high-risk upgrades:
|
|
99
|
+
|
|
100
|
+
1. Deploy to canary environment
|
|
101
|
+
2. Route 5% of traffic
|
|
102
|
+
3. Monitor error rates for 24 hours
|
|
103
|
+
4. Gradually increase traffic
|
|
104
|
+
5. Full rollout if stable
|
|
105
|
+
|
|
106
|
+
## Common Upgrade Patterns
|
|
107
|
+
|
|
108
|
+
### Pattern 1: Adapter Layer
|
|
109
|
+
|
|
110
|
+
Create abstraction to isolate changes:
|
|
111
|
+
|
|
112
|
+
```typescript
|
|
113
|
+
// Before: Direct usage spread across codebase
|
|
114
|
+
import { oldApi } from 'library';
|
|
115
|
+
oldApi.doThing();
|
|
116
|
+
|
|
117
|
+
// After: Centralized adapter
|
|
118
|
+
// src/adapters/library-adapter.ts
|
|
119
|
+
import { newApi } from 'library';
|
|
120
|
+
|
|
121
|
+
export function doThing() {
|
|
122
|
+
// Translate old interface to new
|
|
123
|
+
return newApi.doNewThing();
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// Usage unchanged
|
|
127
|
+
import { doThing } from '@/adapters/library-adapter';
|
|
128
|
+
doThing();
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### Pattern 2: Feature Flag Migration
|
|
132
|
+
|
|
133
|
+
Gradual migration with feature flags:
|
|
134
|
+
|
|
135
|
+
```typescript
|
|
136
|
+
const useNewLibraryVersion = featureFlags.get('USE_NEW_LIBRARY');
|
|
137
|
+
|
|
138
|
+
if (useNewLibraryVersion) {
|
|
139
|
+
// New implementation
|
|
140
|
+
newLibrary.process(data);
|
|
141
|
+
} else {
|
|
142
|
+
// Old implementation (fallback)
|
|
143
|
+
oldLibrary.process(data);
|
|
144
|
+
}
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### Pattern 3: Parallel Running
|
|
148
|
+
|
|
149
|
+
Run both versions, compare results:
|
|
150
|
+
|
|
151
|
+
```typescript
|
|
152
|
+
async function processWithValidation(data: Input) {
|
|
153
|
+
const [oldResult, newResult] = await Promise.all([
|
|
154
|
+
oldLibrary.process(data),
|
|
155
|
+
newLibrary.process(data),
|
|
156
|
+
]);
|
|
157
|
+
|
|
158
|
+
if (!deepEqual(oldResult, newResult)) {
|
|
159
|
+
logger.warn('Mismatch detected', { oldResult, newResult });
|
|
160
|
+
// Use old result while investigating
|
|
161
|
+
return oldResult;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
return newResult;
|
|
165
|
+
}
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## Deprecation Handling
|
|
169
|
+
|
|
170
|
+
### Types of Deprecations
|
|
171
|
+
|
|
172
|
+
| Type | Urgency | Action |
|
|
173
|
+
|------|---------|--------|
|
|
174
|
+
| **Hard removal** | Before upgrade | Must fix |
|
|
175
|
+
| **Soft deprecation** | Within 2 releases | Plan migration |
|
|
176
|
+
| **Warning only** | Low priority | Track for future |
|
|
177
|
+
|
|
178
|
+
### Finding Deprecation Warnings
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
# Run build and capture warnings
|
|
182
|
+
npm run build 2>&1 | grep -i deprecat
|
|
183
|
+
|
|
184
|
+
# Run tests with verbose output
|
|
185
|
+
npm test -- --verbose 2>&1 | grep -i deprecat
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### Documenting Deprecation Debt
|
|
189
|
+
|
|
190
|
+
```markdown
|
|
191
|
+
## Deprecation Tracking
|
|
192
|
+
|
|
193
|
+
| Package | Deprecated API | Replacement | Files Affected | Target Version |
|
|
194
|
+
|---------|---------------|-------------|----------------|----------------|
|
|
195
|
+
| react | componentWillMount | useEffect | 5 | Remove in 18.x |
|
|
196
|
+
| lodash | _.pluck | _.map | 12 | Already removed |
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
## Rollback Planning
|
|
200
|
+
|
|
201
|
+
### Before Every Upgrade
|
|
202
|
+
|
|
203
|
+
1. **Document current state**
|
|
204
|
+
```bash
|
|
205
|
+
npm ls > pre-upgrade-deps.txt
|
|
206
|
+
git tag pre-upgrade-<package>-<date>
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
2. **Preserve lock file**
|
|
210
|
+
```bash
|
|
211
|
+
cp package-lock.json package-lock.json.backup
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
3. **Test rollback procedure**
|
|
215
|
+
- Can you revert package.json?
|
|
216
|
+
- Does lock file restore work?
|
|
217
|
+
- Are there database migrations?
|
|
218
|
+
|
|
219
|
+
### Rollback Triggers
|
|
220
|
+
|
|
221
|
+
Rollback immediately if:
|
|
222
|
+
- Error rate increases >5%
|
|
223
|
+
- Critical path failures
|
|
224
|
+
- Performance degrades >20%
|
|
225
|
+
- Security regression detected
|
|
226
|
+
|
|
227
|
+
### Rollback Procedure
|
|
228
|
+
|
|
229
|
+
```bash
|
|
230
|
+
# Revert package.json and lock file
|
|
231
|
+
git checkout HEAD~1 -- package.json package-lock.json
|
|
232
|
+
|
|
233
|
+
# Clean and reinstall
|
|
234
|
+
rm -rf node_modules
|
|
235
|
+
npm ci
|
|
236
|
+
|
|
237
|
+
# Verify rollback
|
|
238
|
+
npm test
|
|
239
|
+
npm run build
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
## Estimation Guidelines
|
|
243
|
+
|
|
244
|
+
| Factor | Multiplier |
|
|
245
|
+
|--------|------------|
|
|
246
|
+
| Well-documented migration guide | 1x |
|
|
247
|
+
| No migration guide | 2x |
|
|
248
|
+
| Breaking type changes | +0.5x per type |
|
|
249
|
+
| Behavior changes | +1x per behavior |
|
|
250
|
+
| Low test coverage (<60%) | 2x |
|
|
251
|
+
| No staging environment | 1.5x |
|
|
252
|
+
|
|
253
|
+
**Example estimation:**
|
|
254
|
+
|
|
255
|
+
```
|
|
256
|
+
Base: 2 hours
|
|
257
|
+
- No migration guide: 2x = 4 hours
|
|
258
|
+
- 3 breaking types: +1.5 hours
|
|
259
|
+
- Low test coverage: 2x = 11 hours
|
|
260
|
+
- Buffer (20%): 13.2 hours
|
|
261
|
+
|
|
262
|
+
Estimate: 2 days
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
## Upgrade Checklist Template
|
|
266
|
+
|
|
267
|
+
```markdown
|
|
268
|
+
## Upgrade: [package] v[X] → v[Y]
|
|
269
|
+
|
|
270
|
+
### Pre-upgrade
|
|
271
|
+
- [ ] Changelog reviewed
|
|
272
|
+
- [ ] Breaking changes documented
|
|
273
|
+
- [ ] Impact assessed (files: X, risk: High/Medium/Low)
|
|
274
|
+
- [ ] Tests baseline captured
|
|
275
|
+
- [ ] Rollback procedure documented
|
|
276
|
+
|
|
277
|
+
### Upgrade stages
|
|
278
|
+
- [ ] Stage 1: v[X] → v[X+1]
|
|
279
|
+
- [ ] Tests passing
|
|
280
|
+
- [ ] Build successful
|
|
281
|
+
- [ ] Manual verification
|
|
282
|
+
- [ ] Stage N: v[Y-1] → v[Y]
|
|
283
|
+
- [ ] Tests passing
|
|
284
|
+
- [ ] Build successful
|
|
285
|
+
- [ ] Manual verification
|
|
286
|
+
|
|
287
|
+
### Post-upgrade
|
|
288
|
+
- [ ] Full test suite passing
|
|
289
|
+
- [ ] Performance verified
|
|
290
|
+
- [ ] Deprecation warnings addressed
|
|
291
|
+
- [ ] Documentation updated
|
|
292
|
+
```
|