Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions src/Command/BreakPointCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,17 @@ protected function execute(InputInterface $input, OutputInterface $output): int
sprintf('The "<fg=green>%s</>" package is outdated', $outdatedPackage->getName())
);

$symfonyStyle->writeln(sprintf(
' * Your version %s is <fg=%s>%s</>',
$outdatedPackage->getCurrentVersion(),
$outdatedPackage->isVeryOld() ? 'red' : 'yellow',
$outdatedPackage->getCurrentVersionAge(),
));
if ($outdatedPackage->getCurrentVersionAge()) {
$symfonyStyle->writeln(sprintf(
' * Your version %s is <fg=%s>%s</>',
$outdatedPackage->getCurrentVersion(),
$outdatedPackage->isVeryOld() ? 'red' : 'yellow',
$outdatedPackage->getCurrentVersionAge(),
));
} else {
// composer 2.7- compatible
$symfonyStyle->writeln(sprintf(' * Your version is %s', $outdatedPackage->getCurrentVersion()));
}

$symfonyStyle->writeln(sprintf(' * Bump to %s', $outdatedPackage->getLatestVersion()));
$symfonyStyle->newLine();
Expand Down
2 changes: 1 addition & 1 deletion src/Mapper/OutdatedPackageMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function mapToObjects(array $outdatedPackages, string $composerJsonFilePa
$composerVersions,
$isProd,
$data['latest'],
$data['release-age']
$data['release-age'] ?? null
);
}, $outdatedPackages);
}
Expand Down
9 changes: 7 additions & 2 deletions src/ValueObject/OutdatedPackage.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ public function __construct(
private string $composerVersion,
private bool $isProd,
private string $latestVersion,
private string $currentVersionAge,
// nullable on composer 2.7-
private ?string $currentVersionAge,
) {
}

Expand Down Expand Up @@ -43,13 +44,17 @@ public function getLatestVersion(): string
return $this->latestVersion;
}

public function getCurrentVersionAge(): string
public function getCurrentVersionAge(): ?string
{
return $this->currentVersionAge;
}

public function isVeryOld(): bool
{
if ($this->currentVersionAge === null) {
return true;
}

$matchYears = Strings::match($this->currentVersionAge, '#[3-9] years#');
return $matchYears !== null;
}
Expand Down