public function testNotifyBatch() { $packagesBuilder = new PackagesBuilder(new NullOutput(), vfsStream::url('build'), array('notify-batch' => 'http://localhost:54715/notify', 'repositories' => array(array('type' => 'composer', 'url' => 'http://localhost:54715')), 'require' => array('vendor/name' => '*')), false); $packages = array($this->package); $packagesBuilder->dump($packages); $packagesJson = JsonFile::parseJson($this->root->getChild('build/packages.json')->getContent()); $this->assertEquals('http://localhost:54715/notify', $packagesJson['notify-batch']); }
protected function setFileSystem() { vfsStreamWrapper::register(); $root = vfsStream::newDirectory('build'); vfsStreamWrapper::setRoot($root); $packagesBuilder = new PackagesBuilder(new NullOutput(), vfsStream::url('build'), array('repositories' => array(array('type' => 'composer', 'url' => 'http://localhost:54715')), 'require' => array('vendor/name' => '*')), false); $packagesBuilder->dump(array($this->package)); return $root; }
public function testNominalCase() { $arrayPackage = array("vendor/name" => array("1.0" => array("name" => "vendor/name", "version" => "1.0", "version_normalized" => "1.0.0.0", "type" => "library"))); vfsStreamWrapper::register(); $root = vfsStream::newDirectory('build'); vfsStreamWrapper::setRoot($root); $packagesBuilder = new PackagesBuilder(new NullOutput(), vfsStream::url('build'), array('repositories' => array(array('type' => 'composer', 'url' => 'http://localhost:54715')), 'require' => array('vendor/name' => '*')), false); $packages = array(new Package('vendor/name', '1.0.0.0', '1.0')); $packagesBuilder->dump($packages); $packagesJson = JsonFile::parseJson($root->getChild('build/packages.json')->getContent()); $tmpArray = array_keys($packagesJson['includes']); $includeJson = array_shift($tmpArray); $includeJsonFile = 'build/' . $includeJson; $this->assertTrue(is_file(vfsStream::url($includeJsonFile))); $packagesIncludeJson = JsonFile::parseJson($root->getChild($includeJsonFile)->getContent()); $this->assertEquals($arrayPackage, $packagesIncludeJson['packages']); }
/** * @param InputInterface $input The input instance * @param OutputInterface $output The output instance */ protected function execute(InputInterface $input, OutputInterface $output) { $verbose = $input->getOption('verbose'); $configFile = $input->getArgument('file'); $packagesFilter = $input->getArgument('packages'); $repositoryUrl = $input->getOption('repository-url'); $skipErrors = (bool) $input->getOption('skip-errors'); if ($repositoryUrl !== null && count($packagesFilter) > 0) { throw new \InvalidArgumentException('The arguments "package" and "repository-url" can not be used together.'); } // load auth.json authentication information and pass it to the io interface $io = $this->getIO(); $io->loadConfiguration($this->getConfiguration()); if (preg_match('{^https?://}i', $configFile)) { $rfs = new RemoteFilesystem($io); $contents = $rfs->getContents(parse_url($configFile, PHP_URL_HOST), $configFile, false); $config = JsonFile::parseJson($contents, $configFile); } else { $file = new JsonFile($configFile); if (!$file->exists()) { $output->writeln('<error>File not found: ' . $configFile . '</error>'); return 1; } $config = $file->read(); } // disable packagist by default unset(Config::$defaultRepositories['packagist']); if (!($outputDir = $input->getArgument('output-dir'))) { $outputDir = isset($config['output-dir']) ? $config['output-dir'] : null; } if (null === $outputDir) { throw new \InvalidArgumentException('The output dir must be specified as second argument or be configured inside ' . $input->getArgument('file')); } $composer = $this->getApplication()->getComposer(true, $config); $packageSelection = new PackageSelection($output, $outputDir, $config, $skipErrors); if ($repositoryUrl !== null) { $packageSelection->setRepositoryFilter($repositoryUrl); } else { $packageSelection->setPackagesFilter($packagesFilter); } $packages = $packageSelection->select($composer, $verbose); if (isset($config['archive']['directory'])) { $downloads = new ArchiveBuilder($output, $outputDir, $config, $skipErrors); $downloads->setComposer($composer); $downloads->dump($packages); } if ($packageSelection->hasFilterForPackages()) { // in case of an active package filter we need to load the dumped packages.json and merge the // updated packages in $oldPackages = $packageSelection->load(); $packages += $oldPackages; ksort($packages); } $packagesBuilder = new PackagesBuilder($output, $outputDir, $config, $skipErrors); $packagesBuilder->dump($packages); if ($htmlView = !$input->getOption('no-html-output')) { $htmlView = !isset($config['output-html']) || $config['output-html']; } if ($htmlView) { $web = new WebBuilder($output, $outputDir, $config, $skipErrors); $web->setRootPackage($composer->getPackage()); $web->dump($packages); } }