local_precompile 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.editorconfig +18 -0
- data/.gitignore +12 -0
- data/.rubocop.yml +45 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +19 -0
- data/README.md +61 -0
- data/Rakefile +3 -0
- data/bin/console +12 -0
- data/bin/setup +7 -0
- data/lib/local_precompile/capistrano.rb +56 -0
- data/lib/local_precompile/tasks.rb +1 -0
- data/lib/local_precompile/version.rb +3 -0
- data/lib/local_precompile.rb +1 -0
- data/local_precompile.gemspec +32 -0
- metadata +18 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4b303e98908439f3ea9cadbedda15f71c64f6bc3d2e8feec2a23aae58a876ab7
|
4
|
+
data.tar.gz: '093964238d30534b241cec3d2a1faa9375c85616addc8fe2948b1d5142bc87a9'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 38f6cbebae5817d60157b3b7b84b58e13aa5797e352f1fd3f7f7ef2b79b7ad2d611e1755f07d57671d23809a160d5d8b35349d95370ad5f53220cefc8052a198
|
7
|
+
data.tar.gz: 5ee3dfbc7164625f2243a94114d8b1fc44c2e2a1f83457db6270ec35dbc17837378e32506d4e2bd4abec7df4d58f74ff9f912f2bfb34f43d9a1e90dc3b42fd4e
|
data/.editorconfig
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# EditorConfig helps developers define and maintain consistent
|
2
|
+
# coding styles between different editors and IDEs
|
3
|
+
# editorconfig.org
|
4
|
+
|
5
|
+
root = true
|
6
|
+
[*]
|
7
|
+
# Change these settings to your own preference
|
8
|
+
indent_style = space
|
9
|
+
indent_size = 2
|
10
|
+
|
11
|
+
# We recommend you to keep these unchanged
|
12
|
+
end_of_line = lf
|
13
|
+
charset = utf-8
|
14
|
+
trim_trailing_whitespace = true
|
15
|
+
insert_final_newline = true
|
16
|
+
|
17
|
+
[*.md]
|
18
|
+
trim_trailing_whitespace = false
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
require:
|
2
|
+
- rubocop-performance
|
3
|
+
- rubocop-rspec
|
4
|
+
|
5
|
+
AllCops:
|
6
|
+
TargetRubyVersion: 2.4.2
|
7
|
+
DisplayCopNames: true
|
8
|
+
NewCops: enable
|
9
|
+
|
10
|
+
Exclude:
|
11
|
+
- bin/**/*
|
12
|
+
- db/**/*
|
13
|
+
- test/**/*
|
14
|
+
- node_modules/**/*
|
15
|
+
- tmp/**/*
|
16
|
+
- Gemfile
|
17
|
+
- vendor/**/*
|
18
|
+
- gemfiles/**/*
|
19
|
+
|
20
|
+
Style/FrozenStringLiteralComment:
|
21
|
+
Enabled: false
|
22
|
+
Style/Documentation:
|
23
|
+
Enabled: false
|
24
|
+
Style/DoubleNegation:
|
25
|
+
Enabled: false
|
26
|
+
Style/ClassAndModuleChildren:
|
27
|
+
EnforcedStyle: compact
|
28
|
+
|
29
|
+
Metrics/AbcSize:
|
30
|
+
Max: 25
|
31
|
+
Layout/LineLength:
|
32
|
+
Max: 120
|
33
|
+
Metrics/MethodLength:
|
34
|
+
Max: 25
|
35
|
+
Metrics/BlockLength:
|
36
|
+
Max: 30
|
37
|
+
Exclude:
|
38
|
+
- "Rakefile"
|
39
|
+
- "**/*.rake"
|
40
|
+
- "spec/**/*.rb"
|
41
|
+
|
42
|
+
Performance/MethodObjectAsBlock:
|
43
|
+
Enabled: false
|
44
|
+
Performance/OpenStruct:
|
45
|
+
Enabled: true
|
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
local_precompile
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-2.4.2
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
4
|
+
|
5
|
+
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
|
6
|
+
|
7
|
+
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
8
|
+
|
9
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
10
|
+
|
11
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
12
|
+
|
13
|
+
This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
data/Gemfile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
3
|
+
ruby '2.4.2'
|
4
|
+
|
5
|
+
gemspec
|
6
|
+
|
7
|
+
gem 'capistrano', '~> 3.10', '>= 3.10.1'
|
8
|
+
gem 'capistrano-rails', '~> 1.1', '>= 1.1.5'
|
9
|
+
gem 'capistrano-rvm', '~> 0.1', '>= 0.1.2'
|
10
|
+
gem 'capistrano-rails-console', '~> 2.3', '>= 2.3.0'
|
11
|
+
|
12
|
+
gem 'activerecord-nulldb-adapter'
|
13
|
+
gem 'airbrussh', '~> 1.0', '>= 1.0.0'
|
14
|
+
|
15
|
+
group :development do
|
16
|
+
gem 'rubocop', '~> 0.71', '>= 0.71.0'
|
17
|
+
gem 'redcarpet', '~> 3.5', '>= 3.5.1'
|
18
|
+
gem 'yard', '~> 0.9', '>= 0.9.26'
|
19
|
+
end
|
data/README.md
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
# Capistrano Local Precompile
|
2
|
+
|
3
|
+
The slowest part in a rails application is in the assets compiling. So let's throw it out! This gem adds a local build of assets and packs right on your machine and then uploads all the files to the server.
|
4
|
+
|
5
|
+
## Usage
|
6
|
+
|
7
|
+
Add local-precompile to your Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
group :development do
|
11
|
+
gem 'local_precompile', '~> 0.0.1', require: false
|
12
|
+
end
|
13
|
+
```
|
14
|
+
|
15
|
+
Then add the following line to your `Capfile`:
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
require 'capistrano/local_precompile'
|
19
|
+
```
|
20
|
+
|
21
|
+
Remove the following line from your `Capfile`:
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
require 'capistrano/rails/assets'
|
25
|
+
```
|
26
|
+
|
27
|
+
Here's the full set of configurable options:
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
set :precompile_env # default: fetch(:rails_env) || 'production'
|
31
|
+
set :assets_dir # default: "public/assets"
|
32
|
+
set :packs_dir # default: "public/packs"
|
33
|
+
set :rsync_cmd # default: "rsync -av --delete"
|
34
|
+
```
|
35
|
+
|
36
|
+
Capistrano supports **dry run** mode. In that case the `rsync` command will not actually be run but only shown in stdout:
|
37
|
+
|
38
|
+
```
|
39
|
+
cap production deploy --dry-run
|
40
|
+
```
|
41
|
+
|
42
|
+
## Acknowledgement
|
43
|
+
|
44
|
+
This gem is based on another gem with the same functionality but improved [capistrano-local-precompile][].
|
45
|
+
|
46
|
+
[capistrano-local-precompile]: https://github.com/stve/capistrano-local-precompile
|
47
|
+
|
48
|
+
In turn that gem is derived from gists by [uhlenbrock][] and [keighl][].
|
49
|
+
|
50
|
+
[uhlenbrock]: https://gist.github.com/uhlenbrock/1477596
|
51
|
+
[keighl]: https://gist.github.com/keighl/4338134
|
52
|
+
|
53
|
+
So many thanks to this guys.
|
54
|
+
|
55
|
+
## Contributing
|
56
|
+
|
57
|
+
Pull requests welcome: fork, make a topic branch, commit (squash when possible) *with tests* and I'll happily consider.
|
58
|
+
|
59
|
+
## Copyright
|
60
|
+
|
61
|
+
Copyright (c) 2021 Denis Arushanov
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
ßrequire "bundler/setup"
|
2
|
+
require "locum_best_practices"
|
3
|
+
|
4
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
5
|
+
# with your gem easier. You can also use a different console, if you like.
|
6
|
+
|
7
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
8
|
+
# require "pry"
|
9
|
+
# Pry.start
|
10
|
+
|
11
|
+
require "irb"
|
12
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
namespace :load do
|
2
|
+
task :defaults do
|
3
|
+
set :assets_dir, 'public/assets'
|
4
|
+
set :packs_dir, 'public/packs'
|
5
|
+
set :rsync_cmd, 'rsync -av --delete'
|
6
|
+
set :assets_role, 'web'
|
7
|
+
|
8
|
+
after 'bundler:install', 'deploy:assets:prepare'
|
9
|
+
after 'deploy:assets:prepare', 'deploy:assets:rsync'
|
10
|
+
after 'deploy:assets:rsync', 'deploy:assets:cleanup'
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
namespace :deploy do
|
15
|
+
namespace :assets do
|
16
|
+
desc 'Remove all local precompiled assets'
|
17
|
+
task :cleanup do
|
18
|
+
run_locally do
|
19
|
+
execute 'rm', '-rf', fetch(:assets_dir)
|
20
|
+
execute 'rm', '-rf', fetch(:packs_dir)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
desc 'Actually precompile the assets locally'
|
25
|
+
task :prepare do
|
26
|
+
run_locally do
|
27
|
+
precompile_env = fetch(:precompile_env) || fetch(:rails_env) || 'production'
|
28
|
+
with rails_env: precompile_env do
|
29
|
+
execute 'DB_ADAPTER=nulldb rake assets:clean'
|
30
|
+
execute 'DB_ADAPTER=nulldb rake assets:precompile'
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
desc 'Performs rsync to app servers'
|
36
|
+
task :rsync do
|
37
|
+
on roles(fetch(:assets_role)), in: :parallel do |server|
|
38
|
+
run_locally do
|
39
|
+
remote_shell = %(-e "ssh -p #{server.port}") if server.port
|
40
|
+
|
41
|
+
commands = []
|
42
|
+
commands << "#{fetch(:rsync_cmd)} #{remote_shell} ./#{fetch(:assets_dir)}/ #{server.user}@#{server.hostname}:#{release_path}/#{fetch(:assets_dir)}/" if Dir.exists?(fetch(:assets_dir))
|
43
|
+
commands << "#{fetch(:rsync_cmd)} #{remote_shell} ./#{fetch(:packs_dir)}/ #{server.user}@#{server.hostname}:#{release_path}/#{fetch(:packs_dir)}/" if Dir.exists?(fetch(:packs_dir))
|
44
|
+
|
45
|
+
commands.each do |command|
|
46
|
+
if dry_run?
|
47
|
+
SSHKit.config.output.info command
|
48
|
+
else
|
49
|
+
execute command
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
load File.expand_path('../../tasks/local_precompile.cap', __FILE__)
|
@@ -0,0 +1 @@
|
|
1
|
+
module LocumBestPractices; end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'local_precompile/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |gem|
|
6
|
+
gem.name = 'local_precompile'
|
7
|
+
gem.version = LocalPrecompile::VERSION
|
8
|
+
gem.authors = %w[DarkWater]
|
9
|
+
gem.email = %w[denis.arushanov@darkcreative.ru]
|
10
|
+
|
11
|
+
gem.summary = 'Local compile assets and packs for Capistrano'
|
12
|
+
gem.description = 'Contains cap tasks'
|
13
|
+
gem.homepage = 'https://github.com/DarkWater666/local_precompile'
|
14
|
+
|
15
|
+
gem.license = 'MIT'
|
16
|
+
|
17
|
+
if gem.respond_to?(:metadata)
|
18
|
+
gem.metadata['allowed_push_host'] = 'https://rubygems.org'
|
19
|
+
else
|
20
|
+
fail 'RubyGems 2.0 or newer is required to protect against public gem pushes.'
|
21
|
+
end
|
22
|
+
|
23
|
+
gem.files = `git ls-files -z`.split("\x0").reject { |f| f.match(/^(test|spec|features)/) }
|
24
|
+
gem.bindir = 'exe'
|
25
|
+
gem.executables = gem.files.grep(/^exe/) { |f| File.basename(f) }
|
26
|
+
gem.require_paths = %w[lib]
|
27
|
+
|
28
|
+
gem.required_ruby_version = '>= 2.4.2'
|
29
|
+
|
30
|
+
gem.add_development_dependency 'bundler', '~> 2.0', '>= 2.0.2'
|
31
|
+
gem.add_development_dependency 'rake', '~> 13.0', '>= 13.0.1'
|
32
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: local_precompile
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- DarkWater
|
@@ -56,7 +56,23 @@ email:
|
|
56
56
|
executables: []
|
57
57
|
extensions: []
|
58
58
|
extra_rdoc_files: []
|
59
|
-
files:
|
59
|
+
files:
|
60
|
+
- ".editorconfig"
|
61
|
+
- ".gitignore"
|
62
|
+
- ".rubocop.yml"
|
63
|
+
- ".ruby-gemset"
|
64
|
+
- ".ruby-version"
|
65
|
+
- CODE_OF_CONDUCT.md
|
66
|
+
- Gemfile
|
67
|
+
- README.md
|
68
|
+
- Rakefile
|
69
|
+
- bin/console
|
70
|
+
- bin/setup
|
71
|
+
- lib/local_precompile.rb
|
72
|
+
- lib/local_precompile/capistrano.rb
|
73
|
+
- lib/local_precompile/tasks.rb
|
74
|
+
- lib/local_precompile/version.rb
|
75
|
+
- local_precompile.gemspec
|
60
76
|
homepage: https://github.com/DarkWater666/local_precompile
|
61
77
|
licenses:
|
62
78
|
- MIT
|