Open tklie opened 2 years ago
If I'm following the upstream Composer source correctly, the --no-scripts
cli flag eventually turns into an EventDispatcher->setRunScripts(false)
call which sets a protected $this->runScripts
member variable.
There are getEventDispatcher()
and setEventDispatcher()
methods in PartialComposer, so we might be able to grab the EventDispatcher from $this->composer
inside of our onPostInstallOrUpdate
callback and pass it on to the fresh Composer instance passed to the $installer
in that same method.
I haven't done the same tracing through the Composer 1.x code base. If the same things are not implemented in 1.x this should probably be considered blocked on #243.
@tklie Hey Tim, have you solved this problem in the end?
@Mohammad-Alavi I did - not to my complete satisfaction, tbh, but I needed a quick fix. I ended up forking the plugin, getting the ConsoleIO
and Input
options (no-plugins
and no-scripts
) from the event
using reflection, and then passing them to the factory method that creates the new composer instance.
Right now, if a project root does not already contain a
vendor
folder (e.g. on initial project setup), acomposer install --no-scripts
does not respect the--no-scripts
option and instead executes scripts (e.g.post-autoload-dump
scripts) after the install.This is causing problems for us when trying to containerize Laravel applications in a CI context, where basically every build is an initial install. We use a
post-autoload-dump
script which triggers Laravel's package discovery. This then fails because it is trying to register services that for example require secrets only passed in at runtime.After a quick source code dive, this seems to be due to the
MergePlugin
running composer update to apply merge settings without passing thedisableScripts
parameter (which also apparently was not available yet in composer 2.0) to the newly instantiated composer instance (i.e. factory method) when the original composer command was executed as such.Example files
composer.json
composer-shared.json