lib/roku_builder/controller.rb in roku_builder-3.3.2 vs lib/roku_builder/controller.rb in roku_builder-3.3.3

- old
+ new

@@ -26,19 +26,22 @@ BAD_CURRENT = 5 # No deeplink options supplied for deeplink BAD_DEEPLINK = 6 + # Incorrect use of the in option + BAD_IN_FILE = 7 + ### Device Codes ### # The default device is offline switched to a secondary device CHANGED_DEVICE = -1 # Device is online - GOOD_DEVCICE = 0 + GOOD_DEVICE = 0 # User defined device was not online BAD_DEVICE = 1 # No configured devices were online @@ -106,15 +109,15 @@ end options_code = self.validate_options(options: options, logger: logger) - self.handle_error_codes(options_code: options_code, logger: logger) + self.handle_error_codes(options: options, options_code: options_code, logger: logger) handle_code = self.handle_options(options: options, logger: logger) - self.handle_error_codes(handle_code: handle_code, logger: logger) + self.handle_error_codes(options: options, handle_code: handle_code, logger: logger) end protected # Validates the commands @@ -131,10 +134,13 @@ return NO_SOURCE unless sources.count == 1 end if sources.include?(:current) return BAD_CURRENT unless options[:build] or options[:sideload] end + if options[:in] + return BAD_IN_FILE unless options[:sideload] + end if options[:deeplink] return BAD_DEEPLINK if !options[:deeplink_options] or options[:deeplink_options].chomp == "" end return VALID end @@ -150,11 +156,11 @@ code, config, configs = self.load_config(options: options, logger: logger) return code if code != SUCCESS # Check devices device_code, configs = self.check_devices(options: options, config: config, configs: configs, logger: logger) - self.handle_error_codes(device_code: device_code, logger: logger) + self.handle_error_codes(options: options, device_code: device_code, logger: logger) command = (self.commands & options.keys).first case command when :validate # Do Nothing # @@ -191,11 +197,11 @@ logger.unknown "dev.zip: #{info[:dev_zip]}" end when :build ### Build ### loader = Loader.new(**configs[:device_config]) - build_version = ManifestManager.build_version(**configs[:manifest_config], logger: logger) + build_version = ManifestManager.build_version(**configs[:manifest_config]) options[:build_version] = build_version configs = self.update_configs(configs: configs, options: options) outfile = loader.build(**configs[:build_config]) logger.info "Build: #{outfile}" when :update @@ -243,11 +249,11 @@ # @param options [Hash] The options hash # @param logger [Logger] system logger def self.check_devices(options:, config:, configs:, logger:) ping = Net::Ping::External.new host = configs[:device_config][:ip] - return [GOOD_DEVCICE, configs] if ping.ping? host, 1, 0.2, 1 + return [GOOD_DEVICE, configs] if ping.ping? host, 1, 0.2, 1 return [BAD_DEVICE, nil] if options[:device_given] config[:devices].each_pair {|key, value| unless key == :default host = value[:ip] if ping.ping? host, 1, 0.2, 1 @@ -282,11 +288,11 @@ # Handle error codes # @param options_code [Integer] the error code returned by validate_options # @param handle_code [Integer] the error code returned by handle_options # @param logger [Logger] system logger - def self.handle_error_codes(options_code: nil, device_code: nil, handle_code: nil, logger:) + def self.handle_error_codes(options:, options_code: nil, device_code: nil, handle_code: nil, logger:) if options_code case options_code when EXTRA_COMMANDS logger.fatal "Only one command is allowed" abort @@ -303,10 +309,13 @@ logger.fatal "Can only sideload or build 'current' directory" abort when BAD_DEEPLINK logger.fatal "Must supply deeplinking options when deeplinking" abort + when BAD_IN_FILE + logger.fatal "Can only supply in file for building" + abort end elsif device_code case device_code when CHANGED_DEVICE logger.info "The default device was not online so a secondary device is being used" @@ -495,11 +504,11 @@ # Create Package Config configs[:package_config] = { password: configs[:key][:password], app_name_version: "#{project_config[:app_name]} - #{stage}" } - if options[:outfile] + if options[:out_file] configs[:package_config][:out_file] = File.join(options[:out_folder], options[:out_file]) end # Create Inspector Config configs[:inspect_config] = { pkg: configs[:package_config][:out_file], @@ -514,10 +523,11 @@ folders: project_config[:folders], files: project_config[:files] } # Create Manifest Config configs[:manifest_config] = { - root_dir: project_config[:directory] + root_dir: project_config[:directory], + logger: logger } # Create Deeplink Config configs[:deeplink_config] ={ options: options[:deeplink_options] }