/**
  * Creates the configuration.
  *
  * @param Puli $puli The Puli service container.
  */
 public function __construct(Puli $puli = null)
 {
     // Start Puli already so that plugins can change the CLI configuration
     $this->puli = $puli ?: new Puli(getcwd());
     if (!$this->puli->isStarted()) {
         $this->puli->start();
     }
     parent::__construct();
 }
Exemple #2
0
 /**
  * Rebuild the puli dependencies for symfony container.
  */
 protected function rebuild(InputInterface $input, OutputInterface $output)
 {
     $puli = new Puli(Path::join([getcwd(), NANBANDO_DIR]));
     $puli->start();
     /** @var EmbeddedComposerInterface $embeddedComposer */
     $embeddedComposer = $this->getApplication()->getEmbeddedComposer();
     $packageManager = $puli->getPackageManager();
     $io = new ConsoleIO($input, $output, $this->getApplication()->getHelperSet());
     $composer = $embeddedComposer->createComposer($io);
     $installationManager = $composer->getInstallationManager();
     $rootPackage = $composer->getPackage();
     $repository = $composer->getRepositoryManager()->getLocalRepository();
     $packages = [];
     foreach ($repository->getPackages() as $package) {
         $packages[$package->getName()] = $package;
     }
     foreach ($rootPackage->getRequires() as $require) {
         if (!array_key_exists($require->getTarget(), $packages)) {
             continue;
         }
         $packageManager->installPackage(Path::normalize($installationManager->getInstallPath($packages[$require->getTarget()])), $require->getTarget(), 'nanbando');
     }
     $filesystem = new Filesystem();
     $filesystem->remove(Path::join([getcwd(), NANBANDO_DIR, '.puli']));
     $discoveryManager = $puli->getDiscoveryManager();
     if (!$discoveryManager->hasRootTypeDescriptor('nanbando/bundle')) {
         $discoveryManager->addRootTypeDescriptor(new BindingTypeDescriptor(new BindingType('nanbando/bundle')), 0);
     }
     $discoveryManager->clearDiscovery();
     $discoveryManager->buildDiscovery();
     $filesystem = new Filesystem();
     $filesystem->remove(Path::join([getcwd(), NANBANDO_DIR, 'app', 'cache']));
 }
Exemple #3
0
 /**
  * @expectedException \Puli\Manager\Api\InvalidConfigException
  */
 public function testFailIfPluginClassNotInstanceOfPuliPlugin()
 {
     $filesystem = new Filesystem();
     $filesystem->copy($this->tempRoot . '/puli-not-a-plugin.json', $this->tempRoot . '/puli.json', true);
     $this->puli->setRootDirectory($this->tempRoot);
     $this->puli->start();
 }