Skip to content

Commit d23f28d

Browse files
authored
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
1 parent 960ecf7 commit d23f28d

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/Command/CreateCommand.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
namespace Mine\AppStore\Command;
1414

15+
use Hyperf\Codec\Json;
1516
use Hyperf\Command\Annotation\Command;
1617
use Hyperf\Stringable\Str;
1718
use Mine\AppStore\Enums\PluginTypeEnum;
@@ -73,7 +74,7 @@ public function createMineJson(string $path, string $name, PluginTypeEnum $plugi
7374
],
7475
];
7576
if ($pluginType === PluginTypeEnum::Backend || $pluginType === PluginTypeEnum::Mix) {
76-
$namespace = 'Plugin\\' . Str::studly($name);
77+
$namespace = 'Plugin\\' . ucwords(str_replace('/', '\\', Str::studly($name)));
7778

7879
$this->createInstallScript($namespace, $path);
7980
$this->createUninstallScript($namespace, $path);
@@ -82,7 +83,7 @@ public function createMineJson(string $path, string $name, PluginTypeEnum $plugi
8283
$output->composer = [
8384
'require' => [],
8485
'psr-4' => [
85-
$namespace . '\\' => 'src',
86+
'\\' . $namespace . '\\' => 'src',
8687
],
8788
'installScript' => $namespace . '\InstallScript',
8889
'uninstallScript' => $namespace . '\UninstallScript',
@@ -96,8 +97,7 @@ public function createMineJson(string $path, string $name, PluginTypeEnum $plugi
9697
],
9798
];
9899
}
99-
100-
$output = json_encode($output, \JSON_THROW_ON_ERROR | \JSON_PRETTY_PRINT | \JSON_UNESCAPED_UNICODE, 512);
100+
$output = Json::encode($output);
101101
file_put_contents($path . '/mine.json', $output);
102102
$this->output->success(\sprintf('%s 创建成功', $path . '/mine.json'));
103103
}

0 commit comments

Comments
 (0)