-
-
Notifications
You must be signed in to change notification settings - Fork 238
/
Dependencies.php
54 lines (44 loc) · 1.69 KB
/
Dependencies.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
/**
* @file
* Contains \cweagans\Composer\Resolvers\Dependencies.
*/
namespace cweagans\Composer\Resolver;
use cweagans\Composer\Patch;
use cweagans\Composer\PatchCollection;
class Dependencies extends ResolverBase
{
/**
* {@inheritDoc}
*/
public function resolve(PatchCollection $collection): void
{
$locker = $this->composer->getLocker();
if (!$locker->isLocked()) {
$this->io->write(' - <info>Composer lock file does not exist.</info>');
$this->io->write(' - <info>Patches defined in dependencies will not be resolved.</info>');
return;
}
$this->io->write(' - <info>Resolving patches from dependencies.</info>');
$ignored_dependencies = $this->plugin->getConfig('ignore-dependency-patches');
$lockdata = $locker->getLockData();
foreach ($lockdata['packages'] as $p) {
// If we're supposed to skip gathering patches from a dependency, do that.
if (in_array($p['name'], $ignored_dependencies)) {
continue;
}
// Find patches in the composer.json for dependencies.
if (!isset($p['extra']) || !isset($p['extra']['patches'])) {
continue;
}
foreach ($this->findPatchesInJson($p['extra']['patches']) as $package => $patches) {
foreach ($patches as $patch) {
$patch->extra['provenance'] = "dependency:" . $package;
/** @var Patch $patch */
$collection->addPatch($patch);
}
}
// TODO: Also find patches in a configured patches.json for the dependency.
}
}
}