Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions src/BlueprintServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -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',
]);
}

Expand Down
16 changes: 15 additions & 1 deletion src/Commands/NewCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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');
Expand Down
27 changes: 27 additions & 0 deletions src/Commands/PublishStubsCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace Blueprint\Commands;

use Illuminate\Console\Command;

class PublishStubsCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'blueprint:stubs';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Publish blueprint stubs';

public function handle()
{
return $this->call('vendor:publish', ['--tag' => 'blueprint-stubs']);
}
}