command noSystemUser param

This commit is contained in:
Yuri Kuznetsov
2024-04-04 20:53:33 +03:00
parent 77f60734f6
commit 0a115a3603
4 changed files with 41 additions and 8 deletions

View File

@@ -40,7 +40,6 @@ use Exception;
class Command implements Runner
{
use Cli;
use SetupSystemUser;
public function __construct(private ConsoleCommandManager $commandManager)
{}

View File

@@ -29,6 +29,7 @@
namespace Espo\Core\Console;
use Espo\Core\ApplicationUser;
use Espo\Core\InjectableFactory;
use Espo\Core\Utils\Metadata;
use Espo\Core\Utils\Util;
@@ -44,8 +45,11 @@ class CommandManager
private const DEFAULT_COMMAND = 'Help';
private const DEFAULT_COMMAND_FLAG = 'help';
public function __construct(private InjectableFactory $injectableFactory, private Metadata $metadata)
{}
public function __construct(
private InjectableFactory $injectableFactory,
private Metadata $metadata,
private ApplicationUser $applicationUser
) {}
/**
* @param array<int, string> $argv
@@ -75,6 +79,8 @@ class CommandManager
$io = new IO();
$this->setupUser($command);
$commandObj = $this->createCommand($command);
if (!$commandObj instanceof Command) {
@@ -146,4 +152,15 @@ class CommandManager
{
return Params::fromArgs(array_slice($argv, 1));
}
private function setupUser(string $command): void
{
$noSystemUser = $this->metadata->get(['app', 'consoleCommands', lcfirst($command), 'noSystemUser']);
if ($noSystemUser) {
return;
}
$this->applicationUser->setupSystemUser();
}
}

View File

@@ -4,13 +4,16 @@
"listed": true
},
"clearCache": {
"listed": true
"listed": true,
"noSystemUser": true
},
"rebuild": {
"listed": true
"listed": true,
"noSystemUser": true
},
"updateAppTimestamp": {
"listed": true
"listed": true,
"noSystemUser": true
},
"appInfo": {
"listed": true
@@ -28,7 +31,8 @@
"listed": true
},
"version": {
"listed": true
"listed": true,
"noSystemUser": true
},
"createAdminUser": {
"className": "Espo\\Classes\\ConsoleCommands\\CreateAdminUser",
@@ -48,6 +52,15 @@
},
"checkFilePermissions": {
"className": "Espo\\Classes\\ConsoleCommands\\CheckFilePermissions",
"listed": true
"listed": true,
"noSystemUser": true
},
"migrate": {
"listed": true,
"noSystemUser": true
},
"migrationVersionStep": {
"listed": false,
"noSystemUser": true
}
}

View File

@@ -15,6 +15,10 @@
"listed": {
"type": "boolean",
"description": "Whether the command is listed when running bin/command."
},
"noSystemUser": {
"type": "boolean",
"description": "Do not load the system user."
}
}
}