capistrano-rails-precompile-deps 0.0.1
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.
- checksums.yaml +7 -0
- data/README.md +50 -0
- data/Rakefile +14 -0
- data/lib/capistrano/rails-precompile-deps.rb +1 -0
- data/lib/capistrano/tasks/assets_precompile.rake +43 -0
- metadata +76 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 29a91e01313a3b819a4c504b0bcb9b4ffab3cfa0
|
4
|
+
data.tar.gz: 4f3ed7856343cb6e18ba25ee83e617b08e6736df
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: aab0045ae733d47d2e57943d0b32e2baaf9b22030c3079c0dd25121033b9b3ed2eeb60daf7fda3314abd6a8c9595fc9fc27a98a26ce8ccbe757dbf4fa57cd935
|
7
|
+
data.tar.gz: 51f74819f9fc601861db081d0288e43462b42e39e8594d6c77f6ab8406da2c72ec806b1bf4e64ed48f79c01340533d9f4c09478474408856079ab76b6ae49813
|
data/README.md
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# Capistrano::RailsPrecompileDeps
|
2
|
+
|
3
|
+
This gem provides a task for capistrano for precompiling Rails-based apps assets only when needed. The task identifies when to precompile by comparing the changes on the release against a list of folders to which the assets depend on.
|
4
|
+
|
5
|
+
Note: this task overrides the default deploy:assets:precompile.
|
6
|
+
|
7
|
+
## Notes
|
8
|
+
|
9
|
+
**If you use this integration with capistrano-rails, please ensure that you have `capistrano-bundler >= 1.1.0`.**
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
Add this line to your application's Gemfile:
|
14
|
+
|
15
|
+
``` ruby
|
16
|
+
# Gemfile
|
17
|
+
gem 'capistrano', '~> 3.0'
|
18
|
+
gem 'capistrano-rails-precompile-deps', group: :development, require: false
|
19
|
+
```
|
20
|
+
|
21
|
+
And then execute:
|
22
|
+
|
23
|
+
``` sh
|
24
|
+
$ bundle install
|
25
|
+
```
|
26
|
+
|
27
|
+
## Usage
|
28
|
+
|
29
|
+
Require in Capfile to use the default task:
|
30
|
+
|
31
|
+
``` ruby
|
32
|
+
# Capfile
|
33
|
+
require 'capistrano/rails-precompile-deps'
|
34
|
+
```
|
35
|
+
|
36
|
+
On your deploy.rb set the dependencies:
|
37
|
+
|
38
|
+
``` ruby
|
39
|
+
set :assets_dependencies, %w(app/assets lib/assets vendor/assets Gemfile.lock config/routes.rb)
|
40
|
+
```
|
41
|
+
|
42
|
+
If a release contains any changes on the listed files and folders, your assets will get precompiled.
|
43
|
+
|
44
|
+
## Contributing
|
45
|
+
|
46
|
+
1. Fork it
|
47
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
48
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
49
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
50
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
|
3
|
+
begin
|
4
|
+
require 'bundler/setup'
|
5
|
+
rescue LoadError
|
6
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
7
|
+
end
|
8
|
+
|
9
|
+
require 'bundler/gem_tasks'
|
10
|
+
|
11
|
+
require 'rspec/core'
|
12
|
+
require 'rspec/core/rake_task'
|
13
|
+
|
14
|
+
task default: :spec
|
@@ -0,0 +1 @@
|
|
1
|
+
load File.expand_path("../tasks/assets_precompile.rake", __FILE__)
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# Clear the previous precompile task
|
2
|
+
Rake::Task["deploy:assets:precompile"].clear_actions
|
3
|
+
|
4
|
+
class PrecompileRequired < StandardError
|
5
|
+
end
|
6
|
+
|
7
|
+
namespace :deploy do
|
8
|
+
namespace :assets do
|
9
|
+
desc "Precompile assets"
|
10
|
+
task :precompile do
|
11
|
+
on roles(fetch(:assets_roles)) do
|
12
|
+
within release_path do
|
13
|
+
with rails_env: fetch(:rails_env) do
|
14
|
+
begin
|
15
|
+
# find the most recent release
|
16
|
+
latest_release = capture(:ls, '-xr', releases_path).split[1]
|
17
|
+
|
18
|
+
# precompile if this is the first deploy
|
19
|
+
raise PrecompileRequired unless latest_release
|
20
|
+
|
21
|
+
latest_release_path = releases_path.join(latest_release)
|
22
|
+
|
23
|
+
# precompile if the previous deploy failed to finish precompiling
|
24
|
+
execute(:ls, latest_release_path.join('assets_manifest_backup')) rescue raise(PrecompileRequired)
|
25
|
+
|
26
|
+
fetch(:assets_dependencies).each do |dep|
|
27
|
+
# execute raises if there is a diff
|
28
|
+
execute(:diff, '-Naur', release_path.join(dep), latest_release_path.join(dep)) rescue raise(PrecompileRequired)
|
29
|
+
end
|
30
|
+
|
31
|
+
info("Skipping asset precompile, no asset diff found")
|
32
|
+
|
33
|
+
# copy over all of the assets from the last release
|
34
|
+
execute(:cp, '-r', latest_release_path.join('public', fetch(:assets_prefix)), release_path.join('public', fetch(:assets_prefix)))
|
35
|
+
rescue PrecompileRequired
|
36
|
+
execute(:rake, "assets:precompile")
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
metadata
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: capistrano-rails-precompile-deps
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Andre Dieb Martins
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-12-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: capistrano
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: sshkit
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.2'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.2'
|
41
|
+
description: Precompile rails assets only when needed
|
42
|
+
email:
|
43
|
+
- andre.dieb@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- README.md
|
49
|
+
- Rakefile
|
50
|
+
- lib/capistrano/rails-precompile-deps.rb
|
51
|
+
- lib/capistrano/tasks/assets_precompile.rake
|
52
|
+
homepage: https://github.com/dieb/capistrano-rails-precompile-deps
|
53
|
+
licenses:
|
54
|
+
- MIT
|
55
|
+
metadata: {}
|
56
|
+
post_install_message:
|
57
|
+
rdoc_options: []
|
58
|
+
require_paths:
|
59
|
+
- lib
|
60
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '0'
|
65
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
requirements: []
|
71
|
+
rubyforge_project:
|
72
|
+
rubygems_version: 2.4.3
|
73
|
+
signing_key:
|
74
|
+
specification_version: 4
|
75
|
+
summary: Precompile rails assets only when needed
|
76
|
+
test_files: []
|