44
55namespace OpenForgeProject \MageForge \Console \Command \Hyva ;
66
7- use Laravel \Prompts \MultiSelectPrompt ;
7+ use Laravel \Prompts \ConfirmPrompt ;
8+ use Laravel \Prompts \SelectPrompt ;
89use Magento \Framework \Console \Cli ;
910use OpenForgeProject \MageForge \Console \Command \AbstractCommand ;
1011use OpenForgeProject \MageForge \Service \Hyva \CompatibilityChecker ;
@@ -26,6 +27,13 @@ class CompatibilityCheckCommand extends AbstractCommand
2627 private const OPTION_INCLUDE_VENDOR = 'include-vendor ' ;
2728 private const OPTION_DETAILED = 'detailed ' ;
2829
30+ private const DISPLAY_MODE_ISSUES = 'issues ' ;
31+ private const DISPLAY_MODE_INCOMPATIBLE_ONLY = 'incompatible-only ' ;
32+ private const DISPLAY_MODE_SHOW_ALL = 'show-all ' ;
33+
34+ private const SCOPE_THIRD_PARTY = 'third-party ' ;
35+ private const SCOPE_ALL = 'all ' ;
36+
2937 private array $ originalEnv = [];
3038 private array $ secureEnvStorage = [];
3139
@@ -92,28 +100,43 @@ private function runInteractiveMode(InputInterface $input, OutputInterface $outp
92100 $ this ->setPromptEnvironment ();
93101
94102 try {
95- $ scanOptionsPrompt = new MultiSelectPrompt (
96- label: 'Select scan options ' ,
103+ // Display mode selection
104+ $ displayModePrompt = new SelectPrompt (
105+ label: 'What modules do you want to see? ' ,
97106 options: [
98- 'show-all ' => 'Show all modules including compatible ones ' ,
99- 'incompatible-only ' => 'Show only incompatible modules (default behavior) ' ,
100- 'include-vendor ' => 'Include Magento core modules (default: third-party only) ' ,
101- 'detailed ' => 'Show detailed file-level issues with line numbers ' ,
107+ self ::DISPLAY_MODE_ISSUES => 'Modules with any issues (warnings or critical) ' ,
108+ self ::DISPLAY_MODE_INCOMPATIBLE_ONLY => 'Only modules with critical issues ' ,
109+ self ::DISPLAY_MODE_SHOW_ALL => 'All modules including compatible ones ' ,
102110 ],
103- default: [],
104- hint: 'Space to toggle, Enter to confirm. Default: third-party modules only ' ,
105- required: false ,
111+ default: self ::DISPLAY_MODE_ISSUES ,
106112 );
107113
108- $ selectedOptions = $ scanOptionsPrompt ->prompt ();
109- \Laravel \Prompts \Prompt::terminal ()->restoreTty ();
110- $ this ->resetPromptEnvironment ();
114+ $ displayMode = $ displayModePrompt ->prompt ();
115+
116+ // Module scope selection
117+ $ scopePrompt = new SelectPrompt (
118+ label: 'Which modules to scan? ' ,
119+ options: [
120+ self ::SCOPE_THIRD_PARTY => 'Third-party modules only (exclude Magento_*) ' ,
121+ self ::SCOPE_ALL => 'All modules including Magento core ' ,
122+ ],
123+ default: self ::SCOPE_THIRD_PARTY ,
124+ );
125+
126+ $ scope = $ scopePrompt ->prompt ();
127+
128+ // Detailed view confirmation
129+ $ detailedPrompt = new ConfirmPrompt (
130+ label: 'Show detailed file-level issues? ' ,
131+ default: false ,
132+ );
133+
134+ $ detailed = $ detailedPrompt ->prompt ();
111135
112- // Apply selected options to input
113- $ showAll = in_array ('show-all ' , $ selectedOptions );
114- $ incompatibleOnly = in_array ('incompatible-only ' , $ selectedOptions );
115- $ includeVendor = in_array ('include-vendor ' , $ selectedOptions );
116- $ detailed = in_array ('detailed ' , $ selectedOptions );
136+ // Map selected options to flags
137+ $ showAll = $ displayMode === self ::DISPLAY_MODE_SHOW_ALL ;
138+ $ incompatibleOnly = $ displayMode === self ::DISPLAY_MODE_INCOMPATIBLE_ONLY ;
139+ $ includeVendor = $ scope === self ::SCOPE_ALL ;
117140 $ thirdPartyOnly = false ; // Not needed in interactive mode
118141
119142 // Show selected configuration
@@ -126,25 +149,23 @@ private function runInteractiveMode(InputInterface $input, OutputInterface $outp
126149 } else {
127150 $ config [] = 'Show modules with issues ' ;
128151 }
129- if ($ includeVendor ) {
130- $ config [] = 'Include Magento core ' ;
131- } else {
132- $ config [] = 'Third-party modules only ' ;
133- }
152+ $ config [] = $ includeVendor ? 'Include Magento core ' : 'Third-party modules only ' ;
134153 if ($ detailed ) {
135154 $ config [] = 'Detailed issues ' ;
136155 }
137156 $ this ->io ->comment ('Configuration: ' . implode (', ' , $ config ));
138157 $ this ->io ->newLine ();
139158
140- // Run scan with selected options (pass incompatibleOnly flag)
159+ // Run scan with selected options
141160 return $ this ->runScan ($ showAll , $ thirdPartyOnly , $ includeVendor , $ detailed , $ incompatibleOnly , $ output );
142- } catch (\Exception $ e ) {
143- $ this ->resetPromptEnvironment ();
161+ } catch (\Throwable $ e ) {
144162 $ this ->io ->error ('Interactive mode failed: ' . $ e ->getMessage ());
145163 $ this ->io ->info ('Falling back to default scan (third-party modules only)... ' );
146164 $ this ->io ->newLine ();
147165 return $ this ->runDirectMode ($ input , $ output );
166+ } finally {
167+ \Laravel \Prompts \Prompt::terminal ()->restoreTty ();
168+ $ this ->resetPromptEnvironment ();
148169 }
149170 }
150171
@@ -213,6 +234,9 @@ private function runScan(
213234 $ this ->displayRecommendations ();
214235 }
215236
237+ // Add spacing before exit
238+ $ this ->io ->newLine ();
239+
216240 // Return appropriate exit code
217241 return $ results ['summary ' ]['criticalIssues ' ] > 0
218242 ? Cli::RETURN_FAILURE
@@ -301,15 +325,21 @@ private function displaySummary(array $results): void
301325
302326 // Final message
303327 if ($ summary ['criticalIssues ' ] > 0 ) {
304- $ this ->io ->error (sprintf (
305- 'Found %d critical compatibility issue(s) that need attention. ' ,
306- $ summary ['criticalIssues ' ]
328+ $ this ->io ->newLine ();
329+ $ this ->io ->writeln (sprintf (
330+ '<fg=red>⚠</> Found <fg=red;options=bold>%d critical compatibility issue(s)</> in %d scanned modules. ' ,
331+ $ summary ['criticalIssues ' ],
332+ $ summary ['total ' ]
307333 ));
334+ $ this ->io ->writeln ('These modules require modifications to work with Hyvä themes. ' );
308335 } elseif ($ summary ['warningIssues ' ] > 0 ) {
309- $ this ->io ->warning (sprintf (
310- 'Found %d warning(s). Review these for potential issues. ' ,
311- $ summary ['warningIssues ' ]
336+ $ this ->io ->newLine ();
337+ $ this ->io ->writeln (sprintf (
338+ '<fg=yellow>ℹ</> Found <fg=yellow;options=bold>%d warning(s)</> in %d scanned modules. ' ,
339+ $ summary ['warningIssues ' ],
340+ $ summary ['total ' ]
312341 ));
342+ $ this ->io ->writeln ('Review these modules for potential compatibility issues. ' );
313343 } else {
314344 $ this ->io ->success ('All scanned modules are Hyvä compatible! ' );
315345 }
@@ -320,7 +350,6 @@ private function displaySummary(array $results): void
320350 */
321351 private function displayRecommendations (): void
322352 {
323-
324353 $ this ->io ->section ('Recommendations ' );
325354
326355 $ recommendations = [
@@ -444,6 +473,4 @@ private function setEnvVar(string $name, string $value): void
444473 $ this ->secureEnvStorage [$ name ] = $ value ;
445474 putenv ("$ name= $ value " );
446475 }
447-
448-
449476}
0 commit comments