Release of v4.0.1-alpha7
Add push options to Joomla Power. Complete the Joomla Power Init and Reset features. Fix Gitea Contents class functions. Last Alpha release (feature block).
This commit is contained in:
@@ -16,6 +16,7 @@ use Joomla\Registry\Registry as JoomlaRegistry;
|
||||
use Joomla\CMS\Factory as JoomlaFactory;
|
||||
use VDM\Joomla\Utilities\GetHelper;
|
||||
use VDM\Joomla\Utilities\StringHelper;
|
||||
use VDM\Joomla\Componentbuilder\Utilities\RepoHelper;
|
||||
use VDM\Joomla\Componentbuilder\Abstraction\BaseConfig;
|
||||
|
||||
|
||||
@@ -113,21 +114,6 @@ class Config extends BaseConfig
|
||||
return $repos;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Joomla power push repo
|
||||
*
|
||||
* @return object|null The push repository on Gitea
|
||||
* @since 3.2.1
|
||||
*/
|
||||
protected function getJoomlapowerspushrepo(): ?object
|
||||
{
|
||||
// some defaults repos we need by JCB
|
||||
if (!empty($this->gitea_username))
|
||||
{
|
||||
return (object) ['organisation' => $this->gitea_username, 'repository' => 'joomla-powers', 'read_branch' => 'master'];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get joomla power approved paths
|
||||
*
|
||||
@@ -136,7 +122,26 @@ class Config extends BaseConfig
|
||||
*/
|
||||
protected function getApprovedjoomlapaths(): array
|
||||
{
|
||||
return array_values($this->joomla_powers_init_repos);
|
||||
// some defaults repos we need by JCB
|
||||
$approved = $this->joomla_powers_init_repos;
|
||||
|
||||
$paths = RepoHelper::get(2); // Joomla Power = 2
|
||||
|
||||
if ($paths !== null)
|
||||
{
|
||||
foreach ($paths as $path)
|
||||
{
|
||||
$owner = $path->organisation ?? null;
|
||||
$repo = $path->repository ?? null;
|
||||
if ($owner !== null && $repo !== null)
|
||||
{
|
||||
// we make sure to get only the objects
|
||||
$approved = ["{$owner}.{$repo}" => $path] + $approved;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return array_values($approved);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -54,20 +54,36 @@ final class Grep extends ExtendingGrep implements GrepInterface
|
||||
return;
|
||||
}
|
||||
|
||||
$path->index = null;
|
||||
|
||||
// update the branch
|
||||
$branch_field = $this->getBranchField();
|
||||
$branch = $path->{$branch_field} ?? $path->read_branch ?? 'master';
|
||||
|
||||
try
|
||||
{
|
||||
$this->contents->load_($path->base ?? null, $path->token ?? null);
|
||||
$path->index = $this->contents->get($path->organisation, $path->repository, 'joomla-powers.json', $path->read_branch);
|
||||
$source = $this->contents->metadata($path->organisation, $path->repository, 'src', $branch);
|
||||
if ($source && is_array($source))
|
||||
{
|
||||
$path->index = new \stdClass();
|
||||
foreach ($source as $index)
|
||||
{
|
||||
if (is_object($index) && isset($index->name))
|
||||
{
|
||||
$path->index->{$index->name} = $index;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->contents->reset_();
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
$this->app->enqueueMessage(
|
||||
Text::sprintf('COM_COMPONENTBUILDER_PSUPER_POWERB_REPOSITORY_AT_BSSB_GAVE_THE_FOLLOWING_ERRORBR_SP', $this->contents->api(), $path->path, $e->getMessage()),
|
||||
Text::sprintf('COM_COMPONENTBUILDER_PJOOMLA_POWERB_REPOSITORY_AT_BSSB_GAVE_THE_FOLLOWING_ERRORBR_SP', $this->contents->api(), $path->path, $e->getMessage()),
|
||||
'Error'
|
||||
);
|
||||
|
||||
$path->index = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,7 +98,7 @@ final class Grep extends ExtendingGrep implements GrepInterface
|
||||
protected function searchRemote(string $guid): ?object
|
||||
{
|
||||
// we can only search if we have paths
|
||||
if ($this->path && $this->paths)
|
||||
if (is_array($this->paths))
|
||||
{
|
||||
foreach ($this->paths as $path)
|
||||
{
|
||||
@@ -100,7 +116,7 @@ final class Grep extends ExtendingGrep implements GrepInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a remote power
|
||||
* Get a remote joomla power
|
||||
*
|
||||
* @param object $path The repository path details
|
||||
* @param string $guid The global unique id of the power
|
||||
@@ -111,20 +127,40 @@ final class Grep extends ExtendingGrep implements GrepInterface
|
||||
protected function getRemote(object $path, string $guid): ?object
|
||||
{
|
||||
$power = null;
|
||||
if (empty($path->index->{$guid}->settings))
|
||||
if (empty($path->index->{$guid}->path))
|
||||
{
|
||||
return $power;
|
||||
}
|
||||
|
||||
// get the branch name
|
||||
$branch_field = $this->getBranchField();
|
||||
$branch = $path->{$branch_field} ?? $path->read_branch ?? 'master';
|
||||
|
||||
// get the settings
|
||||
$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 &&
|
||||
if (($power = $this->loadRemoteFile($path->organisation, $path->repository, $path->index->{$guid}->path . '/item.json', $branch)) !== null &&
|
||||
isset($power->guid))
|
||||
{
|
||||
// set the git details in params
|
||||
$power->params = (object) [
|
||||
'source' => ['guid' => $path->guid ?? null]
|
||||
];
|
||||
$path_guid = $path->guid ?? null;
|
||||
if ($path_guid !== null)
|
||||
{
|
||||
if (($meta = $this->contents->metadata($path->organisation, $path->repository, $path->index->{$guid}->path . '/item.json', $branch)) !== null &&
|
||||
isset($meta->sha))
|
||||
{
|
||||
if (isset($power->params) && is_object($power->params) &&
|
||||
isset($power->params->source) && is_array($power->params->source))
|
||||
{
|
||||
$power->params->source[$path_guid] = $meta->sha;
|
||||
}
|
||||
else
|
||||
{
|
||||
$power->params = (object)[
|
||||
'source' => [$path_guid => $meta->sha]
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->contents->reset_();
|
||||
|
||||
|
@@ -0,0 +1,46 @@
|
||||
<?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;
|
||||
|
||||
|
||||
use VDM\Joomla\Data\Repository as ExtendingRepository;
|
||||
|
||||
|
||||
/**
|
||||
* Set JoomlaPower based on global unique ids to remote repository
|
||||
*
|
||||
* @since 3.2.2
|
||||
*/
|
||||
final class Repository extends ExtendingRepository
|
||||
{
|
||||
/**
|
||||
* Table Name
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.1
|
||||
*/
|
||||
protected string $table = 'joomla_power';
|
||||
|
||||
/**
|
||||
* The item map
|
||||
*
|
||||
* @var array
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected array $map = [
|
||||
'system_name' => 'system_name',
|
||||
'settings' => 'settings',
|
||||
'guid' => 'guid',
|
||||
'description' => 'description'
|
||||
];
|
||||
}
|
||||
|
@@ -18,6 +18,7 @@ use VDM\Joomla\Componentbuilder\JoomlaPower\Config;
|
||||
use VDM\Joomla\Componentbuilder\Table;
|
||||
use VDM\Joomla\Componentbuilder\JoomlaPower\Grep;
|
||||
use VDM\Joomla\Componentbuilder\JoomlaPower\Super as Superpower;
|
||||
use VDM\Joomla\Componentbuilder\JoomlaPower\Repository;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Power\Parser;
|
||||
|
||||
|
||||
@@ -34,7 +35,7 @@ class JoomlaPower implements ServiceProviderInterface
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
* @since 3.2.1
|
||||
*/
|
||||
public function register(Container $container)
|
||||
{
|
||||
@@ -50,6 +51,9 @@ class JoomlaPower implements ServiceProviderInterface
|
||||
$container->alias(Superpower::class, 'Joomlapower')
|
||||
->share('Joomlapower', [$this, 'getSuperpower'], true);
|
||||
|
||||
$container->alias(Repository::class, 'Joomla.Power.Repository')
|
||||
->share('Joomla.Power.Repository', [$this, 'getRepository'], true);
|
||||
|
||||
$container->alias(Parser::class, 'Power.Parser')
|
||||
->share('Power.Parser', [$this, 'getParser'], true);
|
||||
}
|
||||
@@ -60,7 +64,7 @@ class JoomlaPower implements ServiceProviderInterface
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Config
|
||||
* @since 3.2.0
|
||||
* @since 3.2.1
|
||||
*/
|
||||
public function getConfig(Container $container): Config
|
||||
{
|
||||
@@ -73,7 +77,7 @@ class JoomlaPower implements ServiceProviderInterface
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Table
|
||||
* @since 3.2.0
|
||||
* @since 3.2.1
|
||||
*/
|
||||
public function getTable(Container $container): Table
|
||||
{
|
||||
@@ -86,7 +90,7 @@ class JoomlaPower implements ServiceProviderInterface
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Grep
|
||||
* @since 3.2.0
|
||||
* @since 3.2.1
|
||||
*/
|
||||
public function getGrep(Container $container): Grep
|
||||
{
|
||||
@@ -102,7 +106,7 @@ class JoomlaPower implements ServiceProviderInterface
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Superpower
|
||||
* @since 3.2.0
|
||||
* @since 3.2.1
|
||||
*/
|
||||
public function getSuperpower(Container $container): Superpower
|
||||
{
|
||||
@@ -112,13 +116,31 @@ class JoomlaPower implements ServiceProviderInterface
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Repository Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Repository
|
||||
* @since 3.2.2
|
||||
*/
|
||||
public function getRepository(Container $container): Repository
|
||||
{
|
||||
return new Repository(
|
||||
$container->get('Config')->approved_joomla_paths,
|
||||
$container->get('Joomla.Power.Grep'),
|
||||
$container->get('Data.Items'),
|
||||
$container->get('Gitea.Repository.Contents')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Parser Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Parser
|
||||
* @since 3.2.0
|
||||
* @since 3.2.1
|
||||
*/
|
||||
public function getParser(Container $container): Parser
|
||||
{
|
||||
|
@@ -135,26 +135,6 @@ class Config extends BaseConfig
|
||||
return $repos;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get super power push repo
|
||||
*
|
||||
* @return object|null The push repository on Gitea
|
||||
* @since 3.2.1
|
||||
*/
|
||||
protected function getSuperpowerspushrepo(): ?object
|
||||
{
|
||||
if ($this->gitea_username !== null)
|
||||
{
|
||||
return (object) [
|
||||
'organisation' => $this->gitea_username,
|
||||
'repository' => 'super-powers',
|
||||
'read_branch' => 'master'
|
||||
];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* get temporary path
|
||||
*
|
||||
|
Reference in New Issue
Block a user