Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Add support to capistrano's shared path #1

Closed
wants to merge 4 commits into from

2 participants

@blackjid
Owner

This will make bower to install the components in the application_name/shared folder.

This should improve the running time.

In the deploy.rb you need to add set :linked_dirs, %w{bin bower_components}

@blackjid
Owner

Maybe is not necessary, because bower has a good caching system, so is pretty fast to run bower install every time.

Opinions and thoughts are very welcomed.

@kcm
kcm commented

I actually like using the global cache to reinstall each time. If you re-use the directory, it becomes hard to manage situations where an old asset file still exists after you remove the reference from your bower.json file.

For example, jquery_ujs included the test/ directory via bower, and that would fail in asset compilation (running the tests overlapped in some namespaces). If I removed jquery_ujs from my bower.js, a shared app/assets/components/ directory would still have the crufty jquery_ujs files, no?

@blackjid
Owner

Hi ken, you are right, that's one of the reasons I'm a little hesitant of merging this feature. Maybe one alternative would be run bower prune after bower install that way all the orphan components should be removed.

@blackjid blackjid closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 1, 2013
  1. @blackjid

    Adds cwd config and change default dir property value

    blackjid authored
    Conflicts:
    	README.md
    	lib/capistrano/tasks/bower.tasks
  2. @blackjid
  3. @blackjid
  4. @blackjid

    Update readme

    blackjid authored
This page is out of date. Refresh to see the latest.
Showing with 13 additions and 0 deletions.
  1. +4 −0 README.md
  2. +9 −0 lib/capistrano/tasks/bower.tasks
View
4 README.md
@@ -28,9 +28,13 @@ or can be run in isolation with `cap production bower:install`
Configurable options, shown here with defaults:
+ set :bower_dir, -> { (shared_path.relative_path_from release_path).join((JSON.parse(File.read(".bowerrc")) rescue {}).fetch("directory", "bower_components")) }
+ set :bower_cwd, -> { release_path }
set :bower_flags, '--quiet'
set :bower_roles, :all
+NOTE: bower doesn't support installing packages to an absoulte path. When the directory property is used, it's always relative to the cwd property. That's why in the default value I had to use the `relative_path_from` method from the release path.
+
## Contributing
1. Fork it
View
9 lib/capistrano/tasks/bower.tasks
@@ -1,3 +1,6 @@
+require 'pathname'
+require 'json'
+
namespace :bower do
desc <<-DESC
Install the current Bower environment. The install command is executed \
@@ -5,6 +8,8 @@ namespace :bower do
You can override any of these defaults by setting the variables shown below.
+ set :bower_dir, -> { (shared_path.relative_path_from release_path).join((JSON.parse(File.read(".bowerrc")) rescue {}).fetch("directory", "bower_components")) }
+ set :bower_cwd, -> { release_path }
set :bower_flags, '--quiet'
set :bower_roles, :all
DESC
@@ -12,6 +17,8 @@ namespace :bower do
on roles fetch(:bower_roles) do
within release_path do
execute :bower, "install",
+ "--config.directory=#{fetch(:bower_dir)}",
+ "--config.cwd=#{fetch(:bower_cwd)}",
fetch(:bower_flags)
end
end
@@ -22,6 +29,8 @@ end
namespace :load do
task :defaults do
+ set :bower_dir, -> { (shared_path.relative_path_from release_path).join((JSON.parse(File.read(".bowerrc")) rescue {}).fetch("directory", "bower_components")) }
+ set :bower_cwd, -> { release_path }
set :bower_flags, '--quiet'
set :bower_roles, :all
end
Something went wrong with that request. Please try again.