Skip to content

Commit 2a05707

Browse files
dermatzCopilotCopilot
authored
add Hyvä compatibility checker command (#59)
* Add Hyvä compatibility checker command - New command: mageforge:hyva:compatibility:check (aliases: m:h:c:c, hyva:check) - Scans Magento modules for Hyvä theme incompatibilities - Detects RequireJS, Knockout.js, jQuery, UI Components usage - Options: --show-all, --third-party-only, --include-vendor, --detailed - Service layer: CompatibilityChecker, ModuleScanner, IncompatibilityDetector - Exit code 1 for critical issues, 0 for success - Updated CI/CD workflow and documentation * Fix: Default scan now includes third-party modules - Changed default behavior from 0 modules to third-party modules (18) - Without flags: Scans third-party only (excludes Magento_*) - With --include-vendor: Scans all 394 modules including Magento core - Updated documentation to reflect new default behavior * Add interactive menu with Laravel Prompts - Interactive mode activated when no options provided - Multi-select menu for scan options: * Show all modules * Include Magento core modules * Detailed file-level issues - Displays selected configuration before scan - Falls back to direct mode if interactive fails - Consistent with theme:build command UX * Docs: Add interactive mode documentation * Add 'incompatible only' option to interactive menu - New option: Show only incompatible modules (pre-selected by default) - Improves UX by filtering out compatible modules - Users can still choose 'Show all' for complete overview - Configuration display updated to reflect selection * Remove pre-selection from 'incompatible only' option * Update src/Service/Hyva/ModuleScanner.php Co-authored-by: Copilot <[email protected]> * Update CHANGELOG for Hyvä compatibility checker * ✨ feat: update CHANGELOG and improve di.xml formatting * Update src/Service/Hyva/IncompatibilityDetector.php Co-authored-by: Copilot <[email protected]> * Add actual execution tests for Hyvä compatibility checker in CI (#60) * Initial plan * Add actual execution tests for Hyvä compatibility checker command Co-authored-by: dermatz <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: dermatz <[email protected]> Co-authored-by: Mathias Elle <[email protected]> * Clarify exit code behavior in Hyvä compatibility checker documentation (#61) * Initial plan * Clarify exit code documentation for Hyvä compatibility checker Co-authored-by: dermatz <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: dermatz <[email protected]> Co-authored-by: Mathias Elle <[email protected]> * Update src/Console/Command/Hyva/CompatibilityCheckCommand.php Co-authored-by: Copilot <[email protected]> * Initial plan (#64) Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: Mathias Elle <[email protected]> * Update src/Service/Hyva/IncompatibilityDetector.php Co-authored-by: Copilot <[email protected]> * Address code review feedback: fix duplicate config, improve regex patterns, enhance security (#65) * Initial plan * Apply code review feedback: fix duplicate di.xml, improve regex patterns, safer environment handling Co-authored-by: dermatz <[email protected]> * Replace error suppression with explicit exception handling in TTY detection Co-authored-by: dermatz <[email protected]> * Fix RequireJS pattern regex to properly match module references Co-authored-by: dermatz <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: dermatz <[email protected]> --------- Co-authored-by: Copilot <[email protected]> Co-authored-by: Copilot <[email protected]>
1 parent bbd02a9 commit 2a05707

File tree

8 files changed

+1306
-25
lines changed

8 files changed

+1306
-25
lines changed

.github/workflows/magento-compatibility.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,20 @@ jobs:
134134
echo "Test MageForge Theme List command:"
135135
bin/magento mageforge:theme:list
136136
137+
138+
echo "Test MageForge Hyvä Compatibility Check command:"
139+
bin/magento mageforge:hyva:compatibility:check --help
140+
bin/magento m:h:c:c --help
141+
142+
echo "Test MageForge Hyvä Compatibility Check - Show all modules:"
143+
bin/magento mageforge:hyva:compatibility:check --show-all
144+
145+
echo "Test MageForge Hyvä Compatibility Check - Third party only:"
146+
bin/magento m:h:c:c --third-party-only
147+
148+
echo "Test MageForge Hyvä Compatibility Check - Detailed output:"
149+
bin/magento m:h:c:c --show-all --detailed
150+
137151
echo "Test MageForge Static Clean command with dry-run:"
138152
bin/magento mageforge:static:clean --all --dry-run
139153
@@ -143,6 +157,7 @@ jobs:
143157
bin/magento m:st:c --help
144158
bin/magento frontend:clean --help
145159
160+
146161
- name: Test Summary
147162
run: |
148163
echo "MageForge module compatibility test with Magento ${{ matrix.magento-version }} completed"
@@ -264,13 +279,27 @@ jobs:
264279
echo "Test MageForge Theme List command:"
265280
bin/magento mageforge:theme:list
266281
282+
echo "Test MageForge Hyvä Compatibility Check command:"
283+
bin/magento mageforge:hyva:compatibility:check --help
284+
bin/magento m:h:c:c --help
285+
286+
echo "Test MageForge Hyvä Compatibility Check - Show all modules:"
287+
bin/magento mageforge:hyva:compatibility:check --show-all
288+
289+
echo "Test MageForge Hyvä Compatibility Check - Third party only:"
290+
bin/magento m:h:c:c --third-party-only
291+
292+
echo "Test MageForge Hyvä Compatibility Check - Detailed output:"
293+
bin/magento m:h:c:c --show-all --detailed
294+
267295
echo "Test MageForge Static Clean command with dry-run:"
268296
bin/magento mageforge:static:clean --all --dry-run
269297
270298
echo "Test MageForge Static Clean alias:"
271299
bin/magento m:st:c --help
272300
bin/magento frontend:clean --help
273301
302+
274303
- name: Test Summary
275304
run: |
276305
echo "MageForge module compatibility test with Magento 2.4.8 completed"

CHANGELOG.md

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,21 @@ All notable changes to this project will be documented in this file.
88

99
### Added
1010

11+
- feat: add `mageforge:hyva:compatibility:check` command to add a Hyvä compatibility checker
12+
- Scans Magento modules for Hyvä theme compatibility issues
13+
- Detects RequireJS, Knockout.js, jQuery, and UI Components usage
14+
- Interactive menu with Laravel Prompts for scan options
15+
- Options: `--show-all`, `--third-party-only`, `--include-vendor`, `--detailed`
16+
- Color-coded output (✓ Compatible, ⚠ Warnings, ✗ Incompatible)
17+
- Detailed file-level issues with line numbers
18+
- Exit code 1 for critical issues, 0 for success
19+
- Command aliases: `m:h:c:c`, `hyva:check`
1120
- feat: add `mageforge:static:clean` command for comprehensive cache and generated files cleanup
12-
- feat: add interactive multi-theme selection for static:clean command using Laravel Prompts
13-
- feat: add `--all` option to clean all themes at once
14-
- feat: add `--dry-run` option to preview what would be cleaned without deleting
15-
- feat: add command alias `frontend:clean` for quick access
16-
- feat: add CI/CD tests for static:clean command in compatibility workflow
21+
- feat: add interactive multi-theme selection for static:clean command using Laravel Prompts
22+
- feat: add `--all` option to clean all themes at once
23+
- feat: add `--dry-run` option to preview what would be cleaned without deleting
24+
- feat: add command alias `frontend:clean` for quick access
25+
- feat: add CI/CD tests for static:clean command in compatibility workflow
1726

1827
### Changed
1928

docs/commands.md

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,17 @@ All commands in MageForge follow a consistent structure based on Symfony's Conso
1919
**File**: `/src/Console/Command/ListThemeCommand.php`
2020

2121
**Dependencies**:
22+
2223
- `ThemeList` - Service to retrieve theme information
2324

2425
**Usage**:
26+
2527
```bash
2628
bin/magento mageforge:theme:list
2729
```
2830

2931
**Implementation Details**:
32+
3033
- Retrieves all themes from the `ThemeList` service
3134
- Displays a formatted table with theme information (code, title, path)
3235
- Returns success status code
@@ -40,16 +43,19 @@ bin/magento mageforge:theme:list
4043
**File**: `/src/Console/Command/BuildThemeCommand.php`
4144

4245
**Dependencies**:
46+
4347
- `ThemePath` - Service to resolve theme paths
4448
- `ThemeList` - Service to retrieve theme information
4549
- `BuilderPool` - Service to get appropriate builders for themes
4650

4751
**Usage**:
52+
4853
```bash
4954
bin/magento mageforge:theme:build [<themeCodes>...]
5055
```
5156

5257
**Implementation Details**:
58+
5359
- If no theme codes are provided, displays an interactive prompt to select themes
5460
- For each selected theme:
5561
1. Resolves the theme path
@@ -67,16 +73,19 @@ bin/magento mageforge:theme:build [<themeCodes>...]
6773
**File**: `/src/Console/Command/ThemeWatchCommand.php`
6874

6975
**Dependencies**:
76+
7077
- `BuilderPool` - Service to get appropriate builders for themes
7178
- `ThemeList` - Service to retrieve theme information
7279
- `ThemePath` - Service to resolve theme paths
7380

7481
**Usage**:
82+
7583
```bash
7684
bin/magento mageforge:theme:watch [--theme=THEME]
7785
```
7886

7987
**Implementation Details**:
88+
8089
- If no theme code is provided, displays an interactive prompt to select a theme
8190
- Resolves the theme path
8291
- Determines the appropriate builder for the theme type
@@ -126,15 +135,18 @@ bin/magento mageforge:static:clean [<themename>]
126135
**File**: `/src/Console/Command/SystemCheckCommand.php`
127136

128137
**Dependencies**:
138+
129139
- `ProductMetadataInterface` - For retrieving Magento version
130140
- `Escaper` - For HTML escaping output
131141

132142
**Usage**:
143+
133144
```bash
134145
bin/magento mageforge:system:check
135146
```
136147

137148
**Implementation Details**:
149+
138150
- Retrieves and displays:
139151
- PHP version
140152
- Node.js version (with comparison to latest LTS)
@@ -152,35 +164,176 @@ bin/magento mageforge:system:check
152164
**File**: `/src/Console/Command/VersionCommand.php`
153165

154166
**Dependencies**:
167+
155168
- `File` - Filesystem driver for reading files
156169

157170
**Usage**:
171+
158172
```bash
159173
bin/magento mageforge:version
160174
```
161175

162176
**Implementation Details**:
177+
163178
- Reads the current module version from `composer.lock`
164179
- Fetches the latest version from GitHub API
165180
- Displays both versions for comparison
166181

182+
---
183+
184+
### 6. CompatibilityCheckCommand (`mageforge:hyva:compatibility:check`)
185+
186+
**Purpose**: Scans all Magento modules for Hyvä theme compatibility issues such as RequireJS, Knockout.js, jQuery, and UI Components usage.
187+
188+
**File**: `/src/Console/Command/Hyva/CompatibilityCheckCommand.php`
189+
190+
**Dependencies**:
191+
192+
- `CompatibilityChecker` - Main orchestrator service for scanning modules
193+
194+
**Usage**:
195+
196+
```bash
197+
bin/magento mageforge:hyva:compatibility:check [options]
198+
```
199+
200+
**Aliases**:
201+
202+
- `m:h:c:c`
203+
- `hyva:check`
204+
205+
**Options**:
206+
207+
- `--show-all` / `-a` - Show all modules including compatible ones
208+
- `--third-party-only` / `-t` - Check only third-party modules (exclude Magento_* modules)
209+
- `--include-vendor` - Include Magento core modules in scan (default: third-party only)
210+
- `--detailed` / `-d` - Show detailed file-level issues for incompatible modules
211+
212+
**Interactive Mode**:
213+
When running **without any options**, the command launches an interactive menu (using Laravel Prompts):
214+
215+
```bash
216+
# Launch interactive menu
217+
bin/magento m:h:c:c
218+
```
219+
220+
The menu allows you to select:
221+
222+
- ☐ Show all modules including compatible ones
223+
- ☐ Show only incompatible modules (default behavior)
224+
- ☐ Include Magento core modules (default: third-party only)
225+
- ☐ Show detailed file-level issues with line numbers
226+
227+
Use **Space** to toggle options, **Enter** to confirm and start the scan.
228+
229+
**Default Behavior**:
230+
Without any flags, the command scans **third-party modules only** (excludes `Magento_*` modules but includes vendor third-party like Hyva, PayPal, Mollie, etc.).
231+
232+
**Examples**:
233+
234+
```bash
235+
# Basic scan (third-party modules only - DEFAULT)
236+
bin/magento m:h:c:c
237+
238+
# Include Magento core modules
239+
bin/magento m:h:c:c --include-vendor
240+
241+
# Show all modules including compatible ones
242+
bin/magento m:h:c:c -a
243+
244+
# Show detailed file-level issues
245+
bin/magento m:h:c:c -d
246+
247+
# Using full command name
248+
bin/magento mageforge:hyva:compatibility:check --detailed
249+
```
250+
251+
**Implementation Details**:
252+
253+
- Scans module directories for JS, XML, and PHTML files
254+
- Detects incompatibility patterns:
255+
- **Critical Issues**:
256+
- RequireJS `define()` and `require()` usage
257+
- Knockout.js observables and computed properties
258+
- Magento UI Components in XML
259+
- `data-mage-init` and `x-magento-init` in templates
260+
- **Warnings**:
261+
- jQuery AJAX direct usage
262+
- jQuery DOM manipulation
263+
- Block removal in layout XML (review needed)
264+
- Displays results in formatted tables with color-coded status:
265+
- ✓ Green: Compatible modules
266+
- ⚠ Yellow: Warnings (non-critical issues)
267+
- ✗ Red: Incompatible (critical issues)
268+
- ✓ Hyvä-Aware: Modules with Hyvä compatibility packages
269+
- Provides summary statistics:
270+
- Total modules scanned
271+
- Compatible vs. incompatible count
272+
- Hyvä-aware modules count
273+
- Critical issues and warnings count
274+
- Shows detailed file paths and line numbers with `--detailed` flag
275+
- Provides helpful recommendations for resolving issues
276+
- Returns exit code 1 if critical issues are found, 0 otherwise (even if warnings exist)
277+
278+
**Detected Patterns**:
279+
280+
_JavaScript Files (.js)_:
281+
282+
- `define([` - RequireJS module definition
283+
- `require([` - RequireJS dependency loading
284+
- `ko.observable` / `ko.observableArray` / `ko.computed` - Knockout.js
285+
- `$.ajax` / `jQuery.ajax` - jQuery AJAX
286+
- `mage/` - Magento RequireJS module references
287+
288+
_XML Files (.xml)_:
289+
290+
- `<uiComponent` - UI Component declarations
291+
- `component="uiComponent"` - UI Component references
292+
- `component="Magento_Ui/js/` - Magento UI JS components
293+
- `<referenceBlock.*remove="true"` - Block removals
294+
295+
_PHTML Files (.phtml)_:
296+
297+
- `data-mage-init=` - Magento JavaScript initialization
298+
- `x-magento-init` - Magento 2.4+ JavaScript initialization
299+
- `$(.*).` - jQuery DOM manipulation patterns
300+
- `require([` - RequireJS in templates
301+
302+
**Recommendations Provided**:
303+
304+
- Check for Hyvä compatibility packages on hyva.io/compatibility
305+
- Review module vendor documentation for Hyvä support
306+
- Consider refactoring RequireJS/Knockout to Alpine.js
307+
- Contact module vendors for Hyvä-compatible versions
308+
309+
---
310+
167311
## Command Services
168312

169313
The commands rely on several services for their functionality:
170314

315+
### Hyvä Services
316+
317+
- `CompatibilityChecker`: Main orchestrator for Hyvä compatibility scanning
318+
- `ModuleScanner`: Recursively scans module directories for relevant files
319+
- `IncompatibilityDetector`: Pattern matching service for detecting incompatibilities
320+
171321
### Builder Services
322+
172323
- `BuilderPool`: Manages theme builders and selects appropriate builders for themes
173324
- `BuilderInterface`: Implemented by all theme builders
174325
- `MagentoStandard\Builder`: Processes standard Magento LESS-based themes
175326
- Various other builders for different theme types
176327

177328
### Theme Services
329+
178330
- `ThemeList`: Retrieves all installed themes
179331
- `ThemePath`: Resolves theme codes to filesystem paths
180332
- `StaticContentDeployer`: Handles static content deployment
181333
- `CacheCleaner`: Manages cache cleaning after theme builds
182334

183335
### Utility Services
336+
184337
- `DependencyChecker`: Verifies required dependencies for theme building
185338
- `GruntTaskRunner`: Executes Grunt tasks for theme compilation
186339

0 commit comments

Comments
 (0)