public function onPostPackageInstall(PackageEvent $event)
 {
     if (!in_array($event->getOperation()->getPackage()->getType(), ['heroku-sys-php', 'heroku-sys-hhvm', 'heroku-sys-php-extension', 'heroku-sys-hhvm-extension', 'heroku-sys-webserver'])) {
         return;
     }
     $this->initAllPlatformRequirements($event->getOperations());
     try {
         $this->configurePackage($event->getOperation()->getPackage());
         $this->enableReplaces($event->getOperation()->getPackage());
         $this->writeProfile($event->getOperation()->getPackage());
         $this->writeExport($event->getOperation()->getPackage());
     } catch (\Exception $e) {
         $this->io->writeError(sprintf('<error>Failed to activate package %s</error>', $event->getOperation()->getPackage()->getName()));
         $this->io->writeError('');
         throw $e;
     }
 }
Esempio n. 2
0
 /**
  * Gather patches from dependencies and store them for later use.
  *
  * @param PackageEvent $event
  */
 public function gatherPatches(PackageEvent $event)
 {
     // If we've already done this, then don't do it again.
     if (isset($this->patches['_patchesGathered'])) {
         $this->io->write('<info>Patches already gathered. Skipping</info>');
         return;
     } elseif (!$this->isPatchingEnabled()) {
         $this->io->write('<info>Patching is disabled. Skipping.</info>');
         return;
     }
     $this->patches = $this->grabPatches();
     if (empty($this->patches)) {
         $this->io->write('<info>No patches supplied.</info>');
     }
     $extra = $this->composer->getPackage()->getExtra();
     $patches_ignore = isset($extra['patches-ignore']) ? $extra['patches-ignore'] : [];
     // Now add all the patches from dependencies that will be installed.
     $operations = $event->getOperations();
     $this->io->write('<info>Gathering patches for dependencies. This might take a minute.</info>');
     foreach ($operations as $operation) {
         if ($operation->getJobType() == 'install' || $operation->getJobType() == 'update') {
             $package = $this->getPackageFromOperation($operation);
             $extra = $package->getExtra();
             if (isset($extra['patches'])) {
                 if (isset($patches_ignore[$package->getName()])) {
                     foreach ($patches_ignore[$package->getName()] as $package => $patches) {
                         if (isset($extra['patches'][$package])) {
                             $extra['patches'][$package] = array_diff($extra['patches'][$package], $patches);
                         }
                     }
                 }
                 $this->patches = array_merge_recursive($this->patches, $extra['patches']);
             }
             // Unset installed patches for this package
             if (isset($this->installedPatches[$package->getName()])) {
                 unset($this->installedPatches[$package->getName()]);
             }
         }
     }
     // Merge installed patches from dependencies that did not receive an update.
     foreach ($this->installedPatches as $patches) {
         $this->patches = array_merge_recursive($this->patches, $patches);
     }
     // If we're in verbose mode, list the projects we're going to patch.
     if ($this->io->isVerbose()) {
         foreach ($this->patches as $package => $patches) {
             $number = count($patches);
             $this->io->write('<info>Found ' . $number . ' patches for ' . $package . '.</info>');
         }
     }
     // Make sure we don't gather patches again. Extra keys in $this->patches
     // won't hurt anything, so we'll just stash it there.
     $this->patches['_patchesGathered'] = TRUE;
 }
Esempio n. 3
0
 /**
  * Creates and returns a new PackageEvent with the given operation.
  *
  * @param PackageEvent $event
  * @param OperationInterface $operation
  * @return PackageEvent
  */
 private function createPackageEventWithOperation(PackageEvent $event, OperationInterface $operation)
 {
     return new PackageEvent($event->getName(), $this->composer, $this->io, $event->isDevMode(), $event->getPolicy(), $event->getPool(), $event->getInstalledRepo(), $event->getRequest(), $event->getOperations(), $operation);
 }
Esempio n. 4
0
 public function downloadPackages(\Composer\Installer\PackageEvent $event)
 {
     // exit early, if no downloader was found
     if ($this->tool === false) {
         $this->io->write('Skipping downloading, because Composer couldn\'t find a suitable download tool.');
         $this->io->write('You might install one of the following tools: aria2');
         //, wget, curl.
         return;
     }
     $installedPackage = $event->getOperation()->getPackage();
     if ('jakoch/composer-fastfetch' === $installedPackage->getPrettyName()) {
         $this->downloader->downloadPackages($event->getOperations());
     }
 }