Commit 91518db6 authored by Taylor Otwell's avatar Taylor Otwell

dropped submodule support. added upgrade command for bundles.

parent ea42fe75
...@@ -33,4 +33,4 @@ ...@@ -33,4 +33,4 @@
| |
*/ */
return array(); return array('gravitas');
\ No newline at end of file \ No newline at end of file
<?php namespace Laravel\CLI\Tasks\Bundle; defined('DS') or die('No direct script access.'); <?php namespace Laravel\CLI\Tasks\Bundle; defined('DS') or die('No direct script access.');
use Laravel\IoC; use Laravel\IoC;
use Laravel\File;
use Laravel\Bundle; use Laravel\Bundle;
use Laravel\CLI\Tasks\Task; use Laravel\CLI\Tasks\Task;
...@@ -34,7 +35,7 @@ class Bundler extends Task { ...@@ -34,7 +35,7 @@ class Bundler extends Task {
{ {
foreach ($this->get($bundles) as $bundle) foreach ($this->get($bundles) as $bundle)
{ {
if (is_dir(path('bundle').$bundle['name'])) if (Bundle::exists($bundle['name']))
{ {
echo "Bundle {$bundle['name']} is already installed."; echo "Bundle {$bundle['name']} is already installed.";
...@@ -48,7 +49,9 @@ class Bundler extends Task { ...@@ -48,7 +49,9 @@ class Bundler extends Task {
// Each bundle provider implements the Provider interface and // Each bundle provider implements the Provider interface and
// is repsonsible for retrieving the bundle source from its // is repsonsible for retrieving the bundle source from its
// hosting party and installing it into the application. // hosting party and installing it into the application.
$this->download($bundle, $this->path($bundle)); $path = path('bundle').$this->path($bundle);
$this->download($bundle, $path);
echo "Bundle [{$bundle['name']}] has been installed!".PHP_EOL; echo "Bundle [{$bundle['name']}] has been installed!".PHP_EOL;
} }
...@@ -64,25 +67,38 @@ class Bundler extends Task { ...@@ -64,25 +67,38 @@ class Bundler extends Task {
{ {
foreach ($bundles as $name) foreach ($bundles as $name)
{ {
$bundle = Bundle::get($name); if ( ! Bundle::exists($name))
if (is_nulL($bundle))
{ {
throw new \Exception("Bundle [{$name}] is not installed!"); echo "Bundle [{$name}] is not installed!";
continue;
} }
$data = $this->retrieve($bundle); // First we want to retrieve the information for the bundle,
// such as where it is currently installed. This will let
// us upgrade the bundle into the same path in which it
// is already installed.
$bundle = Bundle::get($name);
// If the bundle exists, we will grab the data about the
// bundle from the API so we can make the right bundle
// provider for the bundle, since we have no way of
// knowing which provider was used to install.
$response = $this->retrieve($name);
if ($response['status'] == 'not-found') if ($response['status'] == 'not-found')
{ {
continue; continue;
} }
// Once we have the bundle information from the API,
// we'll simply recursively delete the bundle and
// then re-download it using the provider.
File::rmdir($bundle->location); File::rmdir($bundle->location);
$this->download($bundle, $bundle->location); $this->download($response['bundle'], $bundle->location);
echo "Bundle [{$bundle['name']}] has been upgraded!".PHP_EOL; echo "Bundle [{$name}] has been upgraded!".PHP_EOL;
} }
} }
...@@ -94,9 +110,9 @@ class Bundler extends Task { ...@@ -94,9 +110,9 @@ class Bundler extends Task {
*/ */
public function publish($bundles) public function publish($bundles)
{ {
// If no bundles are passed to the command, we'll just gather all // If no bundles are passed to the command, we'll just gather
// of the installed bundle names and publish the assets for each // all of the installed bundle names and publish the assets
// of the bundles to the public directory. // for each of the bundles to the public directory.
if (count($bundles) == 0) $bundles = Bundle::names(); if (count($bundles) == 0) $bundles = Bundle::names();
$publisher = IoC::resolve('bundle.publisher'); $publisher = IoC::resolve('bundle.publisher');
...@@ -138,7 +154,9 @@ class Bundler extends Task { ...@@ -138,7 +154,9 @@ class Bundler extends Task {
$responses[] = $bundle; $responses[] = $bundle;
$responses = array_merge($responses, $this->get($bundle['dependencies'])); $dependencies = $this->get($bundle['dependencies']);
$responses = array_merge($responses, $dependencies);
} }
return $responses; return $responses;
...@@ -151,7 +169,7 @@ class Bundler extends Task { ...@@ -151,7 +169,7 @@ class Bundler extends Task {
* @param string $path * @param string $path
* @return void * @return void
*/ */
protected function download($bundlem, $path) protected function download($bundle, $path)
{ {
$provider = "bundle.provider: {$bundle['provider']}"; $provider = "bundle.provider: {$bundle['provider']}";
......
...@@ -49,9 +49,7 @@ abstract class Provider { ...@@ -49,9 +49,7 @@ abstract class Provider {
// Once we have the latest modified directory, we should be // Once we have the latest modified directory, we should be
// able to move its contents over into the bundles folder // able to move its contents over into the bundles folder
// so the bundle will be usable by the develoepr. // so the bundle will be usable by the develoepr.
$path = $this->path($bundle); File::mvdir($latest, $path);
File::mvdir($latest, path('bundle').$path);
@unlink($target); @unlink($target);
} }
......
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