Example #1
0
 /**
  * pre-fetch parallel by curl_multi
  */
 public function onPostDependenciesSolving(Installer\InstallerEvent $ev)
 {
     $ops = $ev->getOperations();
     $packages = $this->filterPackages($ops);
     $pluginConfig = $this->getConfig();
     if (count($packages) >= $pluginConfig['minConnections']) {
         $downloader = new ParallelDownloader($this->io, $this->config);
         $downloader->download($packages, $pluginConfig);
     }
 }
 public function testGetter()
 {
     $composer = $this->getMock('Composer\\Composer');
     $io = $this->getMock('Composer\\IO\\IOInterface');
     $policy = $this->getMock('Composer\\DependencyResolver\\PolicyInterface');
     $pool = $this->getMockBuilder('Composer\\DependencyResolver\\Pool')->disableOriginalConstructor()->getMock();
     $installedRepo = $this->getMockBuilder('Composer\\Repository\\CompositeRepository')->disableOriginalConstructor()->getMock();
     $request = $this->getMockBuilder('Composer\\DependencyResolver\\Request')->disableOriginalConstructor()->getMock();
     $operations = array($this->getMock('Composer\\DependencyResolver\\Operation\\OperationInterface'));
     $event = new InstallerEvent('EVENT_NAME', $composer, $io, true, $policy, $pool, $installedRepo, $request, $operations);
     $this->assertSame('EVENT_NAME', $event->getName());
     $this->assertInstanceOf('Composer\\Composer', $event->getComposer());
     $this->assertInstanceOf('Composer\\IO\\IOInterface', $event->getIO());
     $this->assertTrue($event->isDevMode());
     $this->assertInstanceOf('Composer\\DependencyResolver\\PolicyInterface', $event->getPolicy());
     $this->assertInstanceOf('Composer\\DependencyResolver\\Pool', $event->getPool());
     $this->assertInstanceOf('Composer\\Repository\\CompositeRepository', $event->getInstalledRepo());
     $this->assertInstanceOf('Composer\\DependencyResolver\\Request', $event->getRequest());
     $this->assertCount(1, $event->getOperations());
 }
 /**
  * Prints a list of links to package changelogs on the post-dependencies-solving event.
  *
  * @param InstallerEvent $event
  */
 public function onPostDependenciesSolving(InstallerEvent $event)
 {
     $changelogs = [];
     $operations = $event->getOperations();
     foreach ($operations as $operation) {
         if ($operation instanceof UpdateOperation) {
             try {
                 $changelogs[] = self::getChangelog($operation->getInitialPackage(), $operation->getTargetPackage());
             } catch (Exception\CouldNotCalculateChangelog $e) {
                 $changelogs[] = $e->getMessage();
             }
         }
     }
     if (!empty($changelogs)) {
         $this->io->write(self::PAD_STR . 'CHANGELOGS:');
         foreach ($changelogs as $changelog) {
             $this->io->write(self::PAD_STR . self::PAD_STR . $changelog);
         }
     }
 }
 public function postDependencySolve(InstallerEvent $event)
 {
     if (!$this->enabled) {
         return;
     }
     $extra = $event->getComposer()->getPackage()->getExtra();
     $uninstall = array_get($extra, 'xpressengine-plugin.uninstall', []);
     foreach ($event->getOperations() as $operation) {
         /** @var UpdateOperation $operation */
         if (is_subclass_of($operation, UpdateOperation::class) || is_subclass_of($operation, InstallOperation::class)) {
             $target = $operation->getInitialPackage();
             if (in_array($target->getName(), $uninstall)) {
                 throw new \Exception('xpressengine-installer: To install or update the package requested to delete is not allowed.', 66);
             }
         }
     }
 }
Example #5
0
 /**
  * Handle an event callback for pre-dependency solving phase of an install
  * or update by adding any duplicate package dependencies found during
  * initial merge processing to the request that will be processed by the
  * dependency solver.
  *
  * @param InstallerEvent $event
  */
 public function onDependencySolve(InstallerEvent $event)
 {
     $request = $event->getRequest();
     foreach ($this->state->getDuplicateLinks('require') as $link) {
         $this->logger->info("Adding dependency <comment>{$link}</comment>");
         $request->install($link->getTarget(), $link->getConstraint());
     }
     if ($this->state->isDevMode()) {
         foreach ($this->state->getDuplicateLinks('require-dev') as $link) {
             $this->logger->info("Adding dev dependency <comment>{$link}</comment>");
             $request->install($link->getTarget(), $link->getConstraint());
         }
     }
 }
Example #6
0
 /**
  * Add pool in plugin.
  *
  * @param InstallerEvent $event
  */
 public function onPreDependenciesSolving(InstallerEvent $event)
 {
     $this->pool = $event->getPool();
 }
Example #7
0
 /**
  * Handle an event callback for pre-dependency solving phase of an install
  * or update by adding any duplicate package dependencies found during
  * initial merge processing to the request that will be processed by the
  * dependency solver.
  *
  * @param InstallerEvent $event
  */
 public function onDependencySolve(InstallerEvent $event)
 {
     if (!$this->duplicateLinks) {
         return;
     }
     $request = $event->getRequest();
     foreach ($this->duplicateLinks['require'] as $link) {
         $this->debug("Adding dependency <comment>{$link}</comment>");
         $request->install($link->getTarget(), $link->getConstraint());
     }
     if ($this->devMode) {
         foreach ($this->duplicateLinks['require-dev'] as $link) {
             $this->debug("Adding dev dependency <comment>{$link}</comment>");
             $request->install($link->getTarget(), $link->getConstraint());
         }
     }
 }
Example #8
0
 /**
  * Constructor.
  *
  * @param string               $eventName
  * @param Composer             $composer
  * @param IOInterface          $io
  * @param bool                 $devMode
  * @param PolicyInterface      $policy
  * @param Pool                 $pool
  * @param CompositeRepository  $installedRepo
  * @param Request              $request
  * @param OperationInterface[] $operations
  * @param OperationInterface   $operation
  */
 public function __construct($eventName, Composer $composer, IOInterface $io, $devMode, PolicyInterface $policy, Pool $pool, CompositeRepository $installedRepo, Request $request, array $operations, OperationInterface $operation)
 {
     parent::__construct($eventName, $composer, $io, $devMode, $policy, $pool, $installedRepo, $request, $operations);
     $this->operation = $operation;
 }
Example #9
0
 /**
  * pre-fetch parallel by curl_multi
  */
 public function onPostDependenciesSolving(Installer\InstallerEvent $ev)
 {
     if ($this->disabled) {
         return;
     }
     $prefetcher = new Prefetcher();
     $prefetcher->fetchAllFromOperations($this->io, $this->config, $ev->getOperations());
 }
 public static function preDependencySolving(InstallerEvent $event)
 {
     // add repo for resolving dependencies - hum, will it work?
     $that = self::$instance;
     $event->getPool()->addRepository($that->repo);
 }
 /**
  * Handle an event callback for pre-dependency solving phase of an install
  * or update by adding any duplicate package dependencies found during
  * initial merge processing to the request that will be processed by the
  * dependency solver.
  *
  * @param InstallerEvent $event
  */
 public function onDependencySolve(InstallerEvent $event)
 {
     if (empty($this->duplicateLinks)) {
         // @codeCoverageIgnoreStart
         // We shouldn't really ever be able to get here as this event is
         // triggered inside Composer\Installer and should have been
         // preceded by a pre-install or pre-update event but better to
         // have an unneeded check than to break with some future change in
         // the event system.
         return;
         // @codeCoverageIgnoreEnd
     }
     $request = $event->getRequest();
     foreach ($this->duplicateLinks['require'] as $link) {
         $this->debug("Adding dependency <comment>{$link}</comment>");
         $request->install($link->getTarget(), $link->getConstraint());
     }
     if ($this->devMode) {
         foreach ($this->duplicateLinks['require-dev'] as $link) {
             $this->debug("Adding dev dependency <comment>{$link}</comment>");
             $request->install($link->getTarget(), $link->getConstraint());
         }
     }
 }
 /**
  * Handle an event callback for pre-dependency solving phase of an install
  * or update by adding any duplicate package dependencies found during
  * initial merge processing to the request that will be processed by the
  * dependency solver.
  *
  * @param InstallerEvent $event
  */
 public function onDependencySolve(InstallerEvent $event)
 {
     $request = $event->getRequest();
     foreach ($this->state->getDuplicateLinks('require') as $link) {
         $this->logger->info("Adding dependency <comment>{$link}</comment>");
         $request->install($link->getTarget(), $link->getConstraint());
     }
     // Issue #113: Check devMode of event rather than our global state.
     // Composer fires the PRE_DEPENDENCIES_SOLVING event twice for
     // `--no-dev` operations to decide which packages are dev only
     // requirements.
     if ($this->state->shouldMergeDev() && $event->isDevMode()) {
         foreach ($this->state->getDuplicateLinks('require-dev') as $link) {
             $this->logger->info("Adding dev dependency <comment>{$link}</comment>");
             $request->install($link->getTarget(), $link->getConstraint());
         }
     }
 }
 /**
  * Check that there is only 1 core package required
  */
 public function checkCoreDependencies(InstallerEvent $event)
 {
     $installedCorePackages = array();
     foreach ($event->getInstalledRepo()->getPackages() as $package) {
         if ($package->getType() === $this->type) {
             $installedCorePackages[$package->getName()] = $package;
         }
     }
     $operations = array_filter($event->getOperations(), function (OperationInterface $o) {
         return in_array($o->getJobType(), array('install', 'uninstall'));
     });
     foreach ($operations as $operation) {
         $p = $operation->getPackage();
         if ($p->getType() === $this->type) {
             switch ($operation->getJobType()) {
                 case "uninstall":
                     unset($installedCorePackages[$p->getName()]);
                     break;
                 case "install":
                     $installedCorePackages[$p->getName()] = $p;
                     break;
             }
         }
     }
     if (count($installedCorePackages) > 1) {
         throw new \RuntimeException("Cannot use more than 1 core package");
     }
 }
Example #14
0
 /**
  * Handle an event callback for pre-dependency solving phase of an install
  * or update by adding any duplicate package dependencies found during
  * initial merge processing to the request that will be processed by the
  * dependency solver.
  *
  * @param  \Composer\Installer\InstallerEvent  $event
  */
 public function onDependencySolve(InstallerEvent $event)
 {
     $request = $event->getRequest();
     $this->installRequires($request, $this->state->getDuplicateLinks('require'));
     // Check devMode of event rather than our global state.
     // Composer fires the PRE_DEPENDENCIES_SOLVING event twice for `--no-dev`
     // operations to decide which packages are dev only requirements.
     if ($this->state->shouldMergeDev() && $event->isDevMode()) {
         $this->installRequires($request, $this->state->getDuplicateLinks('require-dev'), true);
     }
 }