|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Onigoetz\Deployer; |
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\Support\ServiceProvider; |
|
6
|
|
|
use Onigoetz\Deployer\Command\DeployCommand; |
|
7
|
|
|
use Onigoetz\Deployer\Command\RollbackCommand; |
|
8
|
|
|
use Onigoetz\Deployer\Configuration\ConfigurationManager; |
|
9
|
|
|
|
|
10
|
|
|
class DeployServiceProvider extends ServiceProvider |
|
11
|
|
|
{ |
|
12
|
|
|
/** |
|
13
|
|
|
* Indicates if loading of the provider is deferred. |
|
14
|
|
|
* |
|
15
|
|
|
* @var bool |
|
16
|
|
|
*/ |
|
17
|
|
|
protected $defer = true; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* {@inheritdoc} |
|
21
|
|
|
*/ |
|
22
|
|
|
public function boot() |
|
23
|
|
|
{ |
|
24
|
|
|
$files = ['directories', 'environments', 'servers', 'sources', 'tasks']; |
|
25
|
|
|
|
|
26
|
|
|
$configPath = __DIR__ . '/config/'; |
|
27
|
|
|
$publishes = []; |
|
28
|
|
|
foreach ($files as $file) { |
|
29
|
|
|
$publishes["$configPath/$file.php"] = config_path("deployer/$file.php"); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
$this->publishes($publishes); |
|
33
|
|
|
|
|
34
|
|
|
foreach ($files as $file) { |
|
35
|
|
|
$this->mergeConfigFrom("$configPath/$file.php", "deployer.$file"); |
|
36
|
|
|
} |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* Register the service provider. |
|
41
|
|
|
* |
|
42
|
|
|
* @return void |
|
43
|
|
|
*/ |
|
44
|
|
|
public function register() |
|
45
|
|
|
{ |
|
46
|
|
|
$this->app['deployer.configuration'] = $this->app->share( |
|
47
|
|
|
function ($app) { |
|
48
|
|
|
$configuration = [ |
|
49
|
|
|
'directories' => $app['config']['deployer.directories'], |
|
50
|
|
|
'servers' => $app['config']['deployer.servers'], |
|
51
|
|
|
'sources' => $app['config']['deployer.sources'], |
|
52
|
|
|
'tasks' => $app['config']['deployer.tasks'], |
|
53
|
|
|
'environments' => $app['config']['deployer.environments'], |
|
54
|
|
|
]; |
|
55
|
|
|
|
|
56
|
|
|
return ConfigurationManager::create($configuration); |
|
57
|
|
|
} |
|
58
|
|
|
); |
|
59
|
|
|
|
|
60
|
|
|
$this->app['command.deployer.deploy'] = $this->app->share( |
|
|
|
|
|
|
61
|
|
|
function ($app) { |
|
62
|
|
|
return new DeployCommand($app['deployer.configuration']); |
|
63
|
|
|
} |
|
64
|
|
|
); |
|
65
|
|
|
|
|
66
|
|
|
$this->app['command.deployer.rollback'] = $this->app->share( |
|
|
|
|
|
|
67
|
|
|
function ($app) { |
|
68
|
|
|
return new RollbackCommand($app['deployer.configuration']); |
|
69
|
|
|
} |
|
70
|
|
|
); |
|
71
|
|
|
|
|
72
|
|
|
$this->commands('command.deployer.deploy', 'command.deployer.rollback'); |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* Get the services provided by the provider. |
|
77
|
|
|
* |
|
78
|
|
|
* @return string[] |
|
79
|
|
|
*/ |
|
80
|
|
|
public function provides() |
|
81
|
|
|
{ |
|
82
|
|
|
return ['command.deployer.deploy', 'command.deployer.rollback']; |
|
83
|
|
|
} |
|
84
|
|
|
} |
|
85
|
|
|
|
Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.