Skip to content

Commit 298cb9d

Browse files
authored
feat(Command): add ignore option for BreakPointCommand (#24)
- Add an option to ignore specific packages by name when checking for outdated composer dependencies
1 parent 32a20bb commit 298cb9d

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ composer.lock
44
.phpunit.cache
55

66
tmp
7+
/.idea/

src/Command/BreakPointCommand.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ protected function configure(): void
3737
'Maximum number of outdated major version packages',
3838
5
3939
);
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+
);
4047
}
4148

4249
protected function execute(InputInterface $input, OutputInterface $output): int
@@ -59,7 +66,18 @@ protected function execute(InputInterface $input, OutputInterface $output): int
5966

6067
$composerJsonFilePath = getcwd() . '/composer.json';
6168
$outdatedComposer = $this->outdatedComposerFactory->createOutdatedComposer(
62-
$responseJson[ComposerKey::INSTALLED_KEY],
69+
array_filter(
70+
$responseJson[ComposerKey::INSTALLED_KEY],
71+
static function (array $package) use ($input): bool {
72+
foreach ($input->getOption('ignore') as $ignoredPackage) {
73+
if (str_contains((string) $package['name'], $ignoredPackage)) {
74+
return false;
75+
}
76+
}
77+
78+
return true;
79+
}
80+
),
6381
$composerJsonFilePath
6482
);
6583

tests/ComposerProcessor/RaiseToInstalledComposerProcessor/RaiseToInstalledComposerProcessorTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public function testSinglePiped(): void
5959

6060
$this->assertSame('illuminate/container', $changedPackageVersion->getPackageName());
6161
$this->assertSame('^12.14 | 13.0', $changedPackageVersion->getOldVersion());
62-
$this->assertSame('^12.18', $changedPackageVersion->getNewVersion());
62+
$this->assertSame('^12.19', $changedPackageVersion->getNewVersion());
6363
}
6464

6565
public function testDoublePiped(): void
@@ -72,6 +72,6 @@ public function testDoublePiped(): void
7272

7373
$this->assertSame('illuminate/container', $changedPackageVersion->getPackageName());
7474
$this->assertSame('^12.14 | 13.0', $changedPackageVersion->getOldVersion());
75-
$this->assertSame('^12.18', $changedPackageVersion->getNewVersion());
75+
$this->assertSame('^12.19', $changedPackageVersion->getNewVersion());
7676
}
7777
}

0 commit comments

Comments
 (0)