dependency-update
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseDependency Update Skill
依赖更新技能
Safe and systematic dependency updates with vulnerability management, license checking, and rollback planning.
具备漏洞管理、许可证检查和回滚规划能力的安全系统化依赖更新方案。
When to Use
适用场景
| Trigger | Priority | Description |
|---|---|---|
| Security Vulnerability | Critical | Known CVE in dependency |
| Monthly Maintenance | High | Regular update cycle |
| Major Version | Medium | New major version available |
| Pre-Release | High | Before production deployments |
| Breaking Bug | Critical | Bug in current dependency |
| 触发条件 | 优先级 | 说明 |
|---|---|---|
| 安全漏洞 | 最高 | 依赖中存在已知CVE漏洞 |
| 月度维护 | 高 | 常规更新周期 |
| 主版本发布 | 中 | 有新的主版本可用 |
| 预发布阶段 | 高 | 生产环境部署前 |
| 阻断性Bug | 最高 | 当前依赖存在严重Bug |
Update Strategy
更新策略
Update Types
更新类型
| Type | Risk | Frequency | Testing |
|---|---|---|---|
| Patch (x.x.1) | Low | Weekly/Auto | Basic |
| Minor (x.1.0) | Low-Medium | Monthly | Standard |
| Major (1.0.0) | High | Quarterly | Comprehensive |
| 类型 | 风险 | 更新频率 | 测试要求 |
|---|---|---|---|
| 补丁版本 (x.x.1) | 低 | 每周/自动 | 基础测试 |
| 次版本 (x.1.0) | 低-中 | 每月 | 标准测试 |
| 主版本 (1.0.0) | 高 | 每季度 | 全面测试 |
Semantic Versioning
语义化版本规范
MAJOR.MINOR.PATCH
│ │ │
│ │ └── Bug fixes (backward compatible)
│ └──────── New features (backward compatible)
└────────────── Breaking changesMAJOR.MINOR.PATCH
│ │ │
│ │ └── Bug修复(向后兼容)
│ └──────── 新增功能(向后兼容)
└────────────── 不兼容的破坏性变更Prerequisites
前置条件
Before starting:
- All tests passing
- Clean git working directory
- Recent backup/checkpoint
- Time for testing and potential rollback
- Access to changelogs/release notes
开始更新前:
- 所有测试用例通过
- git工作目录干净
- 近期有备份/检查点
- 预留测试和潜在回滚的时间
- 有权限查看变更日志/发布说明
Update Process
更新流程
Phase 1: Audit Dependencies
↓
Phase 2: Check Vulnerabilities
↓
Phase 3: Check License Compatibility
↓
Phase 4: Plan Updates
↓
Phase 5: Execute Updates
↓
Phase 6: Test & Validate
↓
Phase 7: Document & Deploy第一阶段:依赖审计
↓
第二阶段:漏洞检查
↓
第三阶段:许可证兼容性检查
↓
第四阶段:更新规划
↓
第五阶段:执行更新
↓
第六阶段:测试与验证
↓
第七阶段:文档记录与部署Phase 1: Audit Dependencies
第一阶段:依赖审计
List outdated dependencies using ecosystem-specific tools:
bash
undefined使用对应生态的工具列出过时依赖:
bash
undefinedNode.js
Node.js
npm outdated
npm outdated
Python
Python
pip list --outdated
pip list --outdated
Go
Go
go list -u -m all
go list -u -m all
Rust
Rust
cargo outdated
cargo outdated
Ruby
Ruby
bundle outdated
Create update inventory prioritizing direct dependencies over transitive ones.
---bundle outdated
创建更新清单,优先处理直接依赖,再处理传递依赖。
---Phase 2: Check Vulnerabilities
第二阶段:漏洞检查
Run security audits:
bash
undefined执行安全审计:
bash
undefinedNode.js: npm audit
Node.js: npm audit
Python: pip-audit or safety check
Python: pip-audit 或 safety check
Go: govulncheck ./...
Go: govulncheck ./...
Rust: cargo audit
Rust: cargo audit
Ruby: bundle audit check
Ruby: bundle audit check
Prioritize by severity: Critical (hours) → High (days) → Moderate (weeks) → Low (monthly).
---
按严重程度优先级处理:最高(小时级响应)→ 高(天级响应)→ 中(周级响应)→ 低(月度处理)。
---Phase 3: Check License Compatibility
第三阶段:许可证兼容性检查
Check licenses before adding dependencies:
bash
undefined新增依赖前检查许可证:
bash
undefinedNode.js: npx license-checker --summary
Node.js: npx license-checker --summary
Python: pip-licenses
Python: pip-licenses
Avoid: GPL-3.0, AGPL-3.0, SSPL, Unlicensed (require legal review).
Safe: MIT, Apache-2.0, BSD, ISC.
---
避免使用:GPL-3.0、AGPL-3.0、SSPL、无许可证(需要法务审核)。
安全许可证:MIT、Apache-2.0、BSD、ISC。
---Phase 4: Plan Updates
第四阶段:更新规划
Priority: Security → Patches → Minor → Major
Update strategies:
- Individual: Major updates, risky dependencies
- Batched: Patches and minor updates together
- All at once: Only for fresh projects with comprehensive tests
Create update plan grouping by priority and risk level.
优先级:安全修复 → 补丁版本 → 次版本 → 主版本
更新策略:
- 单独更新:主版本更新、高风险依赖
- 批量更新:补丁版本和次版本一起更新
- 全量更新:仅适用于有全面测试覆盖的新项目
按优先级和风险等级分组制定更新计划。
Phase 5: Execute Updates
第五阶段:执行更新
Create branch:
git checkout -b chore/dependency-updates-YYYY-MMUpdate commands by ecosystem:
bash
undefined创建分支:
git checkout -b chore/dependency-updates-YYYY-MM不同生态的更新命令:
bash
undefinedIndividual: npm install pkg@ver | pip install pkg==ver | go get pkg@ver
单独更新:npm install pkg@ver | pip install pkg==ver | go get pkg@ver
Batch: npm update | pip install -U pkg1 pkg2 | go get -u ./... | cargo update
批量更新:npm update | pip install -U pkg1 pkg2 | go get -u ./... | cargo update
Verify lock files updated. Commit with descriptive messages following conventional commits.
---
确认锁定文件已更新,按照约定式提交规范编写清晰的提交信息。
---Phase 6: Test & Validate
第六阶段:测试与验证
Run comprehensive validation:
bash
undefined执行全面验证:
bash
undefinedTests: npm test | pytest | go test ./... | cargo test
测试:npm test | pytest | go test ./... | cargo test
Types: npm run typecheck | mypy . | cargo check
类型检查:npm run typecheck | mypy . | cargo check
Lint: npm run lint | ruff check . | golangci-lint run | cargo clippy
代码规范检查:npm run lint | ruff check . | golangci-lint run | cargo clippy
Build: npm run build | go build ./... | cargo build --release
构建:npm run build | go build ./... | cargo build --release
For major updates, verify critical paths manually.
---
主版本更新需要手动验证核心路径功能正常。
---Phase 7: Document & Deploy
第七阶段:文档记录与部署
Create PR documenting:
- Security fixes with CVE numbers
- Package updates table
- Breaking changes addressed
- Testing checklist completed
- Rollback plan
Deploy: Dev → Staging → Production (with validation at each stage).
创建PR,记录以下内容:
- 带CVE编号的安全修复
- 包更新明细表格
- 已处理的破坏性变更
- 已完成的测试检查清单
- 回滚计划
部署流程:开发环境 → 预发环境 → 生产环境(每个阶段都需验证)。
Rollback Procedures
回滚流程
If Tests Fail
测试失败时
bash
undefinedbash
undefinedReset to before updates
重置到更新前状态
git checkout package.json package-lock.json
npm install
undefinedgit checkout package.json package-lock.json
npm install
undefinedIf Production Issues
生产环境出现问题时
bash
undefinedbash
undefinedRevert the commit
回滚提交
git revert <update-commit-hash>
npm install
git revert <update-commit-hash>
npm install
Deploy revert
部署回滚版本
undefinedundefinedPin Problematic Dependency
锁定有问题的依赖版本
json
// package.json
{
"dependencies": {
"problematic-package": "1.2.3" // Pin to working version
},
"resolutions": {
"problematic-package": "1.2.3" // Force transitive deps
}
}json
// package.json
{
"dependencies": {
"problematic-package": "1.2.3" // 锁定到可用版本
},
"resolutions": {
"problematic-package": "1.2.3" // 强制传递依赖使用该版本
}
}Quick Reference
快速参考
Commands by Language
不同语言对应命令
| Task | Node.js | Python | Go | Rust |
|---|---|---|---|---|
| List outdated | | | | |
| Security audit | | | | |
| Update all | | | | |
| Update one | | | | |
| 任务 | Node.js | Python | Go | Rust |
|---|---|---|---|---|
| 列出过时依赖 | | | | |
| 安全审计 | | | | |
| 全量更新 | | | | |
| 单个更新 | | | | |
Checklist
检查清单
Pre-Update
更新前
- Tests passing
- Clean git state
- Outdated list generated
- Vulnerabilities checked
- Licenses checked
- Update plan created
- 所有测试通过
- git状态干净
- 已生成过时依赖列表
- 已完成漏洞检查
- 已完成许可证检查
- 已制定更新计划
During Update
更新中
- Branch created
- Updates applied
- Lock files updated
- Commits atomic and descriptive
- 已创建更新分支
- 已执行更新
- 锁定文件已更新
- 提交原子化且描述清晰
Post-Update
更新后
- All tests pass
- Type checks pass
- Lint passes
- Build succeeds
- Manual testing done
- PR created
- Rollback plan ready
- 所有测试通过
- 类型检查通过
- 代码规范检查通过
- 构建成功
- 完成手动测试
- 已创建PR
- 回滚计划已准备
Related Workflows
相关工作流
- security-audit.md - Includes vulnerability scanning
- code-review.md - Review updated code
- troubleshooting.md - If updates cause issues
- security-audit.md - 包含漏洞扫描相关内容
- code-review.md - 审核更新后的代码
- troubleshooting.md - 处理更新导致的问题
Extended Resources
扩展资源
For detailed per-ecosystem commands, verbose examples, and automation configuration, see:
- references/process.md - Comprehensive ecosystem-specific processes
如需查看各生态详细命令、完整示例和自动化配置,请参考:
- references/process.md - 各生态专属的完整更新流程