capistrano-rsync-local 1.2 → 2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -4
- data/capistrano-rsync-local.gemspec +1 -3
- data/lib/capistrano-rsync.rb +0 -0
- data/lib/capistrano/rsync.rb +1 -107
- data/lib/capistrano/rsync/scm/svn.rb +9 -8
- data/lib/capistrano/rsync/tasks.rb +5 -0
- data/lib/capistrano/tasks/rsync.cap +100 -0
- metadata +5 -3
- data/lib/capistrano/rsync/version.rb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d61cfcaba0fd9157085b08907d67b0ad584f637a
|
4
|
+
data.tar.gz: 21bf85381764e4dc4b0bf54f924907ded4f8d684
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8138f91c8695c3f4dc21853798d15d85300755251c870d2a03c457c62f3659452058a9a99af902ae488eb1c5138cb56e4076812e748f4aa6a3e66bad3a634c0c
|
7
|
+
data.tar.gz: 46ed927ebad4b994fe1a5c1b46366ba4e0a1ffa859d4709d21371ce46f4804f1dec014543d3e3e8cfa0cb251f799e7755c704a2a7417e5eb26825ad294ce673c
|
data/README.md
CHANGED
@@ -9,20 +9,18 @@ you want to deploy. Also allows you to easily precompile things on your local
|
|
9
9
|
machine before deploying.
|
10
10
|
|
11
11
|
### Tour
|
12
|
-
- Works with
|
12
|
+
- Works with [**Capistrano v3**](http://www.capistranorb.com/) ([source
|
13
13
|
code](https://github.com/capistrano/capistrano)) versions `>= 3.0.0pre14` and
|
14
14
|
`< 4`.
|
15
15
|
- Suitable for deploying any apps, be it Ruby, Rails, Node.js or others.
|
16
16
|
- Exclude files from being deployed with Rsync's `--exclude` options.
|
17
17
|
- Precompile files or assets easily before deploying, like JavaScript or CSS.
|
18
18
|
- Caches your previously deployed code to speed up deployments ~1337%.
|
19
|
-
-
|
20
|
-
your interest in other SCMs.
|
19
|
+
- Works with git and svn.
|
21
20
|
|
22
21
|
Using [Mina](http://nadarei.co/mina/) instead of Capistrano? I've (actuall not me, but Moll) built
|
23
22
|
[Mina::Rsync](https://github.com/moll/mina-rsync) as well.
|
24
23
|
|
25
|
-
|
26
24
|
Using
|
27
25
|
-----
|
28
26
|
Install with:
|
@@ -1,8 +1,6 @@
|
|
1
|
-
require File.expand_path('../lib/capistrano/rsync/version', __FILE__)
|
2
|
-
|
3
1
|
Gem::Specification.new do |gem|
|
4
2
|
gem.name = 'capistrano-rsync-local'
|
5
|
-
gem.version =
|
3
|
+
gem.version = '2.0'
|
6
4
|
gem.homepage = 'https://github.com/tonkonogov/capistrano-rsync'
|
7
5
|
gem.summary = <<-end.strip.gsub(/\s*\n\s*/, " ")
|
8
6
|
Deploy with Rsync from any local (or remote) repository.
|
File without changes
|
data/lib/capistrano/rsync.rb
CHANGED
@@ -1,107 +1 @@
|
|
1
|
-
|
2
|
-
require File.expand_path("../rsync/scm/base", __FILE__)
|
3
|
-
require File.expand_path("../rsync/scm/git", __FILE__)
|
4
|
-
require File.expand_path("../rsync/scm/svn", __FILE__)
|
5
|
-
|
6
|
-
# NOTE: Please don't depend on tasks without a description (`desc`) as they
|
7
|
-
# might change between minor or patch version releases. They make up the
|
8
|
-
# private API and internals of Capistrano::Rsync. If you think something should
|
9
|
-
# be public for extending and hooking, please let me know!
|
10
|
-
|
11
|
-
rsync_cache = lambda do
|
12
|
-
cache = fetch(:rsync_cache)
|
13
|
-
cache = deploy_to + "/" + cache if cache && cache !~ /^\//
|
14
|
-
cache
|
15
|
-
end
|
16
|
-
|
17
|
-
|
18
|
-
Rake::Task["load:defaults"].enhance ["rsync:defaults"]
|
19
|
-
Rake::Task["deploy:check"].enhance ["rsync:hook_scm"]
|
20
|
-
Rake::Task["deploy:updating"].enhance ["rsync:hook_scm"]
|
21
|
-
|
22
|
-
|
23
|
-
desc "Stage and rsync to the server (or its cache)."
|
24
|
-
task :rsync => %w[rsync:stage rsync:ext_stage] do
|
25
|
-
roles(:all).each do |role|
|
26
|
-
user = role.user + "@" if !role.user.nil?
|
27
|
-
|
28
|
-
rsync = %w[rsync]
|
29
|
-
rsync.concat fetch(:rsync_options)
|
30
|
-
rsync << fetch(:rsync_stage) + "/"
|
31
|
-
rsync << "#{user}#{role.hostname}:#{rsync_cache.call || release_path}"
|
32
|
-
|
33
|
-
Kernel.system *rsync
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
namespace :rsync do
|
38
|
-
desc "Load rsync default options."
|
39
|
-
task :defaults do
|
40
|
-
set :rsync_options, []
|
41
|
-
set :rsync_copy, "rsync --archive --acls --xattrs"
|
42
|
-
|
43
|
-
# Scm to use.
|
44
|
-
set :rsync_scm, "git"
|
45
|
-
|
46
|
-
# Stage is used on your local machine for rsyncing from.
|
47
|
-
set :rsync_stage, "tmp/deploy"
|
48
|
-
|
49
|
-
# Cache is used on the server to copy files to from to the release directory.
|
50
|
-
# Saves you rsyncing your whole app folder each time. If you nil rsync_cache,
|
51
|
-
# Capistrano::Rsync will sync straight to the release path.
|
52
|
-
set :rsync_cache, "shared/deploy"
|
53
|
-
set :rsync_local_repo, false
|
54
|
-
|
55
|
-
set :rsync_with_ext, false
|
56
|
-
set :rsync_ext_stage, 'tmp/deploy_ext'
|
57
|
-
end
|
58
|
-
|
59
|
-
# internally needed by capistrano's "deploy.rake"
|
60
|
-
task :set_current_revision do
|
61
|
-
Dir.chdir fetch(:rsync_stage) do
|
62
|
-
cmd = scm_instance.call.get_current_revision_cmd
|
63
|
-
rev = `#{cmd}`
|
64
|
-
set :current_revision, rev
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
task :hook_scm do
|
69
|
-
Rake::Task.define_task("#{scm}:check") do
|
70
|
-
invoke "rsync:check"
|
71
|
-
end
|
72
|
-
|
73
|
-
Rake::Task.define_task("#{scm}:create_release") do
|
74
|
-
invoke "rsync:release"
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
task :check do
|
79
|
-
# Everything's a-okay inherently!
|
80
|
-
end
|
81
|
-
|
82
|
-
task :ext_stage do
|
83
|
-
next unless fetch(:rsync_with_ext)
|
84
|
-
scm_instance.call.get_last_ext_stage
|
85
|
-
end
|
86
|
-
|
87
|
-
desc "Update and freshen the stage repository."
|
88
|
-
task :stage do
|
89
|
-
next if fetch(:rsync_local_repo)
|
90
|
-
scm_instance.call.get_last_main_stage
|
91
|
-
end
|
92
|
-
|
93
|
-
desc "Copy the code to the releases directory."
|
94
|
-
task :release => %w[rsync] do
|
95
|
-
# Skip copying if we've already synced straight to the release directory.
|
96
|
-
next if !fetch(:rsync_cache)
|
97
|
-
|
98
|
-
copy = %(#{fetch(:rsync_copy)} "#{rsync_cache.call}/" "#{release_path}/")
|
99
|
-
on roles(:all) do |host|
|
100
|
-
execute copy
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
# Matches the naming scheme of git tasks.
|
105
|
-
# Plus was part of the public API in Capistrano::Rsync <= v0.2.1.
|
106
|
-
task :create_release => %w[release]
|
107
|
-
end
|
1
|
+
require_relative 'rsync/tasks'
|
@@ -1,7 +1,6 @@
|
|
1
1
|
module Capistrano
|
2
2
|
module Rsync
|
3
3
|
module Scm
|
4
|
-
|
5
4
|
class Svn < Capistrano::Rsync::Scm::Base
|
6
5
|
attr_reader :context
|
7
6
|
|
@@ -9,21 +8,21 @@ module Capistrano
|
|
9
8
|
"svn info | grep '^Revision:' | sed -e 's/^Revision: //'"
|
10
9
|
end
|
11
10
|
|
12
|
-
def
|
13
|
-
|
11
|
+
def run_cmd(list = [])
|
12
|
+
Kernel.system *list
|
14
13
|
end
|
15
14
|
|
16
15
|
def create_stage(repo, path)
|
17
16
|
cmd = []
|
18
17
|
|
19
18
|
clone = %W[svn checkout]
|
20
|
-
clone <<
|
21
|
-
clone <<
|
19
|
+
clone << repo || "."
|
20
|
+
clone << path
|
22
21
|
|
23
22
|
clone << %W[--username #{context.fetch(:rsync_scm_username)}] if context.fetch(:rsync_scm_username)
|
24
23
|
clone << %W[--password #{context.fetch(:rsync_scm_password)}] if context.fetch(:rsync_scm_password)
|
25
24
|
|
26
|
-
|
25
|
+
run_cmd clone.flatten
|
27
26
|
end
|
28
27
|
|
29
28
|
def update_stage
|
@@ -33,18 +32,20 @@ module Capistrano
|
|
33
32
|
update << %W[--username #{context.fetch(:rsync_scm_username)}] if context.fetch(:rsync_scm_username)
|
34
33
|
update << %W[--password #{context.fetch(:rsync_scm_password)}] if context.fetch(:rsync_scm_password)
|
35
34
|
|
36
|
-
|
35
|
+
run_cmd update.flatten
|
37
36
|
|
38
37
|
checkout = %W[svn revert --recursive .]
|
39
|
-
|
38
|
+
run_cmd checkout
|
40
39
|
end
|
41
40
|
|
41
|
+
|
42
42
|
def get_stage(repo_key, path_key)
|
43
43
|
if File.directory?(fetch(path_key))
|
44
44
|
repo = context.fetch(repo_key, ".")
|
45
45
|
path = context.fetch(path_key)
|
46
46
|
create_stage(repo, path)
|
47
47
|
else
|
48
|
+
|
48
49
|
Dir.chdir fetch(path_key) do
|
49
50
|
update_stage
|
50
51
|
end
|
@@ -0,0 +1,100 @@
|
|
1
|
+
rsync_cache = lambda do
|
2
|
+
cache = fetch(:rsync_cache)
|
3
|
+
cache = deploy_to + "/" + cache if cache && cache !~ /^\//
|
4
|
+
cache
|
5
|
+
end
|
6
|
+
|
7
|
+
scm_instance = lambda do
|
8
|
+
scm_class = Capistrano::Rsync::Scm.const_get(:"#{fetch(:rsync_scm).capitalize}")
|
9
|
+
scm_class.new(self)
|
10
|
+
end
|
11
|
+
|
12
|
+
Rake::Task["load:defaults"].enhance ["rsync:defaults"]
|
13
|
+
Rake::Task["deploy:check"].enhance ["rsync:hook_scm"]
|
14
|
+
Rake::Task["deploy:updating"].enhance ["rsync:hook_scm"]
|
15
|
+
|
16
|
+
desc "Stage and rsync to the server (or its cache)."
|
17
|
+
task :rsync => %w[rsync:stage rsync:ext_stage] do
|
18
|
+
roles(:all).each do |role|
|
19
|
+
user = role.user + "@" if !role.user.nil?
|
20
|
+
|
21
|
+
rsync = %w[rsync]
|
22
|
+
rsync.concat fetch(:rsync_options)
|
23
|
+
rsync << fetch(:rsync_stage) + "/"
|
24
|
+
rsync << "#{user}#{role.hostname}:#{rsync_cache.call || release_path}"
|
25
|
+
|
26
|
+
Kernel.system *rsync
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
namespace :rsync do
|
31
|
+
desc "Load rsync default options."
|
32
|
+
task :defaults do
|
33
|
+
set :rsync_options, []
|
34
|
+
set :rsync_copy, "rsync --archive --acls --xattrs"
|
35
|
+
|
36
|
+
# Scm to use.
|
37
|
+
set :rsync_scm, "git"
|
38
|
+
|
39
|
+
# Stage is used on your local machine for rsyncing from.
|
40
|
+
set :rsync_stage, "tmp/deploy"
|
41
|
+
|
42
|
+
# Cache is used on the server to copy files to from to the release directory.
|
43
|
+
# Saves you rsyncing your whole app folder each time. If you nil rsync_cache,
|
44
|
+
# Capistrano::Rsync will sync straight to the release path.
|
45
|
+
set :rsync_cache, "shared/deploy"
|
46
|
+
set :rsync_local_repo, false
|
47
|
+
|
48
|
+
set :rsync_with_ext, false
|
49
|
+
set :rsync_ext_stage, 'tmp/deploy_ext'
|
50
|
+
end
|
51
|
+
|
52
|
+
# internally needed by capistrano's "deploy.rake"
|
53
|
+
task :set_current_revision do
|
54
|
+
Dir.chdir fetch(:rsync_stage) do
|
55
|
+
cmd = scm_instance.call.get_current_revision_cmd
|
56
|
+
rev = `#{cmd}`
|
57
|
+
set :current_revision, rev
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
task :hook_scm do
|
62
|
+
Rake::Task.define_task("#{scm}:check") do
|
63
|
+
invoke "rsync:check"
|
64
|
+
end
|
65
|
+
|
66
|
+
Rake::Task.define_task("#{scm}:create_release") do
|
67
|
+
invoke "rsync:release"
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
task :check do
|
72
|
+
# Everything's a-okay inherently!
|
73
|
+
end
|
74
|
+
|
75
|
+
task :ext_stage do
|
76
|
+
next unless fetch(:rsync_with_ext)
|
77
|
+
scm_instance.call.get_last_ext_stage
|
78
|
+
end
|
79
|
+
|
80
|
+
desc "Update and freshen the stage repository."
|
81
|
+
task :stage do
|
82
|
+
next if fetch(:rsync_local_repo)
|
83
|
+
scm_instance.call.get_last_main_stage
|
84
|
+
end
|
85
|
+
|
86
|
+
desc "Copy the code to the releases directory."
|
87
|
+
task :release => %w[rsync] do
|
88
|
+
# Skip copying if we've already synced straight to the release directory.
|
89
|
+
next if !fetch(:rsync_cache)
|
90
|
+
|
91
|
+
copy = %(#{fetch(:rsync_copy)} "#{rsync_cache.call}/" "#{release_path}/")
|
92
|
+
on roles(:all) do |host|
|
93
|
+
execute copy
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
# Matches the naming scheme of git tasks.
|
98
|
+
# Plus was part of the public API in Capistrano::Rsync <= v0.2.1.
|
99
|
+
task :create_release => %w[release]
|
100
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-rsync-local
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '
|
4
|
+
version: '2.0'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dmitry Tonkonogov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capistrano
|
@@ -49,11 +49,13 @@ files:
|
|
49
49
|
- README.md
|
50
50
|
- Vagrantfile
|
51
51
|
- capistrano-rsync-local.gemspec
|
52
|
+
- lib/capistrano-rsync.rb
|
52
53
|
- lib/capistrano/rsync.rb
|
53
54
|
- lib/capistrano/rsync/scm/base.rb
|
54
55
|
- lib/capistrano/rsync/scm/git.rb
|
55
56
|
- lib/capistrano/rsync/scm/svn.rb
|
56
|
-
- lib/capistrano/rsync/
|
57
|
+
- lib/capistrano/rsync/tasks.rb
|
58
|
+
- lib/capistrano/tasks/rsync.cap
|
57
59
|
- provision.sh
|
58
60
|
homepage: https://github.com/tonkonogov/capistrano-rsync
|
59
61
|
licenses:
|