Closed sljgcovas closed 2 months ago
Showing the version was removed in #1653 by @dereuromark, where I think the rationale was that updating the version
field in composer.json
was constantly forgotten on releases and so the info was wrong. From https://github.com/cakephp/phinx/pull/1653#issuecomment-564967668, I do think using vendor/composer/installed.php
as the easiest way to re-incorporate this without having to deal with manually incrementing a version field. Just need to also validate that this file gets packed into the phar archive as well.
Could it read the version from the composer lock file etc?
Yeah, there's three files we could use:
composer.lock
vendor/composer/installed.json
vendor/composer/composer.php
The first two files have the downside of that we have to load the JSON and parse it, and then do a search through an array to find robmorgan/phinx
. Additionally, for development within this repo, those files will not have a reference at all for it.
The third file has the advantage where we can just require the file and then can look up the name like $installed['versions']['robmorgan/phinx']['pretty_version']
and that it'll also have an entry for within the repo (0.x-dev
) which is nice.
We could also use the composer-runtime-api
to further simplify things and then could do \Composer\InstalledVersions::getPrettyVersion('robmorgan/phinx')
, though this does have the downside of requiring composer 2.0+ which is probably true, though not sure it's worth mandating.
For those of us that use Phinx as standalone tool, it may be convenient that
--version
argument actually displays the version number and not only "hey, I'm Phinx":The
--help
says:-V, --version
Display this application versionThanks :)