feat: add NodeSetupValidator for validating Magento default setup files#142
feat: add NodeSetupValidator for validating Magento default setup files#142
Conversation
There was a problem hiding this comment.
Pull request overview
This pull request introduces a new NodeSetupValidator service to automatically detect and restore missing Node.js setup files required for Magento Standard theme development. The service integrates into the Magento Standard theme builder workflow, checking for required files (package.json, Gruntfile.js, grunt-config.json) and offering to restore them from the Magento base installation when missing.
Changes:
- Added
NodeSetupValidatorservice to validate and restore Node.js setup files fromvendor/magento/magento2-base - Integrated validation into the Magento Standard theme builder's
processNodeSetup()method to run before other Node/Grunt operations - Configured dependency injection for the new service with required dependencies (FileDriver and NodePackageManager)
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/Service/NodeSetupValidator.php | New service that validates required Node.js files, prompts user for restoration, copies files from Magento base, and runs npm install as needed |
| src/Service/ThemeBuilder/MagentoStandard/Builder.php | Injected NodeSetupValidator dependency and added validation call in processNodeSetup() before autoRepair() |
| src/etc/di.xml | Registered NodeSetupValidator service with FileDriver and NodePackageManager dependencies |
| return confirm( | ||
| label: 'Would you like to restore missing files from Magento base?', | ||
| default: true, | ||
| hint: 'This will copy the standard Magento files to your project root.' | ||
| ); |
There was a problem hiding this comment.
The Laravel Prompts confirm() function should be replaced with $io->confirm() to be consistent with how other service classes handle user prompts. Additionally, the second parameter should be set to true to match the default behavior shown in the Laravel Prompts call (default: true), or adjust as needed for the desired default behavior. See src/Service/DependencyChecker.php lines 52, 71, and 111 for examples of the correct pattern.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This pull request introduces a new service,
NodeSetupValidator, to streamline the validation and restoration of Node.js setup files required for Magento Standard theme development. The service is integrated into the Magento Standard theme builder workflow, ensuring that missing or corrupted Node.js setup files are automatically detected and optionally restored from the Magento base installation, improving reliability and developer experience.The most important changes are:
Node.js Setup Validation and Restoration:
NodeSetupValidator, which checks for the presence of required Node.js setup files and directories (such aspackage.json,Gruntfile.js, andnode_modules/) in the project root, and offers to restore them from the Magento base installation if missing. It also handles generated files likepackage-lock.jsonand can runnpm installas needed. (src/Service/NodeSetupValidator.php)Integration with Theme Builder Workflow:
NodeSetupValidatorservice into the Magento Standard theme builder and updated the node setup process to invoke validation and restoration before proceeding with further build steps. (src/Service/ThemeBuilder/MagentoStandard/Builder.php) [1] [2] [3]Dependency Injection Configuration:
NodeSetupValidatorservice and its dependencies in the DI configuration file to ensure proper instantiation by the framework. (src/etc/di.xml)Thanks therouv for reporting