cweagans / composer-patches

Simple patches plugin for Composer
https://www.cweagans.net/project/composer-patches
BSD 3-Clause "New" or "Revised" License
1.52k stars 239 forks source link

Possibilities to give the command "patches-repatch" options for the composer install #564

Open saschabaecher-twocream opened 6 months ago

saschabaecher-twocream commented 6 months ago

Verification

Is your feature request related to a problem?

Currently you have to use the command patches-repatch to execute the patches, which then executes the normal Composer install routine.

But now you have the problem that you can not use options like --no-dev.

Describe your proposed solution(s)

The possibility to pass the command patches-repatch a new parameter "install-options" with a string in the following format: "--no-dev --no-interactions"

From this you can then store the options in the ArrayInput with the value true with an explode to " ".

Describe alternatives

No response

Additional context

No response

github-actions[bot] commented 6 months ago

👋 Thanks for the idea! Please remember that this is an open source project - feature requests may or may not be implemented, and if they are, the timeline is unknown. If you need a guaranteed implementation or timeline, sponsorships are welcome!

cweagans commented 6 months ago

Seems reasonable! It'll be a bit until I can work on this, but if you open a PR in the mean time, I'd be glad to review!

saschabaecher-twocream commented 5 months ago

Hi @cweagans, with pleasure! PR is created.

mfrieling commented 4 months ago

I was looking if an issue for this problem already exists or not and am lucky to see a PR already. I hope this gets released soon.

Another way to think about this would be a --pre-install option. In my projects I usually use two custom composer scripts which look like this:

"scripts": {
  "deploy-staging": [
    "git pull -p",
    "@composer validate",
    "@composer install --optimize-autoloader"
  ],
  "deploy": [
    "git pull -p",
    "@composer validate",
    "@composer install --no-dev --optimize-autoloader"
  ]
}

With the --pre-install option this would be possible:

"scripts": {
  "pre-install-cmd": [
    "@composer patches-repatch --pre-install"
  ],
  "deploy-staging": [
    "git pull -p",
    "@composer validate",
    "@composer install --optimize-autoloader"
  ],
  "deploy": [
    "git pull -p",
    "@composer validate",
    "@composer install --no-dev --optimize-autoloader"
  ]
}

This way patches-repatch would do its job as part of the composer install pre-hooks without executing the composer install by itself. Currently this is not possible because that would lead to an endless loop.