1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* Composer plugin for bower/npm assets |
5
|
|
|
* |
6
|
|
|
* @link https://github.com/hiqdev/composer-asset-plugin |
7
|
|
|
* @package composer-asset-plugin |
8
|
|
|
* @license BSD-3-Clause |
9
|
|
|
* @copyright Copyright (c) 2015-2016, HiQDev (http://hiqdev.com/) |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace hiqdev\composerassetplugin; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Bower package manager class. |
16
|
|
|
* |
17
|
|
|
* @author Andrii Vasyliev <[email protected]> |
18
|
|
|
*/ |
19
|
|
|
class Bower extends PackageManager |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* {@inheritdoc} |
23
|
|
|
*/ |
24
|
|
|
protected $name = 'bower'; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* {@inheritdoc} |
28
|
|
|
*/ |
29
|
|
|
public $file = 'bower.json'; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* {@inheritdoc} |
33
|
|
|
*/ |
34
|
|
|
public $rcfile = '.bowerrc'; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* {@inheritdoc} |
38
|
|
|
*/ |
39
|
|
|
public $phpPackage = 'beelab/bowerphp'; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* {@inheritdoc} |
43
|
|
|
*/ |
44
|
|
|
public $phpBin = 'bowerphp'; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @var array Minimal bower config |
48
|
|
|
*/ |
49
|
|
|
protected $config = [ |
50
|
|
|
'name' => 'composer-asset-plugin', |
51
|
|
|
'description' => "This file is auto-generated with 'hiqdev/composer-asset-plugin'.", |
52
|
|
|
]; |
53
|
|
|
|
54
|
|
|
public function setDestination($dir) |
55
|
|
|
{ |
56
|
|
|
if (substr($dir, 0, 7) === 'vendor/') { |
57
|
|
|
$dir = substr($dir, 7); |
58
|
|
|
} |
59
|
|
|
$this->rc['directory'] = $dir; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
public function writeRc($path, $data) { |
63
|
|
|
$this->writeJson($path, $data); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
public function fixConstraint($constraint) |
67
|
|
|
{ |
68
|
|
|
if (Constraint::isDisjunctive($constraint)) { |
69
|
|
|
$constraint = Constraint::findMax(explode('|', $constraint)); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
$pos = strpos($constraint, '@'); |
73
|
|
|
if ($pos !== false) { |
74
|
|
|
$constraint = substr($constraint, 0, $pos); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
return $constraint; |
78
|
|
|
} |
79
|
|
|
} |
80
|
|
|
|