Problem/Motivation
The recipe unpacker is, in effect, a version lock. When you unpack a recipe and remove it from Composer's awareness, you are pinning it to that specific version.
That's all well and good, but it means we have no way to interrogate Composer to ask which version of the recipe was installed -- which is very much necessary for, say, downloading the correct translation of the recipe.
Normally you'd use the version field in composer.json for that, but there is no guarantee that will be set, because Composer can and does infer versions from things like Git tags and such.
Proposed resolution
The recipe unpacker should alter the unpacked recipe's composer.json file and write the version field explicitly. It has access to the version because it has access to the PackageInterface object and its getPrettyVersion() method.
| Comment | File | Size | Author |
|---|
Issue fork drupal-3607162
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
phenaproximaComment #4
smustgrave commentedShould I see a version key added to the recipe?
Comment #5
phenaproximaTo the recipe's composer.json, yeah.
Comment #6
smustgrave commentedSorry trying to help test this one.
I applied the MR, downloaded a recipe via composer, but not seeing VERSION key.
Comment #7
smustgrave commentedGoing to do a lot of leaning on other sources here.
1. I trust what @phenaproxima is suggesting around recipes.
2. MR is green, I did rebase as it was 500+ commits behind.
3. I had to run the test-only locally
Failed asserting that a NULL is not empty.
/var/www/html/core/tests/Drupal/BuildTests/Composer/Plugin/Unpack/Functional/UnpackRecipeTest.php:691
/var/www/html/core/tests/Drupal/BuildTests/Composer/Plugin/Unpack/Functional/UnpackRecipeTest.php:94
Failed asserting that a NULL is not empty.
/var/www/html/core/tests/Drupal/BuildTests/Composer/Plugin/Unpack/Functional/UnpackRecipeTest.php:691
/var/www/html/core/tests/Drupal/BuildTests/Composer/Plugin/Unpack/Functional/UnpackRecipeTest.php:226
Going to go on a limb
Comment #8
catchChanging the recipe's composer.json seems a bit unexpected, I wouldn't expect the local site to change that.
Could we put this information into vendor/composer - like vendor/composer/unpacked-recipes.json or similar? (note this is a proper question not a concrete suggestion because I don't know how hard that would be).
Comment #9
phenaproximaNot hard at all, actually. I've implemented this and updated the tests.
Comment #10
phenaproximaComment #11
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #12
phenaproxima