I am using https://packagist.drupal-composer.org/ as Packagist repository for Drupal modules, and I get the version information inside the .info.yml file of the modules I require with composer require
.
I first added the new repository with composer config repositories.drupal composer https://packagist.drupal-composer.org/
. After, I can add any modules, for example the Focal Point module with a command like the following.
composer require drupal/focal_point 8.1.*@dev
The command install the module and its dependencies, producing the following output.
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
- Installing drupal/crop (8.1.0)
Downloading: 100%
> Drupal\Core\Composer\Composer::vendorTestCodeCleanup
- Installing drupal/focal_point (8.1.0-beta3)
Downloading: 100%
> Drupal\Core\Composer\Composer::vendorTestCodeCleanup
drupal/crop suggests installing drupal/media_entity (Required by drupal/crop_media_entity)
Writing lock file
Generating autoload files
> Drupal\Core\Composer\Composer::preAutoloadDump
> Drupal\Core\Composer\Composer::ensureHtaccess
If then I check the content of modules/focal_point/focal_point.info.yml and modules/crop/crop.info.yml, I get the following output.
name: Focal Point
type: module
description: Allows users to specify the focal point of an image for use during cropping.
# core: 8.x
package: Images
# version: VERSION
test_dependencies:
- crop
dependencies:
- image
- crop (>=8.x-1.0-alpha2)
# Information added by Drupal.org packaging script on 2016-09-01
version: '8.x-1.0-beta3'
core: '8.x'
project: 'focal_point'
datestamp: 1472695440
name: Crop API
description: 'Provides storage and API for image crops.'
# core: 8.x
package: Media
type: module
dependencies:
- image
- user
# Information added by Drupal.org packaging script on 2016-05-25
version: '8.x-1.0-rc1'
core: '8.x'
project: 'crop'
datestamp: 1464160143
In both the cases, the information added from the Drupal.org packaging script is present for both the modules (the one I directly required, and it's dependency). I am using this method for all the module I need in my site, and I have never had problems with the version strings.
To update the modules, I just run composer update
, and Composer updates all the modules with a new version that respects the restriction I set for each module.