1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Backpack\CRUD\app\Console\Commands; |
4
|
|
|
|
5
|
|
|
use File; |
6
|
|
|
use Illuminate\Console\Command; |
7
|
|
|
use Symfony\Component\Process\Process; |
8
|
|
|
|
9
|
|
|
class RequireDevTools extends Command |
10
|
|
|
{ |
11
|
|
|
use \Backpack\CRUD\app\Console\Commands\Traits\PrettyCommandOutput; |
12
|
|
|
|
13
|
|
|
protected $progressBar; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* The name and signature of the console command. |
17
|
|
|
* |
18
|
|
|
* @var string |
19
|
|
|
*/ |
20
|
|
|
protected $signature = 'backpack:devtools:require |
21
|
|
|
{--debug} : Show process output or not. Useful for debugging.'; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* The console command description. |
25
|
|
|
* |
26
|
|
|
* @var string |
27
|
|
|
*/ |
28
|
|
|
protected $description = 'Install DevTools with its requirements on dev.'; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Execute the console command. |
32
|
|
|
* |
33
|
|
|
* @return mixed Command-line output |
34
|
|
|
*/ |
35
|
|
|
public function handle() |
36
|
|
|
{ |
37
|
|
|
$this->progressBar = $this->output->createProgressBar(15); |
38
|
|
|
$this->progressBar->minSecondsBetweenRedraws(0); |
39
|
|
|
$this->progressBar->maxSecondsBetweenRedraws(120); |
40
|
|
|
$this->progressBar->setRedrawFrequency(1); |
41
|
|
|
|
42
|
|
|
$this->progressBar->start(); |
43
|
|
|
|
44
|
|
|
$this->info(' DevTools installation started. Please wait...'); |
45
|
|
|
$this->progressBar->advance(); |
46
|
|
|
|
47
|
|
|
// Check if auth exists |
48
|
|
|
$details = null; |
49
|
|
|
$process = new Process(['composer', 'config', 'http-basic.backpackforlaravel.com']); |
50
|
|
|
$process->run(function ($type, $buffer) use (&$details) { |
51
|
|
|
if ($type !== Process::ERR && $buffer !== '') { |
52
|
|
|
$details = json_decode($buffer); |
53
|
|
|
} |
54
|
|
|
$this->progressBar->advance(); |
55
|
|
|
}); |
56
|
|
|
|
57
|
|
|
// Create an auth.json file |
58
|
|
|
if (! $details) { |
59
|
|
|
$this->info(' Creating auth.json file with DevTools auth details'); |
60
|
|
|
|
61
|
|
|
$this->line(' (Find your access token details on https://backpackforlaravel.com/user/tokens)'); |
62
|
|
|
$username = $this->ask('Access token username'); |
63
|
|
|
$password = $this->ask('Access token password'); |
64
|
|
|
|
65
|
|
|
$process = new Process(['composer', 'config', 'http-basic.backpackforlaravel.com', $username, $password]); |
66
|
|
|
$process->run(function ($type, $buffer) { |
|
|
|
|
67
|
|
|
if ($type === Process::ERR) { |
68
|
|
|
$this->error('Could not write to auth.json file.'); |
69
|
|
|
} |
70
|
|
|
$this->progressBar->advance(); |
71
|
|
|
}); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
// Require package |
75
|
|
|
$process = new Process(['composer', 'require', '--dev', 'backpack/devtools']); |
76
|
|
|
$process->run(function ($type, $buffer) { |
|
|
|
|
77
|
|
|
$this->progressBar->advance(); |
78
|
|
|
}); |
79
|
|
|
|
80
|
|
|
// Finish |
81
|
|
|
$this->progressBar->finish(); |
82
|
|
|
$this->info(' DevTools installation finished.'); |
83
|
|
|
|
84
|
|
|
// DevTools inside installer |
85
|
|
|
$this->info(''); |
86
|
|
|
$this->info(' DevTools requirements started. Please wait...'); |
87
|
|
|
$this->call('backpack:devtools:install'); |
88
|
|
|
} |
89
|
|
|
} |
90
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.