|
| 1 | +# Jack to raise your dependency version |
| 2 | + |
| 3 | +[](https://packagist.org/packages/rector/jack/stats) |
| 4 | + |
| 5 | +@todo img |
| 6 | + |
| 7 | +The slow and steady way to raise your `composer.json` dependencies versions. |
| 8 | + |
| 9 | +No more outdated dependencies without noticing. |
| 10 | + |
| 11 | +<br> |
| 12 | + |
| 13 | +## Install |
| 14 | + |
| 15 | +```bash |
| 16 | +composer require rector/jack --dev |
| 17 | +``` |
| 18 | + |
| 19 | +<br> |
| 20 | + |
| 21 | +## Usage |
| 22 | + |
| 23 | +## 1. Let your CI tell you, if there is too many outdated dependencies |
| 24 | + |
| 25 | +We tend to postpone upgrade and to them in big jumps = once a couple years. The postponing turns upgrades to harder and more costly project. Also, we can face more errors, as some newer version of packages no longer work with our PHP version. |
| 26 | + |
| 27 | +Let CI pay attention to this issue for us. Too many outdated major packages? CI will fail. |
| 28 | + |
| 29 | +```bash |
| 30 | +vendor/bin/jack breakpoint |
| 31 | +``` |
| 32 | + |
| 33 | +Default limit of outdated packages is 5. Do you 15 outdated packages? Make it fit your needs - goal of this command is not to get stressed, but to keep raising your dependencies one step at a time: |
| 34 | + |
| 35 | +```bash |
| 36 | +vendor/bin/jack breakpoint --limit 13 |
| 37 | +``` |
| 38 | + |
| 39 | +This way, the upgrade will be bring to our focus, if we're lacking behind for too long. |
| 40 | +No more: "oops, all our dependencies are 3 years old, let's update them all at once" mayhem. |
| 41 | + |
| 42 | +<br> |
| 43 | + |
| 44 | +## 2. Open up next versions |
| 45 | + |
| 46 | +We know we're behind the latest versions of our dependencies, but where to start? Which versions should be force to update first? We can get lot of errors if we try to bump wrong end of not. |
| 47 | + |
| 48 | +Instead, let composer handle it. How? We open-up package versions to the next version: |
| 49 | + |
| 50 | +```diff |
| 51 | + { |
| 52 | + "require": { |
| 53 | + "php": "^7.4", |
| 54 | +- "symfony/console": "^5.0" |
| 55 | ++ "symfony/console": "^5.0|^6.0" |
| 56 | + }, |
| 57 | + "require-dev": { |
| 58 | +- "phpunit/phpunit": "^9.0" |
| 59 | ++ "phpunit/phpunit": "^10.0" |
| 60 | + } |
| 61 | + } |
| 62 | + } |
| 63 | +``` |
| 64 | + |
| 65 | +Not forcing, just opening up. If composer won't see any blockers, it will update the package to the next version. |
| 66 | + |
| 67 | +<br> |
| 68 | + |
| 69 | +You can limit the range of versions to open up by using the `--limit` option (default 5) |
| 70 | + |
| 71 | +```bash |
| 72 | +vendor/bin/jack open-versions --limit 3 |
| 73 | +``` |
| 74 | + |
| 75 | +To try it out without changing the `composer.json`, you can use the `--dry-run` option. |
| 76 | + |
| 77 | +```bash |
| 78 | +vendor/bin/jack open-versions --dry-run |
| 79 | +``` |
| 80 | + |
| 81 | +It's proven practice to update all dev packages first, as they're low hanging fruit. Just add `--dev` option to the command: |
| 82 | + |
| 83 | +```bash |
| 84 | +vendor/bin/jack open-versions --dev |
| 85 | +``` |
| 86 | + |
| 87 | +This way we **get slowly and steadily to the next possible version** of our dependencies. |
| 88 | + |
| 89 | +<br> |
| 90 | + |
| 91 | +Happy coding! |
0 commit comments