lib/convox_installer/requirements.rb in convox_installer-1.0.9 vs lib/convox_installer/requirements.rb in convox_installer-2.0.0
- old
+ new
@@ -1,56 +1,65 @@
# frozen_string_literal: true
-require "highline"
-require "os"
-require "logger"
+require 'highline'
+require 'os'
+require 'logger'
module ConvoxInstaller
class Requirements
attr_accessor :ecr_label, :logger
def initialize(options = {})
@ecr_label = options[:ecr_label]
- @logger = Logger.new(STDOUT)
+ @logger = Logger.new($stdout)
logger.level = options[:log_level] || Logger::INFO
end
def ensure_requirements!
- logger.debug "Checking for required commands..."
+ logger.debug 'Checking for required commands...'
@missing_packages = []
- unless has_command? "convox"
+ unless command_present? 'convox'
@missing_packages << {
- name: "convox",
- brew: "convox",
- docs: "https://docs.convox.com/introduction/installation",
+ name: 'convox',
+ brew: 'convox',
+ docs: 'https://docs.convox.com/introduction/installation'
}
end
- unless has_command? "aws"
+ unless command_present? 'aws'
@missing_packages << {
- name: "aws",
- brew: "awscli",
- docs: "https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html",
+ name: 'aws',
+ brew: 'awscli',
+ docs: 'https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html'
}
end
if @missing_packages.any?
- logger.error "This script requires the convox and AWS CLI tools."
+ logger.error 'This script requires the convox and AWS CLI tools.'
if OS.mac?
- logger.error "Please run: brew install " \
- "#{@missing_packages.map { |p| p[:brew] }.join(" ")}"
+ logger.error 'Please run: brew install ' \
+ "#{@missing_packages.map { |p| p[:brew] }.join(' ')}"
else
- logger.error "Installation Instructions:"
+ logger.error 'Installation Instructions:'
@missing_packages.each do |package|
logger.error "* #{package[:name]}: #{package[:docs]}"
end
end
quit!
end
+
+ client = Convox::Client.new
+ return if client.convox_2_cli?
+
+ logger.error 'This script requires Convox CLI version 2.x.x. ' \
+ "Your Convox CLI version is: #{client.cli_version_string}"
+ logger.error 'Please follow the instructions here to downgrade your ' \
+ 'Convox CLI version: https://docsv2.convox.com/introduction/installation'
+ quit!
end
- def has_command?(command)
+ def command_present?(command)
path = find_command command
if path.present?
logger.debug "=> Found #{command}: #{path}"
return true
end