use app\Model\Accounts;
use app\Web;
use http\Params;
-use pharext\Task;
-use pharext\Metadata;
-use pharext\SourceDir;
class Receive implements Controller
{
}
$this->setTokenForUser($release->repository->owner->login);
- $this->github->uploadAssetForRelease($release->release, $release->repository, null, function($json) use($response) {
+ $this->github->uploadAssetForRelease(
+ $release->release,
+ $release->repository
+ )->done(function($result) use($response) {
+ list($created) = $result;
$response->setResponseCode(201);
- $response->setHeader("Location", $json->url);
- })->send();
+ $response->setHeader("Location", $created->url);
+ });
+ $this->github->drain();
}
private function create($create) {
}
$this->setTokenForUser($create->repository->owner->login);
- $this->github->createReleaseFromTag($create->repository, $create->ref, null, function($json) use($response) {
+ $this->github->createReleaseFromTag(
+ $create->repository,
+ $create->ref
+ )->done(function($result) use($response) {
+ list($created) = $result;
$response->setResponseCode(201);
- $response->setHeader("Location", $json->url);
- })->send();
+ $response->setHeader("Location", $created->url);
+ });
+ $this->github->drain();
}
-
- private function createReleaseAsset($release, $repo) {
- $hook = $this->github->checkRepoHook($repo);
- $phar = new Pharext\Package($repo->clone_url, $release->tag_name, $repo->name, $hook->config);
- return $phar->getFile();
-
- $dir = (new Task\GitClone($repo->clone_url, $release->tag_name))->run();
- if (!empty($hook->config->pecl)) {
- $src = new SoureDir\Pecl($dir);
- } else {
- $src = new SourceDir\Git($dir);
- }
- $meta = Metadata::all() + [
- "name" => $repo->name,
- "release" => $release->tag_name,
- "license" => $src->getLicense(),
- "stub" => "pharext_installer.php",
- "type" => !empty($hook->config->zend) ? "zend_extension" : "extension",
- ];
- $file = (new Task\PharBuild($src, $meta))->run();
- return $file;
- }
-
}
use app\Controller\Github;
use app\Github\API\Repos\RepoCallback;
-
class Release extends Github
{
function __invoke(array $args = null) {
extract($args);
if ($this->checkToken()) {
- list($repo) = $this->github->readRepo("$owner/$name", function($repo, $links = null) {
- call_user_func(new RepoCallback($this->github), $repo, $links);
-
- $this->github->listReleases($repo->full_name, null, function($releases) use($repo) {
- $config = $this->app->getRequest()->getForm();
- foreach ($releases as $r) {
- if ($r->tag_name === $config->tag) {
- $this->github->uploadAssetForRelease($repo, $r, $config, function() use($repo) {
- $this->app->redirect($this->app->getBaseUrl()->mod("./github/" . $repo->full_name));
- });
- return;
- }
+ $this->github->readRepo("$owner/$name")->then(
+ new RepoCallback($this->github)
+ )->then(function($result) use(&$repo) {
+ list($repo,,,$releases) = $result;
+ $config = $this->app->getRequest()->getForm();
+
+ foreach ($releases as $release) {
+ if ($release->tag_name === $config["tag"]) {
+ return $this->github->uploadAssetForRelease($repo, $release, $config);
}
-
- $this->github->createReleaseFromTag($repo, $tag, $config, function() use($repo) {
- $this->app->redirect($this->app->getBaseUrl()->mod("./github/" . $repo->full_name));
- });
- });
- })->send();
+ }
+
+ return $this->github->createReleaseFromTag($repo, $config["tag"], $config);
+ })->done(function() use(&$repo) {
+ $this->app->redirect($this->app->getBaseUrl()->mod("./github/repo/" . $repo->full_name));
+ });
+ $this->github->drain();
$hook = $this->github->checkRepoHook($repo);
-
$this->app->getView()->addData(compact("owner", "name", "repo", "hook"));
if (($modal = $this->app->getRequest()->getQuery("modal"))) {
return $this->queue(new API\Releases\ListReleaseAssets($this, compact("repo", "id")));
}
- function uploadAssetForRelease($repo, $release, $config) {
+ function uploadAssetForRelease($repo, $release, $config = null) {
return $this->listHooks($repo->full_name)->then(function($result) use($release, $repo, $config) {
list($repo->hooks) = $result;
- $hook = $this->checkRepoHook($repo);
- $phar = new Pharext\Package($repo->clone_url, $release->tag_name, $repo->name, $config ?: $hook->config);
+ $phar = new Pharext\Package(
+ $repo->clone_url,
+ $release->tag_name,
+ $repo->name,
+ $config ?: (array) $this->checkRepoHook($repo)->config
+ );
$name = sprintf("%s-%s.ext.phar", $repo->name, $release->tag_name);
$url = uri_template($release->upload_url, compact("name"));
$promise = $this->createReleaseAsset($url, $phar, "application/phar");
});
}
- function createReleaseFromTag($repo, $tag_name, $config) {
+ function createReleaseFromTag($repo, $tag_name, $config = null) {
return $this->createRelease($repo->full_name, $tag_name)->then(function($result) use($repo, $config) {
list($release) = $result;
return $this->uploadAssetForRelease($repo, $release, $config);
function __construct($git_url, $tag_name, $pkg_name, $options) {
$dir = (new Task\GitClone($git_url, $tag_name))->run();
- $src = !empty($options->pecl)
+ $src = !empty($options["pecl"])
? new SourceDir\Pecl($dir)
: new SourceDir\Git($dir);
$meta = Metadata::all() + [
"release" => $tag_name,
"license" => $src->getLicense(),
"stub" => "pharext_installer.php",
- "type" => !empty($options->zend) ? "zend_extension" : "extension",
+ "type" => !empty($options["zend"]) ? "zend_extension" : "extension",
];
$this->file = (new Task\PharBuild($src, $meta))->run();
}