1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Acacha\AdminLTETemplateLaravel\Console; |
4
|
|
|
|
5
|
|
|
use Acacha\AdminLTETemplateLaravel\Console\Traits\UseComposer; |
6
|
|
|
use Symfony\Component\Console\Command\Command; |
7
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
8
|
|
|
use Symfony\Component\Console\Input\InputOption; |
9
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
10
|
|
|
use Symfony\Component\Process\Process; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Class InstallCommand. |
14
|
|
|
*/ |
15
|
|
|
class InstallCommand extends Command |
16
|
|
|
{ |
17
|
|
|
use UseComposer; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Get package name to install. |
21
|
|
|
*/ |
22
|
|
|
protected function getPackageName() |
23
|
|
|
{ |
24
|
|
|
return 'acacha/admin-lte-template-laravel'; |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Configure the command options. |
29
|
|
|
*/ |
30
|
|
|
protected function configure() |
31
|
|
|
{ |
32
|
|
|
$this->ignoreValidationErrors(); |
33
|
|
|
|
34
|
|
|
$this->setName('install') |
35
|
|
|
->setDescription('Install Acacha AdminLTE Laravel package into the current project.') |
36
|
|
|
->addOption( |
37
|
|
|
'dev', |
38
|
|
|
'-d', |
39
|
|
|
InputOption::VALUE_NONE, |
40
|
|
|
'Installs the latest "development" release' |
41
|
|
|
) |
42
|
|
|
->addOption( |
43
|
|
|
'dontforce', |
44
|
|
|
'-F', |
45
|
|
|
InputOption::VALUE_NONE, |
46
|
|
|
'Do not force overwrite of files during publish' |
47
|
|
|
); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* Execute the command. |
52
|
|
|
* |
53
|
|
|
* @param InputInterface $input |
54
|
|
|
* @param OutputInterface $output |
55
|
|
|
* |
56
|
|
|
* @return void |
57
|
|
|
*/ |
58
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
59
|
|
|
{ |
60
|
|
|
$composer = $this->findComposer(); |
61
|
|
|
|
62
|
|
|
$commands = [ |
63
|
|
|
$composer.' require '. $this->getPackageName().$this->getDevSuffix($input), |
64
|
|
|
$composer.' require --dev laravel/dusk' |
65
|
|
|
]; |
66
|
|
|
|
67
|
|
|
if ($input->getOption('no-ansi')) { |
68
|
|
|
$commands = array_map(function ($value) { |
69
|
|
|
return $value.' --no-ansi'; |
70
|
|
|
}, $commands); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
$force = $input->getOption('dontforce') ? '' : ' --force'; |
74
|
|
|
$commands = array_merge($commands, [ |
75
|
|
|
'php artisan dusk:install', |
76
|
|
|
'php artisan adminlte:publish' . $force |
77
|
|
|
]); |
78
|
|
|
|
79
|
|
|
$process = new Process( |
80
|
|
|
$runningCommand = implode(' && ', $commands), |
81
|
|
|
null, |
82
|
|
|
null, |
83
|
|
|
null, |
84
|
|
|
null |
85
|
|
|
); |
86
|
|
|
|
87
|
|
|
if ('\\' !== DIRECTORY_SEPARATOR && file_exists('/dev/tty') && is_readable('/dev/tty')) { |
88
|
|
|
$process->setTty(true); |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
$output->writeln('<info>Running '. $runningCommand.'</info>'); |
92
|
|
|
$process->run(function ($type, $line) use ($output) { |
93
|
|
|
$output->write($line); |
94
|
|
|
}); |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* Gets dev suffix. |
99
|
|
|
* |
100
|
|
|
* @param InputInterface $input |
101
|
|
|
* |
102
|
|
|
* @return string |
103
|
|
|
*/ |
104
|
|
|
private function getDevSuffix(InputInterface $input) |
105
|
|
|
{ |
106
|
|
|
return $input->getOption('dev') ? ':dev-master' : ''; |
107
|
|
|
} |
108
|
|
|
} |
109
|
|
|
|