From 91518db6bd2ac994d50303e7fe64895b98833118 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Fri, 3 Feb 2012 15:29:52 -0600 Subject: [PATCH] dropped submodule support. added upgrade command for bundles. --- bundles/bundles.php | 2 +- laravel/cli/tasks/bundle/bundler.php | 46 +++++++++++++------ .../cli/tasks/bundle/providers/provider.php | 4 +- 3 files changed, 34 insertions(+), 18 deletions(-) diff --git a/bundles/bundles.php b/bundles/bundles.php index 49d126bb..59a9601c 100644 --- a/bundles/bundles.php +++ b/bundles/bundles.php @@ -33,4 +33,4 @@ | */ -return array(); \ No newline at end of file +return array('gravitas'); \ No newline at end of file diff --git a/laravel/cli/tasks/bundle/bundler.php b/laravel/cli/tasks/bundle/bundler.php index 937c0a81..db86e448 100644 --- a/laravel/cli/tasks/bundle/bundler.php +++ b/laravel/cli/tasks/bundle/bundler.php @@ -1,6 +1,7 @@ get($bundles) as $bundle) { - if (is_dir(path('bundle').$bundle['name'])) + if (Bundle::exists($bundle['name'])) { echo "Bundle {$bundle['name']} is already installed."; @@ -48,7 +49,9 @@ public function install($bundles) // Each bundle provider implements the Provider interface and // is repsonsible for retrieving the bundle source from its // 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; } @@ -64,25 +67,38 @@ public function upgrade($bundles) { foreach ($bundles as $name) { - $bundle = Bundle::get($name); - - if (is_nulL($bundle)) + if ( ! Bundle::exists($name)) { - 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') { 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); - $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 @@ public function upgrade($bundles) */ public function publish($bundles) { - // If no bundles are passed to the command, we'll just gather all - // of the installed bundle names and publish the assets for each - // of the bundles to the public directory. + // If no bundles are passed to the command, we'll just gather + // all of the installed bundle names and publish the assets + // for each of the bundles to the public directory. if (count($bundles) == 0) $bundles = Bundle::names(); $publisher = IoC::resolve('bundle.publisher'); @@ -138,7 +154,9 @@ protected function get($bundles) $responses[] = $bundle; - $responses = array_merge($responses, $this->get($bundle['dependencies'])); + $dependencies = $this->get($bundle['dependencies']); + + $responses = array_merge($responses, $dependencies); } return $responses; @@ -151,7 +169,7 @@ protected function get($bundles) * @param string $path * @return void */ - protected function download($bundlem, $path) + protected function download($bundle, $path) { $provider = "bundle.provider: {$bundle['provider']}"; diff --git a/laravel/cli/tasks/bundle/providers/provider.php b/laravel/cli/tasks/bundle/providers/provider.php index ffccf796..5309e5c0 100644 --- a/laravel/cli/tasks/bundle/providers/provider.php +++ b/laravel/cli/tasks/bundle/providers/provider.php @@ -49,9 +49,7 @@ protected function zipball($url, $bundle, $path) // Once we have the latest modified directory, we should be // able to move its contents over into the bundles folder // so the bundle will be usable by the develoepr. - $path = $this->path($bundle); - - File::mvdir($latest, path('bundle').$path); + File::mvdir($latest, $path); @unlink($target); }