diff --git a/src/Symfony/Installer/NewCommand.php b/src/Symfony/Installer/NewCommand.php index fc6d67b..15413c2 100644 --- a/src/Symfony/Installer/NewCommand.php +++ b/src/Symfony/Installer/NewCommand.php @@ -105,19 +105,14 @@ protected function execute(InputInterface $input, OutputInterface $output) protected function checkSymfonyVersionIsInstallable() { // 'latest' is a special version name that refers to the latest stable version - // available at the moment of installing Symfony - if ('latest' === $this->version) { - return $this; - } - // 'lts' is a special version name that refers to the current long term support version - if ('lts' === $this->version) { + if (in_array($this->version, array('latest', 'lts'))) { return $this; } // validate semver syntax - if (!preg_match('/^2\.\d(?:\.\d{1,2})?$/', $this->version)) { - throw new \RuntimeException('The Symfony version should be 2.N or 2.N.M, where N = 0..9 and M = 0..99'); + if (!preg_match('/^2\.\d(?:\.\d{1,2})?(?:-(?:dev|BETA\d*|RC\d*))?$/i', $this->version)) { + throw new \RuntimeException('The Symfony version must be 2.N or 2.N.M (where N and M are positive integers). The special "-dev", "-BETA" and "-RC" versions are also supported.'); } if (preg_match('/^2\.\d$/', $this->version)) { @@ -175,6 +170,25 @@ protected function checkSymfonyVersionIsInstallable() )); } + // "-dev" versions are not supported because Symfony doesn't provide packages for them + if (preg_match('/^.*\-dev$/i', $this->version)) { + throw new \RuntimeException(sprintf( + "The selected version (%s) cannot be installed because it hasn't\n". + "been published as a package yet. Read the following article for\n". + "an alternative installation method:\n\n". + "> How to Install or Upgrade to the Latest, Unreleased Symfony Version\n". + '> http://symfony.com/doc/current/cookbook/install/unstable_versions.html', + $this->version + )); + } + + // warn the user when downloading an unstable version + if (preg_match('/^.*\-(BETA|RC)\d*$/i', $this->version)) { + $this->output->writeln("\n WARNING You are downloading an unstable Symfony version."); + // versions provided by the download server are case sensitive + $this->version = strtoupper($this->version); + } + return $this; } diff --git a/tests/Symfony/Installer/Tests/IntegrationTest.php b/tests/Symfony/Installer/Tests/IntegrationTest.php index d632025..21a6e17 100644 --- a/tests/Symfony/Installer/Tests/IntegrationTest.php +++ b/tests/Symfony/Installer/Tests/IntegrationTest.php @@ -106,6 +106,12 @@ public function provideSymfonyInstallationData() '/.*Symfony 2\.5\.6 was successfully installed.*/', '/Symfony version 2\.5\.6 - app\/dev\/debug/', ), + + array( + '2.7.0-BETA1', + '/.*Symfony 2\.7\.0\-BETA1 was successfully installed.*/', + '/Symfony version 2\.7\.0\-BETA1 - app\/dev\/debug/', + ), ); } }