Commit 14ab7c4e authored by Taylor Otwell's avatar Taylor Otwell

tweaking github provider.

parent a6c083f3
<?php namespace Laravel\CLI\Tasks\Bundle\Providers; <?php namespace Laravel\CLI\Tasks\Bundle\Providers;
class Github implements Provider { class Github extends Provider {
/** /**
* Install the given bundle into the application. * Install the given bundle into the application.
...@@ -10,17 +10,35 @@ class Github implements Provider { ...@@ -10,17 +10,35 @@ class Github implements Provider {
*/ */
public function install($bundle) public function install($bundle)
{ {
$repository = "git@github.com:{$bundle['location']}.git"; $method = (Request::server('cli.zip')) ? 'zipball' : 'submodule';
$this->$method($bundle);
}
/**
* Install a Github hosted bundle from Zip.
*
* @param string $bundle
* @return void
*/
protected function zipball($bundle)
{
$zip = "https://github.com/{$bundle['location']}/zipball/master";
$path = array_get($bundle, 'path', $bundle['name']); parent::zipball($zip, true);
}
/**
* Install a Github hosted bundle using submodules.
*
* @param string $bundle
* @return void
*/
protected function submodule($bundle)
{
$repository = "git@github.com:{$bundle['location']}.git";
// If the installation target directory doesn't exist, we will create $this->directory($bundle);
// it recursively so that we can properly add the Git submodule for
// the bundle when we install.
if ( ! is_dir($target = dirname(path('bundle').$path)))
{
mkdir($target, 0777, true);
}
// We need to just extract the basename of the bundle path when // We need to just extract the basename of the bundle path when
// adding the submodule. Of course, we can't add a submodule to // adding the submodule. Of course, we can't add a submodule to
...@@ -28,7 +46,7 @@ class Github implements Provider { ...@@ -28,7 +46,7 @@ class Github implements Provider {
// the full bundle path. // the full bundle path.
$root = basename(path('bundle')).'/'; $root = basename(path('bundle')).'/';
passthru('git submodule add '.$repository.' '.$root.$path); passthru('git submodule add '.$repository.' '.$root.$this->path($bundle));
passthru('git submodule update'); passthru('git submodule update');
} }
......
<?php namespace Laravel\CLI\Tasks\Bundle\Providers; <?php namespace Laravel\CLI\Tasks\Bundle\Providers;
interface Provider { abstract class Provider {
/** /**
* Install the given bundle into the application. * Install the given bundle into the application.
...@@ -8,6 +8,36 @@ interface Provider { ...@@ -8,6 +8,36 @@ interface Provider {
* @param string $bundle * @param string $bundle
* @return void * @return void
*/ */
public function install($bundle); abstract public function install($bundle);
/**
* Create the path to the bundle's dirname.
*
* @param array $bundle
* @return void
*/
protected function directory($bundle)
{
// If the installation target directory doesn't exist, we will create
// it recursively so that we can properly install the bundle to the
// correct path in the application.
$target = dirname(path('bundle').$this->path($bundle));
if ( ! is_dir($target))
{
mkdir($target, 0777, true);
}
}
/**
* Return the path for a given bundle.
*
* @param array $bundle
* @return string
*/
protected function path($bundle)
{
return array_get($bundle, 'path', $bundle['name']);
}
} }
\ No newline at end of file
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