Skip to content

Commit 49f02e2

Browse files
committed
try entropy
1 parent e34eccd commit 49f02e2

File tree

17 files changed

+163
-187
lines changed

17 files changed

+163
-187
lines changed

.github/workflows/code_analysis.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656
# see https://github.com/shivammathur/setup-php
5757
- uses: shivammathur/setup-php@v2
5858
with:
59-
php-version: 8.2
59+
php-version: 8.3
6060
coverage: none
6161

6262
# composer install cache - https://github.com/ramsey/composer-install

.github/workflows/downgraded_release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
-
2020
uses: "shivammathur/setup-php@v2"
2121
with:
22-
php-version: 8.2
22+
php-version: 8.3
2323
coverage: none
2424

2525
# invoke patches

bin/jack.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22

33
declare(strict_types=1);
44

5-
use Symfony\Component\Console\Application;
6-
use Symfony\Component\Console\Input\ArgvInput;
7-
use Symfony\Component\Console\Output\ConsoleOutput;
5+
use Entropy\Console\ConsoleApplication;
86
use Rector\Jack\DependencyInjection\ContainerFactory;
97

108
$scoperAutoloadFilepath = __DIR__ . '/../vendor/scoper-autoload.php';
@@ -32,7 +30,7 @@
3230
$containerFactory = new ContainerFactory();
3331
$container = $containerFactory->create();
3432

35-
$application = $container->make(Application::class);
33+
$consoleApplication = $container->make(ConsoleApplication::class);
3634

37-
$exitCode = $application->run(new ArgvInput(), new ConsoleOutput());
35+
$exitCode = $consoleApplication->run($argv);
3836
exit($exitCode);

composer.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@
66
"bin/jack"
77
],
88
"require": {
9-
"php": ">=8.2",
9+
"php": ">=8.3",
1010
"composer/semver": "^3.4",
11-
"illuminate/container": "^12.37",
11+
"entropy/entropy": "dev-main",
1212
"nette/utils": "^4.0",
1313
"symfony/console": "^6.4",
14-
"symfony/finder": "^7.3",
1514
"symfony/process": "^7.3",
1615
"webmozart/assert": "^1.12"
1716
},
@@ -23,7 +22,6 @@
2322
"shipmonk/composer-dependency-analyser": "^1.8",
2423
"phpecs/phpecs": "^2.2",
2524
"symplify/phpstan-extensions": "^12.0",
26-
"symplify/vendor-patches": "^11.5",
2725
"tomasvotruba/class-leak": "^2.0",
2826
"tracy/tracy": "^2.11"
2927
},
@@ -41,7 +39,6 @@
4139
"sort-packages": true,
4240
"platform-check": false,
4341
"allow-plugins": {
44-
"cweagans/composer-patches": true,
4542
"phpstan/extension-installer": true
4643
}
4744
},

src/Command/BreakPointCommand.php

Lines changed: 55 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -4,62 +4,39 @@
44

55
namespace Rector\Jack\Command;
66

7+
use Entropy\Console\Contract\CommandInterface;
8+
use Entropy\Console\ValueObject\ArgumentsAndOptions;
79
use Nette\Utils\Json;
10+
use Rector\Console\ExitCode;
811
use Rector\Jack\Composer\ComposerOutdatedResponseProvider;
912
use Rector\Jack\Enum\ComposerKey;
1013
use Rector\Jack\OutdatedComposerFactory;
11-
use Symfony\Component\Console\Command\Command;
12-
use Symfony\Component\Console\Input\InputInterface;
1314
use Symfony\Component\Console\Input\InputOption;
14-
use Symfony\Component\Console\Output\OutputInterface;
1515
use Symfony\Component\Console\Style\SymfonyStyle;
1616

17-
final class BreakPointCommand extends Command
17+
final readonly class BreakPointCommand implements CommandInterface
1818
{
1919
public function __construct(
20-
private readonly OutdatedComposerFactory $outdatedComposerFactory,
21-
private readonly ComposerOutdatedResponseProvider $composerOutdatedResponseProvider
20+
private SymfonyStyle $symfonyStyle,
21+
private OutdatedComposerFactory $outdatedComposerFactory,
22+
private ComposerOutdatedResponseProvider $composerOutdatedResponseProvider
2223
) {
23-
parent::__construct();
2424
}
2525

26-
protected function configure(): void
26+
public function run(ArgumentsAndOptions $argumentsAndOptions): int
2727
{
28-
$this->setName('breakpoint');
29-
30-
$this->setDescription('Let your CI tell you, if there is too many major-version outdated packages');
31-
$this->addOption('dev', null, InputOption::VALUE_NONE, 'Focus on dev packages only');
32-
33-
$this->addOption(
34-
'limit',
35-
null,
36-
InputOption::VALUE_REQUIRED,
37-
'Maximum number of outdated major version packages',
38-
5
39-
);
40-
41-
$this->addOption(
42-
'ignore',
43-
null,
44-
InputOption::VALUE_IS_ARRAY | InputOption::VALUE_OPTIONAL,
45-
'Ignore packages by name, e.g. "symfony/" or "symfony/console"',
46-
);
47-
}
48-
49-
protected function execute(InputInterface $input, OutputInterface $output): int
50-
{
51-
$symfonyStyle = new SymfonyStyle($input, $output);
28+
// $symfonyStyle = new SymfonyStyle($input, $output);
5229

5330
$maxOutdatePackages = (int) $input->getOption('limit');
5431
$onlyDev = (bool) $input->getOption('dev');
5532

56-
$symfonyStyle->writeln('<fg=green>Analyzing "composer.json" for major outdated packages</>');
33+
$this->symfonyStyle->writeln('<fg=green>Analyzing "composer.json" for major outdated packages</>');
5734

5835
$responseJsonContents = $this->composerOutdatedResponseProvider->provide();
5936

6037
$responseJson = Json::decode($responseJsonContents, true);
6138
if (! isset($responseJson[ComposerKey::INSTALLED_KEY])) {
62-
$symfonyStyle->success('All packages are up to date');
39+
$this->symfonyStyle->success('All packages are up to date');
6340

6441
return self::SUCCESS;
6542
}
@@ -82,11 +59,11 @@ static function (array $package) use ($input): bool {
8259
);
8360

8461
if ($outdatedComposer->count() === 0) {
85-
$symfonyStyle->success('All packages are up to date');
62+
$this->symfonyStyle->success('All packages are up to date');
8663
return self::SUCCESS;
8764
}
8865

89-
$symfonyStyle->title(
66+
$this->symfonyStyle->title(
9067
sprintf(
9168
'Found %d outdated package%s',
9269
$outdatedComposer->count($onlyDev),
@@ -95,57 +72,87 @@ static function (array $package) use ($input): bool {
9572
);
9673

9774
foreach ($outdatedComposer->getPackages($onlyDev) as $outdatedPackage) {
98-
$symfonyStyle->writeln(
75+
$this->symfonyStyle->writeln(
9976
sprintf('The "<fg=green>%s</>" package is outdated', $outdatedPackage->getName())
10077
);
10178

10279
if ($outdatedPackage->getCurrentVersionAge()) {
103-
$symfonyStyle->writeln(sprintf(
80+
$this->symfonyStyle->writeln(sprintf(
10481
' * Your version %s is <fg=%s>%s</>',
10582
$outdatedPackage->getCurrentVersion(),
10683
$outdatedPackage->isVeryOld() ? 'red' : 'yellow',
10784
$outdatedPackage->getCurrentVersionAge(),
10885
));
10986
} else {
11087
// composer 2.7- compatible
111-
$symfonyStyle->writeln(sprintf(' * Your version is %s', $outdatedPackage->getCurrentVersion()));
88+
$this->symfonyStyle->writeln(sprintf(' * Your version is %s', $outdatedPackage->getCurrentVersion()));
11289
}
11390

114-
$symfonyStyle->writeln(sprintf(' * Bump to %s', $outdatedPackage->getLatestVersion()));
115-
$symfonyStyle->newLine();
91+
$this->symfonyStyle->writeln(sprintf(' * Bump to %s', $outdatedPackage->getLatestVersion()));
92+
$this->symfonyStyle->newLine();
11693
}
11794

118-
$symfonyStyle->newLine();
95+
$this->symfonyStyle->newLine();
11996
if ($outdatedComposer->count() >= $maxOutdatePackages) {
12097
// to much → fail
121-
$symfonyStyle->error(sprintf(
98+
$this->symfonyStyle->error(sprintf(
12299
'There %s %d outdated package%s. Update couple of them to get under %d limit',
123100
$outdatedComposer->count() > 1 ? 'are' : 'is',
124101
$outdatedComposer->count(),
125102
$outdatedComposer->count() > 1 ? 's' : '',
126103
$maxOutdatePackages
127104
));
128105

129-
return self::FAILURE;
106+
return ExitCode::FAILURE;
130107
}
131108

132109
if ($outdatedComposer->count() > max(1, $maxOutdatePackages - 5)) {
133110
// to much → fail
134-
$symfonyStyle->warning(sprintf(
111+
$this->symfonyStyle->warning(sprintf(
135112
'There are %d outdated packages. Soon, the count will go over %d limit and this job will fail.%sUpgrade in time',
136113
$outdatedComposer->count(),
137114
$maxOutdatePackages,
138115
PHP_EOL
139116
));
140117

141-
return self::SUCCESS;
118+
return ExitCode::SUCCESS;
142119
}
143120

144121
// to many → fail
145-
$symfonyStyle->success(
122+
$this->symfonyStyle->success(
146123
sprintf('Still far away from limit %d. Good job keeping your project up to date!', $maxOutdatePackages)
147124
);
148125

149-
return self::SUCCESS;
126+
return ExitCode::SUCCESS;
127+
}
128+
129+
public function getName(): string
130+
{
131+
return 'breakpoint';
132+
}
133+
134+
public function getDescription(): string
135+
{
136+
return 'Let your CI tell you, if there is too many major-version outdated packages';
137+
}
138+
139+
private function configure(): void
140+
{
141+
$this->addOption('dev', null, InputOption::VALUE_NONE, 'Focus on dev packages only');
142+
143+
$this->addOption(
144+
'limit',
145+
null,
146+
InputOption::VALUE_REQUIRED,
147+
'Maximum number of outdated major version packages',
148+
5
149+
);
150+
151+
$this->addOption(
152+
'ignore',
153+
null,
154+
InputOption::VALUE_IS_ARRAY | InputOption::VALUE_OPTIONAL,
155+
'Ignore packages by name, e.g. "symfony/" or "symfony/console"',
156+
);
150157
}
151158
}

0 commit comments

Comments
 (0)