Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"ext-pdo_mysql": "*",
"ext-redis": "*",
"ext-swoole": ">=5.0",
"ext-zip": "*",
"doctrine/dbal": "^3.1",
"hyperf/amqp": "~3.1.0",
"hyperf/async-queue": "~3.1.0",
Expand Down
4 changes: 2 additions & 2 deletions src/app-store/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"description": "Mineadmin 2.0 AppStore Extension",
"type": "library",
"require": {
"xmo/mine-core": "v2.0.x-dev",
"xmo/mine-service": "v2.0.x-dev"
"hyperf/translation": "~3.1.0",
"ext-zip": "*"
},
"require-dev": {
"pestphp/pest": "^2.33"
Expand Down
63 changes: 63 additions & 0 deletions src/app-store/publish/mine-extension.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?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
*/
use function Hyperf\Support\env;

return [
/*
* Whether to enable the Extended Store feature,
* it is recommended to disable it for production environments.
* Default with APP_DEBUG environment on off
*
* 是否开启扩展商店功能,生产环境建议禁用。默认随着 APP_DEBUG 环境开启关闭
*/
'enable' => env('APP_DEBUG', false),
/*
* MineAdmin
*/
'access_token' => env('MINE_ACCESS_TOKEN'),

/*
* The root directory where the front-end code resides.
*
* 前端代码所在根目录.
*/
'front_directory' => BASE_PATH . '/web',
'composer' => [
/*
* composer executes the program directly from composer by default,
* but if there is an environment restriction,
* you can specify something like /usr/bin/composer.
*
*
* composer 执行程序 默认直接是 composer 如果有环境限制 可以指定比如 /usr/bin/composer
*/
'bin' => 'composer',
],
'front-tool' => [
/*
* Front-end package management execution tools Optional npm yarn pnpm, default npm is used
*
*
* 前端包管理执行工具 可选 npm yarn pnpm,默认使用 npm
*/
'type' => 'npm',
/*
* The default directory for executing programs is npm,
* but if you don't have the npm environment variable configured,
* you can manually specify the program to execute, e.g. /usr/local/npm/bin/npm.
*
*
* 执行程序所在目录 默认是直接执行 npm, 如果没有配置 npm 环境变量 则可以手动指定 执行程序 例如 /usr/local/npm/bin/npm
*/
'bin' => 'npm',
],
];
4 changes: 3 additions & 1 deletion src/app-store/publish/trans/en.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);
/**
* This file is part of MineAdmin.
*
Expand Down
40 changes: 40 additions & 0 deletions src/app-store/src/Command/ExtensionDownloadCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?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 Xmo\AppStore\Command;

use Hyperf\Command\Annotation\Command;
use Hyperf\Command\Command as Base;
use Hyperf\Context\ApplicationContext;
use Symfony\Component\Console\Input\InputOption;
use Xmo\AppStore\Service\AppStoreService;

#[Command]
class ExtensionDownloadCommand extends Base
{
protected ?string $name = 'mine-extension:download';

protected string $description = 'Download the specified remote plug-in file locally';

public function __invoke()
{
$name = $this->input->getOption('name');
$appStoreService = ApplicationContext::getContainer()->get(AppStoreService::class);
$appStoreService->download($name);
$this->output->success('Plugin Downloaded Successfully');
}

protected function configure()
{
$this->addOption('name', 'n', InputOption::VALUE_REQUIRED, 'Plug-in Name');
}
}
55 changes: 55 additions & 0 deletions src/app-store/src/Command/ExtensionInitialCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?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 Xmo\AppStore\Command;

use Hyperf\Command\Annotation\Command;
use Hyperf\Command\Command as Base;
use Nette\Utils\FileSystem;
use Symfony\Component\Console\Input\InputOption;

#[Command]
class ExtensionInitialCommand extends Base
{
protected ?string $name = 'mine-extension:initial';

protected string $description = 'MineAdmin Extended Store Initialization Command Line';

public function __invoke(): void
{
$this->output->info('Start initialization');
$this->output->info('Publishing multilingual documents');
$publishPath = dirname(__DIR__, 2) . DIRECTORY_SEPARATOR . 'publish';
$languages = BASE_PATH . '/storage/languages';
FileSystem::copy($publishPath . '/trans/en.php', $languages . '/en/app-store.php');
FileSystem::copy($publishPath . '/trans/zh-CN.php', $languages . '/zh_CN/app-store.php');
$this->output->success('Language file published successfully');
$this->output->info('Publishing Configuration Files');
FileSystem::copy($publishPath . '/mine-extension.php', BASE_PATH . '/config/autoload/mine-extension.php');
$this->output->success('Publishing Configuration File Succeeded');
$this->output->warning('
接下来选择开发模式,
默认是用 ./web 目录作为前端源码所在目录,
也可以配置 mine-extension.php 配置文件
手动指定前端源代码开发目录');
$this->output->warning('
Next, select the development mode.
The default is to use . /web directory as the front-end source code directory.
You can also configure the mine-extension.php configuration file
Manually specify the front-end source code development directory');
}

protected function configure()
{
$this->addOption('force', 'f', InputOption::VALUE_NONE, 'Whether or not coverage is mandatory');
}
}
63 changes: 63 additions & 0 deletions src/app-store/src/Command/ExtensionInstallCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?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 Xmo\AppStore\Command;

use Hyperf\Command\Annotation\Command;
use Hyperf\Command\Command as Base;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use Xmo\AppStore\Plugin;
use Xmo\AppStore\Service\PluginService;

#[Command]
class ExtensionInstallCommand extends Base
{
protected ?string $name = 'mine-extension:install';

protected string $description = 'Installing Plugin Commands';

public function __construct(
private readonly PluginService $pluginService
) {
parent::__construct();
}

public function __invoke()
{
$path = $this->input->getArgument('path');
$yes = $this->input->getOption('yes');
$info = Plugin::read($path);

$headers = ['Extension name', 'author', 'description', 'homepage'];
$rows[] = [
$info['name'],
is_string($info['author']) ? $info['author'] : ($info['author'][0]['name'] ?? '--'),
$info['description'],
$info['homepage'] ?? '--',
];
$this->table($headers, $rows);
$confirm = $yes ?: $this->confirm('Enter to start the installation', true);
if (! $confirm) {
$this->output->success('Installation has been successfully canceled');
return;
}
Plugin::install($path);
$this->output->success(sprintf('Plugin %s installed successfully', $path));
}

protected function configure()
{
$this->addArgument('path', InputArgument::REQUIRED, 'Plug-in Catalog (relative path)');
$this->addOption('yes', 'y', InputOption::VALUE_NONE, 'silent installation');
}
}
51 changes: 51 additions & 0 deletions src/app-store/src/Command/ExtensionListCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?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 Xmo\AppStore\Command;

use Hyperf\Command\Annotation\Command;
use Hyperf\Command\Command as Base;
use Hyperf\Context\ApplicationContext;
use Symfony\Component\Console\Input\InputOption;
use Xmo\AppStore\Service\AppStoreService;

#[Command]
class ExtensionListCommand extends Base
{
protected ?string $name = 'mine-extension:list';

protected string $description = 'View a list of remote app store plugins';

public function __invoke()
{
$params = [];
$params['type'] = $this->input->getOption('type');
if (empty($params['type'])) {
$type = 'all';
}
if ($title = $this->input->getOption('title')) {
$params['title'] = $title;
}
$appStoreService = ApplicationContext::getContainer()->get(AppStoreService::class);
$result = $appStoreService->list($params);
$headers = [
'extensionName', 'description', 'author', 'homePage', 'status',
];
$this->output->table($headers, $result);
}

protected function configure()
{
$this->addOption('type', 't', InputOption::VALUE_OPTIONAL, 'Type of plugin to query');
$this->addOption('title', 'title', InputOption::VALUE_OPTIONAL, 'Plugin Title');
}
}
50 changes: 50 additions & 0 deletions src/app-store/src/Command/ExtensionLocalListCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?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 Xmo\AppStore\Command;

use Hyperf\Command\Annotation\Command;
use Hyperf\Command\Command as Base;
use Xmo\AppStore\Plugin;

#[Command]
class ExtensionLocalListCommand extends Base
{
protected ?string $name = 'mine-extension:local-list';

protected string $description = 'List all locally installed extensions(列出本地所有已经安装的扩展)';

public function __invoke()
{
$list = Plugin::getPluginJsonPaths();

$headers = [
'extensionName', 'description', 'author', 'homePage', 'status',
];
$rows = [];
foreach ($list as $splFileInfo) {
$info = Plugin::read($splFileInfo->getPath());
$current = [];
$current[] = $info['name'];
$current[] = $info['description'];
if (is_string($info['author'])) {
$current[] = $info['author'];
} else {
$current[] = $info['author'][0]['name'] ?? '--';
}
$current[] = $info['homePage'] ?? '--';
$current[] = $info['status'] ? 'installed' : 'uninstalled';
$rows[] = $current;
}
$this->table($headers, $rows);
}
}
Loading