Skip to content

Commit 133ebd4

Browse files
authored
Hide packages that are dev- only (#18)
* Hide packages that are dev- only * cs
1 parent ab2c2cb commit 133ebd4

File tree

5 files changed

+28
-5
lines changed

5 files changed

+28
-5
lines changed

composer.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,3 @@
6464
}
6565
}
6666
}
67-
68-
69-
70-

src/Command/BreakPointCommand.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int
6363
$composerJsonFilePath
6464
);
6565

66+
if ($outdatedComposer->count() === 0) {
67+
$symfonyStyle->success('All packages are up to date');
68+
return self::SUCCESS;
69+
}
70+
6671
$symfonyStyle->title(
6772
sprintf(
6873
'Found %d outdated package%s',

src/Command/OpenVersionsCommand.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int
6060
$composerJsonFilePath
6161
);
6262

63+
if ($outdatedComposer->count() === 0) {
64+
$symfonyStyle->success('All packages are up to date. You are the best!');
65+
66+
return self::SUCCESS;
67+
}
68+
6369
$symfonyStyle->newLine();
6470

6571
$symfonyStyle->writeln(

src/OutdatedComposerFactory.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use Rector\Jack\Mapper\OutdatedPackageMapper;
88
use Rector\Jack\ValueObject\OutdatedComposer;
9+
use Rector\Jack\ValueObject\OutdatedPackage;
910

1011
/**
1112
* @see \Rector\Jack\Tests\OutdatedComposerFactory\OutdatedComposerFactoryTest
@@ -24,6 +25,12 @@ public function createOutdatedComposer(array $installedPackages, string $compose
2425
{
2526
$outdatedPackages = $this->outdatedPackageMapper->mapToObjects($installedPackages, $composerJsonFilePath);
2627

27-
return new OutdatedComposer($outdatedPackages);
28+
// filter out dev packages, those are silently added, when "minimum-stability" is set to "dev"
29+
$nonDevOutdatedPackages = array_filter(
30+
$outdatedPackages,
31+
fn (OutdatedPackage $outdatedPackage): bool => ! $outdatedPackage->lastestIsDevBranch()
32+
);
33+
34+
return new OutdatedComposer($nonDevOutdatedPackages);
2835
}
2936
}

src/ValueObject/OutdatedPackage.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,13 @@ public function isVeryOld(): bool
5858
$matchYears = Strings::match($this->currentVersionAge, '#[3-9] years#');
5959
return $matchYears !== null;
6060
}
61+
62+
public function lastestIsDevBranch(): bool
63+
{
64+
if (str_starts_with($this->latestVersion, 'dev-')) {
65+
return true;
66+
}
67+
68+
return str_contains($this->latestVersion, '-dev');
69+
}
6170
}

0 commit comments

Comments
 (0)