-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathLocalListCommand.php
More file actions
53 lines (46 loc) · 1.48 KB
/
LocalListCommand.php
File metadata and controls
53 lines (46 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
declare(strict_types=1);
/**
* This file is part of MineAdmin.
*
* @link https://www.mineadmin.com
* @document https://doc.mineadmin.com
* @contact root@imoi.cn
* @license https://github.com/mineadmin/MineAdmin/blob/master/LICENSE
*/
namespace Mine\AppStore\Command;
use Hyperf\Command\Annotation\Command;
use Mine\AppStore\Plugin;
#[Command]
class LocalListCommand extends AbstractCommand
{
protected const COMMAND_NAME = 'local-list';
protected string $description = 'List all locally installed extensions(列出本地所有已经安装的扩展)';
public function __invoke(): int
{
$list = Plugin::getPluginJsonPaths();
$headers = [
'extensionName', 'description', 'author', 'homePage', 'status',
];
$rows = [];
foreach ($list as $splFileInfo) {
$info = Plugin::read($splFileInfo->getRelativePath());
$current = [
$info['name'],
$info['description'],
];
if (\is_string($info['author'])) {
$current[] = $info['author'];
} else {
$current[] = $info['author'][0]['name'] ?? '--';
}
$current = array_merge($current, [
$info['homePage'] ?? '--',
$info['status'] ? 'installed' : 'uninstalled',
]);
$rows[] = $current;
}
$this->table($headers, $rows);
return AbstractCommand::SUCCESS;
}
}