capistrano 2.8.0 → 3.19.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (239) hide show
  1. checksums.yaml +7 -0
  2. data/.docker/Dockerfile +7 -0
  3. data/.docker/ssh_key_rsa +49 -0
  4. data/.docker/ssh_key_rsa.pub +1 -0
  5. data/.docker/ubuntu_setup.sh +23 -0
  6. data/.github/issue_template.md +19 -0
  7. data/.github/pull_request_template.md +22 -0
  8. data/.github/release-drafter.yml +25 -0
  9. data/.github/workflows/ci.yml +80 -0
  10. data/.github/workflows/release-drafter.yml +18 -0
  11. data/.gitignore +23 -8
  12. data/.rubocop.yml +62 -0
  13. data/CHANGELOG.md +1 -0
  14. data/CONTRIBUTING.md +63 -0
  15. data/DEVELOPMENT.md +112 -0
  16. data/Gemfile +42 -9
  17. data/LICENSE.txt +21 -0
  18. data/README.md +221 -0
  19. data/RELEASING.md +17 -0
  20. data/Rakefile +17 -8
  21. data/UPGRADING-3.7.md +86 -0
  22. data/bin/cap +2 -3
  23. data/bin/capify +7 -89
  24. data/capistrano.gemspec +29 -43
  25. data/docker-compose.yml +8 -0
  26. data/features/configuration.feature +28 -0
  27. data/features/deploy.feature +92 -0
  28. data/features/deploy_failure.feature +17 -0
  29. data/features/doctor.feature +11 -0
  30. data/features/installation.feature +21 -0
  31. data/features/sshconnect.feature +11 -0
  32. data/features/stage_failure.feature +9 -0
  33. data/features/step_definitions/assertions.rb +162 -0
  34. data/features/step_definitions/cap_commands.rb +21 -0
  35. data/features/step_definitions/setup.rb +91 -0
  36. data/features/subdirectory.feature +9 -0
  37. data/features/support/docker_gateway.rb +53 -0
  38. data/features/support/env.rb +1 -0
  39. data/features/support/remote_command_helpers.rb +29 -0
  40. data/features/support/remote_ssh_helpers.rb +33 -0
  41. data/lib/Capfile +3 -0
  42. data/lib/capistrano/all.rb +17 -0
  43. data/lib/capistrano/application.rb +153 -0
  44. data/lib/capistrano/configuration/empty_filter.rb +9 -0
  45. data/lib/capistrano/configuration/filter.rb +26 -0
  46. data/lib/capistrano/configuration/host_filter.rb +29 -0
  47. data/lib/capistrano/configuration/null_filter.rb +9 -0
  48. data/lib/capistrano/configuration/plugin_installer.rb +51 -0
  49. data/lib/capistrano/configuration/question.rb +76 -0
  50. data/lib/capistrano/configuration/role_filter.rb +29 -0
  51. data/lib/capistrano/configuration/scm_resolver.rb +149 -0
  52. data/lib/capistrano/configuration/server.rb +137 -0
  53. data/lib/capistrano/configuration/servers.rb +56 -96
  54. data/lib/capistrano/configuration/validated_variables.rb +110 -0
  55. data/lib/capistrano/configuration/variables.rb +79 -94
  56. data/lib/capistrano/configuration.rb +178 -33
  57. data/lib/capistrano/console.rb +1 -0
  58. data/lib/capistrano/defaults.rb +36 -0
  59. data/lib/capistrano/deploy.rb +3 -0
  60. data/lib/capistrano/doctor/environment_doctor.rb +19 -0
  61. data/lib/capistrano/doctor/gems_doctor.rb +45 -0
  62. data/lib/capistrano/doctor/output_helpers.rb +79 -0
  63. data/lib/capistrano/doctor/servers_doctor.rb +105 -0
  64. data/lib/capistrano/doctor/variables_doctor.rb +74 -0
  65. data/lib/capistrano/doctor.rb +6 -0
  66. data/lib/capistrano/dotfile.rb +2 -0
  67. data/lib/capistrano/dsl/env.rb +43 -0
  68. data/lib/capistrano/dsl/paths.rb +89 -0
  69. data/lib/capistrano/dsl/stages.rb +31 -0
  70. data/lib/capistrano/dsl/task_enhancements.rb +61 -0
  71. data/lib/capistrano/dsl.rb +95 -0
  72. data/lib/capistrano/framework.rb +2 -0
  73. data/lib/capistrano/i18n.rb +46 -0
  74. data/lib/capistrano/immutable_task.rb +30 -0
  75. data/lib/capistrano/install.rb +1 -0
  76. data/lib/capistrano/plugin.rb +95 -0
  77. data/lib/capistrano/proc_helpers.rb +13 -0
  78. data/lib/capistrano/scm/git.rb +105 -0
  79. data/lib/capistrano/scm/hg.rb +55 -0
  80. data/lib/capistrano/scm/plugin.rb +13 -0
  81. data/lib/capistrano/scm/svn.rb +56 -0
  82. data/lib/capistrano/scm/tasks/git.rake +84 -0
  83. data/lib/capistrano/scm/tasks/hg.rake +53 -0
  84. data/lib/capistrano/scm/tasks/svn.rake +53 -0
  85. data/lib/capistrano/scm.rb +115 -0
  86. data/lib/capistrano/setup.rb +36 -0
  87. data/lib/capistrano/tasks/console.rake +25 -0
  88. data/lib/capistrano/tasks/deploy.rake +280 -0
  89. data/lib/capistrano/tasks/doctor.rake +24 -0
  90. data/lib/capistrano/tasks/framework.rake +67 -0
  91. data/lib/capistrano/tasks/install.rake +41 -0
  92. data/lib/capistrano/templates/Capfile +38 -0
  93. data/lib/capistrano/templates/deploy.rb.erb +39 -0
  94. data/lib/capistrano/templates/stage.rb.erb +61 -0
  95. data/lib/capistrano/upload_task.rb +9 -0
  96. data/lib/capistrano/version.rb +1 -14
  97. data/lib/capistrano/version_validator.rb +32 -0
  98. data/lib/capistrano.rb +0 -3
  99. data/spec/integration/dsl_spec.rb +632 -0
  100. data/spec/integration_spec_helper.rb +5 -0
  101. data/spec/lib/capistrano/application_spec.rb +60 -0
  102. data/spec/lib/capistrano/configuration/empty_filter_spec.rb +17 -0
  103. data/spec/lib/capistrano/configuration/filter_spec.rb +109 -0
  104. data/spec/lib/capistrano/configuration/host_filter_spec.rb +71 -0
  105. data/spec/lib/capistrano/configuration/null_filter_spec.rb +17 -0
  106. data/spec/lib/capistrano/configuration/plugin_installer_spec.rb +98 -0
  107. data/spec/lib/capistrano/configuration/question_spec.rb +92 -0
  108. data/spec/lib/capistrano/configuration/role_filter_spec.rb +80 -0
  109. data/spec/lib/capistrano/configuration/scm_resolver_spec.rb +56 -0
  110. data/spec/lib/capistrano/configuration/server_spec.rb +309 -0
  111. data/spec/lib/capistrano/configuration/servers_spec.rb +331 -0
  112. data/spec/lib/capistrano/configuration_spec.rb +357 -0
  113. data/spec/lib/capistrano/doctor/environment_doctor_spec.rb +44 -0
  114. data/spec/lib/capistrano/doctor/gems_doctor_spec.rb +67 -0
  115. data/spec/lib/capistrano/doctor/output_helpers_spec.rb +47 -0
  116. data/spec/lib/capistrano/doctor/servers_doctor_spec.rb +86 -0
  117. data/spec/lib/capistrano/doctor/variables_doctor_spec.rb +89 -0
  118. data/spec/lib/capistrano/dsl/paths_spec.rb +228 -0
  119. data/spec/lib/capistrano/dsl/task_enhancements_spec.rb +108 -0
  120. data/spec/lib/capistrano/dsl_spec.rb +125 -0
  121. data/spec/lib/capistrano/immutable_task_spec.rb +31 -0
  122. data/spec/lib/capistrano/plugin_spec.rb +84 -0
  123. data/spec/lib/capistrano/scm/git_spec.rb +194 -0
  124. data/spec/lib/capistrano/scm/hg_spec.rb +109 -0
  125. data/spec/lib/capistrano/scm/svn_spec.rb +137 -0
  126. data/spec/lib/capistrano/scm_spec.rb +103 -0
  127. data/spec/lib/capistrano/upload_task_spec.rb +19 -0
  128. data/spec/lib/capistrano/version_validator_spec.rb +118 -0
  129. data/spec/lib/capistrano_spec.rb +7 -0
  130. data/spec/spec_helper.rb +29 -0
  131. data/spec/support/matchers.rb +5 -0
  132. data/spec/support/tasks/database.rake +11 -0
  133. data/spec/support/tasks/fail.rake +8 -0
  134. data/spec/support/tasks/failed.rake +5 -0
  135. data/spec/support/tasks/plugin.rake +6 -0
  136. data/spec/support/tasks/root.rake +11 -0
  137. data/spec/support/test_app.rb +205 -0
  138. metadata +234 -208
  139. data/.rvmrc +0 -1
  140. data/CHANGELOG +0 -954
  141. data/README.mdown +0 -76
  142. data/lib/capistrano/callback.rb +0 -45
  143. data/lib/capistrano/cli/execute.rb +0 -85
  144. data/lib/capistrano/cli/help.rb +0 -125
  145. data/lib/capistrano/cli/help.txt +0 -81
  146. data/lib/capistrano/cli/options.rb +0 -243
  147. data/lib/capistrano/cli/ui.rb +0 -40
  148. data/lib/capistrano/cli.rb +0 -47
  149. data/lib/capistrano/command.rb +0 -286
  150. data/lib/capistrano/configuration/actions/file_transfer.rb +0 -51
  151. data/lib/capistrano/configuration/actions/inspect.rb +0 -46
  152. data/lib/capistrano/configuration/actions/invocation.rb +0 -298
  153. data/lib/capistrano/configuration/callbacks.rb +0 -148
  154. data/lib/capistrano/configuration/connections.rb +0 -230
  155. data/lib/capistrano/configuration/execution.rb +0 -143
  156. data/lib/capistrano/configuration/loading.rb +0 -197
  157. data/lib/capistrano/configuration/namespaces.rb +0 -197
  158. data/lib/capistrano/configuration/roles.rb +0 -73
  159. data/lib/capistrano/errors.rb +0 -19
  160. data/lib/capistrano/ext/string.rb +0 -5
  161. data/lib/capistrano/extensions.rb +0 -57
  162. data/lib/capistrano/logger.rb +0 -59
  163. data/lib/capistrano/processable.rb +0 -53
  164. data/lib/capistrano/recipes/compat.rb +0 -32
  165. data/lib/capistrano/recipes/deploy/assets.rb +0 -57
  166. data/lib/capistrano/recipes/deploy/dependencies.rb +0 -44
  167. data/lib/capistrano/recipes/deploy/local_dependency.rb +0 -54
  168. data/lib/capistrano/recipes/deploy/remote_dependency.rb +0 -111
  169. data/lib/capistrano/recipes/deploy/scm/accurev.rb +0 -169
  170. data/lib/capistrano/recipes/deploy/scm/base.rb +0 -196
  171. data/lib/capistrano/recipes/deploy/scm/bzr.rb +0 -86
  172. data/lib/capistrano/recipes/deploy/scm/cvs.rb +0 -153
  173. data/lib/capistrano/recipes/deploy/scm/darcs.rb +0 -96
  174. data/lib/capistrano/recipes/deploy/scm/git.rb +0 -282
  175. data/lib/capistrano/recipes/deploy/scm/mercurial.rb +0 -137
  176. data/lib/capistrano/recipes/deploy/scm/none.rb +0 -44
  177. data/lib/capistrano/recipes/deploy/scm/perforce.rb +0 -138
  178. data/lib/capistrano/recipes/deploy/scm/subversion.rb +0 -121
  179. data/lib/capistrano/recipes/deploy/scm.rb +0 -19
  180. data/lib/capistrano/recipes/deploy/strategy/base.rb +0 -88
  181. data/lib/capistrano/recipes/deploy/strategy/checkout.rb +0 -20
  182. data/lib/capistrano/recipes/deploy/strategy/copy.rb +0 -224
  183. data/lib/capistrano/recipes/deploy/strategy/export.rb +0 -20
  184. data/lib/capistrano/recipes/deploy/strategy/remote.rb +0 -52
  185. data/lib/capistrano/recipes/deploy/strategy/remote_cache.rb +0 -57
  186. data/lib/capistrano/recipes/deploy/strategy.rb +0 -19
  187. data/lib/capistrano/recipes/deploy/templates/maintenance.rhtml +0 -53
  188. data/lib/capistrano/recipes/deploy.rb +0 -568
  189. data/lib/capistrano/recipes/standard.rb +0 -37
  190. data/lib/capistrano/recipes/templates/maintenance.rhtml +0 -53
  191. data/lib/capistrano/role.rb +0 -102
  192. data/lib/capistrano/server_definition.rb +0 -56
  193. data/lib/capistrano/shell.rb +0 -260
  194. data/lib/capistrano/ssh.rb +0 -101
  195. data/lib/capistrano/task_definition.rb +0 -75
  196. data/lib/capistrano/transfer.rb +0 -216
  197. data/rvmrc.sample +0 -1
  198. data/test/cli/execute_test.rb +0 -132
  199. data/test/cli/help_test.rb +0 -165
  200. data/test/cli/options_test.rb +0 -329
  201. data/test/cli/ui_test.rb +0 -28
  202. data/test/cli_test.rb +0 -17
  203. data/test/command_test.rb +0 -289
  204. data/test/configuration/actions/file_transfer_test.rb +0 -61
  205. data/test/configuration/actions/inspect_test.rb +0 -65
  206. data/test/configuration/actions/invocation_test.rb +0 -247
  207. data/test/configuration/callbacks_test.rb +0 -220
  208. data/test/configuration/connections_test.rb +0 -420
  209. data/test/configuration/execution_test.rb +0 -175
  210. data/test/configuration/loading_test.rb +0 -132
  211. data/test/configuration/namespace_dsl_test.rb +0 -311
  212. data/test/configuration/roles_test.rb +0 -144
  213. data/test/configuration/servers_test.rb +0 -183
  214. data/test/configuration/variables_test.rb +0 -190
  215. data/test/configuration_test.rb +0 -88
  216. data/test/deploy/local_dependency_test.rb +0 -76
  217. data/test/deploy/remote_dependency_test.rb +0 -135
  218. data/test/deploy/scm/accurev_test.rb +0 -23
  219. data/test/deploy/scm/base_test.rb +0 -55
  220. data/test/deploy/scm/bzr_test.rb +0 -51
  221. data/test/deploy/scm/darcs_test.rb +0 -37
  222. data/test/deploy/scm/git_test.rb +0 -184
  223. data/test/deploy/scm/mercurial_test.rb +0 -134
  224. data/test/deploy/scm/none_test.rb +0 -35
  225. data/test/deploy/scm/subversion_test.rb +0 -32
  226. data/test/deploy/strategy/copy_test.rb +0 -321
  227. data/test/extensions_test.rb +0 -69
  228. data/test/fixtures/cli_integration.rb +0 -5
  229. data/test/fixtures/config.rb +0 -5
  230. data/test/fixtures/custom.rb +0 -3
  231. data/test/logger_test.rb +0 -123
  232. data/test/recipes_test.rb +0 -25
  233. data/test/role_test.rb +0 -11
  234. data/test/server_definition_test.rb +0 -121
  235. data/test/shell_test.rb +0 -90
  236. data/test/ssh_test.rb +0 -113
  237. data/test/task_definition_test.rb +0 -116
  238. data/test/transfer_test.rb +0 -160
  239. data/test/utils.rb +0 -37
@@ -0,0 +1,25 @@
1
+ desc "Execute remote commands"
2
+ task :console do
3
+ stage = fetch(:stage)
4
+ puts I18n.t("console.welcome", scope: :capistrano, stage: stage)
5
+ loop do
6
+ print "#{stage}> "
7
+
8
+ command = (input = $stdin.gets) ? input.chomp : "exit"
9
+
10
+ next if command.empty?
11
+
12
+ if %w{quit exit q}.include? command
13
+ puts t("console.bye")
14
+ break
15
+ else
16
+ begin
17
+ on roles :all do
18
+ execute command
19
+ end
20
+ rescue => e
21
+ puts e
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,280 @@
1
+ namespace :deploy do
2
+ task :starting do
3
+ invoke "deploy:print_config_variables" if fetch(:print_config_variables, false)
4
+ invoke "deploy:check"
5
+ invoke "deploy:set_previous_revision"
6
+ invoke "deploy:set_previous_revision_time"
7
+ end
8
+
9
+ task :print_config_variables do
10
+ puts
11
+ puts "------- Printing current config variables -------"
12
+ env.keys.each do |config_variable_key|
13
+ if is_question?(config_variable_key)
14
+ puts "#{config_variable_key.inspect} => Question (awaits user input on next fetch(#{config_variable_key.inspect}))"
15
+ else
16
+ puts "#{config_variable_key.inspect} => #{fetch(config_variable_key).inspect}"
17
+ end
18
+ end
19
+
20
+ puts
21
+ puts "------- Printing current config variables of SSHKit mechanism -------"
22
+ puts env.backend.config.inspect
23
+ # puts env.backend.config.backend.config.ssh_options.inspect
24
+ # puts env.backend.config.command_map.defaults.inspect
25
+
26
+ puts
27
+ end
28
+
29
+ task updating: :new_release_path do
30
+ invoke "deploy:set_current_revision"
31
+ invoke "deploy:set_current_revision_time"
32
+ invoke "deploy:symlink:shared"
33
+ end
34
+
35
+ task :reverting do
36
+ invoke "deploy:revert_release"
37
+ end
38
+
39
+ task :publishing do
40
+ invoke "deploy:symlink:release"
41
+ end
42
+
43
+ task :finishing do
44
+ invoke "deploy:cleanup"
45
+ end
46
+
47
+ task :finishing_rollback do
48
+ invoke "deploy:cleanup_rollback"
49
+ end
50
+
51
+ task :finished do
52
+ invoke "deploy:log_revision"
53
+ end
54
+
55
+ desc "Check required files and directories exist"
56
+ task :check do
57
+ invoke "deploy:check:directories"
58
+ invoke "deploy:check:linked_dirs"
59
+ invoke "deploy:check:make_linked_dirs"
60
+ invoke "deploy:check:linked_files"
61
+ end
62
+
63
+ namespace :check do
64
+ desc "Check shared and release directories exist"
65
+ task :directories do
66
+ on release_roles :all do
67
+ execute :mkdir, "-p", shared_path, releases_path
68
+ end
69
+ end
70
+
71
+ desc "Check directories to be linked exist in shared"
72
+ task :linked_dirs do
73
+ next unless any? :linked_dirs
74
+ on release_roles :all do
75
+ execute :mkdir, "-p", linked_dirs(shared_path)
76
+ end
77
+ end
78
+
79
+ desc "Check directories of files to be linked exist in shared"
80
+ task :make_linked_dirs do
81
+ next unless any? :linked_files
82
+ on release_roles :all do |_host|
83
+ execute :mkdir, "-p", linked_file_dirs(shared_path)
84
+ end
85
+ end
86
+
87
+ desc "Check files to be linked exist in shared"
88
+ task :linked_files do
89
+ next unless any? :linked_files
90
+ on release_roles :all do |host|
91
+ linked_files(shared_path).each do |file|
92
+ unless test "[ -f #{file} ]"
93
+ error t(:linked_file_does_not_exist, file: file, host: host)
94
+ exit 1
95
+ end
96
+ end
97
+ end
98
+ end
99
+ end
100
+
101
+ namespace :symlink do
102
+ desc "Symlink release to current"
103
+ task :release do
104
+ on release_roles :all do
105
+ tmp_current_path = release_path.parent.join(current_path.basename)
106
+ execute :ln, "-s", release_path, tmp_current_path
107
+ execute :mv, tmp_current_path, current_path.parent
108
+ end
109
+ end
110
+
111
+ desc "Symlink files and directories from shared to release"
112
+ task :shared do
113
+ invoke "deploy:symlink:linked_files"
114
+ invoke "deploy:symlink:linked_dirs"
115
+ end
116
+
117
+ desc "Symlink linked directories"
118
+ task :linked_dirs do
119
+ next unless any? :linked_dirs
120
+ on release_roles :all do
121
+ execute :mkdir, "-p", linked_dir_parents(release_path)
122
+
123
+ fetch(:linked_dirs).each do |dir|
124
+ target = release_path.join(dir)
125
+ source = shared_path.join(dir)
126
+ next if test "[ -L #{target} ]"
127
+ execute :rm, "-rf", target if test "[ -d #{target} ]"
128
+ execute :ln, "-s", source, target
129
+ end
130
+ end
131
+ end
132
+
133
+ desc "Symlink linked files"
134
+ task :linked_files do
135
+ next unless any? :linked_files
136
+ on release_roles :all do
137
+ execute :mkdir, "-p", linked_file_dirs(release_path)
138
+
139
+ fetch(:linked_files).each do |file|
140
+ target = release_path.join(file)
141
+ source = shared_path.join(file)
142
+ next if test "[ -L #{target} ]"
143
+ execute :rm, target if test "[ -f #{target} ]"
144
+ execute :ln, "-s", source, target
145
+ end
146
+ end
147
+ end
148
+ end
149
+
150
+ desc "Clean up old releases"
151
+ task :cleanup do
152
+ on release_roles :all do |host|
153
+ releases = capture(:ls, "-x", releases_path).split
154
+ valid, invalid = releases.partition { |e| /^\d{14}$/ =~ e }
155
+
156
+ warn t(:skip_cleanup, host: host.to_s) if invalid.any?
157
+
158
+ if valid.count >= fetch(:keep_releases)
159
+ info t(:keeping_releases, host: host.to_s, keep_releases: fetch(:keep_releases), releases: valid.count)
160
+ directories = (valid - valid.last(fetch(:keep_releases))).map do |release|
161
+ releases_path.join(release).to_s
162
+ end
163
+ if test("[ -d #{current_path} ]")
164
+ current_release = capture(:readlink, current_path).to_s
165
+ if directories.include?(current_release)
166
+ warn t(:wont_delete_current_release, host: host.to_s)
167
+ directories.delete(current_release)
168
+ end
169
+ else
170
+ debug t(:no_current_release, host: host.to_s)
171
+ end
172
+ if directories.any?
173
+ directories.each_slice(100) do |directories_batch|
174
+ execute :rm, "-rf", *directories_batch
175
+ end
176
+ else
177
+ info t(:no_old_releases, host: host.to_s, keep_releases: fetch(:keep_releases))
178
+ end
179
+ end
180
+ end
181
+ end
182
+
183
+ desc "Remove and archive rolled-back release."
184
+ task :cleanup_rollback do
185
+ on release_roles(:all) do
186
+ last_release = capture(:ls, "-xt", releases_path).split.first
187
+ last_release_path = releases_path.join(last_release)
188
+ if test "[ `readlink #{current_path}` != #{last_release_path} ]"
189
+ execute :tar, "-czf",
190
+ deploy_path.join("rolled-back-release-#{last_release}.tar.gz"),
191
+ last_release_path
192
+ execute :rm, "-rf", last_release_path
193
+ else
194
+ debug "Last release is the current release, skip cleanup_rollback."
195
+ end
196
+ end
197
+ end
198
+
199
+ desc "Log details of the deploy"
200
+ task :log_revision do
201
+ on release_roles(:all) do
202
+ within releases_path do
203
+ execute :echo, %Q{"#{revision_log_message}" >> #{revision_log}}
204
+ end
205
+ end
206
+ end
207
+
208
+ desc "Revert to previous release timestamp"
209
+ task revert_release: :rollback_release_path do
210
+ on release_roles(:all) do
211
+ set(:revision_log_message, rollback_log_message)
212
+ end
213
+ end
214
+
215
+ task :new_release_path do
216
+ set_release_path
217
+ end
218
+
219
+ task :rollback_release_path do
220
+ on release_roles(:all) do
221
+ releases = capture(:ls, "-xt", releases_path).split
222
+ if releases.count < 2
223
+ error t(:cannot_rollback)
224
+ exit 1
225
+ end
226
+
227
+ rollback_release = ENV["ROLLBACK_RELEASE"]
228
+ index = rollback_release.nil? ? 1 : releases.index(rollback_release)
229
+ if index.nil?
230
+ error t(:cannot_found_rollback_release, release: rollback_release)
231
+ exit 1
232
+ end
233
+
234
+ last_release = releases[index]
235
+ set_release_path(last_release)
236
+ set(:rollback_timestamp, last_release)
237
+ end
238
+ end
239
+
240
+ desc "Place a REVISION file with the current revision SHA in the current release path"
241
+ task :set_current_revision do
242
+ on release_roles(:all) do
243
+ within release_path do
244
+ execute :echo, "\"#{fetch(:current_revision)}\" > REVISION"
245
+ end
246
+ end
247
+ end
248
+
249
+ task :set_previous_revision do
250
+ on release_roles(:all) do
251
+ target = release_path.join("REVISION")
252
+ if test "[ -f #{target} ]"
253
+ set(:previous_revision, capture(:cat, target, "2>/dev/null"))
254
+ end
255
+ end
256
+ end
257
+
258
+ desc "Place a REVISION_TIME file with the current revision commit time in the current release path"
259
+ task :set_current_revision_time do
260
+ on release_roles(:all) do
261
+ within release_path do
262
+ if fetch(:current_revision_time)
263
+ execute :echo, "\"#{fetch(:current_revision_time)}\" > REVISION_TIME"
264
+ end
265
+ end
266
+ end
267
+ end
268
+
269
+ task :set_previous_revision_time do
270
+ on release_roles(:all) do
271
+ target = release_path.join("REVISION_TIME")
272
+ if test "[ -f #{target} ]"
273
+ set(:previous_revision_time, capture(:cat, target, "2>/dev/null"))
274
+ end
275
+ end
276
+ end
277
+
278
+ task :restart
279
+ task :failed
280
+ end
@@ -0,0 +1,24 @@
1
+ desc "Display a Capistrano troubleshooting report (all doctor: tasks)"
2
+ task doctor: ["doctor:environment", "doctor:gems", "doctor:variables", "doctor:servers"]
3
+
4
+ namespace :doctor do
5
+ desc "Display Ruby environment details"
6
+ task :environment do
7
+ Capistrano::Doctor::EnvironmentDoctor.new.call
8
+ end
9
+
10
+ desc "Display Capistrano gem versions"
11
+ task :gems do
12
+ Capistrano::Doctor::GemsDoctor.new.call
13
+ end
14
+
15
+ desc "Display the values of all Capistrano variables"
16
+ task :variables do
17
+ Capistrano::Doctor::VariablesDoctor.new.call
18
+ end
19
+
20
+ desc "Display the effective servers configuration"
21
+ task :servers do
22
+ Capistrano::Doctor::ServersDoctor.new.call
23
+ end
24
+ end
@@ -0,0 +1,67 @@
1
+ namespace :deploy do
2
+ desc "Start a deployment, make sure server(s) ready."
3
+ task :starting do
4
+ end
5
+
6
+ desc "Started"
7
+ task :started do
8
+ end
9
+
10
+ desc "Update server(s) by setting up a new release."
11
+ task :updating do
12
+ end
13
+
14
+ desc "Updated"
15
+ task :updated do
16
+ end
17
+
18
+ desc "Revert server(s) to previous release."
19
+ task :reverting do
20
+ end
21
+
22
+ desc "Reverted"
23
+ task :reverted do
24
+ end
25
+
26
+ desc "Publish the release."
27
+ task :publishing do
28
+ end
29
+
30
+ desc "Published"
31
+ task :published do
32
+ end
33
+
34
+ desc "Finish the deployment, clean up server(s)."
35
+ task :finishing do
36
+ end
37
+
38
+ desc "Finish the rollback, clean up server(s)."
39
+ task :finishing_rollback do
40
+ end
41
+
42
+ desc "Finished"
43
+ task :finished do
44
+ end
45
+
46
+ desc "Rollback to previous release."
47
+ task :rollback do
48
+ %w{ starting started
49
+ reverting reverted
50
+ publishing published
51
+ finishing_rollback finished }.each do |task|
52
+ invoke "deploy:#{task}"
53
+ end
54
+ end
55
+ end
56
+
57
+ desc "Deploy a new release."
58
+ task :deploy do
59
+ set(:deploying, true)
60
+ %w{ starting started
61
+ updating updated
62
+ publishing published
63
+ finishing finished }.each do |task|
64
+ invoke "deploy:#{task}"
65
+ end
66
+ end
67
+ task default: :deploy
@@ -0,0 +1,41 @@
1
+ require "erb"
2
+ require "pathname"
3
+ desc "Install Capistrano, cap install STAGES=staging,production"
4
+ task :install do
5
+ envs = ENV["STAGES"] || "staging,production"
6
+
7
+ tasks_dir = Pathname.new("lib/capistrano/tasks")
8
+ config_dir = Pathname.new("config")
9
+ deploy_dir = config_dir.join("deploy")
10
+
11
+ deploy_rb = File.expand_path("../../templates/deploy.rb.erb", __FILE__)
12
+ stage_rb = File.expand_path("../../templates/stage.rb.erb", __FILE__)
13
+ capfile = File.expand_path("../../templates/Capfile", __FILE__)
14
+
15
+ mkdir_p deploy_dir
16
+
17
+ entries = [{ template: deploy_rb, file: config_dir.join("deploy.rb") }]
18
+ entries += envs.split(",").map { |stage| { template: stage_rb, file: deploy_dir.join("#{stage}.rb") } }
19
+
20
+ entries.each do |entry|
21
+ if File.exist?(entry[:file])
22
+ warn "[skip] #{entry[:file]} already exists"
23
+ else
24
+ File.open(entry[:file], "w+") do |f|
25
+ f.write(ERB.new(File.read(entry[:template])).result(binding))
26
+ puts I18n.t(:written_file, scope: :capistrano, file: entry[:file])
27
+ end
28
+ end
29
+ end
30
+
31
+ mkdir_p tasks_dir
32
+
33
+ if File.exist?("Capfile")
34
+ warn "[skip] Capfile already exists"
35
+ else
36
+ FileUtils.cp(capfile, "Capfile")
37
+ puts I18n.t(:written_file, scope: :capistrano, file: "Capfile")
38
+ end
39
+
40
+ puts I18n.t :capified, scope: :capistrano
41
+ end
@@ -0,0 +1,38 @@
1
+ # Load DSL and set up stages
2
+ require "capistrano/setup"
3
+
4
+ # Include default deployment tasks
5
+ require "capistrano/deploy"
6
+
7
+ # Load the SCM plugin appropriate to your project:
8
+ #
9
+ # require "capistrano/scm/hg"
10
+ # install_plugin Capistrano::SCM::Hg
11
+ # or
12
+ # require "capistrano/scm/svn"
13
+ # install_plugin Capistrano::SCM::Svn
14
+ # or
15
+ require "capistrano/scm/git"
16
+ install_plugin Capistrano::SCM::Git
17
+
18
+ # Include tasks from other gems included in your Gemfile
19
+ #
20
+ # For documentation on these, see for example:
21
+ #
22
+ # https://github.com/capistrano/rvm
23
+ # https://github.com/capistrano/rbenv
24
+ # https://github.com/capistrano/chruby
25
+ # https://github.com/capistrano/bundler
26
+ # https://github.com/capistrano/rails
27
+ # https://github.com/capistrano/passenger
28
+ #
29
+ # require "capistrano/rvm"
30
+ # require "capistrano/rbenv"
31
+ # require "capistrano/chruby"
32
+ # require "capistrano/bundler"
33
+ # require "capistrano/rails/assets"
34
+ # require "capistrano/rails/migrations"
35
+ # require "capistrano/passenger"
36
+
37
+ # Load custom tasks from `lib/capistrano/tasks` if you have any defined
38
+ Dir.glob("lib/capistrano/tasks/*.rake").each { |r| import r }
@@ -0,0 +1,39 @@
1
+ # config valid for current version and patch releases of Capistrano
2
+ lock "~> <%= Capistrano::VERSION %>"
3
+
4
+ set :application, "my_app_name"
5
+ set :repo_url, "git@example.com:me/my_repo.git"
6
+
7
+ # Default branch is :master
8
+ # ask :branch, `git rev-parse --abbrev-ref HEAD`.chomp
9
+
10
+ # Default deploy_to directory is /var/www/my_app_name
11
+ # set :deploy_to, "/var/www/my_app_name"
12
+
13
+ # Default value for :format is :airbrussh.
14
+ # set :format, :airbrussh
15
+
16
+ # You can configure the Airbrussh format using :format_options.
17
+ # These are the defaults.
18
+ # set :format_options, command_output: true, log_file: "log/capistrano.log", color: :auto, truncate: :auto
19
+
20
+ # Default value for :pty is false
21
+ # set :pty, true
22
+
23
+ # Default value for :linked_files is []
24
+ # append :linked_files, "config/database.yml", 'config/master.key'
25
+
26
+ # Default value for linked_dirs is []
27
+ # append :linked_dirs, "log", "tmp/pids", "tmp/cache", "tmp/sockets", "public/system", "vendor", "storage"
28
+
29
+ # Default value for default_env is {}
30
+ # set :default_env, { path: "/opt/ruby/bin:$PATH" }
31
+
32
+ # Default value for local_user is ENV['USER']
33
+ # set :local_user, -> { `git config user.name`.chomp }
34
+
35
+ # Default value for keep_releases is 5
36
+ # set :keep_releases, 5
37
+
38
+ # Uncomment the following to require manually verifying the host key before first deploy.
39
+ # set :ssh_options, verify_host_key: :secure
@@ -0,0 +1,61 @@
1
+ # server-based syntax
2
+ # ======================
3
+ # Defines a single server with a list of roles and multiple properties.
4
+ # You can define all roles on a single server, or split them:
5
+
6
+ # server "example.com", user: "deploy", roles: %w{app db web}, my_property: :my_value
7
+ # server "example.com", user: "deploy", roles: %w{app web}, other_property: :other_value
8
+ # server "db.example.com", user: "deploy", roles: %w{db}
9
+
10
+
11
+
12
+ # role-based syntax
13
+ # ==================
14
+
15
+ # Defines a role with one or multiple servers. The primary server in each
16
+ # group is considered to be the first unless any hosts have the primary
17
+ # property set. Specify the username and a domain or IP for the server.
18
+ # Don't use `:all`, it's a meta role.
19
+
20
+ # role :app, %w{deploy@example.com}, my_property: :my_value
21
+ # role :web, %w{user1@primary.com user2@additional.com}, other_property: :other_value
22
+ # role :db, %w{deploy@example.com}
23
+
24
+
25
+
26
+ # Configuration
27
+ # =============
28
+ # You can set any configuration variable like in config/deploy.rb
29
+ # These variables are then only loaded and set in this stage.
30
+ # For available Capistrano configuration variables see the documentation page.
31
+ # http://capistranorb.com/documentation/getting-started/configuration/
32
+ # Feel free to add new variables to customise your setup.
33
+
34
+
35
+
36
+ # Custom SSH Options
37
+ # ==================
38
+ # You may pass any option but keep in mind that net/ssh understands a
39
+ # limited set of options, consult the Net::SSH documentation.
40
+ # http://net-ssh.github.io/net-ssh/classes/Net/SSH.html#method-c-start
41
+ #
42
+ # Global options
43
+ # --------------
44
+ # set :ssh_options, {
45
+ # keys: %w(/home/user_name/.ssh/id_rsa),
46
+ # forward_agent: false,
47
+ # auth_methods: %w(password)
48
+ # }
49
+ #
50
+ # The server-based syntax can be used to override options:
51
+ # ------------------------------------
52
+ # server "example.com",
53
+ # user: "user_name",
54
+ # roles: %w{web app},
55
+ # ssh_options: {
56
+ # user: "user_name", # overrides user setting above
57
+ # keys: %w(/home/user_name/.ssh/id_rsa),
58
+ # forward_agent: false,
59
+ # auth_methods: %w(publickey password)
60
+ # # password: "please use keys"
61
+ # }
@@ -0,0 +1,9 @@
1
+ require "rake/file_creation_task"
2
+
3
+ module Capistrano
4
+ class UploadTask < Rake::FileCreationTask
5
+ def needed?
6
+ true # always needed because we can't check remote hosts
7
+ end
8
+ end
9
+ end
@@ -1,16 +1,3 @@
1
- require 'scanf'
2
1
  module Capistrano
3
-
4
- class Version
5
-
6
- MAJOR = 2
7
- MINOR = 8
8
- PATCH = 0
9
-
10
- def self.to_s
11
- "#{MAJOR}.#{MINOR}.#{PATCH}"
12
- end
13
-
14
- end
15
-
2
+ VERSION = "3.19.0".freeze
16
3
  end
@@ -0,0 +1,32 @@
1
+ module Capistrano
2
+ class VersionValidator
3
+ def initialize(version)
4
+ @version = version
5
+ end
6
+
7
+ def verify
8
+ return self if match?
9
+ raise "Capfile locked at #{version}, but #{current_version} is loaded"
10
+ end
11
+
12
+ private
13
+
14
+ attr_reader :version
15
+
16
+ def match?
17
+ available =~ requested
18
+ end
19
+
20
+ def current_version
21
+ VERSION
22
+ end
23
+
24
+ def available
25
+ Gem::Dependency.new("cap", version)
26
+ end
27
+
28
+ def requested
29
+ Gem::Dependency.new("cap", current_version)
30
+ end
31
+ end
32
+ end
data/lib/capistrano.rb CHANGED
@@ -1,3 +0,0 @@
1
- require 'capistrano/configuration'
2
- require 'capistrano/extensions'
3
- require 'capistrano/ext/string'