Added support for php dependencies in GPM blueprints

This commit is contained in:
Andy Miller
2018-02-16 18:16:07 -07:00
parent 79e580a79d
commit ccf0f9c74e
3 changed files with 20 additions and 5 deletions

View File

@@ -3,6 +3,7 @@
1. [](#new)
* Added `Grav\Framework\Uri` classes extending PSR-7 `HTTP message UriInterface` implementation
* Added ability to have `php` version dependencies in GPM assets
# v1.4.0-rc.2
## 02/15/2018

View File

@@ -719,8 +719,8 @@ class GPM extends Iterator
foreach ($packages as $package_name => $package) {
if (isset($package['dependencies'])) {
foreach ($package['dependencies'] as $dependency) {
if (is_array($dependency)) {
$dependency = array_keys($dependency)[0];
if (is_array($dependency) && isset($dependency['name'])) {
$dependency = $dependency['name'];
}
if ($dependency == $slug) {
@@ -835,6 +835,20 @@ class GPM extends Iterator
continue;
}
// Check PHP version
if ($dependency_slug == 'php') {
$current_php_version = phpversion();
if (version_compare($this->calculateVersionNumberFromDependencyVersion($dependencyVersionWithOperator),
$current_php_version) === 1
) {
//Needs a Grav update first
throw new \Exception("<red>One of the packages require PHP " . $dependencies['php'] . ". Please update PHP to resolve this");
} else {
unset($dependencies[$dependency_slug]);
continue;
}
}
//First, check for Grav dependency. If a dependency requires Grav > the current version, abort and tell.
if ($dependency_slug == 'grav') {
if (version_compare($this->calculateVersionNumberFromDependencyVersion($dependencyVersionWithOperator),
@@ -1062,9 +1076,9 @@ class GPM extends Iterator
} elseif ($version == '') {
return null;
} elseif ($this->versionFormatIsNextSignificantRelease($version)) {
return substr($version, 1);
return trim(substr($version, 1));
} elseif ($this->versionFormatIsEqualOrHigher($version)) {
return substr($version, 2);
return trim(substr($version, 2));
} else {
return $version;
}

View File

@@ -185,7 +185,7 @@ class UninstallCommand extends ConsoleCommand
if (is_array($dependency)) {
$dependency = $dependency['name'];
}
if ($dependency === 'grav') {
if ($dependency === 'grav' || $dependency === 'php') {
continue;
}