envoy-cli 1.0.0rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +3 -0
  3. data/.rspec +2 -0
  4. data/.rubocop.yml +95 -0
  5. data/.ruby-version +1 -0
  6. data/Gemfile +4 -0
  7. data/bin/envoy +12 -0
  8. data/bin/envoy.bak +485 -0
  9. data/bootstrap/base/.envoyrc +1 -0
  10. data/bootstrap/base/.jshintrc +91 -0
  11. data/bootstrap/base/.nvmrc +1 -0
  12. data/bootstrap/base/config/.gitkeep +0 -0
  13. data/bootstrap/base/docs/.gitkeep +0 -0
  14. data/bootstrap/base/gulpfile.js +0 -0
  15. data/bootstrap/base/i18n/.gitkeep +0 -0
  16. data/bootstrap/base/index.js +5 -0
  17. data/bootstrap/base/lib/.gitkeep +0 -0
  18. data/bootstrap/base/routes/.gitkeep +0 -0
  19. data/bootstrap/base/views/.gitkeep +0 -0
  20. data/bootstrap/base/workers/.gitkeep +0 -0
  21. data/bootstrap/events/generic.json +6 -0
  22. data/bootstrap/events/host_notification.json +27 -0
  23. data/bootstrap/events/route.json +6 -0
  24. data/bootstrap/events/sms_host_notification.json +158 -0
  25. data/bootstrap/templates/docs/about.md.erb +3 -0
  26. data/bootstrap/templates/gitignore.erb +8 -0
  27. data/bootstrap/templates/index.js.erb +5 -0
  28. data/bootstrap/templates/license.md.erb +1 -0
  29. data/bootstrap/templates/npmignore.erb +0 -0
  30. data/bootstrap/templates/package.json +24 -0
  31. data/bootstrap/templates/readme.md.erb +9 -0
  32. data/bootstrap/templates/routes/callback.js.erb +10 -0
  33. data/bootstrap/templates/routes/html.js.erb +9 -0
  34. data/bootstrap/templates/routes/json.js.erb +9 -0
  35. data/bootstrap/templates/routes/other.js.erb +9 -0
  36. data/bootstrap/templates/views/hello.html.erb +91 -0
  37. data/bootstrap/templates/views/starter.html.erb +10 -0
  38. data/bootstrap/templates/worker.js.erb +10 -0
  39. data/envoy-cli.gemspec +29 -0
  40. data/lib/envoy.rb +70 -0
  41. data/lib/envoy/version.rb +3 -0
  42. data/lib/inc/commands.rb +74 -0
  43. data/lib/inc/generator.rb +159 -0
  44. data/lib/inc/mixins.rb +347 -0
  45. data/lib/inc/runner.rb +21 -0
  46. data/lib/tasks/plugin.rb +181 -0
  47. data/lib/tasks/routes.rb +39 -0
  48. data/lib/tasks/test.rb +68 -0
  49. data/lib/tasks/workers.rb +39 -0
  50. data/readme.md +0 -0
  51. metadata +276 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: dec124e3b5fc290be2ef15c35db1efe32015c810
4
+ data.tar.gz: 3c60fd82c958edcec08994fc3b63a3ccc708ee23
5
+ SHA512:
6
+ metadata.gz: 556842fa3ea2aee9da0c13801b928ae013b9be5040b84ccd040ae24f978374767977066633d162ca12e83bbe268de2a7e775730852993b9722ae13fa684a2418
7
+ data.tar.gz: fccef4834dc086872214a57ad7f0a04035b032ecbcdc5fb6c83da5f20b7c603a5fa9cdef95f16d0c4d7adbea5bd16f5313f6fbc7da441b38a1388db4cc0a2b38
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ *.gem
2
+ *.zip
3
+ sandbox
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,95 @@
1
+ require:
2
+ - rubocop-rspec
3
+
4
+ AllCops:
5
+ TargetRubyVersion: 2.3
6
+ Exclude:
7
+ - 'db/**/*'
8
+ - 'script/**/*'
9
+ - 'tmp/**/*'
10
+ - 'log/**/*'
11
+ - 'doc/**/*'
12
+ - 'vendor/**/*'
13
+
14
+ Rails:
15
+ Enabled: true
16
+
17
+ RSpec/DescribedClass:
18
+ Enabled: false
19
+
20
+ Style/FrozenStringLiteralComment:
21
+ Enabled: false
22
+
23
+ Style/AlignHash:
24
+ EnforcedColonStyle: table
25
+ EnforcedHashRocketStyle: table
26
+
27
+ Style/IndentArray:
28
+ EnforcedStyle: consistent
29
+
30
+ Style/IndentHash:
31
+ EnforcedStyle: consistent
32
+
33
+ # FIXME: We need to settle on something and stick to it
34
+ Style/StringLiterals:
35
+ # EnforcedStyle: double_quotes
36
+ Enabled: false
37
+
38
+ Style/RedundantParentheses:
39
+ Enabled: false
40
+
41
+ Style/Documentation:
42
+ Enabled: false
43
+
44
+ Style/GlobalVars:
45
+ Enabled: false
46
+
47
+ Style/BracesAroundHashParameters:
48
+ Enabled: false
49
+
50
+ Metrics/LineLength:
51
+ Max: 115
52
+
53
+ Style/ConditionalAssignment:
54
+ Enabled: false
55
+
56
+ Style/IfUnlessModifier:
57
+ Enabled: false
58
+
59
+ Metrics/PerceivedComplexity:
60
+ Enabled: false
61
+ Severity: warning
62
+ Max: 14
63
+
64
+ Metrics/CyclomaticComplexity:
65
+ Enabled: false
66
+ Severity: warning
67
+ Max: 12
68
+
69
+ Metrics/ClassLength:
70
+ Enabled: false
71
+ Severity: warning
72
+ Max: 200
73
+
74
+ Metrics/ModuleLength:
75
+ Enabled: false
76
+ Severity: warning
77
+ Max: 200
78
+
79
+ Metrics/MethodLength:
80
+ Enabled: false
81
+ Severity: warning
82
+ Max: 50
83
+
84
+ # @see http://c2.com/cgi/wiki?AbcMetric
85
+ Metrics/AbcSize:
86
+ Enabled: false
87
+ Severity: warning
88
+ Max: 30
89
+
90
+ Lint/AssignmentInCondition:
91
+ Enabled: true
92
+ AllowSafeAssignment: false
93
+
94
+ Rails/Delegate:
95
+ Enabled: false
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.3.0
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in envoy-cli.gemspec
4
+ gemspec
data/bin/envoy ADDED
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby
2
+ file = File.symlink?(__FILE__) ? File.readlink(__FILE__) : __FILE__
3
+ $LOAD_PATH.push File.expand_path("../../lib", file)
4
+
5
+ trap "SIGINT" do
6
+ puts "\n████████ Exited ████████".red
7
+ exit 130
8
+ end
9
+
10
+ $thor_runner = true
11
+
12
+ require "envoy"
data/bin/envoy.bak ADDED
@@ -0,0 +1,485 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'commander/import'
5
+ require 'terminal-table'
6
+ require 'colorize'
7
+ require 'unirest'
8
+ require 'parseconfig'
9
+ require 'net/http'
10
+ require 'json'
11
+ require 'archive/zip'
12
+ require 'coderay'
13
+ require File.join(File.dirname(__FILE__), "../", "lib", "envoy_support")
14
+
15
+ program :name, 'Envoy'
16
+ program :version, '0.0.1'
17
+ program :description, 'Envoy developer CLI'
18
+ program :help, 'Author', 'David Boskovic'
19
+ program :help_formatter, :compact
20
+
21
+ global_option(
22
+ '--profile PROFILE',
23
+ String,
24
+ "If you use multiple developer accounts, this is for specifying the one you want to use."
25
+ )
26
+
27
+ trap "SIGINT" do
28
+ puts "Exiting"
29
+ exit 130
30
+ end
31
+
32
+ # make sure we can get a
33
+ if !File.exist?(Dir.home + '/.envoy-cfg')
34
+ file = File.open(Dir.home + '/.envoy-cfg', 'w')
35
+ config = ParseConfig.new
36
+ config.groups = ['default']
37
+ config.params = { 'default' => { 'access_token' => '', 'email' => '' } }
38
+ config.write(file)
39
+ file.close
40
+ else
41
+ config = ParseConfig.new Dir.home + '/.envoy-cfg'
42
+ end
43
+
44
+ $config = config
45
+
46
+ command :login do |c|
47
+ c.syntax = 'envoy login'
48
+ c.summary = 'Login with your envoy developer account.'
49
+ c.option '--local', String, 'Login to local only.'
50
+ c.option '--path PATH', String, 'URL to API for deploy'
51
+ c.action do |_args, options|
52
+ email = ask "Email: "
53
+ password = password "Password: "
54
+ res = Unirest.post(base_url(options, 'oauth/token', true), parameters: {
55
+ grant_type: 'password',
56
+ username: email,
57
+ password: password
58
+ })
59
+ handle_errors(res) unless res.code.between?(200, 299)
60
+
61
+ Unirest.post(base_url(options, './platform/developers', true), parameters: {
62
+ access_token: res.body['access_token']
63
+ })
64
+ # save user to config
65
+ if options.profile && !config.groups.include?(options.profile)
66
+ config.groups.push options.profile
67
+ end
68
+ conf = {
69
+ 'email' => email,
70
+ 'access_token' => res.body['access_token'],
71
+ }
72
+ if options.local
73
+ conf['local'] = true
74
+ end
75
+ if options.path
76
+ conf['api_path'] = options.path
77
+ end
78
+ config.params[profile(options)] = conf
79
+ file = File.open(Dir.home + '/.envoy-cfg', 'w')
80
+ config.write(file)
81
+ file.close
82
+
83
+ puts "You are now logged in.".green
84
+
85
+ end
86
+ end
87
+
88
+ # command :foo do |c|
89
+ # c.syntax = 'envoy foo'
90
+ # c.summary = 'Misc stuff'
91
+ # c.action do |args, options|
92
+ # if args[0]
93
+ # # @create dir if it doesn't already exist
94
+ # Dir.chdir args[0]
95
+ # end
96
+ # name = ask 'Plugin Name: '
97
+
98
+ # manifest = JSON.parse File.read(Dir.pwd+'/envoy-manifest.json')
99
+ # manifest['name'] = name
100
+ # file = File.open(Dir.pwd+'/envoy-manifest.json','w')
101
+ # file.write JSON.pretty_generate manifest
102
+ # file.close
103
+ # end
104
+ # end
105
+
106
+ command :'list plugins' do |c|
107
+ c.syntax = 'envoy list [options]'
108
+ c.summary = ''
109
+ c.action do |_args, options|
110
+ res = Unirest.get(base_url(options, './platform/plugins'), parameters: {
111
+ access_token: config[profile(options)]['access_token']
112
+ })
113
+ rows = []
114
+ res.body['data'].each do |plugin|
115
+ rows.push [plugin['attributes']['name'], plugin['attributes']['key'], plugin['attributes']['updated-at']]
116
+ end
117
+ puts Terminal::Table.new rows: rows, headings: ['Name', 'Key', 'Last Updated']
118
+ if res.body['data'].empty?
119
+ say_warning 'No plugins created for developer account: ' + config[profile(options)]['email']
120
+ end
121
+ end
122
+ end
123
+
124
+ command :'tail events' do |c|
125
+ c.syntax = 'envoy tail events [options]'
126
+ c.summary = ''
127
+ c.action do |_args, options|
128
+ l_config = local_config
129
+ token = plugin_uuid options
130
+ since = nil
131
+ entries = false
132
+ loop do
133
+ res = Unirest.get(base_url(options, './platform/events'), parameters: {
134
+ access_token: config[profile(options)]['access_token'],
135
+ plugin_id: token,
136
+ 'filter[since]': since
137
+ })
138
+ unless res.body['data'].empty?
139
+ since = res.body['data'][0]['attributes']['created-at']
140
+ end
141
+ res.body['data'].reverse.each do |event|
142
+ if entries
143
+ puts "\n\n\n\n"
144
+ end
145
+ entries = true
146
+ print_event event
147
+ end
148
+ sleep(2)
149
+ end
150
+ end
151
+ end
152
+
153
+ command :release do |c|
154
+ c.syntax = 'envoy release <type> <base> [options]'
155
+ c.summary = 'This will release your plugin.'
156
+ c.option '--local', String, 'Deploys to local only.'
157
+ c.option '--retry', String, 'Deploys to local only.'
158
+ c.action do |args, options|
159
+ unless %w(patch minor major).include? args[0]
160
+ say_error("<#{args[0]}> is an invalid release type. Must be one of " \
161
+ "patch|minor|major.\nUse format: envoy release <type>")
162
+ exit
163
+ end
164
+ release_type = args[0]
165
+ token = plugin_uuid options
166
+ parsed = JSON.parse File.read(manifest_file(options))
167
+ manifest = parsed['manifest'] || {}
168
+ unless options.local
169
+ notes = ask "Release Notes:"
170
+ if !notes || notes.length < 10
171
+ say_error "Please provide at least a couple words about what this release is for."
172
+ exit
173
+ end
174
+ end
175
+
176
+ say 'Requesting deploy permissions...'
177
+
178
+ headers = {
179
+ 'Content-Type': 'application/json',
180
+ 'Authorization': "Bearer #{config[profile(options)]['access_token']}"
181
+ }
182
+ params = {
183
+ type: 'platform-releases',
184
+ attributes: {
185
+ manifest: manifest,
186
+ notes: notes || '',
187
+ provider: options.local && 'local' || 'lambda',
188
+ version_type: release_type,
189
+ version_base: args[1] || nil
190
+ },
191
+ relationships: {
192
+ plugin: {
193
+ data: {
194
+ type: 'platform-plugins',
195
+ id: token
196
+ }
197
+ }
198
+ }
199
+ }
200
+ if options.local
201
+ params[:attributes][:path] = Dir.pwd
202
+ end
203
+ res = Unirest.post(base_url(options, './platform/releases'), headers: headers, parameters: {data: params}.to_json)
204
+ handle_errors(res) unless res.code.between?(200, 299)
205
+ say_ok '✔ Received deploy permission.'
206
+ unless options.local
207
+ unless options.retry
208
+ say 'Packing your plugin...'
209
+ `grunt lambda_package`
210
+ say_ok '✔ Plugin has been packaged.'
211
+ else
212
+ say 'Using previously packaged plugin...'
213
+ end
214
+ files = Dir.glob("#{Dir.pwd}/dist/*_latest.zip")
215
+ uri = URI.parse(res.body['data']['attributes']['upload-to'])
216
+ request = Net::HTTP::Put.new(uri.request_uri)
217
+ request.body = File.open(files.first, 'rb', &:read)
218
+
219
+ http = Net::HTTP.new(uri.host, uri.port)
220
+ http.use_ssl = true
221
+ say 'Uploading...'
222
+ http.request(request)
223
+ say_ok '✔ Successfully uploaded your plugin package.'
224
+ end
225
+ say 'Deploying...'
226
+ release_id = res.body['data']['id']
227
+ ares = Unirest.post(
228
+ base_url(options, "./platform/releases/#{release_id.to_s}/complete"),
229
+ headers: headers
230
+ )
231
+ handle_errors(ares) unless ares.code.between?(200, 299)
232
+ say_ok '✔ Successfully deployed your plugin package.'
233
+ say 'Check out your new plugin at ' \
234
+ "\e[4m"+base_url(options, "/platform/#{res.body['data']['attributes']['plugin-key']}/welcome")+"\e[0m"
235
+ end
236
+ end
237
+
238
+ command :init do |c|
239
+ c.syntax = 'envoy init'
240
+ c.summary = 'Bootstrap a new plugin'
241
+ c.option '--bootstrap', String, 'Adds a prefix to bar'
242
+ c.action do |args, options|
243
+ options.default bootstrap: false
244
+ if args[0]
245
+ # @TODO create dir if it doesn't already exist
246
+ Dir.chdir args[0]
247
+ end
248
+
249
+ if File.exist?(Dir.pwd + '/envoy-manifest.json') || File.exist?(Dir.pwd + '/envoy-manifest-' + profile(options).downcase + '.json')
250
+ agree("It looks you've already created a plugin here. Would you like to register it? (y/n)") || exit
251
+ manifest = JSON.parse File.read(manifest_file(options))
252
+ name = manifest['name']
253
+ key = manifest['key']
254
+ else
255
+ agree("Are you sure you want to initialize a new plugin at #{Dir.pwd}? (y/n)") || exit
256
+ name = ask 'Plugin Name: '
257
+ key = ask 'Unique Key (lowercase [a-z0-9] only): '
258
+ end
259
+
260
+ if name.empty?
261
+ say_error("Invalid plugin name.") && exit
262
+ end
263
+
264
+ if key.empty?
265
+ say_error("Invalid plugin key.") && exit
266
+ end
267
+
268
+ res = Unirest.post(base_url(options, './platform/plugins'), parameters: {
269
+ access_token: config[profile(options)]['access_token'],
270
+ data: { type: 'platform-plugins', attributes: { name: name, key: key } }
271
+ })
272
+
273
+ if !res.code.between?(200, 299)
274
+ handle_errors res
275
+ else
276
+ if options.bootstrap
277
+ Archive::Zip.extract("#{Dir.home}/.envoy/packages/envoy-lambda-sandbox-master.zip", Dir.pwd)
278
+ FileUtils.cp_r "#{Dir.pwd}/envoy-lambda-sandbox-master/.", Dir.pwd
279
+ FileUtils.rm_r "#{Dir.pwd}/envoy-lambda-sandbox-master"
280
+ end
281
+
282
+ cf = !File.exist?(Dir.pwd + '/.env') ? ParseConfig.new : ParseConfig.new(Dir.pwd + '/.env')
283
+ cf.add "ENVOY_#{profile(options).upcase}_PLUGIN_UUID", res.body['data']['id'], true
284
+ file = File.open(Dir.pwd + '/.env', 'w')
285
+ cf.write(file, false)
286
+ file.close
287
+
288
+ manifest = JSON.parse File.read(manifest_file(options))
289
+ manifest['name'] = name
290
+ manifest['key'] = key
291
+
292
+ file = File.open(manifest_file(options), 'w')
293
+ file.write JSON.pretty_generate manifest
294
+ file.close
295
+
296
+ say_ok "✔ Your plugin is ready for development."
297
+ say "ℹ Run `npm install --global-style` before continuing." if options.bootstrap
298
+ end
299
+ end
300
+ end
301
+
302
+ command :sync do |c|
303
+ c.syntax = 'envoy sync [options]'
304
+ c.summary = 'Synchronize your manifest file with the server so that it can parse routes and trigger events.'
305
+ c.action do |_args, options|
306
+ l_config = local_config
307
+ token = plugin_uuid options
308
+ if !File.exist? Dir.pwd + '/envoy-manifest.json'
309
+ say_warning 'No envoy-manifest.json'
310
+ manifest = {}
311
+ else
312
+ manifest = JSON.parse File.read(Dir.pwd + '/envoy-manifest.json')
313
+ end
314
+ payload = { data: { type: 'platform-plugins', attributes: manifest } }
315
+ res = Unirest.put(
316
+ base_url(options, "./platform/plugins/#{token}"),
317
+ parameters: payload.to_json,
318
+ headers: {
319
+ 'Content-Type': 'application/json',
320
+ Authorization: 'Bearer ' + (config[profile(options)]['access_token'])
321
+ }
322
+ )
323
+ if !res.code.between?(200, 299)
324
+ puts res.body
325
+ say_error 'Error syncing. Make sure you are logged in as the right user.'
326
+ else
327
+ say_ok 'Synced successfully'
328
+ end
329
+ end
330
+ end
331
+
332
+ command :rollback do |c|
333
+ c.syntax = 'envoy rollback [options]'
334
+ c.summary = ''
335
+ c.action do |args, options|
336
+ # @TODO: list 5 versions and allow selection of version
337
+ # @TODO: rollback last deploy (or rollback to specific version)
338
+ end
339
+ end
340
+
341
+ command :'list releases' do |c|
342
+ c.syntax = 'envoy list releases [options]'
343
+ c.summary = ''
344
+ c.action do |args, options|
345
+ # @TODO: list plugin releases
346
+ end
347
+ end
348
+
349
+ def handle_errors(res)
350
+ if res.body.instance_of?(Hash) && (res.body['errors'].nil? || res.body['errors'].empty?)
351
+ if res.body.dig('meta', 'message')
352
+ say_error res.body.dig('meta', 'message')
353
+ else
354
+ say_error 'Unkown error occured'
355
+ puts CodeRay.scan(JSON.pretty_generate(res.body), :json).terminal
356
+ end
357
+ elsif res.body.instance_of? String
358
+ say_error 'Unkown error occured'
359
+ if agree("View full response body? (y/n)")
360
+ ask_editor res.body
361
+ end
362
+ elsif res.body.instance_of?(Hash)
363
+ res.body['errors'].each do |err|
364
+ say_error err['detail']
365
+ end
366
+ else
367
+ say_error 'Unkown error occured'
368
+ puts res.body
369
+ end
370
+ exit
371
+ end
372
+
373
+ def base_url(options, path, ignore_profile = false)
374
+ local = false
375
+ profile = $config[profile(options)]
376
+ debug_val(options, ignore_profile, 'Ignore Profile?')
377
+ if !ignore_profile && profile['local']
378
+ local = true
379
+ end
380
+ if options.local
381
+ local = true
382
+ end
383
+ if local
384
+ if profile && profile['api_path_local']
385
+ base = profile['api_path_local']
386
+ else
387
+ base = 'http://localhost:3000'
388
+ end
389
+ else
390
+ if ignore_profile && options.path
391
+ base = options.path
392
+ elsif profile && profile['api_path']
393
+ base = profile['api_path']
394
+ else
395
+ base = 'https://app.envoy.com'
396
+ end
397
+ end
398
+ if path.start_with?('./')
399
+ path = 'api/v2/'+path[2..-1]
400
+ end
401
+ if path.start_with?('/')
402
+ path = path[1..-1]
403
+ end
404
+ if options.trace
405
+ debug options, 'URL', "#{base}/#{path}"
406
+ end
407
+ return "#{base}/#{path}"
408
+ end
409
+
410
+ def debug(options, df, text, extra = false)
411
+ if options.trace || options.debug
412
+ puts "#{df} -> #{text}"
413
+ end
414
+ end
415
+
416
+ def plugin_uuid(options)
417
+ uuid = local_config["ENVOY_#{profile(options).upcase}_PLUGIN_UUID"]
418
+ if !uuid
419
+ say_error 'No ENVOY_PLUGIN_UUID configuration.'
420
+ exit
421
+ end
422
+ uuid
423
+ end
424
+
425
+ def profile(options)
426
+ return debug_val(options, options.profile, 'Using Profile') if options.profile
427
+ cf = local_config
428
+ return debug_val(options, cf['ENVOY_PROFILE'], 'Using Profile') if cf['ENVOY_PROFILE']
429
+ return debug_val(options, 'default', 'Using Profile')
430
+ end
431
+
432
+ def manifest_file(options)
433
+ file = Dir.pwd + '/envoy-manifest-' + profile(options).downcase + '.json'
434
+ unless File.exist? file
435
+ file = Dir.pwd + '/envoy-manifest.json'
436
+ unless File.exist? file
437
+ say_error "Must have envoy-manifest.json or envoy-manifest-" + profile(options).downcase + '.json'
438
+ exit
439
+ end
440
+ end
441
+ debug_val options, file, 'Using Manifest File'
442
+ end
443
+
444
+ def local_config
445
+ return @local_config if @local_config
446
+ if !File.exist? Dir.pwd + '/.env'
447
+ say_error '.env configuration does not exist in this directory'
448
+ exit
449
+ end
450
+ @local_config = ParseConfig.new Dir.pwd + '/.env'
451
+ end
452
+
453
+ def debug_val(options, val, label)
454
+ debug options, label, val
455
+ val
456
+ end
457
+
458
+ def print_event(event)
459
+ puts "------------------------------------------------------------------------"
460
+ data = event['attributes']
461
+ puts "Event UUID => #{event['id']}".green
462
+ puts "Timestamp =>".yellow + " #{data['created-at']}"
463
+ puts "Task Time =>".yellow + " #{data['task-time']}ms"
464
+ puts "Execution Time =>".yellow + " #{data['process-time']}ms"
465
+ puts "\n"
466
+ puts "REQUEST META"
467
+ req_h = JSON.pretty_generate Envoy.min_json(data['request-meta'] || {})
468
+ puts CodeRay.scan(req_h, :json).terminal(line_numbers: :table)
469
+ puts "\n"
470
+ puts "REQUEST BODY"
471
+ req_h = JSON.pretty_generate Envoy.min_json(data['request-body'] || {})
472
+ puts CodeRay.scan(req_h, :json).terminal(line_numbers: :table)
473
+ puts "\n"
474
+ puts "REPONSE META"
475
+ req_h = JSON.pretty_generate Envoy.min_json(data['response-meta'] || {})
476
+ puts CodeRay.scan(req_h, :json).terminal(line_numbers: :table)
477
+ puts "\n"
478
+ puts "RESPONSE BODY"
479
+ req_h = JSON.pretty_generate Envoy.min_json(data['response-body'] || {})
480
+ puts CodeRay.scan(req_h, :json).terminal(line_numbers: :table)
481
+ puts "\n"
482
+ puts "LOG ENTRIES"
483
+ puts data['tail']
484
+ # puts data
485
+ end