capistrano-exts 1.8.2 → 1.9.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.
- data/README.md +9 -7
- data/capistrano-exts.gemspec +4 -4
- data/lib/capistrano-exts/receipts/multistage.rb +49 -47
- data/lib/capistrano-exts/version.rb +2 -2
- metadata +22 -18
data/README.md
CHANGED
@@ -1,9 +1,11 @@
|
|
1
|
-
# Capistrano
|
1
|
+
# Capistrano Exts [](http://travis-ci.org/TechnoGate/capistrano-exts)
|
2
2
|
|
3
|
-
|
3
|
+
Capistrano exts is a set of helper tasks to help with the initial server
|
4
4
|
configuration and application provisioning. Things like creating the directory
|
5
5
|
structure, setting up that database, and other one-off you might find yourself
|
6
|
-
doing by hand far too often.
|
6
|
+
doing by hand far too often. It provides many helpful post-deployment tasks to
|
7
|
+
help you import/export database and contents as well as sync one stage with
|
8
|
+
another.
|
7
9
|
|
8
10
|
# Installation
|
9
11
|
|
@@ -16,7 +18,7 @@ gem install capistrano-exts
|
|
16
18
|
or add it to your Gemfile
|
17
19
|
|
18
20
|
```ruby
|
19
|
-
gem 'capistrano-exts', '>=1.
|
21
|
+
gem 'capistrano-exts', '>=1.9.0', :require => false
|
20
22
|
```
|
21
23
|
|
22
24
|
# Setup
|
@@ -145,19 +147,19 @@ with those of staging like so:
|
|
145
147
|
Sync the database only
|
146
148
|
|
147
149
|
```bash
|
148
|
-
$ cap multistage:
|
150
|
+
$ cap multistage:sync:production_database_with_staging
|
149
151
|
```
|
150
152
|
|
151
153
|
Sync the contents only
|
152
154
|
|
153
155
|
```bash
|
154
|
-
$ cap multistage:
|
156
|
+
$ cap multistage:sync:production_contents_with_staging
|
155
157
|
```
|
156
158
|
|
157
159
|
Sync both
|
158
160
|
|
159
161
|
```bash
|
160
|
-
$ cap multistage:
|
162
|
+
$ cap multistage:sync:production_with_staging
|
161
163
|
```
|
162
164
|
|
163
165
|
# License
|
data/capistrano-exts.gemspec
CHANGED
@@ -10,14 +10,14 @@ Gem::Specification.new do |s|
|
|
10
10
|
s.homepage = "https://github.com/TechnoGate/capistrano-exts"
|
11
11
|
s.summary = %q{Set of helper tasks to help with the initial server configuration and application provisioning.}
|
12
12
|
s.description = <<-EOD
|
13
|
-
|
13
|
+
Capistrano exts is a set of helper tasks to help with the initial server
|
14
14
|
configuration and application provisioning. Things like creating the directory
|
15
15
|
structure, setting up that database, and other one-off you might find yourself
|
16
|
-
doing by hand far too often.
|
16
|
+
doing by hand far too often. It provides many helpful post-deployment tasks to
|
17
|
+
help you import/export database and contents as well as sync one stage with
|
18
|
+
another.
|
17
19
|
EOD
|
18
20
|
|
19
|
-
s.rubyforge_project = "capistrano-exts"
|
20
|
-
|
21
21
|
s.files = `git ls-files`.split("\n")
|
22
22
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
23
23
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
@@ -88,62 +88,64 @@ Capistrano::Configuration.instance.load do
|
|
88
88
|
multistages[stage].each { |config, value| set config, value }
|
89
89
|
end
|
90
90
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
stages.
|
95
|
-
|
96
|
-
|
97
|
-
#
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
91
|
+
namespace :sync do
|
92
|
+
# Synchronisations tasks
|
93
|
+
# Don't you just love metaprogramming? I know I fucking do!
|
94
|
+
stages.each do |target_stage|
|
95
|
+
stages.reject { |s| s == target_stage }.each do |source_stage|
|
96
|
+
desc "Synchronise #{target_stage}'s database with #{source_stage}"
|
97
|
+
task "#{target_stage}_database_with_#{source_stage}", :roles => :db, :except => { :no_release => true } do
|
98
|
+
# Ask for a confirmation
|
99
|
+
ask_for_confirmation "I am going to synchronise '#{target_stage}' database with '#{source_stage}', it means I will overwrite the database of '#{target_stage}' with those of '#{source_stage}', are you really sure you would like to continue (Yes, [No], Abort)", default:'N'
|
100
|
+
|
101
|
+
# Generate a random folder name
|
102
|
+
random_folder = random_tmp_file
|
103
|
+
|
104
|
+
# Create the folder
|
105
|
+
FileUtils.mkdir_p random_folder
|
106
|
+
|
107
|
+
# Get the database of the source
|
108
|
+
system "bundle exec cap #{source_stage} mysql:export_db_dump #{random_folder}/database.sql"
|
109
|
+
|
110
|
+
# Send it to the target
|
111
|
+
system "bundle exec cap -S force=true #{target_stage} mysql:import_db_dump #{random_folder}/database.sql"
|
112
|
+
|
113
|
+
# Remove the entire folder
|
114
|
+
FileUtils.rm_rf random_folder
|
115
|
+
end
|
115
116
|
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
117
|
+
desc "Synchronise #{target_stage}'s contents with #{source_stage}"
|
118
|
+
task "#{target_stage}_contents_with_#{source_stage}", :roles => :app, :except => { :no_release => true } do
|
119
|
+
# Ask for a confirmation
|
120
|
+
ask_for_confirmation "I am going to synchronise '#{target_stage}' contents with '#{source_stage}', it means I will overwrite the contents of '#{target_stage}' with those of '#{source_stage}', are you really sure you would like to continue (Yes, [No], Abort)", default:'N'
|
120
121
|
|
121
|
-
|
122
|
-
|
122
|
+
# Generate a random folder name
|
123
|
+
random_folder = random_tmp_file
|
123
124
|
|
124
|
-
|
125
|
-
|
125
|
+
# Create the folder
|
126
|
+
FileUtils.mkdir_p random_folder
|
126
127
|
|
127
|
-
|
128
|
-
|
128
|
+
# Get the contents of the source
|
129
|
+
system "bundle exec cap #{source_stage} contents:export #{random_folder}/contents.tar.gz"
|
129
130
|
|
130
|
-
|
131
|
-
|
131
|
+
# Send them to the target
|
132
|
+
system "bundle exec cap -S force=true #{target_stage} contents:import #{random_folder}/contents.tar.gz"
|
132
133
|
|
133
|
-
|
134
|
-
|
135
|
-
|
134
|
+
# Remove the entire folder
|
135
|
+
FileUtils.rm_rf random_folder
|
136
|
+
end
|
136
137
|
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
138
|
+
desc "Synchronise #{target_stage} with #{source_stage}"
|
139
|
+
task "#{target_stage}_with_#{source_stage}", :roles => [:app, :db], :except => { :no_release => true } do
|
140
|
+
# Ask for a confirmation
|
141
|
+
ask_for_confirmation "I am going to synchronise '#{target_stage}' with '#{source_stage}', it means I will overwrite both the database and the contents of '#{target_stage}' with those of '#{source_stage}', are you really sure you would like to continue (Yes, [No], Abort)", default:'N'
|
141
142
|
|
142
|
-
|
143
|
-
|
143
|
+
# Synchronise the database
|
144
|
+
system "bundle exec cap -S force=true multistage:#{target_stage}_database_with_#{source_stage}"
|
144
145
|
|
145
|
-
|
146
|
-
|
146
|
+
# Synchronise the contents
|
147
|
+
system "bundle exec cap -S force=true multistage:#{target_stage}_contents_with_#{source_stage}"
|
148
|
+
end
|
147
149
|
end
|
148
150
|
end
|
149
151
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-exts
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.9.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2011-09-12 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: capistrano
|
16
|
-
requirement: &
|
16
|
+
requirement: &2151803400 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 2.8.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2151803400
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: i18n
|
27
|
-
requirement: &
|
27
|
+
requirement: &2151801460 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 0.6.0
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2151801460
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: activesupport
|
38
|
-
requirement: &
|
38
|
+
requirement: &2151799900 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 3.1.0
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *2151799900
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: guard
|
49
|
-
requirement: &
|
49
|
+
requirement: &2151798720 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 0.6.2
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *2151798720
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: guard-bundler
|
60
|
-
requirement: &
|
60
|
+
requirement: &2153407400 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: 0.1.3
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *2153407400
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: guard-rspec
|
71
|
-
requirement: &
|
71
|
+
requirement: &2153406580 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: 0.4.3
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *2153406580
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: rspec
|
82
|
-
requirement: &
|
82
|
+
requirement: &2153405280 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,15 +87,19 @@ dependencies:
|
|
87
87
|
version: 2.6.0
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
91
|
-
description: ! '
|
90
|
+
version_requirements: *2153405280
|
91
|
+
description: ! 'Capistrano exts is a set of helper tasks to help with the initial
|
92
92
|
server
|
93
93
|
|
94
94
|
configuration and application provisioning. Things like creating the directory
|
95
95
|
|
96
96
|
structure, setting up that database, and other one-off you might find yourself
|
97
97
|
|
98
|
-
doing by hand far too often.
|
98
|
+
doing by hand far too often. It provides many helpful post-deployment tasks to
|
99
|
+
|
100
|
+
help you import/export database and contents as well as sync one stage with
|
101
|
+
|
102
|
+
another.
|
99
103
|
|
100
104
|
'
|
101
105
|
email:
|
@@ -174,7 +178,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
174
178
|
- !ruby/object:Gem::Version
|
175
179
|
version: '0'
|
176
180
|
requirements: []
|
177
|
-
rubyforge_project:
|
181
|
+
rubyforge_project:
|
178
182
|
rubygems_version: 1.8.10
|
179
183
|
signing_key:
|
180
184
|
specification_version: 3
|