From f59181d7d557b78580929a28a0cb77c06912943d Mon Sep 17 00:00:00 2001 From: Galymzhan Date: Tue, 11 Dec 2012 20:30:09 +0600 Subject: [PATCH 01/16] add support for --no-progress, fixes #621 --- src/Composer/Command/CreateProjectCommand.php | 7 +++++-- src/Composer/Command/InstallCommand.php | 2 ++ src/Composer/Command/RequireCommand.php | 2 ++ src/Composer/Command/UpdateCommand.php | 2 ++ src/Composer/Downloader/DownloadManager.php | 16 ++++++++++++++++ src/Composer/Downloader/DownloaderInterface.php | 8 ++++++++ src/Composer/Downloader/FileDownloader.php | 15 +++++++++++++-- src/Composer/Downloader/VcsDownloader.php | 9 +++++++++ 8 files changed, 57 insertions(+), 4 deletions(-) diff --git a/src/Composer/Command/CreateProjectCommand.php b/src/Composer/Command/CreateProjectCommand.php index 1a3086ed8..8efd88725 100644 --- a/src/Composer/Command/CreateProjectCommand.php +++ b/src/Composer/Command/CreateProjectCommand.php @@ -60,6 +60,7 @@ class CreateProjectCommand extends Command new InputOption('dev', null, InputOption::VALUE_NONE, 'Whether to install dependencies for development.'), new InputOption('no-custom-installers', null, InputOption::VALUE_NONE, 'Whether to disable custom installers.'), new InputOption('no-scripts', null, InputOption::VALUE_NONE, 'Whether to prevent execution of all defined scripts in the root package.'), + new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'), new InputOption('keep-vcs', null, InputOption::VALUE_NONE, 'Whether to prevent deletion vcs folder.'), )) ->setHelp(<<getOption('repository-url'), $input->getOption('no-custom-installers'), $input->getOption('no-scripts'), + $input->getOption('no-progress'), $input->getOption('keep-vcs') ); } - public function installProject(IOInterface $io, $packageName, $directory = null, $packageVersion = null, $stability = 'stable', $preferSource = false, $preferDist = false, $installDevPackages = false, $repositoryUrl = null, $disableCustomInstallers = false, $noScripts = false, $keepVcs = false) + public function installProject(IOInterface $io, $packageName, $directory = null, $packageVersion = null, $stability = 'stable', $preferSource = false, $preferDist = false, $installDevPackages = false, $repositoryUrl = null, $disableCustomInstallers = false, $noScripts = false, $noProgress = false, $keepVcs = false) { $config = Factory::createConfig(); @@ -177,7 +179,8 @@ EOT $dm = $this->createDownloadManager($io, $config); $dm->setPreferSource($preferSource) - ->setPreferDist($preferDist); + ->setPreferDist($preferDist) + ->setOutputProgress(!$noProgress); $projectInstaller = new ProjectInstaller($directory, $dm); $im = $this->createInstallationManager(); diff --git a/src/Composer/Command/InstallCommand.php b/src/Composer/Command/InstallCommand.php index d31dbdce7..0d8ffce2d 100644 --- a/src/Composer/Command/InstallCommand.php +++ b/src/Composer/Command/InstallCommand.php @@ -36,6 +36,7 @@ class InstallCommand extends Command new InputOption('dev', null, InputOption::VALUE_NONE, 'Enables installation of dev-require packages.'), new InputOption('no-custom-installers', null, InputOption::VALUE_NONE, 'Disables all custom installers.'), new InputOption('no-scripts', null, InputOption::VALUE_NONE, 'Skips the execution of all scripts defined in composer.json file.'), + new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'), new InputOption('verbose', 'v', InputOption::VALUE_NONE, 'Shows more details including new commits pulled in when updating packages.'), new InputOption('optimize-autoloader', 'o', InputOption::VALUE_NONE, 'Optimize autoloader during autoloader dump') )) @@ -55,6 +56,7 @@ EOT protected function execute(InputInterface $input, OutputInterface $output) { $composer = $this->getComposer(); + $composer->getDownloadManager()->setOutputProgress(!$input->getOption('no-progress')); $io = $this->getIO(); $install = Installer::create($io, $composer); diff --git a/src/Composer/Command/RequireCommand.php b/src/Composer/Command/RequireCommand.php index b67d087d0..f75ec44db 100644 --- a/src/Composer/Command/RequireCommand.php +++ b/src/Composer/Command/RequireCommand.php @@ -37,6 +37,7 @@ class RequireCommand extends InitCommand new InputOption('dev', null, InputOption::VALUE_NONE, 'Add requirement to require-dev.'), new InputOption('prefer-source', null, InputOption::VALUE_NONE, 'Forces installation from package sources when possible, including VCS information.'), new InputOption('prefer-dist', null, InputOption::VALUE_NONE, 'Forces installation from package dist even for dev versions.'), + new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'), new InputOption('no-update', null, InputOption::VALUE_NONE, 'Disables the automatic update of the dependencies.'), )) ->setHelp(<<getComposer(); + $composer->getDownloadManager()->setOutputProgress(!$input->getOption('no-progress')); $io = $this->getIO(); $install = Installer::create($io, $composer); diff --git a/src/Composer/Command/UpdateCommand.php b/src/Composer/Command/UpdateCommand.php index 1cbc654b9..a6aa3a476 100644 --- a/src/Composer/Command/UpdateCommand.php +++ b/src/Composer/Command/UpdateCommand.php @@ -36,6 +36,7 @@ class UpdateCommand extends Command new InputOption('dev', null, InputOption::VALUE_NONE, 'Enables installation of dev-require packages.'), new InputOption('no-custom-installers', null, InputOption::VALUE_NONE, 'Disables all custom installers.'), new InputOption('no-scripts', null, InputOption::VALUE_NONE, 'Skips the execution of all scripts defined in composer.json file.'), + new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'), new InputOption('verbose', 'v', InputOption::VALUE_NONE, 'Shows more details including new commits pulled in when updating packages.'), new InputOption('optimize-autoloader', 'o', InputOption::VALUE_NONE, 'Optimize autoloader during autoloader dump') )) @@ -58,6 +59,7 @@ EOT protected function execute(InputInterface $input, OutputInterface $output) { $composer = $this->getComposer(); + $composer->getDownloadManager()->setOutputProgress(!$input->getOption('no-progress')); $io = $this->getIO(); $install = Installer::create($io, $composer); diff --git a/src/Composer/Downloader/DownloadManager.php b/src/Composer/Downloader/DownloadManager.php index 42f822c00..e52212f76 100644 --- a/src/Composer/Downloader/DownloadManager.php +++ b/src/Composer/Downloader/DownloadManager.php @@ -64,6 +64,22 @@ class DownloadManager return $this; } + /** + * Sets whether to output download progress information for all registered + * downloaders + * + * @param bool $outputProgress + * @return DownloadManager + */ + public function setOutputProgress($outputProgress) + { + foreach ($this->downloaders as $downloader) { + $downloader->setOutputProgress($outputProgress); + } + + return $this; + } + /** * Sets installer downloader for a specific installation type. * diff --git a/src/Composer/Downloader/DownloaderInterface.php b/src/Composer/Downloader/DownloaderInterface.php index 61dc35302..713bf36dc 100644 --- a/src/Composer/Downloader/DownloaderInterface.php +++ b/src/Composer/Downloader/DownloaderInterface.php @@ -53,4 +53,12 @@ interface DownloaderInterface * @param string $path download path */ public function remove(PackageInterface $package, $path); + + /** + * Sets whether to output download progress information or not + * + * @param bool $outputProgress + * @return DownloaderInterface + */ + public function setOutputProgress($outputProgress); } diff --git a/src/Composer/Downloader/FileDownloader.php b/src/Composer/Downloader/FileDownloader.php index 752659040..437873492 100644 --- a/src/Composer/Downloader/FileDownloader.php +++ b/src/Composer/Downloader/FileDownloader.php @@ -36,6 +36,7 @@ class FileDownloader implements DownloaderInterface protected $rfs; protected $filesystem; protected $cache; + protected $outputProgress = true; /** * Constructor. @@ -94,7 +95,7 @@ class FileDownloader implements DownloaderInterface try { try { if (!$this->cache || !$this->cache->copyTo($this->getCacheKey($package), $fileName)) { - $this->rfs->copy($hostname, $processedUrl, $fileName); + $this->rfs->copy($hostname, $processedUrl, $fileName, $this->outputProgress); if ($this->cache) { $this->cache->copyFrom($this->getCacheKey($package), $fileName); } @@ -108,7 +109,7 @@ class FileDownloader implements DownloaderInterface ) { throw $e; } - $this->rfs->copy($hostname, $processedUrl, $fileName); + $this->rfs->copy($hostname, $processedUrl, $fileName, $this->outputProgress); } else { throw $e; } @@ -131,6 +132,16 @@ class FileDownloader implements DownloaderInterface } } + /** + * {@inheritDoc} + */ + public function setOutputProgress($outputProgress) + { + $this->outputProgress = $outputProgress; + + return $this; + } + protected function clearCache(PackageInterface $package, $path) { if ($this->cache) { diff --git a/src/Composer/Downloader/VcsDownloader.php b/src/Composer/Downloader/VcsDownloader.php index ea40f0a81..55a189b7b 100644 --- a/src/Composer/Downloader/VcsDownloader.php +++ b/src/Composer/Downloader/VcsDownloader.php @@ -132,6 +132,15 @@ abstract class VcsDownloader implements DownloaderInterface } } + /** + * Download progress information is not available for all VCS downloaders. + * {@inheritDoc} + */ + public function setOutputProgress($outputProgress) + { + return $this; + } + /** * Prompt the user to check if changes should be stashed/removed or the operation aborted * From 47442b6e390d91f0cd7ca0d93a2f935869741267 Mon Sep 17 00:00:00 2001 From: Galymzhan Date: Wed, 12 Dec 2012 11:02:52 +0600 Subject: [PATCH 02/16] change parameter order to preserve BC --- src/Composer/Command/CreateProjectCommand.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Composer/Command/CreateProjectCommand.php b/src/Composer/Command/CreateProjectCommand.php index 8efd88725..4c1aeb6d6 100644 --- a/src/Composer/Command/CreateProjectCommand.php +++ b/src/Composer/Command/CreateProjectCommand.php @@ -103,12 +103,12 @@ EOT $input->getOption('repository-url'), $input->getOption('no-custom-installers'), $input->getOption('no-scripts'), - $input->getOption('no-progress'), - $input->getOption('keep-vcs') + $input->getOption('keep-vcs'), + $input->getOption('no-progress') ); } - public function installProject(IOInterface $io, $packageName, $directory = null, $packageVersion = null, $stability = 'stable', $preferSource = false, $preferDist = false, $installDevPackages = false, $repositoryUrl = null, $disableCustomInstallers = false, $noScripts = false, $noProgress = false, $keepVcs = false) + public function installProject(IOInterface $io, $packageName, $directory = null, $packageVersion = null, $stability = 'stable', $preferSource = false, $preferDist = false, $installDevPackages = false, $repositoryUrl = null, $disableCustomInstallers = false, $noScripts = false, $keepVcs = false, $noProgress = false) { $config = Factory::createConfig(); From 159badb06bf4ed25cadbaeabd56b7b2b7b30b33e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Thieriot?= Date: Thu, 13 Dec 2012 09:08:04 +0000 Subject: [PATCH 03/16] Add ability to use a Regexp when updating packages --- doc/03-cli.md | 4 ++ src/Composer/Installer.php | 8 +++- .../installer/update-whitelist-patterns.test | 45 +++++++++++++++++++ 3 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 tests/Composer/Test/Fixtures/installer/update-whitelist-patterns.test diff --git a/doc/03-cli.md b/doc/03-cli.md index 39634e06c..2a69d7540 100644 --- a/doc/03-cli.md +++ b/doc/03-cli.md @@ -96,6 +96,10 @@ If you just want to update a few packages and not all, you can list them as such $ php composer.phar update vendor/package vendor/package2 +You can also use a Regular expression pattern to update a bunch of packages at once: + + $ php composer.phar update vendor.* + ### Options * **--prefer-source:** Install packages from `source` when available. diff --git a/src/Composer/Installer.php b/src/Composer/Installer.php index 88d4ff65f..dea566eca 100644 --- a/src/Composer/Installer.php +++ b/src/Composer/Installer.php @@ -624,7 +624,13 @@ class Installer throw new \LogicException('isUpdateable should only be called when a whitelist is present'); } - return isset($this->updateWhitelist[$package->getName()]); + foreach($this->updateWhitelist as $whiteListedPattern => $void) { + if(preg_match("#^".$whiteListedPattern."$#i", $package->getName())) { + return true; + } + } + + return false; } /** diff --git a/tests/Composer/Test/Fixtures/installer/update-whitelist-patterns.test b/tests/Composer/Test/Fixtures/installer/update-whitelist-patterns.test new file mode 100644 index 000000000..ff959dd3e --- /dev/null +++ b/tests/Composer/Test/Fixtures/installer/update-whitelist-patterns.test @@ -0,0 +1,45 @@ +--TEST-- +Update with a package whitelist only updates those corresponding to the pattern +--COMPOSER-- +{ + "repositories": [ + { + "type": "package", + "package": [ + { "name": "vendor/Test-Package", "version": "2.0" }, + { "name": "vendor/NotMe", "version": "2.0" }, + { "name": "exact/Test-Package", "version": "2.0" }, + { "name": "notexact/TestPackage", "version": "2.0" }, + { "name": "all/Package1", "version": "2.0" }, + { "name": "all/Package2", "version": "2.0" }, + { "name": "another/another", "version": "2.0" } + ] + } + ], + "require": { + "vendor/Test-Package": "*.*", + "vendor/NotMe": "*.*", + "exact/Test-Package": "*.*", + "notexact/TestPackage": "*.*", + "all/Package1": "*.*", + "all/Package2": "*.*", + "another/another": "*.*" + } +} +--INSTALLED-- +[ + { "name": "vendor/Test-Package", "version": "1.0" }, + { "name": "vendor/NotMe", "version": "1.0" }, + { "name": "exact/Test-Package", "version": "1.0" }, + { "name": "notexact/TestPackage", "version": "1.0" }, + { "name": "all/Package1", "version": "1.0" }, + { "name": "all/Package2", "version": "1.0" }, + { "name": "another/another", "version": "1.0" } +] +--RUN-- +update vendor/Test.* exact/Test-Package notexact/Test all.* +--EXPECT-- +Updating vendor/Test-Package (1.0) to vendor/Test-Package (2.0) +Updating exact/Test-Package (1.0) to exact/Test-Package (2.0) +Updating all/Package1 (1.0) to all/Package1 (2.0) +Updating all/Package2 (1.0) to all/Package2 (2.0) \ No newline at end of file From e264282ac7260b3fa54e4bf659fb69792fafd188 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Thieriot?= Date: Thu, 13 Dec 2012 14:06:06 +0000 Subject: [PATCH 04/16] Allowed only * wildcard --- doc/03-cli.md | 4 ++-- src/Composer/Installer.php | 4 +++- .../Fixtures/installer/update-whitelist-patterns.test | 11 +++++++---- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/doc/03-cli.md b/doc/03-cli.md index 2a69d7540..a87247482 100644 --- a/doc/03-cli.md +++ b/doc/03-cli.md @@ -96,9 +96,9 @@ If you just want to update a few packages and not all, you can list them as such $ php composer.phar update vendor/package vendor/package2 -You can also use a Regular expression pattern to update a bunch of packages at once: +You can also use wildcards to update a bunch of packages at once: - $ php composer.phar update vendor.* + $ php composer.phar update vendor/* ### Options diff --git a/src/Composer/Installer.php b/src/Composer/Installer.php index dea566eca..ef44d2109 100644 --- a/src/Composer/Installer.php +++ b/src/Composer/Installer.php @@ -625,7 +625,9 @@ class Installer } foreach($this->updateWhitelist as $whiteListedPattern => $void) { - if(preg_match("#^".$whiteListedPattern."$#i", $package->getName())) { + $cleanedWhiteListedPattern = str_replace('\*', '.*', preg_quote($whiteListedPattern)); + + if(preg_match("#^".$cleanedWhiteListedPattern."$#i", $package->getName())) { return true; } } diff --git a/tests/Composer/Test/Fixtures/installer/update-whitelist-patterns.test b/tests/Composer/Test/Fixtures/installer/update-whitelist-patterns.test index ff959dd3e..e8aa593c0 100644 --- a/tests/Composer/Test/Fixtures/installer/update-whitelist-patterns.test +++ b/tests/Composer/Test/Fixtures/installer/update-whitelist-patterns.test @@ -12,7 +12,8 @@ Update with a package whitelist only updates those corresponding to the pattern { "name": "notexact/TestPackage", "version": "2.0" }, { "name": "all/Package1", "version": "2.0" }, { "name": "all/Package2", "version": "2.0" }, - { "name": "another/another", "version": "2.0" } + { "name": "another/another", "version": "2.0" }, + { "name": "no/regexp", "version": "2.0" } ] } ], @@ -23,7 +24,8 @@ Update with a package whitelist only updates those corresponding to the pattern "notexact/TestPackage": "*.*", "all/Package1": "*.*", "all/Package2": "*.*", - "another/another": "*.*" + "another/another": "*.*", + "no/regexp": "*.*" } } --INSTALLED-- @@ -34,10 +36,11 @@ Update with a package whitelist only updates those corresponding to the pattern { "name": "notexact/TestPackage", "version": "1.0" }, { "name": "all/Package1", "version": "1.0" }, { "name": "all/Package2", "version": "1.0" }, - { "name": "another/another", "version": "1.0" } + { "name": "another/another", "version": "1.0" }, + { "name": "no/regexp", "version": "1.0" } ] --RUN-- -update vendor/Test.* exact/Test-Package notexact/Test all.* +update vendor/Test* exact/Test-Package notexact/Test all/* no/reg?xp --EXPECT-- Updating vendor/Test-Package (1.0) to vendor/Test-Package (2.0) Updating exact/Test-Package (1.0) to exact/Test-Package (2.0) From 5fd19f63dd8fee88104e80121246e60d3fe0bbf8 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Thu, 13 Dec 2012 15:37:11 +0100 Subject: [PATCH 05/16] CS fixes, refs #1419 --- src/Composer/Installer.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Composer/Installer.php b/src/Composer/Installer.php index ef44d2109..3ded1c66a 100644 --- a/src/Composer/Installer.php +++ b/src/Composer/Installer.php @@ -624,10 +624,10 @@ class Installer throw new \LogicException('isUpdateable should only be called when a whitelist is present'); } - foreach($this->updateWhitelist as $whiteListedPattern => $void) { - $cleanedWhiteListedPattern = str_replace('\*', '.*', preg_quote($whiteListedPattern)); + foreach ($this->updateWhitelist as $whiteListedPattern => $void) { + $cleanedWhiteListedPattern = str_replace('\\*', '.*', preg_quote($whiteListedPattern)); - if(preg_match("#^".$cleanedWhiteListedPattern."$#i", $package->getName())) { + if (preg_match("#^".$cleanedWhiteListedPattern."$#i", $package->getName())) { return true; } } From b8da471f9a643d4feea9f68ff5f585ccde86dc1d Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Thu, 13 Dec 2012 15:40:47 +0100 Subject: [PATCH 06/16] Clarify transport exception for 403s, fixes #1416 --- src/Composer/Util/RemoteFilesystem.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Composer/Util/RemoteFilesystem.php b/src/Composer/Util/RemoteFilesystem.php index aa1961c5a..882ff4bce 100644 --- a/src/Composer/Util/RemoteFilesystem.php +++ b/src/Composer/Util/RemoteFilesystem.php @@ -229,6 +229,8 @@ class RemoteFilesystem case STREAM_NOTIFY_AUTH_RESULT: if (403 === $messageCode) { + $message = "The '" . $this->fileUrl . "' URL could not be accessed: " . $message; + throw new TransportException($message, 403); } break; From b34e8554d29c21e68a3d439c606bdc03af32fb40 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Thu, 13 Dec 2012 16:54:05 +0100 Subject: [PATCH 07/16] Output info about downloads even with --no-progress and show when reading from cache, refs #1410 --- src/Composer/Downloader/FileDownloader.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Composer/Downloader/FileDownloader.php b/src/Composer/Downloader/FileDownloader.php index 437873492..7f8d8e0b6 100644 --- a/src/Composer/Downloader/FileDownloader.php +++ b/src/Composer/Downloader/FileDownloader.php @@ -96,9 +96,14 @@ class FileDownloader implements DownloaderInterface try { if (!$this->cache || !$this->cache->copyTo($this->getCacheKey($package), $fileName)) { $this->rfs->copy($hostname, $processedUrl, $fileName, $this->outputProgress); + if (!$this->outputProgress) { + $this->io->write(' Downloading'); + } if ($this->cache) { $this->cache->copyFrom($this->getCacheKey($package), $fileName); } + } else { + $this->io->write(' Loading from cache'); } } catch (TransportException $e) { if (404 === $e->getCode() && 'github.com' === $hostname) { From 6bb1b4ae78064086a55c16c8b41c330047a431b9 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Thu, 13 Dec 2012 16:54:21 +0100 Subject: [PATCH 08/16] Fix regex delimiters, refs #1419 --- src/Composer/Installer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Composer/Installer.php b/src/Composer/Installer.php index 3ded1c66a..c6c0ebfa5 100644 --- a/src/Composer/Installer.php +++ b/src/Composer/Installer.php @@ -627,7 +627,7 @@ class Installer foreach ($this->updateWhitelist as $whiteListedPattern => $void) { $cleanedWhiteListedPattern = str_replace('\\*', '.*', preg_quote($whiteListedPattern)); - if (preg_match("#^".$cleanedWhiteListedPattern."$#i", $package->getName())) { + if (preg_match("{^".$cleanedWhiteListedPattern."$}i", $package->getName())) { return true; } } From b0b9c7b0d1e9ba6884cf8d3cb66d90f6ebe3d99c Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Thu, 13 Dec 2012 17:19:58 +0100 Subject: [PATCH 09/16] Add docs for #1410 --- doc/03-cli.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/doc/03-cli.md b/doc/03-cli.md index a87247482..870509c3a 100644 --- a/doc/03-cli.md +++ b/doc/03-cli.md @@ -78,6 +78,8 @@ resolution. `require-dev`. * **--no-scripts:** Skips execution of scripts defined in `composer.json`. * **--no-custom-installers:** Disables custom installers. +* **--no-progress:** Removes the progress display that can mess with some + terminals or scripts which don't handle backspace characters. * **--optimize-autoloader (-o):** Convert PSR-0 autoloading to classmap to get a faster autoloader. This is recommended especially for production, but can take a bit of time to run so it is currently not done by default. @@ -108,6 +110,8 @@ You can also use wildcards to update a bunch of packages at once: * **--dev:** Install packages listed in `require-dev`. * **--no-scripts:** Skips execution of scripts defined in `composer.json`. * **--no-custom-installers:** Disables custom installers. +* **--no-progress:** Removes the progress display that can mess with some + terminals or scripts which don't handle backspace characters. * **--optimize-autoloader (-o):** Convert PSR-0 autoloading to classmap to get a faster autoloader. This is recommended especially for production, but can take a bit of time to run so it is currently not done by default. @@ -133,6 +137,8 @@ to the command. * **--prefer-dist:** Install packages from `dist` when available. * **--dev:** Add packages to `require-dev`. * **--no-update:** Disables the automatic update of the dependencies. +* **--no-progress:** Removes the progress display that can mess with some + terminals or scripts which don't handle backspace characters. ## search @@ -315,6 +321,8 @@ By default the command checks for the packages on packagist.org. * **--no-custom-installers:** Disables custom installers. * **--no-scripts:** Disables the execution of the scripts defined in the root package. +* **--no-progress:** Removes the progress display that can mess with some + terminals or scripts which don't handle backspace characters. * **--keep-vcs:** Skip the deletion of the VCS metadata for the created project. This is mostly useful if you run the command in non-interactive mode. From 51eca2cdfccec6e7f194316e78493f22c27e0a92 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Thu, 13 Dec 2012 17:39:17 +0100 Subject: [PATCH 10/16] Fix matching of classes in trailing non-php text, fixes #1409 --- src/Composer/Autoload/ClassMapGenerator.php | 7 ++++++- .../Test/Autoload/Fixtures/template/template_3.php | 10 ++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 tests/Composer/Test/Autoload/Fixtures/template/template_3.php diff --git a/src/Composer/Autoload/ClassMapGenerator.php b/src/Composer/Autoload/ClassMapGenerator.php index 5a74728f2..0a4db9bdc 100644 --- a/src/Composer/Autoload/ClassMapGenerator.php +++ b/src/Composer/Autoload/ClassMapGenerator.php @@ -121,7 +121,12 @@ class ClassMapGenerator $contents = preg_replace('{^.+?<\?}s', '.*<\?}s', '', $contents); + $contents = preg_replace('{\?>.+<\?}s', '?>'); + if (false !== $pos && false === strpos(substr($contents, $pos), ' + +class inner { } + + + +class trailing { } \ No newline at end of file From 03e355f0634ee7db7dff17142f6c5d29f83e1c0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Haso=C5=88?= Date: Fri, 14 Dec 2012 15:01:48 +0100 Subject: [PATCH 11/16] Fixed topological sorting of packages in AutoloadGenerator --- src/Composer/Autoload/AutoloadGenerator.php | 52 ++++++++----------- .../Test/Autoload/AutoloadGeneratorTest.php | 7 ++- .../autoload_real_files_by_dependency.php | 4 +- .../Fixtures/autoload_real_functions.php | 2 +- 4 files changed, 31 insertions(+), 34 deletions(-) diff --git a/src/Composer/Autoload/AutoloadGenerator.php b/src/Composer/Autoload/AutoloadGenerator.php index 5d6281cf0..00ef6ca06 100644 --- a/src/Composer/Autoload/AutoloadGenerator.php +++ b/src/Composer/Autoload/AutoloadGenerator.php @@ -179,17 +179,12 @@ EOF; { // build package => install path map $packageMap = array(); - array_unshift($packages, $mainPackage); foreach ($packages as $package) { if ($package instanceof AliasPackage) { continue; } - if ($package === $mainPackage) { - $packageMap[] = array($mainPackage, ''); - continue; - } $packageMap[] = array( $package, $installationManager->getInstallPath($package) @@ -209,6 +204,8 @@ EOF; public function parseAutoloads(array $packageMap, PackageInterface $mainPackage) { $sortedPackageMap = $this->sortPackageMap($packageMap); + $sortedPackageMap[] = array($mainPackage, ''); + array_unshift($packageMap, array($mainPackage, '')); $psr0 = $this->parseAutoloadsType($packageMap, 'psr-0', $mainPackage); $classmap = $this->parseAutoloadsType($sortedPackageMap, 'classmap', $mainPackage); @@ -434,6 +431,7 @@ FOOTER; protected function parseAutoloadsType(array $packageMap, $type, PackageInterface $mainPackage) { $autoloads = array(); + foreach ($packageMap as $item) { list($package, $installPath) = $item; @@ -465,49 +463,45 @@ FOOTER; protected function sortPackageMap(array $packageMap) { - $groups = array(); + $positions = array(); $names = array(); - foreach ($packageMap as $key => $item) { - $groups[$key] = array($item); + $indexes = array(); + + foreach ($packageMap as $position => $item) { $mainName = $item[0]->getName(); - foreach ($item[0]->getNames() as $name) { - if (!isset($names[$name])) { - $names[$name] = $name == $mainName ? $key : $mainName; - } - } + $names = array_merge(array_fill_keys($item[0]->getNames(), $mainName), $names); + $names[$mainName] = $mainName; + $indexes[$mainName] = $positions[$mainName] = $position; } foreach ($packageMap as $item) { + $position = $positions[$item[0]->getName()]; foreach (array_merge($item[0]->getRequires(), $item[0]->getDevRequires()) as $link) { $target = $link->getTarget(); if (!isset($names[$target])) { continue; } - $targetKey = $names[$target]; - if (is_string($targetKey)) { - if (!isset($names[$targetKey])) { - continue; - } - $targetKey = $names[$targetKey]; - } - - $packageKey = $names[$item[0]->getName()]; - if ($targetKey <= $packageKey || !isset($groups[$packageKey])) { + $target = $names[$target]; + if ($positions[$target] <= $position) { continue; } - foreach ($groups[$packageKey] as $originalItem) { - $groups[$targetKey][] = $originalItem; - $names[$originalItem[0]->getName()] = $targetKey; + foreach ($positions as $key => $value) { + if ($value >= $position) { + break; + } + $positions[$key]--; } - unset($groups[$packageKey]); + + $positions[$target] = $position - 1; } + asort($positions); } $sortedPackageMap = array(); - foreach ($groups as $group) { - $sortedPackageMap = array_merge($sortedPackageMap, $group); + foreach (array_keys($positions) as $packageName) { + $sortedPackageMap[] = $packageMap[$indexes[$packageName]]; } return $sortedPackageMap; diff --git a/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php b/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php index 6beb39811..f3d819134 100644 --- a/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php +++ b/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php @@ -338,23 +338,26 @@ class AutoloadGeneratorTest extends TestCase $package = new Package('a', '1.0', '1.0'); $package->setAutoload(array('files' => array('root.php'))); $package->setRequires(array(new Link('a', 'z/foo'))); + $package->setRequires(array(new Link('a', 'd/d'))); + $package->setRequires(array(new Link('a', 'e/e'))); $packages = array(); $packages[] = $z = new Package('z/foo', '1.0', '1.0'); $packages[] = $b = new Package('b/bar', '1.0', '1.0'); - $packages[] = $c = new Package('c/lorem', '1.0', '1.0'); $packages[] = $d = new Package('d/d', '1.0', '1.0'); + $packages[] = $c = new Package('c/lorem', '1.0', '1.0'); $packages[] = $e = new Package('e/e', '1.0', '1.0'); $z->setAutoload(array('files' => array('testA.php'))); $z->setRequires(array(new Link('z/foo', 'c/lorem'))); $b->setAutoload(array('files' => array('testB.php'))); - $b->setRequires(array(new Link('b/bar', 'c/lorem'))); + $b->setRequires(array(new Link('b/bar', 'c/lorem'), new Link('b/bar', 'd/d'))); $c->setAutoload(array('files' => array('testC.php'))); $d->setAutoload(array('files' => array('testD.php'))); + $d->setRequires(array(new Link('d/d', 'c/lorem'))); $e->setAutoload(array('files' => array('testE.php'))); $e->setRequires(array(new Link('e/e', 'c/lorem'))); diff --git a/tests/Composer/Test/Autoload/Fixtures/autoload_real_files_by_dependency.php b/tests/Composer/Test/Autoload/Fixtures/autoload_real_files_by_dependency.php index 990e3dfd2..00afd35a9 100644 --- a/tests/Composer/Test/Autoload/Fixtures/autoload_real_files_by_dependency.php +++ b/tests/Composer/Test/Autoload/Fixtures/autoload_real_files_by_dependency.php @@ -40,10 +40,10 @@ class ComposerAutoloaderInitFilesAutoloadOrder require $vendorDir . '/c/lorem/testC.php'; require $vendorDir . '/z/foo/testA.php'; - require $baseDir . '/root.php'; - require $vendorDir . '/b/bar/testB.php'; require $vendorDir . '/d/d/testD.php'; + require $vendorDir . '/b/bar/testB.php'; require $vendorDir . '/e/e/testE.php'; + require $baseDir . '/root.php'; return $loader; } diff --git a/tests/Composer/Test/Autoload/Fixtures/autoload_real_functions.php b/tests/Composer/Test/Autoload/Fixtures/autoload_real_functions.php index 7408075f4..118d45854 100644 --- a/tests/Composer/Test/Autoload/Fixtures/autoload_real_functions.php +++ b/tests/Composer/Test/Autoload/Fixtures/autoload_real_functions.php @@ -38,9 +38,9 @@ class ComposerAutoloaderInitFilesAutoload $loader->register(); - require $baseDir . '/root.php'; require $vendorDir . '/a/a/test.php'; require $vendorDir . '/b/b/test2.php'; + require $baseDir . '/root.php'; return $loader; } From 247b02d077d2eb14e527365eef943f5b1c65412e Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Sat, 15 Dec 2012 18:35:32 +0100 Subject: [PATCH 12/16] Fix minimum-stability handling in InitCommand, fixes #1421 --- src/Composer/Command/InitCommand.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Composer/Command/InitCommand.php b/src/Composer/Command/InitCommand.php index 652eba1d8..2a7132fa5 100644 --- a/src/Composer/Command/InitCommand.php +++ b/src/Composer/Command/InitCommand.php @@ -89,6 +89,11 @@ EOT unset($options['author']); } + if (isset($options['stability'])) { + $options['minimum-stability'] = $options['stability']; + unset($options['stability']); + } + $options['require'] = isset($options['require']) ? $this->formatRequirements($options['require']) : new \stdClass; if (array() === $options['require']) { $options['require'] = new \stdClass; From 45d7eb5b5379bd01d3dd6bb61a6bb42c3ee352b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Haso=C5=88?= Date: Mon, 17 Dec 2012 10:54:48 +0100 Subject: [PATCH 13/16] Fixed generating packageMap in AutoloaderGenerater (fixes generating include_paths.php file) --- src/Composer/Autoload/AutoloadGenerator.php | 7 +++-- .../Test/Autoload/AutoloadGeneratorTest.php | 28 +++++++++++++++++++ 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/src/Composer/Autoload/AutoloadGenerator.php b/src/Composer/Autoload/AutoloadGenerator.php index 00ef6ca06..d6196f3d6 100644 --- a/src/Composer/Autoload/AutoloadGenerator.php +++ b/src/Composer/Autoload/AutoloadGenerator.php @@ -178,7 +178,7 @@ EOF; public function buildPackageMap(InstallationManager $installationManager, PackageInterface $mainPackage, array $packages) { // build package => install path map - $packageMap = array(); + $packageMap = array(array($mainPackage, '')); foreach ($packages as $package) { if ($package instanceof AliasPackage) { @@ -203,9 +203,10 @@ EOF; */ public function parseAutoloads(array $packageMap, PackageInterface $mainPackage) { + $mainPackageMap = array_shift($packageMap); $sortedPackageMap = $this->sortPackageMap($packageMap); - $sortedPackageMap[] = array($mainPackage, ''); - array_unshift($packageMap, array($mainPackage, '')); + $sortedPackageMap[] = $mainPackageMap; + array_unshift($packageMap, $mainPackageMap); $psr0 = $this->parseAutoloadsType($packageMap, 'psr-0', $mainPackage); $classmap = $this->parseAutoloadsType($sortedPackageMap, 'classmap', $mainPackage); diff --git a/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php b/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php index f3d819134..9693d8826 100644 --- a/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php +++ b/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php @@ -524,6 +524,34 @@ EOF; set_include_path($oldIncludePath); } + public function testIncludePathsInMainPackage() + { + $package = new Package('a', '1.0', '1.0'); + $package->setIncludePaths(array('/lib', '/src')); + + $packages = array($a = new Package("a/a", "1.0", "1.0")); + $a->setIncludePaths(array("lib/")); + + $this->repository->expects($this->once()) + ->method("getPackages") + ->will($this->returnValue($packages)); + + mkdir($this->vendorDir."/composer", 0777, true); + + $this->generator->dump($this->config, $this->repository, $package, $this->im, "composer", false, '_12'); + + $oldIncludePath = get_include_path(); + + require $this->vendorDir."/autoload.php"; + + $this->assertEquals( + $this->workingDir."/lib".PATH_SEPARATOR.$this->workingDir."/src".PATH_SEPARATOR.$this->vendorDir."/a/a/lib".PATH_SEPARATOR.$oldIncludePath, + get_include_path() + ); + + set_include_path($oldIncludePath); + } + public function testIncludePathFileWithoutPathsIsSkipped() { $package = new Package('a', '1.0', '1.0'); From 64ca297f9792dd8b9404e1e3f13b713bd72aa514 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Wed, 19 Dec 2012 10:50:39 +0100 Subject: [PATCH 14/16] Autoload dev packages as well for script execution, refs #1430 --- src/Composer/Script/EventDispatcher.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Composer/Script/EventDispatcher.php b/src/Composer/Script/EventDispatcher.php index 48428a664..7e923ab1e 100644 --- a/src/Composer/Script/EventDispatcher.php +++ b/src/Composer/Script/EventDispatcher.php @@ -140,7 +140,10 @@ class EventDispatcher } $generator = new AutoloadGenerator; - $packages = $this->composer->getRepositoryManager()->getLocalRepository()->getPackages(); + $packages = array_merge( + $this->composer->getRepositoryManager()->getLocalRepository()->getPackages(), + $this->composer->getRepositoryManager()->getLocalDevRepository()->getPackages() + ); $packageMap = $generator->buildPackageMap($this->composer->getInstallationManager(), $package, $packages); $map = $generator->parseAutoloads($packageMap, $package); $this->loader = $generator->createLoader($map); From 0e0af00ad97dc96476204c351a7f7972d2f2a27a Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Thu, 20 Dec 2012 13:59:21 +0100 Subject: [PATCH 15/16] Add 5.5 builds on travis --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index a680e4753..81af8c474 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,7 @@ php: - 5.3.3 - 5.3 - 5.4 + - 5.5 before_script: composer install From 1beccf9f0f6fa02f0eda16020e4133aaeb673f67 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Tue, 25 Dec 2012 16:08:36 +0100 Subject: [PATCH 16/16] Fix access of the static loader property --- src/Composer/Autoload/AutoloadGenerator.php | 6 +++--- .../Autoload/Fixtures/autoload_real_files_by_dependency.php | 6 +++--- .../Test/Autoload/Fixtures/autoload_real_functions.php | 6 +++--- .../Test/Autoload/Fixtures/autoload_real_target_dir.php | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Composer/Autoload/AutoloadGenerator.php b/src/Composer/Autoload/AutoloadGenerator.php index d6196f3d6..0691434c3 100644 --- a/src/Composer/Autoload/AutoloadGenerator.php +++ b/src/Composer/Autoload/AutoloadGenerator.php @@ -357,12 +357,12 @@ class ComposerAutoloaderInit$suffix public static function getLoader() { - if (null !== static::\$loader) { - return static::\$loader; + if (null !== self::\$loader) { + return self::\$loader; } spl_autoload_register(array('ComposerAutoloaderInit$suffix', 'loadClassLoader')); - static::\$loader = \$loader = new \\Composer\\Autoload\\ClassLoader(); + self::\$loader = \$loader = new \\Composer\\Autoload\\ClassLoader(); spl_autoload_unregister(array('ComposerAutoloaderInit$suffix', 'loadClassLoader')); \$vendorDir = $vendorPathCode; diff --git a/tests/Composer/Test/Autoload/Fixtures/autoload_real_files_by_dependency.php b/tests/Composer/Test/Autoload/Fixtures/autoload_real_files_by_dependency.php index 00afd35a9..6434b76dd 100644 --- a/tests/Composer/Test/Autoload/Fixtures/autoload_real_files_by_dependency.php +++ b/tests/Composer/Test/Autoload/Fixtures/autoload_real_files_by_dependency.php @@ -15,12 +15,12 @@ class ComposerAutoloaderInitFilesAutoloadOrder public static function getLoader() { - if (null !== static::$loader) { - return static::$loader; + if (null !== self::$loader) { + return self::$loader; } spl_autoload_register(array('ComposerAutoloaderInitFilesAutoloadOrder', 'loadClassLoader')); - static::$loader = $loader = new \Composer\Autoload\ClassLoader(); + self::$loader = $loader = new \Composer\Autoload\ClassLoader(); spl_autoload_unregister(array('ComposerAutoloaderInitFilesAutoloadOrder', 'loadClassLoader')); $vendorDir = dirname(__DIR__); diff --git a/tests/Composer/Test/Autoload/Fixtures/autoload_real_functions.php b/tests/Composer/Test/Autoload/Fixtures/autoload_real_functions.php index 118d45854..a25e920db 100644 --- a/tests/Composer/Test/Autoload/Fixtures/autoload_real_functions.php +++ b/tests/Composer/Test/Autoload/Fixtures/autoload_real_functions.php @@ -15,12 +15,12 @@ class ComposerAutoloaderInitFilesAutoload public static function getLoader() { - if (null !== static::$loader) { - return static::$loader; + if (null !== self::$loader) { + return self::$loader; } spl_autoload_register(array('ComposerAutoloaderInitFilesAutoload', 'loadClassLoader')); - static::$loader = $loader = new \Composer\Autoload\ClassLoader(); + self::$loader = $loader = new \Composer\Autoload\ClassLoader(); spl_autoload_unregister(array('ComposerAutoloaderInitFilesAutoload', 'loadClassLoader')); $vendorDir = dirname(__DIR__); diff --git a/tests/Composer/Test/Autoload/Fixtures/autoload_real_target_dir.php b/tests/Composer/Test/Autoload/Fixtures/autoload_real_target_dir.php index 0964af746..ec8e392be 100644 --- a/tests/Composer/Test/Autoload/Fixtures/autoload_real_target_dir.php +++ b/tests/Composer/Test/Autoload/Fixtures/autoload_real_target_dir.php @@ -15,12 +15,12 @@ class ComposerAutoloaderInitTargetDir public static function getLoader() { - if (null !== static::$loader) { - return static::$loader; + if (null !== self::$loader) { + return self::$loader; } spl_autoload_register(array('ComposerAutoloaderInitTargetDir', 'loadClassLoader')); - static::$loader = $loader = new \Composer\Autoload\ClassLoader(); + self::$loader = $loader = new \Composer\Autoload\ClassLoader(); spl_autoload_unregister(array('ComposerAutoloaderInitTargetDir', 'loadClassLoader')); $vendorDir = dirname(__DIR__);