circleci-cli 3.0.0 → 4.0.1

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.
data/Gemfile.lock CHANGED
@@ -1,58 +1,107 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- circleci-cli (3.0.0)
5
- circleci (~> 2.0.2)
6
- faraday (>= 0.14, < 1.1)
7
- highline (>= 1.7.8, < 2.1.0)
8
- launchy (>= 2.4.3, < 2.6.0)
4
+ circleci-cli (4.0.1)
5
+ circleci (>= 2.1.0)
6
+ faraday (>= 0.14, < 2.14)
7
+ highline (>= 1.7.8, < 3.2.0)
8
+ launchy (>= 2.4.3, < 3.2.0)
9
9
  pusher-client (~> 0.6.2)
10
- rugged (>= 0.26, < 1.1)
10
+ rugged (>= 0.26, < 1.10)
11
11
  terminal-notifier (~> 2.0.0)
12
- terminal-table (~> 1.8.0)
13
- thor (>= 0.20, < 1.1)
12
+ terminal-table (>= 1.8, < 4.1)
13
+ thor (>= 0.20, < 1.4)
14
14
 
15
15
  GEM
16
16
  remote: https://rubygems.org/
17
17
  specs:
18
- activesupport (6.0.3.2)
19
- concurrent-ruby (~> 1.0, >= 1.0.2)
20
- i18n (>= 0.7, < 2)
21
- minitest (~> 5.1)
22
- tzinfo (~> 1.1)
23
- zeitwerk (~> 2.2, >= 2.2.2)
24
- addressable (2.7.0)
25
- public_suffix (>= 2.0.2, < 5.0)
26
- ast (2.4.1)
27
- circleci (2.0.3)
28
- codecov (0.2.8)
29
- json
30
- simplecov
18
+ abbrev (0.1.2)
19
+ activesupport (7.2.2.1)
20
+ base64
21
+ benchmark (>= 0.3)
22
+ bigdecimal
23
+ concurrent-ruby (~> 1.0, >= 1.3.1)
24
+ connection_pool (>= 2.2.5)
25
+ drb
26
+ i18n (>= 1.6, < 2)
27
+ logger (>= 1.4.2)
28
+ minitest (>= 5.1)
29
+ securerandom (>= 0.3)
30
+ tzinfo (~> 2.0, >= 2.0.5)
31
+ addressable (2.8.7)
32
+ public_suffix (>= 2.0.2, < 7.0)
33
+ ast (2.4.3)
34
+ async (2.24.0)
35
+ console (~> 1.29)
36
+ fiber-annotation
37
+ io-event (~> 1.9)
38
+ metrics (~> 0.12)
39
+ traces (~> 0.15)
40
+ async-http (0.88.0)
41
+ async (>= 2.10.2)
42
+ async-pool (~> 0.9)
43
+ io-endpoint (~> 0.14)
44
+ io-stream (~> 0.6)
45
+ metrics (~> 0.12)
46
+ protocol-http (~> 0.49)
47
+ protocol-http1 (~> 0.30)
48
+ protocol-http2 (~> 0.22)
49
+ traces (~> 0.10)
50
+ async-http-faraday (0.22.0)
51
+ async-http (~> 0.42)
52
+ faraday
53
+ async-pool (0.10.3)
54
+ async (>= 1.25)
55
+ base64 (0.3.0)
56
+ benchmark (0.4.1)
57
+ bigdecimal (3.2.2)
58
+ childprocess (5.1.0)
59
+ logger (~> 1.5)
60
+ circleci (2.1.0)
61
+ codecov (0.6.0)
62
+ simplecov (>= 0.15, < 0.22)
31
63
  coderay (1.1.3)
32
- concurrent-ruby (1.1.7)
33
- diff-lcs (1.4.4)
34
- docile (1.3.2)
35
- faraday (1.0.1)
36
- multipart-post (>= 1.2, < 3)
37
- faraday-http-cache (2.2.0)
64
+ concurrent-ruby (1.3.5)
65
+ connection_pool (2.5.3)
66
+ console (1.30.2)
67
+ fiber-annotation
68
+ fiber-local (~> 1.1)
69
+ json
70
+ diff-lcs (1.6.2)
71
+ docile (1.4.1)
72
+ drb (2.2.3)
73
+ faraday (2.13.2)
74
+ faraday-net_http (>= 2.0, < 3.5)
75
+ json
76
+ logger
77
+ faraday-http-cache (2.5.1)
38
78
  faraday (>= 0.8)
39
- ffi (1.13.1)
40
- formatador (0.2.5)
41
- github_changelog_generator (1.15.2)
79
+ faraday-net_http (3.4.1)
80
+ net-http (>= 0.5.0)
81
+ ffi (1.17.2)
82
+ fiber-annotation (0.2.0)
83
+ fiber-local (1.1.0)
84
+ fiber-storage
85
+ fiber-storage (1.0.1)
86
+ formatador (1.1.0)
87
+ github_changelog_generator (1.16.4)
42
88
  activesupport
89
+ async (>= 1.25.0)
90
+ async-http-faraday
43
91
  faraday-http-cache
44
92
  multi_json
45
93
  octokit (~> 4.6)
46
94
  rainbow (>= 2.2.1)
47
95
  rake (>= 10.0)
48
- retriable (~> 3.0)
49
- guard (2.16.2)
96
+ guard (2.19.1)
50
97
  formatador (>= 0.2.4)
51
98
  listen (>= 2.7, < 4.0)
99
+ logger (~> 1.6)
52
100
  lumberjack (>= 1.0.12, < 2.0)
53
101
  nenv (~> 0.1)
54
102
  notiffany (~> 0.0)
55
- pry (>= 0.9.12)
103
+ ostruct (~> 0.6)
104
+ pry (>= 0.13.0)
56
105
  shellany (~> 0.0)
57
106
  thor (>= 0.18.1)
58
107
  guard-compat (1.2.1)
@@ -60,97 +109,130 @@ GEM
60
109
  guard (~> 2.1)
61
110
  guard-compat (~> 1.1)
62
111
  rspec (>= 2.99.0, < 4.0)
63
- guard-rubocop (1.3.0)
112
+ guard-rubocop (1.5.0)
64
113
  guard (~> 2.0)
65
- rubocop (~> 0.20)
66
- highline (2.0.3)
67
- i18n (1.8.5)
114
+ rubocop (< 2.0)
115
+ highline (3.1.2)
116
+ reline
117
+ i18n (1.14.7)
68
118
  concurrent-ruby (~> 1.0)
69
- json (2.3.1)
70
- launchy (2.5.0)
71
- addressable (~> 2.7)
72
- listen (3.2.1)
119
+ io-console (0.8.0)
120
+ io-endpoint (0.15.2)
121
+ io-event (1.11.2)
122
+ io-stream (0.6.1)
123
+ json (2.12.2)
124
+ language_server-protocol (3.17.0.5)
125
+ launchy (3.1.1)
126
+ addressable (~> 2.8)
127
+ childprocess (~> 5.0)
128
+ logger (~> 1.6)
129
+ lint_roller (1.1.0)
130
+ listen (3.9.0)
73
131
  rb-fsevent (~> 0.10, >= 0.10.3)
74
132
  rb-inotify (~> 0.9, >= 0.9.10)
75
- lumberjack (1.2.7)
76
- method_source (1.0.0)
77
- minitest (5.14.1)
133
+ logger (1.7.0)
134
+ lumberjack (1.2.10)
135
+ method_source (1.1.0)
136
+ metrics (0.12.2)
137
+ minitest (5.25.5)
78
138
  multi_json (1.15.0)
79
- multipart-post (2.1.1)
80
139
  nenv (0.3.0)
140
+ net-http (0.6.0)
141
+ uri
81
142
  notiffany (0.1.3)
82
143
  nenv (~> 0.1)
83
144
  shellany (~> 0.0)
84
- octokit (4.18.0)
85
- faraday (>= 0.9)
86
- sawyer (~> 0.8.0, >= 0.5.3)
87
- parallel (1.19.2)
88
- parser (2.7.1.4)
145
+ octokit (4.25.1)
146
+ faraday (>= 1, < 3)
147
+ sawyer (~> 0.9)
148
+ ostruct (0.6.2)
149
+ parallel (1.27.0)
150
+ parser (3.3.8.0)
89
151
  ast (~> 2.4.1)
90
- pry (0.13.1)
152
+ racc
153
+ prism (1.4.0)
154
+ protocol-hpack (1.5.1)
155
+ protocol-http (0.49.0)
156
+ protocol-http1 (0.34.0)
157
+ protocol-http (~> 0.22)
158
+ protocol-http2 (0.22.1)
159
+ protocol-hpack (~> 1.4)
160
+ protocol-http (~> 0.47)
161
+ pry (0.15.2)
91
162
  coderay (~> 1.1)
92
163
  method_source (~> 1.0)
93
- public_suffix (4.0.5)
164
+ public_suffix (6.0.2)
94
165
  pusher-client (0.6.2)
95
166
  json
96
167
  websocket (~> 1.0)
97
- rainbow (3.0.0)
98
- rake (13.0.1)
99
- rb-fsevent (0.10.4)
100
- rb-inotify (0.10.1)
168
+ racc (1.8.1)
169
+ rainbow (3.1.1)
170
+ rake (13.3.0)
171
+ rb-fsevent (0.11.2)
172
+ rb-inotify (0.11.1)
101
173
  ffi (~> 1.0)
102
- regexp_parser (1.7.1)
103
- retriable (3.1.2)
104
- rexml (3.2.4)
105
- rspec (3.9.0)
106
- rspec-core (~> 3.9.0)
107
- rspec-expectations (~> 3.9.0)
108
- rspec-mocks (~> 3.9.0)
109
- rspec-core (3.9.2)
110
- rspec-support (~> 3.9.3)
111
- rspec-expectations (3.9.2)
174
+ regexp_parser (2.10.0)
175
+ reline (0.6.1)
176
+ io-console (~> 0.5)
177
+ rspec (3.13.1)
178
+ rspec-core (~> 3.13.0)
179
+ rspec-expectations (~> 3.13.0)
180
+ rspec-mocks (~> 3.13.0)
181
+ rspec-core (3.13.5)
182
+ rspec-support (~> 3.13.0)
183
+ rspec-expectations (3.13.5)
112
184
  diff-lcs (>= 1.2.0, < 2.0)
113
- rspec-support (~> 3.9.0)
114
- rspec-mocks (3.9.1)
185
+ rspec-support (~> 3.13.0)
186
+ rspec-mocks (3.13.5)
115
187
  diff-lcs (>= 1.2.0, < 2.0)
116
- rspec-support (~> 3.9.0)
117
- rspec-support (3.9.3)
118
- rubocop (0.89.1)
188
+ rspec-support (~> 3.13.0)
189
+ rspec-support (3.13.4)
190
+ rubocop (1.78.0)
191
+ json (~> 2.3)
192
+ language_server-protocol (~> 3.17.0.2)
193
+ lint_roller (~> 1.1.0)
119
194
  parallel (~> 1.10)
120
- parser (>= 2.7.1.1)
195
+ parser (>= 3.3.0.2)
121
196
  rainbow (>= 2.2.2, < 4.0)
122
- regexp_parser (>= 1.7)
123
- rexml
124
- rubocop-ast (>= 0.3.0, < 1.0)
197
+ regexp_parser (>= 2.9.3, < 3.0)
198
+ rubocop-ast (>= 1.45.1, < 2.0)
125
199
  ruby-progressbar (~> 1.7)
126
- unicode-display_width (>= 1.4.0, < 2.0)
127
- rubocop-ast (0.3.0)
128
- parser (>= 2.7.1.4)
129
- ruby-progressbar (1.10.1)
130
- rugged (1.0.1)
131
- sawyer (0.8.2)
200
+ unicode-display_width (>= 2.4.0, < 4.0)
201
+ rubocop-ast (1.45.1)
202
+ parser (>= 3.3.7.2)
203
+ prism (~> 1.4)
204
+ ruby-progressbar (1.13.0)
205
+ rugged (1.9.0)
206
+ sawyer (0.9.2)
132
207
  addressable (>= 2.3.5)
133
- faraday (> 0.8, < 2.0)
208
+ faraday (>= 0.17.3, < 3)
209
+ securerandom (0.4.1)
134
210
  shellany (0.0.1)
135
- simplecov (0.19.0)
211
+ simplecov (0.21.2)
136
212
  docile (~> 1.1)
137
213
  simplecov-html (~> 0.11)
138
- simplecov-html (0.12.2)
214
+ simplecov_json_formatter (~> 0.1)
215
+ simplecov-html (0.13.1)
216
+ simplecov_json_formatter (0.1.4)
139
217
  terminal-notifier (2.0.0)
140
- terminal-table (1.8.0)
141
- unicode-display_width (~> 1.1, >= 1.1.1)
142
- thor (1.0.1)
143
- thread_safe (0.3.6)
144
- tzinfo (1.2.7)
145
- thread_safe (~> 0.1)
146
- unicode-display_width (1.7.0)
147
- websocket (1.2.8)
148
- zeitwerk (2.4.0)
218
+ terminal-table (4.0.0)
219
+ unicode-display_width (>= 1.1.1, < 4)
220
+ thor (1.3.2)
221
+ traces (0.15.2)
222
+ tzinfo (2.0.6)
223
+ concurrent-ruby (~> 1.0)
224
+ unicode-display_width (3.1.4)
225
+ unicode-emoji (~> 4.0, >= 4.0.4)
226
+ unicode-emoji (4.0.4)
227
+ uri (1.0.3)
228
+ websocket (1.2.11)
149
229
 
150
230
  PLATFORMS
151
231
  ruby
152
232
 
153
233
  DEPENDENCIES
234
+ abbrev
235
+ base64
154
236
  bundler
155
237
  circleci-cli!
156
238
  codecov
@@ -164,4 +246,4 @@ DEPENDENCIES
164
246
  simplecov
165
247
 
166
248
  BUNDLED WITH
167
- 2.0.2
249
+ 2.4.18
data/Guardfile CHANGED
@@ -17,7 +17,7 @@
17
17
  #
18
18
  # and, you'll have to watch "config/Guardfile" instead of "Guardfile"
19
19
 
20
- # Note: The cmd option is now required due to the increasing number of ways
20
+ # NOTE: The cmd option is now required due to the increasing number of ways
21
21
  # rspec may be run, below are examples of the most common uses.
22
22
  # * bundler: 'bundle exec rspec'
23
23
  # * bundler binstubs: 'bin/rspec'
data/README.md CHANGED
@@ -1,16 +1,15 @@
1
1
  # circleci-cli
2
2
  [![All Contributors](https://img.shields.io/badge/all_contributors-3-orange.svg?style=flat-square)](#contributors-)
3
3
  [![Gem Version](https://badge.fury.io/rb/circleci-cli.svg)](https://badge.fury.io/rb/circleci-cli)
4
- [![Circle CI](https://circleci.com/gh/unhappychoice/circleci-cli.svg?style=shield)](https://circleci.com/gh/unhappychoice/circleci-cli)
5
- [![Code Climate](https://codeclimate.com/github/unhappychoice/circleci-cli/badges/gpa.svg)](https://codeclimate.com/github/unhappychoice/circleci-cli)
6
- [![codecov](https://codecov.io/gh/unhappychoice/circleci-cli/branch/master/graph/badge.svg)](https://codecov.io/gh/unhappychoice/circleci-cli)
7
- [![Libraries.io dependency status for GitHub repo](https://img.shields.io/librariesio/github/unhappychoice/circleci-cli.svg)](https://libraries.io/github/unhappychoice/circleci-cli)
4
+ [![Code Climate](https://codeclimate.com/github/circleci-tools/circleci-cli/badges/gpa.svg)](https://codeclimate.com/github/circleci-tools/circleci-cli)
5
+ [![codecov](https://codecov.io/gh/circleci-tools/circleci-cli/branch/master/graph/badge.svg)](https://codecov.io/gh/circleci-tools/circleci-cli)
6
+ [![Libraries.io dependency status for GitHub repo](https://img.shields.io/librariesio/github/circleci-tools/circleci-cli.svg)](https://libraries.io/github/circleci-tools/circleci-cli)
8
7
  ![](http://ruby-gem-downloads-badge.herokuapp.com/circleci-cli?type=total)
9
- ![GitHub](https://img.shields.io/github/license/unhappychoice/circleci-cli.svg)
8
+ ![GitHub](https://img.shields.io/github/license/circleci-tools/circleci-cli.svg)
10
9
 
11
10
  circleci-cli is a CLI tool for [Circle CI](https://circleci.com).
12
11
 
13
- ![sample.gif](https://github.com/unhappychoice/circler/raw/master/movie/rec.gif)
12
+ ![sample.gif](https://github.com/circleci-tools/circleci-cli/raw/master/movie/rec.gif)
14
13
 
15
14
  ## Installation
16
15
 
@@ -84,7 +83,7 @@ $ circleci-cli browse
84
83
 
85
84
  ## Contributing
86
85
 
87
- Bug reports and pull requests are welcome on GitHub at https://github.com/unhappychoice/circleci-cli.
86
+ Bug reports and pull requests are welcome on GitHub at https://github.com/circleci-tools/circleci-cli.
88
87
 
89
88
  ## License
90
89
 
data/circleci-cli.gemspec CHANGED
@@ -5,18 +5,20 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
5
  require 'circleci/cli/version'
6
6
 
7
7
  def production_dependency(spec)
8
- spec.add_dependency 'circleci', '~> 2.0.2'
9
- spec.add_dependency 'faraday', '>= 0.14', '< 1.1'
10
- spec.add_dependency 'highline', '>= 1.7.8', '< 2.1.0'
11
- spec.add_dependency 'launchy', '>= 2.4.3', '< 2.6.0'
8
+ spec.add_dependency 'circleci', '>= 2.1.0'
9
+ spec.add_dependency 'faraday', '>= 0.14', '< 2.14'
10
+ spec.add_dependency 'highline', '>= 1.7.8', '< 3.2.0'
11
+ spec.add_dependency 'launchy', '>= 2.4.3', '< 3.2.0'
12
12
  spec.add_dependency 'pusher-client', '~> 0.6.2'
13
- spec.add_dependency 'rugged', '>= 0.26', '< 1.1'
13
+ spec.add_dependency 'rugged', '>= 0.26', '< 1.10'
14
14
  spec.add_dependency 'terminal-notifier', '~> 2.0.0'
15
- spec.add_dependency 'terminal-table', '~> 1.8.0'
16
- spec.add_dependency 'thor', '>= 0.20', '< 1.1'
15
+ spec.add_dependency 'terminal-table', '>= 1.8', '< 4.1'
16
+ spec.add_dependency 'thor', '>= 0.20', '< 1.4'
17
17
  end
18
18
 
19
19
  def development_dependency(spec)
20
+ spec.add_development_dependency 'abbrev'
21
+ spec.add_development_dependency 'base64'
20
22
  spec.add_development_dependency 'bundler'
21
23
  spec.add_development_dependency 'codecov'
22
24
  spec.add_development_dependency 'github_changelog_generator'
@@ -36,20 +38,23 @@ def project_files
36
38
  end
37
39
 
38
40
  Gem::Specification.new do |spec|
39
- spec.name = 'circleci-cli'
40
- spec.version = CircleCI::CLI::VERSION
41
- spec.required_ruby_version = '>= 2.5'
42
- spec.authors = ['unhappychoice']
43
- spec.email = ['unhappychoice@gmail.com']
41
+ spec.name = 'circleci-cli'
42
+ spec.version = CircleCI::CLI::VERSION
43
+ spec.required_ruby_version = '>= 3.1'
44
+ spec.authors = ['unhappychoice']
45
+ spec.email = ['unhappychoice@gmail.com']
44
46
 
45
- spec.summary = 'CLI tool for CircleCI'
46
- spec.description = 'A command line tool for CircleCI'
47
- spec.homepage = 'https://github.com/unhappychoice/circleci-cli'
48
- spec.license = 'MIT'
49
- spec.files = project_files
50
- spec.bindir = 'exe'
51
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
52
- spec.require_paths = ['lib']
47
+ spec.summary = 'CLI tool for CircleCI'
48
+ spec.description = 'A command line tool for CircleCI'
49
+ spec.homepage = 'https://github.com/circleci-tools/circleci-cli'
50
+ spec.license = 'MIT'
51
+ spec.files = project_files
52
+ spec.bindir = 'exe'
53
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
54
+ spec.require_paths = ['lib']
55
+ spec.metadata = {
56
+ 'rubygems_mfa_required' => 'true'
57
+ }
53
58
 
54
59
  production_dependency spec
55
60
  development_dependency spec
@@ -7,7 +7,7 @@ module CircleCI
7
7
  class << self
8
8
  def setup_token
9
9
  CircleCi.configure do |config|
10
- config.token = ENV['CIRCLE_CI_TOKEN'] || ask('Circle CI token ? :')
10
+ config.token = ENV.fetch('CIRCLE_CI_TOKEN', nil) || ask('Circle CI token ? :')
11
11
  end
12
12
  end
13
13
 
@@ -30,8 +30,8 @@ module CircleCI
30
30
  def builds_to_show
31
31
  @builds
32
32
  .reject { |build| @build_numbers_shown.include?(build.build_number) }
33
- .select { |build| @branch.nil? || build.branch.to_s == @branch.to_s }
34
- .select { |build| @user.nil? || build.user.to_s == @user.to_s }
33
+ .select { |build| @branch.nil? || build.branch == @branch }
34
+ .select { |build| @user.nil? || build.user == @user }
35
35
  .sort_by(&:build_number)
36
36
  end
37
37
 
@@ -10,50 +10,109 @@ module CircleCI
10
10
  @build = build
11
11
  @verbose = verbose
12
12
  @messages = Hash.new { |h, k| h[k] = [] }
13
+
14
+ @build_thread = nil
15
+
16
+ @steps = build.steps
17
+ @current_step = nil
18
+ @read_byte = 0
13
19
  end
14
20
 
15
21
  def start
16
- bind_event_handling @build.channel_name
22
+ poll_build
17
23
  notify_started
18
24
  end
19
25
 
20
26
  def stop(status)
21
- client.unsubscribe("#{@build.channel_name}@0")
27
+ update_build
28
+ @build_thread&.kill
22
29
  notify_stopped(status)
23
30
  end
24
31
 
25
32
  private
26
33
 
27
- def bind_event_handling(channel) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
28
- client.bind_event_json(channel, 'newAction') do |json|
29
- if @verbose
30
- print_bordered json['log']['name']
31
- else
32
- print json['log']['name']
34
+ def poll_build
35
+ @build_thread = Thread.new do
36
+ count = 0
37
+ loop do
38
+ update_build if (count % 5).zero?
39
+ update_actions
40
+
41
+ count += 1
42
+ sleep 1
33
43
  end
34
44
  end
45
+ end
35
46
 
36
- client.bind_event_json(channel, 'appendAction') do |json|
37
- if @verbose
38
- Thor::Shell::Basic.new.say(json['out']['message'], nil, false)
47
+ # rubocop:disable Metrics/MethodLength
48
+ def on_new_step(step)
49
+ if @verbose
50
+ print_bordered step.name
51
+ else
52
+ case step.status
53
+ when 'success'
54
+ puts "\e[2K\r#{Printer.colorize_green(step.name)}"
55
+ when 'failed'
56
+ puts "\e[2K\r#{Printer.colorize_red(step.name)}"
39
57
  else
40
- @messages[json['step']] << json['out']['message']
58
+ puts step.name
41
59
  end
42
60
  end
61
+ end
62
+ # rubocop:enable Metrics/MethodLength
43
63
 
44
- client.bind_event_json(channel, 'updateAction') do |json|
45
- next if @verbose
64
+ def on_new_step_status(step)
65
+ return if @verbose
46
66
 
47
- case json['log']['status']
48
- when 'success'
49
- puts "\e[2K\r#{Printer.colorize_green(json['log']['name'])}"
50
- when 'failed'
51
- puts "\e[2K\r#{Printer.colorize_red(json['log']['name'])}"
52
- @messages[json['step']].each(&method(:say))
53
- end
67
+ case step.status
68
+ when 'success'
69
+ puts "\e[1A\e[2K\r#{Printer.colorize_green(step.name)}"
70
+ when 'failed'
71
+ puts "\e[1A\e[2K\r#{Printer.colorize_red(step.name)}"
72
+ @messages[step.name].each(&method(:say))
54
73
  end
55
74
  end
56
75
 
76
+ # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
77
+ def update_build
78
+ build = CircleCI::CLI::Response::Build.get(@build.username, @build.reponame, @build.build_number)
79
+
80
+ # Calc actions diff and dispatch event
81
+ build.steps
82
+ .each do |step|
83
+ on_new_step(step) unless @steps.any? { |s| s.name == step.name }
84
+ on_new_step_status(step) if @steps.any? { |s| s.name == step.name && s.status != step.status }
85
+ end
86
+
87
+ @steps = build.steps
88
+
89
+ next_step = build.steps.find { |s| s.status == 'running' }
90
+ @read_byte = 0 if @current_step&.name != next_step&.name
91
+ @current_step = next_step
92
+ end
93
+ # rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
94
+
95
+ # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
96
+ def update_actions
97
+ return unless @current_step
98
+
99
+ response = Faraday.new(
100
+ url: "https://circleci.com/api/private/output/raw/github/#{@build.username}/#{@build.reponame}/#{@build.build_number}/output/#{@current_step.actions.first.index}/#{@current_step.actions.first.step}",
101
+ headers: { Range: "bytes=#{@read_byte}-" }
102
+ ).get.body
103
+
104
+ return if response.empty?
105
+
106
+ @read_byte += response.bytesize
107
+
108
+ if @verbose
109
+ Thor::Shell::Basic.new.say(response, nil, false)
110
+ else
111
+ @messages[@current_step.name] << response
112
+ end
113
+ end
114
+ # rubocop:enable Metrics/AbcSize, Metrics/MethodLength
115
+
57
116
  def notify_started
58
117
  say Printer::BuildPrinter.header_for(
59
118
  @build,
@@ -75,10 +134,6 @@ module CircleCI
75
134
  def print_bordered(text)
76
135
  say Terminal::Table.new(rows: [[text]], style: { width: 120 }).to_s
77
136
  end
78
-
79
- def client
80
- @client ||= Networking::CircleCIPusherClient.new.tap(&:connect)
81
- end
82
137
  end
83
138
  end
84
139
  end
@@ -11,13 +11,13 @@ module CircleCI
11
11
  socket.connect(true)
12
12
  end
13
13
 
14
- def bind(channel, event, &block)
14
+ def bind(channel, event, &)
15
15
  socket.subscribe(channel)
16
- socket[channel].bind(event, &block)
16
+ socket[channel].bind(event, &)
17
17
  end
18
18
 
19
- def bind_event_json(channel, event, &block)
20
- bind(channel, event) { |data| JSON.parse(data).each(&block) }
19
+ def bind_event_json(channel, event, &)
20
+ bind(channel, event) { |data| JSON.parse(data).each(&) }
21
21
  end
22
22
 
23
23
  def unsubscribe(channel)
@@ -31,15 +31,15 @@ module CircleCI
31
31
  '1cf6e0e755e419d2ac9a',
32
32
  secure: true,
33
33
  auth_method: proc { |a, b| auth(a, b) },
34
- logger: Logger.new('/dev/null')
34
+ logger: Logger.new(File::NULL)
35
35
  )
36
36
  end
37
37
 
38
38
  def auth(socket_id, channel)
39
- token = ENV['CIRCLE_CI_TOKEN'] || ask('Circle CI token ? :')
39
+ token = ENV.fetch('CIRCLE_CI_TOKEN', nil) || ask('Circle CI token ? :')
40
40
  res = connection.post(
41
41
  "/auth/pusher?circle-token=#{token}",
42
- { socket_id: socket_id, channel_name: channel.name }
42
+ { socket_id:, channel_name: channel.name }
43
43
  )
44
44
  JSON.parse(res.body)['auth']
45
45
  end
@@ -12,7 +12,7 @@ module CircleCI
12
12
  ["Author: #{build.author_name}"],
13
13
  ["Workflow: #{build.workflow_name}/#{build.workflow_job_name}"]
14
14
  ]
15
- Terminal::Table.new(title: title, rows: texts, style: { width: 120 }).to_s
15
+ Terminal::Table.new(title:, rows: texts, style: { width: 120 }).to_s
16
16
  end
17
17
  end
18
18
 
@@ -33,7 +33,7 @@ module CircleCI
33
33
  end
34
34
 
35
35
  def print_pretty
36
- Terminal::Table.new(title: title, headings: headings, rows: rows).to_s
36
+ Terminal::Table.new(title:, headings:, rows:).to_s
37
37
  end
38
38
 
39
39
  def title