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
feat: avoid having to remove files in ddev composer create
#5493
#5499
Conversation
ddev composer create
instead of removingddev composer create
instead of removing
ddev composer create
instead of removingddev composer create
instead of removing, helps with #5493
GitHub is all over the place - https://www.githubstatus.com/ |
3fe9466
to
57bf581
Compare
rebased to restart tests |
I'd be a bit interested in you revisiting the very promising before going forward with this one. If you wouldn't mind taking a look at that and thinking about it, I'm sure we can figure out a way for you to either push into it or just start a new PR by forking it. |
Download the artifacts for this pull request:
See Testing a PR |
@rfay I looked at #5058 , from what I gathered, the other one is much bigger and not so related to this one. This one just changes the approach to not remove anything and performs useful validations to whether it should run of not. If the two should be combined into one I'd say to fork the otherone on top of this one, but maybe this one is quicker to get accepted? If you like the approach the changes should be pretty harmless. |
Thanks! This is going to need tests as well, because it's super important. And another thing to think about (another PR) is controlling |
I would assume that all of the tests already there for this functionality should be as useful, if you can thing of anything else to test. One test could be make sure it fails when it has to. I will comment on #5493 as I don't see that much of a need there if this gets in. |
@rfay can you let me know why on ddev/cmd/ddev/cmd/composer_test.go Lines 97 to 114 in 64c9e46
|
It's just testing different things, but using the same project to do it, which saves time. You could change it to deliberately remove (have the test remove the contents) or you could change it to create new projects. |
@rfay this obviously adds a step to some quickstarts, see https://ddev--5499.org.readthedocs.build/en/5499/users/quickstart/#drupal for example. As not every project adds files to the webroot on start this should only be on those that do. I can over other composer create quickstart and check that out. |
Please say why :) It's not so obvious. |
It's not possible to remove some things if they're bind-mounted, like sites/default/files with mutagen. Not sure where you're going with this. |
I've thought about this, the way I undrestood your current code, you are removing them and then recreating it before the first restart. I figured this is not necessary, as another restart happens after |
see if https://ddev--5499.org.readthedocs.build/en/5499/users/quickstart/#drupal is clear enough now. |
Because you are removing things on the host, i don't think that affects the container, the bind mount will be there on restart. |
Not very happy about that :( |
About what? And can you elaborate what would you recommend doing instead? |
Why is the code not doing this programatically? |
Well, the main goal of this PR was to offload arbitrary removal of ddev to the user, so that ddev doesn't have any chance of removing unnecessary things. As it is down, doing a composer create on a wrong folder could have a very bad data loss, that's why I consider this safer. But safer doesn't mean user friendly and you know more about your users than me. I used But I thought of something else that was more work so I didn't go that route, which is removing ONLY what ddev start adds, which probably means adding another hook to your projectMatrix... I can explore that. I prefer not go the route of having ddev remove EVERYTHING inside the docroot, as again, there might be things there that ddev should not remove. Again, let's say you accidentally init in a parent dir that happen to have a web docroot and you wiped that out, not great. |
I guess we're finding out why Another strategy may be to gleefully remove composer_root/vendor, but balk at other subdirectories. |
For the quickstarts, since people are clearly in a new directory, we should be able to sort this out. |
Some other possible safety valves:
|
Also added project type to test dir name
Which fixed yet another bug
improved tests for failure and one special case
5a57d60
to
0852fc2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got to spend some time with this and it's good to go, thanks!
I added one commit, please take a look and see if you're OK with it @hanoii .
It's great that this prevents accidental problems using this command, and I think even if there are any flaws people will understand and clean up their project successfully.
This can go into v1.22.5 this week.
@rfay all good with your last commit! |
Thanks @hanoii and @rfay! Maybe add this in the issue summary, so this PR and its issue gets linked and automatically closed as well? A very impressive effort, and getting the feature available already in the next release is great! |
EDIT: Thanks for clarifying the situation in #5493, I simply misunderstood that the original issue and this PR diverged. |
Basically what I am doing instead of removing everything is:
.ddev
,.git
,.tarballs
and, if configured, the docroot.If any of the validations above fails, the command does not run. This forces you to start on a clean directory without doing any removal, if you have to remove things, you have to do it yourself.
Helps with #5493