From 5a3afa371f0c4ec20b195accbb626a7484102831 Mon Sep 17 00:00:00 2001 From: panliang <1163816051@qq.com> Date: Wed, 27 Jul 2022 13:36:45 +0800 Subject: [PATCH] update command --- src/Console/ExtensionMakeCommand.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Console/ExtensionMakeCommand.php b/src/Console/ExtensionMakeCommand.php index 03bf4e3..b5bab4c 100644 --- a/src/Console/ExtensionMakeCommand.php +++ b/src/Console/ExtensionMakeCommand.php @@ -14,8 +14,8 @@ class ExtensionMakeCommand extends Command * * @var string */ - protected $signature = 'admin:ext-make - {name : The name of the extension. Eg: author-name/extension-name} + protected $signature = 'admin:ext-make + {name : The name of the extension. Eg: author-name/extension-name} {--namespace= : The namespace of the extension.} {--theme} '; @@ -97,11 +97,12 @@ class ExtensionMakeCommand extends Command if (! file_exists($this->extensionDir)) { $this->makeDir(); } + $name = $this->argument('name'); - $this->package = str_replace('.', '/', $this->argument('name')); + $this->package = str_replace('.', '/', 'Peidikeji/'.ucfirst($name)); $this->extensionName = str_replace('/', '.', $this->package); - $this->basePath = rtrim($this->extensionDir, '/').'/'.ltrim($this->package, '/'); + $this->basePath = rtrim($this->extensionDir, '/').'/'.ltrim(strtolower($name), '/'); if (is_dir($this->basePath)) { return $this->error(sprintf('The extension [%s] already exists!', $this->package)); @@ -188,7 +189,7 @@ TREE; // make composer.json $composerContents = str_replace( ['{package}', '{alias}', '{namespace}', '{className}'], - [$this->package, '', str_replace('\\', '\\\\', $this->namespace).'\\\\', $this->className], + [strtolower($this->package), strtolower($this->className), str_replace('\\', '\\\\', $this->namespace).'\\\\', $this->className], file_get_contents(__DIR__.'/stubs/extension/composer.json.stub') ); $this->putFile('composer.json', $composerContents);