Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save greendog/631445 to your computer and use it in GitHub Desktop.
Save greendog/631445 to your computer and use it in GitHub Desktop.
# Spree extension capistrano tasks
# --------------------------------
# $ cap extension:site:update
# $ cap deploy:restart
#Or remove my snippets extension (not that I would, it's an integral part of the site)
# $ cap extension:snippets:remove
# $ cap deploy:restart
#Or install a new extension (after adding it to the extensions hash)
# $ cap extension:deprecate_user_agents:install
# $ cap deploy:migrate
# $ cap deploy:restart
#
# by Christopher Maujean
#
# These tasks depend on the existence of the extensions hash.
# The key is name of the directory in vendor/extensions.
# The value is the git url of the extension.
#
# set :extensions, {
# 'my_site' => "git@github.com:/username/spree-my-site.git"
# 'ship_notification' => "git://github.com/azimuth/spree-ship-notification.git",
# 'sitemaps' => "git://github.com/stephp/spree-sitemaps.git",
# 'snippets' => "git://github.com/cmaujean/spree-snippets.git"
# }
#
# $ cap -T extension
# cap deploy:install_extensions # Install all the spree extensions th...
# cap extension:my_site:install # Install my_site extension
# cap extension:my_site:remove # Remove my_site extension
# cap extension:my_site:update # update my_site extension
# cap extension:ship_notification:install # Install ship_notification extension
# cap extension:ship_notification:remove # Remove ship_notification extension
# cap extension:ship_notification:update # update ship_notification extension
# cap extension:sitemaps:install # Install sitemaps extension
# cap extension:sitemaps:remove # Remove sitemaps extension
# cap extension:sitemaps:update # update sitemaps extension
# cap extension:snippets:install # Install snippets extension
# cap extension:snippets:remove # Remove snippets extension
# cap extension:snippets:update # update snippets extension
#
namespace :deploy do
desc "Install all the spree extensions that this app requires"
task :install_extensions, :roles => :app do
extensions.each do |name,location|
puts "Installing #{name} extension from #{location}"
run "cd #{release_path} && script/extension install #{location}"
end
end
end
# dynamic set of tasks based on the extension hash above
namespace :extension do
extensions.each do |name, location|
namespace name.to_sym do
desc "Install #{name} extension"
task :install, :roles => :app do
run "cd #{current_path} && script/extension install #{location}"
end
desc "Remove #{name} extension"
task :remove, :roles => :app do
run "cd #{current_path} && script/extension remove #{name}"
end
desc "update #{name} extension"
task :update, :roles => :app do
run "cd #{current_path} && script/extension install #{location} --force"
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment