4
0
Fork 0

update command

master
panliang 2022-07-27 13:36:45 +08:00
parent fb88053b95
commit 5a3afa371f
1 changed files with 6 additions and 5 deletions

View File

@ -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);