Release of v5.1.1-beta3
Fixes issue with loading the Component Builder Wiki. Adds advanced version update notice to the Component Builder Dashboard. Completely refactors the class that builds the Component Dashboard. #1134.
This commit is contained in:
@@ -19,7 +19,7 @@ use VDM\Joomla\Interfaces\Git\ApiInterface;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Api
|
||||
* The Github Api
|
||||
*
|
||||
* @since 5.1.1
|
||||
*/
|
||||
@@ -98,10 +98,11 @@ abstract class Api implements ApiInterface
|
||||
// for the rest of the container
|
||||
if ($backup)
|
||||
{
|
||||
if ($url !== null)
|
||||
{
|
||||
$this->url = $this->uri->getUrl();
|
||||
}
|
||||
// Github has only one URL
|
||||
// if ($url !== null)
|
||||
// {
|
||||
// $this->url = $this->uri->getUrl();
|
||||
// }
|
||||
|
||||
if ($token !== null)
|
||||
{
|
||||
@@ -109,10 +110,11 @@ abstract class Api implements ApiInterface
|
||||
}
|
||||
}
|
||||
|
||||
if ($url !== null)
|
||||
{
|
||||
$this->uri->setUrl($url);
|
||||
}
|
||||
// Github has only one URL
|
||||
// if ($url !== null)
|
||||
// {
|
||||
// $this->uri->setUrl($url);
|
||||
// }
|
||||
|
||||
if ($token !== null)
|
||||
{
|
||||
@@ -128,11 +130,12 @@ abstract class Api implements ApiInterface
|
||||
**/
|
||||
public function reset_(): void
|
||||
{
|
||||
if ($this->url !== null)
|
||||
{
|
||||
$this->uri->setUrl($this->url);
|
||||
$this->url = null;
|
||||
}
|
||||
// Github has only one URL
|
||||
// if ($this->url !== null)
|
||||
// {
|
||||
// $this->uri->setUrl($this->url);
|
||||
// $this->url = null;
|
||||
// }
|
||||
|
||||
if ($this->token !== null)
|
||||
{
|
||||
|
51
libraries/vendor_jcb/VDM.Joomla.Github/src/Factory.php
Normal file
51
libraries/vendor_jcb/VDM.Joomla.Github/src/Factory.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Github;
|
||||
|
||||
|
||||
use Joomla\DI\Container;
|
||||
use VDM\Joomla\Github\Service\Utilities;
|
||||
use VDM\Joomla\Componentbuilder\Power\Service\Github;
|
||||
use VDM\Joomla\Interfaces\FactoryInterface;
|
||||
use VDM\Joomla\Abstraction\Factory as ExtendingFactory;
|
||||
|
||||
|
||||
/**
|
||||
* Github Factory
|
||||
*
|
||||
* @since 5.1.1
|
||||
*/
|
||||
abstract class Factory extends ExtendingFactory implements FactoryInterface
|
||||
{
|
||||
/**
|
||||
* Package Container
|
||||
*
|
||||
* @var Container|null
|
||||
* @since 5.0.3
|
||||
**/
|
||||
protected static ?Container $container = null;
|
||||
|
||||
/**
|
||||
* Create a container object
|
||||
*
|
||||
* @return Container
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected static function createContainer(): Container
|
||||
{
|
||||
return (new Container())
|
||||
->registerServiceProvider(new Utilities())
|
||||
->registerServiceProvider(new Github());
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -21,7 +21,7 @@ use VDM\Joomla\Github\Abstraction\Api;
|
||||
*
|
||||
* @since 5.1.1
|
||||
*/
|
||||
class Contents extends Api implements ContentsInterface
|
||||
final class Contents extends Api implements ContentsInterface
|
||||
{
|
||||
/**
|
||||
* Get a file from a repository.
|
||||
|
186
libraries/vendor_jcb/VDM.Joomla.Github/src/Repository/Tags.php
Normal file
186
libraries/vendor_jcb/VDM.Joomla.Github/src/Repository/Tags.php
Normal file
@@ -0,0 +1,186 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Github\Repository;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\Git\Repository\TagsInterface;
|
||||
use VDM\Joomla\Github\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Github Repository Tags
|
||||
*
|
||||
* @since 5.1.1
|
||||
*/
|
||||
final class Tags extends Api implements TagsInterface
|
||||
{
|
||||
/**
|
||||
* List a repository's tags
|
||||
*
|
||||
* @param string $owner The owner of the repo.
|
||||
* @param string $repo The name of the repo.
|
||||
* @param int|null $page The page number of results to return (1-based).
|
||||
* @param int|null $limit The page size of results. GitHub default is 30, max 100. Here we fix it to 10.
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function list(
|
||||
string $owner,
|
||||
string $repo,
|
||||
?int $page = 1,
|
||||
?int $limit = 10
|
||||
): ?array {
|
||||
$path = "/repos/{$owner}/{$repo}/tags";
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
$uri->setVar('page', $page ?? 1);
|
||||
$uri->setVar('per_page', $limit ?? 10);
|
||||
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the tag object by tag name (loop until found or exhausted).
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $tag The tag name to find.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function get(string $owner, string $repo, string $tag): ?object
|
||||
{
|
||||
$page = 1;
|
||||
$limit = 10;
|
||||
|
||||
do {
|
||||
$tags = $this->list($owner, $repo, $page, $limit);
|
||||
|
||||
if (empty($tags))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
foreach ($tags as $entry)
|
||||
{
|
||||
if (isset($entry->name) && $entry->name === $tag)
|
||||
{
|
||||
return $entry;
|
||||
}
|
||||
}
|
||||
|
||||
$page++;
|
||||
} while (count($tags) === $limit);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the annotated tag object by SHA.
|
||||
*
|
||||
* @param string $owner The owner of the repo.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $sha The tag object SHA.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function sha(string $owner, string $repo, string $sha): ?object
|
||||
{
|
||||
$path = "/repos/{$owner}/{$repo}/git/tags/{$sha}";
|
||||
return $this->response->get(
|
||||
$this->http->get($this->uri->get($path))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new annotated tag and attach it to the repository.
|
||||
*
|
||||
* GitHub requires two steps to create a tag:
|
||||
* 1. Create an annotated tag object.
|
||||
* 2. Create a reference to the tag under `refs/tags/*`.
|
||||
*
|
||||
* @param string $owner The owner of the repo.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $tagName The name of the tag.
|
||||
* @param string $target The SHA the tag points to (usually a commit SHA).
|
||||
* @param string $message The tag message.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function create(string $owner, string $repo, string $tagName, string $target, string $message): ?object
|
||||
{
|
||||
// Step 1: Create the tag object
|
||||
$tagObject = (object) [
|
||||
'tag' => $tagName,
|
||||
'message' => $message,
|
||||
'object' => $target,
|
||||
'type' => 'commit'
|
||||
];
|
||||
|
||||
$tagResponse = $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get("/repos/{$owner}/{$repo}/git/tags"),
|
||||
json_encode($tagObject)
|
||||
)
|
||||
);
|
||||
|
||||
if (!isset($tagResponse->sha))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// Step 2: Create the ref pointing to the tag object
|
||||
$refData = (object) [
|
||||
'ref' => "refs/tags/{$tagName}",
|
||||
'sha' => $tagResponse->sha
|
||||
];
|
||||
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get("/repos/{$owner}/{$repo}/git/refs"),
|
||||
json_encode($refData)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a tag reference by tag name.
|
||||
*
|
||||
* GitHub deletes tags via refs.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $tag The tag name to delete.
|
||||
*
|
||||
* @return string Returns 'success' on successful deletion.
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function delete(string $owner, string $repo, string $tag): string
|
||||
{
|
||||
$path = "/repos/{$owner}/{$repo}/git/refs/tags/{$tag}";
|
||||
|
||||
return $this->response->get(
|
||||
$this->http->delete(
|
||||
$this->uri->get($path)
|
||||
),
|
||||
204,
|
||||
'success'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
166
libraries/vendor_jcb/VDM.Joomla.Github/src/Repository/Wiki.php
Normal file
166
libraries/vendor_jcb/VDM.Joomla.Github/src/Repository/Wiki.php
Normal file
@@ -0,0 +1,166 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Github\Repository;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\Git\Repository\WikiInterface;
|
||||
use VDM\Joomla\Github\Abstraction\Api;
|
||||
use Joomla\CMS\Uri\Uri;
|
||||
|
||||
|
||||
/**
|
||||
* The Github Repository Wiki
|
||||
*
|
||||
* @since 5.1.1
|
||||
*/
|
||||
class Wiki extends Api implements WikiInterface
|
||||
{
|
||||
/**
|
||||
* Create a new wiki page or update it if it already exists.
|
||||
*
|
||||
* @param string $owner Repository owner (user or organization).
|
||||
* @param string $repo Repository name (without `.wiki`).
|
||||
* @param string $title Title of the wiki page.
|
||||
* @param string $contentBase64 Base64-encoded Markdown content.
|
||||
* @param string|null $message Optional commit message.
|
||||
*
|
||||
* @return object|null API response object or null on failure.
|
||||
* @since 5.1.1
|
||||
*/
|
||||
public function create(
|
||||
string $owner,
|
||||
string $repo,
|
||||
string $title,
|
||||
string $contentBase64,
|
||||
?string $message = null
|
||||
): ?object
|
||||
{
|
||||
return null; // github does not support wiki over API
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the content of a specific wiki page.
|
||||
*
|
||||
* @param string $owner Repository owner (user or organization).
|
||||
* @param string $repo Repository name (without `.wiki`).
|
||||
* @param string $pageName Name of the page (excluding `.md`).
|
||||
*
|
||||
* @return object|null Page details including content and metadata, or null on failure.
|
||||
* @since 5.1.1
|
||||
*/
|
||||
public function get(
|
||||
string $owner,
|
||||
string $repo,
|
||||
string $pageName
|
||||
): ?object
|
||||
{
|
||||
// Build the raw wiki URL
|
||||
$url = "https://raw.githubusercontent.com/wiki/{$owner}/{$repo}/{$pageName}.md";
|
||||
|
||||
// Use a direct HTTP GET request (bypasses GitHub API)
|
||||
$body = $this->response->get(
|
||||
$this->http->get(new Uri($url), [])
|
||||
);
|
||||
|
||||
return (object) [
|
||||
'name' => "{$pageName}.md",
|
||||
'content' => base64_encode($body),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* List all wiki pages in the repository.
|
||||
*
|
||||
* @param string $owner Repository owner (user or organization).
|
||||
* @param string $repo Repository name (without `.wiki`).
|
||||
* @param int $page Pagination index (1-based).
|
||||
* @param int $limit Number of results per page.
|
||||
*
|
||||
* @return array|null List of page metadata or null on failure.
|
||||
* @since 5.1.1
|
||||
*/
|
||||
public function pages(
|
||||
string $owner,
|
||||
string $repo,
|
||||
int $page = 1,
|
||||
int $limit = 10
|
||||
): ?array
|
||||
{
|
||||
return null; // github does not support wiki over API
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a wiki page from the repository.
|
||||
*
|
||||
* @param string $owner Repository owner (user or organization).
|
||||
* @param string $repo Repository name (without `.wiki`).
|
||||
* @param string $pageName Name of the page to delete (excluding `.md`).
|
||||
*
|
||||
* @return string 'success' on deletion, or error message if the page was not found.
|
||||
* @since 5.1.1
|
||||
*/
|
||||
public function delete(
|
||||
string $owner,
|
||||
string $repo,
|
||||
string $pageName
|
||||
): string
|
||||
{
|
||||
return 'error'; // github does not support wiki over API
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit an existing wiki page.
|
||||
*
|
||||
* @param string $owner Repository owner (user or organization).
|
||||
* @param string $repo Repository name (without `.wiki`).
|
||||
* @param string $pageName Name of the page to edit (excluding `.md`).
|
||||
* @param string $title New title of the page (used to rename if applicable).
|
||||
* @param string $content Updated Markdown content.
|
||||
* @param string|null $message Optional commit message.
|
||||
*
|
||||
* @return object|null API response object or null if the page doesn't exist.
|
||||
* @since 5.1.1
|
||||
*/
|
||||
public function edit(
|
||||
string $owner,
|
||||
string $repo,
|
||||
string $pageName,
|
||||
string $title,
|
||||
string $content,
|
||||
string $message = null
|
||||
): ?object
|
||||
{
|
||||
return null; // github does not support wiki over API
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the commit history (revisions) for a specific wiki page.
|
||||
*
|
||||
* @param string $owner Repository owner (user or organization).
|
||||
* @param string $repo Repository name (without `.wiki`).
|
||||
* @param string $pageName Name of the page to retrieve revisions for (excluding `.md`).
|
||||
* @param int $page Pagination index (1-based).
|
||||
*
|
||||
* @return object|null API response object with commit history or null on failure.
|
||||
* @since 5.1.1
|
||||
*/
|
||||
public function revisions(
|
||||
string $owner,
|
||||
string $repo,
|
||||
string $pageName,
|
||||
int $page = 1
|
||||
): ?object
|
||||
{
|
||||
return null; // github does not support wiki over API
|
||||
}
|
||||
}
|
||||
|
@@ -14,6 +14,7 @@ namespace VDM\Joomla\Github\Service;
|
||||
|
||||
use Joomla\DI\Container;
|
||||
use Joomla\DI\ServiceProviderInterface;
|
||||
use VDM\Joomla\Utilities\Component\Helper;
|
||||
use VDM\Joomla\Github\Utilities\Http;
|
||||
use VDM\Joomla\Github\Utilities\Uri;
|
||||
use VDM\Joomla\Github\Utilities\Response;
|
||||
@@ -56,7 +57,9 @@ class Utilities implements ServiceProviderInterface
|
||||
*/
|
||||
public function getHttp(Container $container): Http
|
||||
{
|
||||
return new Http();
|
||||
return new Http(
|
||||
Helper::getParams('com_componentbuilder')->get('github_access_token') ?? null
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user