capistrano-local-precompile 0.0.5 → 1.0.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.
- checksums.yaml +4 -4
- data/README.md +7 -17
- data/capistrano-local-precompile.gemspec +4 -5
- data/lib/capistrano-local-precompile.rb +1 -1
- data/lib/capistrano/capistrano-local-precompile/tasks.rb +1 -0
- data/lib/capistrano/local_precompile.rb +45 -44
- data/spec/configuration_spec.rb +6 -1
- data/spec/integration_spec.rb +4 -1
- metadata +12 -19
- data/lib/capistrano-local-precompile/version.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b0ddf2d34a15668372bb7954051441270ba2a07d
|
4
|
+
data.tar.gz: 0d92e8a0e178e6d5c3e9a5b13307831a873badab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d219e42f960febfeee330dcb9c61ad1bc5f74abc108cd6bd7ebc90943cc713bc1898f846976395e1ff0543d0e7a4a705c9307f48d3afd4ace0c0135b42642854
|
7
|
+
data.tar.gz: 381b75305467c302cc2a7aab3bfaa642406e60d0436eb75c10d2d0a5e4ee4107da2b665d65259a1165f1d48f3e49f7ddacc785dee4c04ba1c5ad8915438fea85
|
data/README.md
CHANGED
@@ -2,40 +2,30 @@
|
|
2
2
|
|
3
3
|
If your Rails apps are anything like mine, one of the slowest parts of your deployment is waiting for asset pipeline precompilation. It's sometimes so slow, it's painful. So I went searching for some solutions. [turbo-sprockets](https://github.com/ndbroadbent/turbo-sprockets-rails3) helped, but it's not a silver bullet. This gem isn't a silver bullet either, but it can help. Capistrano Local Precompile takes a different approach. It builds your assets locally and rsync's them to your web server(s).
|
4
4
|
|
5
|
-
*Note: This gem is not yet compatible with Capistrano 3.*
|
6
|
-
|
7
5
|
## Usage
|
8
6
|
|
9
7
|
Add capistrano-local-precompile to your Gemfile:
|
10
8
|
|
11
9
|
```ruby
|
12
10
|
group :development do
|
13
|
-
|
11
|
+
# Capistrano v2 should use '~> 0.0.5'
|
12
|
+
# Capistrano v3 should use '~> 1.0.0'
|
13
|
+
gem 'capistrano-local-precompile', '~> 1.0.0', require: false
|
14
14
|
end
|
15
15
|
```
|
16
16
|
|
17
|
-
Then add the following line to your `
|
17
|
+
Then add the following line to your `Capfile`:
|
18
18
|
|
19
19
|
```ruby
|
20
20
|
require 'capistrano/local_precompile'
|
21
21
|
```
|
22
22
|
|
23
|
-
If you are using turbo-sprockets, just set it to enabled. Your asset will still compile locally, but they'll use turbosprockets to do so:
|
24
|
-
|
25
|
-
```ruby
|
26
|
-
set :turbosprockets_enabled, true
|
27
|
-
```
|
28
|
-
|
29
23
|
Here's the full set of configurable options:
|
30
24
|
|
31
25
|
```ruby
|
32
|
-
set :
|
26
|
+
set :precompile_env # default: fetch(:rails_env) || 'production'
|
33
27
|
set :assets_dir # default: "public/assets"
|
34
|
-
set :rsync_cmd # default: "rsync -av"
|
35
|
-
|
36
|
-
set :turbosprockets_enabled # default: false
|
37
|
-
set :turbosprockets_backup_dir # default: "public/.assets"
|
38
|
-
set :cleanexpired_cmd # default: bundle exec rake assets:clean_expired
|
28
|
+
set :rsync_cmd # default: "rsync -av --delete"
|
39
29
|
```
|
40
30
|
|
41
31
|
## Acknowledgement
|
@@ -51,4 +41,4 @@ Pull requests welcome: fork, make a topic branch, commit (squash when possible)
|
|
51
41
|
|
52
42
|
## Copyright
|
53
43
|
|
54
|
-
Copyright (c)
|
44
|
+
Copyright (c) 2017 Steve Agalloco / Tom Caflisch. See [LICENSE](LICENSE.md) for detail
|
@@ -1,21 +1,20 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
lib = File.expand_path('../lib', __FILE__)
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'capistrano-local-precompile/version'
|
5
4
|
|
6
5
|
Gem::Specification.new do |gem|
|
7
6
|
gem.name = 'capistrano-local-precompile'
|
8
|
-
gem.version =
|
7
|
+
gem.version = '1.0.0'
|
9
8
|
gem.homepage = 'https://github.com/spagalloco/capistrano-local-precompile'
|
10
9
|
|
11
|
-
gem.author = "Steve Agalloco"
|
12
|
-
gem.email = 'steve.agalloco@gmail.com'
|
10
|
+
gem.author = "Steve Agalloco, Tom Caflisch"
|
11
|
+
gem.email = 'steve.agalloco@gmail.com, tomcaflisch@gmail.com'
|
13
12
|
gem.description = 'Local asset-pipeline precompilation for Capstrano'
|
14
13
|
gem.summary = gem.description
|
15
14
|
|
16
15
|
gem.license = 'MIT'
|
17
16
|
|
18
|
-
gem.add_dependency 'capistrano', '
|
17
|
+
gem.add_dependency 'capistrano', '>=3'
|
19
18
|
|
20
19
|
gem.files = %w(.yardopts LICENSE.md README.md Rakefile capistrano-local-precompile.gemspec)
|
21
20
|
gem.files += Dir.glob("lib/**/*.rb")
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
load File.expand_path('../../tasks/local_precompile.cap', __FILE__)
|
@@ -1,58 +1,59 @@
|
|
1
|
-
require 'capistrano'
|
1
|
+
require 'capistrano/rails/assets'
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
namespace :load do
|
4
|
+
task :defaults do
|
5
|
+
set :precompile_env, fetch(:rails_env) || 'production'
|
6
|
+
set :assets_dir, "public/assets"
|
7
|
+
set :rsync_cmd, "rsync -av --delete"
|
5
8
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
set(:cleanexpired_cmd) { "RAILS_ENV=#{rails_env.to_s.shellescape} #{asset_env} #{rake} assets:clean_expired" }
|
12
|
-
set(:assets_dir) { "public/assets" }
|
13
|
-
set(:rsync_cmd) { "rsync -av" }
|
14
|
-
|
15
|
-
before "deploy:assets:precompile", "deploy:assets:prepare"
|
16
|
-
before "deploy:assets:symlink", "deploy:assets:remove_manifest"
|
9
|
+
after "bundler:install", "deploy:assets:prepare"
|
10
|
+
#before "deploy:assets:symlink", "deploy:assets:remove_manifest"
|
11
|
+
after "deploy:assets:prepare", "deploy:assets:cleanup"
|
12
|
+
end
|
13
|
+
end
|
17
14
|
|
18
|
-
|
15
|
+
namespace :deploy do
|
16
|
+
# Clear existing task so we can replace it rather than "add" to it.
|
17
|
+
Rake::Task["deploy:compile_assets"].clear
|
19
18
|
|
20
|
-
|
21
|
-
namespace :assets do
|
19
|
+
namespace :assets do
|
22
20
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
21
|
+
# desc "Remove manifest file from remote server"
|
22
|
+
# task :remove_manifest do
|
23
|
+
# with rails_env: fetch(:assets_dir) do
|
24
|
+
# execute "rm -f #{shared_path}/#{shared_assets_prefix}/manifest*"
|
25
|
+
# end
|
26
|
+
# end
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
|
28
|
+
desc "Remove all local precompiled assets"
|
29
|
+
task :cleanup do
|
30
|
+
run_locally do
|
31
|
+
with rails_env: fetch(:precompile_env) do
|
32
|
+
execute "rm -rf", fetch(:assets_dir)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
31
36
|
|
32
|
-
|
33
|
-
|
34
|
-
|
37
|
+
desc "Actually precompile the assets locally"
|
38
|
+
task :prepare do
|
39
|
+
run_locally do
|
40
|
+
with rails_env: fetch(:precompile_env) do
|
41
|
+
execute :bundle, "exec rake assets:clean"
|
42
|
+
execute :bundle, "exec rake assets:precompile"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
35
46
|
|
36
|
-
|
37
|
-
|
47
|
+
desc "Performs rsync to app servers"
|
48
|
+
task :precompile do
|
49
|
+
on roles(fetch(:assets_role)) do
|
38
50
|
|
39
|
-
|
40
|
-
|
51
|
+
local_manifest_path = run_locally "ls #{assets_dir}/manifest*"
|
52
|
+
local_manifest_path.strip!
|
41
53
|
|
42
|
-
|
43
|
-
|
44
|
-
run_locally "#{fetch(:rsync_cmd)} ./#{fetch(:assets_dir)}/ #{user}@#{srvr}:#{release_path}/#{fetch(:assets_dir)}/"
|
45
|
-
run_locally "#{fetch(:rsync_cmd)} ./#{local_manifest_path} #{user}@#{srvr}:#{release_path}/assets_manifest#{File.extname(local_manifest_path)}"
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
54
|
+
run_locally "#{fetch(:rsync_cmd)} ./#{fetch(:assets_dir)}/ #{user}@#{server}:#{release_path}/#{fetch(:assets_dir)}/"
|
55
|
+
run_locally "#{fetch(:rsync_cmd)} ./#{local_manifest_path} #{user}@#{server}:#{release_path}/assets_manifest#{File.extname(local_manifest_path)}"
|
50
56
|
end
|
51
57
|
end
|
52
|
-
|
53
58
|
end
|
54
59
|
end
|
55
|
-
|
56
|
-
if Capistrano::Configuration.instance
|
57
|
-
Capistrano::LocalPrecompile.load_into(Capistrano::Configuration.instance)
|
58
|
-
end
|
data/spec/configuration_spec.rb
CHANGED
@@ -30,7 +30,7 @@ describe Capistrano::LocalPrecompile, "configuration" do
|
|
30
30
|
end
|
31
31
|
|
32
32
|
it "defines rsync_cmd" do
|
33
|
-
expect(@configuration.fetch(:rsync_cmd)).to eq('rsync -av')
|
33
|
+
expect(@configuration.fetch(:rsync_cmd)).to eq('rsync -av --delete')
|
34
34
|
end
|
35
35
|
|
36
36
|
it "performs deploy:assets:prepare before deploy:assets:precompile" do
|
@@ -47,4 +47,9 @@ describe Capistrano::LocalPrecompile, "configuration" do
|
|
47
47
|
expect(@configuration).to callback('deploy:assets:cleanup').
|
48
48
|
after('deploy:assets:precompile')
|
49
49
|
end
|
50
|
+
|
51
|
+
it "performs deploy:assets:remove_manifest before deploy:assets:symlink" do
|
52
|
+
expect(@configuration).to callback('deploy:assets:remove_manifest').
|
53
|
+
before('deploy:assets:symlink')
|
54
|
+
end
|
50
55
|
end
|
data/spec/integration_spec.rb
CHANGED
@@ -31,8 +31,11 @@ describe Capistrano::LocalPrecompile, "integration" do
|
|
31
31
|
|
32
32
|
describe 'remove manifest task' do
|
33
33
|
it 'invokes the precompile command' do
|
34
|
+
allow(@configuration).to receive(:shared_path).and_return('/tmp/shared')
|
35
|
+
allow(@configuration).to receive(:shared_assets_prefix).and_return('assets')
|
36
|
+
|
34
37
|
expect(@configuration).to receive(:run).
|
35
|
-
with('rm -f
|
38
|
+
with('rm -f /tmp/shared/assets/manifest*').once
|
36
39
|
|
37
40
|
@configuration.find_and_execute_task('deploy:assets:remove_manifest')
|
38
41
|
end
|
metadata
CHANGED
@@ -1,49 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-local-precompile
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
- Steve Agalloco
|
7
|
+
- Steve Agalloco, Tom Caflisch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-05-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capistrano
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '2'
|
20
|
-
- - "<"
|
17
|
+
- - '>='
|
21
18
|
- !ruby/object:Gem::Version
|
22
19
|
version: '3'
|
23
20
|
type: :runtime
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
26
23
|
requirements:
|
27
|
-
- -
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '2'
|
30
|
-
- - "<"
|
24
|
+
- - '>='
|
31
25
|
- !ruby/object:Gem::Version
|
32
26
|
version: '3'
|
33
27
|
description: Local asset-pipeline precompilation for Capstrano
|
34
|
-
email: steve.agalloco@gmail.com
|
28
|
+
email: steve.agalloco@gmail.com, tomcaflisch@gmail.com
|
35
29
|
executables: []
|
36
30
|
extensions: []
|
37
31
|
extra_rdoc_files: []
|
38
32
|
files:
|
39
|
-
-
|
33
|
+
- .yardopts
|
40
34
|
- LICENSE.md
|
41
35
|
- README.md
|
42
36
|
- Rakefile
|
43
37
|
- capistrano-local-precompile.gemspec
|
44
|
-
- lib/capistrano-local-precompile.rb
|
45
|
-
- lib/capistrano-local-precompile/version.rb
|
38
|
+
- lib/capistrano/capistrano-local-precompile/tasks.rb
|
46
39
|
- lib/capistrano/local_precompile.rb
|
40
|
+
- lib/capistrano-local-precompile.rb
|
47
41
|
- spec/configuration_spec.rb
|
48
42
|
- spec/integration_spec.rb
|
49
43
|
- spec/spec_helper.rb
|
@@ -57,17 +51,17 @@ require_paths:
|
|
57
51
|
- lib
|
58
52
|
required_ruby_version: !ruby/object:Gem::Requirement
|
59
53
|
requirements:
|
60
|
-
- -
|
54
|
+
- - '>='
|
61
55
|
- !ruby/object:Gem::Version
|
62
56
|
version: '0'
|
63
57
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
58
|
requirements:
|
65
|
-
- -
|
59
|
+
- - '>='
|
66
60
|
- !ruby/object:Gem::Version
|
67
61
|
version: '0'
|
68
62
|
requirements: []
|
69
63
|
rubyforge_project:
|
70
|
-
rubygems_version: 2.
|
64
|
+
rubygems_version: 2.0.14.1
|
71
65
|
signing_key:
|
72
66
|
specification_version: 4
|
73
67
|
summary: Local asset-pipeline precompilation for Capstrano
|
@@ -75,4 +69,3 @@ test_files:
|
|
75
69
|
- spec/configuration_spec.rb
|
76
70
|
- spec/integration_spec.rb
|
77
71
|
- spec/spec_helper.rb
|
78
|
-
has_rdoc:
|