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

Commit d58812a

Browse files
94nonijaviereguiluz
authored andcommitted
Installation dev/beta versions (143)
1 parent 9638151 commit d58812a

File tree

1 file changed

+32
-9
lines changed

1 file changed

+32
-9
lines changed

src/Symfony/Installer/NewCommand.php

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Symfony\Component\Console\Input\InputInterface;
1616
use Symfony\Component\Console\Output\OutputInterface;
1717
use Symfony\Installer\Exception\AbortException;
18+
use Symfony\Component\Console\Question\ConfirmationQuestion;
1819

1920
/**
2021
* This command creates new Symfony projects for the given Symfony version.
@@ -69,7 +70,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
6970
aborted:
7071

7172
$output->writeln('');
72-
$output->writeln('<error>Aborting download and cleaning up temporary directories.</>');
73+
$output->writeln('<error>Aborting download and cleaning up temporary directories.</error>');
7374

7475
$this->cleanUp();
7576

@@ -104,20 +105,17 @@ protected function execute(InputInterface $input, OutputInterface $output)
104105
*/
105106
protected function checkSymfonyVersionIsInstallable()
106107
{
108+
// Available at the moment of installing Symfony with this installer.
107109
// 'latest' is a special version name that refers to the latest stable version
108-
// available at the moment of installing Symfony
109-
if ('latest' === $this->version) {
110-
return $this;
111-
}
112-
113110
// 'lts' is a special version name that refers to the current long term support version
114-
if ('lts' === $this->version) {
111+
// 'dev' is a special version name that refers to the current development version
112+
if (in_array($this->version, array('latest', 'lts', 'dev'))) {
115113
return $this;
116114
}
117115

118116
// validate semver syntax
119-
if (!preg_match('/^2\.\d(?:\.\d{1,2})?$/', $this->version)) {
120-
throw new \RuntimeException('The Symfony version should be 2.N or 2.N.M, where N = 0..9 and M = 0..99');
117+
if (!preg_match('/^2\.\d(?:\.\d{1,2})?(-(dev|BETA)\d*)?$/', $this->version)) {
118+
throw new \RuntimeException('The Symfony version should be 2.N or 2.N.M, where N = 0..9 and M = 0..99.');
121119
}
122120

123121
if (preg_match('/^2\.\d$/', $this->version)) {
@@ -178,6 +176,31 @@ protected function checkSymfonyVersionIsInstallable()
178176
return $this;
179177
}
180178

179+
/**
180+
* @param InputInterface $input
181+
* @param OutputInterface $output
182+
*
183+
* @return NewCommand
184+
*
185+
* @throws AbortException If the user wants to stop the download process in case of dev/BETA versions
186+
*/
187+
protected function askUserConfirmation(InputInterface $input, OutputInterface $output)
188+
{
189+
if (preg_match('/^(\d\.\d)(\.\d{1,2})?-(dev|BETA)\d*$/', $this->version)) {
190+
$helper = $this->getHelper('question');
191+
$question = new ConfirmationQuestion(
192+
sprintf('<question>You are trying to install an unstable version (%s). Do you confirm this action? [y/n]</question>', $this->version),
193+
false
194+
);
195+
196+
if (!$helper->ask($input, $output, $question)) {
197+
throw new AbortException();
198+
}
199+
}
200+
201+
return $this;
202+
}
203+
181204
/**
182205
* Removes all the temporary files and directories created to
183206
* download the project and removes Symfony-related files that don't make

0 commit comments

Comments
 (0)