Module: Capistrano::NewArtrailsCapistrano::FrontHelpers
- Defined in:
- lib/capistrano/new_artrails_capistrano/front_helpers.rb
Instance Method Summary collapse
- #front_branch ⇒ Object
- #front_checkout_command ⇒ Object
- #front_command ⇒ Object
-
#front_copy_command ⇒ Object
do not delete Rails’ Apache served folders.
- #front_dist_dir_name ⇒ Object
- #front_install_command ⇒ Object
- #front_local_cache ⇒ Object
- #front_release_path ⇒ Object
- #front_remote_cache ⇒ Object
- #front_revision ⇒ Object
- #front_rsync_credentials ⇒ Object
- #front_rsync_exclude ⇒ Object
- #front_rsync_include ⇒ Object
- #front_rsync_options ⇒ Object
- #front_rsync_remote_cache ⇒ Object
- #front_sync_command ⇒ Object
Instance Method Details
#front_branch ⇒ Object
7 8 9 |
# File 'lib/capistrano/new_artrails_capistrano/front_helpers.rb', line 7 def front_branch fetch(:front_branch) || 'master' end |
#front_checkout_command ⇒ Object
81 82 83 84 85 86 87 88 89 |
# File 'lib/capistrano/new_artrails_capistrano/front_helpers.rb', line 81 def front_checkout_command fetch(:front_checkout_command) || <<-CMD git clone #{fetch(:front_repo_url)} #{front_local_cache} && cd #{front_local_cache} && git checkout -b deploy/#{front_branch} #{front_revision} && #{front_install_command} CMD end |
#front_command ⇒ Object
91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/capistrano/new_artrails_capistrano/front_helpers.rb', line 91 def front_command if (File.exists?(front_local_cache) && File.directory?(front_local_cache)) puts "[FRONT] updating front local cache to revision #{front_revision}" cmd = front_sync_command end unless (File.exists?(front_local_cache) || File.directory?(front_local_cache)) puts "[FRONT] creating front local cache with revision #{front_revision}" File.delete(front_local_cache) if File.exists?(front_local_cache) Dir.mkdir(File.dirname(front_local_cache)) unless File.directory?(File.dirname(front_local_cache)) cmd = front_checkout_command end cmd.gsub("\n", '') end |
#front_copy_command ⇒ Object
do not delete Rails’ Apache served folders
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/capistrano/new_artrails_capistrano/front_helpers.rb', line 42 def front_copy_command assets_prefix = fetch(:assets_prefix) || 'assets' keeps = fetch(:backend_dirs_or_files_to_keep_in_public) || ([assets_prefix] + %w[ images system upload download]) if keeps.empty? keep_string = '' else keep_string = ' ' + keeps.map { |keep| "--exclude=\'#{keep}\'" }.join(' ').to_s end "rsync -a --no-p --no-g --delete#{keep_string}" end |
#front_dist_dir_name ⇒ Object
25 26 27 |
# File 'lib/capistrano/new_artrails_capistrano/front_helpers.rb', line 25 def front_dist_dir_name fetch(:front_dist_dir_name) || 'dist' end |
#front_install_command ⇒ Object
61 62 63 64 65 66 67 68 69 |
# File 'lib/capistrano/new_artrails_capistrano/front_helpers.rb', line 61 def front_install_command fetch(:front_install_command) || <<-CMD npm install && bower install && gulp clean && gulp build CMD end |
#front_local_cache ⇒ Object
15 16 17 18 19 |
# File 'lib/capistrano/new_artrails_capistrano/front_helpers.rb', line 15 def front_local_cache front_application = fetch(:front_application) # "-#{fetch(:stage)}" fetch(:front_local_cache) || "/tmp/.#{front_application}_rsync_cache" end |
#front_release_path ⇒ Object
57 58 59 |
# File 'lib/capistrano/new_artrails_capistrano/front_helpers.rb', line 57 def front_release_path File.join(release_path, 'public') end |
#front_remote_cache ⇒ Object
106 107 108 109 110 111 112 |
# File 'lib/capistrano/new_artrails_capistrano/front_helpers.rb', line 106 def front_remote_cache lambda do cache = front_rsync_remote_cache cache = deploy_to + '/' + cache if cache && cache !~ /^\// cache end end |
#front_revision ⇒ Object
53 54 55 |
# File 'lib/capistrano/new_artrails_capistrano/front_helpers.rb', line 53 def front_revision @front_revision ||= `git ls-remote #{fetch(:front_repo_url)} #{front_branch}`.split("\t").first end |
#front_rsync_credentials ⇒ Object
21 22 23 |
# File 'lib/capistrano/new_artrails_capistrano/front_helpers.rb', line 21 def front_rsync_credentials fetch(:local_user) end |
#front_rsync_exclude ⇒ Object
37 38 39 |
# File 'lib/capistrano/new_artrails_capistrano/front_helpers.rb', line 37 def front_rsync_exclude fetch(:front_rsync_exclude) || fetch(:rsync_exclude) end |
#front_rsync_include ⇒ Object
33 34 35 |
# File 'lib/capistrano/new_artrails_capistrano/front_helpers.rb', line 33 def front_rsync_include fetch(:front_rsync_include) || fetch(:rsync_include) end |
#front_rsync_options ⇒ Object
29 30 31 |
# File 'lib/capistrano/new_artrails_capistrano/front_helpers.rb', line 29 def fetch(:front_rsync_options) || fetch(:rsync_options) end |
#front_rsync_remote_cache ⇒ Object
11 12 13 |
# File 'lib/capistrano/new_artrails_capistrano/front_helpers.rb', line 11 def front_rsync_remote_cache fetch(:front_remote_cache) || "shared/front-cached-copy-#{fetch(:local_user) || 'deploy'}" end |
#front_sync_command ⇒ Object
70 71 72 73 74 75 76 77 78 79 |
# File 'lib/capistrano/new_artrails_capistrano/front_helpers.rb', line 70 def front_sync_command fetch(:front_sync_command) || <<-CMD cd #{front_local_cache} && git fetch #{fetch(:front_repo_url)} #{front_branch} && git fetch --tags #{fetch(:front_repo_url)} #{front_branch} && git reset --hard #{front_revision} && #{front_install_command} CMD end |