|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of Bowerphp. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Massimiliano Arione <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace Bowerphp\Command; |
|
13
|
|
|
|
|
14
|
|
|
use Bowerphp\Installer\Installer; |
|
15
|
|
|
use Bowerphp\Package\Package; |
|
16
|
|
|
use Bowerphp\Util\PackageNameVersionExtractor; |
|
17
|
|
|
use Bowerphp\Util\ZipArchive; |
|
18
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
|
19
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
20
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* Uninstall |
|
24
|
|
|
*/ |
|
25
|
|
|
class UninstallCommand extends Command |
|
26
|
|
|
{ |
|
27
|
|
|
/** |
|
28
|
|
|
* {@inheritdoc} |
|
29
|
|
|
*/ |
|
30
|
|
|
protected function configure() |
|
31
|
|
|
{ |
|
32
|
|
|
$this |
|
33
|
|
|
->setName('uninstall') |
|
34
|
|
|
->setDescription('Uninstalls a single specified package') |
|
35
|
|
|
->addArgument('package', InputArgument::REQUIRED, 'Choose a package.') |
|
36
|
|
|
->setHelp(<<<EOT |
|
37
|
|
|
The <info>%command.name%</info> command uninstall a package. |
|
38
|
|
|
|
|
39
|
|
|
<info>php %command.full_name% packageName</info> |
|
40
|
|
|
EOT |
|
41
|
|
|
) |
|
42
|
|
|
; |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* {@inheritdoc} |
|
47
|
|
|
*/ |
|
48
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
|
49
|
|
|
{ |
|
50
|
|
|
$this->setGithubToken($output); |
|
51
|
|
|
|
|
52
|
|
|
$scripts = $this->config->getScripts(); |
|
53
|
|
|
foreach((array)$scripts['preuninstall'] as $script){ |
|
54
|
|
|
passthru($script); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
$packageName = $input->getArgument('package'); |
|
58
|
|
|
|
|
59
|
|
|
$bowerphp = $this->getBowerphp($output); |
|
60
|
|
|
|
|
61
|
|
|
try { |
|
62
|
|
|
$installer = new Installer($this->filesystem, new ZipArchive(), $this->config); |
|
63
|
|
|
|
|
64
|
|
|
$packageNameVersion = PackageNameVersionExtractor::fromString($packageName); |
|
65
|
|
|
|
|
66
|
|
|
$package = new Package($packageNameVersion->name, $packageNameVersion->version); |
|
67
|
|
|
$bowerphp->uninstallPackage($package, $installer); |
|
68
|
|
|
} catch (\RuntimeException $e) { |
|
69
|
|
|
$output->writeln(sprintf('<error>%s</error>', $e->getMessage())); |
|
70
|
|
|
|
|
71
|
|
|
return 1; |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
$output->writeln(''); |
|
75
|
|
|
} |
|
76
|
|
|
} |
|
77
|
|
|
|