This repository was archived by the owner on Nov 23, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 282
Expand file tree
/
Copy pathInstall.php
More file actions
123 lines (103 loc) · 3.69 KB
/
Copy pathInstall.php
File metadata and controls
123 lines (103 loc) · 3.69 KB
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<?php
namespace Backpack\Base\app\Console\Commands;
use Illuminate\Console\Command;
use Symfony\Component\Process\Exception\ProcessFailedException;
use Symfony\Component\Process\Process;
class Install extends Command
{
protected $progressBar;
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'backpack:base:install
{--timeout=300} : How many seconds to allow each process to run.
{--debug} : Show process output or not. Useful for debugging.';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Require dev packages and publish files for Backpack\Base to work';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$this->progressBar = $this->output->createProgressBar(6);
$this->progressBar->start();
$this->info(" Backpack\Base installation started. Please wait...");
$this->progressBar->advance();
$this->line(' Installing backpack/generators');
$this->executeProcess('composer require backpack/generators --dev');
$this->line(' Installing laracasts/generators');
$this->executeProcess('composer require laracasts/generators:dev-master --dev');
$this->line(' Publishing configs, langs, views and AdminLTE files');
$this->executeProcess('php artisan vendor:publish --provider="Backpack\Base\BaseServiceProvider" --tag=minimum');
$this->line(' Publishing config for notifications - prologue/alerts');
$this->executeProcess('php artisan vendor:publish --provider="Prologue\Alerts\AlertsServiceProvider"');
$this->line(" Generating users table (using Laravel's default migrations)");
$this->executeProcess('php artisan migrate');
$this->progressBar->finish();
$this->info(" Backpack\Base installation finished.");
}
/**
* Run a SSH command.
*
* @param string $command The SSH command that needs to be run
* @param bool $beforeNotice Information for the user before the command is run
* @param bool $afterNotice Information for the user after the command is run
*
* @return mixed Command-line output
*/
public function executeProcess($command, $beforeNotice = false, $afterNotice = false)
{
$this->echo('info', $beforeNotice ? ' '.$beforeNotice : $command);
$process = new Process($command, null, null, null, $this->option('timeout'), null);
$process->run(function ($type, $buffer) {
if (Process::ERR === $type) {
$this->echo('comment', $buffer);
} else {
$this->echo('line', $buffer);
}
});
// executes after the command finishes
if (!$process->isSuccessful()) {
throw new ProcessFailedException($process);
}
if ($this->progressBar) {
$this->progressBar->advance();
}
if ($afterNotice) {
$this->echo('info', $afterNotice);
}
}
/**
* Write text to the screen for the user to see.
*
* @param [string] $type line, info, comment, question, error
* @param [string] $content
*/
public function echo($type, $content)
{
if ($this->option('debug') == false) {
return;
}
// skip empty lines
if (trim($content)) {
$this->{$type}($content);
}
}
}