Issue #3284420 by longwave, Gábor Hojtsy, Spokje: Remove Composer 1 specific code paths from Drupal 10
(cherry picked from commit 6c6f6a3f31
)
merge-requests/1691/head
parent
f2639f9f77
commit
cec54c5a49
|
@ -681,10 +681,10 @@
|
|||
"dist": {
|
||||
"type": "path",
|
||||
"url": "composer/Plugin/ProjectMessage",
|
||||
"reference": "b4efdbe26634b41a1b89e4f3770a8074769088a6"
|
||||
"reference": "56ffb5a4a8cab53a97554862ce1003541af3438d"
|
||||
},
|
||||
"require": {
|
||||
"composer-plugin-api": "^1.1 || ^2",
|
||||
"composer-plugin-api": "^2",
|
||||
"php": ">=7.3.0"
|
||||
},
|
||||
"type": "composer-plugin",
|
||||
|
@ -714,10 +714,10 @@
|
|||
"dist": {
|
||||
"type": "path",
|
||||
"url": "composer/Plugin/VendorHardening",
|
||||
"reference": "d54f0b3cc8b4237f3a41a0860a808db242f9da9e"
|
||||
"reference": "db4c3ed9b83937aa292951593a8e35176ef5f907"
|
||||
},
|
||||
"require": {
|
||||
"composer-plugin-api": "^1.1 || ^2",
|
||||
"composer-plugin-api": "^2",
|
||||
"php": ">=7.3.0"
|
||||
},
|
||||
"type": "composer-plugin",
|
||||
|
|
|
@ -91,8 +91,8 @@ class Composer {
|
|||
public static function ensureComposerVersion(): void {
|
||||
$composerVersion = method_exists(ComposerApp::class, 'getVersion') ?
|
||||
ComposerApp::getVersion() : ComposerApp::VERSION;
|
||||
if (Comparator::lessThan($composerVersion, '1.9.0')) {
|
||||
throw new \RuntimeException("Drupal core development requires Composer 1.9.0, but Composer $composerVersion is installed. Please run 'composer self-update'.");
|
||||
if (Comparator::lessThan($composerVersion, '2.0.0')) {
|
||||
throw new \RuntimeException("Drupal core development requires Composer 2.0.0, but Composer $composerVersion is installed. Please run 'composer self-update'.");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,6 @@
|
|||
},
|
||||
"require": {
|
||||
"php": ">=7.3.0",
|
||||
"composer-plugin-api": "^1.1 || ^2"
|
||||
"composer-plugin-api": "^2"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
namespace Drupal\Composer\Plugin\Scaffold;
|
||||
|
||||
use Composer\Composer;
|
||||
use Composer\DependencyResolver\Operation\OperationInterface;
|
||||
use Composer\Installer\PackageEvent;
|
||||
use Composer\IO\IOInterface;
|
||||
use Composer\Package\PackageInterface;
|
||||
|
@ -101,8 +100,7 @@ class AllowedPackages implements PostPackageEventListenerInterface {
|
|||
// which of the newly-installed packages have scaffold operations, and
|
||||
// whether or not they are allowed to scaffold by the allowed-packages
|
||||
// option in the root-level composer.json file.
|
||||
$operationType = $this->getOperationType($operation);
|
||||
$package = $operationType === 'update' ? $operation->getTargetPackage() : $operation->getPackage();
|
||||
$package = $operation->getOperationType() === 'update' ? $operation->getTargetPackage() : $operation->getPackage();
|
||||
if (ScaffoldOptions::hasOptions($package->getExtra())) {
|
||||
$this->newPackages[$package->getName()] = $package;
|
||||
}
|
||||
|
@ -181,26 +179,6 @@ class AllowedPackages implements PostPackageEventListenerInterface {
|
|||
return $allowed_packages;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine the type of the provided operation.
|
||||
*
|
||||
* Adjusts API used for Composer 1 or Composer 2.
|
||||
*
|
||||
* @param \Composer\DependencyResolver\Operation\OperationInterface $operation
|
||||
* The operation object.
|
||||
*
|
||||
* @return string
|
||||
* The operation type.
|
||||
*/
|
||||
protected function getOperationType(OperationInterface $operation) {
|
||||
// Use Composer 2 method.
|
||||
if (method_exists($operation, 'getOperationType')) {
|
||||
return $operation->getOperationType();
|
||||
}
|
||||
// Fallback to Composer 1 method.
|
||||
return $operation->getJobType();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a package from the current composer process.
|
||||
*
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
"homepage": "https://www.drupal.org/project/drupal",
|
||||
"license": "GPL-2.0-or-later",
|
||||
"require": {
|
||||
"composer-plugin-api": "^1 || ^2",
|
||||
"composer-plugin-api": "^2",
|
||||
"php": ">=7.3.0"
|
||||
},
|
||||
"conflict": {
|
||||
|
|
|
@ -15,6 +15,6 @@
|
|||
},
|
||||
"require": {
|
||||
"php": ">=7.3.0",
|
||||
"composer-plugin-api": "^1.1 || ^2"
|
||||
"composer-plugin-api": "^2"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ class ComposerTest extends UnitTestCase {
|
|||
$this->assertNull(Composer::ensureComposerVersion());
|
||||
}
|
||||
catch (\RuntimeException $e) {
|
||||
$this->assertMatchesRegularExpression('/Drupal core development requires Composer 1.9.0, but Composer /', $e->getMessage());
|
||||
$this->assertMatchesRegularExpression('/Drupal core development requires Composer 2.0.0, but Composer /', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue