From 3c01faf0e2823ce00c81b839977cae14567c42d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Auri=C3=A8res?= Date: Thu, 13 Dec 2018 10:26:29 +0100 Subject: [PATCH 01/23] Use parameter with default value to set schema file path. --- src/Composer/Json/JsonFile.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Composer/Json/JsonFile.php b/src/Composer/Json/JsonFile.php index b84791420..45d638a96 100644 --- a/src/Composer/Json/JsonFile.php +++ b/src/Composer/Json/JsonFile.php @@ -34,6 +34,8 @@ class JsonFile const JSON_PRETTY_PRINT = 128; const JSON_UNESCAPED_UNICODE = 256; + const COMPOSER_SCHEMA_PATH = __DIR__ . '/../../../res/composer-schema.json'; + private $path; private $rfs; private $io; @@ -144,10 +146,11 @@ class JsonFile * Validates the schema of the current json file according to composer-schema.json rules * * @param int $schema a JsonFile::*_SCHEMA constant + * @param string $schemaFile a path to the schema file * @throws JsonValidationException * @return bool true on success */ - public function validateSchema($schema = self::STRICT_SCHEMA) + public function validateSchema($schema = self::STRICT_SCHEMA, $schemaFile = self::COMPOSER_SCHEMA_PATH) { $content = file_get_contents($this->path); $data = json_decode($content); @@ -156,8 +159,6 @@ class JsonFile self::validateSyntax($content, $this->path); } - $schemaFile = __DIR__ . '/../../../res/composer-schema.json'; - // Prepend with file:// only when not using a special schema already (e.g. in the phar) if (false === strpos($schemaFile, '://')) { $schemaFile = 'file://' . $schemaFile; From a8f27bf097448160cd6a9433ad3398afde3c9689 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Auri=C3=A8res?= Date: Thu, 13 Dec 2018 11:36:57 +0100 Subject: [PATCH 02/23] Fix constant usage to be compatible with PHP 5.3 --- src/Composer/Json/JsonFile.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Composer/Json/JsonFile.php b/src/Composer/Json/JsonFile.php index 45d638a96..ad73a8169 100644 --- a/src/Composer/Json/JsonFile.php +++ b/src/Composer/Json/JsonFile.php @@ -34,7 +34,7 @@ class JsonFile const JSON_PRETTY_PRINT = 128; const JSON_UNESCAPED_UNICODE = 256; - const COMPOSER_SCHEMA_PATH = __DIR__ . '/../../../res/composer-schema.json'; + const COMPOSER_SCHEMA_PATH = '/../../../res/composer-schema.json'; private $path; private $rfs; @@ -150,7 +150,7 @@ class JsonFile * @throws JsonValidationException * @return bool true on success */ - public function validateSchema($schema = self::STRICT_SCHEMA, $schemaFile = self::COMPOSER_SCHEMA_PATH) + public function validateSchema($schema = self::STRICT_SCHEMA, $schemaFile = null) { $content = file_get_contents($this->path); $data = json_decode($content); @@ -159,6 +159,10 @@ class JsonFile self::validateSyntax($content, $this->path); } + if (null === $schemaFile) { + $schemaFile = __DIR__ . self::COMPOSER_SCHEMA_PATH; + } + // Prepend with file:// only when not using a special schema already (e.g. in the phar) if (false === strpos($schemaFile, '://')) { $schemaFile = 'file://' . $schemaFile; From 6725d1d244836b6a1a199278c93f3531d9ba4823 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Auri=C3=A8res?= Date: Thu, 13 Dec 2018 11:39:20 +0100 Subject: [PATCH 03/23] Fix docblock. --- src/Composer/Json/JsonFile.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Composer/Json/JsonFile.php b/src/Composer/Json/JsonFile.php index ad73a8169..f2d950004 100644 --- a/src/Composer/Json/JsonFile.php +++ b/src/Composer/Json/JsonFile.php @@ -146,7 +146,7 @@ class JsonFile * Validates the schema of the current json file according to composer-schema.json rules * * @param int $schema a JsonFile::*_SCHEMA constant - * @param string $schemaFile a path to the schema file + * @param string|null $schemaFile a path to the schema file * @throws JsonValidationException * @return bool true on success */ From 767462b4095d655145c8e71f801c9f2c6f9ad9b3 Mon Sep 17 00:00:00 2001 From: bugreportuser <37939393+bugreportuser@users.noreply.github.com> Date: Thu, 13 Dec 2018 12:15:45 -0600 Subject: [PATCH 04/23] Move config check after config read --- src/Composer/Factory.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Composer/Factory.php b/src/Composer/Factory.php index 1aac934a1..6df73ceb3 100644 --- a/src/Composer/Factory.php +++ b/src/Composer/Factory.php @@ -164,6 +164,16 @@ class Factory 'data-dir' => self::getDataDir($home), ))); + // load global config + $file = new JsonFile($config->get('home').'/config.json'); + if ($file->exists()) { + if ($io && $io->isDebug()) { + $io->writeError('Loading config file ' . $file->getPath()); + } + $config->merge($file->read()); + } + $config->setConfigSource(new JsonConfigSource($file)); + $htaccessProtect = (bool) $config->get('htaccess-protect'); if ($htaccessProtect) { // Protect directory against web access. Since HOME could be @@ -180,16 +190,6 @@ class Factory } } - // load global config - $file = new JsonFile($config->get('home').'/config.json'); - if ($file->exists()) { - if ($io && $io->isDebug()) { - $io->writeError('Loading config file ' . $file->getPath()); - } - $config->merge($file->read()); - } - $config->setConfigSource(new JsonConfigSource($file)); - // load global auth file $file = new JsonFile($config->get('home').'/auth.json'); if ($file->exists()) { From 2739fc05e9c40e7bae15fc40b229890db086ea3e Mon Sep 17 00:00:00 2001 From: bugreportuser <37939393+bugreportuser@users.noreply.github.com> Date: Thu, 13 Dec 2018 12:22:31 -0600 Subject: [PATCH 05/23] Read htaccess-protect as a bool --- src/Composer/Config.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Composer/Config.php b/src/Composer/Config.php index 7b4220724..ad820ce3a 100644 --- a/src/Composer/Config.php +++ b/src/Composer/Config.php @@ -216,7 +216,6 @@ class Config case 'cache-vcs-dir': case 'cafile': case 'capath': - case 'htaccess-protect': // convert foo-bar to COMPOSER_FOO_BAR and check if it exists since it overrides the local config $env = 'COMPOSER_' . strtoupper(strtr($key, '-', '_')); @@ -230,6 +229,13 @@ class Config return (($flags & self::RELATIVE_PATHS) == self::RELATIVE_PATHS) ? $val : $this->realpath($val); + case 'htaccess-protect': + $value = $this->getComposerEnv('COMPOSER_HTACCESS_PROTECT'); + if (false === $value) { + $value = $this->config[$key]; + } + return $value !== 'false' && (bool) $value; + case 'cache-ttl': return (int) $this->config[$key]; From 618122f8979bb67764c4d6a733f9ec07833ba20c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=B6ller?= Date: Mon, 24 Dec 2018 10:45:06 +0100 Subject: [PATCH 06/23] Fix: Keep environment variables sorted by name --- doc/03-cli.md | 138 +++++++++++++++++++++++++------------------------- 1 file changed, 69 insertions(+), 69 deletions(-) diff --git a/doc/03-cli.md b/doc/03-cli.md index 74374ec6b..300d4837f 100644 --- a/doc/03-cli.md +++ b/doc/03-cli.md @@ -796,58 +796,40 @@ COMPOSER=composer-other.json php composer.phar install The generated lock file will use the same name: `composer-other.lock` in this example. -### COMPOSER_ROOT_VERSION +### COMPOSER_ALLOW_SUPERUSER -By setting this var you can specify the version of the root package, if it can -not be guessed from VCS info and is not present in `composer.json`. +If set to 1, this env disables the warning about running commands as root/super user. +It also disables automatic clearing of sudo sessions, so you should really only set this +if you use Composer as super user at all times like in docker containers. -### COMPOSER_VENDOR_DIR +### COMPOSER_AUTH -By setting this var you can make Composer install the dependencies into a -directory other than `vendor`. +The `COMPOSER_AUTH` var allows you to set up authentication as an environment variable. +The contents of the variable should be a JSON formatted object containing http-basic, +github-oauth, bitbucket-oauth, ... objects as needed, and following the +[spec from the config](06-config.md#gitlab-oauth). ### COMPOSER_BIN_DIR By setting this option you can change the `bin` ([Vendor Binaries](articles/vendor-binaries.md)) directory to something other than `vendor/bin`. -### http_proxy or HTTP_PROXY - -If you are using Composer from behind an HTTP proxy, you can use the standard -`http_proxy` or `HTTP_PROXY` env vars. Simply set it to the URL of your proxy. -Many operating systems already set this variable for you. - -Using `http_proxy` (lowercased) or even defining both might be preferable since -some tools like git or curl will only use the lower-cased `http_proxy` version. -Alternatively you can also define the git proxy using -`git config --global http.proxy `. - -If you are using Composer in a non-CLI context (i.e. integration into a CMS or -similar use case), and need to support proxies, please provide the `CGI_HTTP_PROXY` -environment variable instead. See [httpoxy.org](https://httpoxy.org/) for further -details. - -### no_proxy or NO_PROXY +### COMPOSER_CACHE_DIR -If you are behind a proxy and would like to disable it for certain domains, you -can use the `no_proxy` or `NO_PROXY` env var. Simply set it to a comma separated list of -domains the proxy should *not* be used for. +The `COMPOSER_CACHE_DIR` var allows you to change the Composer cache directory, +which is also configurable via the [`cache-dir`](06-config.md#cache-dir) option. -The env var accepts domains, IP addresses, and IP address blocks in CIDR -notation. You can restrict the filter to a particular port (e.g. `:80`). You -can also set it to `*` to ignore the proxy for all HTTP requests. +By default it points to `$COMPOSER_HOME/cache` on \*nix and macOS, and +`C:\Users\\AppData\Local\Composer` (or `%LOCALAPPDATA%/Composer`) on Windows. -### HTTP_PROXY_REQUEST_FULLURI +### COMPOSER_CAFILE -If you use a proxy but it does not support the request_fulluri flag, then you -should set this env var to `false` or `0` to prevent Composer from setting the -request_fulluri option. +By setting this environmental value, you can set a path to a certificate bundle +file to be used during SSL/TLS peer verification. -### HTTPS_PROXY_REQUEST_FULLURI +### COMPOSER_DISCARD_CHANGES -If you use a proxy but it does not support the request_fulluri flag for HTTPS -requests, then you should set this env var to `false` or `0` to prevent Composer -from setting the request_fulluri option. +This env var controls the [`discard-changes`](06-config.md#discard-changes) config option. ### COMPOSER_HOME @@ -873,59 +855,77 @@ This file allows you to set [repositories](05-repositories.md) and In case global configuration matches _local_ configuration, the _local_ configuration in the project's `composer.json` always wins. -### COMPOSER_CACHE_DIR +### COMPOSER_HTACCESS_PROTECT -The `COMPOSER_CACHE_DIR` var allows you to change the Composer cache directory, -which is also configurable via the [`cache-dir`](06-config.md#cache-dir) option. +Defaults to `1`. If set to `0`, Composer will not create `.htaccess` files in the +composer home, cache, and data directories. -By default it points to `$COMPOSER_HOME/cache` on \*nix and macOS, and -`C:\Users\\AppData\Local\Composer` (or `%LOCALAPPDATA%/Composer`) on Windows. +### COMPOSER_MEMORY_LIMIT + +If set, the value is used as php's memory_limit. + +### COMPOSER_MIRROR_PATH_REPOS + +If set to 1, this env changes the default path repository strategy to `mirror` instead +of `symlink`. As it is the default strategy being set it can still be overwritten by +repository options. + +### COMPOSER_NO_INTERACTION + +If set to 1, this env var will make Composer behave as if you passed the +`--no-interaction` flag to every command. This can be set on build boxes/CI. ### COMPOSER_PROCESS_TIMEOUT This env var controls the time Composer waits for commands (such as git commands) to finish executing. The default value is 300 seconds (5 minutes). -### COMPOSER_CAFILE - -By setting this environmental value, you can set a path to a certificate bundle -file to be used during SSL/TLS peer verification. +### COMPOSER_ROOT_VERSION -### COMPOSER_AUTH +By setting this var you can specify the version of the root package, if it can +not be guessed from VCS info and is not present in `composer.json`. -The `COMPOSER_AUTH` var allows you to set up authentication as an environment variable. -The contents of the variable should be a JSON formatted object containing http-basic, -github-oauth, bitbucket-oauth, ... objects as needed, and following the -[spec from the config](06-config.md#gitlab-oauth). +### COMPOSER_VENDOR_DIR -### COMPOSER_DISCARD_CHANGES +By setting this var you can make Composer install the dependencies into a +directory other than `vendor`. -This env var controls the [`discard-changes`](06-config.md#discard-changes) config option. +### http_proxy or HTTP_PROXY -### COMPOSER_NO_INTERACTION +If you are using Composer from behind an HTTP proxy, you can use the standard +`http_proxy` or `HTTP_PROXY` env vars. Simply set it to the URL of your proxy. +Many operating systems already set this variable for you. -If set to 1, this env var will make Composer behave as if you passed the -`--no-interaction` flag to every command. This can be set on build boxes/CI. +Using `http_proxy` (lowercased) or even defining both might be preferable since +some tools like git or curl will only use the lower-cased `http_proxy` version. +Alternatively you can also define the git proxy using +`git config --global http.proxy `. -### COMPOSER_ALLOW_SUPERUSER +If you are using Composer in a non-CLI context (i.e. integration into a CMS or +similar use case), and need to support proxies, please provide the `CGI_HTTP_PROXY` +environment variable instead. See [httpoxy.org](https://httpoxy.org/) for further +details. -If set to 1, this env disables the warning about running commands as root/super user. -It also disables automatic clearing of sudo sessions, so you should really only set this -if you use Composer as super user at all times like in docker containers. +### HTTP_PROXY_REQUEST_FULLURI -### COMPOSER_MEMORY_LIMIT +If you use a proxy but it does not support the request_fulluri flag, then you +should set this env var to `false` or `0` to prevent Composer from setting the +request_fulluri option. -If set, the value is used as php's memory_limit. +### HTTPS_PROXY_REQUEST_FULLURI -### COMPOSER_MIRROR_PATH_REPOS +If you use a proxy but it does not support the request_fulluri flag for HTTPS +requests, then you should set this env var to `false` or `0` to prevent Composer +from setting the request_fulluri option. -If set to 1, this env changes the default path repository strategy to `mirror` instead -of `symlink`. As it is the default strategy being set it can still be overwritten by -repository options. +### no_proxy or NO_PROXY -### COMPOSER_HTACCESS_PROTECT +If you are behind a proxy and would like to disable it for certain domains, you +can use the `no_proxy` or `NO_PROXY` env var. Simply set it to a comma separated list of +domains the proxy should *not* be used for. -Defaults to `1`. If set to `0`, Composer will not create `.htaccess` files in the -composer home, cache, and data directories. +The env var accepts domains, IP addresses, and IP address blocks in CIDR +notation. You can restrict the filter to a particular port (e.g. `:80`). You +can also set it to `*` to ignore the proxy for all HTTP requests. ← [Libraries](02-libraries.md) | [Schema](04-schema.md) → From e5989fcfe0c8c24e1378215b15463e7e095148e1 Mon Sep 17 00:00:00 2001 From: Christopher Hertel Date: Wed, 26 Dec 2018 20:37:46 +0100 Subject: [PATCH 07/23] adding PHP_BINARY as env var to script execution --- src/Composer/EventDispatcher/EventDispatcher.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Composer/EventDispatcher/EventDispatcher.php b/src/Composer/EventDispatcher/EventDispatcher.php index 0fb978fd4..ee02381e5 100644 --- a/src/Composer/EventDispatcher/EventDispatcher.php +++ b/src/Composer/EventDispatcher/EventDispatcher.php @@ -244,6 +244,12 @@ class EventDispatcher if (substr($exec, 0, 5) === '@php ') { $exec = $this->getPhpExecCommand() . ' ' . substr($exec, 5); + } else { + $finder = new PhpExecutableFinder(); + $phpPath = $finder->find(false); + if ($phpPath) { + putenv('PHP_BINARY=' . $phpPath); + } } if (0 !== ($exitCode = $this->process->execute($exec))) { From 894b3da970c92360f26004eb5382e600e488e1fe Mon Sep 17 00:00:00 2001 From: Christopher Hertel Date: Wed, 26 Dec 2018 21:21:45 +0100 Subject: [PATCH 08/23] updating lock file hash --- composer.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.lock b/composer.lock index 957382bc6..6d0d93512 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "e46280c4cfd37bf3ec8be36095feb20e", + "content-hash": "0367be765bb2ea718da11dbb9b3ed793", "packages": [ { "name": "composer/ca-bundle", From 4fc305456aa8e940cfdbfe4b8bb7810f1c1361a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=B6ller?= Date: Wed, 2 Jan 2019 15:12:27 +0100 Subject: [PATCH 09/23] Enhancement: Validate composer.json on Travis --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index c1511b6c3..ddd7917de 100644 --- a/.travis.yml +++ b/.travis.yml @@ -42,6 +42,7 @@ before_install: # disable default memory limit - export INI=~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini - echo memory_limit = -1 >> $INI + - composer validate install: # flags to pass to install From 9f2dd5c612d3d2d75815dc0f4291201775d90ddf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=B6ller?= Date: Wed, 2 Jan 2019 15:38:07 +0100 Subject: [PATCH 10/23] Fix: Consistently indent with 2 spaces --- .travis.yml | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/.travis.yml b/.travis.yml index c1511b6c3..1ff8a5221 100644 --- a/.travis.yml +++ b/.travis.yml @@ -37,33 +37,33 @@ matrix: - php: nightly before_install: - # disable xdebug if available - - phpenv config-rm xdebug.ini || echo "xdebug not available" - # disable default memory limit - - export INI=~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini - - echo memory_limit = -1 >> $INI + # disable xdebug if available + - phpenv config-rm xdebug.ini || echo "xdebug not available" + # disable default memory limit + - export INI=~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini + - echo memory_limit = -1 >> $INI install: - # flags to pass to install - - flags="--ansi --prefer-dist --no-interaction --optimize-autoloader --no-suggest --no-progress" - # update deps to latest in case of high deps build - - if [ "$deps" == "high" ]; then composer config platform.php 7.2.4; composer update $flags; fi - # install dependencies using system provided composer binary - - composer install $flags - # install dependencies using composer from source - - bin/composer install $flags + # flags to pass to install + - flags="--ansi --prefer-dist --no-interaction --optimize-autoloader --no-suggest --no-progress" + # update deps to latest in case of high deps build + - if [ "$deps" == "high" ]; then composer config platform.php 7.2.4; composer update $flags; fi + # install dependencies using system provided composer binary + - composer install $flags + # install dependencies using composer from source + - bin/composer install $flags before_script: - # make sure git tests do not complain about user/email not being set - - git config --global user.name travis-ci - - git config --global user.email travis@example.com + # make sure git tests do not complain about user/email not being set + - git config --global user.name travis-ci + - git config --global user.email travis@example.com script: - # run test suite directories in parallel using GNU parallel - - ls -d tests/Composer/Test/* | grep -v TestCase.php | parallel --gnu --keep-order 'echo "Running {} tests"; ./vendor/bin/phpunit -c tests/complete.phpunit.xml --colors=always {} || (echo -e "\e[41mFAILED\e[0m {}" && exit 1);' + # run test suite directories in parallel using GNU parallel + - ls -d tests/Composer/Test/* | grep -v TestCase.php | parallel --gnu --keep-order 'echo "Running {} tests"; ./vendor/bin/phpunit -c tests/complete.phpunit.xml --colors=always {} || (echo -e "\e[41mFAILED\e[0m {}" && exit 1);' before_deploy: - - php -d phar.readonly=0 bin/compile + - php -d phar.readonly=0 bin/compile deploy: provider: releases From 8f3946fc3aaf87202a19e62728cd720dc6e61b81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=B6ller?= Date: Wed, 2 Jan 2019 15:40:17 +0100 Subject: [PATCH 11/23] Enhancement: Reference phpunit.xsd as installed with composer --- phpunit.xml.dist | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 4c6749521..20eaefb12 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,6 +1,8 @@ - Date: Wed, 2 Jan 2019 15:45:25 +0100 Subject: [PATCH 12/23] Enhancement: Explicitly configure build matrix to maintain order --- .travis.yml | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index c1511b6c3..df2110057 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,22 +16,20 @@ addons: packages: - parallel -php: - - 5.4 - - 5.5 - - 5.6 - - 7.0 - - 7.1 - - 7.2 - - 7.3 - - nightly - matrix: include: - php: 5.3 dist: precise + - php: 5.4 + - php: 5.5 + - php: 5.6 + - php: 7.0 + - php: 7.1 + - php: 7.2 + - php: 7.3 - php: 7.3 env: deps=high + - php: nightly fast_finish: true allow_failures: - php: nightly From 05e86c2c071e1c9b7ca1bdfe09b0b44c5aaf729a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=B6ller?= Date: Wed, 2 Jan 2019 15:41:33 +0100 Subject: [PATCH 13/23] Fix: Remove non-existent attribute --- phpunit.xml.dist | 1 - 1 file changed, 1 deletion(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 20eaefb12..bb3b94774 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -10,7 +10,6 @@ convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" - syntaxCheck="false" bootstrap="tests/bootstrap.php" > From bd2a46cf5dcc33af229834a4b817383252d14ffc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=B6ller?= Date: Wed, 2 Jan 2019 15:52:53 +0100 Subject: [PATCH 14/23] Fix: Remove sudo configuration --- .travis.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index c1511b6c3..e9bc30034 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,5 @@ language: php -sudo: false - dist: trusty git: From 4b2e63704bffe8d5a3699499d660d014078f0318 Mon Sep 17 00:00:00 2001 From: fancyweb Date: Wed, 2 Jan 2019 23:36:53 +0100 Subject: [PATCH 15/23] fix(application): use precise helper set --- src/Composer/Console/Application.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Composer/Console/Application.php b/src/Composer/Console/Application.php index e6ff7da9d..c25ee3fe0 100644 --- a/src/Composer/Console/Application.php +++ b/src/Composer/Console/Application.php @@ -17,6 +17,8 @@ use Composer\Util\Platform; use Composer\Util\Silencer; use Symfony\Component\Console\Application as BaseApplication; use Symfony\Component\Console\Exception\CommandNotFoundException; +use Symfony\Component\Console\Helper\HelperSet; +use Symfony\Component\Console\Helper\QuestionHelper; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; @@ -111,7 +113,9 @@ class Application extends BaseApplication { $this->disablePluginsByDefault = $input->hasParameterOption('--no-plugins'); - $io = $this->io = new ConsoleIO($input, $output, $this->getHelperSet()); + $io = $this->io = new ConsoleIO($input, $output, new HelperSet(array( + new QuestionHelper(), + ))); ErrorHandler::register($io); // switch working dir From 45a7b8e1c2e68a450ac053d0f96bc5df3d7ef399 Mon Sep 17 00:00:00 2001 From: fancyweb Date: Wed, 2 Jan 2019 23:38:11 +0100 Subject: [PATCH 16/23] feat(buffer-io): add question helper set --- src/Composer/IO/BufferIO.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Composer/IO/BufferIO.php b/src/Composer/IO/BufferIO.php index d47d4eaa5..83a1a9820 100644 --- a/src/Composer/IO/BufferIO.php +++ b/src/Composer/IO/BufferIO.php @@ -12,6 +12,7 @@ namespace Composer\IO; +use Symfony\Component\Console\Helper\QuestionHelper; use Symfony\Component\Console\Output\StreamOutput; use Symfony\Component\Console\Formatter\OutputFormatterInterface; use Symfony\Component\Console\Input\StringInput; @@ -34,7 +35,9 @@ class BufferIO extends ConsoleIO $output = new StreamOutput(fopen('php://memory', 'rw'), $verbosity, $formatter ? $formatter->isDecorated() : false, $formatter); - parent::__construct($input, $output, new HelperSet(array())); + parent::__construct($input, $output, new HelperSet(array( + new QuestionHelper(), + ))); } public function getOutput() From db4ec12a24e0091c861c43da7e05cd1df1a34d9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=B6ller?= Date: Wed, 2 Jan 2019 15:16:42 +0100 Subject: [PATCH 17/23] Enhancement: Add .editorconfig --- .editorconfig | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 000000000..033f8a6da --- /dev/null +++ b/.editorconfig @@ -0,0 +1,11 @@ +root = true + +[*] +charset = utf-8 +indent_size = 4 +indent_style = space +insert_final_newline = true +trim_trailing_whitespace = true + +[*.yml] +indent_size = 2 From ea48bad401339a650bb8a445238bca747b3b72c9 Mon Sep 17 00:00:00 2001 From: Pete Cooper Date: Thu, 3 Jan 2019 17:05:46 +0000 Subject: [PATCH 18/23] Fix spelling mistake on Cygwin --- src/Composer/Installer/BinaryInstaller.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Composer/Installer/BinaryInstaller.php b/src/Composer/Installer/BinaryInstaller.php index 0f709f60b..a14755bf1 100644 --- a/src/Composer/Installer/BinaryInstaller.php +++ b/src/Composer/Installer/BinaryInstaller.php @@ -197,7 +197,7 @@ class BinaryInstaller dir=\$(cd "\${0%[/\\\\]*}" > /dev/null; cd $binDir && pwd) if [ -d /proc/cygdrive ] && [[ \$(which php) == \$(readlink -n /proc/cygdrive)/* ]]; then - # We are in Cgywin using Windows php, so the path must be translated + # We are in Cygwin using Windows php, so the path must be translated dir=\$(cygpath -m "\$dir"); fi From a9d6068c57652f8c5290d4668f1377387f308a76 Mon Sep 17 00:00:00 2001 From: fancyweb Date: Thu, 3 Jan 2019 10:35:51 +0100 Subject: [PATCH 19/23] feat(buffer-io): add the possibility to set user inputs for interactive questions --- src/Composer/IO/BufferIO.php | 24 ++++++++++++++ tests/Composer/Test/IO/BufferIOTest.php | 43 +++++++++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 tests/Composer/Test/IO/BufferIOTest.php diff --git a/src/Composer/IO/BufferIO.php b/src/Composer/IO/BufferIO.php index d47d4eaa5..742c3f8a4 100644 --- a/src/Composer/IO/BufferIO.php +++ b/src/Composer/IO/BufferIO.php @@ -14,6 +14,7 @@ namespace Composer\IO; use Symfony\Component\Console\Output\StreamOutput; use Symfony\Component\Console\Formatter\OutputFormatterInterface; +use Symfony\Component\Console\Input\StreamableInputInterface; use Symfony\Component\Console\Input\StringInput; use Symfony\Component\Console\Helper\HelperSet; @@ -56,4 +57,27 @@ class BufferIO extends ConsoleIO return $output; } + + public function setUserInputs(array $inputs) + { + if (!$this->input instanceof StreamableInputInterface) { + throw new \RuntimeException('Setting the user inputs requires at least the version 3.2 of the symfony/console component.'); + } + + $this->input->setStream($this->createStream($inputs)); + $this->input->setInteractive(true); + } + + private function createStream(array $inputs) + { + $stream = fopen('php://memory', 'r+', false); + + foreach ($inputs as $input) { + fwrite($stream, $input.PHP_EOL); + } + + rewind($stream); + + return $stream; + } } diff --git a/tests/Composer/Test/IO/BufferIOTest.php b/tests/Composer/Test/IO/BufferIOTest.php new file mode 100644 index 000000000..013a3c100 --- /dev/null +++ b/tests/Composer/Test/IO/BufferIOTest.php @@ -0,0 +1,43 @@ + + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Composer\Test\IO; + +use Composer\IO\BufferIO; +use Composer\Test\TestCase; +use Symfony\Component\Console\Input\StreamableInputInterface; + +class BufferIOTest extends TestCase +{ + public function testSetUserInputs() + { + $bufferIO = new BufferIO(); + + $refl = new \ReflectionProperty($bufferIO, 'input'); + $refl->setAccessible(true); + $input = $refl->getValue($bufferIO); + + if (!$input instanceof StreamableInputInterface) { + $this->setExpectedException('\RuntimeException', 'Setting the user inputs requires at least the version 3.2 of the symfony/console component.'); + } + + $bufferIO->setUserInputs(array( + 'yes', + 'no', + '', + )); + + $this->assertTrue($bufferIO->askConfirmation('Please say yes!', 'no')); + $this->assertFalse($bufferIO->askConfirmation('Now please say no!', 'yes')); + $this->assertSame('default', $bufferIO->ask('Empty string last', 'default')); + } +} From cc4e5ec281391db709ddb607dfb937db71dbac2e Mon Sep 17 00:00:00 2001 From: Marko Kaznovac Date: Thu, 10 Jan 2019 15:00:56 +0100 Subject: [PATCH 20/23] add compile script call to composer.json expose call for compiling `composer.phar` in composer json, along with description --- composer.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/composer.json b/composer.json index 41048903b..5ed969969 100644 --- a/composer.json +++ b/composer.json @@ -72,8 +72,13 @@ "bin/composer" ], "scripts": { + "compile": "@php -dphar.readonly=0 bin/compile", "test": "phpunit" }, + "scripts-descriptions": { + "compile": "Compile composer.phar", + "test": "Run all tests" + }, "support": { "issues": "https://github.com/composer/composer/issues", "irc": "irc://irc.freenode.org/composer" From 59360983c604bb44e8ada7a281c81046f8cd4ff5 Mon Sep 17 00:00:00 2001 From: Stephan Vock Date: Thu, 17 Jan 2019 12:46:57 +0100 Subject: [PATCH 21/23] Archive: cleanup temp dir on download error --- src/Composer/Package/Archiver/ArchiveManager.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Composer/Package/Archiver/ArchiveManager.php b/src/Composer/Package/Archiver/ArchiveManager.php index 22f8eeafe..6f8fa8a01 100644 --- a/src/Composer/Package/Archiver/ArchiveManager.php +++ b/src/Composer/Package/Archiver/ArchiveManager.php @@ -147,8 +147,13 @@ class ArchiveManager $sourcePath = sys_get_temp_dir().'/composer_archive'.uniqid(); $filesystem->ensureDirectoryExists($sourcePath); - // Download sources - $this->downloadManager->download($package, $sourcePath); + try { + // Download sources + $this->downloadManager->download($package, $sourcePath); + } catch (\Exception $e) { + $filesystem->removeDirectory($sourcePath); + throw $e; + } // Check exclude from downloaded composer.json if (file_exists($composerJsonPath = $sourcePath.'/composer.json')) { From bcff704bc52efc22be7f74a8a62145ea924250e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Xu=C3=A2n=20Qu=E1=BB=B3nh?= Date: Sun, 20 Jan 2019 12:46:13 +0700 Subject: [PATCH 22/23] Add alias of run-script command --- src/Composer/Command/RunScriptCommand.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Composer/Command/RunScriptCommand.php b/src/Composer/Command/RunScriptCommand.php index ea3b5c892..7997dfb37 100644 --- a/src/Composer/Command/RunScriptCommand.php +++ b/src/Composer/Command/RunScriptCommand.php @@ -48,6 +48,7 @@ class RunScriptCommand extends BaseCommand { $this ->setName('run-script') + ->setAliases(array('run')) ->setDescription('Runs the scripts defined in composer.json.') ->setDefinition(array( new InputArgument('script', InputArgument::OPTIONAL, 'Script name to run.'), From c5cc178375cad478efabf74270e8583e217afa4a Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Mon, 28 Jan 2019 14:31:16 +0100 Subject: [PATCH 23/23] Update to latest CA bundle --- composer.lock | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/composer.lock b/composer.lock index 957382bc6..fa0ed41fd 100644 --- a/composer.lock +++ b/composer.lock @@ -8,16 +8,16 @@ "packages": [ { "name": "composer/ca-bundle", - "version": "1.1.3", + "version": "1.1.4", "source": { "type": "git", "url": "https://github.com/composer/ca-bundle.git", - "reference": "8afa52cd417f4ec417b4bfe86b68106538a87660" + "reference": "558f321c52faeb4828c03e7dc0cfe39a09e09a2d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/ca-bundle/zipball/8afa52cd417f4ec417b4bfe86b68106538a87660", - "reference": "8afa52cd417f4ec417b4bfe86b68106538a87660", + "url": "https://api.github.com/repos/composer/ca-bundle/zipball/558f321c52faeb4828c03e7dc0cfe39a09e09a2d", + "reference": "558f321c52faeb4828c03e7dc0cfe39a09e09a2d", "shasum": "" }, "require": { @@ -60,7 +60,7 @@ "ssl", "tls" ], - "time": "2018-10-18T06:09:13+00:00" + "time": "2019-01-28T09:30:10+00:00" }, { "name": "composer/semver",