1 | <?php |
||
20 | * |
||
21 | * Originally from https://github.com/XploreNet/silverstripe-composerupdates |
||
22 | * |
||
23 | * @author Matt Dwen |
||
24 | * @license MIT |
||
25 | */ |
||
26 | class CheckComposerUpdatesTask extends BuildTask |
||
27 | { |
||
28 | /** |
||
29 | * @var string |
||
30 | */ |
||
31 | protected $title = 'Composer update checker'; |
||
32 | |||
33 | /** |
||
34 | * @var string |
||
35 | */ |
||
36 | protected $description = 'Checks if any composer dependencies can be updated.'; |
||
37 | |||
38 | private static $segment = "CheckComposerUpdates"; |
||
39 | |||
40 | private static $dependencies = [ |
||
41 | 'ComposerLoader' => '%$BringYourOwnIdeas\\Maintenance\\Util\\ComposerLoader', |
||
42 | 'UpdateChecker' => '%$BringYourOwnIdeas\\UpdateChecker\\UpdateChecker', |
||
43 | ]; |
||
44 | |||
45 | /** |
||
46 | * @var ComposerLoader |
||
47 | */ |
||
48 | protected $composerLoader; |
||
49 | |||
50 | /** |
||
51 | * @var UpdateChecker |
||
52 | */ |
||
53 | protected $updateChecker; |
||
54 | |||
55 | /** |
||
56 | * Runs the actual steps to verify if there are updates available |
||
57 | * |
||
58 | * @param HTTPRequest $request |
||
59 | */ |
||
60 | public function run($request) |
||
74 | |||
75 | /** |
||
76 | * Retrieve an array of primary composer dependencies from composer.json. |
||
77 | * |
||
78 | * Packages are filtered by allowed type. |
||
79 | * |
||
80 | * @return array[] |
||
81 | */ |
||
82 | protected function getPackages() |
||
109 | |||
110 | /** |
||
111 | * Find all dependency constraints for the given package in the current repository and return the strictest one |
||
112 | * |
||
113 | * @param BaseRepository $repository |
||
114 | * @param string $packageName |
||
115 | * @return string |
||
116 | */ |
||
117 | protected function getInstalledConstraint(BaseRepository $repository, $packageName) |
||
130 | |||
131 | /** |
||
132 | * Check whether the package type is "allowed", which will include it in reports. If the type is not allowed |
||
133 | * then the package will be skipped. |
||
134 | * |
||
135 | * @param string $type |
||
136 | * @return bool |
||
137 | */ |
||
138 | protected function isAllowedType($type) |
||
144 | |||
145 | /** |
||
146 | * prints a message during the run of the task |
||
147 | * |
||
148 | * @param string $text |
||
149 | */ |
||
150 | protected function message($text) |
||
158 | |||
159 | /** |
||
160 | * @param ComposerLoader $composerLoader |
||
161 | * @return $this |
||
162 | */ |
||
163 | public function setComposerLoader(ComposerLoader $composerLoader) |
||
168 | |||
169 | /** |
||
170 | * @return ComposerLoader |
||
171 | */ |
||
172 | public function getComposerLoader() |
||
176 | |||
177 | /** |
||
178 | * @param UpdateChecker $updateChecker |
||
179 | * @return $this |
||
180 | */ |
||
181 | public function setUpdateChecker(UpdateChecker $updateChecker) |
||
186 | |||
187 | /** |
||
195 |