public function applyOverlay(PackageEvent $packageEvent)
 {
     switch ($packageEvent->getOperation()->getJobType()) {
         case 'install':
             $package = $packageEvent->getOperation()->getPackage();
             break;
         case 'update':
             $package = $packageEvent->getOperation() - getTargetPackage();
             break;
         default:
             return;
     }
     if (Installer\CoreInstaller::INSTALLER_TYPE === $package->getType()) {
         $extra = $packageEvent->getComposer()->getPackage()->getExtra();
         if (empty($extra['wordpress'])) {
             return;
         }
         $config = $extra['wordpress'];
         if (!empty($config['core-path']) && !empty($config['overlay-path'])) {
             $filesystem = new Filesystem();
             $corePath = $packageEvent->getComposer()->getInstallationManager()->getInstaller($package->getType())->getInstallPath($package);
             $overlayPath = $config['overlay-path'];
             $filesystem->mirror($overlayPath, $corePath, null, array('override' => true));
         }
     }
 }
 /**
  * Calls actions and install scripts provided by installed packages.
  *
  * @param \Composer\Script\PackageEvent $event
  * @return void
  * @throws Exception\UnexpectedOperationException
  */
 public static function postPackageUpdateAndInstall(PackageEvent $event)
 {
     $operation = $event->getOperation();
     if (!$operation instanceof InstallOperation && !$operation instanceof UpdateOperation) {
         throw new Exception\UnexpectedOperationException('Handling of operation with type "' . $operation->getJobType() . '" not supported', 1348750840);
     }
     $package = $operation->getJobType() === 'install' ? $operation->getPackage() : $operation->getTargetPackage();
     $packageExtraConfig = $package->getExtra();
     $installPath = $event->getComposer()->getInstallationManager()->getInstallPath($package);
     $evaluatedInstallerResources = false;
     if (isset($packageExtraConfig['neos']['installer-resource-folders'])) {
         foreach ($packageExtraConfig['neos']['installer-resource-folders'] as $installerResourceDirectory) {
             static::copyDistributionFiles($installPath . $installerResourceDirectory);
         }
         $evaluatedInstallerResources = true;
     }
     if (isset($packageExtraConfig['typo3/flow']['post-install']) && $operation->getJobType() === 'install') {
         self::runPackageScripts($packageExtraConfig['typo3/flow']['post-install']);
     }
     if (isset($packageExtraConfig['typo3/flow']['post-update']) && $operation->getJobType() === 'update') {
         self::runPackageScripts($packageExtraConfig['typo3/flow']['post-update']);
     }
     // TODO: Deprecated from Flow 3.1 remove three versions after.
     if (!$evaluatedInstallerResources && isset($packageExtraConfig['typo3/flow']['manage-resources']) && $packageExtraConfig['typo3/flow']['manage-resources'] === true) {
         static::copyDistributionFiles($installPath . 'Resources/Private/Installer/');
     }
 }
Exemplo n.º 3
0
 /**
  * Calls actions and install scripts provided by installed packages.
  *
  * @param \Composer\Script\PackageEvent $event
  * @return void
  * @throws Exception\UnexpectedOperationException
  */
 public static function postPackageUpdateAndInstall(PackageEvent $event)
 {
     $operation = $event->getOperation();
     if (!$operation instanceof \Composer\DependencyResolver\Operation\InstallOperation && !$operation instanceof \Composer\DependencyResolver\Operation\UpdateOperation) {
         throw new Exception\UnexpectedOperationException('Handling of operation with type "' . $operation->getJobType() . '" not supported', 1348750840);
     }
     $package = $operation->getJobType() === 'install' ? $operation->getPackage() : $operation->getTargetPackage();
     $packageExtraConfig = $package->getExtra();
     if (isset($packageExtraConfig['typo3/flow'])) {
         if (isset($packageExtraConfig['typo3/flow']['post-install']) && $operation->getJobType() === 'install') {
             self::runPackageScripts($packageExtraConfig['typo3/flow']['post-install']);
         } elseif (isset($packageExtraConfig['typo3/flow']['post-update']) && $operation->getJobType() === 'update') {
             self::runPackageScripts($packageExtraConfig['typo3/flow']['post-update']);
         }
         $installPath = $event->getComposer()->getInstallationManager()->getInstallPath($package);
         $relativeInstallPath = str_replace(getcwd() . '/', '', $installPath);
         if (isset($packageExtraConfig['typo3/flow']['manage-resources']) && $packageExtraConfig['typo3/flow']['manage-resources'] === TRUE) {
             if (is_dir($relativeInstallPath . '/Resources/Private/Installer/Distribution/Essentials')) {
                 Files::copyDirectoryRecursively($relativeInstallPath . '/Resources/Private/Installer/Distribution/Essentials', './', FALSE, TRUE);
             }
             if (is_dir($relativeInstallPath . '/Resources/Private/Installer/Distribution/Defaults')) {
                 Files::copyDirectoryRecursively($relativeInstallPath . '/Resources/Private/Installer/Distribution/Defaults', './', TRUE, TRUE);
             }
         }
     }
 }
Exemplo n.º 4
0
 /**
  * Вызов инсталлятора из composer
  * @param PackageEvent $event
  * @return type
  */
 public static function package(PackageEvent $event)
 {
     // консоль
     $io = $event->getIO();
     // устанавливаемый модуль
     $package = $event->getOperation()->getPackage();
     // только для модулей /podvincev-n/
     if (preg_match('#podvincev-n/([^/]+)#', $package->getName(), $match)) {
         $packageName = $match[1];
     } else {
         $io->write("> skip install " . $package->getName() . ": not /podvincev-n/", true);
         return false;
     }
     $composer = $event->getComposer();
     $composerConfig = $composer->getConfig();
     $installationManager = $composer->getInstallationManager();
     $installationPath = $installationManager->getInstallPath($package);
     $installationFile = $installationPath . '/Install.php';
     $basePath = dirname($composerConfig->get('vendor-dir'));
     if (file_exists($installationFile)) {
         $io->write("> installation file: " . $installationFile, true);
         $installerClass = (require_once $installationFile);
         $installer = new $installerClass(array('yiiConsoleApp' => self::getYiiConsoleApp($basePath), 'path' => $installationPath, 'name' => $packageName, 'io' => $io, 'migrationPath' => static::getMigrationPath($basePath), 'configPath' => static::getYiipConfigPath($basePath) . $packageName));
         $installer->install();
         $io->write("---", true);
         $io->write("", true);
     } else {
         $io->write("> no installation file", true);
         $io->write("", true);
     }
     return true;
 }
Exemplo n.º 5
0
 /**
  * Remove ignored files of the installed package defined in the root
  * package extra section.
  *
  * @param PackageEvent $event
  */
 public static function deleteIgnoredFiles(PackageEvent $event)
 {
     if (null === ($package = static::getLibraryPackage($event->getOperation()))) {
         return;
     }
     $section = static::getIgnoreExtraSection();
     $manager = IgnoreFactory::create($event->getComposer(), $package, null, $section);
     $manager->cleanup();
 }
 /**
  * Remove the installed library from the lib Magento folder
  *
  * @param PackageEvent $event
  */
 public static function cleanPackageAction(PackageEvent $event)
 {
     $extras = $event->getComposer()->getPackage()->getExtra();
     if (isset($extras['magento-root-dir'])) {
         $magentoPath = $extras['magento-root-dir'];
         if (is_dir($magentoPath . 'lib/YellowCube')) {
             self::_recursiveRmDir($magentoPath . 'lib/YellowCube');
         }
         if (is_dir($magentoPath . 'lib/Assert')) {
             self::_recursiveRmDir($magentoPath . 'lib/Assert');
         }
         if (is_dir($magentoPath . 'lib/Wse')) {
             self::_recursiveRmDir($magentoPath . 'lib/Wse');
         }
         if (is_dir($magentoPath . 'lib/Psr')) {
             self::_recursiveRmDir($magentoPath . 'lib/Psr');
         }
     }
 }
Exemplo n.º 7
0
 /**
  * @param PackageEvent $event
  * @throws \Exception
  */
 public function postInstall(PackageEvent $event)
 {
     // Get the package object for the current operation.
     $operation = $event->getOperation();
     /** @var PackageInterface $package */
     $package = $this->getPackageFromOperation($operation);
     $package_name = $package->getName();
     if (!isset($this->patches[$package_name])) {
         if ($this->io->isVerbose()) {
             $this->io->write('<info>No patches found for ' . $package_name . '.</info>');
         }
         return;
     }
     $this->io->write('  - Applying patches for <info>' . $package_name . '</info>');
     // Get the install path from the package object.
     $manager = $event->getComposer()->getInstallationManager();
     $install_path = $manager->getInstaller($package->getType())->getInstallPath($package);
     // Set up a downloader.
     $downloader = new RemoteFilesystem($this->io, $this->composer->getConfig());
     // Track applied patches in the package info in installed.json
     $localRepository = $this->composer->getRepositoryManager()->getLocalRepository();
     $localPackage = $localRepository->findPackage($package_name, $package->getVersion());
     $extra = $localPackage->getExtra();
     $extra['patches_applied'] = array();
     foreach ($this->patches[$package_name] as $description => $url) {
         $this->io->write('    <info>' . $url . '</info> (<comment>' . $description . '</comment>)');
         try {
             $this->eventDispatcher->dispatch(NULL, new PatchEvent(PatchEvents::PRE_PATCH_APPLY, $package, $url, $description));
             $this->getAndApplyPatch($downloader, $install_path, $url);
             $this->eventDispatcher->dispatch(NULL, new PatchEvent(PatchEvents::POST_PATCH_APPLY, $package, $url, $description));
             $extra['patches_applied'][$description] = $url;
         } catch (\Exception $e) {
             $this->io->write('   <error>Could not apply patch! Skipping. The error was: ' . $e->getMessage() . '</error>');
             if (getenv('COMPOSER_EXIT_ON_PATCH_FAILURE')) {
                 throw new \Exception("Cannot apply patch {$description} ({$url})!");
             }
         }
     }
     $localPackage->setExtra($extra);
     $this->io->write('');
     $this->writePatchReport($this->patches[$package_name], $install_path);
 }
Exemplo n.º 8
0
 /**
  * Detects changes to config fixtures in the newly updated version of a
  * given package. Also installs any new configs fixtures not in this
  * installations config directory.
  *
  * The user is warned if a difference is detected, as they should manually
  * check to see what has changed.
  *
  * @param  PackageEvent $event The post-update package event
  *
  * @return void|false          Returns false if the method needn't run
  */
 public static function postUpdate(PackageEvent $event)
 {
     if (!static::isPackageCompatible($event->getOperation()->getInitialPackage())) {
         return false;
     }
     $package = $event->getOperation()->getInitialPackage();
     $fixtureDir = static::getConfigFixtureDir($event->getComposer(), $package);
     $workingDir = static::getWorkingDir();
     try {
         $fixtures = static::getFixtures($fixtureDir);
         if (!$fixtures) {
             return false;
         }
         foreach ($fixtures as $fixture) {
             $file = $workingDir . 'config/' . $fixture;
             $packageName = $event->getOperation()->getInitialPackage()->getPrettyName();
             // If config file for this fixture exists, detect + report any change in the fixture
             if (file_exists($file)) {
                 $checksum = md5_file($fixtureDir . $fixture);
                 if (isset(static::$_updatedFixtures[$package->getPrettyName()][$fixture]) && $checksum !== static::$_updatedFixtures[$package->getPrettyName()][$fixture]) {
                     $event->getIO()->write(sprintf('<warning>Package `%s` config fixture `%s` has changed: please review manually.</warning>', $package->getPrettyName(), $fixture));
                 }
             } else {
                 copy($fixtureDir . $fixture, $file);
                 $event->getIO()->write(sprintf('<info>Moved package `%s` config fixture `%s` to application config directory.</info>', $packageName, $fixture));
             }
         }
     } catch (Exception $e) {
         $event->getIO()->write('<error>' . $e->getMessage() . '</error>');
     }
 }