railsless-deploy 1.1.2 → 1.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 44404d3ba6e97eca9c0ce0a5b9776354fa3cfd5c
4
- data.tar.gz: 8e55136724a51f0db29a3696cc7d60b84b6b5f90
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MzY3NjE1NzJiM2E1ZGMwMTc5NGEzNGIxZTJhNjlkODhlYTAxNTEyYQ==
5
+ data.tar.gz: !binary |-
6
+ MGIyZjIxYWY0YTVhMjJjZGYzYjFlNGIxOTRkNDAwNmNjNzIxZmY4ZQ==
5
7
  SHA512:
6
- metadata.gz: aa720a4d5b546f91295ad03f2782a8d29f4190262394aea38dfd5cb0191fe66d71f67120f6af80b9a4e9c7715006441b5d587b511a8f42cb0c3150492b136f8a
7
- data.tar.gz: ad4beba3001a37e439a0241a7ce8d6db1416b56cc42b8d0f6c3ceed936dfe8091ee43bac0f09e1ef8f5688df978ecf24600db589bf80e7742d0d9dbd1c5513c8
8
+ metadata.gz: !binary |-
9
+ ZTdjYTU3ODRlODM0ZTdmMzYzZGNlYmYxMTAzMWU3NzdiOGE3NDBlMTRiM2U3
10
+ NmIzYWFhZWE3NDZhZTliNWNjYjhmMmUyNDliNjg0Zjc0Mjc2ZWRjNDkyOGYy
11
+ MTI3NGUzOWI5MDUzNTM3ZWNlMzQzZmU2YjU0OWQwOTE2OGY2OTU=
12
+ data.tar.gz: !binary |-
13
+ OWQwMDVjMzQ4NDA1YWJkODE3MTJkYWRlNDJmNmQ5NjMzZDMzZTdjMTFmMWMz
14
+ OTgzNjUwYTE2MTE3OTkxYjExZDkyN2ZiYWIzZTM3ZDlhNDNjMzY0YzUxNWE1
15
+ MzIzZGVkOTk0NDYzNTVmMzYzYmZkMGEyYTRmNDFjNGNlNWI3NTE=
@@ -0,0 +1 @@
1
+ /*.gem
@@ -1,5 +1,9 @@
1
1
  # Lee Hambley's Railsless Deploy
2
2
 
3
+ ## 1.1.3 – Dec 13 2013
4
+
5
+ * Manually merge in code from [Capistrano 2.15.5's `lib/capistrano/recipes/deploy.rb`](https://github.com/capistrano/capistrano/blob/2.15.5/lib/capistrano/recipes/deploy.rb) to provide feature parity with last release of Cap 2.x.
6
+
3
7
  ## 1.1.2 - May 28 2013
4
8
 
5
9
  * Small change not to set latest_release if there are no old releases.
@@ -1,3 +1,7 @@
1
+ # This Project Is Obsolete
2
+
3
+ **Note:** Capistrano 3 (http://www.capistranorb.com/) doesn't ship with any Railsisms, and is better in almost every measurable way than Capistrano 2 + `raileless-deploy`. It's time to switch, as I won't be maintaining this Gem anymore!
4
+
1
5
  # Lee Hambley's Railsless Deploy
2
6
 
3
7
  If you want to get the most out of Capistrano and you do not want to have to deal with the *railsisms* that ship by default, this is the gem for you.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.2
1
+ 1.1.3
@@ -22,7 +22,7 @@ Capistrano::Configuration.instance(:must_exist).load do
22
22
  # are not sufficient.
23
23
  # =========================================================================
24
24
 
25
- _cset :scm, :subversion
25
+ _cset(:scm) { scm_default }
26
26
  _cset :deploy_via, :checkout
27
27
 
28
28
  _cset(:deploy_to) { "/u/apps/#{application}" }
@@ -39,6 +39,7 @@ Capistrano::Configuration.instance(:must_exist).load do
39
39
 
40
40
  _cset(:strategy) { Capistrano::Deploy::Strategy.new(deploy_via, self) }
41
41
 
42
+ # If overriding release name, please also select an appropriate setting for :releases below.
42
43
  _cset(:release_name) { set :deploy_timestamped, true; Time.now.utc.strftime("%Y%m%d%H%M%S") }
43
44
 
44
45
  _cset :version_dir, "releases"
@@ -51,27 +52,56 @@ Capistrano::Configuration.instance(:must_exist).load do
51
52
  _cset(:current_path) { File.join(deploy_to, current_dir) }
52
53
  _cset(:release_path) { File.join(releases_path, release_name) }
53
54
 
54
- _cset(:releases) { capture("ls -xt #{releases_path}").split.reverse }
55
- _cset(:current_release) { releases.any? ? File.join(releases_path, releases.last) : nil }
55
+ _cset(:releases) { capture("#{try_sudo} ls -x #{releases_path}", :except => { :no_release => true }).split.sort }
56
+ _cset(:current_release) { releases.length > 0 ? File.join(releases_path, releases.last) : nil }
56
57
  _cset(:previous_release) { releases.length > 1 ? File.join(releases_path, releases[-2]) : nil }
57
58
 
58
- _cset(:current_revision) { capture("cat #{current_path}/REVISION").chomp }
59
- _cset(:latest_revision) { capture("cat #{current_release}/REVISION").chomp }
60
- _cset(:previous_revision) { capture("cat #{previous_release}/REVISION").chomp }
59
+ _cset(:current_revision) { capture("#{try_sudo} cat #{current_path}/REVISION", :except => { :no_release => true }).chomp }
60
+ _cset(:latest_revision) { capture("#{try_sudo} cat #{current_release}/REVISION", :except => { :no_release => true }).chomp }
61
+ _cset(:previous_revision) { capture("#{try_sudo} cat #{previous_release}/REVISION", :except => { :no_release => true }).chomp if previous_release }
61
62
 
62
63
  _cset(:run_method) { fetch(:use_sudo, true) ? :sudo : :run }
63
64
 
64
- # some tasks, like create_symlink, need to always point at the latest release, but
65
+ # some tasks, like symlink, need to always point at the latest release, but
65
66
  # they can also (occassionally) be called standalone. In the standalone case,
66
67
  # the timestamped release_path will be inaccurate, since the directory won't
67
- # actually exist. This variable lets tasks like create_symlink work either in the
68
+ # actually exist. This variable lets tasks like symlink work either in the
68
69
  # standalone case, or during deployment.
69
70
  _cset(:latest_release) { exists?(:deploy_timestamped) ? release_path : current_release }
70
71
 
72
+ _cset :maintenance_basename, "maintenance"
73
+ _cset(:maintenance_template_path) { File.join(File.dirname(__FILE__), "templates", "maintenance.rhtml") }
71
74
  # =========================================================================
72
75
  # These are helper methods that will be available to your recipes.
73
76
  # =========================================================================
74
77
 
78
+ # Checks known version control directories to intelligently set the version
79
+ # control in-use. For example, if a .svn directory exists in the project,
80
+ # it will set the :scm variable to :subversion, if a .git directory exists
81
+ # in the project, it will set the :scm variable to :git and so on. If no
82
+ # directory is found, it will default to :git.
83
+ def scm_default
84
+ if File.exist? '.git'
85
+ :git
86
+ elsif File.exist? '.accurev'
87
+ :accurev
88
+ elsif File.exist? '.bzr'
89
+ :bzr
90
+ elsif File.exist? '.cvs'
91
+ :cvs
92
+ elsif File.exist? '_darcs'
93
+ :darcs
94
+ elsif File.exist? '.hg'
95
+ :mercurial
96
+ elsif File.exist? '.perforce'
97
+ :perforce
98
+ elsif File.exist? '.svn'
99
+ :subversion
100
+ else
101
+ :none
102
+ end
103
+ end
104
+
75
105
  # Auxiliary helper method for the `deploy:check' task. Lets you set up your
76
106
  # own dependencies.
77
107
  def depend(location, type, *args)
@@ -94,8 +124,19 @@ Capistrano::Configuration.instance(:must_exist).load do
94
124
  # logs the command then executes it locally.
95
125
  # returns the command output as a string
96
126
  def run_locally(cmd)
127
+ if dry_run
128
+ return logger.debug "executing locally: #{cmd.inspect}"
129
+ end
97
130
  logger.trace "executing locally: #{cmd.inspect}" if logger
98
- `#{cmd}`
131
+ output_on_stdout = nil
132
+ elapsed = Benchmark.realtime do
133
+ output_on_stdout = `#{cmd}`
134
+ end
135
+ if $?.to_i > 0 # $? is command exit code (posix style)
136
+ raise Capistrano::LocalArgumentError, "Command #{cmd} returned status code #{$?}"
137
+ end
138
+ logger.trace "command finished in #{(elapsed * 1000).round}ms" if logger
139
+ output_on_stdout
99
140
  end
100
141
 
101
142
  # If a command is given, this will try to execute the given command, as
@@ -111,7 +152,7 @@ Capistrano::Configuration.instance(:must_exist).load do
111
152
  # THUS, if you want to try to run something via sudo, and what to use the
112
153
  # root user, you'd just to try_sudo('something'). If you wanted to try_sudo as
113
154
  # someone else, you'd just do try_sudo('something', :as => "bob"). If you
114
- # always wanted sudo to run as a particular user, you could do
155
+ # always wanted sudo to run as a particular user, you could do
115
156
  # set(:admin_runner, "bob").
116
157
  def try_sudo(*args)
117
158
  options = args.last.is_a?(Hash) ? args.pop : {}
@@ -174,7 +215,7 @@ Capistrano::Configuration.instance(:must_exist).load do
174
215
 
175
216
  desc <<-DESC
176
217
  Copies your project and updates the symlink. It does this in a \
177
- transaction, so that if either `update_code' or `create_symlink' fail, all \
218
+ transaction, so that if either `update_code' or `symlink' fail, all \
178
219
  changes made to the remote servers will be rolled back, leaving your \
179
220
  system in the same state it was in before `update' was invoked. Usually, \
180
221
  you will want to call `deploy' instead of `update', but `update' can be \
@@ -218,22 +259,30 @@ Capistrano::Configuration.instance(:must_exist).load do
218
259
  public/stylesheets, and public/javascripts so that the times are \
219
260
  consistent (so that asset timestamping works). This touch process \
220
261
  is only carried out if the :normalize_asset_timestamps variable is \
221
- set to true, which is the default.
262
+ set to true, which is the default. The asset directories can be overridden \
263
+ using the :public_children variable.
222
264
  DESC
223
265
  task :finalize_update, :except => { :no_release => true } do
266
+ escaped_release = latest_release.to_s.shellescape
267
+ commands = []
268
+ commands << "chmod -R -- g+w #{escaped_release}" if fetch(:group_writable, true)
269
+
224
270
  # mkdir -p is making sure that the directories are there for some SCM's that don't
225
271
  # save empty folders
226
- shared_children.map do |d|
227
- if (d.rindex('/')) then
228
- run "rm -rf #{latest_release}/#{d} && mkdir -p #{latest_release}/#{d.slice(0..(d.rindex('/')))}"
272
+ shared_children.map do |dir|
273
+ d = dir.shellescape
274
+ if (dir.rindex('/')) then
275
+ commands += ["rm -rf -- #{escaped_release}/#{d}",
276
+ "mkdir -p -- #{escaped_release}/#{dir.slice(0..(dir.rindex('/'))).shellescape}"]
229
277
  else
230
- run "rm -rf #{latest_release}/#{d}"
278
+ commands << "rm -rf -- #{escaped_release}/#{d}"
231
279
  end
232
- run "ln -s #{shared_path}/#{d.split('/').last} #{latest_release}/#{d}"
280
+ commands << "ln -s -- #{shared_path}/#{dir.split('/').last.shellescape} #{escaped_release}/#{d}"
233
281
  end
234
282
 
235
- run "chmod -R g+w #{latest_release}" if fetch(:group_writable, true)
236
-
283
+ commands << "chmod -R g+w #{latest_release}" if fetch(:group_writable, true)
284
+ run commands.join(' && ') if commands.any?
285
+
237
286
  shared_children.map do |d|
238
287
  run <<-CMD
239
288
  rm -rf #{latest_release}/#{d} &&
@@ -242,6 +291,14 @@ Capistrano::Configuration.instance(:must_exist).load do
242
291
  end
243
292
  end
244
293
 
294
+ desc <<-DESC
295
+ Deprecated API. This has become deploy:create_symlink, please update your recipes
296
+ DESC
297
+ task :symlink, :except => { :no_release => true } do
298
+ Kernel.warn "[Deprecation Warning] This API has changed, please hook `deploy:create_symlink` instead of `deploy:symlink`."
299
+ create_symlink
300
+ end
301
+
245
302
  desc <<-DESC
246
303
  Updates the symlink to the most recently deployed version. Capistrano works \
247
304
  by putting each new release of your application in its own directory. When \
@@ -254,23 +311,13 @@ Capistrano::Configuration.instance(:must_exist).load do
254
311
  task :create_symlink, :except => { :no_release => true } do
255
312
  on_rollback do
256
313
  if previous_release
257
- run "rm -f #{current_path}; ln -s #{previous_release} #{current_path}; true"
314
+ run "#{try_sudo} rm -f #{current_path}; #{try_sudo} ln -s #{previous_release} #{current_path}; true"
258
315
  else
259
316
  logger.important "no previous release to rollback to, rollback of symlink skipped"
260
317
  end
261
318
  end
262
319
 
263
- run "rm -f #{current_path} && ln -s #{latest_release} #{current_path}"
264
- end
265
-
266
- desc <<-DESC
267
- Deprecated. Use `deploy:create_symlink` instead.
268
- DESC
269
- task :symlink, :except => { :no_release => true } do
270
- warn "[Deprecation Warning] This API has changed, please use `deploy:create_symlink` instead of" \
271
- " `deploy:symlink`."
272
-
273
- create_symlink
320
+ run "#{try_sudo} rm -f #{current_path} && #{try_sudo} ln -s #{latest_release} #{current_path}"
274
321
  end
275
322
 
276
323
  desc <<-DESC
@@ -306,7 +353,7 @@ Capistrano::Configuration.instance(:must_exist).load do
306
353
  DESC
307
354
  task :revision, :except => { :no_release => true } do
308
355
  if previous_release
309
- run "rm #{current_path}; ln -s #{previous_release} #{current_path}"
356
+ run "#{try_sudo} rm #{current_path};#{try_sudo} ln -s #{previous_release} #{current_path}"
310
357
  else
311
358
  abort "could not rollback the code because there is no prior release"
312
359
  end
@@ -318,13 +365,14 @@ Capistrano::Configuration.instance(:must_exist).load do
318
365
  (if ever) need to be called directly.
319
366
  DESC
320
367
  task :cleanup, :except => { :no_release => true } do
321
- run "if [ `readlink #{current_path}` != #{current_release} ]; then rm -rf #{current_release}; fi"
368
+ run "if [ `readlink #{current_path}` != #{current_release} ]; then #{try_sudo} rm -rf #{current_release}; fi"
322
369
  end
323
370
 
324
371
  desc <<-DESC
325
372
  Rolls back to the previously deployed version. The `current' symlink will \
326
373
  be updated to point at the previously deployed version, and then the \
327
- current release will be removed from the servers.
374
+ current release will be removed from the servers. You'll generally want \
375
+ to call `rollback' instead, as it performs a `restart' as well.
328
376
  DESC
329
377
  task :code, :except => { :no_release => true } do
330
378
  revision
@@ -351,16 +399,7 @@ Capistrano::Configuration.instance(:must_exist).load do
351
399
  DESC
352
400
  task :cleanup, :except => { :no_release => true } do
353
401
  count = fetch(:keep_releases, 5).to_i
354
- if count >= releases.length
355
- logger.important "no old releases to clean up"
356
- else
357
- logger.info "keeping #{count} of #{releases.length} deployed releases"
358
-
359
- directories = (releases - releases.last(count)).map { |release|
360
- File.join(releases_path, release) }.join(" ")
361
-
362
- try_sudo "rm -rf #{directories}"
363
- end
402
+ try_sudo "ls -1dt #{releases_path}/* | tail -n +#{count + 1} | #{try_sudo} xargs rm -rf"
364
403
  end
365
404
 
366
405
  desc <<-DESC
@@ -0,0 +1,35 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
4
+ # -*- encoding: utf-8 -*-
5
+ # stub: railsless-deploy 1.1.3 ruby lib
6
+
7
+ Gem::Specification.new do |s|
8
+ s.name = "railsless-deploy"
9
+ s.version = "1.1.3"
10
+
11
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
+ s.authors = ["Lee Hambley"]
13
+ s.date = "2013-12-13"
14
+ s.description = "Replacement for the rails deploy strategy which ships with Capistrano, allows you to deploy any platform with ease; some people have had huge success with this deploying rails projects where they needed to customise their deploy strategy beyond the code which ships with the Capistrano gem."
15
+ s.email = "lee.hambley@gmail.com"
16
+ s.extra_rdoc_files = [
17
+ "LICENSE.markdown",
18
+ "README.markdown"
19
+ ]
20
+ s.files = [
21
+ ".gitignore",
22
+ "CHANGELOG.markdown",
23
+ "LICENSE.markdown",
24
+ "README.markdown",
25
+ "Rakefile",
26
+ "VERSION",
27
+ "lib/railsless-deploy.rb",
28
+ "railsless-deploy.gemspec"
29
+ ]
30
+ s.homepage = "http://github.com/leehambley/railsless-deploy/"
31
+ s.rdoc_options = ["--charset=UTF-8"]
32
+ s.require_paths = ["lib"]
33
+ s.rubygems_version = "2.1.10"
34
+ s.summary = "Replacement for the default Capistrano tasks, designed to make life easier for PHP/Perl/Python developers"
35
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: railsless-deploy
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lee Hambley
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-04-23 00:00:00.000000000 Z
11
+ date: 2013-12-13 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Replacement for the rails deploy strategy which ships with Capistrano,
14
14
  allows you to deploy any platform with ease; some people have had huge success with
@@ -21,35 +21,37 @@ extra_rdoc_files:
21
21
  - LICENSE.markdown
22
22
  - README.markdown
23
23
  files:
24
+ - .gitignore
24
25
  - CHANGELOG.markdown
25
26
  - LICENSE.markdown
26
27
  - README.markdown
27
28
  - Rakefile
28
29
  - VERSION
29
30
  - lib/railsless-deploy.rb
31
+ - railsless-deploy.gemspec
30
32
  homepage: http://github.com/leehambley/railsless-deploy/
31
33
  licenses: []
32
34
  metadata: {}
33
35
  post_install_message:
34
- rdoc_options: []
36
+ rdoc_options:
37
+ - --charset=UTF-8
35
38
  require_paths:
36
39
  - lib
37
40
  required_ruby_version: !ruby/object:Gem::Requirement
38
41
  requirements:
39
- - - '>='
42
+ - - ! '>='
40
43
  - !ruby/object:Gem::Version
41
44
  version: '0'
42
45
  required_rubygems_version: !ruby/object:Gem::Requirement
43
46
  requirements:
44
- - - '>='
47
+ - - ! '>='
45
48
  - !ruby/object:Gem::Version
46
49
  version: '0'
47
50
  requirements: []
48
51
  rubyforge_project:
49
- rubygems_version: 2.0.3
52
+ rubygems_version: 2.1.10
50
53
  signing_key:
51
- specification_version: 3
54
+ specification_version: 4
52
55
  summary: Replacement for the default Capistrano tasks, designed to make life easier
53
56
  for PHP/Perl/Python developers
54
57
  test_files: []
55
- has_rdoc: