-
Notifications
You must be signed in to change notification settings - Fork 488
/
Copy pathInstallCommand.php
62 lines (50 loc) · 1.65 KB
/
InstallCommand.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
namespace Laravel\Sail\Console;
use Illuminate\Console\Command;
use RuntimeException;
use Symfony\Component\Process\Process;
class InstallCommand extends Command
{
use Concerns\InteractsWithDockerComposeServices;
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'sail:install
{--with= : The services that should be included in the installation}
{--devcontainer : Create a .devcontainer configuration directory}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Install Laravel Sail\'s default Docker Compose file';
/**
* Execute the console command.
*
* @return int|null
*/
public function handle()
{
if ($this->option('with')) {
$services = $this->option('with') == 'none' ? [] : explode(',', $this->option('with'));
} elseif ($this->option('no-interaction')) {
$services = $this->defaultServices;
} else {
$services = $this->gatherServicesWithSymfonyMenu();
}
if ($invalidServices = array_diff($services, $this->services)) {
$this->error('Invalid services ['.implode(',', $invalidServices).'].');
return 1;
}
$this->buildDockerCompose($services);
$this->replaceEnvVariables($services);
$this->configurePhpUnit();
if ($this->option('devcontainer')) {
$this->installDevContainer();
}
$this->info('Sail scaffolding installed successfully.');
$this->prepareInstallation($services);
}
}