getConfig(); $httpBasicCredentials = []; $pm = new DependabotPluginManager($io, $composer, null, false); $composer->setPluginManager($pm); $pm->loadInstalledPlugins(); foreach ($gitCredentials as &$cred) { $httpBasicCredentials[$cred['host']] = [ 'username' => $cred['username'], 'password' => $cred['password'], ]; } foreach ($registryCredentials as &$cred) { $httpBasicCredentials[$cred['registry']] = [ 'username' => $cred['username'], 'password' => $cred['password'], ]; } if ($httpBasicCredentials) { $config->merge( [ 'config' => [ 'http-basic' => $httpBasicCredentials, ], ] ); $io->loadConfiguration($config); } $install = new Installer( $io, $config, $composer->getPackage(), $composer->getDownloadManager(), $composer->getRepositoryManager(), $composer->getLocker(), $composer->getInstallationManager(), $composer->getEventDispatcher(), $composer->getAutoloadGenerator() ); // For all potential options, see UpdateCommand in composer $install ->setWriteLock(true) ->setUpdate(true) ->setDevMode(true) ->setUpdateAllowList([$dependencyName]) ->setAllowListTransitiveDependencies(true) ->setExecuteOperations(false) ->setDumpAutoloader(false) ->setRunScripts(false) ->setIgnorePlatformRequirements(false); $install->run(); $result = [ 'composer.lock' => file_get_contents('composer.lock'), ]; chdir($originalDir); return $result; } }