aiknowsys 0.0.1

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.
@@ -0,0 +1,561 @@
1
+ ---
2
+ name: dependency-updates
3
+ description: Safe dependency update workflow for gnwebsite fullstack Django/Vue project. Use when updating packages, upgrading dependencies, fixing vulnerabilities, or when user asks to update dependencies. Covers backend Python (pyproject.toml), frontend npm packages, vulnerability audits, testing requirements, and rollback procedures. Ensures updates maintain compatibility and don't break existing functionality.
4
+ ---
5
+
6
+ # Dependency Updates
7
+
8
+ Comprehensive guide for safely updating backend and frontend dependencies in gnwebsite project while maintaining stability and security.
9
+
10
+ ## When to Use This Skill
11
+
12
+ - User asks to "update dependencies" or "upgrade packages"
13
+ - Monthly/quarterly dependency maintenance
14
+ - Security vulnerability alerts
15
+ - When fixing known CVEs or vulnerabilities
16
+ - Before major feature releases
17
+ - When you hear: "Are our dependencies up to date?"
18
+
19
+ ## Core Principles
20
+
21
+ 1. **Security First**: Update packages with known vulnerabilities immediately
22
+ 2. **Test-Driven**: Never update without running full test suite
23
+ 3. **Incremental**: Update one category at a time (backend → frontend → devDeps)
24
+ 4. **Documented**: Track what changed and why in CODEBASE_CHANGELOG.md
25
+ 5. **Reversible**: Always commit before updates for easy rollback
26
+
27
+ ## Pre-Update Checklist
28
+
29
+ Before starting any dependency updates:
30
+
31
+ - [ ] Commit all current work: `git status` should be clean
32
+ - [ ] All tests currently passing (backend + frontend)
33
+ - [ ] Create a new branch: `git checkout -b chore/dependency-updates-YYYY-MM`
34
+ - [ ] Read CODEBASE_ESSENTIALS.md for current stack snapshot
35
+ - [ ] Check for breaking changes in major version updates
36
+
37
+ ## Backend Dependency Updates (Python)
38
+
39
+ ### Step 1: Audit Current Dependencies
40
+
41
+ ```bash
42
+ # Check for vulnerabilities using pip-audit (if available)
43
+ docker-compose exec backend pip install pip-audit
44
+ docker-compose exec backend pip-audit
45
+
46
+ # Check for outdated packages
47
+ docker-compose exec backend pip list --outdated
48
+ ```
49
+
50
+ ### Step 2: Update pyproject.toml
51
+
52
+ **Source of truth**: `backend/pyproject.toml`
53
+
54
+ ```toml
55
+ [project]
56
+ dependencies = [
57
+ "Django>=5.1.0", # Production dependencies
58
+ "djangorestframework>=3.15.2",
59
+ # ... more
60
+ ]
61
+
62
+ [project.optional-dependencies]
63
+ dev = [
64
+ "pytest>=8.0.0", # Dev dependencies
65
+ # ... more
66
+ ]
67
+ ```
68
+
69
+ **Update strategy**:
70
+
71
+ 1. **Patch updates** (5.1.0 → 5.1.1): Generally safe, update automatically
72
+ 2. **Minor updates** (5.1.0 → 5.2.0): Review changelog, test thoroughly
73
+ 3. **Major updates** (5.1.0 → 6.0.0): May require code changes, plan separately
74
+
75
+ ```bash
76
+ # Edit pyproject.toml manually
77
+ # For patch updates: Change Django>=5.1.0 to Django>=5.1.2
78
+ # For minor updates: Change Django>=5.1.0 to Django>=5.2.0
79
+ # NEVER use exact pins (==) unless absolutely required
80
+ ```
81
+
82
+ ### Step 3: Regenerate requirements.txt
83
+
84
+ ```bash
85
+ # Use the project's update script (preferred)
86
+ cd backend && ./update-requirements.sh
87
+
88
+ # Or manually:
89
+ docker-compose exec backend pip-compile pyproject.toml -o requirements.txt --resolver=backtracking --strip-extras
90
+ ```
91
+
92
+ **What this does**:
93
+ - Resolves all transitive dependencies
94
+ - Locks exact versions for reproducible builds
95
+ - Generates requirements.txt from pyproject.toml
96
+
97
+ ### Step 4: Rebuild Backend Container
98
+
99
+ ```bash
100
+ # Rebuild with new dependencies
101
+ docker-compose build backend
102
+
103
+ # Start fresh
104
+ docker-compose up -d backend
105
+ ```
106
+
107
+ ### Step 5: Run Backend Tests
108
+
109
+ **MANDATORY - DO NOT SKIP**
110
+
111
+ ```bash
112
+ # Run all backend tests
113
+ docker-compose exec backend pytest jewelry_portfolio/ -x
114
+
115
+ # Expected: "X passed, Y skipped" with no failures
116
+ ```
117
+
118
+ **If tests fail:**
119
+ 1. Read error messages carefully
120
+ 2. Check changelogs for breaking changes
121
+ 3. Update code to match new API
122
+ 4. Re-run tests until all pass
123
+ 5. If unfixable, rollback: `git checkout backend/pyproject.toml backend/requirements.txt`
124
+
125
+ ### Step 6: Test Django Admin & API Manually
126
+
127
+ ```bash
128
+ # Start dev server
129
+ docker-compose up backend
130
+
131
+ # Test in browser:
132
+ # - Admin panel: http://localhost:8000/panel-0911/
133
+ # - API endpoints: http://localhost:8000/api/
134
+ # - OpenAPI docs: http://localhost:8000/api/schema/swagger-ui/
135
+ ```
136
+
137
+ ### Step 7: Regenerate OpenAPI Schema
138
+
139
+ **Required if Django/DRF updated:**
140
+
141
+ ```bash
142
+ # Regenerate OpenAPI schema
143
+ docker-compose exec backend python manage.py spectacular --file openapi_schema.json
144
+
145
+ # Check for schema changes
146
+ git diff backend/openapi_schema.json
147
+ ```
148
+
149
+ If schema changed → proceed to frontend TypeScript client regeneration
150
+
151
+ ## Frontend Dependency Updates (npm)
152
+
153
+ ### Step 1: Audit Current Dependencies
154
+
155
+ ```bash
156
+ # Check for vulnerabilities
157
+ cd frontend && npm audit
158
+
159
+ # View vulnerability details
160
+ npm audit --json > audit-report.json
161
+
162
+ # Check for outdated packages
163
+ npm outdated
164
+ ```
165
+
166
+ ### Step 2: Update package.json
167
+
168
+ **Two approaches:**
169
+
170
+ #### A. Interactive Update (Recommended for major updates)
171
+
172
+ ```bash
173
+ # Use npm-check-updates (install if needed)
174
+ npm install -g npm-check-updates
175
+
176
+ # Preview updates
177
+ ncu
178
+
179
+ # Update package.json (does NOT install yet)
180
+ ncu -u
181
+
182
+ # Review changes
183
+ git diff package.json
184
+ ```
185
+
186
+ #### B. Targeted Update (For specific packages)
187
+
188
+ ```bash
189
+ # Update specific package to latest
190
+ npm install vue@latest
191
+
192
+ # Update with version constraint
193
+ npm install typescript@~5.9.3
194
+
195
+ # Update dev dependency
196
+ npm install -D vite@latest
197
+ ```
198
+
199
+ ### Step 3: Install Updated Dependencies
200
+
201
+ ```bash
202
+ # Install and update package-lock.json
203
+ npm install
204
+
205
+ # If conflicts, try:
206
+ npm install --legacy-peer-deps
207
+ ```
208
+
209
+ ### Step 4: Run Frontend Tests
210
+
211
+ **MANDATORY - DO NOT SKIP**
212
+
213
+ ```bash
214
+ # Type checking
215
+ npm run type-check
216
+ # Expected: No output = success
217
+
218
+ # Unit/integration tests
219
+ npm run test:run # NOT "npm test" - it hangs!
220
+ # Expected: "X passed" with acceptable documented failures
221
+
222
+ # Build check
223
+ npm run build
224
+ # Expected: Successful build
225
+ ```
226
+
227
+ **If tests fail:**
228
+ 1. Check for TypeScript errors first: `npm run type-check`
229
+ 2. Read error messages for breaking API changes
230
+ 3. Update components/composables to match new APIs
231
+ 4. Check migration guides in package changelogs
232
+ 5. If unfixable, rollback: `git checkout frontend/package.json frontend/package-lock.json && npm install`
233
+
234
+ ### Step 5: Regenerate TypeScript API Client (If Backend Updated)
235
+
236
+ **Required if openapi_schema.json changed:**
237
+
238
+ ```bash
239
+ cd frontend
240
+
241
+ # Regenerate TypeScript client from OpenAPI schema
242
+ npx @openapitools/openapi-generator-cli generate \
243
+ -i ../backend/openapi_schema.json \
244
+ -g typescript-fetch \
245
+ -o src/api/generated
246
+
247
+ # Verify TypeScript compiles
248
+ npm run type-check
249
+ ```
250
+
251
+ ### Step 6: Test Frontend Manually
252
+
253
+ ```bash
254
+ # Start dev server
255
+ npm run dev
256
+
257
+ # Test in browser:
258
+ # - All routes load: http://localhost:3000
259
+ # - Forms submit correctly
260
+ # - Image uploads work
261
+ # - Admin panel accessible
262
+ # - No console errors
263
+ ```
264
+
265
+ ## Vulnerability-Specific Updates
266
+
267
+ **For critical security updates, use expedited workflow:**
268
+
269
+ ### Backend Vulnerabilities
270
+
271
+ ```bash
272
+ # 1. Identify vulnerable package from audit
273
+ docker-compose exec backend pip-audit
274
+
275
+ # 2. Update ONLY the vulnerable package in pyproject.toml
276
+ # Example: If Pillow has CVE, update Pillow>=10.4.0 to Pillow>=10.5.0
277
+
278
+ # 3. Regenerate requirements.txt
279
+ cd backend && ./update-requirements.sh
280
+
281
+ # 4. Rebuild and test
282
+ docker-compose build backend
283
+ docker-compose exec backend pytest jewelry_portfolio/ -x
284
+
285
+ # 5. Commit immediately if tests pass
286
+ git add backend/pyproject.toml backend/requirements.txt
287
+ git commit -m "security: update Pillow to fix CVE-XXXX-YYYY"
288
+ ```
289
+
290
+ ### Frontend Vulnerabilities
291
+
292
+ ```bash
293
+ # 1. Audit and identify vulnerable packages
294
+ npm audit
295
+
296
+ # 2. Try automatic fix first
297
+ npm audit fix
298
+
299
+ # 3. If that doesn't work, update manually
300
+ npm install vulnerable-package@latest
301
+
302
+ # 4. Test immediately
303
+ npm run type-check && npm run test:run
304
+
305
+ # 5. Commit if tests pass
306
+ git add package.json package-lock.json
307
+ git commit -m "security: update axios to fix CVE-XXXX-YYYY"
308
+ ```
309
+
310
+ ## Testing Matrix
311
+
312
+ **After ANY dependency update, run ALL relevant tests:**
313
+
314
+ | Changed | Commands | Required |
315
+ |---------|----------|----------|
316
+ | **Backend dependencies** | `docker-compose exec backend pytest jewelry_portfolio/ -x` | ✅ MANDATORY |
317
+ | **Django/DRF** | Regenerate OpenAPI schema → TypeScript client | ✅ If major update |
318
+ | **Frontend dependencies** | `cd frontend && npm run type-check` | ✅ MANDATORY |
319
+ | **Frontend logic packages** | `cd frontend && npm run test:run` | ✅ MANDATORY |
320
+ | **Vue/TypeScript** | `cd frontend && npm run build` | ✅ MANDATORY |
321
+ | **Any dependency** | Manual smoke testing in browser | ✅ MANDATORY |
322
+
323
+ ## Update Categories & Priority
324
+
325
+ ### High Priority (Update Immediately)
326
+
327
+ - **Security vulnerabilities**: Any CVE with severity ≥ 7.0
328
+ - **Critical bug fixes**: Data loss, auth bypass, XSS, CSRF
329
+ - **Zero-day exploits**: Update same day if possible
330
+
331
+ ### Medium Priority (Update Monthly/Quarterly)
332
+
333
+ - **Minor version updates**: New features, performance improvements
334
+ - **Patch updates**: Bug fixes without breaking changes
335
+ - **DevDependencies**: Testing tools, build tools
336
+
337
+ ### Low Priority (Update Before Major Releases)
338
+
339
+ - **Major version updates**: Breaking changes, require code migration
340
+ - **Experimental features**: Alpha/beta packages
341
+ - **Optional dependencies**: Nice-to-have features
342
+
343
+ ## Common Pitfalls & Solutions
344
+
345
+ ### ❌ Pitfall 1: Updating Everything at Once
346
+
347
+ **Problem**: Can't identify which update broke tests
348
+
349
+ **Solution**:
350
+ ```bash
351
+ # ✅ Update in stages
352
+ git commit -m "deps: update backend security packages"
353
+ git commit -m "deps: update backend dev tools"
354
+ git commit -m "deps: update frontend runtime packages"
355
+ git commit -m "deps: update frontend dev tools"
356
+ ```
357
+
358
+ ### ❌ Pitfall 2: Skipping Tests
359
+
360
+ **Problem**: Broken code reaches production
361
+
362
+ **Solution**: ALWAYS run full test suite:
363
+ ```bash
364
+ # Backend
365
+ docker-compose exec backend pytest jewelry_portfolio/ -x
366
+
367
+ # Frontend
368
+ cd frontend && npm run type-check && npm run test:run && npm run build
369
+ ```
370
+
371
+ ### ❌ Pitfall 3: Not Reading Changelogs
372
+
373
+ **Problem**: Breaking changes surprise you in production
374
+
375
+ **Solution**: For major updates, read migration guides:
376
+ ```bash
377
+ # Example: Vue 3.4 → 3.5
378
+ # 1. Read: https://github.com/vuejs/core/blob/main/CHANGELOG.md
379
+ # 2. Search for "BREAKING" or "Migration"
380
+ # 3. Update code before updating dependency
381
+ ```
382
+
383
+ ### ❌ Pitfall 4: Forgetting Docker Rebuild
384
+
385
+ **Problem**: Old packages still in container, tests pass locally but fail in CI
386
+
387
+ **Solution**:
388
+ ```bash
389
+ # ✅ Always rebuild after backend updates
390
+ docker-compose build backend
391
+ docker-compose up -d backend
392
+ ```
393
+
394
+ ### ❌ Pitfall 5: Using Exact Versions
395
+
396
+ **Problem**: Can't get security patches without manual updates
397
+
398
+ **Solution**:
399
+ ```toml
400
+ # ❌ DON'T - locks to exact version
401
+ Django==5.1.0
402
+
403
+ # ✅ DO - allows patches
404
+ Django>=5.1.0
405
+
406
+ # ✅ DO - allows minor updates
407
+ Django>=5.1.0,<6.0.0
408
+ ```
409
+
410
+ ## Rollback Procedure
411
+
412
+ **If updates break critical functionality:**
413
+
414
+ ### Quick Rollback (Last Commit)
415
+
416
+ ```bash
417
+ # Rollback all changes
418
+ git reset --hard HEAD~1
419
+
420
+ # Reinstall old dependencies
421
+ docker-compose build backend # Backend
422
+ cd frontend && npm install # Frontend
423
+
424
+ # Verify rollback worked
425
+ docker-compose exec backend pytest jewelry_portfolio/ -x
426
+ cd frontend && npm run test:run
427
+ ```
428
+
429
+ ### Selective Rollback (Specific Files)
430
+
431
+ ```bash
432
+ # Rollback only backend
433
+ git checkout HEAD~1 -- backend/pyproject.toml backend/requirements.txt
434
+ cd backend && ./update-requirements.sh
435
+ docker-compose build backend
436
+
437
+ # Rollback only frontend
438
+ git checkout HEAD~1 -- frontend/package.json frontend/package-lock.json
439
+ cd frontend && npm install
440
+ ```
441
+
442
+ ## Post-Update Checklist
443
+
444
+ After successful updates:
445
+
446
+ - [ ] All tests passing (backend + frontend)
447
+ - [ ] Manual smoke testing completed
448
+ - [ ] No console errors in browser
449
+ - [ ] No build warnings
450
+ - [ ] OpenAPI schema regenerated (if backend updated)
451
+ - [ ] TypeScript client regenerated (if schema changed)
452
+ - [ ] Update CODEBASE_CHANGELOG.md with session entry
453
+ - [ ] Commit changes with descriptive message
454
+
455
+ ## Commit Message Format
456
+
457
+ ```bash
458
+ # Security updates
459
+ git commit -m "security: update Django to 5.1.4 (CVE-2024-XXXXX)"
460
+
461
+ # Regular updates
462
+ git commit -m "deps: update backend dependencies (Django 5.1.4, DRF 3.15.3)"
463
+ git commit -m "deps: update frontend dependencies (Vue 3.5.26, Vite 7.3.0)"
464
+
465
+ # Breaking changes
466
+ git commit -m "deps!: update Vue to 3.5.0 (breaking: new Composition API)"
467
+ ```
468
+
469
+ ## Documentation Requirements
470
+
471
+ **Update CODEBASE_CHANGELOG.md after significant updates:**
472
+
473
+ ```markdown
474
+ ## Session: Dependency Updates - Backend Security (Jan 17, 2026)
475
+
476
+ **Goal**: Update Django and Pillow to fix security vulnerabilities
477
+
478
+ **Changes**:
479
+ - [backend/pyproject.toml](backend/pyproject.toml): Django 5.1.0 → 5.1.4 (CVE-2024-XXXXX)
480
+ - [backend/pyproject.toml](backend/pyproject.toml): Pillow 10.4.0 → 10.5.0 (CVE-2024-YYYYY)
481
+ - [backend/requirements.txt](backend/requirements.txt): Regenerated with pip-compile
482
+
483
+ **Validation**:
484
+ - ✅ Backend tests: 156 passed
485
+ - ✅ Manual admin panel check: OK
486
+ - ✅ API endpoints: OK
487
+
488
+ **Key Learning**: Django 5.1.4 changes cookie handling - required updating JWT settings
489
+ ```
490
+
491
+ ## Monthly Maintenance Workflow
492
+
493
+ **Recommended schedule: First Monday of each month**
494
+
495
+ ```bash
496
+ # 1. Create update branch
497
+ git checkout -b chore/dependency-updates-$(date +%Y-%m)
498
+
499
+ # 2. Backend audit & update
500
+ docker-compose exec backend pip-audit
501
+ # Update pyproject.toml
502
+ cd backend && ./update-requirements.sh
503
+ docker-compose build backend
504
+ docker-compose exec backend pytest jewelry_portfolio/ -x
505
+ git commit -m "deps: update backend dependencies"
506
+
507
+ # 3. Frontend audit & update
508
+ cd frontend
509
+ npm audit
510
+ npm outdated
511
+ ncu -u # Update package.json
512
+ npm install
513
+ npm run type-check && npm run test:run && npm run build
514
+ git commit -m "deps: update frontend dependencies"
515
+
516
+ # 4. Manual testing
517
+ # Test all critical user flows
518
+
519
+ # 5. Update changelog
520
+ # Add session entry to CODEBASE_CHANGELOG.md
521
+ git commit -m "docs: update changelog for dependency updates"
522
+
523
+ # 6. Create PR
524
+ git push origin chore/dependency-updates-$(date +%Y-%m)
525
+ ```
526
+
527
+ ## Integration with Other Skills
528
+
529
+ - **Before updating**: Read [developer-checklist](../developer-checklist/SKILL.md) for test requirements
530
+ - **After breaking changes**: May need [feature-implementation](../feature-implementation/SKILL.md) to update code
531
+ - **For refactoring after updates**: Use [code-refactoring](../code-refactoring/SKILL.md)
532
+
533
+ ## Related Files
534
+
535
+ - [backend/DEPENDENCIES.md](../../../backend/DEPENDENCIES.md) - Backend dependency workflow
536
+ - [CODEBASE_ESSENTIALS.md](../../../CODEBASE_ESSENTIALS.md) - Current stack snapshot
537
+ - [CODEBASE_CHANGELOG.md](../../../CODEBASE_CHANGELOG.md) - Session history
538
+ - [.github/skills/developer-checklist/SKILL.md](../developer-checklist/SKILL.md) - Testing requirements
539
+
540
+ ## Quick Reference Commands
541
+
542
+ ```bash
543
+ # Backend
544
+ cd backend && ./update-requirements.sh
545
+ docker-compose build backend
546
+ docker-compose exec backend pytest jewelry_portfolio/ -x
547
+
548
+ # Frontend
549
+ cd frontend
550
+ npm audit
551
+ npm outdated
552
+ ncu -u && npm install
553
+ npm run type-check && npm run test:run && npm run build
554
+
555
+ # OpenAPI sync (if backend updated)
556
+ docker-compose exec backend python manage.py spectacular --file openapi_schema.json
557
+ cd frontend && npx @openapitools/openapi-generator-cli generate \
558
+ -i ../backend/openapi_schema.json \
559
+ -g typescript-fetch \
560
+ -o src/api/generated
561
+ ```