Skip to content

Commit c7e1f78

Browse files
committed
init
0 parents  commit c7e1f78

40 files changed

+1466
-0
lines changed

.editorconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
insert_final_newline = true
7+
trim_trailing_whitespace = true
8+
indent_style = space
9+
indent_size = 4

.gitattributes

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.gitattributes export-ignore
2+
.gitignore export-ignore
3+
*.md export-ignore
4+
tests export-ignore

.github/FUNDING.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# These are supported funding model platforms
2+
github: tomasvotruba
3+
custom: https://www.paypal.me/rectorphp

.github/workflows/bare_run.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Bare Run on various PHP versions
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
8+
jobs:
9+
bare_run:
10+
runs-on: ubuntu-latest
11+
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
php_version: ['7.4', '8.0', '8.2']
16+
17+
steps:
18+
- uses: shivammathur/setup-php@v2
19+
with:
20+
php-version: ${{ matrix.php }}
21+
coverage: none
22+
23+
- run: composer require rector/jack --dev --ansi
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Code Analysis
2+
3+
on:
4+
pull_request: null
5+
push:
6+
branches:
7+
- main
8+
9+
jobs:
10+
code_analysis:
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
actions:
15+
-
16+
name: 'PHPStan'
17+
run: composer phpstan --ansi
18+
19+
-
20+
name: 'Composer Validate'
21+
run: composer validate --ansi
22+
23+
-
24+
name: 'Rector'
25+
run: composer rector --ansi
26+
27+
-
28+
name: 'Coding Standard'
29+
run: composer fix-cs --ansi
30+
31+
-
32+
name: 'Outdated Breakpoint'
33+
run: ./bin/jack outdated-breakpoint --ansi --limit 2
34+
35+
-
36+
name: 'Tests'
37+
run: vendor/bin/phpunit
38+
39+
-
40+
name: 'Check Active Classes'
41+
run: vendor/bin/class-leak check bin src tests --ansi
42+
43+
-
44+
name: 'Unusued check'
45+
run: vendor/bin/composer-dependency-analyser
46+
47+
name: ${{ matrix.actions.name }}
48+
runs-on: ubuntu-latest
49+
50+
steps:
51+
- uses: actions/checkout@v3
52+
# see https://github.com/shivammathur/setup-php
53+
- uses: shivammathur/setup-php@v2
54+
with:
55+
php-version: 8.2
56+
coverage: none
57+
58+
# composer install cache - https://github.com/ramsey/composer-install
59+
- uses: "ramsey/composer-install@v2"
60+
61+
- run: ${{ matrix.actions.run }}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Downgraded Release
2+
3+
on:
4+
push:
5+
tags:
6+
# avoid infinite looping, skip tags that ends with ".74"
7+
# see https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-including-and-excluding-branches
8+
- '*'
9+
10+
jobs:
11+
downgrade_release:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: "actions/checkout@v3"
16+
with:
17+
token: ${{ secrets.WORKFLOWS_TOKEN }}
18+
19+
-
20+
uses: "shivammathur/setup-php@v2"
21+
with:
22+
php-version: 8.2
23+
coverage: none
24+
25+
# invoke patches
26+
- run: composer install --ansi
27+
28+
# but no dev packages
29+
- run: composer update --no-dev --ansi
30+
31+
# get rector to "rector-local" directory, to avoid downgrading itself in the /vendor
32+
- run: mkdir rector-local
33+
- run: composer require rector/rector --working-dir rector-local --ansi
34+
35+
# downgrade to PHP 7.4
36+
- run: rector-local/vendor/bin/rector process bin src vendor --config build/rector-downgrade-php.php --ansi
37+
38+
# clear the dev files
39+
- run: rm -rf tests ecs.php phpstan.neon phpunit.xml .gitignore .editorconfig
40+
41+
# prefix and scope
42+
- run: sh prefix-code.sh
43+
44+
# copy PHP 7.4 composer + workflows
45+
- run: cp -r build/target-repository/. .
46+
47+
# clear the dev files
48+
- run: rm -rf build prefix-code.sh full-tool-build.sh scoper.php rector.php php-scoper.phar rector-local
49+
50+
# setup git user
51+
-
52+
run: |
53+
git config user.email "[email protected]"
54+
git config user.name "GitHub Action"
55+
# publish to the same repository with a new tag
56+
# see https://tomasvotruba.com/blog/how-to-release-php-81-and-72-package-in-the-same-repository/
57+
-
58+
name: "Tag Downgraded Code"
59+
run: |
60+
# separate a "git add" to add untracked (new) files too
61+
git add --all
62+
git commit -m "release PHP 7.2 downgraded"
63+
64+
# force push tag, so there is only 1 version
65+
git tag "${GITHUB_REF#refs/tags/}" --force
66+
git push origin "${GITHUB_REF#refs/tags/}" --force

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
composer.lock
2+
/vendor
3+
4+
.phpunit.cache
5+
6+
tmp

LICENSE

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
The MIT License
2+
---------------
3+
4+
Copyright (c) 2020 Tomas Votruba (https://tomasvotruba.com)
5+
6+
Permission is hereby granted, free of charge, to any person
7+
obtaining a copy of this software and associated documentation
8+
files (the "Software"), to deal in the Software without
9+
restriction, including without limitation the rights to use,
10+
copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
copies of the Software, and to permit persons to whom the
12+
Software is furnished to do so, subject to the following
13+
conditions:
14+
15+
The above copyright notice and this permission notice shall be
16+
included in all copies or substantial portions of the Software.
17+
18+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25+
OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# Jack to raise your dependency version
2+
3+
[![Downloads total](https://img.shields.io/packagist/dt/rector/jack.svg?style=flat-square)](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!

bin/jack

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
require __DIR__ . '/jack.php';

0 commit comments

Comments
 (0)