diff --git a/src/ArtisanDevCommandsServiceProvider.php b/src/ArtisanDevCommandsServiceProvider.php index b077d40..19f472f 100644 --- a/src/ArtisanDevCommandsServiceProvider.php +++ b/src/ArtisanDevCommandsServiceProvider.php @@ -30,5 +30,9 @@ public function boot() Commands\MakeTrait::class, Commands\MakeVueComponent::class, ]); + + $this->publishes([ + __DIR__.'/Stubs/' => base_path('stubs/dev_commands') + ], 'stubs'); } } diff --git a/src/Commands/MakePage.php b/src/Commands/MakePage.php index a0039fe..686d0e9 100644 --- a/src/Commands/MakePage.php +++ b/src/Commands/MakePage.php @@ -47,12 +47,13 @@ public function handle() // Get the stub file for the generator. protected function getStub() { - if($this->option('optionsApi')) + $stubName = $this->option('optionsApi') ? 'PageStub-Options.stub' : 'PageStub-Setup.stub'; + + if(file_exists(base_path('stubs/dev_commands/'.$stubName))) { - $this->line('options api'); - return base_path('vendor/butcherman/artisan-dev-commands/src/Stubs/PageStub-Options.stub'); + return base_path('stubs/dev_commands/'.$stubName); } - return base_path('vendor/butcherman/artisan-dev-commands/src/Stubs/PageStub-Setup.stub'); + return base_path('vendor/butcherman/artisan-dev-commands/src/Stubs/'.$stubName); } } diff --git a/src/Commands/MakeTrait.php b/src/Commands/MakeTrait.php index 6a523bb..262d604 100644 --- a/src/Commands/MakeTrait.php +++ b/src/Commands/MakeTrait.php @@ -56,6 +56,11 @@ protected function getStubVariables($traitName) // Get the stub file for the generator. protected function getStub() { + if(file_exists(base_path('stubs/dev_commands/TraitStub.stub'))) + { + return base_path('stubs/dev_commands/TraitStub.stub'); + } + return base_path('vendor/butcherman/artisan-dev-commands/src/Stubs/TraitStub.stub'); } diff --git a/src/Commands/MakeVueComponent.php b/src/Commands/MakeVueComponent.php index ed83640..daba27f 100644 --- a/src/Commands/MakeVueComponent.php +++ b/src/Commands/MakeVueComponent.php @@ -47,12 +47,13 @@ public function handle() // Get the stub file for the generator. protected function getStub() { - if($this->option('optionsApi')) + $stubName = $this->option('optionsApi') ? 'ComponentStub-Options.stub' : 'ComponentStub-Setup.stub'; + + if(file_exists(base_path('stubs/dev_commands/'.$stubName))) { - $this->line('options api'); - return base_path('vendor/butcherman/artisan-dev-commands/src/Stubs/ComponentStub-Options.stub'); + return base_path('stubs/dev_commands/'.$stubName); } - return base_path('vendor/butcherman/artisan-dev-commands/src/Stubs/ComponentStub-Setup.stub'); + return base_path('vendor/butcherman/artisan-dev-commands/src/Stubs/'.$stubName); } }