App info provider, versions providers

This commit is contained in:
Yurii
2026-06-16 09:16:43 +03:00
parent 1c9e890322
commit 83c09f37da
7 changed files with 155 additions and 27 deletions

View File

@@ -33,17 +33,15 @@ use Espo\Core\Binding\Binding as BindingItem;
use Espo\Core\Binding\EspoBindingLoader;
use Espo\Core\Console\Command\Params;
use Espo\Core\Utils\Module;
use Espo\Tools\ConsoleAppInfo\InfoProvider;
class Binding
class Binding implements InfoProvider
{
private Module $module;
public function __construct(Module $module)
{
$this->module = $module;
}
public function __construct(private Module $module)
{}
public function process(Params $params): string
public function get(Params $params): string
{
$result = '';

View File

@@ -32,13 +32,14 @@ namespace Espo\Classes\AppInfo;
use Espo\Core\Console\Command\Params;
use Espo\Core\Container as ContainerService;
use Espo\Core\Utils\Metadata;
use Espo\Tools\ConsoleAppInfo\InfoProvider;
class Container
class Container implements InfoProvider
{
public function __construct(private ContainerService $container, private Metadata $metadata)
{}
public function process(Params $params): string
public function get(Params $params): string
{
$nameOnly = $params->hasFlag('nameOnly');

View File

@@ -0,0 +1,49 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM Open Source CRM application.
* Copyright (C) 2014-2026 EspoCRM, Inc.
* Website: https://www.espocrm.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
namespace Espo\Classes\AppInfo;
use Espo\Core\Console\Command\Params;
use Espo\Core\Upgrades\Migration\VersionDataProvider;
use Espo\Tools\ConsoleAppInfo\InfoProvider;
/**
* @noinspection PhpUnused
*/
class CoreVersion implements InfoProvider
{
public function __construct(
private VersionDataProvider $versionDataProvider,
) {}
public function get(Params $params): string
{
return $this->versionDataProvider->getTargetVersion();
}
}

View File

@@ -32,20 +32,17 @@ namespace Espo\Classes\AppInfo;
use Espo\Core\Console\Command\Params;
use Espo\Core\Utils\ClassFinder;
use Espo\Core\Job\MetadataProvider;
use Espo\Tools\ConsoleAppInfo\InfoProvider;
class Jobs
class Jobs implements InfoProvider
{
private $classFinder;
private $metadataProvider;
public function __construct(
private ClassFinder $classFinder,
private MetadataProvider $metadataProvider,
) {}
public function __construct(ClassFinder $classFinder, MetadataProvider $metadataProvider)
{
$this->classFinder = $classFinder;
$this->metadataProvider = $metadataProvider;
}
public function process(Params $params): string
public function get(Params $params): string
{
$result = "Available jobs:\n\n";

View File

@@ -0,0 +1,46 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM Open Source CRM application.
* Copyright (C) 2014-2026 EspoCRM, Inc.
* Website: https://www.espocrm.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
namespace Espo\Classes\AppInfo;
use Espo\Core\Console\Command\Params;
use Espo\Core\Utils\Config\SystemConfig;
use Espo\Tools\ConsoleAppInfo\InfoProvider;
class Version implements InfoProvider
{
public function __construct(
private SystemConfig $systemConfig,
) {}
public function get(Params $params): string
{
return $this->systemConfig->getVersion();
}
}

View File

@@ -35,6 +35,7 @@ use Espo\Core\Console\IO;
use Espo\Core\InjectableFactory;
use Espo\Core\Utils\File\Manager as FileManager;
use Espo\Core\Utils\Util;
use Espo\Tools\ConsoleAppInfo\InfoProvider;
/**
* @noinspection PhpUnused
@@ -57,7 +58,7 @@ class AppInfo implements Command
);
foreach ($typeList as $type) {
if ($params->hasFlag(Util::camelCaseToHyphen($type))) {
if ($params->hasFlag($type)) {
$this->processType($io, $type, $params);
return;
@@ -83,17 +84,13 @@ class AppInfo implements Command
protected function processType(IO $io, string $type, Params $params): void
{
/** @var class-string $className */
/** @var class-string<InfoProvider> $className */
$className = 'Espo\\Classes\\AppInfo\\' . ucfirst($type);
$obj = $this->injectableFactory->create($className);
$provider = $this->injectableFactory->create($className);
// @todo Use inteface.
assert(method_exists($obj, 'process'));
$result = $provider->get($params);
$result = $obj->process($params);
$io->writeLine('');
$io->write($result);
$io->writeLine("");
}

View File

@@ -0,0 +1,40 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM Open Source CRM application.
* Copyright (C) 2014-2026 EspoCRM, Inc.
* Website: https://www.espocrm.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
namespace Espo\Tools\ConsoleAppInfo;
use Espo\Core\Console\Command\Params;
/**
* @since 10.0.0
*/
interface InfoProvider
{
public function get(Params $params): string;
}