Class: Spaceship::UpdateChecker

Inherits:
Object
  • Object
show all
Defined in:
lib/spaceship/update_checker.rb

Constant Summary collapse

UPDATE_URL =
"https://fastlane-refresher.herokuapp.com/spaceship"

Class Method Summary collapse

Class Method Details

.ensure_spaceship_versionObject


5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/spaceship/update_checker.rb', line 5

def self.ensure_spaceship_version
  return if defined?(SpecHelper) # is this running via tests
  return if ENV["FASTLANE_SKIP_UPDATE_CHECK"]

  require 'faraday'
  require 'json'

  response = Faraday.get(UPDATE_URL)
  return if response.nil? || response.body.to_s.length == 0

  version = JSON.parse(response.body)["version"]
  puts "Comparing spaceship version (remote #{version} - local #{Spaceship::VERSION})" if $verbose
  return if Gem::Version.new(version) <= Gem::Version.new(Spaceship::VERSION)

  show_update_message(Spaceship::VERSION, version)
rescue => ex
  puts ex.to_s if $verbose
  puts "Couldn't verify that spaceship is up to date"
end

.show_update_message(local_version, live_version) ⇒ Object


25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/spaceship/update_checker.rb', line 25

def self.show_update_message(local_version, live_version)
  puts "---------------------------------------------".red
  puts "-------------------WARNING-------------------".red
  puts "---------------------------------------------".red
  puts "You're using an old version of spaceship"
  puts "To ensure spaceship and fastlane works"
  puts "update to the latest version."
  puts ""
  puts "Run `[sudo] gem update spaceship`"
  puts ""
  puts "or `bundle update` if you use bundler."
  puts ""
  puts "You're on spaceship version: #{local_version}".yellow
  puts "Latest spaceship version   : #{live_version}".yellow
  puts ""
end