Skip to content
Open
Show file tree
Hide file tree
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
26 changes: 26 additions & 0 deletions .github/workflows/magento-compatibility.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,19 @@ jobs:
echo "Test MageForge Theme List command:"
bin/magento mageforge:theme:list

echo "Test MageForge Hyvä Compatibility Check command:"
bin/magento mageforge:hyva:compatibility:check --help
bin/magento m:h:c:c --help

echo "Test MageForge Hyvä Compatibility Check - Show all modules:"
bin/magento mageforge:hyva:compatibility:check --show-all

echo "Test MageForge Hyvä Compatibility Check - Third party only:"
bin/magento m:h:c:c --third-party-only

echo "Test MageForge Hyvä Compatibility Check - Detailed output:"
bin/magento m:h:c:c --show-all --detailed

- name: Test Summary
run: |
echo "MageForge module compatibility test with Magento ${{ matrix.magento-version }} completed"
Expand Down Expand Up @@ -255,6 +268,19 @@ jobs:
echo "Test MageForge Theme List command:"
bin/magento mageforge:theme:list

echo "Test MageForge Hyvä Compatibility Check command:"
bin/magento mageforge:hyva:compatibility:check --help
bin/magento m:h:c:c --help

echo "Test MageForge Hyvä Compatibility Check - Show all modules:"
bin/magento mageforge:hyva:compatibility:check --show-all

echo "Test MageForge Hyvä Compatibility Check - Third party only:"
bin/magento m:h:c:c --third-party-only

echo "Test MageForge Hyvä Compatibility Check - Detailed output:"
bin/magento m:h:c:c --show-all --detailed

- name: Test Summary
run: |
echo "MageForge module compatibility test with Magento 2.4.8 completed"
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@ All notable changes to this project will be documented in this file.

## UNRELEASED

### Added

- feat: add Hyvä compatibility checker command (`mageforge:hyva:compatibility:check`)
- Scans Magento modules for Hyvä theme compatibility issues
- Detects RequireJS, Knockout.js, jQuery, and UI Components usage
- Interactive menu with Laravel Prompts for scan options
- Options: `--show-all`, `--third-party-only`, `--include-vendor`, `--detailed`
- Color-coded output (✓ Compatible, ⚠ Warnings, ✗ Incompatible)
- Detailed file-level issues with line numbers
- Exit code 1 for critical issues, 0 for success
- Command aliases: `m:h:c:c`, `hyva:check`

## Latest Release

### [0.2.2] - 2025-06-05
Expand Down
153 changes: 153 additions & 0 deletions docs/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,17 @@ All commands in MageForge follow a consistent structure based on Symfony's Conso
**File**: `/src/Console/Command/ListThemeCommand.php`

**Dependencies**:

- `ThemeList` - Service to retrieve theme information

**Usage**:

```bash
bin/magento mageforge:theme:list
```

**Implementation Details**:

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

**Dependencies**:

- `ThemePath` - Service to resolve theme paths
- `ThemeList` - Service to retrieve theme information
- `BuilderPool` - Service to get appropriate builders for themes

**Usage**:

```bash
bin/magento mageforge:theme:build [<themeCodes>...]
```

**Implementation Details**:

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

**Dependencies**:

- `BuilderPool` - Service to get appropriate builders for themes
- `ThemeList` - Service to retrieve theme information
- `ThemePath` - Service to resolve theme paths

**Usage**:

```bash
bin/magento mageforge:theme:watch [--theme=THEME]
```

**Implementation Details**:

- If no theme code is provided, displays an interactive prompt to select a theme
- Resolves the theme path
- Determines the appropriate builder for the theme type
Expand All @@ -92,15 +101,18 @@ bin/magento mageforge:theme:watch [--theme=THEME]
**File**: `/src/Console/Command/SystemCheckCommand.php`

**Dependencies**:

- `ProductMetadataInterface` - For retrieving Magento version
- `Escaper` - For HTML escaping output

**Usage**:

```bash
bin/magento mageforge:system:check
```

**Implementation Details**:

- Retrieves and displays:
- PHP version
- Node.js version (with comparison to latest LTS)
Expand All @@ -118,35 +130,176 @@ bin/magento mageforge:system:check
**File**: `/src/Console/Command/VersionCommand.php`

**Dependencies**:

- `File` - Filesystem driver for reading files

**Usage**:

```bash
bin/magento mageforge:version
```

**Implementation Details**:

- Reads the current module version from `composer.lock`
- Fetches the latest version from GitHub API
- Displays both versions for comparison

---

### 6. CompatibilityCheckCommand (`mageforge:hyva:compatibility:check`)

**Purpose**: Scans all Magento modules for Hyvä theme compatibility issues such as RequireJS, Knockout.js, jQuery, and UI Components usage.

**File**: `/src/Console/Command/Hyva/CompatibilityCheckCommand.php`

**Dependencies**:

- `CompatibilityChecker` - Main orchestrator service for scanning modules

**Usage**:

```bash
bin/magento mageforge:hyva:compatibility:check [options]
```

**Aliases**:

- `m:h:c:c`
- `hyva:check`

**Options**:

- `--show-all` / `-a` - Show all modules including compatible ones
- `--third-party-only` / `-t` - Check only third-party modules (exclude Magento\_\* modules)
- `--include-vendor` - Include Magento core modules in scan (default: third-party only)
- `--detailed` / `-d` - Show detailed file-level issues for incompatible modules

**Interactive Mode**:
When running **without any options**, the command launches an interactive menu (using Laravel Prompts):

```bash
# Launch interactive menu
bin/magento m:h:c:c
```

The menu allows you to select:

- ☐ Show all modules including compatible ones
- ☐ Show only incompatible modules (default behavior)
- ☐ Include Magento core modules (default: third-party only)
- ☐ Show detailed file-level issues with line numbers

Use **Space** to toggle options, **Enter** to confirm and start the scan.

**Default Behavior**:
Without any flags, the command scans **third-party modules only** (excludes `Magento_*` modules but includes vendor third-party like Hyva, PayPal, Mollie, etc.).

**Examples**:

```bash
# Basic scan (third-party modules only - DEFAULT)
bin/magento m:h:c:c

# Include Magento core modules
bin/magento m:h:c:c --include-vendor

# Show all modules including compatible ones
bin/magento m:h:c:c -a

# Show detailed file-level issues
bin/magento m:h:c:c -d

# Using full command name
bin/magento mageforge:hyva:compatibility:check --detailed
```

**Implementation Details**:

- Scans module directories for JS, XML, and PHTML files
- Detects incompatibility patterns:
- **Critical Issues**:
- RequireJS `define()` and `require()` usage
- Knockout.js observables and computed properties
- Magento UI Components in XML
- `data-mage-init` and `x-magento-init` in templates
- **Warnings**:
- jQuery AJAX direct usage
- jQuery DOM manipulation
- Block removal in layout XML (review needed)
- Displays results in formatted tables with color-coded status:
- ✓ Green: Compatible modules
- ⚠ Yellow: Warnings (non-critical issues)
- ✗ Red: Incompatible (critical issues)
- ✓ Hyvä-Aware: Modules with Hyvä compatibility packages
- Provides summary statistics:
- Total modules scanned
- Compatible vs. incompatible count
- Hyvä-aware modules count
- Critical issues and warnings count
- Shows detailed file paths and line numbers with `--detailed` flag
- Provides helpful recommendations for resolving issues
- Returns exit code 1 if critical issues are found, 0 otherwise (even if warnings exist)

**Detected Patterns**:

_JavaScript Files (.js)_:

- `define([` - RequireJS module definition
- `require([` - RequireJS dependency loading
- `ko.observable` / `ko.observableArray` / `ko.computed` - Knockout.js
- `$.ajax` / `jQuery.ajax` - jQuery AJAX
- `mage/` - Magento RequireJS module references

_XML Files (.xml)_:

- `<uiComponent` - UI Component declarations
- `component="uiComponent"` - UI Component references
- `component="Magento_Ui/js/` - Magento UI JS components
- `<referenceBlock.*remove="true"` - Block removals

_PHTML Files (.phtml)_:

- `data-mage-init=` - Magento JavaScript initialization
- `x-magento-init` - Magento 2.4+ JavaScript initialization
- `$(.*).` - jQuery DOM manipulation patterns
- `require([` - RequireJS in templates

**Recommendations Provided**:

- Check for Hyvä compatibility packages on hyva.io/compatibility
- Review module vendor documentation for Hyvä support
- Consider refactoring RequireJS/Knockout to Alpine.js
- Contact module vendors for Hyvä-compatible versions

---

## Command Services

The commands rely on several services for their functionality:

### Hyvä Services

- `CompatibilityChecker`: Main orchestrator for Hyvä compatibility scanning
- `ModuleScanner`: Recursively scans module directories for relevant files
- `IncompatibilityDetector`: Pattern matching service for detecting incompatibilities

### Builder Services

- `BuilderPool`: Manages theme builders and selects appropriate builders for themes
- `BuilderInterface`: Implemented by all theme builders
- `MagentoStandard\Builder`: Processes standard Magento LESS-based themes
- Various other builders for different theme types

### Theme Services

- `ThemeList`: Retrieves all installed themes
- `ThemePath`: Resolves theme codes to filesystem paths
- `StaticContentDeployer`: Handles static content deployment
- `CacheCleaner`: Manages cache cleaning after theme builds

### Utility Services

- `DependencyChecker`: Verifies required dependencies for theme building
- `GruntTaskRunner`: Executes Grunt tasks for theme compilation

Expand Down
Loading