capistrano-rails 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: dcd91a978e99c58547d28d3049fec73695c4f518
4
+ data.tar.gz: f6e20bd2b13cdc0f55e39b1bcf2fdad3d16cc4b5
5
+ SHA512:
6
+ metadata.gz: 8be01bc08a5084597616374ce6497038c69ebba06a42832b2b64edb56130720e1c2f7ed3106274befa02706f67630b94a9c2efb6ff082523fc1d87a2cc7bfe3a
7
+ data.tar.gz: 53d8decbff18ca1d824a8032b9118ff687c2403a1733b02b7d138fc17eaa0aabe5933c6096c67a66f05ad9a464d3b9beb0b34965039f757465bc3465a6313f75
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
@@ -0,0 +1,6 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.3
5
+ before_install: gem install bundler -v '~> 1.14' --conservative
6
+ before_script: bundle exec danger
@@ -0,0 +1,85 @@
1
+ # [master][]
2
+
3
+ * Your contribution here!
4
+
5
+ # [1.3.0][] (Jun 9 2017)
6
+
7
+ * rails_assets_groups config option to set RAILS_GROUPS (https://github.com/capistrano/rails/pull/135)
8
+
9
+ # [1.2.3][] (Mar 4 2017)
10
+
11
+ * [#200](https://github.com/capistrano/rails/pull/200): Don't link public/assets if public is already linked - [@mattbrictson](https://github.com/mattbrictson)
12
+
13
+ # [1.2.2][] (Jan 10 2017)
14
+
15
+ * Restored compatibility with older versions of Rake (< 11.0.0), introduced in previous change. (@toupeira)
16
+
17
+ # [1.2.1][] (Dec 23 2016)
18
+
19
+ * Diff db directory recursively
20
+ * Avoid warning while running migrations on multiple servers (#189)
21
+
22
+ # [1.2.0][] (Oct 25 2016)
23
+
24
+ * Diff entire db directory when determining if migrations are needed
25
+
26
+ # 1.1.8 (Sep 13 2016)
27
+
28
+ * Handle arrays passed into `normalize_asset_timestamps` correctly (#184)
29
+
30
+ # 1.1.7 (Jun 10 2016)
31
+
32
+ * call `Array#uniq` in `deploy:set_linked_dirs` task to remove duplicated :linked_dirs
33
+ * Add `migration_servers` configuration (#168)
34
+
35
+ # 1.1.6 (Jan 19 2016)
36
+
37
+ * Add `rake assets:clobber` task from Rails (#149)
38
+ * Make `assets:clean` capable with zsh (#150)
39
+ * Split `deploy:migrate` to allow for finer hook-control (#148)
40
+ * Fix for parsing ls output in detect_manifest_path (#133)
41
+
42
+ # 1.1.5 (Oct 15 2015)
43
+
44
+ * Disable `deploy:cleanup_assets` by default due to undesirable behavior in Rails 3. Use `set :keep_assets, 2` to explicitly enable this feature for Rails 4.
45
+
46
+ # 1.1.4 (Oct 10 2015)
47
+
48
+ * Fixing bug with normalize_assets typo #138
49
+ * Cleanup assets after:updated (#136)
50
+ * Fixed linked_dirs containing default value of assets_prefix (#125)
51
+
52
+ # 1.1.3 (Apr 18 2015)
53
+
54
+ * Fixed no_release behaviour (https://github.com/capistrano/rails/pull/95)
55
+ * Allow assets manifest backup with folder "manifests" (https://github.com/capistrano/rails/pull/92)
56
+ * Handle Sprocket 3 manifest filename
57
+
58
+ # 1.1.2 (Sep 1 2014)
59
+
60
+ * rails_env is set before deploy (https://github.com/capistrano/rails/pull/66)
61
+ * with `conditionally_migrate` option enabled you can skip `db:migrate` if there were no new migrations (https://github.com/capistrano/rails/pull/71)
62
+ * Allow early overriding of assets_* parameters (https://github.com/capistrano/rails/pull/73)
63
+
64
+ # 1.1.1
65
+
66
+ * New `asset_roles` options: https://github.com/capistrano/rails/pull/30
67
+ * normalized task spelling: 'deploy:normalise_assets' is now 'deploy:normalize_assets'
68
+ * depend on capistrano 3.1 to support multiple role arguments
69
+
70
+ # 1.1.0
71
+
72
+ * set rails_env even if capistrano-rails was required partly
73
+ * depend on capistrano-bundler
74
+ * require bundler with capistrano-rails/all
75
+
76
+ # 1.0.0
77
+
78
+ Initial release
79
+
80
+ [master]: https://github.com/capistrano/rails/compare/v1.3.0...HEAD
81
+ [1.3.0]: https://github.com/capistrano/rails/compare/v1.2.2...v1.3.0
82
+ [1.2.3]: https://github.com/capistrano/rails/compare/v1.2.2...v1.2.3
83
+ [1.2.2]: https://github.com/capistrano/rails/compare/v1.2.1...v1.2.2
84
+ [1.2.1]: https://github.com/capistrano/rails/compare/v1.2.0...v1.2.1
85
+ [1.2.0]: https://github.com/capistrano/rails/compare/v1.1.8...v1.2.0
@@ -0,0 +1 @@
1
+ danger.import_dangerfile(github: "capistrano/danger")
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in capistrano-rails.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Tom Clements
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,116 @@
1
+ # Capistrano::Rails
2
+
3
+ Rails specific tasks for Capistrano v3:
4
+
5
+ - `cap deploy:migrate`
6
+ - `cap deploy:compile_assets`
7
+
8
+ ## Installation
9
+
10
+ Add these lines to your application's Gemfile:
11
+
12
+ ```ruby
13
+ group :development do
14
+ gem 'capistrano', '~> 3.6'
15
+ gem 'capistrano-rails', '~> 1.3'
16
+ end
17
+ ```
18
+
19
+ Run the following command to install the gems:
20
+
21
+ ```
22
+ bundle install
23
+ ```
24
+
25
+ Then run the generator to create a basic set of configuration files:
26
+
27
+ ```
28
+ bundle exec cap install
29
+ ```
30
+
31
+ ## Usage
32
+
33
+ Require everything (`bundler`, `rails/assets` and `rails/migrations`):
34
+
35
+ ```ruby
36
+ # Capfile
37
+ require 'capistrano/rails'
38
+ ```
39
+
40
+ Or require just what you need manually:
41
+
42
+ ```ruby
43
+ # Capfile
44
+ require 'capistrano/bundler' # Rails needs Bundler, right?
45
+ require 'capistrano/rails/assets'
46
+ require 'capistrano/rails/migrations'
47
+ ```
48
+
49
+ Please note that any `require`s should be placed in `Capfile`, not in `config/deploy.rb`.
50
+
51
+ You can tweak some Rails-specific options in `config/deploy.rb`:
52
+
53
+ ```ruby
54
+ # If the environment differs from the stage name
55
+ set :rails_env, 'staging'
56
+
57
+ # Defaults to :db role
58
+ set :migration_role, :db
59
+
60
+ # Defaults to the primary :db server
61
+ set :migration_servers, -> { primary(fetch(:migration_role)) }
62
+
63
+ # Defaults to false
64
+ # Skip migration if files in db/migrate were not modified
65
+ set :conditionally_migrate, true
66
+
67
+ # Defaults to [:web]
68
+ set :assets_roles, [:web, :app]
69
+
70
+ # Defaults to 'assets'
71
+ # This should match config.assets.prefix in your rails config/application.rb
72
+ set :assets_prefix, 'prepackaged-assets'
73
+
74
+ # RAILS_GROUPS env value for the assets:precompile task. Default to nil.
75
+ set :rails_assets_groups, :assets
76
+
77
+ # If you need to touch public/images, public/javascripts, and public/stylesheets on each deploy
78
+ set :normalize_asset_timestamps, %w{public/images public/javascripts public/stylesheets}
79
+
80
+ # Defaults to nil (no asset cleanup is performed)
81
+ # If you use Rails 4+ and you'd like to clean up old assets after each deploy,
82
+ # set this to the number of versions to keep
83
+ set :keep_assets, 2
84
+ ```
85
+
86
+ ### Symlinks
87
+
88
+ You'll probably want to symlink Rails shared files and directories like `log`, `tmp` and `public/uploads`.
89
+ Make sure you enable it by setting `linked_dirs` and `linked_files` options:
90
+
91
+ ```ruby
92
+ # deploy.rb
93
+ set :linked_dirs, fetch(:linked_dirs, []).push('log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', 'public/system', 'public/uploads')
94
+ set :linked_files, fetch(:linked_files, []).push('config/database.yml', 'config/secrets.yml')
95
+ ```
96
+
97
+ ### Recommendations
98
+
99
+ While migrations looks like a concern of the database layer, Rails migrations
100
+ are strictly related to the framework. Therefore, it's recommended to set the
101
+ role to `:app` instead of `:db` like:
102
+
103
+ ```ruby
104
+ set :migration_role, :app
105
+ ```
106
+
107
+ The advantage is you won't need to deploy your application to your database
108
+ server, and overall a better separation of concerns.
109
+
110
+ ## Contributing
111
+
112
+ 1. Fork it
113
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
114
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
115
+ 4. Push to the branch (`git push origin my-new-feature`)
116
+ 5. Create new Pull Request
@@ -0,0 +1,4 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ # Do nothing by default
4
+ task :default
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |gem|
6
+ gem.name = "capistrano-rails"
7
+ gem.version = '1.3.0'
8
+ gem.authors = ["Tom Clements", "Lee Hambley", "Kir Shatrov"]
9
+ gem.email = ["seenmyfate@gmail.com", "lee.hambley@gmail.com", "shatrov@me.com"]
10
+ gem.description = %q{Rails specific Capistrano tasks}
11
+ gem.summary = %q{Rails specific Capistrano tasks}
12
+ gem.homepage = "https://github.com/capistrano/rails"
13
+
14
+ gem.files = `git ls-files`.split($/)
15
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
16
+ gem.require_paths = ["lib"]
17
+
18
+ gem.add_dependency 'capistrano', '~> 3.1'
19
+ gem.add_dependency 'capistrano-bundler', '~> 1.1'
20
+
21
+ gem.add_development_dependency 'danger'
22
+ end
File without changes
@@ -0,0 +1,3 @@
1
+ require 'capistrano/bundler'
2
+ require 'capistrano/rails/assets'
3
+ require 'capistrano/rails/migrations'
@@ -0,0 +1 @@
1
+ load File.expand_path("../../tasks/assets.rake", __FILE__)
@@ -0,0 +1 @@
1
+ load File.expand_path("../../tasks/migrations.rake", __FILE__)
@@ -0,0 +1,138 @@
1
+ load File.expand_path("../set_rails_env.rake", __FILE__)
2
+
3
+ module Capistrano
4
+ class FileNotFound < StandardError
5
+ end
6
+ end
7
+
8
+ namespace :deploy do
9
+ desc 'Normalize asset timestamps'
10
+ task :normalize_assets => [:set_rails_env] do
11
+ on release_roles(fetch(:assets_roles)) do
12
+ assets = Array(fetch(:normalize_asset_timestamps, []))
13
+ if assets.any?
14
+ within release_path do
15
+ execute :find, "#{assets.join(' ')} -exec touch -t #{asset_timestamp} {} ';'; true"
16
+ end
17
+ end
18
+ end
19
+ end
20
+
21
+ desc 'Compile assets'
22
+ task :compile_assets => [:set_rails_env] do
23
+ invoke 'deploy:assets:precompile'
24
+ invoke 'deploy:assets:backup_manifest'
25
+ end
26
+
27
+ desc 'Cleanup expired assets'
28
+ task :cleanup_assets => [:set_rails_env] do
29
+ next unless fetch(:keep_assets)
30
+ on release_roles(fetch(:assets_roles)) do
31
+ within release_path do
32
+ with rails_env: fetch(:rails_env) do
33
+ execute :rake, "'assets:clean[#{fetch(:keep_assets)}]'"
34
+ end
35
+ end
36
+ end
37
+ end
38
+
39
+ desc 'Clobber assets'
40
+ task :clobber_assets => [:set_rails_env] do
41
+ on release_roles(fetch(:assets_roles)) do
42
+ within release_path do
43
+ with rails_env: fetch(:rails_env) do
44
+ execute :rake, "assets:clobber"
45
+ end
46
+ end
47
+ end
48
+ end
49
+
50
+ desc 'Rollback assets'
51
+ task :rollback_assets => [:set_rails_env] do
52
+ begin
53
+ invoke 'deploy:assets:restore_manifest'
54
+ rescue Capistrano::FileNotFound
55
+ invoke 'deploy:compile_assets'
56
+ end
57
+ end
58
+
59
+ after 'deploy:updated', 'deploy:compile_assets'
60
+ after 'deploy:updated', 'deploy:cleanup_assets'
61
+ after 'deploy:updated', 'deploy:normalize_assets'
62
+ after 'deploy:reverted', 'deploy:rollback_assets'
63
+
64
+ namespace :assets do
65
+ task :precompile do
66
+ on release_roles(fetch(:assets_roles)) do
67
+ within release_path do
68
+ with rails_env: fetch(:rails_env), rails_groups: fetch(:rails_assets_groups) do
69
+ execute :rake, "assets:precompile"
70
+ end
71
+ end
72
+ end
73
+ end
74
+
75
+ task :backup_manifest do
76
+ on release_roles(fetch(:assets_roles)) do
77
+ within release_path do
78
+ backup_path = release_path.join('assets_manifest_backup')
79
+
80
+ execute :mkdir, '-p', backup_path
81
+ execute :cp,
82
+ detect_manifest_path,
83
+ backup_path
84
+ end
85
+ end
86
+ end
87
+
88
+ task :restore_manifest do
89
+ on release_roles(fetch(:assets_roles)) do
90
+ within release_path do
91
+ target = detect_manifest_path
92
+ source = release_path.join('assets_manifest_backup', File.basename(target))
93
+ if test "[[ -f #{source} && -f #{target} ]]"
94
+ execute :cp, source, target
95
+ else
96
+ msg = 'Rails assets manifest file (or backup file) not found.'
97
+ warn msg
98
+ fail Capistrano::FileNotFound, msg
99
+ end
100
+ end
101
+ end
102
+ end
103
+
104
+ def detect_manifest_path
105
+ %w(
106
+ .sprockets-manifest*
107
+ manifest*.*
108
+ ).each do |pattern|
109
+ candidate = release_path.join('public', fetch(:assets_prefix), pattern)
110
+ return capture(:ls, candidate).strip.gsub(/(\r|\n)/,' ') if test(:ls, candidate)
111
+ end
112
+ msg = 'Rails assets manifest file not found.'
113
+ warn msg
114
+ fail Capistrano::FileNotFound, msg
115
+ end
116
+ end
117
+ end
118
+
119
+ # we can't set linked_dirs in load:defaults,
120
+ # as assets_prefix will always have a default value
121
+ namespace :deploy do
122
+ task :set_linked_dirs do
123
+ linked_dirs = fetch(:linked_dirs, [])
124
+ unless linked_dirs.include?('public')
125
+ linked_dirs << "public/#{fetch(:assets_prefix)}"
126
+ set :linked_dirs, linked_dirs.uniq
127
+ end
128
+ end
129
+ end
130
+
131
+ after 'deploy:set_rails_env', 'deploy:set_linked_dirs'
132
+
133
+ namespace :load do
134
+ task :defaults do
135
+ set :assets_roles, fetch(:assets_roles, [:web])
136
+ set :assets_prefix, fetch(:assets_prefix, 'assets')
137
+ end
138
+ end
@@ -0,0 +1,40 @@
1
+ load File.expand_path("../set_rails_env.rake", __FILE__)
2
+
3
+ namespace :deploy do
4
+
5
+ desc 'Runs rake db:migrate if migrations are set'
6
+ task :migrate => [:set_rails_env] do
7
+ on fetch(:migration_servers) do
8
+ conditionally_migrate = fetch(:conditionally_migrate)
9
+ info '[deploy:migrate] Checking changes in db' if conditionally_migrate
10
+ if conditionally_migrate && test(:diff, "-qr #{release_path}/db #{current_path}/db")
11
+ info '[deploy:migrate] Skip `deploy:migrate` (nothing changed in db)'
12
+ else
13
+ info '[deploy:migrate] Run `rake db:migrate`'
14
+ # NOTE: We access instance variable since the accessor was only added recently. Once capistrano-rails depends on rake 11+, we can revert the following line
15
+ invoke :'deploy:migrating' unless Rake::Task[:'deploy:migrating'].instance_variable_get(:@already_invoked)
16
+ end
17
+ end
18
+ end
19
+
20
+ desc 'Runs rake db:migrate'
21
+ task migrating: [:set_rails_env] do
22
+ on fetch(:migration_servers) do
23
+ within release_path do
24
+ with rails_env: fetch(:rails_env) do
25
+ execute :rake, 'db:migrate'
26
+ end
27
+ end
28
+ end
29
+ end
30
+
31
+ after 'deploy:updated', 'deploy:migrate'
32
+ end
33
+
34
+ namespace :load do
35
+ task :defaults do
36
+ set :conditionally_migrate, fetch(:conditionally_migrate, false)
37
+ set :migration_role, fetch(:migration_role, :db)
38
+ set :migration_servers, -> { primary(fetch(:migration_role)) }
39
+ end
40
+ end
@@ -0,0 +1,9 @@
1
+ namespace :deploy do
2
+ task :set_rails_env do
3
+ set :rails_env, (fetch(:rails_env) || fetch(:stage))
4
+ end
5
+ end
6
+
7
+ Capistrano::DSL.stages.each do |stage|
8
+ after stage, 'deploy:set_rails_env'
9
+ end
metadata ADDED
@@ -0,0 +1,105 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capistrano-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.3.0
5
+ platform: ruby
6
+ authors:
7
+ - Tom Clements
8
+ - Lee Hambley
9
+ - Kir Shatrov
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2017-06-09 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: capistrano
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - "~>"
20
+ - !ruby/object:Gem::Version
21
+ version: '3.1'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - "~>"
27
+ - !ruby/object:Gem::Version
28
+ version: '3.1'
29
+ - !ruby/object:Gem::Dependency
30
+ name: capistrano-bundler
31
+ requirement: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - "~>"
34
+ - !ruby/object:Gem::Version
35
+ version: '1.1'
36
+ type: :runtime
37
+ prerelease: false
38
+ version_requirements: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - "~>"
41
+ - !ruby/object:Gem::Version
42
+ version: '1.1'
43
+ - !ruby/object:Gem::Dependency
44
+ name: danger
45
+ requirement: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
50
+ type: :development
51
+ prerelease: false
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ description: Rails specific Capistrano tasks
58
+ email:
59
+ - seenmyfate@gmail.com
60
+ - lee.hambley@gmail.com
61
+ - shatrov@me.com
62
+ executables: []
63
+ extensions: []
64
+ extra_rdoc_files: []
65
+ files:
66
+ - ".gitignore"
67
+ - ".travis.yml"
68
+ - CHANGELOG.md
69
+ - Dangerfile
70
+ - Gemfile
71
+ - LICENSE.txt
72
+ - README.md
73
+ - Rakefile
74
+ - capistrano-rails.gemspec
75
+ - lib/capistrano-rails.rb
76
+ - lib/capistrano/rails.rb
77
+ - lib/capistrano/rails/assets.rb
78
+ - lib/capistrano/rails/migrations.rb
79
+ - lib/capistrano/tasks/assets.rake
80
+ - lib/capistrano/tasks/migrations.rake
81
+ - lib/capistrano/tasks/set_rails_env.rake
82
+ homepage: https://github.com/capistrano/rails
83
+ licenses: []
84
+ metadata: {}
85
+ post_install_message:
86
+ rdoc_options: []
87
+ require_paths:
88
+ - lib
89
+ required_ruby_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ required_rubygems_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ requirements: []
100
+ rubyforge_project:
101
+ rubygems_version: 2.6.12
102
+ signing_key:
103
+ specification_version: 4
104
+ summary: Rails specific Capistrano tasks
105
+ test_files: []