Skip to content

Commit

Permalink
fix(AppStore): correct namespace formatting and JSON encoding (#129)
Browse files Browse the repository at this point in the history
- Update namespace formatting for backend and mix plugins
- Replace manual JSON encoding with Hyperf\Codec\Json::encode
  • Loading branch information
zds-s authored Oct 28, 2024
1 parent d650b74 commit 1ca8e1b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/AppStore/src/Command/CreateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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',
Expand All @@ -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'));
}
Expand Down

0 comments on commit 1ca8e1b

Please sign in to comment.