Reputation: 249
How can I use composer require vendor/normal_package
and composer require vendor/dev_package --dev
in one single command? I want one CLI command that requires 2 packages, one into "normal" require
and one into require-dev
section.
Background info: I've a composer.json file like this:
{
"require": {
"drupal/core": "^8.6.7"
},
"require-dev": {
"webflo/drupal-core-require-dev": "^8.6.7"
}
}
Those two packages always need to be updated the same time. Usually I just do a composer update drupal/core webflo/drupal-core-require-dev --with-dependencies
which works fine.
But sometimes I explicitly want to require a new minimum version, and I want to do it in a shell script in order to update multiple projects at once (no manual editing of composer.json
). I can't run the two commands
composer require drupal/core:^8.6.10
composer require webflo/drupal-core-require-dev:^8.6.10
consecutively, because they depend on each other.
How can I require a normal and a dev package in one single command?
Upvotes: 3
Views: 7696
Reputation: 249
If you have got a circular dependency in your composer.json
and that dependency is split across require
and require-dev
, then it currently is not possible to update and set a new min version with just one command. But I've found a workaround that saves a lot of time by using the require-command with --no-update
option.
Below is the code I'm currently using (drupal/core
is the normal package, webflo/drupal...
is the dev package, version ^8.7.1
is the new minimum version I want to enforce):
# include both packages in the require section, but don't update
# this is much faster than normal require with update
composer require --no-update drupal/core:^8.7.1 webflo/drupal-core-require-dev:^8.7.1
# move the dev package back into the require-dev section
composer require --dev --no-update webflo/drupal-core-require-dev:^8.7.1
# now run the update, this will take some time (you can not use --no-dev here)
composer update drupal/core webflo/drupal-core-require-dev:^8.7.1 more_stuff/*
# optional: remove the dev-packages again (this is quite fast too)
composer install --no-dev
I won't mark the question as answered though, because this is just a time-saving workaround and not a real solution.
Upvotes: 2