Skip to content
Open
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
15 changes: 13 additions & 2 deletions src/Command/BreakPointCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ public function __construct(
/**
* @param bool $dev Focus on dev packages only
* @param int $limit Maximum number of outdated major version packages
* @param int $minDays Minimum number of days a release has to be old to be considered outdated
* @param string[] $ignore Ignore packages by name, e.g. "symfony/" or "symfony/console"
*/
public function run(bool $dev = false, int $limit = 5, array $ignore = []): int
public function run(bool $dev = false, int $limit = 5, int $minDays = 0, array $ignore = []): int
{
$this->outputPrinter->green('Analyzing "composer.json" for major outdated packages');

Expand All @@ -40,16 +41,26 @@ public function run(bool $dev = false, int $limit = 5, array $ignore = []): int
}

$composerJsonFilePath = getcwd() . '/composer.json';
$now = new \DateTimeImmutable();
$outdatedComposer = $this->outdatedComposerFactory->createOutdatedComposer(
array_filter(
$responseJson[ComposerKey::INSTALLED_KEY],
static function (array $package) use ($ignore): bool {
static function (array $package) use ($ignore, $minDays, $now): bool {
foreach ($ignore as $ignoredPackage) {
if (str_contains((string) $package['name'], $ignoredPackage)) {
return false;
}
}

if ($minDays === 0) {
return true;
}

$pageAgeInDays = (new \DateTimeImmutable($package['latest-release-date']))->diff($now)->days;
if ($pageAgeInDays < $minDays) {
return false;
}

return true;
}
),
Expand Down
Loading