Magento Marketplace is going through beta testing before opening up more widely. One area that has become clear is the need for a tool to help with verifying the packaging of extensions before submission. This blog post is a preview into this tool so extension developers can try it out today and provide feedback.
In doing submission walk-throughs with a number of application developers, a common source of friction was getting the ZIP upload “just right”. There is the composer.json file, the overall structure of the ZIP file, etc. Because Composer is a new approach for Magento and it was the first time for many extension developers building a Composer ZIP, there were a few repeating problems that came up. The issues were simple to fix, but wasted time during the submission process. So, we are making a tool available that extension developers can use to detect common problems before they attempt to submit. We are making a beta of this script available now to collect feedback before official release.
The script is currently available as a GIST. [Update Feb 19: V2 now available here.] (This may be taken down in the future when the official release is made.) The current version is a standalone PHP script that takes the Composer package ZIP file(s) on the command line. Errors are reported to the screen. Examples include a missing composer.json file, missing fields in the composer.json file, and so on.
$ php validate_m2_package.php my-theme.zip my-module.zip
Please leave any issues you encounter in the comments section below. Examples of problems include false positives (reported errors that are not really errors) and false negatives (missed problems).
Can’t we have support for sub-directories? Like most of composer libraries have their code place inside a “src/” folder.
The tool seems to be more prescribed than what Magento is able to support (and by extension the marketplace). Zipping this extension up https://github.com/fooman/sameorderinvoicenumber-m2/tree/v2.0.1 seems to be unacceptable to the script even though it works as far as Magento itself is concerned. For example:
composer config repositories.fm0017 vcs https://github.com/fooman/sameorderinvoicenumber-m2.git
composer require fooman/sameorderinvoicenumber-m2
bin/magento module:enable Fooman_SameOrderInvoiceNumber
The extension code would then be installed under ./vendor/fooman/sameorderinvoicenumber-m2.
Hi Alan, there are any plan to release also a phpcs ruleset for static code validation? For example like the old https://github.com/magento-ecg/coding-standard.
Thanks for the feedback.
We are currently reviewing support for the ‘src/‘ approach too.
The current version of the tool supports the layout structure as documented here:
I have uploaded a quickly modified version of the tool which reads the json to work out file locations here https://gist.github.com/fooman/5f76763724af09986462. Let me know if you have examples for further testing and I’ll take a look. It currently sounds like the tool would be the only reason why Marketplace doesn’t “support” this approach.
Just stumbled over this related issue https://github.com/magento/magento2/issues/3400 whereby the component manager makes an assumption that registration.php and composer.json reside in the same folder. Duplicating the composer.json can be used as a workaround but I think this can be solved better.
For anyone else who comes across this blog, this tool has been officially published here: https://github.com/magento/marketplace-tools
When i run this command, I get a huge HTML script. I am not sure if there are any errors or not.