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

@ -97,11 +97,12 @@ class ExtensionMakeCommand extends Command
if (! file_exists($this->extensionDir)) { if (! file_exists($this->extensionDir)) {
$this->makeDir(); $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->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)) { if (is_dir($this->basePath)) {
return $this->error(sprintf('The extension [%s] already exists!', $this->package)); return $this->error(sprintf('The extension [%s] already exists!', $this->package));
@ -188,7 +189,7 @@ TREE;
// make composer.json // make composer.json
$composerContents = str_replace( $composerContents = str_replace(
['{package}', '{alias}', '{namespace}', '{className}'], ['{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') file_get_contents(__DIR__.'/stubs/extension/composer.json.stub')
); );
$this->putFile('composer.json', $composerContents); $this->putFile('composer.json', $composerContents);