Skip to content
This repository was archived by the owner on Nov 14, 2019. It is now read-only.

Improve the installation of -dev and -BETA versions #185

Merged
merged 13 commits into from
Sep 28, 2015
Merged
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 20 additions & 8 deletions src/Symfony/Installer/NewCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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*))?$/i', $this->version)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should use non-capturing groups here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've changed it by this: '/^2\.\d(?:\.\d{1,2})?(?:-(?:dev|BETA\d*))?$/i'

throw new \RuntimeException('The Symfony version should be 2.N or 2.N.M, where N = 0..9 and M = 0..99. The special "-dev" or "-BETA" suffixes are also supported.');
}

if (preg_match('/^2\.\d$/', $this->version)) {
Expand Down Expand Up @@ -175,6 +170,23 @@ 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\d*$/i', $this->version)) {
$this->output->writeln("\n <bg=red> WARNING </> You are downloading an unstable Symfony version.");
}

return $this;
}

Expand Down