示例#1
0
 /**
  * @param string $baseDir Root directory of composer package.
  */
 public function __construct($baseDir)
 {
     $this->baseDir = $baseDir;
     $io = new NullIO();
     $this->composer = (new Factory())->createComposer($io, $baseDir . '/composer.json', true, $baseDir, false);
     $generator = new AutoloadGenerator($this->composer->getEventDispatcher(), $io);
     $generator->setDevMode(true);
     $packages = $this->composer->getRepositoryManager()->getLocalRepository()->getPackages();
     $packageMap = $generator->buildPackageMap($this->composer->getInstallationManager(), $this->composer->getPackage(), $packages);
     $packageMap[0][1] = $baseDir;
     // To make root package paths absolute too.
     $autoloads = $generator->parseAutoloads($packageMap, $this->composer->getPackage());
     $this->classLoader = $generator->createLoader($autoloads);
 }
示例#2
0
 /**
  * @param array $packageNames
  *
  * @throws \RuntimeException
  */
 public function uninstall(array $packageNames)
 {
     $this->logger->info('Uninstalling begin', $packageNames);
     array_map(function ($name) {
         if (!$this->canBeDeleted($name)) {
             $errorMessage = sprintf('Package %s is not deletable', $name);
             $this->logger->error($errorMessage);
             throw new \RuntimeException($errorMessage);
         }
     }, $packageNames);
     $this->maintenance->activate();
     $this->removeFromComposerJson($packageNames);
     $installationManager = $this->composer->getInstallationManager();
     $localRepository = $this->getLocalRepository();
     $this->composer->getEventDispatcher()->dispatchCommandEvent('cache-clear', false);
     array_map(function ($name) use($installationManager, $localRepository) {
         $package = $this->findInstalledPackage($name);
         $this->scriptRunner->runUninstallScripts($package);
         $installationManager->uninstall($localRepository, new UninstallOperation($package));
     }, $packageNames);
     $this->scriptRunner->removeCachedFiles();
     $this->scriptRunner->clearApplicationCache();
     $this->scriptRunner->runPlatformUpdate();
     $this->scriptRunner->clearDistApplicationCache();
     $this->logger->info('Packages uninstalled', $packageNames);
 }
 /**
  * Apply plugin modifications to composer
  *
  * @param Composer    $composer
  * @param IOInterface $io
  */
 public function activate(Composer $composer, IOInterface $io)
 {
     $this->composer = $composer;
     $this->io = $io;
     $this->eventDispatcher = $composer->getEventDispatcher();
     $this->executor = new ProcessExecutor($this->io);
     $this->patches = array();
 }
 /**
  * @param \Composer\Package\PackageInterface $package
  * @param \Composer\Composer $composer
  */
 public function __construct(PackageInterface $package, Composer $composer)
 {
     parent::__construct($composer->getEventDispatcher());
     $this->_composer = $composer;
     $this->_autoloader = AssetsAutoloadGenerator::getInstance();
     $this->_autoloader->setGenerator(array($this, 'generate'));
     $this->_package = $package;
 }
示例#5
0
 /**
  * Get a Composer object.
  *
  * @return \Composer\Composer
  */
 protected function getComposer()
 {
     if (!$this->composer) {
         // Set working directory
         chdir($this->getOption('basedir'));
         // Use the factory to get a new Composer object
         try {
             $this->composer = Factory::create($this->getIO(), $this->getOption('composerjson'), true);
             // Add the event subscriber
             $this->composer->getEventDispatcher()->addSubscriber($this->app['extend.listener']);
             if (!$this->app['extend.manager']->useSsl()) {
                 $this->setAllowSslDowngrade(true);
             }
         } catch (\Exception $e) {
             $this->app['logger.system']->critical($e->getMessage(), ['event' => 'exception', 'exception' => $e]);
         }
     }
     return $this->composer;
 }
    public function test_it_receives_event()
    {
        $this->composer->getPluginManager()->addPlugin(new ChangelogsPlugin());
        $initialPackage = new Package('foo/bar', '1.0.0.0', 'v1.0.0');
        $initialPackage->setSourceUrl('https://github.com/foo/bar.git');
        $targetPackage = new Package('foo/bar', '1.0.1.0', 'v1.0.1');
        $targetPackage->setSourceUrl('https://github.com/foo/bar.git');
        $operation = new UpdateOperation($initialPackage, $targetPackage);
        $this->composer->getEventDispatcher()->dispatchPackageEvent(PackageEvents::POST_PACKAGE_UPDATE, false, new DefaultPolicy(false, false), new Pool(), new CompositeRepository([]), new Request(new Pool()), [$operation], $operation);
        $this->composer->getEventDispatcher()->dispatchScript(ScriptEvents::POST_UPDATE_CMD);
        $expectedOutput = <<<OUTPUT
Changelogs summary:

 - foo/bar updated from v1.0.0 to v1.0.1
   See changes: https://github.com/foo/bar/compare/v1.0.0...v1.0.1
   Release notes: https://github.com/foo/bar/releases/tag/v1.0.1


OUTPUT;
        $this->assertSame($expectedOutput, $this->io->getOutput());
    }
示例#7
0
文件: BaseAction.php 项目: d-m-/bolt
 /**
  * Get a Composer object.
  *
  * @throws \Exception
  *
  * @return \Composer\Composer
  */
 protected function getComposer()
 {
     if (!$this->composer) {
         // Set working directory
         chdir($this->getOptions()->baseDir());
         try {
             // Use the factory to get a new Composer object
             $this->composer = Factory::create($this->getIO(), $this->getOptions()->composerJson()->getPath(), false);
         } catch (\InvalidArgumentException $e) {
             throw new PackageManagerException($e->getMessage(), $e->getCode(), $e);
         } catch (\Exception $e) {
             $this->app['logger.system']->critical($e->getMessage(), ['event' => 'exception', 'exception' => $e]);
             throw $e;
         }
         // Add the event subscriber
         $this->composer->getEventDispatcher()->addSubscriber($this->app['extend.listener']);
         if (!$this->app['extend.manager']->useSsl()) {
             $this->setAllowSslDowngrade(true);
         }
     }
     return $this->composer;
 }
 public function activate(Composer $composer, IOInterface $io)
 {
     $this->composer = $composer;
     $this->io = $io;
     // check if there already are scripts in .profile.d, or INI files (because we got invoked before), then calculate new starting point for file names
     foreach (['profileCounter' => (getenv('profile_dir_path') ?: '/dev/null') . '/[0-9][0-9][0-9]-*.sh', 'configCounter' => self::CONF_D_PATHNAME . '/[0-9][0-9][0-9]-*.ini'] as $var => $glob) {
         if ($matches = glob($glob)) {
             $this->{$var} = ceil(max(array_merge([$this->{$var}], array_map(function ($e) {
                 return explode('-', pathinfo($e, PATHINFO_FILENAME), 2)[0];
             }, $matches))) / 10) + 1;
         }
     }
     $composer->getDownloadManager()->setDownloader('heroku-sys-tar', new Downloader($io, $composer->getConfig(), $composer->getEventDispatcher()));
     $composer->getInstallationManager()->addInstaller(new ComposerInstaller($io, $composer));
 }
 /**
  * {@inheritdoc}
  */
 public function activate(Composer $composer, IOInterface $io)
 {
     if (!$this->puliRunner) {
         try {
             // Add Composer's bin directory in case the "puli" executable is
             // installed with Composer
             $this->puliRunner = new PuliRunner($composer->getConfig()->get('bin-dir'));
         } catch (RuntimeException $e) {
             $io->writeError('<warn>' . $e->getMessage() . '</warn>');
             // Don't activate the plugin if Puli cannot be run
             return;
         }
     }
     $composer->getEventDispatcher()->addSubscriber($this);
 }
示例#10
0
 /**
  * Set hoa\core require in last position.
  *
  * @param Composer    $composer composer
  * @param IOInterface $io       io
  */
 public function activate(Composer $composer, IOInterface $io)
 {
     $composer->setAutoloadGenerator(new AutoloadGenerator($composer->getEventDispatcher()));
 }
示例#11
0
 /**
  * {@inheritdoc}
  */
 public function activate(Composer $composer, IOInterface $io)
 {
     $composer->getEventDispatcher()->addSubscriber($this);
 }
示例#12
0
 /**
  * @inheritdoc
  */
 public function activate(Composer $composer, IOInterface $io)
 {
     $installer = new Installer();
     $composer->getEventDispatcher()->addSubscriber($installer);
 }
 public function activate(Composer $composer, IOInterface $io)
 {
     $composer->getDownloadManager()->setDownloader('heroku-sys-tar', new Downloader($io, $composer->getConfig(), $composer->getEventDispatcher()));
     $composer->getInstallationManager()->addInstaller(new ComposerInstaller($io, $composer));
 }
示例#14
0
 /**
  * Create Installer
  *
  * @param  IOInterface $io
  * @param  Composer    $composer
  * @return Installer
  */
 public static function create(IOInterface $io, Composer $composer)
 {
     return new static($io, $composer->getConfig(), $composer->getPackage(), $composer->getDownloadManager(), $composer->getRepositoryManager(), $composer->getLocker(), $composer->getInstallationManager(), $composer->getEventDispatcher(), $composer->getAutoloadGenerator());
 }
示例#15
0
 /**
  * Apply plugin modifications to Composer
  *
  * @param Composer    $composer
  * @param IOInterface $io
  */
 public function activate(Composer $composer, IOInterface $io)
 {
     $this->composer = $composer;
     $this->generator = new AutoloadGenerator($composer->getEventDispatcher(), $io);
 }
 public function activate(Composer $composer, IOInterface $io)
 {
     $io->write('<info>Activating the Composer Package Locator plugin</info>');
     $composer->getEventDispatcher()->addSubscriber($this);
 }
 /**
  * {@inheritdoc}
  */
 public function activate(Composer $composer, IOInterface $io)
 {
     $autoloadGenerator = new Autoload\DoctrineAutoloadGenerator($composer->getEventDispatcher(), $io);
     $composer->setAutoloadGenerator($autoloadGenerator);
 }