hu 1.5.1 → 1.5.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8421ccd321dfadf6098b31dceed6cb185bb4485f
4
- data.tar.gz: 9a0d03a88b9e6b29a8c78c773fa919945fd887d1
3
+ metadata.gz: 7beb0037c656d96fb1c2f635c9a352531cd158cc
4
+ data.tar.gz: d241e791f25e9739e7bf9c66da8015690bbbd232
5
5
  SHA512:
6
- metadata.gz: 22479fb85a37a0fbd173cd00d3d5ddf6c827bf3a8e4e1df6be7248a8465ce5dd4b9789f7811bf45d30f08248b1d6903db2b825f8beab462b88bece391c49808b
7
- data.tar.gz: 0dee3500db9c35604292f6755b24e2b3854319614e5183a627dd440c54076c6ecb6ce162daa3d014b78727e811a7f2211482ffa334f862c283b0bd003ee9a4e1
6
+ metadata.gz: 59a8748de122335431749ed61650ed882a92d9046196b8294d7b65f3e600cb4c21f8e7f4da1fbd17162d73151e65776376556800257fb6690e6f54f473c98891
7
+ data.tar.gz: 304867d5207892a3606b77fbcf7ad1864019c90fd5d1bfe25b5aa8fafeda784dd9828af9d812149680387aecfeae2d722bd8b8fdf8886f29495c4658b220a7a7
data/hu.gemspec CHANGED
@@ -34,6 +34,7 @@ Gem::Specification.new do |spec|
34
34
  spec.add_dependency 'tty-prompt', '~> 0.6.0'
35
35
  spec.add_dependency 'tty-spinner'
36
36
  spec.add_dependency 'tty-table'
37
+ spec.add_dependency 'tty-cursor'
37
38
  spec.add_dependency 'rainbow'
38
39
  spec.add_dependency 'netrc', '= 0.11.0'
39
40
  spec.add_dependency 'chronic_duration'
@@ -1,10 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
  require 'hu/version'
3
3
  require 'optix'
4
- require 'powerbar'
5
- require 'yaml'
6
4
  require 'netrc'
7
- require 'platform-api'
8
5
 
9
6
  require 'hu/common'
10
7
  require 'hu/collab'
@@ -1,11 +1,4 @@
1
1
  # frozen_string_literal: true
2
- require 'powerbar'
3
- require 'yaml'
4
- require 'hashdiff'
5
- require 'set'
6
- require 'netrc'
7
- require 'platform-api'
8
-
9
2
  module Hu
10
3
  class Cli < Optix::Cli
11
4
  class Collab < Optix::Cli
@@ -42,6 +35,13 @@ module Hu
42
35
  end
43
36
  $quiet = opts[:quiet]
44
37
  $quiet = true unless STDOUT.isatty
38
+
39
+ require 'powerbar'
40
+ require 'yaml'
41
+ require 'hashdiff'
42
+ require 'set'
43
+ require 'netrc'
44
+ require 'platform-api'
45
45
  end
46
46
  def collab; end
47
47
 
@@ -15,13 +15,11 @@ class String
15
15
  end
16
16
 
17
17
  Config.load_and_set_settings Hu::CONFIG_FILE
18
- require 'hu/telemetry'
19
18
 
20
19
  begin
21
20
  unless ENV['SKIP_VERSION_CHECK']
22
21
  version_info = BB::Gem.version_info(check_interval: 900)
23
22
  unless version_info[:installed_is_latest] == true
24
- Hu::Tm.t(:gem_outdated, installed_version: version_info[:gem_installed_version], available_version: version_info[:gem_latest_version])
25
23
  puts
26
24
  puts "\e[33;1mWoops! \e[0mA newer version of #{version_info[:gem_name]} is available."
27
25
  puts " Please type '\e[1mgem install #{version_info[:gem_name]}\e[0m' to upgrade (v#{version_info[:gem_installed_version]} -> v#{version_info[:gem_latest_version]})."
@@ -32,5 +30,3 @@ begin
32
30
  end
33
31
  rescue
34
32
  end
35
-
36
- Hu::Tm.t(:launch)
@@ -1,24 +1,5 @@
1
1
  # frozen_string_literal: true
2
- require 'version_sorter'
3
- require 'versionomy'
4
- require 'tty-prompt'
5
2
  require 'tty-spinner'
6
- require 'tty-table'
7
- require 'rainbow'
8
- require 'rainbow/ext/string'
9
- require 'open3'
10
- require 'json'
11
- require 'awesome_print'
12
- require 'chronic_duration'
13
- require 'tempfile'
14
- require 'thread_safe'
15
- require 'io/console'
16
- require 'rugged'
17
- require 'pty'
18
- require 'thread'
19
- require 'paint'
20
- require 'lolcat/lol'
21
- require 'io/console'
22
3
 
23
4
  module Hu
24
5
  class Cli < Optix::Cli
@@ -44,16 +25,48 @@ module Hu
44
25
  STDERR.puts "\e[0;31;1mERROR: Environment variable 'HEROKU_API_KEY' must be set.\e[0m"
45
26
  exit 1
46
27
  end
28
+ require 'tty-cursor'
29
+ print TTY::Cursor.hide + "\e[30;1ms"
30
+ require 'rainbow'
31
+ print 'y'
32
+ require 'rainbow/ext/string'
33
+ print 'n'
34
+ require 'platform-api'
35
+ print 'c'
36
+ require 'version_sorter'
37
+ print 'h'
38
+ require 'versionomy'
39
+ print 'r'
40
+ require 'tty-prompt'
41
+ print 'o'
42
+ require 'tty-table'
43
+ print 'n'
44
+ require 'open3'
45
+ print 'i'
46
+ require 'json'
47
+ require 'awesome_print'
48
+ print 'z'
49
+ require 'chronic_duration'
50
+ require 'tempfile'
51
+ print 'i'
52
+ require 'thread_safe'
53
+ require 'io/console'
54
+ print 'n'
55
+ require 'rugged'
56
+ require 'pty'
57
+ print 'g'
58
+ require 'thread'
59
+ require 'paint'
60
+ require 'lolcat/lol'
61
+ require 'io/console'
47
62
  end
48
63
 
49
64
  def deploy(_cmd, _opts, _argv)
50
- Hu::Tm.t(:invoke, cmd: 'deploy')
51
65
  trap('INT') { shutdown; puts "\e[0m\e[35;1m^C\e[0m"; exit 1 }
52
66
  at_exit do
53
67
  if $!.class == SystemExit && 130 == $!.status
54
68
  puts "\n\n"
55
69
  end
56
- Hu::Tm.flush!
57
70
  shutdown
58
71
  return_to_home_branch
59
72
  print "\e[0m\e[?25h"
@@ -66,7 +79,6 @@ module Hu
66
79
  puts "Git error: #{e}".color(:red)
67
80
  puts 'You need to be inside the working copy of the app that you wish to deploy.'.color(:red)
68
81
  puts
69
- Hu::Tm.t(:error_not_in_working_copy, cmd: 'deploy')
70
82
  exit 1
71
83
  end
72
84
 
@@ -78,7 +90,6 @@ module Hu
78
90
  puts
79
91
  puts ' Sorry, we need an origin here. We really do.'
80
92
  puts
81
- Hu::Tm.t(:error_no_git_origin, cmd: 'deploy')
82
93
  exit 1
83
94
  end
84
95
 
@@ -88,7 +99,6 @@ module Hu
88
99
  puts
89
100
  puts " Please run 'git flow init -d'"
90
101
  puts
91
- Hu::Tm.t(:error_no_git_flow, cmd: 'deploy')
92
102
  exit 1
93
103
  end
94
104
 
@@ -101,7 +111,6 @@ module Hu
101
111
  puts
102
112
  puts " git config --add gitflow.prefix.versiontag ''".bright
103
113
  puts
104
- Hu::Tm.t(:error_git_flow_prefix_enabled, cmd: 'deploy')
105
114
  exit 1
106
115
  end
107
116
 
@@ -119,7 +128,6 @@ module Hu
119
128
  puts
120
129
  puts " Please run 'git remote rm heroku'. Then run 'hu deploy' again to select a new remote."
121
130
  puts
122
- Hu::Tm.t(:error_no_heroku_app_for_remote, cmd: 'deploy')
123
131
  exit 1
124
132
  end
125
133
 
@@ -135,7 +143,6 @@ module Hu
135
143
 
136
144
  puts " Please run 'git remote rm heroku'. Then run 'hu deploy' again to select a new remote."
137
145
  puts
138
- Hu::Tm.t(:error_remote_not_staging, cmd: 'deploy')
139
146
  sleep 2
140
147
  exit 1
141
148
  end
@@ -145,9 +152,9 @@ module Hu
145
152
  prod_app_name = h.app.info(prod_app_id)['name']
146
153
 
147
154
  wc_update.join
148
- unbusy
149
155
 
150
156
  unless develop_can_be_merged_into_master?
157
+ unbusy
151
158
  puts
152
159
  puts "ERROR: It looks like a merge of 'develop' into 'master' would fail.".color(:red)
153
160
  puts ' Aborting early to prevent a merge conflict.'.color(:red)
@@ -190,6 +197,8 @@ module Hu
190
197
 
191
198
  prompt = TTY::Prompt.new
192
199
 
200
+ unbusy
201
+
193
202
  clearscreen = true
194
203
  loop do
195
204
  git_revisions = show_pipeline_status(pipeline_name, stag_app_name, prod_app_name, release_tag, clearscreen)
@@ -221,7 +230,6 @@ module Hu
221
230
  puts ' Nothing else has happened so far. Push this branch to'
222
231
  puts ' ' + stag_app_name.to_s.bright + ' to begin the deploy procedure.'
223
232
  puts
224
- Hu::Tm.t(:phase1, cmd: 'deploy')
225
233
  end
226
234
 
227
235
  if release_branch_exists && git_revisions[:release] == git_revisions[stag_app_name]
@@ -230,7 +238,6 @@ module Hu
230
238
  puts ' If everything looks good, you may proceed and finish the release.'
231
239
  puts ' If there are problems: Quit, delete the release branch and start fixing.'
232
240
  puts
233
- Hu::Tm.t(:phase2, cmd: 'deploy')
234
241
  elsif git_revisions[prod_app_name] != git_revisions[stag_app_name] && !release_branch_exists && git_revisions[:release] != git_revisions[stag_app_name]
235
242
  puts ' Phase 3/3 '.inverse + ' HEADS UP! This is the last chance to detect problems.'
236
243
  puts ' The final version of ' + "release/#{release_tag}".bright + ' is now staged.'
@@ -241,7 +248,6 @@ module Hu
241
248
  puts ' This is the exact version that will be promoted to production.'
242
249
  puts " From here you are on your own. Good luck #{`whoami`.chomp}!"
243
250
  puts
244
- Hu::Tm.t(:phase3, cmd: 'deploy')
245
251
  end
246
252
 
247
253
  choice = prompt.select('Choose your destiny') do |menu|
@@ -274,12 +280,9 @@ module Hu
274
280
 
275
281
  case choice
276
282
  when :DEPLOY
277
- Hu::Tm.t(:promote_begin, cmd: 'deploy')
278
283
  promote_to_production
279
- Hu::Tm.t(:promote_end, cmd: 'deploy')
280
284
  anykey
281
285
  when :finish_release
282
- Hu::Tm.t(:finish_begin, cmd: 'deploy')
283
286
  old_editor = ENV['EDITOR']
284
287
  old_git_editor = ENV['GIT_EDITOR']
285
288
  tf = Tempfile.new('hu-tag')
@@ -302,39 +305,31 @@ module Hu
302
305
  puts 'where the above sequence of commands can'
303
306
  puts 'succeed. Then try again.'
304
307
  puts
305
- Hu::Tm.t(:finish_fail, cmd: 'deploy')
306
308
  exit 1
307
309
  end
308
310
  ENV['EDITOR'] = old_editor
309
311
  ENV['GIT_EDITOR'] = old_git_editor
310
- Hu::Tm.t(:finish_end, cmd: 'deploy')
311
312
  anykey
312
313
  when :push_to_staging
313
- Hu::Tm.t(:stage_begin, cmd: 'deploy')
314
314
  run_each <<-EOS.strip_heredoc
315
315
  :stream
316
316
  git push #{push_url} release/#{release_tag}:master -f
317
317
  EOS
318
- Hu::Tm.t(:stage_end, cmd: 'deploy')
319
318
  anykey
320
319
  when :abort_ask
321
- Hu::Tm.t(:user_quit, cmd: 'deploy')
322
320
  puts if delete_branch("release/#{release_tag}")
323
321
  exit 0
324
322
  when :bump_tiny
325
323
  if delete_branch("release/#{release_tag}")
326
324
  release_tag, branch_already_exists = prompt_for_release_tag(tiny_bump, tiny_bump)
327
- Hu::Tm.t(:switch_release_type, bump: 'patch', cmd: 'deploy')
328
325
  end
329
326
  when :bump_minor
330
327
  if delete_branch("release/#{release_tag}")
331
328
  release_tag, branch_already_exists = prompt_for_release_tag(minor_bump, minor_bump)
332
- Hu::Tm.t(:switch_release_type, bump: 'minor', cmd: 'deploy')
333
329
  end
334
330
  when :bump_major
335
331
  if delete_branch("release/#{release_tag}")
336
332
  release_tag, branch_already_exists = prompt_for_release_tag(major_bump, major_bump)
337
- Hu::Tm.t(:switch_release_type, bump: 'major', cmd: 'deploy')
338
333
  end
339
334
  when :refresh
340
335
  puts
@@ -470,7 +465,6 @@ module Hu
470
465
  end
471
466
  end
472
467
 
473
- Hu::Tm.t(:status_screen, cmd: 'deploy')
474
468
  revs
475
469
  end
476
470
 
@@ -601,7 +595,6 @@ module Hu
601
595
  shutdown if opts[:failfast]
602
596
  puts "Error, exit #{status.exitstatus}: #{line} (L#{i})".color(:red).bright
603
597
 
604
- Hu::Tm.t(:runeach_error, exitstatus: status.exitstatus, cmd: 'deploy')
605
598
  exit status.exitstatus if opts[:failfast]
606
599
  return status.exitstatus
607
600
  end
@@ -646,7 +639,6 @@ module Hu
646
639
  git checkout develop
647
640
  git branch -D #{branch_name}
648
641
  EOS
649
- Hu::Tm.t(:delete_release_branch, cmd: 'deploy')
650
642
  puts "Branch #{branch_name} deleted.".color(:red)
651
643
  true
652
644
  end
@@ -664,7 +656,6 @@ module Hu
664
656
  # Starting release #{release_tag.color(:green)}
665
657
  git flow release start #{release_tag} >/dev/null
666
658
  EOS
667
- Hu::Tm.t(:start_release, cmd: 'deploy')
668
659
  end
669
660
 
670
661
  def update_working_copy
@@ -675,7 +666,6 @@ module Hu
675
666
  git checkout develop && git pull
676
667
  git checkout master && git pull --rebase origin master
677
668
  EOS
678
- Hu::Tm.t(:update_working_copy, cmd: 'deploy')
679
669
  end
680
670
 
681
671
  def heroku_git_remote
@@ -685,6 +675,7 @@ module Hu
685
675
 
686
676
  def ensure_repo_has_heroku_remote
687
677
  exit_code = run_each <<-EOS.strip_heredoc
678
+ :nospinner
688
679
  :quiet
689
680
  :return
690
681
  # Ensure we have a 'heroku' git remote
@@ -852,7 +843,6 @@ module Hu
852
843
  # Abort failed merge (if any)
853
844
  git merge --abort
854
845
  EOS
855
- Hu::Tm.t(:abort_merge, cmd: 'deploy')
856
846
  end
857
847
 
858
848
  def return_to_home_branch
@@ -864,7 +854,6 @@ module Hu
864
854
  # Return to home branch
865
855
  git checkout #{@@home_branch}
866
856
  EOS
867
- Hu::Tm.t(:return_home, cmd: 'deploy')
868
857
  end
869
858
 
870
859
  def develop_can_be_merged_into_master?
@@ -1,8 +1,4 @@
1
1
  # frozen_string_literal: true
2
- require 'yaml'
3
- require 'netrc'
4
- require 'platform-api'
5
- require 'rainbow'
6
2
 
7
3
  module Hu
8
4
  class Cli < Optix::Cli
@@ -80,6 +76,10 @@ module Hu
80
76
  STDERR.puts "\e[0;31;1mERROR: Environment variable 'HEROKU_API_KEY' must be set.\e[0m"
81
77
  exit 1
82
78
  end
79
+ require 'yaml'
80
+ require 'platform-api'
81
+ require 'rainbow'
82
+ require 'rainbow/ext/string'
83
83
  end
84
84
 
85
85
  def scale(_cmd, _opts, _args)
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Hu
3
- VERSION = '1.5.1'
3
+ VERSION = '1.5.2'
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hu
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.1
4
+ version: 1.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - moe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-11 00:00:00.000000000 Z
11
+ date: 2016-08-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -192,6 +192,20 @@ dependencies:
192
192
  - - ">="
193
193
  - !ruby/object:Gem::Version
194
194
  version: '0'
195
+ - !ruby/object:Gem::Dependency
196
+ name: tty-cursor
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - ">="
200
+ - !ruby/object:Gem::Version
201
+ version: '0'
202
+ type: :runtime
203
+ prerelease: false
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - ">="
207
+ - !ruby/object:Gem::Version
208
+ version: '0'
195
209
  - !ruby/object:Gem::Dependency
196
210
  name: rainbow
197
211
  requirement: !ruby/object:Gem::Requirement
@@ -354,7 +368,6 @@ files:
354
368
  - lib/hu/common.rb
355
369
  - lib/hu/deploy.rb
356
370
  - lib/hu/scale.rb
357
- - lib/hu/telemetry.rb
358
371
  - lib/hu/version.rb
359
372
  homepage: https://github.com/busyloop/hu
360
373
  licenses:
@@ -1,71 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'segment'
3
- require 'tty-prompt'
4
- require 'securerandom'
5
-
6
- module Hu
7
- class Tm
8
- API_TOKEN = ENV['HEROKU_API_KEY'] || ENV['HEROKU_API_TOKEN'] || Netrc.read['api.heroku.com']&.password
9
- @segment = nil
10
- @context = {}
11
-
12
- class << self
13
- def t(event, props = {})
14
- return if @segment.nil?
15
- @segment.track(anonymous_id: Settings.userid,
16
- event: event.to_s,
17
- properties: props,
18
- context: @context)
19
- end
20
-
21
- def flush!
22
- return if @segment.nil?
23
- @segment.flush
24
- end
25
-
26
- def start!
27
- if Settings.send_anonymous_usage_statistics.nil?
28
- puts <<-EOF.strip_heredoc
29
-
30
- Hu would like to collect anonymous usage
31
- statistics for the purpose of self-improvement.
32
-
33
- No personal data or identifying information
34
- about your projects will be collected.
35
-
36
- EOF
37
-
38
- prompt = TTY::Prompt.new
39
- choice = prompt.select('Enable anonymous usage statistics?') do |menu|
40
- menu.enum '.'
41
- menu.choice 'Yes, I will help Hu!', true
42
- menu.choice 'Nope', false
43
- end
44
-
45
- cfg = {
46
- userid: SecureRandom.uuid
47
- }
48
- begin
49
- cfg = YAML.parse(File.read(Hu::CONFIG_FILE))
50
- rescue
51
- end
52
- cfg['send_anonymous_usage_statistics'] = choice
53
- File.write(Hu::CONFIG_FILE, YAML.dump(cfg))
54
-
55
- puts "\nThanks!\n"
56
- puts "Your decision was saved to #{Hu::CONFIG_FILE}\n"
57
- sleep 3
58
- end
59
-
60
- if Settings.send_anonymous_usage_statistics == true
61
- @segment = Segment::Analytics.new(write_key: 'T32sCm68MMAsyoa9r5uPtHz0YwJ3MjXI')
62
- @context = { version: Hu::VERSION }
63
- @segment.identify(anonymous_id: Settings.userid || SecureRandom.uuid,
64
- context: @context)
65
- end
66
- end
67
- end
68
- end
69
- end
70
-
71
- Hu::Tm.start!