Merge branch '1.8'
commit
43a43f3cdf
|
@ -193,6 +193,7 @@ class Compiler
|
||||||
$content = str_replace('@package_version@', $this->version, $content);
|
$content = str_replace('@package_version@', $this->version, $content);
|
||||||
$content = str_replace('@package_branch_alias_version@', $this->branchAliasVersion, $content);
|
$content = str_replace('@package_branch_alias_version@', $this->branchAliasVersion, $content);
|
||||||
$content = str_replace('@release_date@', $this->versionDate->format('Y-m-d H:i:s'), $content);
|
$content = str_replace('@release_date@', $this->versionDate->format('Y-m-d H:i:s'), $content);
|
||||||
|
$content = preg_replace('{SOURCE_VERSION = \'[^\']+\';}', 'SOURCE_VERSION = \'\';', $content);
|
||||||
}
|
}
|
||||||
|
|
||||||
$phar->addFromString($path, $content);
|
$phar->addFromString($path, $content);
|
||||||
|
|
|
@ -29,9 +29,46 @@ use Composer\Package\Archiver\ArchiveManager;
|
||||||
*/
|
*/
|
||||||
class Composer
|
class Composer
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
* Examples of the following constants in the various configurations they can be in
|
||||||
|
*
|
||||||
|
* releases (phar):
|
||||||
|
* const VERSION = '1.8.2';
|
||||||
|
* const BRANCH_ALIAS_VERSION = '';
|
||||||
|
* const RELEASE_DATE = '2019-01-29 15:00:53';
|
||||||
|
* const SOURCE_VERSION = '';
|
||||||
|
*
|
||||||
|
* snapshot builds (phar):
|
||||||
|
* const VERSION = 'd3873a05650e168251067d9648845c220c50e2d7';
|
||||||
|
* const BRANCH_ALIAS_VERSION = '1.9-dev';
|
||||||
|
* const RELEASE_DATE = '2019-02-20 07:43:56';
|
||||||
|
* const SOURCE_VERSION = '';
|
||||||
|
*
|
||||||
|
* source (git clone):
|
||||||
|
* const VERSION = '@package_version@';
|
||||||
|
* const BRANCH_ALIAS_VERSION = '@package_branch_alias_version@';
|
||||||
|
* const RELEASE_DATE = '@release_date@';
|
||||||
|
* const SOURCE_VERSION = '1.8-dev+source';
|
||||||
|
*/
|
||||||
const VERSION = '@package_version@';
|
const VERSION = '@package_version@';
|
||||||
const BRANCH_ALIAS_VERSION = '@package_branch_alias_version@';
|
const BRANCH_ALIAS_VERSION = '@package_branch_alias_version@';
|
||||||
const RELEASE_DATE = '@release_date@';
|
const RELEASE_DATE = '@release_date@';
|
||||||
|
const SOURCE_VERSION = '1.8-dev+source';
|
||||||
|
|
||||||
|
public static function getVersion()
|
||||||
|
{
|
||||||
|
// no replacement done, this must be a source checkout
|
||||||
|
if (self::VERSION === '@package_version'.'@') {
|
||||||
|
return self::SOURCE_VERSION;
|
||||||
|
}
|
||||||
|
|
||||||
|
// we have a branch alias and version is a commit id, this must be a snapshot build
|
||||||
|
if (self::BRANCH_ALIAS_VERSION !== '' && preg_match('{^[a-f0-9]{40}$}', self::VERSION)) {
|
||||||
|
return self::BRANCH_ALIAS_VERSION.'+'.self::VERSION;
|
||||||
|
}
|
||||||
|
|
||||||
|
return self::VERSION;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Package\RootPackageInterface
|
* @var Package\RootPackageInterface
|
||||||
|
|
|
@ -91,7 +91,7 @@ class Application extends BaseApplication
|
||||||
|
|
||||||
$this->io = new NullIO();
|
$this->io = new NullIO();
|
||||||
|
|
||||||
parent::__construct('Composer', Composer::VERSION);
|
parent::__construct('Composer', Composer::getVersion());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -190,7 +190,7 @@ class Application extends BaseApplication
|
||||||
if (!$isProxyCommand) {
|
if (!$isProxyCommand) {
|
||||||
$io->writeError(sprintf(
|
$io->writeError(sprintf(
|
||||||
'Running %s (%s) with %s on %s',
|
'Running %s (%s) with %s on %s',
|
||||||
Composer::VERSION,
|
Composer::getVersion(),
|
||||||
Composer::RELEASE_DATE,
|
Composer::RELEASE_DATE,
|
||||||
defined('HHVM_VERSION') ? 'HHVM '.HHVM_VERSION : 'PHP '.PHP_VERSION,
|
defined('HHVM_VERSION') ? 'HHVM '.HHVM_VERSION : 'PHP '.PHP_VERSION,
|
||||||
function_exists('php_uname') ? php_uname('s') . ' / ' . php_uname('r') : 'Unknown OS'
|
function_exists('php_uname') ? php_uname('s') . ' / ' . php_uname('r') : 'Unknown OS'
|
||||||
|
@ -434,7 +434,7 @@ class Application extends BaseApplication
|
||||||
*/
|
*/
|
||||||
public function getLongVersion()
|
public function getLongVersion()
|
||||||
{
|
{
|
||||||
if (Composer::BRANCH_ALIAS_VERSION) {
|
if (Composer::BRANCH_ALIAS_VERSION && Composer::BRANCH_ALIAS_VERSION !== '@package_branch_alias_version'.'@') {
|
||||||
return sprintf(
|
return sprintf(
|
||||||
'<info>%s</info> version <comment>%s (%s)</comment> %s',
|
'<info>%s</info> version <comment>%s (%s)</comment> %s',
|
||||||
$this->getName(),
|
$this->getName(),
|
||||||
|
|
|
@ -20,6 +20,7 @@ use Composer\DependencyResolver\Pool;
|
||||||
use Composer\Json\JsonFile;
|
use Composer\Json\JsonFile;
|
||||||
use Composer\Cache;
|
use Composer\Cache;
|
||||||
use Composer\Config;
|
use Composer\Config;
|
||||||
|
use Composer\Composer;
|
||||||
use Composer\Factory;
|
use Composer\Factory;
|
||||||
use Composer\IO\IOInterface;
|
use Composer\IO\IOInterface;
|
||||||
use Composer\Util\RemoteFilesystem;
|
use Composer\Util\RemoteFilesystem;
|
||||||
|
@ -699,12 +700,7 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = JsonFile::parseJson($json, $filename);
|
$data = JsonFile::parseJson($json, $filename);
|
||||||
if (!empty($data['warning'])) {
|
$this->outputWarnings($data);
|
||||||
$this->io->writeError('<warning>Warning from '.$this->url.': '.$data['warning'].'</warning>');
|
|
||||||
}
|
|
||||||
if (!empty($data['info'])) {
|
|
||||||
$this->io->writeError('<info>Info from '.$this->url.': '.$data['info'].'</info>');
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($cacheKey) {
|
if ($cacheKey) {
|
||||||
if ($storeLastModifiedTime) {
|
if ($storeLastModifiedTime) {
|
||||||
|
@ -769,12 +765,7 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = JsonFile::parseJson($json, $filename);
|
$data = JsonFile::parseJson($json, $filename);
|
||||||
if (!empty($data['warning'])) {
|
$this->outputWarnings($data);
|
||||||
$this->io->writeError('<warning>Warning from '.$this->url.': '.$data['warning'].'</warning>');
|
|
||||||
}
|
|
||||||
if (!empty($data['info'])) {
|
|
||||||
$this->io->writeError('<info>Info from '.$this->url.': '.$data['info'].'</info>');
|
|
||||||
}
|
|
||||||
|
|
||||||
$lastModifiedDate = $rfs->findHeaderValue($rfs->getLastHeaders(), 'last-modified');
|
$lastModifiedDate = $rfs->findHeaderValue($rfs->getLastHeaders(), 'last-modified');
|
||||||
if ($lastModifiedDate) {
|
if ($lastModifiedDate) {
|
||||||
|
@ -835,4 +826,24 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
|
||||||
// wipe rootData as it is fully consumed at this point and this saves some memory
|
// wipe rootData as it is fully consumed at this point and this saves some memory
|
||||||
$this->rootData = true;
|
$this->rootData = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function outputWarnings($data)
|
||||||
|
{
|
||||||
|
foreach (array('warning', 'info') as $type) {
|
||||||
|
if (empty($data[$type])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($data[$type . '-versions'])) {
|
||||||
|
$versionParser = new VersionParser();
|
||||||
|
$constraint = $versionParser->parseConstraints($data[$type . '-versions']);
|
||||||
|
$composer = new Constraint('==', $versionParser->normalize(Composer::getVersion()));
|
||||||
|
if (!$constraint->matches($composer)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->io->writeError('<'.$type.'>'.ucfirst($type).' from '.$this->url.': '.$data[$type].'</'.$type.'>');
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,6 +51,11 @@ class FilesystemRepository extends WritableArrayRepository
|
||||||
try {
|
try {
|
||||||
$packages = $this->file->read();
|
$packages = $this->file->read();
|
||||||
|
|
||||||
|
// forward compatibility for composer v2 installed.json
|
||||||
|
if (isset($packages['packages'])) {
|
||||||
|
$packages = $packages['packages'];
|
||||||
|
}
|
||||||
|
|
||||||
if (!is_array($packages)) {
|
if (!is_array($packages)) {
|
||||||
throw new \UnexpectedValueException('Could not parse package list from the repository');
|
throw new \UnexpectedValueException('Could not parse package list from the repository');
|
||||||
}
|
}
|
||||||
|
|
|
@ -142,7 +142,7 @@ final class StreamContextFactory
|
||||||
if (!isset($options['http']['header']) || false === stripos(implode('', $options['http']['header']), 'user-agent')) {
|
if (!isset($options['http']['header']) || false === stripos(implode('', $options['http']['header']), 'user-agent')) {
|
||||||
$options['http']['header'][] = sprintf(
|
$options['http']['header'][] = sprintf(
|
||||||
'User-Agent: Composer/%s (%s; %s; %s%s)',
|
'User-Agent: Composer/%s (%s; %s; %s%s)',
|
||||||
Composer::VERSION === '@package_version@' ? 'source' : Composer::VERSION,
|
Composer::getVersion(),
|
||||||
function_exists('php_uname') ? php_uname('s') : 'Unknown',
|
function_exists('php_uname') ? php_uname('s') : 'Unknown',
|
||||||
function_exists('php_uname') ? php_uname('r') : 'Unknown',
|
function_exists('php_uname') ? php_uname('r') : 'Unknown',
|
||||||
$phpVersion,
|
$phpVersion,
|
||||||
|
|
Loading…
Reference in New Issue