capistrano-faster-webpacker 1.0.2
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/.gitignore +19 -0
- data/Gemfile +4 -0
- data/LICENSE.md +19 -0
- data/README.md +60 -0
- data/Rakefile +1 -0
- data/capistrano-faster-webpacker.gemspec +28 -0
- data/lib/capistrano-faster-webpacker.rb +0 -0
- data/lib/capistrano/faster_webpacker.rb +1 -0
- data/lib/capistrano/faster_webpacker/version.rb +5 -0
- data/lib/capistrano/tasks/faster_webpacker.rake +93 -0
- metadata +85 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ec963bb46c16646125b52ac3c3364bd194346d45
|
4
|
+
data.tar.gz: b66e1a472ddc9429c2eddd0a71cb82d9833b47c8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 46fb4dafd783b40a424046306894ea4fb334d6aa02ca5c3849490da6b984ab4a7507aea05137535d199aea6c09af282c15f131db5cd3c6a907b433781534eab7
|
7
|
+
data.tar.gz: 25174b895d8831704f2e8ee8a31e7daeb83cc8df4c3c250bbe4cc457bdbb1671ada6ddc1376c2263f63ebc85d2cfbda3056bb29e06606f5a1312145cf7744631
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.md
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2014 Andrew Thal, Ruben Stranders
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the "Software"),
|
5
|
+
to deal in the Software without restriction, including without limitation
|
6
|
+
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
7
|
+
and/or sell copies of the Software, and to permit persons to whom the
|
8
|
+
Software is furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included
|
11
|
+
in all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
14
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
15
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
16
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
17
|
+
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
18
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
19
|
+
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
# Capistrano::FasterAssets
|
2
|
+
|
3
|
+
This gem speeds up asset compilation by skipping the assets:precompile task if none of the assets were changed
|
4
|
+
since last release.
|
5
|
+
|
6
|
+
Works *only* with Capistrano 3+.
|
7
|
+
|
8
|
+
### Installation
|
9
|
+
|
10
|
+
Add this to `Gemfile`:
|
11
|
+
|
12
|
+
group :development do
|
13
|
+
gem 'capistrano', '~> 3.1'
|
14
|
+
gem 'capistrano-rails', '~> 1.1'
|
15
|
+
gem 'capistrano-faster-assets', '~> 1.0'
|
16
|
+
end
|
17
|
+
|
18
|
+
And then:
|
19
|
+
|
20
|
+
$ bundle install
|
21
|
+
|
22
|
+
### Setup and usage
|
23
|
+
|
24
|
+
Add this line to `Capfile`, after `require 'capistrano/rails/assets'`
|
25
|
+
|
26
|
+
require 'capistrano/faster_assets'
|
27
|
+
|
28
|
+
### Warning
|
29
|
+
|
30
|
+
Please keep in mind, that if you use ERB in your assets, you might run into cases where Capistrano won't recompile assets when needed. For instance, let's say you have a CoffeeScript file like this:
|
31
|
+
|
32
|
+
```coffee
|
33
|
+
text = <%= helper.get_text %>
|
34
|
+
```
|
35
|
+
|
36
|
+
The assets might not get recompiled, even if they have to, as this gem only checks if the asset file has changed (which is probably the only safe/fast way to do this).
|
37
|
+
|
38
|
+
### More Capistrano automation?
|
39
|
+
|
40
|
+
If you'd like to streamline your Capistrano deploys, you might want to check
|
41
|
+
these zero-configuration, plug-n-play plugins:
|
42
|
+
|
43
|
+
- [capistrano-unicorn-nginx](https://github.com/bruno-/capistrano-unicorn-nginx)<br/>
|
44
|
+
no-configuration unicorn and nginx setup with sensible defaults
|
45
|
+
- [capistrano-postgresql](https://github.com/bruno-/capistrano-postgresql)<br/>
|
46
|
+
plugin that automates postgresql configuration and setup
|
47
|
+
- [capistrano-rbenv-install](https://github.com/bruno-/capistrano-rbenv-install)<br/>
|
48
|
+
would you like Capistrano to install rubies for you?
|
49
|
+
- [capistrano-safe-deploy-to](https://github.com/bruno-/capistrano-safe-deploy-to)<br/>
|
50
|
+
if you're annoyed that Capistrano does **not** create a deployment path for the
|
51
|
+
app on the server (default `/var/www/myapp`), this is what you need!
|
52
|
+
|
53
|
+
### Bug reports and pull requests
|
54
|
+
|
55
|
+
...are very welcome!
|
56
|
+
|
57
|
+
### Thanks
|
58
|
+
|
59
|
+
[@athal7](https://github.com/athal7) - for the original idea and implementation. See https://coderwall.com/p/aridag
|
60
|
+
for more details
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'capistrano/faster_webpacker/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "capistrano-faster-webpacker"
|
8
|
+
gem.version = Capistrano::FasterWebpacker::VERSION
|
9
|
+
gem.authors = ['masarakki']
|
10
|
+
gem.email = ['masaki182@gmail.com']
|
11
|
+
gem.description = <<-EOF.gsub(/^\s+/, '')
|
12
|
+
Speeds up *webpacker* asset compilation by skipping the assets:precompile task if none of the assets were changed since last release.
|
13
|
+
|
14
|
+
Works *only* with Capistrano 3+.
|
15
|
+
|
16
|
+
forked from capistrano-faster-assets
|
17
|
+
EOF
|
18
|
+
gem.summary = 'Speeds up webpacker asset compilation if none of the assets were changed since last release.'
|
19
|
+
gem.homepage = 'https://github.com/masarakki/capistrano-faster-webpacker'
|
20
|
+
|
21
|
+
gem.files = `git ls-files`.split($/)
|
22
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
23
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
24
|
+
gem.require_paths = ["lib"]
|
25
|
+
|
26
|
+
gem.add_dependency "capistrano", ">= 3.1"
|
27
|
+
gem.add_development_dependency "rake"
|
28
|
+
end
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
load File.expand_path("../tasks/faster_webpacker.rake", __FILE__)
|
@@ -0,0 +1,93 @@
|
|
1
|
+
# Original source: https://coderwall.com/p/aridag
|
2
|
+
|
3
|
+
|
4
|
+
# clear the previous precompile task
|
5
|
+
Rake::Task["deploy:assets:precompile"].clear_actions
|
6
|
+
class PrecompileRequired < StandardError;
|
7
|
+
end
|
8
|
+
|
9
|
+
set :assets_prefix, 'packs'
|
10
|
+
|
11
|
+
namespace :deploy do
|
12
|
+
namespace :assets do
|
13
|
+
desc "Precompile assets"
|
14
|
+
task :precompile do
|
15
|
+
on roles(fetch(:assets_roles)) do
|
16
|
+
within release_path do
|
17
|
+
with rails_env: fetch(:rails_env) do
|
18
|
+
begin
|
19
|
+
# find the most recent release
|
20
|
+
latest_release = capture(:ls, '-xr', releases_path).split[1]
|
21
|
+
|
22
|
+
# precompile if this is the first deploy
|
23
|
+
raise PrecompileRequired unless latest_release
|
24
|
+
|
25
|
+
latest_release_path = releases_path.join(latest_release)
|
26
|
+
|
27
|
+
latest_node_modules_path = latest_release_path.join('node_modules')
|
28
|
+
|
29
|
+
execute(:test, '-e', latest_node_modules_path.to_s) rescue raise PrecompileRequired
|
30
|
+
|
31
|
+
begin
|
32
|
+
execute(:test, '-L', latest_node_modules_path.to_s)
|
33
|
+
rescue
|
34
|
+
execute(:cp, '-r', latest_node_modules_path, release_path)
|
35
|
+
end
|
36
|
+
|
37
|
+
# precompile if the previous deploy failed to finish precompiling
|
38
|
+
execute(:ls, latest_release_path.join('assets_manifest_backup')) rescue raise(PrecompileRequired)
|
39
|
+
|
40
|
+
fetch(:assets_dependencies).each do |dep|
|
41
|
+
release = release_path.join(dep)
|
42
|
+
latest = latest_release_path.join(dep)
|
43
|
+
|
44
|
+
# skip if both directories/files do not exist
|
45
|
+
next if [release, latest].map{|d| test "[ -e #{d} ]"}.uniq == [false]
|
46
|
+
|
47
|
+
# execute raises if there is a diff
|
48
|
+
execute(:diff, '-Nqr', release, latest) rescue raise(PrecompileRequired)
|
49
|
+
end
|
50
|
+
|
51
|
+
fetch(:assets_shared_dependencies).each do |dep|
|
52
|
+
shared_file = shared_path.join(dep)
|
53
|
+
execute(:test, latest_release_path, '-nt', shared_file) rescue raise(PrecompileRequired)
|
54
|
+
end
|
55
|
+
|
56
|
+
info("Skipping asset precompile, no asset diff found")
|
57
|
+
|
58
|
+
# copy over all of the assets from the last release
|
59
|
+
release_asset_path = release_path.join('public', fetch(:assets_prefix))
|
60
|
+
# skip if assets directory is symlink
|
61
|
+
begin
|
62
|
+
execute(:test, '-L', release_asset_path.to_s)
|
63
|
+
rescue
|
64
|
+
execute(:cp, '-r', latest_release_path.join('public', fetch(:assets_prefix)), release_asset_path.parent)
|
65
|
+
end
|
66
|
+
|
67
|
+
# copy assets if manifest file is not exist (this is first deploy after using symlink)
|
68
|
+
execute(:ls, release_asset_path.join('manifest*')) rescue raise(PrecompileRequired)
|
69
|
+
|
70
|
+
rescue PrecompileRequired
|
71
|
+
execute(:rake, "assets:precompile")
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
namespace :load do
|
81
|
+
task :defaults do
|
82
|
+
set :assets_dependencies, fetch(:assets_dependencies, [
|
83
|
+
'package.json',
|
84
|
+
'.babelrc',
|
85
|
+
'.postcssrc.yml',
|
86
|
+
'app/javascript',
|
87
|
+
'config/webpack',
|
88
|
+
'config/webpacker.yml',
|
89
|
+
'yarn.lock'
|
90
|
+
])
|
91
|
+
set :assets_shared_dependencies, fetch(:assets_shared_dependencies, [])
|
92
|
+
end
|
93
|
+
end
|
metadata
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: capistrano-faster-webpacker
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- masarakki
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-06-16 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.1'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.1'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: |
|
42
|
+
Speeds up *webpacker* asset compilation by skipping the assets:precompile task if none of the assets were changed since last release.
|
43
|
+
Works *only* with Capistrano 3+.
|
44
|
+
forked from capistrano-faster-assets
|
45
|
+
email:
|
46
|
+
- masaki182@gmail.com
|
47
|
+
executables: []
|
48
|
+
extensions: []
|
49
|
+
extra_rdoc_files: []
|
50
|
+
files:
|
51
|
+
- ".gitignore"
|
52
|
+
- Gemfile
|
53
|
+
- LICENSE.md
|
54
|
+
- README.md
|
55
|
+
- Rakefile
|
56
|
+
- capistrano-faster-webpacker.gemspec
|
57
|
+
- lib/capistrano-faster-webpacker.rb
|
58
|
+
- lib/capistrano/faster_webpacker.rb
|
59
|
+
- lib/capistrano/faster_webpacker/version.rb
|
60
|
+
- lib/capistrano/tasks/faster_webpacker.rake
|
61
|
+
homepage: https://github.com/masarakki/capistrano-faster-webpacker
|
62
|
+
licenses: []
|
63
|
+
metadata: {}
|
64
|
+
post_install_message:
|
65
|
+
rdoc_options: []
|
66
|
+
require_paths:
|
67
|
+
- lib
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
requirements: []
|
79
|
+
rubyforge_project:
|
80
|
+
rubygems_version: 2.6.11
|
81
|
+
signing_key:
|
82
|
+
specification_version: 4
|
83
|
+
summary: Speeds up webpacker asset compilation if none of the assets were changed
|
84
|
+
since last release.
|
85
|
+
test_files: []
|