|
@@ -10,6 +10,7 @@ use think\console\Input;
|
|
|
use think\console\input\Argument;
|
|
use think\console\input\Argument;
|
|
|
use think\console\Output;
|
|
use think\console\Output;
|
|
|
use think\console\Table;
|
|
use think\console\Table;
|
|
|
|
|
+use function SixShop\Core\extension_path;
|
|
|
|
|
|
|
|
class ExtensionManagementCommand extends Command
|
|
class ExtensionManagementCommand extends Command
|
|
|
{
|
|
{
|
|
@@ -60,9 +61,9 @@ class ExtensionManagementCommand extends Command
|
|
|
$output->error('请指定要创建的扩展模块名');
|
|
$output->error('请指定要创建的扩展模块名');
|
|
|
return self::FAILURE;
|
|
return self::FAILURE;
|
|
|
}
|
|
}
|
|
|
- $basePath = Helper::extension_path($module);
|
|
|
|
|
|
|
+ $basePath = extension_path($module);
|
|
|
if (is_dir($basePath)) {
|
|
if (is_dir($basePath)) {
|
|
|
- $output->error("扩展 {$module} 已存在");
|
|
|
|
|
|
|
+ $output->error("扩展 $module 已存在");
|
|
|
return self::FAILURE;
|
|
return self::FAILURE;
|
|
|
}
|
|
}
|
|
|
// 创建目录结构
|
|
// 创建目录结构
|
|
@@ -87,13 +88,13 @@ class ExtensionManagementCommand extends Command
|
|
|
$infoExport = str_replace(['array (', ')'], ['[', ']'], $infoExport);
|
|
$infoExport = str_replace(['array (', ')'], ['[', ']'], $infoExport);
|
|
|
file_put_contents($basePath . 'info.php', "<?php\ndeclare(strict_types=1);\nreturn " . $infoExport . ";\n");
|
|
file_put_contents($basePath . 'info.php', "<?php\ndeclare(strict_types=1);\nreturn " . $infoExport . ";\n");
|
|
|
// Extension.php
|
|
// Extension.php
|
|
|
- $extClass = "<?php\ndeclare(strict_types=1);\n\nnamespace SixShop\\Extension\\{$module};\n\nuse SixShop\\Extension\\core\\ExtensionAbstract;\n\nclass Extension extends ExtensionAbstract\n{\n protected function getBaseDir(): string\n {\n return dirname(__DIR__);\n }\n}\n";
|
|
|
|
|
|
|
+ $extClass = "<?php\ndeclare(strict_types=1);\n\nnamespace SixShop\\Extension\\$module;\n\nuse SixShop\\Extension\\core\\ExtensionAbstract;\n\nclass Extension extends ExtensionAbstract\n{\n protected function getBaseDir(): string\n {\n return dirname(__DIR__);\n }\n}\n";
|
|
|
file_put_contents($basePath . 'src/Extension.php', $extClass);
|
|
file_put_contents($basePath . 'src/Extension.php', $extClass);
|
|
|
// README.md
|
|
// README.md
|
|
|
file_put_contents($basePath . 'README.md', "# $module\n\n扩展说明\n");
|
|
file_put_contents($basePath . 'README.md', "# $module\n\n扩展说明\n");
|
|
|
// config.php
|
|
// config.php
|
|
|
file_put_contents($basePath . 'config.php', "<?php\ndeclare(strict_types=1);\n\nreturn [];\n");
|
|
file_put_contents($basePath . 'config.php', "<?php\ndeclare(strict_types=1);\n\nreturn [];\n");
|
|
|
- $output->warning("扩展 {$module} 创建成功,目录:$basePath");
|
|
|
|
|
|
|
+ $output->warning("扩展 $module 创建成功,目录:$basePath");
|
|
|
break;
|
|
break;
|
|
|
case 'install':
|
|
case 'install':
|
|
|
if (!$module) {
|
|
if (!$module) {
|
|
@@ -101,7 +102,7 @@ class ExtensionManagementCommand extends Command
|
|
|
return self::FAILURE;
|
|
return self::FAILURE;
|
|
|
}
|
|
}
|
|
|
$extensionManager->install($module);
|
|
$extensionManager->install($module);
|
|
|
- $output->warning("扩展 {$module} 安装成功");
|
|
|
|
|
|
|
+ $output->warning("扩展 $module 安装成功");
|
|
|
break;
|
|
break;
|
|
|
case 'enable':
|
|
case 'enable':
|
|
|
if (!$module) {
|
|
if (!$module) {
|
|
@@ -109,7 +110,7 @@ class ExtensionManagementCommand extends Command
|
|
|
return self::FAILURE;
|
|
return self::FAILURE;
|
|
|
}
|
|
}
|
|
|
$extensionManager->enable($module);
|
|
$extensionManager->enable($module);
|
|
|
- $output->warning("扩展 {$module} 启用成功");
|
|
|
|
|
|
|
+ $output->warning("扩展 $module 启用成功");
|
|
|
break;
|
|
break;
|
|
|
case 'disable':
|
|
case 'disable':
|
|
|
if (!$module) {
|
|
if (!$module) {
|
|
@@ -117,7 +118,7 @@ class ExtensionManagementCommand extends Command
|
|
|
return self::FAILURE;
|
|
return self::FAILURE;
|
|
|
}
|
|
}
|
|
|
$extensionManager->disable($module);
|
|
$extensionManager->disable($module);
|
|
|
- $output->warning("扩展 {$module} 禁用成功");
|
|
|
|
|
|
|
+ $output->warning("扩展 $module 禁用成功");
|
|
|
break;
|
|
break;
|
|
|
case 'uninstall':
|
|
case 'uninstall':
|
|
|
if (!$module) {
|
|
if (!$module) {
|
|
@@ -125,7 +126,7 @@ class ExtensionManagementCommand extends Command
|
|
|
return self::FAILURE;
|
|
return self::FAILURE;
|
|
|
}
|
|
}
|
|
|
$extensionManager->uninstall($module);
|
|
$extensionManager->uninstall($module);
|
|
|
- $output->warning("扩展 {$module} 卸载成功");
|
|
|
|
|
|
|
+ $output->warning("扩展 $module 卸载成功");
|
|
|
break;
|
|
break;
|
|
|
default:
|
|
default:
|
|
|
$output->error('不支持的操作类型: ' . $action);
|
|
$output->error('不支持的操作类型: ' . $action);
|