drupalorg-cli
drupalorg-cli copied to clipboard
--version option does not report the correct version number
I have version 0.1.1, but drupalorg --version
says 0.0.9
Steps to reproduce
You can see this with a PHAR, or a composer installation. We'll get version 1.1 (the latest current one).
With PHAR
In any directory:
$ wget https://github.com/mglaman/drupalorg-cli/releases/download/v0.1.1/drupalorg.phar
$ chmod u+x drupalorg.phar
$ ./drupalorg.phar --version
Drupal.org CLI 0.0.9
With composer
I reproduced it with a global composer install.
$ composer global require mglaman/drupalorg-cli
Changed current directory to /home/andrew/.composer
Using version ^0.1.1 for mglaman/drupalorg-cli
./composer.json has been updated
...
$ ~/composer/vendor/bin/drupalorg --version
Drupal.org CLI 0.0.9
$ composer global info mglaman/drupalorg-cli
Changed current directory to /home/andrew/.composer
name : mglaman/drupalorg-cli
descrip. : Command line interface for interacting with Drupal.org
keywords :
versions : * v0.1.1
type : library
license : GNU General Public License v2.0 or later (GPL-2.0-or-later) (OSI approved) https://spdx.org/licenses/GPL-2.0-or-later.html#licenseText
homepage :
source : [git] https://github.com/mglaman/drupalorg-cli.git fbcdd65a6f76871a04493c82646790470b3d9f70
dist : [zip] https://api.github.com/repos/mglaman/drupalorg-cli/zipball/fbcdd65a6f76871a04493c82646790470b3d9f70 fbcdd65a6f76871a04493c82646790470b3d9f70
The fix is to borrow what I did in drupal-check
, which utilizes jean85/pretty-package-versions
.
try {
$version = \Jean85\PrettyVersions::getVersion('mglaman/drupal-check')->getPrettyVersion();
} catch (\OutOfBoundsException $e) {
$version = '0.0.0';
}
I borrowed this from PHPStan
Please reopen this
$ php drupalorg.phar --version Drupal.org CLI No version set (parsed as 1.0.0)@
https://github.com/mglaman/drupalorg-cli/pull/65#issuecomment-633305705