-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
Copy pathSetupProduction.php
82 lines (69 loc) · 2.58 KB
/
SetupProduction.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
namespace App\Console\Commands;
use function Safe\touch;
use App\Helpers\InstanceHelper;
use App\Models\Account\Account;
use Illuminate\Console\Command;
class SetupProduction extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'setup:production
{--force : Force the operation to run when in production.}
{--email= : Login email for the first account.}
{--password= : Password to set for the first account.}
{--skipSeed : Skip the populate database process.}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Perform setup of Monica.';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
if ((! $this->option('force')) && (! $this->confirm('You are about to setup and configure Monica. Do you wish to continue?'))) {
return;
}
/*
* If the .env file does not exist, then key generation
* will fail. So we create one if it does not already exist.
*/
if (! file_exists(__DIR__.'/../../../.env')) {
touch(__DIR__.'/../../../.env');
}
$this->call('monica:update', ['--force' => true]);
if (! $this->option('skipSeed')) {
$this->line('✓ Filling database');
$this->call('db:seed', ['--force' => true]);
}
$this->line('');
$this->line('-----------------------------');
$this->line('|');
$this->line('| Welcome to Monica v'.config('monica.app_version'));
$this->line('|');
$this->line('-----------------------------');
$email = $this->option('email');
$password = $this->option('password');
if (! empty($email) && ! empty($password)) {
Account::createDefault('John', 'Doe', $email, $password);
$this->info('| You can now sign in to your account:');
$this->line('| username: '.$email);
$this->line('| password: <hidden>');
} elseif (InstanceHelper::hasAtLeastOneAccount()) {
$this->info('| You can now log in to your account');
} else {
$this->info('| You can now register to the first account by opening the application:');
}
$this->line('| URL: '.config('app.url'));
$this->line('-----------------------------');
$this->info('Setup is done. Have fun.');
}
}