/** * @param ReleaseCollection $releases */ public function render(ReleaseCollection $releases) { $this->initRepository(); foreach ($releases->allReleases() as $release) { $this->addRelease($release); } $this->saveRepository(); }
/** * @param ReleaseCollection $releases */ public function render(ReleaseCollection $releases) { foreach ($releases->latestReleases() as $release) { file_put_contents($this->target() . $release->package(), $release->version()); } foreach ($releases->latestReleasesPerPackageAndVersionSeries() as $release) { file_put_contents($this->target() . $release->package() . '-' . $release->versionSeries(), $release->version()); } }
/** * @param PharAlias $alias * * @return ReleaseCollection */ public function getReleases(PharAlias $alias) { $releases = new ReleaseCollection(); $query = sprintf('//phive:phar[@name="%s"]/phive:release', $alias); foreach ($this->getXPath()->query($query) as $releaseNode) { /** @var \DOMElement $releaseNode */ $releases->add(new Release(new Version($releaseNode->getAttribute('version')), new Url($releaseNode->getAttribute('url')), $this->getHash($releaseNode))); } return $releases; }
/** * @param ReleaseCollection $releases */ public function render(ReleaseCollection $releases) { $latestReleases = ''; foreach ($releases->latestReleasesSortedByPackageName() as $release) { $latestReleases .= $this->renderRelease($release, true); } $allReleases = ''; foreach ($releases->allReleases() as $release) { $allReleases .= $this->renderRelease($release); } $page = new \Text_Template(__DIR__ . '/../templates/page.html'); $page->setVar(['domain' => $this->domain(), 'latest_releases' => $latestReleases, 'all_releases' => $allReleases]); $page->renderTo($this->target()); }
/** * @param ReleaseCollection $releases */ public function render(ReleaseCollection $releases) { $feedTemplate = new \Text_Template(__DIR__ . '/../templates/feed.xml'); $feedItemTemplate = new \Text_Template(__DIR__ . '/../templates/item.xml'); $rdfList = ''; $rdfItems = ''; foreach ($releases->latestReleasesSortedByDate() as $release) { $rdfList .= sprintf(' <rdf:li rdf:resource="%s/%s-%s.phar"/>' . "\n", $this->domain(), $release->package(), $release->version()); $feedItemTemplate->setVar(['domain' => $this->domain(), 'package' => $release->package(), 'version' => $release->version(), 'date' => $release->date(), 'content' => '']); $rdfItems .= $feedItemTemplate->render(); } $feedTemplate->setVar(['items_list' => $rdfList, 'items' => $rdfItems, 'domain' => $this->domain(), 'email' => $this->email()]); $feedTemplate->renderTo($this->target()); }
/** * @param ReleaseCollection $releases * @param array $additionalReleaseSeries * @param string $target */ public function render(ReleaseCollection $releases, array $additionalReleaseSeries, $target) { $buffer = ''; foreach ($releases->latestReleases() as $release) { $buffer .= sprintf("rewrite ^/%s.phar\$ /%s-%s.phar redirect;\n", $release->package(), $release->package(), $release->version()); $buffer .= sprintf("rewrite ^/%s.phar.asc\$ /%s-%s.phar.asc redirect;\n", $release->package(), $release->package(), $release->version()); } foreach ($releases->latestReleasesPerPackageAndVersionSeries() as $release) { $buffer .= sprintf("rewrite ^/%s-%s.phar\$ /%s-%s.phar redirect;\n", $release->package(), $release->versionSeries(), $release->package(), $release->version()); $buffer .= sprintf("rewrite ^/%s-%s.phar.asc\$ /%s-%s.phar.asc redirect;\n", $release->package(), $release->versionSeries(), $release->package(), $release->version()); } foreach ($additionalReleaseSeries as $item) { $buffer .= sprintf("rewrite ^/%s-%s.phar\$ /%s-%s.phar redirect;\n", $item['package'], $item['alias'], $item['package'], $releases->latestReleaseOfVersionSeries($item['package'], $item['series'])->version()); $buffer .= sprintf("rewrite ^/%s-%s.phar.asc\$ /%s-%s.phar.asc redirect;\n", $item['package'], $item['alias'], $item['package'], $releases->latestReleaseOfVersionSeries($item['package'], $item['series'])->version()); } file_put_contents($target, $buffer); }
/** * @param string $directory * * @return ReleaseCollection */ public function collect($directory) { $releases = new ReleaseCollection(); foreach (new \GlobIterator($directory . '/*.phar') as $file) { if (!$file->isLink() && stripos($file->getBasename(), 'alpha') === false && stripos($file->getBasename(), 'beta') === false) { $parts = explode('-', $file->getBasename('.phar')); $version = array_pop($parts); $versionSeries = implode('.', array_slice(explode('.', $version), 0, 2)); $name = implode('-', $parts); $manifest = []; if (file_exists('phar://' . $file->getPathname() . '/manifest.txt')) { $manifest = file('phar://' . $file->getPathname() . '/manifest.txt'); } elseif (file_exists('phar://' . $file->getPathname() . '/phar/manifest.txt')) { $manifest = file('phar://' . $file->getPathname() . '/phar/manifest.txt'); } elseif (is_executable($file->getPathname()) && strpos(file_get_contents($file->getPathname()), '--manifest')) { @exec($file->getPathname() . ' --manifest 2> /dev/null', $manifest); } $releases->add(new Release($name, $version, $versionSeries, $manifest, date(DATE_W3C, $file->getMTime()), $this->humanFilesize($file->getSize()), hash_file('sha256', $file->getPathname()))); } } return $releases; }