diff --git a/src/BlueprintServiceProvider.php b/src/BlueprintServiceProvider.php index 9a10b2b3..f088cd26 100644 --- a/src/BlueprintServiceProvider.php +++ b/src/BlueprintServiceProvider.php @@ -2,16 +2,14 @@ namespace Blueprint; -use Blueprint\Blueprint; -use Blueprint\Builder; use Blueprint\Commands\BuildCommand; use Blueprint\Commands\EraseCommand; -use Blueprint\Commands\NewCommand; use Blueprint\Commands\InitCommand; +use Blueprint\Commands\NewCommand; +use Blueprint\Commands\PublishStubsCommand; use Blueprint\Commands\TraceCommand; -use Blueprint\Contracts\Generator; -use Blueprint\FileMixins; -use Blueprint\Tracer; +use Illuminate\Console\Events\CommandFinished; +use Illuminate\Contracts\Console\Kernel; use Illuminate\Contracts\Support\DeferrableProvider; use Illuminate\Support\Facades\File; use Illuminate\Support\ServiceProvider; @@ -71,6 +69,9 @@ public function register() $this->app->bind('command.blueprint.init', function ($app) { return new InitCommand(); }); + $this->app->bind('command.blueprint.stubs', function ($app) { + return new PublishStubsCommand(); + }); $this->app->singleton(Blueprint::class, function ($app) { $blueprint = new Blueprint(); @@ -85,12 +86,19 @@ public function register() return $blueprint; }); + $this->app->make('events')->listen(CommandFinished::class, function ($event) { + if ($event->command == 'stub:publish') { + $this->app->make(Kernel::class)->queue('blueprint:stubs'); + } + }); + $this->commands([ 'command.blueprint.build', 'command.blueprint.erase', 'command.blueprint.trace', 'command.blueprint.new', 'command.blueprint.init', + 'command.blueprint.stubs', ]); } diff --git a/src/Commands/NewCommand.php b/src/Commands/NewCommand.php index 571bc41d..db72a2e4 100644 --- a/src/Commands/NewCommand.php +++ b/src/Commands/NewCommand.php @@ -12,7 +12,10 @@ class NewCommand extends Command * * @var string */ - protected $signature = 'blueprint:new'; + protected $signature = 'blueprint:new + {--c|config : Publish blueprint config } + {--s|stubs : Publish blueprint stubs } + '; /** * The console command description. @@ -40,6 +43,17 @@ public function handle() $this->filesystem->put('draft.yaml', $this->filesystem->stub('draft.stub')); $this->info('Created example draft.yaml'); + $this->newLine(); + } + + if ($this->option('config')) { + $this->call('vendor:publish', ['--tag' => 'blueprint-config']); + $this->newLine(); + } + + if ($this->option('stubs')) { + $this->call('vendor:publish', ['--tag' => 'blueprint-stubs']); + $this->newLine(); } return $this->call('blueprint:trace'); diff --git a/src/Commands/PublishStubsCommand.php b/src/Commands/PublishStubsCommand.php new file mode 100644 index 00000000..3a1e0211 --- /dev/null +++ b/src/Commands/PublishStubsCommand.php @@ -0,0 +1,27 @@ +call('vendor:publish', ['--tag' => 'blueprint-stubs']); + } +}