Skip to content

Add a dedicated file deletion for unconfigure recipes #706

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

Closed
wants to merge 1 commit into from

Conversation

maxhelias
Copy link
Contributor

Re-open #667

In this way, we correct the deletion of the same file imported by 2 recipes.
Factoring in this way would allow us to remove the $lock parameter passing in the unconfigure method and with a little more work in the configure.

WDYT about this way ? Can I continue in this direction?

tgalopin pushed a commit to tgalopin/flex that referenced this pull request Dec 3, 2020
@nicolas-grekas nicolas-grekas changed the base branch from main to 1.x November 22, 2021 18:19
@maxhelias
Copy link
Contributor Author

Outdated and should be resolve in #845

@maxhelias maxhelias closed this Dec 17, 2021
@nicolas-grekas
Copy link
Member

@maxhelias up to rebase this for 2.x?
It looks like we might need this: removing phpunit-bridge currently removes files that should be kept for phpunit when it remains and you had the answer apparently.

@nicolas-grekas nicolas-grekas changed the base branch from 1.x to 2.x May 20, 2025 15:11
@maxhelias
Copy link
Contributor Author

@nicolas-grekas Yes, of course, I think I'll have to work on it again after all this time 😅

@maxhelias maxhelias force-pushed the files-manager branch 2 times, most recently from afbeaaa to b2e4615 Compare May 23, 2025 10:08
@maxhelias
Copy link
Contributor Author

@nicolas-grekas Everything looks good to me. To be fair, the solution isn’t entirely mine — it actually comes from a conversation we had about five years ago 😅 #615 (comment)

Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks cool thanks!

I don't know if this a real-world concern but the change on the signature of the configurator's constructors is a BC break.
This would break anyone adding their own configurator, if any.
Maybe we can update the code with this concern in mind just to be on the safe side?

It'd mean we could wrap the FilesManager in the Options class possibly? (that'd easy reintroduce the shouldWriteFile method + OptionsTest, which could be marked deprecated / legacy respectively?)

An alternative would be to add a setter on AbstractConfigurator.

WDYT?

@maxhelias
Copy link
Contributor Author

maxhelias commented May 23, 2025

Yes, it's a BC for custom configurators. These cases should be very limited, though, as the list of configurators is hard-coded and not extensible within the Symfony\Flex\Configurator class

Encapsulating the FilesManager in the Options class seems like the simplest and safest solution. I had initially left out the shouldWriteFile method to better separate concerns -- to keep Options free of any dependency on IOInterface. That said, reintroducing shouldWriteFile through FilesManager feels acceptable in this case, as it avoids any BCs while keeping IOInterface out of Options.

And the alternative, add a setter on AbstractConfigurator. That would preserve separation of concerns, but it would also make configurators mutable. Even though we control the instantiation flow, I'm a bit hesitant about introducing that mutability.

@nicolas-grekas
Copy link
Member

I agree, let's go with the first option. 🙏

@nicolas-grekas
Copy link
Member

I'm going to take over the PR if you don't, apply my own review comments and a few more things I found while giving it a try. Also because we'd like this to be ready early next week.
Thanks for starting the task!

@maxhelias maxhelias force-pushed the files-manager branch 3 times, most recently from 691c878 to 0404948 Compare May 25, 2025 17:02
@maxhelias
Copy link
Contributor Author

maxhelias commented May 25, 2025

@nicolas-grekas If you want it for the beginning of the week, please take it, I won't have time for that.

I pushed what I'd started at the end of the week as it was.

@nicolas-grekas
Copy link
Member

I'm going to open a new PR, the current one is too far from the target, I had to rewrite almost everything :)
Thanks for submitting, this helps a lot to move forward on the topic!

@maxhelias
Copy link
Contributor Author

Don't hesitate to ping me for a review if needed 😉

nicolas-grekas added a commit that referenced this pull request May 28, 2025
…pes (nicolas-grekas)

This PR was merged into the 2.x branch.

Discussion
----------

Don't remove still-referenced files when unconfiguring recipes

Instead of #706
Fixes broken logic added in #451, which didn't account for folders.
The new logic uses only the symfony.lock file and not the recipe anymore to decide which files to remove.

Commits
-------

6443e31 Don't remove still-referenced files when unconfiguring recipes
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.

2 participants