1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* SyncCommand.php |
4
|
|
|
* |
5
|
|
|
* @copyright More in license.md |
6
|
|
|
* @license http://www.ipublikuj.eu |
7
|
|
|
* @author Adam Kadlec http://www.ipublikuj.eu |
8
|
|
|
* @package iPublikuj:Packages! |
9
|
|
|
* @subpackage Commands |
10
|
|
|
* @since 2.0.0 |
11
|
|
|
* |
12
|
|
|
* @date 19.07.16 |
13
|
|
|
*/ |
14
|
|
|
|
15
|
|
|
declare(strict_types = 1); |
16
|
|
|
|
17
|
|
|
|
18
|
|
|
namespace IPub\Packages\Commands; |
19
|
|
|
|
20
|
|
|
use Symfony\Component\Console\Input; |
21
|
|
|
use Symfony\Component\Console\Output; |
22
|
|
|
|
23
|
|
|
use IPub; |
24
|
|
|
use IPub\Packages; |
25
|
|
|
use IPub\Packages\DependencyResolver; |
26
|
|
|
use IPub\Packages\Exceptions; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Synchronize packages command |
30
|
|
|
* |
31
|
|
|
* @package iPublikuj:Packages! |
32
|
|
|
* @subpackage Commands |
33
|
|
|
* |
34
|
|
|
* @author Josef Kříž <[email protected]> |
35
|
|
|
* @author Adam Kadlec <[email protected]> |
36
|
|
|
*/ |
37
|
|
|
class SyncCommand extends Command |
38
|
|
|
{ |
39
|
|
|
/** |
40
|
|
|
* @return void |
41
|
|
|
*/ |
42
|
|
|
protected function configure() |
43
|
|
|
{ |
44
|
|
|
$this |
45
|
|
|
->setName('ipub:packages:sync') |
46
|
|
|
->addOption('composer', NULL, Input\InputOption::VALUE_NONE, 'run as composer script') |
47
|
|
|
->setDescription('Synchronize packages.'); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @param Input\InputInterface $input |
52
|
|
|
* @param Output\OutputInterface $output |
53
|
|
|
* |
54
|
|
|
* @return void |
55
|
|
|
*/ |
56
|
|
|
protected function execute(Input\InputInterface $input, Output\OutputInterface $output) |
57
|
|
|
{ |
58
|
|
|
if ($input->getOption('composer')) { |
59
|
|
|
$output->writeln('+---------------------------------+'); |
60
|
|
|
$output->writeln('| Package manager synchronization |'); |
61
|
|
|
$output->writeln('+---------------------------------+'); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
// Register available |
65
|
|
|
foreach ($this->packageManager->registerAvailable() as $item) { |
66
|
|
|
foreach ($item as $name => $action) { |
|
|
|
|
67
|
|
|
$output->writeln(sprintf('<info>%s : %s</info>', $action, $name)); |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
try { |
72
|
|
|
foreach ($this->packageManager->enableAvailable() as $item) { |
73
|
|
|
foreach ($item as $name => $action) { |
|
|
|
|
74
|
|
|
$output->writeln(sprintf('<info>%s : %s</info>', $action, $name)); |
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
foreach ($this->packageManager->disableAbsent() as $item) { |
79
|
|
|
foreach ($item as $name => $action) { |
|
|
|
|
80
|
|
|
$output->writeln(sprintf('<info>%s : %s</info>', $action, $name)); |
81
|
|
|
} |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
} catch (Exceptions\InvalidArgumentException $e) { |
85
|
|
|
$output->writeln(sprintf('<error>%s</error>', $e->getMessage())); |
86
|
|
|
} |
87
|
|
|
} |
88
|
|
|
} |
89
|
|
|
|