|
1 | 1 | # Update Dependencies |
2 | 2 |
|
3 | | -You are about to update the dependencies of the project. Please follow these steps: |
4 | | - |
5 | | -1. **Create a new branch** for the update, e.g., `chore/update-dependencies`. |
6 | | -2. **Update the dependencies** in `package.json` to their latest versions. |
7 | | -3. **Run the installation** command to update the `pnpm-lock.yaml` file. |
8 | | -4. **Test the project** to ensure that everything works with the updated dependencies. |
9 | | -5. **Commit the changes** making sure that the pre-commit hook passes without warnings or errors. |
10 | | -6. **Push the branch** to the remote repository. |
11 | | -7. **Create a pull request** to trigger the CI/CD pipeline. |
12 | | -8. **Wait for the CI/CD pipeline to complete** successfully. Ensure that all tests pass and the build is successful. |
13 | | -9. **Merge the pull request** into the main branch once the CI/CD pipeline has passed. The merge should be done using the "Squash and merge" option to keep the commit history clean and the branch should be deleted after merging. |
| 3 | +You are about to update the dependencies of the project. This command helps maintain the project's dependencies while adhering to the established CI/CD workflow and changeset requirements. |
| 4 | + |
| 5 | +## Workflow Steps |
| 6 | + |
| 7 | +### 1. Create a Feature Branch |
| 8 | + |
| 9 | +Create a new branch following the naming convention: |
| 10 | + |
| 11 | +```bash |
| 12 | +git checkout -b chore/update-dependencies-<date> |
| 13 | +# Example: chore/update-dependencies-2024-01 |
| 14 | +``` |
| 15 | + |
| 16 | +### 2. Update Dependencies |
| 17 | + |
| 18 | +#### For Production Dependencies: |
| 19 | + |
| 20 | +```bash |
| 21 | +# Check outdated packages |
| 22 | +pnpm outdated |
| 23 | + |
| 24 | +# Update all dependencies to latest |
| 25 | +pnpm update --latest |
| 26 | + |
| 27 | +# Or update specific packages |
| 28 | +pnpm update <package-name> --latest |
| 29 | +``` |
| 30 | + |
| 31 | +#### For Dev Dependencies: |
| 32 | + |
| 33 | +```bash |
| 34 | +# Update dev dependencies |
| 35 | +pnpm update --latest --dev |
| 36 | +``` |
| 37 | + |
| 38 | +### 3. Install and Lock Dependencies |
| 39 | + |
| 40 | +```bash |
| 41 | +# Ensure pnpm-lock.yaml is updated |
| 42 | +pnpm install |
| 43 | + |
| 44 | +# Deduplicate dependencies if needed |
| 45 | +pnpm dedupe |
| 46 | +``` |
| 47 | + |
| 48 | +### 4. Test the Updates |
| 49 | + |
| 50 | +Run the full verification suite to ensure compatibility: |
| 51 | + |
| 52 | +```bash |
| 53 | +# Run all checks (audit, typecheck, lint, format, test) |
| 54 | +pnpm verify |
| 55 | + |
| 56 | +# Run specific checks if needed |
| 57 | +pnpm test |
| 58 | +pnpm typecheck |
| 59 | +pnpm lint |
| 60 | +``` |
| 61 | + |
| 62 | +### 5. Create a Changeset |
| 63 | + |
| 64 | +**IMPORTANT**: The CI/CD pipeline requires changesets for all changes. |
| 65 | + |
| 66 | +#### For Dev-Only Dependency Updates: |
| 67 | + |
| 68 | +```bash |
| 69 | +# Create an empty changeset (no version bump needed) |
| 70 | +pnpm changeset --empty |
| 71 | + |
| 72 | +# In the changeset file, document: |
| 73 | +# - Which dependencies were updated |
| 74 | +# - Why they were updated |
| 75 | +# - Any breaking changes to be aware of |
| 76 | +``` |
| 77 | + |
| 78 | +#### For Production Dependency Updates: |
| 79 | + |
| 80 | +```bash |
| 81 | +# Create a proper changeset (usually patch version) |
| 82 | +pnpm changeset |
| 83 | + |
| 84 | +# Select: |
| 85 | +# - patch: for backward-compatible dependency updates |
| 86 | +# - minor: if new features are exposed |
| 87 | +# - major: if breaking changes exist |
| 88 | +``` |
| 89 | + |
| 90 | +### 6. Commit the Changes |
| 91 | + |
| 92 | +Follow conventional commit format: |
| 93 | + |
| 94 | +```bash |
| 95 | +git add . |
| 96 | + |
| 97 | +# For routine updates |
| 98 | +git commit -m "chore: update dependencies |
| 99 | +
|
| 100 | +- Updated production dependencies to latest versions |
| 101 | +- Updated dev dependencies to latest versions |
| 102 | +- No breaking changes identified" |
| 103 | + |
| 104 | +# For updates with notable changes |
| 105 | +git commit -m "chore: update dependencies with <notable-package> v<version> |
| 106 | +
|
| 107 | +- Updated <package> from v<old> to v<new> |
| 108 | +- <List any important changes> |
| 109 | +- All tests passing" |
| 110 | +``` |
| 111 | + |
| 112 | +### 7. Push and Create Pull Request |
| 113 | + |
| 114 | +```bash |
| 115 | +# Push the branch |
| 116 | +git push -u origin chore/update-dependencies-<date> |
| 117 | + |
| 118 | +# Create PR with detailed description |
| 119 | +gh pr create \ |
| 120 | + --title "chore: update dependencies" \ |
| 121 | + --body "## Summary |
| 122 | + Updates all dependencies to their latest versions. |
| 123 | +
|
| 124 | + ## Changes |
| 125 | + - Production dependencies updated |
| 126 | + - Dev dependencies updated |
| 127 | + - No breaking changes identified |
| 128 | +
|
| 129 | + ## Testing |
| 130 | + - ✅ All tests passing |
| 131 | + - ✅ Type checking successful |
| 132 | + - ✅ Linting clean |
| 133 | + - ✅ Coverage maintained at 80%+ |
| 134 | +
|
| 135 | + ## Changeset |
| 136 | + - [x] Empty changeset added for dev dependency updates" \ |
| 137 | + --assignee @me |
| 138 | +``` |
| 139 | + |
| 140 | +### 8. Monitor CI/CD Pipeline |
| 141 | + |
| 142 | +```bash |
| 143 | +# Watch the PR checks |
| 144 | +gh pr checks --watch |
| 145 | + |
| 146 | +# View detailed CI logs if needed |
| 147 | +gh run list |
| 148 | +gh run view <run-id> |
| 149 | +``` |
| 150 | + |
| 151 | +### 9. Merge the Pull Request |
| 152 | + |
| 153 | +Once all checks pass: |
| 154 | + |
| 155 | +```bash |
| 156 | +# Squash and merge (maintains clean history) |
| 157 | +gh pr merge --squash --delete-branch |
| 158 | + |
| 159 | +# Or merge through GitHub UI with "Squash and merge" |
| 160 | +``` |
| 161 | + |
| 162 | +## Important Notes |
| 163 | + |
| 164 | +### Changeset Requirements |
| 165 | + |
| 166 | +- **Dev dependencies only**: Use `pnpm changeset --empty` to satisfy CI requirements |
| 167 | +- **Production dependencies**: Create a proper changeset with appropriate version bump |
| 168 | +- **Mixed updates**: Use proper changeset and document both types |
| 169 | + |
| 170 | +### Common Issues and Solutions |
| 171 | + |
| 172 | +#### CI Fails Due to Missing Changeset |
| 173 | + |
| 174 | +```bash |
| 175 | +# Add an empty changeset if you forgot |
| 176 | +pnpm changeset --empty |
| 177 | +git add . |
| 178 | +git commit --amend |
| 179 | +git push --force-with-lease |
| 180 | +``` |
| 181 | + |
| 182 | +#### Breaking Changes in Dependencies |
| 183 | + |
| 184 | +1. Review the changelog of the updated package |
| 185 | +2. Update code to accommodate changes |
| 186 | +3. Add tests for affected functionality |
| 187 | +4. Use minor or major version bump in changeset |
| 188 | + |
| 189 | +#### Audit Vulnerabilities |
| 190 | + |
| 191 | +```bash |
| 192 | +# Check for vulnerabilities |
| 193 | +pnpm audit |
| 194 | + |
| 195 | +# Fix automatically if possible |
| 196 | +pnpm audit --fix |
| 197 | + |
| 198 | +# For critical vulnerabilities that can't be auto-fixed, |
| 199 | +# document in PR and consider alternatives |
| 200 | +``` |
| 201 | + |
| 202 | +### Security Considerations |
| 203 | + |
| 204 | +- Always run `pnpm audit` after updates |
| 205 | +- Review security advisories for updated packages |
| 206 | +- Be cautious with major version updates |
| 207 | +- Consider the security track record of new dependencies |
0 commit comments