pyrech / composer-changelogs

:notebook: Display better summary after Composer update
MIT License
589 stars 26 forks source link

Running the auto-commit after composer scripts #45

Closed ohartl closed 6 years ago

ohartl commented 6 years ago

Currently my composer update is executing some composer scripts, which are executing a file generator of the symfony framework. This is required because these files change sometimes when symfony is updated. I'd like to execute the auto-commit after these scripts, so i can add the generated files in the commit.

pyrech commented 6 years ago

Hi. Sorry for the delay. Maybe this issue can be fixed by just changing the default priority of the listener. Could you try to test if setting a negative priority here fix your issue? Thank you!

ohartl commented 6 years ago

Yes, setting the event to priority -1 or lower fixes it. It should be noted that -1 fixes it for now but once other composer plugins are run, with lower priorities, this problem will come again. So either Solution 1 or 2 should be introduced.

Solution 1

The default priority should be (very) low and a new config option for general priority setting

"eventPriority": <prio>

or even per Event

"eventPriority": {
    "post-update-cmd": <prio>,
    "..": <prio>
}

should be introduced.

Solution 2

Or the plugin should handle it in a very smart way and somehow detect when to run best. This behaviour could be optional with runEventsAfterScripts: true enabling it. But it's hard to determine the correct priority when other composer plugins come into play.

pyrech commented 6 years ago

I don't think the solution 2 is worth it. Every plugin will have its own reason to run last, so IMO it's useless to try to determine automatically the right priority.

But I like the solution 1 as it let anyone adjust the priority to their need. The configuration per event is not needed because only the postUpdate handler affects you - other events are only used to collect operations that were performed by Composer. However, that can be quite tricky to achieve because the EventSubscriber's main method is static, so it may not be easy to retrieve the plugin configuration in there.

It would be awesome if you could give it a try :wink: I will also accept a PR setting a default priority to -1 if it fix your problem for now.