2019-01-31 12:19:50 +01:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2020-03-04 10:35:00 +01:00
|
|
|
# retrieve the Fab-manager's versions
|
2019-01-31 12:19:50 +01:00
|
|
|
class Version
|
2020-03-04 10:35:00 +01:00
|
|
|
# currently installed
|
2019-01-31 12:19:50 +01:00
|
|
|
def self.current
|
|
|
|
package = File.read('package.json')
|
|
|
|
JSON.parse(package)['version']
|
|
|
|
end
|
2020-01-14 14:33:00 +01:00
|
|
|
|
2020-03-04 10:35:00 +01:00
|
|
|
# currently published
|
2020-01-14 14:33:00 +01:00
|
|
|
def self.up_to_date?
|
2020-05-13 15:02:03 +02:00
|
|
|
hub_version = Setting.get('hub_last_version')
|
2020-01-14 14:33:00 +01:00
|
|
|
return unless hub_version
|
|
|
|
|
|
|
|
json = JSON.parse(hub_version)
|
2020-01-14 17:12:36 +01:00
|
|
|
json['up_to_date']
|
2020-01-14 14:33:00 +01:00
|
|
|
end
|
|
|
|
|
2020-07-01 16:56:21 +02:00
|
|
|
# retrieve the last published version from the hub and save it into the database
|
|
|
|
def self.check
|
2020-01-15 10:46:04 +01:00
|
|
|
return if (Rails.env.development? || Rails.env.test?) && ENV['FORCE_VERSION_CHECK'] != 'true'
|
2020-01-14 17:59:30 +01:00
|
|
|
|
2020-07-01 16:56:21 +02:00
|
|
|
# check the version
|
|
|
|
VersionCheckWorker.perform_async
|
2020-01-14 14:33:00 +01:00
|
|
|
end
|
2019-01-31 12:19:50 +01:00
|
|
|
end
|