Commit b2a2515c authored by Taylor Otwell's avatar Taylor Otwell

add ability to install dev version

parent cf4b285b
...@@ -7,6 +7,7 @@ use RuntimeException; ...@@ -7,6 +7,7 @@ use RuntimeException;
use GuzzleHttp\Client; use GuzzleHttp\Client;
use Symfony\Component\Process\Process; use Symfony\Component\Process\Process;
use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
...@@ -23,7 +24,8 @@ class NewCommand extends Command ...@@ -23,7 +24,8 @@ class NewCommand extends Command
$this $this
->setName('new') ->setName('new')
->setDescription('Create a new Laravel application.') ->setDescription('Create a new Laravel application.')
->addArgument('name', InputArgument::REQUIRED); ->addArgument('name', InputArgument::REQUIRED)
->addOption('dev', null, InputOption::VALUE_NONE, 'Installs the latest "development" release');
} }
/** /**
...@@ -42,7 +44,9 @@ class NewCommand extends Command ...@@ -42,7 +44,9 @@ class NewCommand extends Command
$output->writeln('<info>Crafting application...</info>'); $output->writeln('<info>Crafting application...</info>');
$this->download($zipFile = $this->makeFilename()) $version = $this->getVersion($input);
$this->download($zipFile = $this->makeFilename(), $version)
->extract($zipFile, $directory) ->extract($zipFile, $directory)
->cleanUp($zipFile); ->cleanUp($zipFile);
...@@ -91,11 +95,21 @@ class NewCommand extends Command ...@@ -91,11 +95,21 @@ class NewCommand extends Command
* Download the temporary Zip to the given file. * Download the temporary Zip to the given file.
* *
* @param string $zipFile * @param string $zipFile
* @param string $version
* @return $this * @return $this
*/ */
protected function download($zipFile) protected function download($zipFile, $version = 'master')
{ {
$response = (new Client)->get('http://cabinet.laravel.com/latest.zip'); switch ($version) {
case 'master':
$filename = 'latest.zip';
break;
case 'develop':
$filename = 'latest-develop.zip';
break;
}
$response = (new Client)->get('http://cabinet.laravel.com/'.$filename);
file_put_contents($zipFile, $response->getBody()); file_put_contents($zipFile, $response->getBody());
...@@ -137,6 +151,21 @@ class NewCommand extends Command ...@@ -137,6 +151,21 @@ class NewCommand extends Command
return $this; return $this;
} }
/**
* Get the version that should be downloaded.
*
* @param \Symfony\Component\Console\Input\InputInterface
* @return string
*/
protected function getVersion($input)
{
if ($input->getOption('dev')) {
return 'develop';
}
return 'master';
}
/** /**
* Get the composer command for the environment. * Get the composer command for the environment.
* *
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment