Release of v5.0.1-alpha5

Add repositories for better integration with gitea. Refactored the Data classes. Add new Data classes.
This commit is contained in:
2024-06-21 03:25:28 +02:00
parent fc6b04cb5c
commit c51ef999a9
120 changed files with 8945 additions and 3699 deletions

View File

@@ -65,7 +65,7 @@ class Config extends BaseConfig
*/
protected function getGiteausername(): ?string
{
return $this->custom_gitea_username ?? $this->params->get('gitea_username');
return $this->params->get('gitea_username');
}
/**
@@ -76,66 +76,7 @@ class Config extends BaseConfig
*/
protected function getGiteatoken(): ?string
{
return $this->custom_gitea_token ?? $this->params->get('gitea_token');
}
/**
* get Add Custom Gitea URL
*
* @return int the add switch
* @since 3.2.0
*/
protected function getAddcustomgiteaurl(): int
{
return $this->params->get('add_custom_gitea_url', 1);
}
/**
* get Custom Gitea URL
*
* @return string the custom gitea url
* @since 3.2.0
*/
protected function getCustomgiteaurl(): ?string
{
if ($this->add_custom_gitea_url == 2)
{
return $this->params->get('custom_gitea_url');
}
return null;
}
/**
* get Custom Gitea Username
*
* @return string the custom access token
* @since 3.2.0
*/
protected function getCustomgiteausername(): ?string
{
if ($this->add_custom_gitea_url == 2)
{
return $this->params->get('custom_gitea_username');
}
return null;
}
/**
* get Custom Gitea Access Token
*
* @return string the custom access token
* @since 3.2.0
*/
protected function getCustomgiteatoken(): ?string
{
if ($this->add_custom_gitea_url == 2)
{
return $this->params->get('custom_gitea_token');
}
return null;
return $this->params->get('gitea_token');
}
/**
@@ -165,9 +106,9 @@ class Config extends BaseConfig
// get the users own power repo (can overwrite all)
if (!empty($this->gitea_username))
{
$repos[$this->gitea_username . '.joomla-powers'] = (object) ['owner' => $this->gitea_username, 'repo' => 'joomla-powers', 'branch' => 'master'];
$repos[$this->gitea_username . '.joomla-powers'] = (object) ['organisation' => $this->gitea_username, 'repository' => 'joomla-powers', 'read_branch' => 'master'];
}
$repos[$this->joomla_powers_core_organisation . '.joomla-powers'] = (object) ['owner' => $this->joomla_powers_core_organisation, 'repo' => 'joomla-powers', 'branch' => 'master'];
$repos[$this->joomla_powers_core_organisation . '.joomla-powers'] = (object) ['organisation' => $this->joomla_powers_core_organisation, 'repository' => 'joomla-powers', 'read_branch' => 'master'];
return $repos;
}
@@ -183,7 +124,7 @@ class Config extends BaseConfig
// some defaults repos we need by JCB
if (!empty($this->gitea_username))
{
return (object) ['owner' => $this->gitea_username, 'repo' => 'joomla-powers', 'branch' => 'master'];
return (object) ['organisation' => $this->gitea_username, 'repository' => 'joomla-powers', 'read_branch' => 'master'];
}
}

View File

@@ -1,34 +0,0 @@
<?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\Componentbuilder\JoomlaPower\Database;
use VDM\Joomla\Componentbuilder\Interfaces\Database\InsertInterface;
use VDM\Joomla\Componentbuilder\Power\Database\Insert as ExtendingInsert;
/**
* Joomla Power Database Insert
*
* @since 3.2.1
*/
final class Insert extends ExtendingInsert implements InsertInterface
{
/**
* Table Name
*
* @var string
* @since 3.2.1
*/
protected string $table = 'power';
}

View File

@@ -1,34 +0,0 @@
<?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\Componentbuilder\JoomlaPower\Database;
use VDM\Joomla\Componentbuilder\Power\Database\LoadInterface;
use VDM\Joomla\Componentbuilder\Power\Database\Load as ExtendingLoad;
/**
* Power Database Load
*
* @since 2.0.1
*/
final class Load extends ExtendingLoad implements LoadInterface
{
/**
* Table Name
*
* @var string
* @since 3.2.1
*/
protected string $table = 'joomla_power';
}

View File

@@ -1,34 +0,0 @@
<?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\Componentbuilder\JoomlaPower\Database;
use VDM\Joomla\Componentbuilder\Interfaces\Database\UpdateInterface;
use VDM\Joomla\Componentbuilder\Power\Database\Update as ExtendingUpdate;
/**
* Joomla Power Database Update
*
* @since 3.2.0
*/
final class Update extends ExtendingUpdate implements UpdateInterface
{
/**
* Table Name
*
* @var string
* @since 3.2.1
*/
protected string $table = 'joomla_power';
}

View File

@@ -1 +0,0 @@
<html><body bgcolor="#FFFFFF"></body></html>

View File

@@ -14,8 +14,9 @@ namespace VDM\Joomla\Componentbuilder\JoomlaPower;
use Joomla\DI\Container;
use VDM\Joomla\Componentbuilder\JoomlaPower\Service\JoomlaPower as Power;
use VDM\Joomla\Componentbuilder\Service\Database;
use VDM\Joomla\Componentbuilder\JoomlaPower\Service\Database as PowerDatabase;
use VDM\Joomla\Service\Database;
use VDM\Joomla\Service\Model;
use VDM\Joomla\Service\Data;
use VDM\Joomla\Componentbuilder\Service\Gitea;
use VDM\Joomla\Componentbuilder\Power\Service\Gitea as GiteaPower;
use VDM\Joomla\Gitea\Service\Utilities as GiteaUtilities;
@@ -77,7 +78,8 @@ abstract class Factory implements FactoryInterface
return (new Container())
->registerServiceProvider(new Power())
->registerServiceProvider(new Database())
->registerServiceProvider(new PowerDatabase())
->registerServiceProvider(new Model())
->registerServiceProvider(new Data())
->registerServiceProvider(new Gitea())
->registerServiceProvider(new GiteaPower())
->registerServiceProvider(new GiteaUtilities());

View File

@@ -56,7 +56,9 @@ final class Grep extends ExtendingGrep implements GrepInterface
try
{
$path->index = $this->contents->get($path->owner, $path->repo, 'joomla-powers.json', $path->branch);
$this->contents->load_($path->base ?? null, $path->token ?? null);
$path->index = $this->contents->get($path->organisation, $path->repository, 'joomla-powers.json', $path->read_branch);
$this->contents->reset_();
}
catch (\Exception $e)
{
@@ -108,46 +110,43 @@ final class Grep extends ExtendingGrep implements GrepInterface
*/
protected function getRemote(object $path, string $guid): ?object
{
$power = null;
if (empty($path->index->{$guid}->settings))
{
return null;
return $power;
}
// get the settings
if (($power = $this->loadRemoteFile($path->owner, $path->repo, $path->index->{$guid}->settings, $path->branch)) !== null &&
$this->contents->load_($path->base ?? null, $path->token ?? null);
if (($power = $this->loadRemoteFile($path->organisation, $path->repository, $path->index->{$guid}->settings, $path->read_branch)) !== null &&
isset($power->guid))
{
// set the git details in params
$power->params = (object) [
'git' => [
'owner' => $path->owner,
'repo' => $path->repo,
'branch' => $path->branch
]
'source' => ['guid' => $path->guid ?? null]
];
return $power;
}
$this->contents->reset_();
return null;
return $power;
}
/**
* Load the remote file
*
* @param string $owner The repository owner
* @param string $repo The repository name
* @param string $path The repository path to file
* @param string|null $branch The repository branch name
* @param string $organisation The repository organisation
* @param string $repository The repository name
* @param string $path The repository path to file
* @param string|null $branch The repository branch name
*
* @return mixed
* @since 3.2.0
*/
protected function loadRemoteFile(string $owner, string $repo, string $path, ?string $branch)
protected function loadRemoteFile(string $organisation, string $repository, string $path, ?string $branch)
{
try
{
$data = $this->contents->get($owner, $repo, $path, $branch);
$data = $this->contents->get($organisation, $repository, $path, $branch);
}
catch (\Exception $e)
{

View File

@@ -1,37 +0,0 @@
<?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\Componentbuilder\JoomlaPower\Model;
use VDM\Joomla\Interfaces\ModelInterface;
use VDM\Joomla\Componentbuilder\Power\Model\Load as ExtendingLoad;
/**
* Joomla Power Model Load
*
* @since 3.2.0
*/
final class Load extends ExtendingLoad implements ModelInterface
{
/**
* Get the current active table
*
* @return string
* @since 3.2.0
*/
protected function getTable(): string
{
return 'joomla_power';
}
}

View File

@@ -1,38 +0,0 @@
<?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\Componentbuilder\JoomlaPower\Model;
use VDM\Joomla\Interfaces\ModelInterface;
use VDM\Joomla\Componentbuilder\Power\Model\Upsert as ExtendingUpsert;
/**
* Joomla Power Model Update or Insert
*
* @since 3.2.0
*/
final class Upsert extends ExtendingUpsert implements ModelInterface
{
/**
* Get the current active table
*
* @return string
* @since 3.2.0
*/
protected function getTable(): string
{
return 'joomla_power';
}
}

View File

@@ -1 +0,0 @@
<html><body bgcolor="#FFFFFF"></body></html>

View File

@@ -1,135 +0,0 @@
<?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\Componentbuilder\JoomlaPower\Service;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use VDM\Joomla\Componentbuilder\JoomlaPower\Model\Load as ModelLoad;
use VDM\Joomla\Componentbuilder\JoomlaPower\Model\Upsert as ModelUpsert;
use VDM\Joomla\Componentbuilder\JoomlaPower\Database\Load as LoadDatabase;
use VDM\Joomla\Componentbuilder\JoomlaPower\Database\Insert as InsertDatabase;
use VDM\Joomla\Componentbuilder\JoomlaPower\Database\Update as UpdateDatabase;
/**
* Database Service Provider
*
* @since 3.2.0
*/
class Database implements ServiceProviderInterface
{
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
* @since 3.2.0
*/
public function register(Container $container)
{
$container->alias(ModelLoad::class, 'Joomla.Power.Model.Load')
->share('Joomla.Power.Model.Load', [$this, 'getModelLoad'], true);
$container->alias(ModelUpsert::class, 'Joomla.Power.Model.Upsert')
->share('Joomla.Power.Model.Upsert', [$this, 'getModelUpsert'], true);
$container->alias(LoadDatabase::class, 'Joomla.Power.Database.Load')
->share('Joomla.Power.Database.Load', [$this, 'getLoadDatabase'], true);
$container->alias(InsertDatabase::class, 'Joomla.Power.Database.Insert')
->share('Joomla.Power.Database.Insert', [$this, 'getInsertDatabase'], true);
$container->alias(UpdateDatabase::class, 'Joomla.Power.Database.Update')
->share('Joomla.Power.Database.Update', [$this, 'getUpdateDatabase'], true);
}
/**
* Get the Power Model Load
*
* @param Container $container The DI container.
*
* @return ModelLoad
* @since 3.2.0
*/
public function getModelLoad(Container $container): ModelLoad
{
return new ModelLoad(
$container->get('Table')
);
}
/**
* Get the Power Model Update or Insert
*
* @param Container $container The DI container.
*
* @return ModelUpsert
* @since 3.2.0
*/
public function getModelUpsert(Container $container): ModelUpsert
{
return new ModelUpsert(
$container->get('Table')
);
}
/**
* Get the Load Database
*
* @param Container $container The DI container.
*
* @return LoadDatabase
* @since 3.2.0
*/
public function getLoadDatabase(Container $container): LoadDatabase
{
return new LoadDatabase(
$container->get('Joomla.Power.Model.Load'),
$container->get('Load')
);
}
/**
* Get the Insert Database
*
* @param Container $container The DI container.
*
* @return InsertDatabase
* @since 3.2.0
*/
public function getInsertDatabase(Container $container): InsertDatabase
{
return new InsertDatabase(
$container->get('Joomla.Power.Model.Upsert'),
$container->get('Insert')
);
}
/**
* Get the Update Database
*
* @param Container $container The DI container.
*
* @return UpdateDatabase
* @since 3.2.0
*/
public function getUpdateDatabase(Container $container): UpdateDatabase
{
return new UpdateDatabase(
$container->get('Joomla.Power.Model.Upsert'),
$container->get('Update')
);
}
}

View File

@@ -108,8 +108,7 @@ class JoomlaPower implements ServiceProviderInterface
{
return new Superpower(
$container->get('Joomla.Power.Grep'),
$container->get('Joomla.Power.Database.Insert'),
$container->get('Joomla.Power.Database.Update')
$container->get('Data.Item')
);
}

View File

@@ -12,8 +12,8 @@
namespace VDM\Joomla\Componentbuilder\JoomlaPower;
use VDM\Joomla\Componentbuilder\Interfaces\SuperInterface;
use VDM\Joomla\Componentbuilder\Power\Super as ExtendingSuper;
use VDM\Joomla\Interfaces\Data\RemoteInterface;
use VDM\Joomla\Data\Remote;
/**
@@ -21,7 +21,7 @@ use VDM\Joomla\Componentbuilder\Power\Super as ExtendingSuper;
*
* @since 3.2.0
*/
final class Super extends ExtendingSuper implements SuperInterface
final class Super extends Remote implements RemoteInterface
{
/**
* Table Name