From 1ca8e1bcf2126919c09914510b00e9cf81cc89f3 Mon Sep 17 00:00:00 2001 From: lyan <49744633+zds-s@users.noreply.github.com> Date: Mon, 28 Oct 2024 22:03:24 +0800 Subject: [PATCH] fix(AppStore): correct namespace formatting and JSON encoding (#129) - Update namespace formatting for backend and mix plugins - Replace manual JSON encoding with Hyperf\Codec\Json::encode --- src/AppStore/src/Command/CreateCommand.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/AppStore/src/Command/CreateCommand.php b/src/AppStore/src/Command/CreateCommand.php index 27466ae..6d5cf75 100644 --- a/src/AppStore/src/Command/CreateCommand.php +++ b/src/AppStore/src/Command/CreateCommand.php @@ -12,6 +12,7 @@ namespace Mine\AppStore\Command; +use Hyperf\Codec\Json; use Hyperf\Command\Annotation\Command; use Hyperf\Stringable\Str; use Mine\AppStore\Enums\PluginTypeEnum; @@ -73,7 +74,7 @@ public function createMineJson(string $path, string $name, PluginTypeEnum $plugi ], ]; if ($pluginType === PluginTypeEnum::Backend || $pluginType === PluginTypeEnum::Mix) { - $namespace = 'Plugin\\' . Str::studly($name); + $namespace = 'Plugin\\' . ucwords(str_replace('/', '\\', Str::studly($name))); $this->createInstallScript($namespace, $path); $this->createUninstallScript($namespace, $path); @@ -82,7 +83,7 @@ public function createMineJson(string $path, string $name, PluginTypeEnum $plugi $output->composer = [ 'require' => [], 'psr-4' => [ - $namespace . '\\' => 'src', + '\\' . $namespace . '\\' => 'src', ], 'installScript' => $namespace . '\InstallScript', 'uninstallScript' => $namespace . '\UninstallScript', @@ -96,8 +97,7 @@ public function createMineJson(string $path, string $name, PluginTypeEnum $plugi ], ]; } - - $output = json_encode($output, \JSON_THROW_ON_ERROR | \JSON_PRETTY_PRINT | \JSON_UNESCAPED_UNICODE, 512); + $output = Json::encode($output); file_put_contents($path . '/mine.json', $output); $this->output->success(\sprintf('%s εˆ›ε»ΊζˆεŠŸ', $path . '/mine.json')); }