1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Commands; |
4
|
|
|
|
5
|
|
|
use App\Providers\AppServiceProvider; |
6
|
|
|
use App\Support\Database\Database; |
7
|
|
|
|
8
|
|
|
class Begin extends BaseCommand |
9
|
|
|
{ |
10
|
|
|
/** |
11
|
|
|
* The signature of the command. |
12
|
|
|
* |
13
|
|
|
* @var string |
14
|
|
|
*/ |
15
|
|
|
protected $signature = 'begin {home?} {--force}'; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* The description of the command. |
19
|
|
|
* |
20
|
|
|
* @var string |
21
|
|
|
*/ |
22
|
|
|
protected $description = 'Run initial seeders and set up'; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Execute the console command. |
26
|
|
|
* |
27
|
|
|
* @return void |
28
|
|
|
*/ |
29
|
|
|
public function handle(): void |
30
|
|
|
{ |
31
|
|
|
$force = $this->option('force'); |
32
|
|
|
$home = realpath($this->argument('home') ?: $this->cli->currentWorkingDirectory()); |
|
|
|
|
33
|
|
|
|
34
|
|
|
if (! $force && Database::exists()) { |
35
|
|
|
$this->error("Already began, so we've stopped to avoid wiping your settings."); |
36
|
|
|
$this->error("If you definitely want to continue, you can force with the --force flag."); |
37
|
|
|
return; |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
$this->line("================"); |
41
|
|
|
$this->line("PREPARING PORTER"); |
42
|
|
|
$this->line("================"); |
43
|
|
|
$this->line(""); |
44
|
|
|
|
45
|
|
|
if (! file_exists(config('porter.library_path'))) { |
46
|
|
|
mkdir(config('porter.library_path')); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
$this->callSilent('vendor:publish', ['--provider' => AppServiceProvider::class]); |
50
|
|
|
|
51
|
|
|
Database::ensureExists($force); |
|
|
|
|
52
|
|
|
|
53
|
|
|
$this->info("Your Porter settings are stored in ".config('porter.library_path')); |
54
|
|
|
$this->info(""); |
55
|
|
|
|
56
|
|
|
$this->callSilent('home', ['path' => $home]); |
57
|
|
|
|
58
|
|
|
$this->info("Setting home to {$home}."); |
59
|
|
|
$this->comment("This is the used as the root directory for your sites."); |
60
|
|
|
$this->comment("If this is incorrect, you can change it using the 'porter home' command."); |
61
|
|
|
$this->comment(""); |
62
|
|
|
|
63
|
|
|
$this->info("Retrieving docker images"); |
64
|
|
|
$this->porter->pullImages(); |
65
|
|
|
} |
66
|
|
|
} |
67
|
|
|
|