コード例 #1
0
 /**
  * Execute the command
  *
  * @param InputInterface $input
  * @param OutputInterface $output
  * @throws \Exception
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $projectRepository = $this->getContainer()->get('packy.repository.project');
     $packageRepository = $this->getContainer()->get('packy.repository.package');
     $analyzer = $this->getContainer()->get('packy.analyzer.generic_analyzer');
     $versionFormatter = $this->getContainer()->get('packy.service.version_formatter');
     $fetchers = $this->getContainer()->get('packy.fetchers');
     $fetchers = $fetchers->getFetchers();
     $projects = $projectRepository->findAll();
     foreach ($projects as $project) {
         foreach ($fetchers as $fetcher) {
             $dependencies = $fetcher->fetchDependencies($project);
             foreach ($dependencies as $name => $version) {
                 $package = $packageRepository->findOne($name, $fetcher->getName());
                 if (is_null($package)) {
                     $package = new Package();
                     $package->setName($name);
                     $package->setManager($fetcher->getName());
                     $packageRepository->create($package);
                 }
                 $package = $analyzer->analyzePackage($package, $package->getManager());
                 $packageRepository->update($package);
                 $dependency = new Dependency();
                 $dependency->setPackage($package);
                 $dependency->setRawVersion($version);
                 $dependency->setCurrentVersion($versionFormatter->normalizeVersion($version));
                 $project->addDependency($dependency);
             }
         }
         $projectRepository->update($project);
         $output->writeln("<info>Project " . $project->getName() . " updated!</info>");
     }
 }
コード例 #2
0
ファイル: NpmAnalyzer.php プロジェクト: peternijssen/packy
 /**
  * @param Package $package
  *
  * @return Package
  */
 public function analyzePackage(Package $package)
 {
     $client = new GuzzleClient();
     $response = $client->get($this->packageVendor . $package->getName(), array('exceptions' => false));
     if ($response->getStatusCode() == 200) {
         $data = $this->parseJson((string) $response->getBody());
         $newestVersion = $data['dist-tags']['latest'];
         $package->setLatestVersion($newestVersion);
         $package->setLastChecktAt(new \DateTime());
     }
     return $package;
 }
コード例 #3
0
ファイル: BowerAnalyzer.php プロジェクト: peternijssen/packy
 /**
  * @param Package $package
  *
  * @return Package
  */
 public function analyzePackage(Package $package)
 {
     $client = new GuzzleClient();
     $response = $client->get($this->packageVendor . $package->getName(), array('exceptions' => false));
     if ($response->getStatusCode() == 200) {
         $data = $this->parseJson((string) $response->getBody());
         // TODO: Handle this differently
         $urlChunks = explode("/", $data['url']);
         $githubClient = new \Github\Client();
         $tags = $githubClient->api('repo')->tags($urlChunks[3], substr($urlChunks[4], 0, -4));
         $newestVersion = $this->getLatestVersion(array_column($tags, 'name'));
         $package->setLatestVersion($newestVersion);
         $package->setLastChecktAt(new \DateTime());
     }
     return $package;
 }
コード例 #4
0
ファイル: StorageService.php プロジェクト: ravenhaus/cloud
 public function freeze(Package $package)
 {
     $manager = $this->doctrine->getManager();
     $archive = $this->temporalDir . '/archive-' . $package->getCode() . '.zip';
     $zip = new ZipArchive();
     $zip->open($archive, ZipArchive::CREATE);
     $tempDir = $this->temporalDir . '/glacier-' . $package->getCode();
     if (!file_exists($tempDir)) {
         mkdir($tempDir);
     }
     // Download Files
     foreach ($package->getFiles() as $file) {
         $src = 's3://' . $this->bucket . '/' . $package->getCode() . '/' . $file->getHash();
         $transfer = new \Aws\S3\Transfer($this->s3Client, $src, $tempDir);
         $transfer->transfer();
         $zip->addFile($tempDir . '/' . $file->getName(), $file->getName());
     }
     // Create Zip and Delete Downloaded File
     $zip->close();
     foreach ($package->getFiles() as $file) {
         unlink($tempDir . '/' . $file->getName());
         rmdir($tempDir);
     }
     // Initiate Glacier
     // Flag and Finish
     $package->setFrozen(Package::FROZEN);
     $manager->flush($package);
 }