capistrano-fiftyfive 0.17.2 → 0.18.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6bd7a614d1cce71475c2ad308b03b116b5cd2a9a
4
- data.tar.gz: 424092e4974c0cfc779ee2ac471bcf1f40e47ab2
3
+ metadata.gz: ffd897eb6b668f60d4610627fcf7bb456476f31d
4
+ data.tar.gz: d639e21894968d79f1696948b8f41d7bbc470932
5
5
  SHA512:
6
- metadata.gz: f416ef20815e2222e99733a8a24b68ff6f4c1729f05259939cd4cb530c1490b554c8ae5025c141a81890f2e0e6914ccc2de4e48639b4cf1e6a9ff8bd2d509adf
7
- data.tar.gz: 0c0fd5d8fd66e29fa076961eb77c7776a1e1988fbca13fcd69e0b212a2638c33e73132b9b3fea21dcf57cb070b6bc62d9ef228c4e4f73ffb7508a27881b18de8
6
+ metadata.gz: 22d68303c1bf01dd10c8910a41f60fca9cad374f3adb7ecf85078239e6fb6a2f7ece4fa65d2347f9680d77c6753e8c88b97b32f60e54b3760b5859fad102b8a5
7
+ data.tar.gz: 5365ed52ed3fb991cf7bf6c53e857e25d081c5c322a8e7843b888d5c3f5fd6ebe0fd7189df2ce541957caa10b7bef6ebfa504ad0e064387193a533f2d0c785b9
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # capistrano-fiftyfive Changelog
2
2
 
3
+ ## `0.18.0`
4
+
5
+ * **The abbreviated log formatter has been removed and is now available in a new gem: `airbrussh`.** With this change, capistrano-fiftyfive no longer automatically changes the logging format of capistrano. To opt into the prettier, more concise format, add the airbrussh gem to your project as explained in the [airbrussh README](https://github.com/mattbrictson/airbrussh#readme).
6
+ * The version initializer that capistrano-fiftyfive adds during deployment sets a new value: `Rails.application.config.version_time`. You can use this value within your app for the date and time of the last commit that produced the version that is currently deployed.
7
+
8
+
3
9
  ## `0.17.2`
4
10
 
5
11
  * Default self-signed SSL certificate is now more generic (for real this time).
data/README.md CHANGED
@@ -26,7 +26,7 @@ The gem is named "capistrano-fiftyfive" for historical reasons: it was initially
26
26
  * rbenv
27
27
  * dotenv
28
28
 
29
- In addition, capistrano-fiftyfive changes many of Capistrano's defaults, including the deployment location, Bundler behavior, and SSH keep-alive settings. It also overhauls and simplifies the logging format. (See [defaults.rake][] for details.)
29
+ In addition, capistrano-fiftyfive changes many of Capistrano's defaults, including the deployment location, Bundler behavior, and SSH keep-alive settings. (See [defaults.rake][] for details.)
30
30
 
31
31
  Not quite to your liking? Consider forking the project to meet your needs.
32
32
 
@@ -4,8 +4,6 @@ require "capistrano/fiftyfive/version"
4
4
  require "capistrano/fiftyfive/compatibility"
5
5
  require "capistrano/fiftyfive/dsl"
6
6
  require "capistrano/fiftyfive/recipe"
7
- require "capistrano/fiftyfive/console"
8
- require "sshkit/formatter/abbreviated"
9
7
  include Capistrano::Fiftyfive::DSL
10
8
 
11
9
  load File.expand_path("../tasks/provision.rake", __FILE__)
@@ -28,4 +26,3 @@ load File.expand_path("../tasks/seed.rake", __FILE__)
28
26
  load File.expand_path("../tasks/version.rake", __FILE__)
29
27
  load File.expand_path("../tasks/rake.rake", __FILE__)
30
28
  load File.expand_path("../tasks/sidekiq.rake", __FILE__)
31
- load File.expand_path("../tasks/deploy.rake", __FILE__)
@@ -1,2 +1,3 @@
1
1
  Rails.application.config.version = "<%= git_version[:tag] %>"
2
2
  Rails.application.config.version_date = Date.parse("<%= git_version[:date] %>")
3
+ Rails.application.config.version_time = Time.zone.parse("<%= git_version[:time] %>")
@@ -1,5 +1,5 @@
1
1
  module Capistrano
2
2
  module Fiftyfive
3
- VERSION = "0.17.2"
3
+ VERSION = "0.18.0"
4
4
  end
5
5
  end
@@ -94,7 +94,6 @@ namespace :load do
94
94
  set :bundle_binstubs, false
95
95
  set :bundle_flags, '--deployment'
96
96
  set :deploy_to, -> { "/home/deployer/apps/#{fetch(:application)}" }
97
- set :format, :abbreviated
98
97
  set :keep_releases, 10
99
98
  set :linked_dirs, -> {
100
99
  ["public/#{fetch(:assets_prefix, 'assets')}"] +
@@ -17,6 +17,9 @@ namespace :fiftyfive do
17
17
  git_version[:date] = \
18
18
  capture(:git, "log", branch, '-1 --format="%ad" --date=short')\
19
19
  .chomp
20
+ git_version[:time] = \
21
+ capture(:git, "log", branch, '-1 --format="%ad" --date=iso')\
22
+ .chomp
20
23
  end
21
24
  end
22
25
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-fiftyfive
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.17.2
4
+ version: 0.18.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Brictson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-12 00:00:00.000000000 Z
11
+ date: 2015-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capistrano
@@ -83,7 +83,6 @@ files:
83
83
  - capistrano-fiftyfive.gemspec
84
84
  - lib/capistrano/fiftyfive.rb
85
85
  - lib/capistrano/fiftyfive/compatibility.rb
86
- - lib/capistrano/fiftyfive/console.rb
87
86
  - lib/capistrano/fiftyfive/dsl.rb
88
87
  - lib/capistrano/fiftyfive/recipe.rb
89
88
  - lib/capistrano/fiftyfive/templates/crontab.erb
@@ -106,7 +105,6 @@ files:
106
105
  - lib/capistrano/tasks/crontab.rake
107
106
  - lib/capistrano/tasks/defaults.rake
108
107
  - lib/capistrano/tasks/delayed_job.rake
109
- - lib/capistrano/tasks/deploy.rake
110
108
  - lib/capistrano/tasks/dotenv.rake
111
109
  - lib/capistrano/tasks/logrotate.rake
112
110
  - lib/capistrano/tasks/maintenance.rake
@@ -123,7 +121,6 @@ files:
123
121
  - lib/capistrano/tasks/unicorn.rake
124
122
  - lib/capistrano/tasks/user.rake
125
123
  - lib/capistrano/tasks/version.rake
126
- - lib/sshkit/formatter/abbreviated.rb
127
124
  homepage: https://github.com/mattbrictson/capistrano-fiftyfive
128
125
  licenses:
129
126
  - MIT
@@ -144,7 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
144
141
  version: '0'
145
142
  requirements: []
146
143
  rubyforge_project:
147
- rubygems_version: 2.4.5
144
+ rubygems_version: 2.4.6
148
145
  signing_key:
149
146
  specification_version: 4
150
147
  summary: Additional Capistrano 3 recipes
@@ -1,64 +0,0 @@
1
- require 'io/console'
2
-
3
- module Capistrano
4
- module Fiftyfive
5
- # Helper class that wraps an IO object and provides methods for truncating
6
- # output, assuming the IO object represents a console window.
7
- #
8
- # This is useful for writing log messages that will typically show up on
9
- # an ANSI color-capable console. When a console is not present (e.g. when
10
- # running on a CI server) the output will gracefully degrade.
11
- class Console
12
- def initialize(output)
13
- @output = output
14
- end
15
-
16
- # Writes to the IO after first truncating the output to fit the console
17
- # width. If the underlying IO is not a TTY, ANSI colors are removed from
18
- # the output. A newline is always added. Color output can be forced by
19
- # setting the SSHKIT_COLOR environment variable.
20
- def print_line(obj="")
21
- string = obj.to_s
22
-
23
- if console_width
24
- string = truncate_to_console_width(string)
25
- end
26
- unless ENV["SSHKIT_COLOR"] || @output.tty?
27
- string = strip_ascii_color(string)
28
- end
29
-
30
- write(string + "\n")
31
- @output.flush
32
- end
33
-
34
- # Writes directly through to the IO with no truncation or color logic.
35
- # No newline is added.
36
- def write(string)
37
- @output.write(string || "")
38
- end
39
- alias_method :<<, :write
40
-
41
- def truncate_to_console_width(string)
42
- string = (string || "").rstrip
43
- width = console_width
44
-
45
- if strip_ascii_color(string).length > width
46
- while strip_ascii_color(string).length >= width
47
- string.chop!
48
- end
49
- string << "…\e[0m"
50
- else
51
- string
52
- end
53
- end
54
-
55
- def strip_ascii_color(string)
56
- (string || "").gsub(/\033\[[0-9;]*m/, "")
57
- end
58
-
59
- def console_width
60
- IO.console.winsize.last if @output.tty?
61
- end
62
- end
63
- end
64
- end
@@ -1,6 +0,0 @@
1
- namespace :deploy do
2
- task :failed do
3
- output = env.backend.config.output
4
- output.on_deploy_failure if output.respond_to?(:on_deploy_failure)
5
- end
6
- end
@@ -1,194 +0,0 @@
1
- require 'colorize'
2
- require 'ostruct'
3
-
4
- module SSHKit
5
- module Formatter
6
- class Abbreviated < SSHKit::Formatter::Abstract
7
-
8
- class << self
9
- attr_accessor :current_rake_task
10
-
11
- def monkey_patch_rake_task!
12
- return if @rake_patched
13
-
14
- eval(<<-EVAL)
15
- class ::Rake::Task
16
- alias_method :_original_execute_cap55, :execute
17
- def execute(args=nil)
18
- SSHKit::Formatter::Abbreviated.current_rake_task = name
19
- _original_execute_cap55(args)
20
- end
21
- end
22
- EVAL
23
-
24
- @rake_patched = true
25
- end
26
- end
27
-
28
- def initialize(io)
29
- super
30
-
31
- self.class.monkey_patch_rake_task!
32
-
33
- @tasks = {}
34
-
35
- @log_file = fetch(:fiftyfive_log_file) || "capistrano.log"
36
- @log_file_formatter = SSHKit::Formatter::Pretty.new(
37
- ::Logger.new(@log_file, 1, 20971520)
38
- )
39
-
40
- @console = Capistrano::Fiftyfive::Console.new(original_output)
41
- write_log_file_delimiter
42
- write_banner
43
- end
44
-
45
- def print_line(string)
46
- @console.print_line(string)
47
- end
48
-
49
- def write_banner
50
- print_line "Using abbreviated format."
51
- print_line "Full cap output is being written to #{blue(@log_file)}."
52
- end
53
-
54
- def write_log_file_delimiter
55
- delimiter = []
56
- delimiter << "-" * 75
57
- delimiter << "START #{Time.now} cap #{ARGV.join(' ')}"
58
- delimiter << "-" * 75
59
- delimiter.each do |line|
60
- @log_file_formatter << SSHKit::LogMessage.new(
61
- SSHKit::Logger::INFO,
62
- line
63
- )
64
- end
65
- end
66
-
67
- def write(obj)
68
- @log_file_formatter << obj
69
-
70
- case obj
71
- when SSHKit::Command then write_command(obj)
72
- when SSHKit::LogMessage then write_log_message(obj)
73
- end
74
- end
75
- alias :<< :write
76
-
77
- def on_deploy_failure
78
- err = Capistrano::Fiftyfive::Console.new($stderr)
79
- err.print_line
80
- err.print_line(red("** DEPLOY FAILED"))
81
- err.print_line(yellow(
82
- "** Refer to #{@log_file} for details. Here are the last 20 lines:"
83
- ))
84
- err.print_line
85
- system("tail -n 20 #{@log_file.shellescape} 1>&2")
86
- end
87
-
88
- private
89
-
90
- def write_log_message(log_message)
91
- return unless log_message.verbosity >= SSHKit::Logger::INFO
92
- print_task_if_changed
93
- @console.print_line(light_black(" " + log_message.to_s))
94
- end
95
-
96
- def write_command(command)
97
- return unless command.verbosity > SSHKit::Logger::DEBUG
98
-
99
- print_task_if_changed
100
-
101
- ctx = context_for_command(command)
102
- number = '%02d' % ctx.number
103
-
104
- if ctx.first_execution?
105
- description = yellow(ctx.shell_string)
106
- print_line " #{number} #{description}"
107
- end
108
-
109
- if command.finished?
110
- status = format_command_completion_status(command, number)
111
- print_line " #{status}"
112
- end
113
- end
114
-
115
- def print_task_if_changed
116
- status = current_task_status
117
-
118
- if status.changed
119
- print_line "#{clock} #{blue(status.task)}"
120
- end
121
- end
122
-
123
- def current_task_status
124
- task = self.class.current_rake_task.to_s
125
- if @tasks[task]
126
- changed = false
127
- else
128
- changed = true
129
- @tasks[task] = []
130
- end
131
-
132
- OpenStruct.new(
133
- :task => task,
134
- :commands => @tasks[task],
135
- :changed => changed
136
- )
137
- end
138
-
139
- def context_for_command(command)
140
- status = current_task_status
141
- task_commands = status.commands
142
-
143
- shell_string = command.to_s.sub(%r(^/usr/bin/env ), "")
144
-
145
- if task_commands.include?(shell_string)
146
- first_execution = false
147
- else
148
- first_execution = true
149
- task_commands << shell_string
150
- end
151
-
152
- number = task_commands.index(shell_string) + 1
153
-
154
- OpenStruct.new({
155
- :first_execution? => first_execution,
156
- :number => number,
157
- :shell_string => shell_string
158
- })
159
- end
160
-
161
- def format_command_completion_status(command, number)
162
- user = command.user { command.host.user }
163
- host = command.host.to_s
164
- user_at_host = [user, host].join("@")
165
-
166
- status = if command.failure?
167
- red("✘ #{number} #{user_at_host} (see #{@log_file} for details)")
168
- else
169
- green("✔ #{number} #{user_at_host}")
170
- end
171
-
172
- runtime = light_black("%5.3fs" % command.runtime)
173
-
174
- status + " " + runtime
175
- end
176
-
177
- def clock
178
- @start_at ||= Time.now
179
- duration = Time.now - @start_at
180
-
181
- minutes = (duration / 60).to_i
182
- seconds = (duration - minutes * 60).to_i
183
-
184
- "%02d:%02d" % [minutes, seconds]
185
- end
186
-
187
- %w(light_black red blue green yellow).each do |color|
188
- define_method(color) do |string|
189
- string.to_s.colorize(color.to_sym)
190
- end
191
- end
192
- end
193
- end
194
- end