[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill-bb2f1615-ad98-4e6e-b6bc-36ece8cf35d8":3,"$fDdaFx_dwY7I9MFQP4fx81PV2UFBYYxJdCQWyU9qpNwM":43},{"id":4,"title":5,"description":6,"categoryId":7,"moduleId":8,"tags":9,"prompt":10,"icon":11,"source":12,"sourceUrl":13,"authorId":14,"authorName":15,"isPublic":16,"stars":17,"runs":18,"createdAt":19,"updatedAt":19,"module":20,"category":27,"packages":34},"bb2f1615-ad98-4e6e-b6bc-36ece8cf35d8","dependency-upgrade","掌握主依赖版本升级、兼容性分析、分阶段升级策略和全面测试方法。","cat_life_career","mod_other","sickn33,other","---\nname: dependency-upgrade\ndescription: \"Master major dependency version upgrades, compatibility analysis, staged upgrade strategies, and comprehensive testing approaches.\"\nrisk: critical\nsource: community\ndate_added: \"2026-02-27\"\n---\n\n# Dependency Upgrade\n\nMaster major dependency version upgrades, compatibility analysis, staged upgrade strategies, and comprehensive testing approaches.\n\n## Do not use this skill when\n\n- The task is unrelated to dependency upgrade\n- You need a different domain or tool outside this scope\n\n## Instructions\n\n- Clarify goals, constraints, and required inputs.\n- Apply relevant best practices and validate outcomes.\n- Provide actionable steps and verification.\n- If detailed examples are required, open `resources\u002Fimplementation-playbook.md`.\n\n## Use this skill when\n\n- Upgrading major framework versions\n- Updating security-vulnerable dependencies\n- Modernizing legacy dependencies\n- Resolving dependency conflicts\n- Planning incremental upgrade paths\n- Testing compatibility matrices\n- Automating dependency updates\n\n## Semantic Versioning Review\n\n```\nMAJOR.MINOR.PATCH (e.g., 2.3.1)\n\nMAJOR: Breaking changes\nMINOR: New features, backward compatible\nPATCH: Bug fixes, backward compatible\n\n^2.3.1 = >=2.3.1 \u003C3.0.0 (minor updates)\n~2.3.1 = >=2.3.1 \u003C2.4.0 (patch updates)\n2.3.1 = exact version\n```\n\n## Dependency Analysis\n\n### Audit Dependencies\n```bash\n# npm\nnpm outdated\nnpm audit\nnpm audit fix\n\n# yarn\nyarn outdated\nyarn audit\n\n# Check for major updates\nnpx npm-check-updates\nnpx npm-check-updates -u  # Update package.json\n```\n\n### Analyze Dependency Tree\n```bash\n# See why a package is installed\nnpm ls package-name\nyarn why package-name\n\n# Find duplicate packages\nnpm dedupe\nyarn dedupe\n\n# Visualize dependencies\nnpx madge --image graph.png src\u002F\n```\n\n## Compatibility Matrix\n\n```javascript\n\u002F\u002F compatibility-matrix.js\nconst compatibilityMatrix = {\n  'react': {\n    '16.x': {\n      'react-dom': '^16.0.0',\n      'react-router-dom': '^5.0.0',\n      '@testing-library\u002Freact': '^11.0.0'\n    },\n    '17.x': {\n      'react-dom': '^17.0.0',\n      'react-router-dom': '^5.0.0 || ^6.0.0',\n      '@testing-library\u002Freact': '^12.0.0'\n    },\n    '18.x': {\n      'react-dom': '^18.0.0',\n      'react-router-dom': '^6.0.0',\n      '@testing-library\u002Freact': '^13.0.0'\n    }\n  }\n};\n\nfunction checkCompatibility(packages) {\n  \u002F\u002F Validate package versions against matrix\n}\n```\n\n## Staged Upgrade Strategy\n\n### Phase 1: Planning\n```bash\n# 1. Identify current versions\nnpm list --depth=0\n\n# 2. Check for breaking changes\n# Read CHANGELOG.md and MIGRATION.md\n\n# 3. Create upgrade plan\necho \"Upgrade order:\n1. TypeScript\n2. React\n3. React Router\n4. Testing libraries\n5. Build tools\" > UPGRADE_PLAN.md\n```\n\n### Phase 2: Incremental Updates\n```bash\n# Don't upgrade everything at once!\n\n# Step 1: Update TypeScript\nnpm install typescript@latest\n\n# Test\nnpm run test\nnpm run build\n\n# Step 2: Update React (one major version at a time)\nnpm install react@17 react-dom@17\n\n# Test again\nnpm run test\n\n# Step 3: Continue with other packages\nnpm install react-router-dom@6\n\n# And so on...\n```\n\n### Phase 3: Validation\n```javascript\n\u002F\u002F tests\u002Fcompatibility.test.js\ndescribe('Dependency Compatibility', () => {\n  it('should have compatible React versions', () => {\n    const reactVersion = require('react\u002Fpackage.json').version;\n    const reactDomVersion = require('react-dom\u002Fpackage.json').version;\n\n    expect(reactVersion).toBe(reactDomVersion);\n  });\n\n  it('should not have peer dependency warnings', () => {\n    \u002F\u002F Run npm ls and check for warnings\n  });\n});\n```\n\n## Breaking Change Handling\n\n### Identifying Breaking Changes\n```bash\n# Use changelog parsers\nnpx changelog-parser react 16.0.0 17.0.0\n\n# Or manually check\ncurl https:\u002F\u002Fraw.githubusercontent.com\u002Ffacebook\u002Freact\u002Fmain\u002FCHANGELOG.md\n```\n\n### Codemod for Automated Fixes\n```bash\n# React upgrade codemods\nnpx react-codeshift \u003Ctransform> \u003Cpath>\n\n# Example: Update lifecycle methods\nnpx react-codeshift \\\n  --parser tsx \\\n  --transform react-codeshift\u002Ftransforms\u002Frename-unsafe-lifecycles.js \\\n  src\u002F\n```\n\n### Custom Migration Script\n```javascript\n\u002F\u002F migration-script.js\nconst fs = require('fs');\nconst glob = require('glob');\n\nglob('src\u002F**\u002F*.tsx', (err, files) => {\n  files.forEach(file => {\n    let content = fs.readFileSync(file, 'utf8');\n\n    \u002F\u002F Replace old API with new API\n    content = content.replace(\n      \u002FcomponentWillMount\u002Fg,\n      'UNSAFE_componentWillMount'\n    );\n\n    \u002F\u002F Update imports\n    content = content.replace(\n      \u002Fimport { Component } from 'react'\u002Fg,\n      \"import React, { Component } from 'react'\"\n    );\n\n    fs.writeFileSync(file, content);\n  });\n});\n```\n\n## Testing Strategy\n\n### Unit Tests\n```javascript\n\u002F\u002F Ensure tests pass before and after upgrade\nnpm run test\n\n\u002F\u002F Update test utilities if needed\nnpm install @testing-library\u002Freact@latest\n```\n\n### Integration Tests\n```javascript\n\u002F\u002F tests\u002Fintegration\u002Fapp.test.js\ndescribe('App Integration', () => {\n  it('should render without crashing', () => {\n    render(\u003CApp \u002F>);\n  });\n\n  it('should handle navigation', () => {\n    const { getByText } = render(\u003CApp \u002F>);\n    fireEvent.click(getByText('Navigate'));\n    expect(screen.getByText('New Page')).toBeInTheDocument();\n  });\n});\n```\n\n### Visual Regression Tests\n```javascript\n\u002F\u002F visual-regression.test.js\ndescribe('Visual Regression', () => {\n  it('should match snapshot', () => {\n    const { container } = render(\u003CApp \u002F>);\n    expect(container.firstChild).toMatchSnapshot();\n  });\n});\n```\n\n### E2E Tests\n```javascript\n\u002F\u002F cypress\u002Fe2e\u002Fapp.cy.js\ndescribe('E2E Tests', () => {\n  it('should complete user flow', () => {\n    cy.visit('\u002F');\n    cy.get('[data-testid=\"login\"]').click();\n    cy.get('input[name=\"email\"]').type('user@example.com');\n    cy.get('button[type=\"submit\"]').click();\n    cy.url().should('include', '\u002Fdashboard');\n  });\n});\n```\n\n## Automated Dependency Updates\n\n### Renovate Configuration\n```json\n\u002F\u002F renovate.json\n{\n  \"extends\": [\"config:base\"],\n  \"packageRules\": [\n    {\n      \"matchUpdateTypes\": [\"minor\", \"patch\"],\n      \"automerge\": true\n    },\n    {\n      \"matchUpdateTypes\": [\"major\"],\n      \"automerge\": false,\n      \"labels\": [\"major-update\"]\n    }\n  ],\n  \"schedule\": [\"before 3am on Monday\"],\n  \"timezone\": \"America\u002FNew_York\"\n}\n```\n\n### Dependabot Configuration\n```yaml\n# .github\u002Fdependabot.yml\nversion: 2\nupdates:\n  - package-ecosystem: \"npm\"\n    directory: \"\u002F\"\n    schedule:\n      interval: \"weekly\"\n    open-pull-requests-limit: 5\n    reviewers:\n      - \"team-leads\"\n    commit-message:\n      prefix: \"chore\"\n      include: \"scope\"\n```\n\n## Rollback Plan\n\n```javascript\n\u002F\u002F rollback.sh\n#!\u002Fbin\u002Fbash\n\n# Save current state\ngit stash\ngit checkout -b upgrade-branch\n\n# Attempt upgrade\nnpm install package@latest\n\n# Run tests\nif npm run test; then\n  echo \"Upgrade successful\"\n  git add package.json package-lock.json\n  git commit -m \"chore: upgrade package\"\nelse\n  echo \"Upgrade failed, rolling back\"\n  git checkout main\n  git branch -D upgrade-branch\n  npm install  # Restore from package-lock.json\nfi\n```\n\n## Common Upgrade Patterns\n\n### Lock File Management\n```bash\n# npm\nnpm install --package-lock-only  # Update lock file only\nnpm ci  # Clean install from lock file\n\n# yarn\nyarn install --frozen-lockfile  # CI mode\nyarn upgrade-interactive  # Interactive upgrades\n```\n\n### Peer Dependency Resolution\n```bash\n# npm 7+: strict peer dependencies\nnpm install --legacy-peer-deps  # Ignore peer deps\n\n# npm 8+: override peer dependencies\nnpm install --force\n```\n\n### Workspace Upgrades\n```bash\n# Update all workspace packages\nnpm install --workspaces\n\n# Update specific workspace\nnpm install package@latest --workspace=packages\u002Fapp\n```\n\n## Resources\n\n- **references\u002Fsemver.md**: Semantic versioning guide\n- **references\u002Fcompatibility-matrix.md**: Common compatibility issues\n- **references\u002Fstaged-upgrades.md**: Incremental upgrade strategies\n- **references\u002Ftesting-strategy.md**: Comprehensive testing approaches\n- **assets\u002Fupgrade-checklist.md**: Step-by-step checklist\n- **assets\u002Fcompatibility-matrix.csv**: Version compatibility table\n- **scripts\u002Faudit-dependencies.sh**: Dependency audit script\n\n## Best Practices\n\n1. **Read Changelogs**: Understand what changed\n2. **Upgrade Incrementally**: One major version at a time\n3. **Test Thoroughly**: Unit, integration, E2E tests\n4. **Check Peer Dependencies**: Resolve conflicts early\n5. **Use Lock Files**: Ensure reproducible installs\n6. **Automate Updates**: Use Renovate or Dependabot\n7. **Monitor**: Watch for runtime errors post-upgrade\n8. **Document**: Keep upgrade notes\n\n## Upgrade Checklist\n\n```markdown\nPre-Upgrade:\n- [ ] Review current dependency versions\n- [ ] Read changelogs for breaking changes\n- [ ] Create feature branch\n- [ ] Backup current state (git tag)\n- [ ] Run full test suite (baseline)\n\nDuring Upgrade:\n- [ ] Upgrade one dependency at a time\n- [ ] Update peer dependencies\n- [ ] Fix TypeScript errors\n- [ ] Update tests if needed\n- [ ] Run test suite after each upgrade\n- [ ] Check bundle size impact\n\nPost-Upgrade:\n- [ ] Full regression testing\n- [ ] Performance testing\n- [ ] Update documentation\n- [ ] Deploy to staging\n- [ ] Monitor for errors\n- [ ] Deploy to production\n```\n\n## Common Pitfalls\n\n- Upgrading all dependencies at once\n- Not testing after each upgrade\n- Ignoring peer dependency warnings\n- Forgetting to update lock file\n- Not reading breaking change notes\n- Skipping major versions\n- Not having rollback plan\n\n## Limitations\n- Use this skill only when the task clearly matches the scope described above.\n- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.\n- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.\n","","imported","https:\u002F\u002Fgithub.com\u002Fsickn33\u002Fantigravity-awesome-skills","user_system_seed","SkillOPIC",true,137,1061,"2026-05-16 13:14:58",{"id":8,"name":21,"slug":22,"icon":23,"description":24,"sort":25,"createdAt":26},"其他","other","mdi-page-next-outline","其他类型Skill",5,"2026-05-16 12:53:40",{"id":7,"name":28,"slug":29,"icon":30,"description":31,"moduleId":8,"sort":32,"skillCount":33,"createdAt":26},"职场发展","career","mdi-briefcase-outline","面试准备、简历优化、职业规划",4,575,[35],{"id":36,"skillId":4,"version":37,"fileName":38,"fileSize":39,"filePath":40,"fileHash":41,"manifest":42,"createdAt":19},"01df0049-ffac-4b17-862b-59c866bcaaea","1.0.0","dependency-upgrade.zip",3943,"uploads\u002Fskills\u002Fbb2f1615-ad98-4e6e-b6bc-36ece8cf35d8\u002Fdependency-upgrade.zip","36a90b2e2587c8623a52e1cba33d248c85d8e22542cf1a1f2e9078f907f2e6e2","[{\"path\":\"SKILL.md\",\"isDirectory\":false,\"size\":9735}]",{"code":44,"message":45,"data":46},200,"success",{"items":47,"stats":48,"page":51},[],{"averageRating":49,"totalRatings":49,"ratingCounts":50},0,[49,49,49,49,49],{"limit":52,"offset":49,"hasMore":53,"nextOffset":52,"ratedOnly":16},15,false]