|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* Composer plugin for HiDev |
|
5
|
|
|
* |
|
6
|
|
|
* @link https://github.com/hiqdev/hidev-composer |
|
7
|
|
|
* @package hidev-composer |
|
8
|
|
|
* @license BSD-3-Clause |
|
9
|
|
|
* @copyright Copyright (c) 2015-2016, HiQDev (http://hiqdev.com/) |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace hidev\composer\console; |
|
13
|
|
|
|
|
14
|
|
|
use Yii; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* Composer. |
|
18
|
|
|
* @author Andrii Vasyliev <[email protected]> |
|
19
|
|
|
*/ |
|
20
|
|
|
class ComposerController extends \hidev\base\Controller |
|
21
|
|
|
{ |
|
22
|
|
|
protected $_before = ['composer.json']; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* Does `composer install` |
|
26
|
|
|
*/ |
|
27
|
|
|
public function actionIndex() |
|
28
|
|
|
{ |
|
29
|
|
|
return $this->doInstall(); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* Does `composer install` |
|
34
|
|
|
*/ |
|
35
|
|
|
public function actionInstall() |
|
36
|
|
|
{ |
|
37
|
|
|
return $this->doInstall(); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* Does `composer install` |
|
42
|
|
|
*/ |
|
43
|
|
|
public function actionUpdate() |
|
44
|
|
|
{ |
|
45
|
|
|
return $this->doUpdate(); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* Does `composer self-update` |
|
50
|
|
|
*/ |
|
51
|
|
|
public function actionSelfUpdate($version = null) |
|
|
|
|
|
|
52
|
|
|
{ |
|
53
|
|
|
return $this->run('self-update', ''); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
public function doInstall() |
|
57
|
|
|
{ |
|
58
|
|
|
$dir = Yii::getAlias('@root/vendor'); |
|
59
|
|
|
|
|
60
|
|
|
return is_dir($dir) ? 0 : $this->run('install'); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
public function doUpdate() |
|
64
|
|
|
{ |
|
65
|
|
|
return $this->run('update'); |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
public function run($command, $dir = null) |
|
69
|
|
|
{ |
|
70
|
|
|
if ($dir === null) { |
|
71
|
|
|
$dir = Yii::getAlias('@root'); |
|
72
|
|
|
} |
|
73
|
|
|
$args = [$command, '--ansi']; |
|
74
|
|
|
if ($dir && $dir !== getcwd()) { |
|
75
|
|
|
$args[] = '-d'; |
|
76
|
|
|
$args[] = $dir; |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
return $this->passthru('composer', $args); |
|
80
|
|
|
} |
|
81
|
|
|
} |
|
82
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.