name and description are required properties for a strictly valid composer.json file. However, many extensions do not include these properties. This makes them unsuitable for managing with Composer when otherwise they would be. (You don't get dependency resolution, version constraint matching, etc. and are forced to declare a 'package' repository for each extension that you want to manage with Composer. ref
List of steps to reproduce
- Go to any extension directory using your terminal.
- type composer validate
What happens?:
You get publish errors that describe how "name" and "description" are required properties for strict validation.
/var/www/html/extensions/CodeMirror# composer validate ./composer.json is valid for simple usage with Composer but has strict errors that make it unable to be published as a package See https://getcomposer.org/doc/04-schema.md for details on the schema # Publish errors - name : The property name is required - description : The property description is required # General warnings - No license specified, it is recommended to do so. For closed-source software you may use "proprietary" as license.
What should have happened instead?:
composer.json is valid message
/var/www/html/extensions/AdminLinks# composer validate ./composer.json is valid, but with a few warnings See https://getcomposer.org/doc/04-schema.md for details on the schema # General warnings - require.composer/installers : unbound version constraints (>=1.0.1) should be avoided
Positive example:
https://github.com/ProfessionalWiki/bootstrap/blob/master/composer.json
{ "name": "mediawiki/bootstrap", "type": "mediawiki-extension", "description": "Provides the Bootstrap 4 web front-end framework to MediaWiki skins and extensions", "keywords": [ "wiki", "MediaWiki", "extension", "Twitter", "Bootstrap" ], "homepage": "https://www.mediawiki.org/wiki/Extension:Bootstrap", "readme": "README.md", "license": "GPL-3.0-or-later", "authors": [ { "name": "Stephan Gambke", "email": "s7eph4n@protonmail.com", "role": "Developer" }, { "name": "Professional.Wiki", "email": "info@professional.wiki", "homepage": "https://professional.wiki", "role": "Maintainer" } ], "support": { "issues": "https://github.com/cmln/mw-bootstrap/issues", "forum": "https://www.mediawiki.org/wiki/Extension_talk:Bootstrap", "wiki": "https://www.mediawiki.org/wiki/Extension:Bootstrap", "irc": "irc://libera.chat:6667/mediawiki", "source": "https://github.com/cmln/mw-bootstrap", "docs": "https://github.com/cmln/mw-bootstrap/tree/latest/docs", "rss": "https://github.com/cmln/mw-bootstrap/releases.atom" }, "require": { "php": ">=5.6", "composer/installers": "^2|^1.0.1", "mediawiki/scss": "~2.0" }, "require-dev": { "mediawiki/mediawiki-codesniffer": "39.0.0", "mediawiki/mediawiki-phan-config": "0.11.1", "php": ">=7.2" }, "autoload": { "psr-4": { "Bootstrap\\": "src/", "Bootstrap\\Tests\\" : "tests/phpunit/" } }, "scripts": { "test": [ "phpcs -p -s" ], "fix": "phpcbf" }, "extra": { "branch-alias": { "dev-master": "4.x-dev" } } }
other information:
I can find extensions that are valid in MediaWiki code search but I didn't work out the regex to be able to do a negative lookahead (perl-compatible regex is not supported) to generate a list of all the affected extensions.
Additional projects without a 'tag' (there are many more affected extensions, this is just a partial list)
- https://github.com/wikimedia/mediawiki-extensions-NoTitle/blob/master/composer.json
- https://github.com/wikimedia/mediawiki-extensions-NumberFormat/blob/master/composer.json
- https://github.com/wikimedia/mediawiki-extensions-RegexFun/blob/master/composer.json
- https://github.com/wikimedia/mediawiki-extensions-UrlGetParameters/blob/master/composer.json
Recommended Fix:
Simply adding "name": and "description": properties to invalid composer.json files will fix the issue. Important: Extension names in MediaWiki are (almost?) always CamelCase, while the name property for composer.json MUST be lowercase. Simply insert a 'hyphen' (-) character before any capitalized letters in your extension name. If your extension name is PdfHandler, the composer name would be`mediawiki/pdf-handler`
Example: copy/paste to add this to the top of your composer.json file, and revise as needed.
"name": "mediawiki/my-extension", "type": "mediawiki-extension", "description": "Does something great", "keywords": [ "wiki", "MediaWiki", "extension" ], "homepage": "https://www.mediawiki.org/wiki/Extension:MyExtension", "license": "GPL-3.0-or-later",