-
Notifications
You must be signed in to change notification settings - Fork 113
Issue #42 A better way to manage the version on install #90
Changes from 3 commits
f75f252
33e4966
d8ac816
a53a2e8
3bdaaeb
68b8d68
317d0b9
8a892ab
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
use Distill\Exception\IO\Input\FileEmptyException; | ||
use Distill\Exception\IO\Output\TargetDirectoryNotWritableException; | ||
use Distill\Strategy\MinimumSize; | ||
use GuzzleHttp; | ||
use GuzzleHttp\Client; | ||
use GuzzleHttp\Exception\ClientException; | ||
use GuzzleHttp\Message\Response; | ||
|
@@ -122,9 +123,24 @@ private function checkSymfonyVersionIsInstallable() | |
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.M, where N = 0..9 and M = 0..99'); | ||
// validate server syntax | ||
if (!preg_match('/^(2\.\d\.\d{1,2}|2\.\d)$/', $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})|(2\.\d)$/', $this->version)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do you do the check again here? If the regex didn't match, an exception would have been thrown and this code wouldn't be reached. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But you could check for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In fact I meant to check There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I just had a look at 33e4966 and it seems that you just modified the wrong regex. :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, indeed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok fine. When Symfony3 will be released for first stabilization process, we may change the |
||
// Check if we have a minor version | ||
|
||
$client = new Client(); | ||
$json = $client->get('http://symfony.com/versions.json')->getBody()->getContents(); | ||
|
||
if ($json) { | ||
$versionsList = GuzzleHttp\json_decode($json, true); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why not using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that Guzzle's There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. but this function is gone in 5.x, which would make it harder to bump our requirement to the current version (which is something I would like to do) and instead of doing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So do you recommend to entirely use Wasn't aware of |
||
if (isset($versionsList[$this->version])) { | ||
// Get the latest installable of the minor version the user asked | ||
$this->version = $versionsList[$this->version]; | ||
} | ||
} | ||
} | ||
|
||
// 2.0, 2.1, 2.2 and 2.4 cannot be installed because they are unmaintained | ||
|
@@ -241,7 +257,7 @@ private function download() | |
)); | ||
} else { | ||
throw new \RuntimeException(sprintf( | ||
"The selected version (%s) couldn\'t be downloaded because of the following error:\n%s", | ||
"The selected version (%s) couldn't be downloaded because of the following error:\n%s", | ||
$this->version, | ||
$e->getMessage() | ||
)); | ||
|
@@ -553,6 +569,7 @@ private function generateComposerProjectName() | |
/** | ||
* Returns the executed command. | ||
* | ||
* @param string $version A version to add to the command as example, if needed. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You would also have to remove this comment. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Crap, not enough coffee for me this morning, thanks for your note |
||
* @return string | ||
*/ | ||
private function getExecutedCommand() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would use parentheses to distinguish between the two forms of versions: