Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Fix Flex not installing recipes while it is being upgraded #978

Merged
merged 1 commit into from
Oct 22, 2023

Conversation

weaverryan
Copy link
Member

Fixes #977

Here's the lifecycle:

A) Packages are installed/updated and Flex::recordOperations() is called.
B) Composer sees that symfony/flex is updated and unloads the plugin and reloads it under a new Symfony\Flex\Flex_composer_tmp0 class. This results in the Flex::$operations property being lost.
C) And so, no recipes are installed.

This PR "stashes" the operations directly on Symfony/Flex/Flex where we then read them later. Tested locally. Amazing, it seems to work perfectly.

Also, backports #976 to 1.x - my fault for making the PR on the wrong branch.

Cheers!

src/Flex.php Outdated Show resolved Hide resolved
src/Flex.php Outdated Show resolved Hide resolved
@fabpot
Copy link
Member

fabpot commented May 29, 2023

Is it only for 2.x or also for 1.x?

src/Flex.php Outdated Show resolved Hide resolved
src/Flex.php Outdated Show resolved Hide resolved
src/Flex.php Show resolved Hide resolved
@weaverryan weaverryan changed the base branch from 2.x to 1.x May 30, 2023 15:06
@weaverryan
Copy link
Member Author

Is it only for 2.x or also for 1.x?

Also in 1.x. My mistake - I updated the branch target - thanks for catching that.

@weaverryan
Copy link
Member Author

This should be ready to go

@fabpot
Copy link
Member

fabpot commented Oct 22, 2023

Thank you @weaverryan.

@fabpot fabpot merged commit 333abcf into symfony:1.x Oct 22, 2023
7 of 8 checks passed
fabpot added a commit that referenced this pull request Oct 22, 2023
This PR was squashed before being merged into the 1.x branch.

Discussion
----------

AssetMapper: upgrade packages when needed

Hi!

The scenario:

* User installs `symfony/ux-autocomplete`. Flex adds `tom-select` at version `2.2.3` to `importmap.php`
* 3 months later, user upgrades `symfony/ux-autocomplete`. The new version now requires `tom-select` at `^2.5`.

If we do nothing, the user's `tom-select` is out of date and the user won't even know about it. The `^2.5` constraint is defined in the `symfony/ux-autocomplete` [package.json file](https://github.com/symfony/ux/blob/97fe2cd62e70e329b85570e0b797833882930754/src/Autocomplete/assets/package.json#L23), but nothing enforces that or notifies the user.

With this small change, during a composer update/require, we look at the dependencies of all UX packages and compare them against the version in `importmap.php`. If they do not match, the package is upgraded to a version that matches.

<img width="995" alt="Screenshot 2023-10-22 at 1 45 41 PM" src="https://github.com/symfony/flex/assets/121003/286e58b0-d73d-4d7a-bc19-f748b18f489b">

We're not creating a fully-fledge package management by any means, but we don't need to. With a few notifications and things like this, we can keep the user's dependencies in sync with each other.

Unrelated: don't forget about that really cool other PR #978 ;)

Cheers!

Commits
-------

5214615 AssetMapper: upgrade packages when needed
@weaverryan weaverryan deleted the allow-recipes-on-upgrade branch October 22, 2023 18:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Flex does not install recipes if Flex itself is being upgraded
4 participants