Adds better remote repository management for the super power features. Fixes #1014 so that powers are added to components.
This commit is contained in:
@ -85,6 +85,16 @@ abstract class Api
|
||||
$this->http->setToken($token);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the API url
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function api()
|
||||
{
|
||||
return $this->uri->api();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -58,7 +58,7 @@ class Jcb implements ServiceProviderInterface
|
||||
$gitea_url = Helper::getParams('com_componentbuilder')->get('custom_gitea_url');
|
||||
|
||||
// only load this if we have a custom URL set
|
||||
if ($add_gitea_url == 2 && is_string($gitea_url) && strpos($gitea_url, 'http') !== false)
|
||||
if ($add_gitea_url == 2 && !empty($gitea_url) && strpos($gitea_url, 'http') !== false)
|
||||
{
|
||||
return new Uri($gitea_url);
|
||||
}
|
||||
|
@ -72,7 +72,6 @@ final class Http extends JoomlaHttp
|
||||
$headers['Authorization'] = 'token ' . $token;
|
||||
|
||||
$this->setOption('headers', $headers);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -134,7 +134,6 @@ final class Uri
|
||||
private function setVersion($version)
|
||||
{
|
||||
$this->version = $version;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -111,6 +111,73 @@ class Config extends BaseConfig
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get super power core organisation
|
||||
*
|
||||
* @return string The super power core organisation
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function getSuperpowerscoreorganisation(): string
|
||||
{
|
||||
// the VDM default organisation is [joomla]
|
||||
$organisation = 'joomla';
|
||||
|
||||
if ($this->add_custom_gitea_url == 2)
|
||||
{
|
||||
return $this->params->get('super_powers_core_organisation', $organisation);
|
||||
}
|
||||
|
||||
return $organisation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get super power core repos
|
||||
*
|
||||
* @return array The core repositories on Gitea
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function getSuperpowerscorerepos(): array
|
||||
{
|
||||
// some defaults repos we need by JCB
|
||||
$repos = [];
|
||||
|
||||
// only add custom init with custom gitea
|
||||
$paths = null;
|
||||
if ($this->add_custom_gitea_url == 2)
|
||||
{
|
||||
$paths = $this->params->get('super_powers_core_repos');
|
||||
}
|
||||
|
||||
if (!empty($paths) && is_array($paths))
|
||||
{
|
||||
foreach ($paths as $path)
|
||||
{
|
||||
$owner = $path->owner ?? null;
|
||||
$repo = $path->repo ?? null;
|
||||
if ($owner !== null && $repo !== null)
|
||||
{
|
||||
// we make sure to get only the objects
|
||||
$repos = ["{$owner}.{$repo}" => $path] + $repos;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$repos[$this->super_powers_core_organisation . '.super-powers'] = (object) ['owner' => $this->super_powers_core_organisation, 'repo' => 'super-powers', 'branch' => 'master'];
|
||||
$repos[$this->super_powers_core_organisation . '.jcb-compiler'] = (object) ['owner' => $this->super_powers_core_organisation, 'repo' => 'jcb-compiler', 'branch' => 'master'];
|
||||
$repos[$this->super_powers_core_organisation . '.jcb-packager'] = (object) ['owner' => $this->super_powers_core_organisation, 'repo' => 'jcb-packager', 'branch' => 'master'];
|
||||
$repos[$this->super_powers_core_organisation . '.phpseclib'] = (object) ['owner' => $this->super_powers_core_organisation, 'repo' => 'phpseclib', 'branch' => 'master'];
|
||||
$repos[$this->super_powers_core_organisation . '.search'] = (object) ['owner' => $this->super_powers_core_organisation, 'repo' => 'search', 'branch' => 'master'];
|
||||
$repos[$this->super_powers_core_organisation . '.gitea'] = (object) ['owner' => $this->super_powers_core_organisation, 'repo' => 'gitea', 'branch' => 'master'];
|
||||
$repos[$this->super_powers_core_organisation . '.openai'] = (object) ['owner' => $this->super_powers_core_organisation, 'repo' => 'openai', 'branch' => 'master'];
|
||||
$repos[$this->super_powers_core_organisation . '.minify'] = (object) ['owner' => $this->super_powers_core_organisation, 'repo' => 'minify', 'branch' => 'master'];
|
||||
$repos[$this->super_powers_core_organisation . '.psr'] = (object) ['owner' => $this->super_powers_core_organisation, 'repo' => 'psr', 'branch' => 'master'];
|
||||
$repos[$this->super_powers_core_organisation . '.fof'] = (object) ['owner' => $this->super_powers_core_organisation, 'repo' => 'fof', 'branch' => 'master'];
|
||||
}
|
||||
|
||||
return $repos;
|
||||
}
|
||||
|
||||
/**
|
||||
* get add contributors switch
|
||||
*
|
||||
@ -630,20 +697,11 @@ class Config extends BaseConfig
|
||||
protected function getApprovedpaths(): array
|
||||
{
|
||||
// some defaults repos we need by JCB
|
||||
$approved = [];
|
||||
$approved['joomla.super-powers'] = (object) ['owner' => 'joomla', 'repo' => 'super-powers', 'branch' => 'master'];
|
||||
$approved['joomla.jcb-compiler'] = (object) ['owner' => 'joomla', 'repo' => 'jcb-compiler', 'branch' => 'master'];
|
||||
$approved['joomla.phpseclib'] = (object) ['owner' => 'joomla', 'repo' => 'phpseclib', 'branch' => 'master'];
|
||||
$approved['joomla.search'] = (object) ['owner' => 'joomla', 'repo' => 'search', 'branch' => 'master'];
|
||||
$approved['joomla.gitea'] = (object) ['owner' => 'joomla', 'repo' => 'gitea', 'branch' => 'master'];
|
||||
$approved['joomla.openai'] = (object) ['owner' => 'joomla', 'repo' => 'openai', 'branch' => 'master'];
|
||||
$approved['joomla.minify'] = (object) ['owner' => 'joomla', 'repo' => 'minify', 'branch' => 'master'];
|
||||
$approved['joomla.psr'] = (object) ['owner' => 'joomla', 'repo' => 'psr', 'branch' => 'master'];
|
||||
$approved['joomla.fof'] = (object) ['owner' => 'joomla', 'repo' => 'fof', 'branch' => 'master'];
|
||||
$approved = $this->super_powers_core_repos;
|
||||
|
||||
if (!$this->add_own_powers)
|
||||
{
|
||||
return $approved;
|
||||
return array_values($approved);
|
||||
}
|
||||
|
||||
$paths = $this->params->get('approved_paths');
|
||||
@ -762,6 +820,7 @@ class Config extends BaseConfig
|
||||
{
|
||||
// get posted value
|
||||
$value = $this->input->post->get('add_placeholders', 2, 'INT');
|
||||
|
||||
// get global value
|
||||
if ($value > 1)
|
||||
{
|
||||
@ -780,6 +839,7 @@ class Config extends BaseConfig
|
||||
{
|
||||
// get posted value
|
||||
$value = $this->input->post->get('powers', 2, 'INT');
|
||||
|
||||
// get global value
|
||||
if ($value > 1)
|
||||
{
|
||||
@ -945,7 +1005,6 @@ class Config extends BaseConfig
|
||||
protected function getFootableversion(): int
|
||||
{
|
||||
return 2; // default is version 2
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -111,6 +111,66 @@ class Config extends BaseConfig
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get super power core organisation
|
||||
*
|
||||
* @return string The super power core organisation
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function getSuperpowerscoreorganisation(): string
|
||||
{
|
||||
// the VDM default organisation is [joomla]
|
||||
$organisation = 'joomla';
|
||||
|
||||
if ($this->add_custom_gitea_url == 2)
|
||||
{
|
||||
return $this->params->get('super_powers_core_organisation', $organisation);
|
||||
}
|
||||
|
||||
return $organisation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get super power init repos
|
||||
*
|
||||
* @return array The init repositories on Gitea
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function getSuperpowersinitrepos(): array
|
||||
{
|
||||
// some defaults repos we need by JCB
|
||||
$repos = [];
|
||||
|
||||
// only add custom init with custom gitea
|
||||
$paths = null;
|
||||
if ($this->add_custom_gitea_url == 2)
|
||||
{
|
||||
$paths = $this->params->get('super_powers_init_repos');
|
||||
}
|
||||
|
||||
if (!empty($paths) && is_array($paths))
|
||||
{
|
||||
foreach ($paths as $path)
|
||||
{
|
||||
$owner = $path->owner ?? null;
|
||||
$repo = $path->repo ?? null;
|
||||
if ($owner !== null && $repo !== null)
|
||||
{
|
||||
// we make sure to get only the objects
|
||||
$repos = ["{$owner}.{$repo}" => $path] + $repos;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$repos[$this->super_powers_core_organisation . '.super-powers'] = (object) ['owner' => $this->super_powers_core_organisation, 'repo' => 'super-powers', 'branch' => 'master'];
|
||||
$repos[$this->super_powers_core_organisation . '.gitea'] = (object) ['owner' => $this->super_powers_core_organisation, 'repo' => 'gitea', 'branch' => 'master'];
|
||||
$repos[$this->super_powers_core_organisation . '.openai'] = (object) ['owner' => $this->super_powers_core_organisation, 'repo' => 'openai', 'branch' => 'master'];
|
||||
}
|
||||
|
||||
return $repos;
|
||||
}
|
||||
|
||||
/**
|
||||
* get temporary path
|
||||
*
|
||||
@ -177,10 +237,7 @@ class Config extends BaseConfig
|
||||
protected function getApprovedpaths(): array
|
||||
{
|
||||
// some defaults repos we need by JCB
|
||||
$approved = [];
|
||||
$approved['joomla.super-powers'] = (object) ['owner' => 'joomla', 'repo' => 'super-powers', 'branch' => 'master'];
|
||||
$approved['joomla.gitea'] = (object) ['owner' => 'joomla', 'repo' => 'gitea', 'branch' => 'master'];
|
||||
$approved['joomla.openai'] = (object) ['owner' => 'joomla', 'repo' => 'openai', 'branch' => 'master'];
|
||||
$approved = $this->super_powers_init_repos;
|
||||
|
||||
if (!$this->add_own_powers)
|
||||
{
|
||||
|
@ -347,7 +347,7 @@ final class Grep
|
||||
catch (\Exception $e)
|
||||
{
|
||||
$this->app->enqueueMessage(
|
||||
Text::sprintf('COM_COMPONENTBUILDER_PSUPER_POWERB_REPOSITORY_AT_BGITVDMDEVSB_GAVE_THE_FOLLOWING_ERRORBR_SP', $path->path, $e->getMessage()),
|
||||
Text::sprintf('COM_COMPONENTBUILDER_PSUPER_POWERB_REPOSITORY_AT_BSSB_GAVE_THE_FOLLOWING_ERRORBR_SP', $this->contents->api(), $path->path, $e->getMessage()),
|
||||
'Error'
|
||||
);
|
||||
|
||||
@ -375,7 +375,7 @@ final class Grep
|
||||
catch (\Exception $e)
|
||||
{
|
||||
$this->app->enqueueMessage(
|
||||
Text::sprintf('COM_COMPONENTBUILDER_PFILE_AT_BGITEAREMOTESB_GAVE_THE_FOLLOWING_ERRORBR_SP', $path, $e->getMessage()),
|
||||
Text::sprintf('COM_COMPONENTBUILDER_PFILE_AT_BSSB_GAVE_THE_FOLLOWING_ERRORBR_SP', $this->contents->api(), $path, $e->getMessage()),
|
||||
'Error'
|
||||
);
|
||||
|
||||
|
@ -57,7 +57,7 @@ class Gitea implements ServiceProviderInterface
|
||||
$gitea_url = $container->get('Config')->get('custom_gitea_url');
|
||||
|
||||
// only load this if we have a custom URL set
|
||||
if ($add_gitea_url == 2 && is_string($gitea_url) && strpos($gitea_url, 'http') !== false)
|
||||
if ($add_gitea_url == 2 && !empty($gitea_url) && strpos($gitea_url, 'http') !== false)
|
||||
{
|
||||
return new Uri($gitea_url);
|
||||
}
|
||||
|
@ -12,7 +12,6 @@
|
||||
namespace VDM\Joomla\Utilities\String;
|
||||
|
||||
|
||||
use Joomla\CMS\Component\ComponentHelper;
|
||||
use VDM\Joomla\Utilities\StringHelper;
|
||||
use VDM\Joomla\Utilities\Component\Helper;
|
||||
|
||||
@ -97,7 +96,6 @@ abstract class FieldHelper
|
||||
|
||||
// use the default (original behavior/convention)
|
||||
return StringHelper::safe($string);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1 +0,0 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
Reference in New Issue
Block a user