hu 1.3.19 → 1.3.20

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/hu/deploy.rb +59 -30
  3. data/lib/hu/version.rb +1 -1
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: badecd460755df3ef0e716803d7444043fff806a
4
- data.tar.gz: 3ae30df8de4108c85d04a603a9a2ac6a6f5e18f5
3
+ metadata.gz: 7ebf6d97a25b18af1c6168080a870edaddfbd1bb
4
+ data.tar.gz: ac4a4cbf64432c6fa5ce821609f53e9e23d93b74
5
5
  SHA512:
6
- metadata.gz: 6482db2c427955516d158fcf987a75dd5d5706f56aa748c2b88485ed3fca99ba2fd0c68855467667e827eb9374ff2208c348e5e68cd8873977a9a9f66b83d819
7
- data.tar.gz: c4f3d9830eda61de3dfd14dcc796709845929d0129414fc5f2dfb038c521a428bd146d5b28f3d8edf9140c71bf2f9435958f45ce7be06fea2d4dba1f20ed60e4
6
+ metadata.gz: c5c85abf52eef7637fd13c3448942404db774a1ff778977e093eb456b4e7f5b66674c4e842bdba66bd47b15db4b922a187487f511bb65b57478d46f7a98d71ac
7
+ data.tar.gz: 2c61c69e9c85fa066574f47512cee88f590242883c5349daceef552a98c67680c06eec12545a68a64759cc7774b4e8f04cd2c995a933f0c34cda29a3035110ff
data/lib/hu/deploy.rb CHANGED
@@ -18,10 +18,15 @@ require 'pty'
18
18
  require 'thread'
19
19
  require 'paint'
20
20
  require 'lolcat/lol'
21
+ require 'io/console'
21
22
 
22
23
  module Hu
23
24
  class Cli < Optix::Cli
24
25
  class Deploy < Optix::Cli
26
+ ::TTY::Formats::FORMATS[:hu] = { frames: '🌑🌒🌓🌔🌕🌖🌗🌘'.chars, interval: 10 }
27
+ ::TTY::Formats::FORMATS[:huroku] = { frames: '⣾⣽⣻⢿⡿⣟⣯⣷'.chars, interval: 10 }
28
+
29
+ $stdout.sync
25
30
  @@shutting_down = false
26
31
  @@spinner = nil
27
32
 
@@ -210,14 +215,14 @@ module Hu
210
215
  end
211
216
 
212
217
  if release_branch_exists && git_revisions[:release] == git_revisions[stag_app_name]
213
- puts 'Phase 2/3: Your local ' + "release/#{release_tag}".bright + ' (formerly ' + 'develop'.bright + ") is now live at #{stag_app_name}."
214
- puts ' Please test thoroughly: ' + (app['web_url']).to_s.bright
218
+ puts 'Phase 2/3: Your local ' + "release/#{release_tag}".bright + ' (formerly ' + 'develop'.bright + ") is live at "+"#{stag_app_name}".bright+"."
219
+ puts ' Please test here: ' + (app['web_url']).to_s.bright
215
220
  puts ' If everything looks good, you may proceed and finish the release.'
216
221
  puts ' If there are problems: Quit, delete the release branch and start fixing.'
217
222
  puts
218
223
  Hu::Tm.t(:phase2, cmd: 'deploy')
219
224
  elsif git_revisions[prod_app_name] != git_revisions[stag_app_name] && !release_branch_exists && git_revisions[:release] != git_revisions[stag_app_name]
220
- puts 'Phase 3/3: HEADS UP. This is the last chance to detect problems.'
225
+ puts 'Phase 3/3: HEADS UP! This is the last chance to detect problems.'
221
226
  puts ' The final version of ' + "release/#{release_tag}".bright + ' is now staged.'
222
227
  puts
223
228
  puts ' Test here: ' + (app['web_url']).to_s.bright
@@ -329,13 +334,21 @@ module Hu
329
334
 
330
335
  def show_pipeline_status(pipeline_name, stag_app_name, prod_app_name, release_tag, clear = true)
331
336
  table = TTY::Table.new header: %w(location commit tag app_last_modified app_last_modified_by dynos# state)
332
- busy '', :classic
337
+ busy 'loading', :huroku
333
338
  ts = []
339
+ workers = []
334
340
  tpl_row = ['?', '', '', '', '', '', '']
335
341
  revs = ThreadSafe::Hash.new
342
+ app_config = ThreadSafe::Hash.new
336
343
 
337
344
  [[0, stag_app_name], [1, prod_app_name]].each do |idx, app_name|
345
+ workers << Thread.new do
346
+ # config vars
347
+ app_config[app_name] = h.config_var.info(app_name)
348
+ end
349
+
338
350
  ts << Thread.new do
351
+ # dyno settings
339
352
  table_row = tpl_row.dup
340
353
  table_row[0] = app_name
341
354
  loop do
@@ -381,6 +394,10 @@ module Hu
381
394
  end
382
395
  end
383
396
 
397
+ workers.each do |t|
398
+ t.join
399
+ end
400
+
384
401
  rows = []
385
402
  ts.each do |t|
386
403
  idx, table_row = t.value
@@ -418,6 +435,16 @@ module Hu
418
435
  puts
419
436
 
420
437
  puts table.render(:unicode, padding: [0, 1, 0, 1], multiline: true)
438
+
439
+ missing_env = app_config[stag_app_name].keys - app_config[prod_app_name].keys
440
+ unless missing_env.empty?
441
+ puts
442
+ missing_env.each do |var|
443
+ puts " WARNING ".color(:red).bright.inverse + " Missing config in "+prod_app_name.bright+": #{var}"
444
+ sleep 0.42
445
+ end
446
+ end
447
+
421
448
  Hu::Tm.t(:status_screen, cmd: 'deploy')
422
449
  revs
423
450
  end
@@ -481,40 +508,42 @@ module Hu
481
508
  status = nil
482
509
  if opts[:stream]
483
510
  puts "\n> ".color(:green) + line.color(:black).bright
484
- PTY.spawn(line) do |r, _w, pid|
485
- @tspin ||= Thread.new do
486
- @minispin_last_char = Time.now
487
- @minispin_disable = false
488
- i = 0
489
- loop do
490
- break if @minispin_last_char == :end
491
- if 0.23 > Time.now - @minispin_last_char || @minispin_disable
492
- sleep 0.1
493
- next
494
- end
495
- @spinlock.synchronize do
496
- print "\e[?25l"
497
- print Paint[' ', '#000', Lol.rainbow(1, i / 3.0)]
498
- sleep 0.12
499
- print 8.chr
500
- print ' '
501
- print 8.chr
502
- i += 1
503
- print "\e[?25h"
504
- end
511
+ rows, cols = STDIN.winsize
512
+ @minispin_disable = false
513
+ @minispin_last_char_at = Time.now
514
+ @tspin ||= Thread.new do
515
+ i = 0
516
+ loop do
517
+ break if @minispin_last_char_at == :end
518
+ if 0.23 > Time.now - @minispin_last_char_at || @minispin_disable
519
+ sleep 0.1
520
+ next
521
+ end
522
+ @spinlock.synchronize do
523
+ next if @minispin_disable
524
+ print "\e[?25l"
525
+ print Paint[' ', '#000', Lol.rainbow(1, i / 3.0)]
526
+ sleep 0.12
527
+ print 8.chr
528
+ print ' '
529
+ print 8.chr
530
+ i += 1
531
+ print "\e[?25h"
505
532
  end
506
533
  end
534
+ end
507
535
 
536
+ PTY.spawn("stty rows #{rows} cols #{cols}; "+line) do |r, _w, pid|
508
537
  begin
509
538
  until r.eof?
510
539
  c = r.getc
511
540
  @spinlock.synchronize do
512
541
  print c
513
- @minispin_last_char = Time.now
514
- c = c.encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '') # barf.
542
+ @minispin_last_char_at = Time.now
543
+ c = c.encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: "\e") # barf.
515
544
  # hold on when we are (likely) inside an escape sequence
516
- @minispin_disable = true if c == 27
517
- @minispin_disable = false if c =~ /[A-Za-z]/
545
+ @minispin_disable = true if c.ord == 27 || c.ord < 9
546
+ @minispin_disable = false if c =~ /[A-Za-z]/ || [13,10].include?(c.ord)
518
547
  end
519
548
  end
520
549
  rescue Errno::EIO
@@ -524,7 +553,7 @@ module Hu
524
553
  end
525
554
 
526
555
  _pid, status = Process.wait2(pid)
527
- @minispin_last_char = :end
556
+ @minispin_last_char_at = :end
528
557
  @tspin.join
529
558
  @tspin = nil
530
559
  # status = PTY.check(pid)
data/lib/hu/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Hu
3
- VERSION = '1.3.19'
3
+ VERSION = '1.3.20'
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.3.19
4
+ version: 1.3.20
5
5
  platform: ruby
6
6
  authors:
7
7
  - moe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-03 00:00:00.000000000 Z
11
+ date: 2016-06-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler