/**
  * @param PackageInterface $package
  * @param string $packageSourceDirectory
  * @return Entry
  */
 public function make(PackageInterface $package, $packageSourceDirectory)
 {
     $entry = new Entry();
     $entry->setPackageName($package->getName());
     $strategy = $this->deploystrategyFactory->make($package, $packageSourceDirectory);
     $mappingParser = $this->parserFactory->make($package, $packageSourceDirectory);
     $strategy->setMappings($mappingParser->getMappings());
     $entry->setDeployStrategy($strategy);
     return $entry;
 }
 /**
  * @param PackageInterface[] $packagesToInstall
  */
 public function doInstalls(array $packagesToInstall)
 {
     foreach ($packagesToInstall as $install) {
         $installStrategy = $this->installStrategyFactory->make($install, $this->getPackageSourceDirectory($install));
         $deployEntry = new Entry();
         $deployEntry->setPackageName($install->getPrettyName());
         $deployEntry->setDeployStrategy($installStrategy);
         $this->eventManager->dispatch(new PackageDeployEvent('pre-package-deploy', $deployEntry));
         $files = $installStrategy->deploy()->getDeployedFiles();
         $this->eventManager->dispatch(new PackageDeployEvent('post-package-deploy', $deployEntry));
         $this->installedPackageRepository->add(new InstalledPackage($install->getName(), $this->createVersion($install), $files));
     }
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     // init repos
     $composer = $this->getComposer();
     $installedRepo = $composer->getRepositoryManager()->getLocalRepository();
     $dm = $composer->getDownloadManager();
     $im = $composer->getInstallationManager();
     /**
      * @var $moduleInstaller \MagentoHackathon\Composer\Magento\Installer
      */
     $moduleInstaller = $im->getInstaller("magento-module");
     $eventManager = new EventManager();
     $deployManager = new DeployManager($eventManager);
     $io = $this->getIo();
     if ($io->isDebug()) {
         $eventManager->listen('pre-package-deploy', function (PackageDeployEvent $event) use($io) {
             $io->write('Start magento deploy for ' . $event->getDeployEntry()->getPackageName());
         });
     }
     $extra = $composer->getPackage()->getExtra();
     $sortPriority = isset($extra['magento-deploy-sort-priority']) ? $extra['magento-deploy-sort-priority'] : array();
     $deployManager->setSortPriority($sortPriority);
     $moduleInstaller->setDeployManager($deployManager);
     foreach ($installedRepo->getPackages() as $package) {
         if ($input->getOption('verbose')) {
             $output->writeln($package->getName());
             $output->writeln($package->getType());
         }
         if ($package->getType() != "magento-module") {
             continue;
         }
         if ($input->getOption('verbose')) {
             $output->writeln("package {$package->getName()} recognized");
         }
         $strategy = $moduleInstaller->getDeployStrategy($package);
         if ($input->getOption('verbose')) {
             $output->writeln("used " . get_class($strategy) . " as deploy strategy");
         }
         $strategy->setMappings($moduleInstaller->getParser($package)->getMappings());
         $deployManagerEntry = new Entry();
         $deployManagerEntry->setPackageName($package->getName());
         $deployManagerEntry->setDeployStrategy($strategy);
         $deployManager->addPackage($deployManagerEntry);
     }
     $deployManager->doDeploy();
     return;
 }
Example #4
0
 /**
  * Updates specific package
  *
  * @param InstalledRepositoryInterface $repo    repository in which to check
  * @param PackageInterface             $initial already installed package version
  * @param PackageInterface             $target  updated version
  *
  * @throws InvalidArgumentException if $from package is not installed
  */
 public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
 {
     if ($target->getType() === 'magento-core' && !$this->preUpdateMagentoCore()) {
         return;
     }
     // cleanup marshaled files if extra->map exist
     if ($this->hasExtraMap($initial)) {
         $initialStrategy = $this->getDeployStrategy($initial);
         $initialStrategy->setMappings($this->getParser($initial)->getMappings());
         try {
             $initialStrategy->clean();
         } catch (\ErrorException $e) {
             if ($this->io->isDebug()) {
                 $this->io->write($e->getMessage());
             }
         }
     }
     parent::update($repo, $initial, $target);
     // marshal files for new package version if extra->map exist
     if ($this->hasExtraMap($target)) {
         $targetStrategy = $this->getDeployStrategy($target);
         $targetStrategy->setMappings($this->getParser($target)->getMappings());
         $deployManagerEntry = new Entry();
         $deployManagerEntry->setPackageName($target->getName());
         $deployManagerEntry->setDeployStrategy($targetStrategy);
         $this->deployManager->addPackage($deployManagerEntry);
     }
     if ($this->appendGitIgnore) {
         $this->appendGitIgnore($target, $this->getGitIgnoreFileLocation());
     }
     if ($target->getType() === 'magento-core') {
         $this->postUpdateMagentoCore();
     }
 }
 /**
  * @param PackageInterface $package
  *
  * @throws \ErrorException
  */
 protected function addEntryToDeployManager(PackageInterface $package)
 {
     $targetStrategy = $this->getDeployStrategy($package);
     $targetStrategy->setMappings($this->getParser($package)->getMappings());
     $deployManagerEntry = new Entry();
     $deployManagerEntry->setPackageName($package->getName());
     $deployManagerEntry->setDeployStrategy($targetStrategy);
     $deployManagerEntry->getDeployStrategy()->deploy();
 }
 /**
  * Updates specific package
  *
  * @param InstalledRepositoryInterface $repo    repository in which to check
  * @param PackageInterface             $initial already installed package version
  * @param PackageInterface             $target  updated version
  *
  * @throws InvalidArgumentException if $from package is not installed
  */
 public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
 {
     if ($target->getType() === 'magento-core' && !$this->preUpdateMagentoCore()) {
         return;
     }
     $initialStrategy = $this->getDeployStrategy($initial);
     $initialStrategy->setMappings($this->getParser($initial)->getMappings());
     $initialStrategy->clean();
     parent::update($repo, $initial, $target);
     $targetStrategy = $this->getDeployStrategy($target);
     $targetStrategy->setMappings($this->getParser($target)->getMappings());
     $deployManagerEntry = new Entry();
     $deployManagerEntry->setPackageName($target->getName());
     $deployManagerEntry->setDeployStrategy($targetStrategy);
     $this->deployManager->addPackage($deployManagerEntry);
     if ($this->appendGitIgnore) {
         $this->appendGitIgnore($target, $this->getGitIgnoreFileLocation());
     }
     if ($target->getType() === 'magento-core') {
         $this->postUpdateMagentoCore();
     }
 }