Add composer-runtime-api platform package
parent
0d1922dc27
commit
0ab48a1773
|
@ -55,6 +55,17 @@ class Composer
|
||||||
const RELEASE_DATE = '@release_date@';
|
const RELEASE_DATE = '@release_date@';
|
||||||
const SOURCE_VERSION = '2.0-dev+source';
|
const SOURCE_VERSION = '2.0-dev+source';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Version number of the internal composer-runtime-api package
|
||||||
|
*
|
||||||
|
* This is used to version features available to projects at runtime
|
||||||
|
* like the platform-check file, the Composer\InstalledVersions class
|
||||||
|
* and possibly others in the future.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
const RUNTIME_API_VERSION = '2.0.0';
|
||||||
|
|
||||||
public static function getVersion()
|
public static function getVersion()
|
||||||
{
|
{
|
||||||
// no replacement done, this must be a source checkout
|
// no replacement done, this must be a source checkout
|
||||||
|
|
|
@ -261,9 +261,9 @@ class Transaction
|
||||||
|
|
||||||
// is this a plugin or a dependency of a plugin?
|
// is this a plugin or a dependency of a plugin?
|
||||||
if ($isPlugin || count(array_intersect($package->getNames(), $pluginRequires))) {
|
if ($isPlugin || count(array_intersect($package->getNames(), $pluginRequires))) {
|
||||||
// get the package's requires, but filter out any platform requirements or 'composer-plugin-api'
|
// get the package's requires, but filter out any platform requirements
|
||||||
$requires = array_filter(array_keys($package->getRequires()), function ($req) {
|
$requires = array_filter(array_keys($package->getRequires()), function ($req) {
|
||||||
return $req !== 'composer-plugin-api' && !preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $req);
|
return !preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $req);
|
||||||
});
|
});
|
||||||
|
|
||||||
// is this a plugin with no meaningful dependencies?
|
// is this a plugin with no meaningful dependencies?
|
||||||
|
|
|
@ -25,6 +25,11 @@ interface PluginInterface
|
||||||
/**
|
/**
|
||||||
* Version number of the internal composer-plugin-api package
|
* Version number of the internal composer-plugin-api package
|
||||||
*
|
*
|
||||||
|
* This is used to denote the API version of Plugin specific
|
||||||
|
* features, but is also bumped to a new major if Composer
|
||||||
|
* includes a major break in internal APIs which are susceptible
|
||||||
|
* to be used by plugins.
|
||||||
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
const PLUGIN_API_VERSION = '2.0.0';
|
const PLUGIN_API_VERSION = '2.0.0';
|
||||||
|
|
|
@ -134,8 +134,8 @@ class PluginManager
|
||||||
$currentPluginApiVersion = $this->getPluginApiVersion();
|
$currentPluginApiVersion = $this->getPluginApiVersion();
|
||||||
$currentPluginApiConstraint = new Constraint('==', $this->versionParser->normalize($currentPluginApiVersion));
|
$currentPluginApiConstraint = new Constraint('==', $this->versionParser->normalize($currentPluginApiVersion));
|
||||||
|
|
||||||
if ($requiresComposer->getPrettyString() === '1.0.0' && $this->getPluginApiVersion() === '1.0.0') {
|
if ($requiresComposer->getPrettyString() === $this->getPluginApiVersion()) {
|
||||||
$this->io->writeError('<warning>The "' . $package->getName() . '" plugin requires composer-plugin-api 1.0.0, this *WILL* break in the future and it should be fixed ASAP (require ^1.0 for example).</warning>');
|
$this->io->writeError('<warning>The "' . $package->getName() . '" plugin requires composer-plugin-api '.$this->getPluginApiVersion().', this *WILL* break in the future and it should be fixed ASAP (require ^'.$this->getPluginApiVersion().' instead for example).</warning>');
|
||||||
} elseif (!$requiresComposer->matches($currentPluginApiConstraint)) {
|
} elseif (!$requiresComposer->matches($currentPluginApiConstraint)) {
|
||||||
$this->io->writeError('<warning>The "' . $package->getName() . '" plugin was skipped because it requires a Plugin API version ("' . $requiresComposer->getPrettyString() . '") that does not match your Composer installation ("' . $currentPluginApiVersion . '"). You may need to run composer update with the "--no-plugins" option.</warning>');
|
$this->io->writeError('<warning>The "' . $package->getName() . '" plugin was skipped because it requires a Plugin API version ("' . $requiresComposer->getPrettyString() . '") that does not match your Composer installation ("' . $currentPluginApiVersion . '"). You may need to run composer update with the "--no-plugins" option.</warning>');
|
||||||
|
|
||||||
|
|
|
@ -502,7 +502,7 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
|
||||||
{
|
{
|
||||||
if (!$this->hasPartialPackages() || !isset($this->partialPackagesByName[$name])) {
|
if (!$this->hasPartialPackages() || !isset($this->partialPackagesByName[$name])) {
|
||||||
// skip platform packages, root package and composer-plugin-api
|
// skip platform packages, root package and composer-plugin-api
|
||||||
if (preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $name) || '__root__' === $name || 'composer-plugin-api' === $name) {
|
if (preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $name) || '__root__' === $name) {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -672,7 +672,7 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
|
||||||
|
|
||||||
$realName = preg_replace('{~dev$}', '', $name);
|
$realName = preg_replace('{~dev$}', '', $name);
|
||||||
// skip platform packages, root package and composer-plugin-api
|
// skip platform packages, root package and composer-plugin-api
|
||||||
if (preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $realName) || '__root__' === $realName || 'composer-plugin-api' === $realName) {
|
if (preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $realName) || '__root__' === $realName) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ use Composer\Util\ProcessExecutor;
|
||||||
use Composer\Util\Silencer;
|
use Composer\Util\Silencer;
|
||||||
use Composer\Util\Platform;
|
use Composer\Util\Platform;
|
||||||
use Composer\XdebugHandler\XdebugHandler;
|
use Composer\XdebugHandler\XdebugHandler;
|
||||||
|
use Composer\Composer;
|
||||||
use Symfony\Component\Process\ExecutableFinder;
|
use Symfony\Component\Process\ExecutableFinder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -27,7 +28,7 @@ use Symfony\Component\Process\ExecutableFinder;
|
||||||
*/
|
*/
|
||||||
class PlatformRepository extends ArrayRepository
|
class PlatformRepository extends ArrayRepository
|
||||||
{
|
{
|
||||||
const PLATFORM_PACKAGE_REGEX = '{^(?:php(?:-64bit|-ipv6|-zts|-debug)?|hhvm|(?:ext|lib)-[a-z0-9](?:[_.-]?[a-z0-9]+)*|composer-plugin-api)$}iD';
|
const PLATFORM_PACKAGE_REGEX = '{^(?:php(?:-64bit|-ipv6|-zts|-debug)?|hhvm|(?:ext|lib)-[a-z0-9](?:[_.-]?[a-z0-9]+)*|composer-(?:plugin|runtime)-api)$}iD';
|
||||||
|
|
||||||
private $versionParser;
|
private $versionParser;
|
||||||
|
|
||||||
|
@ -79,6 +80,12 @@ class PlatformRepository extends ArrayRepository
|
||||||
$composerPluginApi->setDescription('The Composer Plugin API');
|
$composerPluginApi->setDescription('The Composer Plugin API');
|
||||||
$this->addPackage($composerPluginApi);
|
$this->addPackage($composerPluginApi);
|
||||||
|
|
||||||
|
$prettyVersion = Composer::RUNTIME_API_VERSION;
|
||||||
|
$version = $this->versionParser->normalize($prettyVersion);
|
||||||
|
$composerRuntimeApi = new CompletePackage('composer-runtime-api', $version, $prettyVersion);
|
||||||
|
$composerRuntimeApi->setDescription('The Composer Runtime API');
|
||||||
|
$this->addPackage($composerRuntimeApi);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$prettyVersion = PHP_VERSION;
|
$prettyVersion = PHP_VERSION;
|
||||||
$version = $this->versionParser->normalize($prettyVersion);
|
$version = $this->versionParser->normalize($prettyVersion);
|
||||||
|
|
Loading…
Reference in New Issue