diff --git a/composer.json b/composer.json index 6ee6316..71c5835 100644 --- a/composer.json +++ b/composer.json @@ -64,7 +64,3 @@ } } } - - - - diff --git a/src/Command/BreakPointCommand.php b/src/Command/BreakPointCommand.php index 1be0ccf..4096335 100644 --- a/src/Command/BreakPointCommand.php +++ b/src/Command/BreakPointCommand.php @@ -63,6 +63,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int $composerJsonFilePath ); + if ($outdatedComposer->count() === 0) { + $symfonyStyle->success('All packages are up to date'); + return self::SUCCESS; + } + $symfonyStyle->title( sprintf( 'Found %d outdated package%s', diff --git a/src/Command/OpenVersionsCommand.php b/src/Command/OpenVersionsCommand.php index 1b6ab8d..c887cb3 100644 --- a/src/Command/OpenVersionsCommand.php +++ b/src/Command/OpenVersionsCommand.php @@ -60,6 +60,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int $composerJsonFilePath ); + if ($outdatedComposer->count() === 0) { + $symfonyStyle->success('All packages are up to date. You are the best!'); + + return self::SUCCESS; + } + $symfonyStyle->newLine(); $symfonyStyle->writeln( diff --git a/src/OutdatedComposerFactory.php b/src/OutdatedComposerFactory.php index 83e302b..02d0e54 100644 --- a/src/OutdatedComposerFactory.php +++ b/src/OutdatedComposerFactory.php @@ -6,6 +6,7 @@ use Rector\Jack\Mapper\OutdatedPackageMapper; use Rector\Jack\ValueObject\OutdatedComposer; +use Rector\Jack\ValueObject\OutdatedPackage; /** * @see \Rector\Jack\Tests\OutdatedComposerFactory\OutdatedComposerFactoryTest @@ -24,6 +25,12 @@ public function createOutdatedComposer(array $installedPackages, string $compose { $outdatedPackages = $this->outdatedPackageMapper->mapToObjects($installedPackages, $composerJsonFilePath); - return new OutdatedComposer($outdatedPackages); + // filter out dev packages, those are silently added, when "minimum-stability" is set to "dev" + $nonDevOutdatedPackages = array_filter( + $outdatedPackages, + fn (OutdatedPackage $outdatedPackage): bool => ! $outdatedPackage->lastestIsDevBranch() + ); + + return new OutdatedComposer($nonDevOutdatedPackages); } } diff --git a/src/ValueObject/OutdatedPackage.php b/src/ValueObject/OutdatedPackage.php index f21aac0..5b6b3c5 100644 --- a/src/ValueObject/OutdatedPackage.php +++ b/src/ValueObject/OutdatedPackage.php @@ -58,4 +58,13 @@ public function isVeryOld(): bool $matchYears = Strings::match($this->currentVersionAge, '#[3-9] years#'); return $matchYears !== null; } + + public function lastestIsDevBranch(): bool + { + if (str_starts_with($this->latestVersion, 'dev-')) { + return true; + } + + return str_contains($this->latestVersion, '-dev'); + } }