|
15 | 15 | use Symfony\Component\Console\Input\InputInterface;
|
16 | 16 | use Symfony\Component\Console\Output\OutputInterface;
|
17 | 17 | use Symfony\Installer\Exception\AbortException;
|
| 18 | +use Symfony\Component\Console\Question\ConfirmationQuestion; |
18 | 19 |
|
19 | 20 | /**
|
20 | 21 | * This command creates new Symfony projects for the given Symfony version.
|
@@ -69,7 +70,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
|
69 | 70 | aborted:
|
70 | 71 |
|
71 | 72 | $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>'); |
73 | 74 |
|
74 | 75 | $this->cleanUp();
|
75 | 76 |
|
@@ -104,20 +105,17 @@ protected function execute(InputInterface $input, OutputInterface $output)
|
104 | 105 | */
|
105 | 106 | protected function checkSymfonyVersionIsInstallable()
|
106 | 107 | {
|
| 108 | + // Available at the moment of installing Symfony with this installer. |
107 | 109 | // '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 |
| - |
113 | 110 | // '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'))) { |
115 | 113 | return $this;
|
116 | 114 | }
|
117 | 115 |
|
118 | 116 | // 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.'); |
121 | 119 | }
|
122 | 120 |
|
123 | 121 | if (preg_match('/^2\.\d$/', $this->version)) {
|
@@ -178,6 +176,31 @@ protected function checkSymfonyVersionIsInstallable()
|
178 | 176 | return $this;
|
179 | 177 | }
|
180 | 178 |
|
| 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 | + |
181 | 204 | /**
|
182 | 205 | * Removes all the temporary files and directories created to
|
183 | 206 | * download the project and removes Symfony-related files that don't make
|
|
0 commit comments