skylight 3.1.4 → 5.3.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (126) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +465 -294
  3. data/CLA.md +1 -1
  4. data/CONTRIBUTING.md +11 -3
  5. data/ERRORS.md +3 -0
  6. data/LICENSE.md +8 -18
  7. data/README.md +1 -2
  8. data/bin/skylight +1 -1
  9. data/ext/extconf.rb +118 -122
  10. data/ext/libskylight.yml +8 -6
  11. data/ext/skylight_native.c +56 -100
  12. data/lib/skylight/api.rb +41 -27
  13. data/lib/skylight/cli/doctor.rb +68 -70
  14. data/lib/skylight/cli/helpers.rb +3 -5
  15. data/lib/skylight/cli/merger.rb +99 -92
  16. data/lib/skylight/cli.rb +40 -43
  17. data/lib/skylight/config.rb +656 -201
  18. data/lib/skylight/data/cacert.pem +730 -1023
  19. data/lib/skylight/deprecation.rb +17 -0
  20. data/lib/skylight/errors.rb +34 -16
  21. data/lib/skylight/extensions/source_location.rb +291 -0
  22. data/lib/skylight/extensions.rb +95 -0
  23. data/lib/skylight/formatters/http.rb +18 -0
  24. data/lib/skylight/gc.rb +99 -0
  25. data/lib/skylight/helpers.rb +82 -39
  26. data/lib/skylight/instrumenter.rb +339 -9
  27. data/lib/skylight/middleware.rb +147 -1
  28. data/lib/skylight/native.rb +71 -23
  29. data/lib/skylight/native_ext_fetcher.rb +39 -47
  30. data/lib/skylight/normalizers/action_controller/process_action.rb +68 -0
  31. data/lib/skylight/normalizers/action_controller/send_file.rb +51 -0
  32. data/lib/skylight/normalizers/action_dispatch/process_middleware.rb +22 -0
  33. data/lib/skylight/normalizers/action_dispatch/route_set.rb +27 -0
  34. data/lib/skylight/normalizers/action_view/render_collection.rb +24 -0
  35. data/lib/skylight/normalizers/action_view/render_layout.rb +25 -0
  36. data/lib/skylight/normalizers/action_view/render_partial.rb +23 -0
  37. data/lib/skylight/normalizers/action_view/render_template.rb +23 -0
  38. data/lib/skylight/normalizers/active_job/perform.rb +87 -0
  39. data/lib/skylight/normalizers/active_model_serializers/render.rb +32 -0
  40. data/lib/skylight/normalizers/active_record/instantiation.rb +16 -0
  41. data/lib/skylight/normalizers/active_record/sql.rb +20 -0
  42. data/lib/skylight/normalizers/active_storage.rb +28 -0
  43. data/lib/skylight/normalizers/active_support/cache.rb +11 -0
  44. data/lib/skylight/normalizers/active_support/cache_clear.rb +16 -0
  45. data/lib/skylight/normalizers/active_support/cache_decrement.rb +16 -0
  46. data/lib/skylight/normalizers/active_support/cache_delete.rb +16 -0
  47. data/lib/skylight/normalizers/active_support/cache_exist.rb +16 -0
  48. data/lib/skylight/normalizers/active_support/cache_fetch_hit.rb +16 -0
  49. data/lib/skylight/normalizers/active_support/cache_generate.rb +16 -0
  50. data/lib/skylight/normalizers/active_support/cache_increment.rb +16 -0
  51. data/lib/skylight/normalizers/active_support/cache_read.rb +16 -0
  52. data/lib/skylight/normalizers/active_support/cache_read_multi.rb +16 -0
  53. data/lib/skylight/normalizers/active_support/cache_write.rb +16 -0
  54. data/lib/skylight/normalizers/coach/handler_finish.rb +44 -0
  55. data/lib/skylight/normalizers/coach/middleware_finish.rb +33 -0
  56. data/lib/skylight/normalizers/couch_potato/query.rb +20 -0
  57. data/lib/skylight/normalizers/data_mapper/sql.rb +12 -0
  58. data/lib/skylight/normalizers/default.rb +24 -0
  59. data/lib/skylight/normalizers/elasticsearch/request.rb +20 -0
  60. data/lib/skylight/normalizers/faraday/request.rb +38 -0
  61. data/lib/skylight/normalizers/grape/endpoint.rb +28 -0
  62. data/lib/skylight/normalizers/grape/endpoint_render.rb +25 -0
  63. data/lib/skylight/normalizers/grape/endpoint_run.rb +39 -0
  64. data/lib/skylight/normalizers/grape/endpoint_run_filters.rb +20 -0
  65. data/lib/skylight/normalizers/grape/format_response.rb +20 -0
  66. data/lib/skylight/normalizers/graphiti/render.rb +22 -0
  67. data/lib/skylight/normalizers/graphiti/resolve.rb +31 -0
  68. data/lib/skylight/normalizers/graphql/base.rb +127 -0
  69. data/lib/skylight/normalizers/render.rb +79 -0
  70. data/lib/skylight/normalizers/sequel/sql.rb +12 -0
  71. data/lib/skylight/normalizers/shrine.rb +32 -0
  72. data/lib/skylight/normalizers/sql.rb +41 -0
  73. data/lib/skylight/normalizers.rb +157 -0
  74. data/lib/skylight/probes/action_controller.rb +52 -0
  75. data/lib/skylight/probes/action_dispatch/request_id.rb +33 -0
  76. data/lib/skylight/probes/action_dispatch/routing/route_set.rb +30 -0
  77. data/lib/skylight/probes/action_dispatch.rb +2 -0
  78. data/lib/skylight/probes/action_view.rb +42 -0
  79. data/lib/skylight/probes/active_job.rb +27 -0
  80. data/lib/skylight/probes/active_job_enqueue.rb +35 -0
  81. data/lib/skylight/probes/active_model_serializers.rb +50 -0
  82. data/lib/skylight/probes/active_record_async.rb +96 -0
  83. data/lib/skylight/probes/delayed_job.rb +144 -0
  84. data/lib/skylight/probes/elasticsearch.rb +45 -0
  85. data/lib/skylight/probes/excon/middleware.rb +65 -0
  86. data/lib/skylight/probes/excon.rb +25 -0
  87. data/lib/skylight/probes/faraday.rb +23 -0
  88. data/lib/skylight/probes/graphql.rb +38 -0
  89. data/lib/skylight/probes/httpclient.rb +44 -0
  90. data/lib/skylight/probes/middleware.rb +135 -0
  91. data/lib/skylight/probes/mongo.rb +169 -0
  92. data/lib/skylight/probes/mongoid.rb +6 -0
  93. data/lib/skylight/probes/net_http.rb +54 -0
  94. data/lib/skylight/probes/rack_builder.rb +37 -0
  95. data/lib/skylight/probes/redis.rb +68 -0
  96. data/lib/skylight/probes/sequel.rb +29 -0
  97. data/lib/skylight/probes/sinatra.rb +66 -0
  98. data/lib/skylight/probes/sinatra_add_middleware.rb +10 -10
  99. data/lib/skylight/probes/tilt.rb +25 -0
  100. data/lib/skylight/probes.rb +172 -0
  101. data/lib/skylight/railtie.rb +172 -15
  102. data/lib/skylight/sidekiq.rb +47 -0
  103. data/lib/skylight/sinatra.rb +2 -2
  104. data/lib/skylight/subscriber.rb +130 -0
  105. data/lib/skylight/test.rb +147 -0
  106. data/lib/skylight/trace.rb +331 -15
  107. data/lib/skylight/user_config.rb +60 -0
  108. data/lib/skylight/util/allocation_free.rb +26 -0
  109. data/lib/skylight/util/clock.rb +57 -0
  110. data/lib/skylight/util/component.rb +47 -9
  111. data/lib/skylight/util/deploy.rb +24 -40
  112. data/lib/skylight/util/gzip.rb +20 -0
  113. data/lib/skylight/util/hostname.rb +4 -4
  114. data/lib/skylight/util/http.rb +62 -71
  115. data/lib/skylight/util/instrumenter_method.rb +26 -0
  116. data/lib/skylight/util/logging.rb +136 -0
  117. data/lib/skylight/util/lru_cache.rb +36 -0
  118. data/lib/skylight/util/platform.rb +74 -0
  119. data/lib/skylight/util/proxy.rb +13 -0
  120. data/lib/skylight/util/ssl.rb +4 -28
  121. data/lib/skylight/util.rb +12 -0
  122. data/lib/skylight/vendor/cli/thor/rake_compat.rb +1 -1
  123. data/lib/skylight/version.rb +5 -1
  124. data/lib/skylight/vm/gc.rb +60 -0
  125. data/lib/skylight.rb +213 -24
  126. metadata +171 -53
@@ -1,7 +1,7 @@
1
- require 'ostruct'
2
- require 'skylight/util/http'
3
- require 'thor'
4
- require 'highline'
1
+ require "ostruct"
2
+ require "skylight/util/http"
3
+ require "thor"
4
+ require "highline"
5
5
 
6
6
  module Skylight
7
7
  module CLI
@@ -13,9 +13,9 @@ module Skylight
13
13
  end
14
14
 
15
15
  STRINGS = {
16
- get_token: 'get your merge token from `https://www.skylight.io/merging`',
16
+ get_token: "get your merge token from `https://www.skylight.io/merging`",
17
17
  unlisted: "My app isn't listed here :("
18
- }
18
+ }.freeze
19
19
 
20
20
  argument :merge_token, type: :string, desc: STRINGS[:get_token]
21
21
 
@@ -23,8 +23,8 @@ module Skylight
23
23
  say "\nHello! Welcome to the `skylight merge` CLI!\n", :green
24
24
 
25
25
  say "This CLI is for Skylight users who already have Skylight Environments set up\n" \
26
- "using the legacy method of creating a separate Skylight app per environment.\n" \
27
- "Use this CLI to merge legacy environment apps into their parent apps as Environments."
26
+ "using the legacy method of creating a separate Skylight app per environment.\n" \
27
+ "Use this CLI to merge legacy environment apps into their parent apps as Environments."
28
28
  end
29
29
 
30
30
  def fetch_apps
@@ -40,23 +40,24 @@ module Skylight
40
40
  rescue Skylight::Api::Unauthorized
41
41
  done!(
42
42
  success: false,
43
- message: "Provided merge token is invalid.\n" \
44
- "Please #{STRINGS[:get_token]}" \
45
- "and run `skylight merge <merge token>` again."
43
+ message:
44
+ "Provided merge token is invalid.\n" \
45
+ "Please #{STRINGS[:get_token]}" \
46
+ "and run `skylight merge <merge token>` again."
46
47
  )
47
48
  end
48
49
 
49
50
  def ask_for_parent_app
50
- @parents ||= begin
51
- a = (@apps + [{ name: STRINGS[:unlisted], components: [], unlisted: true }])
52
- a.each_with_object({}).with_index do |(app, h), i|
53
- h[i + 1] = OpenStruct.new(app)
51
+ @parents ||=
52
+ begin
53
+ a = (@apps + [{ name: STRINGS[:unlisted], components: [], unlisted: true }])
54
+ a.each_with_object({}).with_index { |(app, h), i| h[i + 1] = OpenStruct.new(app) }
54
55
  end
55
- end
56
56
 
57
57
  say "\nLet's begin!\n\n" \
58
- "Please specify the \"parent\" app.\n" \
59
- "In most cases, this will be the production app handling web requests.", :green
58
+ "Please specify the \"parent\" app.\n" \
59
+ "In most cases, this will be the production app handling web requests.",
60
+ :green
60
61
 
61
62
  @parent_app = ask_for_app(@parents)
62
63
  end
@@ -76,8 +77,9 @@ module Skylight
76
77
 
77
78
  def ask_for_child_env
78
79
  say "\nWhat environment is the child app?\n" \
79
- "In many cases, this will be equivalent to the Rails " \
80
- "environment, i.e., `development`.", :green
80
+ "In many cases, this will be equivalent to the Rails " \
81
+ "environment, i.e., `development`.",
82
+ :green
81
83
 
82
84
  say "1. development"
83
85
  say "2. staging"
@@ -85,15 +87,18 @@ module Skylight
85
87
 
86
88
  i = ask("\nWhich number?").chomp.to_i
87
89
 
88
- @child_env = case i
89
- when 1 then 'development'
90
- when 2 then 'staging'
91
- when 3
92
- specify_child_env
93
- else
94
- say("\nEh? Please enter 1, 2, or 3.", :red)
95
- ask_for_child_env
96
- end
90
+ @child_env =
91
+ case i
92
+ when 1
93
+ "development"
94
+ when 2
95
+ "staging"
96
+ when 3
97
+ specify_child_env
98
+ else
99
+ say("\nEh? Please enter 1, 2, or 3.", :red)
100
+ ask_for_child_env
101
+ end
97
102
  end
98
103
 
99
104
  def confirm_child_env
@@ -102,7 +107,7 @@ module Skylight
102
107
 
103
108
  def confirm_everything
104
109
  say "\nOk! Now we're going to merge `#{set_color(format_component(@child_app), :yellow)}` " \
105
- "into `#{set_color(@parent_app.name, :green)}` as `#{set_color(@child_env, :yellow)}`."
110
+ "into `#{set_color(@parent_app.name, :green)}` as `#{set_color(@child_env, :yellow)}`."
106
111
  end
107
112
 
108
113
  def do_confirm
@@ -112,10 +117,7 @@ module Skylight
112
117
  when "Y", ""
113
118
  do_merge
114
119
  when "N"
115
- done!(
116
- success: true,
117
- message: "Ok, come back any time."
118
- )
120
+ done!(success: true, message: "Ok, come back any time.")
119
121
  else
120
122
  say("Please respond 'Y' to merge or 'n' to cancel.", :red)
121
123
  do_confirm
@@ -128,37 +130,43 @@ module Skylight
128
130
  say "=======================================================\n", :yellow
129
131
 
130
132
  say "IMPORTANT!\n" \
131
- "If you use a config/skylight.yml file to configure Skylight:\n", :yellow
132
-
133
- say "The #@child_env environment for the #{@parent_app.name} app\n" \
134
- "will now connect using the default authentication token for the app.\n" \
135
- "Remove any environment-specific `authentication` configs from the\n" \
136
- "#{@parent_app.name} #@child_env environment.\n", :yellow
137
-
138
- say "If you're running in Rails and your Rails environment exactly matches `#@child_env`,\n" \
139
- "we will automatically detect and report that environment when your agent connects.\n" \
140
- "Otherwise, you should set `env: '#@child_env'` as environment-specific configuration for\n" \
141
- "#@child_env's Rails environment. For example:\n" \
142
- "```yml\n" \
143
- "staging:\n" \
144
- " env: staging-42\n" \
145
- "```\n", :yellow
133
+ "If you use a config/skylight.yml file to configure Skylight:\n",
134
+ :yellow
135
+
136
+ say "The #{@child_env} environment for the #{@parent_app.name} app\n" \
137
+ "will now connect using the default authentication token for the app.\n" \
138
+ "Remove any environment-specific `authentication` configs from the\n" \
139
+ "#{@parent_app.name} #{@child_env} environment.\n",
140
+ :yellow
141
+
142
+ say "If you're running in Rails and your Rails environment exactly matches `#{@child_env}`,\n" \
143
+ "we will automatically detect and report that environment when your agent connects.\n" \
144
+ "Otherwise, you should set `env: '#{@child_env}'` as environment-specific configuration for\n" \
145
+ "#{@child_env}'s Rails environment. For example:\n" \
146
+ "```yml\n" \
147
+ "staging:\n" \
148
+ " env: staging-42\n" \
149
+ "```\n",
150
+ :yellow
146
151
 
147
152
  say "=======================================================\n", :yellow
148
153
 
149
154
  say "IMPORTANT!\n" \
150
- "If you configure Skylight using environment variables:\n", :yellow
155
+ "If you configure Skylight using environment variables:\n",
156
+ :yellow
151
157
 
152
158
  say "Deploy the latest agent before updating your environment variables.\n", :yellow
153
159
 
154
- say "The #@child_env environment for the #{@parent_app.name} app\n" \
155
- "will now connect using the default authentication token for the app.\n" \
156
- "Set `SKYLIGHT_AUTHENTICATION` in the #@child_env environment to the\n" \
157
- "#{@parent_app.name} app's authentication token.\n", :yellow
160
+ say "The #{@child_env} environment for the #{@parent_app.name} app\n" \
161
+ "will now connect using the default authentication token for the app.\n" \
162
+ "Set `SKYLIGHT_AUTHENTICATION` in the #{@child_env} environment to the\n" \
163
+ "#{@parent_app.name} app's authentication token.\n",
164
+ :yellow
158
165
 
159
- say "If you're running in Rails and your Rails environment exactly matches `#@child_env`,\n" \
160
- "we will automatically detect and report that environment when your agent connects.\n" \
161
- "Otherwise, you should set `SKYLIGHT_ENV=#@child_env` when running in this environment.\n", :yellow
166
+ say "If you're running in Rails and your Rails environment exactly matches `#{@child_env}`,\n" \
167
+ "we will automatically detect and report that environment when your agent connects.\n" \
168
+ "Otherwise, you should set `SKYLIGHT_ENV=#{@child_env}` when running in this environment.\n",
169
+ :yellow
162
170
 
163
171
  say "=======================================================", :yellow
164
172
 
@@ -170,12 +178,13 @@ module Skylight
170
178
  def do_merge
171
179
  say "Merging..."
172
180
 
173
- api.merge_apps!(@merge_token,
174
- app_guid: @parent_app.guid,
175
- component_guid: @child_app.guid,
176
- environment: @child_env
177
- )
178
- rescue => e
181
+ api.merge_apps!(
182
+ @merge_token,
183
+ app_guid: @parent_app.guid,
184
+ component_guid: @child_app.guid,
185
+ environment: @child_env
186
+ )
187
+ rescue StandardError => e
179
188
  say("Something went wrong. Please contact support@skylight.io for more information.", :red)
180
189
  done!(message: e.message, success: false)
181
190
  end
@@ -197,9 +206,7 @@ module Skylight
197
206
 
198
207
  def ask_for_app(app_list, &formatter)
199
208
  formatter ||= :name.to_proc
200
- app_list.each do |index, app|
201
- say("\t#{index}. #{formatter.(app)}")
202
- end
209
+ app_list.each { |index, app| say("\t#{index}. #{formatter.call(app)}") }
203
210
 
204
211
  n = ask("\nWhich number?").chomp.to_i
205
212
 
@@ -207,10 +214,7 @@ module Skylight
207
214
  say "\nHmm?"
208
215
  ask_for_app(app_list, &formatter)
209
216
  elsif app_list[n].unlisted
210
- done!(
211
- success: false,
212
- message: "Sorry, `skylight merge` is only able to merge apps that you own."
213
- )
217
+ done!(success: false, message: "Sorry, `skylight merge` is only able to merge apps that you own.")
214
218
  else
215
219
  app_list[n]
216
220
  end
@@ -221,14 +225,15 @@ module Skylight
221
225
  end
222
226
 
223
227
  def format_component(component)
224
- parts = [].tap do |ary|
225
- ary << component.name unless component.name == 'web'
226
- ary << component.environment unless component.environment == 'production'
227
- end
228
+ parts =
229
+ [].tap do |ary|
230
+ ary << component.name unless component.name == "web"
231
+ ary << component.environment unless component.environment == "production"
232
+ end
228
233
 
229
- str = ''
234
+ str = ""
230
235
  str << component.app_name
231
- str << Thor::Shell::Color.new.set_color(" (#{parts.join(':')})", :yellow) if parts.any?
236
+ str << Thor::Shell::Color.new.set_color(" (#{parts.join(":")})", :yellow) if parts.any?
232
237
  str
233
238
  end
234
239
 
@@ -240,8 +245,9 @@ module Skylight
240
245
  end
241
246
 
242
247
  if @parent_app && parent_component_fingerprints.include?([child_app.name, child_env])
243
- errors << "Sorry, `#{@parent_app.name}` already has a `#{child_env}` " \
244
- "component that conflicts with this merge request. Please choose a new environment."
248
+ errors <<
249
+ "Sorry, `#{@parent_app.name}` already has a `#{child_env}` " \
250
+ "component that conflicts with this merge request. Please choose a new environment."
245
251
  end
246
252
 
247
253
  return child_env unless errors.any?
@@ -253,28 +259,31 @@ module Skylight
253
259
 
254
260
  def valid_component?(component_name, env)
255
261
  return false unless env
256
- Skylight::Util::Component.new(env, component_name) && true
262
+
263
+ Util::Component.new(env, component_name) && true
257
264
  rescue ArgumentError
258
265
  false
259
266
  end
260
267
 
261
268
  def parent_component_fingerprints
262
- @parent_app.components.map { |x| x.values_at('name', 'environment') }
269
+ @parent_app.components.map { |x| x.values_at("name", "environment") }
263
270
  end
264
271
 
265
272
  def children
266
- Enumerator.new do |yielder|
267
- @parents.each do |_, app|
268
- next if app == @parent_app
269
- app.components.each do |component|
270
- yielder << OpenStruct.new({ app_name: app.name }.merge(component))
273
+ ret =
274
+ Enumerator.new do |yielder|
275
+ @parents.each do |_, app|
276
+ next if app == @parent_app
277
+
278
+ app.components.each { |component| yielder << OpenStruct.new({ app_name: app.name }.merge(component)) }
271
279
  end
280
+
281
+ yielder << OpenStruct.new(app_name: STRINGS[:unlisted], unlisted: true)
272
282
  end
273
283
 
274
- yielder << OpenStruct.new({ app_name: STRINGS[:unlisted], unlisted: true })
275
- end.each_with_object({}).with_index do |(c, r), i|
276
- r[i + 1] = c
277
- end.tap do |result|
284
+ ret = ret.each_with_object({}).with_index { |(c, r), i| r[i + 1] = c }
285
+
286
+ ret.tap do |result|
278
287
  if result.values.all?(&:unlisted)
279
288
  done!(
280
289
  success: false,
@@ -288,9 +297,7 @@ module Skylight
288
297
  validate_mergeability(
289
298
  @child_app,
290
299
  ask("Please enter your environment name (only lowercase letters, numbers, or hyphens): ", :green).chomp
291
- ) do
292
- specify_child_env
293
- end
300
+ ) { specify_child_env }
294
301
  end
295
302
  end
296
303
  end
data/lib/skylight/cli.rb CHANGED
@@ -1,14 +1,14 @@
1
- $:.unshift File.expand_path('../vendor/cli', __FILE__)
1
+ $LOAD_PATH.unshift File.expand_path("vendor/cli", __dir__)
2
2
 
3
- require 'skylight'
4
- require 'thor'
5
- require 'yaml'
6
- require 'highline'
7
- require 'active_support/inflector'
3
+ require "skylight"
4
+ require "thor"
5
+ require "yaml"
6
+ require "highline"
7
+ require "active_support/inflector"
8
8
 
9
- require 'skylight/cli/helpers'
10
- require 'skylight/cli/doctor'
11
- require 'skylight/cli/merger'
9
+ require "skylight/cli/helpers"
10
+ require "skylight/cli/doctor"
11
+ require "skylight/cli/merger"
12
12
 
13
13
  module Skylight
14
14
  module CLI
@@ -22,45 +22,46 @@ module Skylight
22
22
  desc "setup TOKEN", "Sets up a new app using the provided token"
23
23
  def setup(token)
24
24
  if File.exist?(config_path)
25
- say <<-OUT, :green
26
- A config/skylight.yml already exists for your application.
25
+ say <<~OUT, :green
26
+ A config/skylight.yml already exists for your application.
27
27
 
28
- Visit your app at https://www.skylight.io/app or remove config/skylight.yml
29
- to set it up as a new app in Skylight.
28
+ Visit your app at https://www.skylight.io/app or remove config/skylight.yml
29
+ to set it up as a new app in Skylight.
30
30
  OUT
31
+
31
32
  return
32
33
  end
33
34
 
34
35
  res = api.create_app(app_name, token)
35
36
 
36
- config[:application] = res.get('app.id')
37
- config[:authentication] = res.get('app.token')
37
+ config[:application] = res.get("app.id")
38
+ config[:authentication] = res.get("app.token")
38
39
  config.write(config_path)
39
40
 
40
41
  say "Congratulations. Your application is on Skylight! https://www.skylight.io", :green
41
- say <<-OUT
42
+ say <<~OUT
42
43
 
43
- The application was registered for you and we generated a config file
44
- containing your API token at:
44
+ The application was registered for you and we generated a config file
45
+ containing your API token at:
45
46
 
46
- #{relative_config_path}
47
+ #{relative_config_path}
47
48
 
48
- The next step is for you to deploy your application to production. The
49
- easiest way is to just commit the config file to your source control
50
- repository and deploy from there. You can learn more about the process at:
49
+ The next step is for you to deploy your application to production. The
50
+ easiest way is to just commit the config file to your source control
51
+ repository and deploy from there. You can learn more about the process at:
51
52
 
52
- https://docs.skylight.io/getting-set-up/#deployment
53
+ https://docs.skylight.io/getting-set-up/#deployment
53
54
 
54
- If you want to specify the authentication token as an environment variable,
55
- you should set the `SKYLIGHT_AUTHENTICATION` variable to:
55
+ If you want to specify the authentication token as an environment variable,
56
+ you should set the `SKYLIGHT_AUTHENTICATION` variable to:
56
57
 
57
- #{config[:authentication]}
58
+ #{config[:authentication]}
58
59
 
59
60
  OUT
60
61
  rescue Api::CreateFailed => e
61
62
  say "Could not create the application. Please run `bundle exec skylight doctor` for diagnostics.", :red
62
63
  say e.to_s, :yellow
63
- rescue Interrupt
64
+ rescue Interrupt # rubocop:disable Lint/SuppressedException
64
65
  end
65
66
 
66
67
  desc "disable_dev_warning", "Disables warning about running Skylight in development mode for all local apps"
@@ -71,7 +72,9 @@ you should set the `SKYLIGHT_AUTHENTICATION` variable to:
71
72
  say "Development mode warning disabled", :green
72
73
  end
73
74
 
74
- desc "disable_env_warning", "Disables warning about running Skylight in environments not defined in config.skylight.environments"
75
+ desc "disable_env_warning",
76
+ "Disables warning about running Skylight in environments not defined in " \
77
+ "config.skylight.environments"
75
78
  def disable_env_warning
76
79
  user_config.disable_env_warning = true
77
80
  user_config.save
@@ -79,25 +82,26 @@ you should set the `SKYLIGHT_AUTHENTICATION` variable to:
79
82
  say "Environment warning disabled", :green
80
83
  end
81
84
 
82
- private
85
+ private
83
86
 
84
87
  def app_name
85
88
  @app_name ||=
86
89
  begin
87
90
  name = nil
88
91
 
89
- if is_rails?
92
+ if rails?
90
93
  # Get the name in a process so that we don't pollute our environment here
91
94
  # This is especially important since users may have things like WebMock that
92
95
  # will prevent us from communicating with the Skylight API
93
96
  begin
94
- namefile = Tempfile.new('skylight-app-name')
97
+ namefile = Tempfile.new("skylight-app-name")
98
+
95
99
  # Windows appears to need double quotes for `rails runner`
96
100
  `rails runner "File.open('#{namefile.path}', 'w') {|f| f.write(Rails.application.class.name) rescue '' }"`
97
101
  name = namefile.read.split("::").first.underscore.titleize
98
102
  name = nil if name.empty?
99
- rescue => e
100
- if ENV['DEBUG']
103
+ rescue StandardError => e
104
+ if ENV["DEBUG"]
101
105
  puts e.class.name
102
106
  puts e.to_s
103
107
  puts e.backtrace.join("\n")
@@ -107,22 +111,16 @@ you should set the `SKYLIGHT_AUTHENTICATION` variable to:
107
111
  namefile.unlink
108
112
  end
109
113
 
110
- unless name
111
- warn "Unable to determine Rails application name. Using directory name."
112
- end
113
- end
114
-
115
- unless name
116
- name = File.basename(File.expand_path('.')).titleize
114
+ warn "Unable to determine Rails application name. Using directory name." unless name
117
115
  end
118
116
 
119
- name
117
+ name || File.basename(File.expand_path(".")).titleize
120
118
  end
121
119
  end
122
120
 
123
121
  # Is this duplicated?
124
122
  def relative_config_path
125
- 'config/skylight.yml'
123
+ "config/skylight.yml"
126
124
  end
127
125
 
128
126
  def config_path
@@ -136,7 +134,6 @@ you should set the `SKYLIGHT_AUTHENTICATION` variable to:
136
134
  def user_config
137
135
  config.user_config
138
136
  end
139
-
140
137
  end
141
138
  end
142
139
  end