-
-
Notifications
You must be signed in to change notification settings - Fork 585
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
fix: pass all valid options to nested commands in ddev composer create
, fixes #6300, fixes #6246, for #5058
#6303
base: master
Are you sure you want to change the base?
Conversation
Download the artifacts for this pull request:
See Testing a PR. |
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.
Could you please add test coverage for this? Thanks! We have been fiddling with ddev composer create
for years and years now, and we keep incrementally improving it, but we never seem to completely get it finished.
Yes, I will add some new test or modify an existing one. |
a693d1f
to
4f748c8
Compare
I added more conditions and checks to the test, now it covers most possible situations. |
composer-create
, fixes #6300composer-create
, fixes #6300, for #5058
Confirmed. This PR fixes #6300 . Thank you for the quick turn around. Test
$ ddev -v
ddev version v1.23.1-62-g4f748c85a
mkdir my-cakephp-site && cd my-cakephp-site
ddev config --project-type=cakephp --docroot=webroot
ddev composer create --prefer-dist --no-interaction cakephp/app:~5.0
ddev cake
ddev launch Note This PR updates the quickstart to include |
There is still some difference how composer scripts work in:
I will investigate this further today and adjust the behavior. |
4f748c8
to
a5635db
Compare
The order was:
The right order:
This is why I made This is not a breaking change, because I moved If you passed If I refactored the test logic to make it more clear and added more tests. I removed the testing for the |
composer-create
, fixes #6300, for #5058composer-create
, fixes #6300, fixes #6246, for #5058
composer-create
, fixes #6300, fixes #6246, for #5058ddev composer create
, fixes #6300, fixes #6246, for #5058
When I split combined short flags, it broke |
a5635db
to
b4ae1d4
Compare
Rebased. I fixed I updated our documentation with a more detailed explanation of what steps we do with I researched the Composer documentation, learned more about what
I'm pretty sure the most of the original logic here works correctly. There are some conflicts with the |
b4ae1d4
to
50f7a91
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 just looked through the docs, not code, had minor comments.
@@ -40,7 +40,14 @@ For example: | |||
|
|||
When using `ddev composer create` your project should be essentially empty or the command will refuse to run, to avoid loss of your files. | |||
|
|||
By default `--no-plugins` and `--no-scripts` options are used while cloning the project and `composer install` is executed afterwards as long as `--no-install` is not provided. When using `--preserve-flags` plugins and scripts are allowed during the cloning step. | |||
Standard order of operations for `ddev composer create`: |
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 sure like this section!
Standard order of operations for `ddev composer create`: | |
`ddev composer create` does these things in this order: |
Standard order of operations for `ddev composer create`: | ||
|
||
1. `composer create-project --no-plugins --no-scripts --no-install` clones a bare Composer package without any additional actions. | ||
2. `composer run-script post-root-package-install` runs if `--no-scripts` is not provided manually. |
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.
2. `composer run-script post-root-package-install` runs if `--no-scripts` is not provided manually. | |
2. `composer run-script post-root-package-install` runs if `--no-scripts` is not given as a flag to `ddev composer create`. |
|
||
1. `composer create-project --no-plugins --no-scripts --no-install` clones a bare Composer package without any additional actions. | ||
2. `composer run-script post-root-package-install` runs if `--no-scripts` is not provided manually. | ||
3. `composer install` runs if `--no-install` is not provided manually. |
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.
3. `composer install` runs if `--no-install` is not provided manually. | |
3. `composer install` runs if `--no-install` is not given as a flag to `ddev composer create`. |
1. `composer create-project --no-plugins --no-scripts --no-install` clones a bare Composer package without any additional actions. | ||
2. `composer run-script post-root-package-install` runs if `--no-scripts` is not provided manually. | ||
3. `composer install` runs if `--no-install` is not provided manually. | ||
4. `composer run-script post-create-project-cmd` runs if `--no-scripts` is not provided manually. |
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.
4. `composer run-script post-create-project-cmd` runs if `--no-scripts` is not provided manually. | |
4. `composer run-script post-create-project-cmd` runs if `--no-scripts` is not given as a flag to `ddev composer create`. |
@rpkoller would you be willing to validate the quickstarts with this PR? I know it's loads of work, but your attention is so valuable. |
The Issue
ddev composer create
fully compatible withcomposer create-project
#5058Composer options were not respected by
composer run-script
.How This PR Solves The Issue
Makes
ddev composer create
fully compatible with all possible composer options. I removed all the hard-coded options.Adds composer options to
composer run-script
.Adds
--no-interaction
to CakePHP quickstart.--preserve-flags
(which doesn't add--no-plugins
and--no-scripts
) didn't work as expected, I decided to remove it.This is not a breaking change, because
--preserve-flags
didn't work before (it was alwaysfalse
).I moved
composer run-script post-create-project-cmd
outside the condition forcomposer install
, to make it work the same way as incomposer create-project
.If you passed
--no-scripts
, DDEV tried to runcomposer run-script
, which was wrong behavior, fixed it.If
--help
or--version
flags were provided, composer showed it's help page or it's version, and DDEV tried to continue creating the project, which was wrong behavior, fixed it.I refactored the test logic to make it more clear and added more tests. I removed the testing for the
psr/log
package and replaced it with custom-made fake packages.Manual Testing Instructions
ddev composer create
must be the same as forcomposer create-project
.To check this behavior, you can use a test repository (it is used for
testdata
here) which contains all the necessary situations to check:test/ddev-composer-create
package (.ddev/test-ddev-composer-create/composer.json
) contains this:test/ddev-require
fromrequire
section:vendor/test/ddev-require
will be here, but only if there is no--no-install
flagtest/ddev-require-dev
fromrequire-dev
section:vendor/test/ddev-require-dev
will be here, but only if there is no--no-dev
/--no-install
flagpost-root-package-install
script:composer install
created-by-post-root-package-install
file, but only if there is no--no-scripts
flagpost-create-project-cmd
script:composer install
created-by-post-create-project-cmd
file, but only if there is no--no-scripts
flagAnd use different flag combinations to see how it works for
composer create-project
andddev composer create
. It is important to check if the commands run in the same order.Available flags for
composer create-project
https://getcomposer.org/doc/03-cli.md#create-projectIgnore the
test-ddev-require
andtest-ddev-require-dev
directories created in the project root (they are expected to be created every time as they are part of the composer package).Every
ddev composer create
will have this output:You can see what flags are used for each of these composer commands, and flags like
--no-interaction
will be also used forcomposer run-script
andcomposer install
.For example:
This should not create
vendor
folder, and there should be nocreated-by-*
filesThis should create
vendor/test/ddev-require
folder, (but notvendor/test/ddev-require-dev
) and there should be nocreated-by-*
filesAnd so on.
Steps To Reproduce
example (it should not ask for input) from:Automated Testing Overview
Release/Deployment Notes