Skip to content

Commit f9a4bbc

Browse files
authored
Add options to publish stubs + config (#530)
1 parent b6ffc81 commit f9a4bbc

File tree

3 files changed

+56
-7
lines changed

3 files changed

+56
-7
lines changed

src/BlueprintServiceProvider.php

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,14 @@
22

33
namespace Blueprint;
44

5-
use Blueprint\Blueprint;
6-
use Blueprint\Builder;
75
use Blueprint\Commands\BuildCommand;
86
use Blueprint\Commands\EraseCommand;
9-
use Blueprint\Commands\NewCommand;
107
use Blueprint\Commands\InitCommand;
8+
use Blueprint\Commands\NewCommand;
9+
use Blueprint\Commands\PublishStubsCommand;
1110
use Blueprint\Commands\TraceCommand;
12-
use Blueprint\Contracts\Generator;
13-
use Blueprint\FileMixins;
14-
use Blueprint\Tracer;
11+
use Illuminate\Console\Events\CommandFinished;
12+
use Illuminate\Contracts\Console\Kernel;
1513
use Illuminate\Contracts\Support\DeferrableProvider;
1614
use Illuminate\Support\Facades\File;
1715
use Illuminate\Support\ServiceProvider;
@@ -71,6 +69,9 @@ public function register()
7169
$this->app->bind('command.blueprint.init', function ($app) {
7270
return new InitCommand();
7371
});
72+
$this->app->bind('command.blueprint.stubs', function ($app) {
73+
return new PublishStubsCommand();
74+
});
7475

7576
$this->app->singleton(Blueprint::class, function ($app) {
7677
$blueprint = new Blueprint();
@@ -85,12 +86,19 @@ public function register()
8586
return $blueprint;
8687
});
8788

89+
$this->app->make('events')->listen(CommandFinished::class, function ($event) {
90+
if ($event->command == 'stub:publish') {
91+
$this->app->make(Kernel::class)->queue('blueprint:stubs');
92+
}
93+
});
94+
8895
$this->commands([
8996
'command.blueprint.build',
9097
'command.blueprint.erase',
9198
'command.blueprint.trace',
9299
'command.blueprint.new',
93100
'command.blueprint.init',
101+
'command.blueprint.stubs',
94102
]);
95103
}
96104

src/Commands/NewCommand.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ class NewCommand extends Command
1212
*
1313
* @var string
1414
*/
15-
protected $signature = 'blueprint:new';
15+
protected $signature = 'blueprint:new
16+
{--c|config : Publish blueprint config }
17+
{--s|stubs : Publish blueprint stubs }
18+
';
1619

1720
/**
1821
* The console command description.
@@ -40,6 +43,17 @@ public function handle()
4043
$this->filesystem->put('draft.yaml', $this->filesystem->stub('draft.stub'));
4144

4245
$this->info('Created example draft.yaml');
46+
$this->newLine();
47+
}
48+
49+
if ($this->option('config')) {
50+
$this->call('vendor:publish', ['--tag' => 'blueprint-config']);
51+
$this->newLine();
52+
}
53+
54+
if ($this->option('stubs')) {
55+
$this->call('vendor:publish', ['--tag' => 'blueprint-stubs']);
56+
$this->newLine();
4357
}
4458

4559
return $this->call('blueprint:trace');
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
namespace Blueprint\Commands;
4+
5+
use Illuminate\Console\Command;
6+
7+
class PublishStubsCommand extends Command
8+
{
9+
/**
10+
* The name and signature of the console command.
11+
*
12+
* @var string
13+
*/
14+
protected $signature = 'blueprint:stubs';
15+
16+
/**
17+
* The console command description.
18+
*
19+
* @var string
20+
*/
21+
protected $description = 'Publish blueprint stubs';
22+
23+
public function handle()
24+
{
25+
return $this->call('vendor:publish', ['--tag' => 'blueprint-stubs']);
26+
}
27+
}

0 commit comments

Comments
 (0)