Skip to content

Commit 1232d5e

Browse files
committed
refactor: rename exclude-vendor option to include-vendor in compatibility check command
1 parent 1b7410d commit 1232d5e

5 files changed

Lines changed: 37 additions & 26 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ All notable changes to this project will be documented in this file.
488488
- Scans Magento modules for Hyvä theme compatibility issues
489489
- Detects RequireJS, Knockout.js, jQuery, and UI Components usage
490490
- Interactive menu with Laravel Prompts for scan options
491-
- Options: `--show-all`, `--third-party-only`, `--include-core`, `--exclude-vendor`, `--detailed`
491+
- Options: `--show-all`, `--third-party-only`, `--include-core`, `--include-vendor`, `--detailed`
492492
- Color-coded output (✓ Compatible, ⚠ Warnings, ✗ Incompatible)
493493
- Detailed file-level issues with line numbers
494494
- Exit code 1 for critical issues, 0 for success

docs/commands_reference.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ bin/magento hyva:check
246246
- `-a, --show-all` — Show all modules including compatible ones.
247247
- `-t, --third-party-only` — Check only third-party modules (exclude Magento\_\*).
248248
- `--include-core` — Include Magento core modules in the check.
249-
- `--exclude-vendor`Exclude modules installed in the vendor directory.
249+
- `--include-vendor`Include modules installed in the vendor directory (default: excluded).
250250
- `--detailed` — Show detailed compatibility information.
251251

252252
**Output:** Displays a table with compatibility status per module.

src/Console/Command/Hyva/CompatibilityCheckCommand.php

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class CompatibilityCheckCommand extends AbstractCommand
2929
private const OPTION_SHOW_ALL = 'show-all';
3030
private const OPTION_THIRD_PARTY_ONLY = 'third-party-only';
3131
private const OPTION_INCLUDE_CORE = 'include-core';
32-
private const OPTION_EXCLUDE_VENDOR = 'exclude-vendor';
32+
private const OPTION_INCLUDE_VENDOR = 'include-vendor';
3333
private const OPTION_DETAILED = 'detailed';
3434

3535
private const DISPLAY_MODE_ISSUES = 'issues';
@@ -78,10 +78,10 @@ protected function configure(): void
7878
'Include Magento core modules (default: third-party modules only)',
7979
)
8080
->addOption(
81-
self::OPTION_EXCLUDE_VENDOR,
81+
self::OPTION_INCLUDE_VENDOR,
8282
null,
8383
InputOption::VALUE_NONE,
84-
'Exclude modules installed in the vendor directory',
84+
'Include modules installed in the vendor directory (default: excluded)',
8585
)
8686
->addOption(
8787
self::OPTION_DETAILED,
@@ -101,9 +101,7 @@ protected function configure(): void
101101
protected function executeCommand(InputInterface $input, OutputInterface $output): int
102102
{
103103
// Validate conflicting options early
104-
if ($input->getOption(self::OPTION_THIRD_PARTY_ONLY)
105-
&& $input->getOption(self::OPTION_INCLUDE_CORE)
106-
) {
104+
if ($input->getOption(self::OPTION_THIRD_PARTY_ONLY) && $input->getOption(self::OPTION_INCLUDE_CORE)) {
107105
$this->io->error('The options --third-party-only and --include-core cannot be used together.');
108106

109107
return Cli::RETURN_FAILURE;
@@ -114,7 +112,7 @@ protected function executeCommand(InputInterface $input, OutputInterface $output
114112
(bool) $input->getOption(self::OPTION_SHOW_ALL)
115113
|| (bool) $input->getOption(self::OPTION_THIRD_PARTY_ONLY)
116114
|| (bool) $input->getOption(self::OPTION_INCLUDE_CORE)
117-
|| (bool) $input->getOption(self::OPTION_EXCLUDE_VENDOR)
115+
|| (bool) $input->getOption(self::OPTION_INCLUDE_VENDOR)
118116
|| (bool) $input->getOption(self::OPTION_DETAILED);
119117

120118
if (!$hasOptions && $this->isInteractiveTerminal($output)) {
@@ -178,7 +176,7 @@ private function runInteractiveMode(InputInterface $input, OutputInterface $outp
178176
$incompatibleOnly = $displayMode === self::DISPLAY_MODE_INCOMPATIBLE_ONLY;
179177
$includeCore = $scope === self::SCOPE_ALL;
180178
$thirdPartyOnly = false; // Not needed in interactive mode
181-
$excludeVendor = false; // Not configurable in interactive mode
179+
$includeVendor = false; // Vendor modules excluded by default in interactive mode
182180

183181
// Show selected configuration
184182
$this->io->newLine();
@@ -202,7 +200,7 @@ private function runInteractiveMode(InputInterface $input, OutputInterface $outp
202200
$showAll,
203201
$thirdPartyOnly,
204202
$includeCore,
205-
$excludeVendor,
203+
$includeVendor,
206204
$detailed,
207205
$incompatibleOnly,
208206
);
@@ -229,23 +227,23 @@ private function runDirectMode(InputInterface $input, OutputInterface $output):
229227
$showAll = (bool) $input->getOption(self::OPTION_SHOW_ALL);
230228
$thirdPartyOnly = (bool) $input->getOption(self::OPTION_THIRD_PARTY_ONLY);
231229
$includeCore = (bool) $input->getOption(self::OPTION_INCLUDE_CORE);
232-
$excludeVendor = (bool) $input->getOption(self::OPTION_EXCLUDE_VENDOR);
230+
$includeVendor = (bool) $input->getOption(self::OPTION_INCLUDE_VENDOR);
233231
$detailed = (bool) $input->getOption(self::OPTION_DETAILED);
234232

235233
$this->io->title('Hyvä Theme Compatibility Check');
236234

237235
if ($this->isVerbose($output)) {
238236
$this->io->info(sprintf(
239-
'Direct mode: showAll=%s, thirdPartyOnly=%s, includeCore=%s, excludeVendor=%s, detailed=%s',
237+
'Direct mode: showAll=%s, thirdPartyOnly=%s, includeCore=%s, includeVendor=%s, detailed=%s',
240238
$showAll ? 'true' : 'false',
241239
$thirdPartyOnly ? 'true' : 'false',
242240
$includeCore ? 'true' : 'false',
243-
$excludeVendor ? 'true' : 'false',
241+
$includeVendor ? 'true' : 'false',
244242
$detailed ? 'true' : 'false',
245243
));
246244
}
247245

248-
return $this->runScan($showAll, $thirdPartyOnly, $includeCore, $excludeVendor, $detailed, false);
246+
return $this->runScan($showAll, $thirdPartyOnly, $includeCore, $includeVendor, $detailed, false);
249247
}
250248

251249
/**
@@ -254,7 +252,7 @@ private function runDirectMode(InputInterface $input, OutputInterface $output):
254252
* @param bool $showAll
255253
* @param bool $thirdPartyOnly
256254
* @param bool $includeCore
257-
* @param bool $excludeVendor
255+
* @param bool $includeVendor
258256
* @param bool $detailed
259257
* @param bool $incompatibleOnly
260258
* @return int
@@ -263,18 +261,18 @@ private function runScan(
263261
bool $showAll,
264262
bool $thirdPartyOnly,
265263
bool $includeCore,
266-
bool $excludeVendor,
264+
bool $includeVendor,
267265
bool $detailed,
268266
bool $incompatibleOnly,
269267
): int {
270268
// Determine filter logic:
271-
// - thirdPartyOnly: Only scan non-Magento_* modules (default behavior)
269+
// - thirdPartyOnly: Only scan non-Magento_* modules
272270
// - includeCore: Also scan Magento_* core modules
273-
// - excludeVendor: Whether to exclude modules installed in vendor/
274-
$scanThirdPartyOnly = !$includeCore;
271+
// - includeVendor: Whether to include modules installed in vendor/
272+
$scanThirdPartyOnly = $thirdPartyOnly || !$includeCore;
275273

276274
// Run the compatibility check
277-
$results = $this->compatibilityChecker->check($this->io, $showAll, $scanThirdPartyOnly, $excludeVendor);
275+
$results = $this->compatibilityChecker->check($this->io, $showAll, $scanThirdPartyOnly, !$includeVendor);
278276

279277
// Determine display mode:
280278
// showAll = show all modules including compatible ones

src/Service/Hyva/ModuleScanner.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,8 @@ public function getModuleInfo(string $modulePath): array
188188
* is a Hyvä compatibility package, or ships a hyva-themes.json config.
189189
*
190190
* @param string $modulePath
191-
* @param array<string, mixed> $composerData
191+
* @param array $composerData
192+
* @phpstan-param array<string, mixed> $composerData
192193
* @return bool
193194
*/
194195
private function isHyvaAware(string $modulePath, array $composerData): bool

tests/Unit/Console/Command/Hyva/CompatibilityCheckCommandTest.php

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -365,28 +365,40 @@ public function testDetailedIssuesIncludesCompatibleModulesThatHaveWarnings(): v
365365
$this->assertStringContainsString('Vendor_Warned', $tester->getDisplay());
366366
}
367367

368+
public function testDefaultExcludesVendorModules(): void
369+
{
370+
$this->compatibilityChecker->expects($this->once())
371+
->method('check')
372+
->with($this->anything(), false, true, true)
373+
->willReturn($this->makeResults());
374+
$this->compatibilityChecker->method('formatResultsForDisplay')->willReturn([]);
375+
376+
$tester = new CommandTester($this->command);
377+
$tester->execute([]);
378+
}
379+
368380
public function testIncludeCoreOptionIsPassedToChecker(): void
369381
{
370382
$this->compatibilityChecker->expects($this->once())
371383
->method('check')
372-
->with($this->anything(), false, false, false)
384+
->with($this->anything(), false, false, true)
373385
->willReturn($this->makeResults());
374386
$this->compatibilityChecker->method('formatResultsForDisplay')->willReturn([]);
375387

376388
$tester = new CommandTester($this->command);
377389
$tester->execute(['--include-core' => true]);
378390
}
379391

380-
public function testExcludeVendorOptionIsPassedToChecker(): void
392+
public function testIncludeVendorOptionIsPassedToChecker(): void
381393
{
382394
$this->compatibilityChecker->expects($this->once())
383395
->method('check')
384-
->with($this->anything(), false, true, true)
396+
->with($this->anything(), false, true, false)
385397
->willReturn($this->makeResults());
386398
$this->compatibilityChecker->method('formatResultsForDisplay')->willReturn([]);
387399

388400
$tester = new CommandTester($this->command);
389-
$tester->execute(['--exclude-vendor' => true]);
401+
$tester->execute(['--include-vendor' => true]);
390402
}
391403

392404
public function testConflictingThirdPartyOnlyAndIncludeCoreOptionsReturnError(): void

0 commit comments

Comments
 (0)