diff --git a/lib/commands/build/distribution/install.rb b/lib/commands/build/distribution/install.rb new file mode 100644 index 0000000..dfeac2a --- /dev/null +++ b/lib/commands/build/distribution/install.rb @@ -0,0 +1,141 @@ +require 'dry/cli' +require 'cfpropertylist' +require 'zip' +require 'rbconfig' +require 'tmpdir' + +module EmergeCLI + module Commands + module Build + module Distribution + class Install < EmergeCLI::Commands::GlobalOptions + desc 'Download and install a build from Build Distribution' + + option :api_token, type: :string, required: false, + desc: 'API token for authentication, defaults to ENV[EMERGE_API_TOKEN]' + option :build_id, type: :string, required: true, desc: 'Build ID to download' + option :install, type: :boolean, default: true, required: false, desc: 'Install the build on the device' + option :device_id, type: :string, desc: 'Specific device ID to target' + option :device_type, type: :string, enum: %w[virtual physical any], default: 'any', + desc: 'Type of device to target (virtual/physical/any)' + option :output, type: :string, required: false, desc: 'Output path for the downloaded build' + + def initialize(network: nil) + @network = network + end + + def call(**options) + @options = options + before(options) + + Sync do + api_token = @options[:api_token] || ENV.fetch('EMERGE_API_TOKEN', nil) + raise 'API token is required' unless api_token + + raise 'Build ID is required' unless @options[:build_id] + + output_name = nil + app_id = nil + + begin + @network ||= EmergeCLI::Network.new(api_token:) + + Logger.info 'Getting build URL...' + request = get_build_url(@options[:build_id]) + response = parse_response(request) + + platform = response['platform'] + download_url = response['downloadUrl'] + app_id = response['appId'] + + extension = platform == 'ios' ? 'ipa' : 'apk' + Logger.info 'Downloading build...' + output_name = @options[:output] || "#{@options[:build_id]}.#{extension}" + `curl --progress-bar -L '#{download_url}' -o #{output_name} ` + Logger.info "✅ Build downloaded to #{output_name}" + rescue StandardError => e + Logger.error "❌ Failed to download build: #{e.message}" + raise e + ensure + @network&.close + end + + begin + if @options[:install] && !output_name.nil? + if platform == 'ios' + install_ios_build(output_name, app_id) + elsif platform == 'android' + install_android_build(output_name) + end + end + rescue StandardError => e + Logger.error "❌ Failed to install build: #{e.message}" + raise e + end + end + end + + private + + def get_build_url(build_id) + @network.get( + path: '/distribution/downloadUrl', + max_retries: 3, + query: { + buildId: build_id + } + ) + end + + def parse_response(response) + case response.status + when 200 + JSON.parse(response.read) + when 400 + error_message = JSON.parse(response.read)['errorMessage'] + raise "Invalid parameters: #{error_message}" + when 401, 403 + raise 'Invalid API token' + else + raise "Getting build failed with status #{response.status}" + end + end + + def install_ios_build(build_path, app_id) + device_type = case @options[:device_type] + when 'simulator' + XcodeDeviceManager::DeviceType::VIRTUAL + when 'physical' + XcodeDeviceManager::DeviceType::PHYSICAL + else + XcodeDeviceManager::DeviceType::ANY + end + + device_manager = XcodeDeviceManager.new + device = if @options[:device_id] + device_manager.find_device_by_id(@options[:device_id]) + else + device_manager.find_device_by_type(device_type, build_path) + end + + Logger.info "Installing build on #{device.device_id}" + device.install_app(build_path) + Logger.info '✅ Build installed' + + Logger.info "Launching app #{app_id}..." + device.launch_app(app_id) + Logger.info '✅ Build launched' + end + + def install_android_build(build_path) + command = "adb -s #{@options[:device_id]} install #{build_path}" + Logger.debug "Running command: #{command}" + `#{command}` + + Logger.info '✅ Build installed' + end + end + end + end + end +end diff --git a/lib/commands/build/distribution/validate.rb b/lib/commands/build/distribution/validate.rb new file mode 100644 index 0000000..f90873d --- /dev/null +++ b/lib/commands/build/distribution/validate.rb @@ -0,0 +1,166 @@ +require 'dry/cli' +require 'cfpropertylist' +require 'zip' +require 'rbconfig' + +module EmergeCLI + module Commands + module Build + module Distribution + class ValidateApp < EmergeCLI::Commands::GlobalOptions + desc 'Validate app for build distribution' + + option :path, type: :string, required: true, desc: 'Path to the xcarchive, IPA or APK to validate' + + # Constants + PLIST_START = ' Time.now + Logger.info '✅ Provisioning profile hasn\'t expired' + else + Logger.info "❌ Provisioning profile is expired. Expiration date: #{expiration_date}" + end + + provisions_all_devices = parsed_data['ProvisionsAllDevices'] + if provisions_all_devices + Logger.info 'Provisioning profile supports all devices (likely an enterprise profile)' + else + devices = parsed_data['ProvisionedDevices'] + Logger.info 'Provisioning profile does not support all devices (likely a development profile).' + Logger.info "Devices: #{devices.inspect}" + end + end + + def check_supported_abis(apk_path) + abis = [] + + Zip::File.open(apk_path) do |zip_file| + zip_file.each do |entry| + if entry.name.start_with?('lib/') && entry.name.count('/') == 2 + abi = entry.name.split('/')[1] + abis << abi unless abis.include?(abi) + end + end + end + + unless abis.include?(EXPECTED_ABI) + raise "APK does not support #{EXPECTED_ABI} architecture, found: #{abis.join(', ')}" + end + + Logger.info "✅ APK supports #{EXPECTED_ABI} architecture" + end + end + end + end + end +end diff --git a/lib/commands/build_distribution/download_and_install.rb b/lib/commands/build_distribution/download_and_install.rb deleted file mode 100644 index 87b4c88..0000000 --- a/lib/commands/build_distribution/download_and_install.rb +++ /dev/null @@ -1,139 +0,0 @@ -require 'dry/cli' -require 'cfpropertylist' -require 'zip' -require 'rbconfig' -require 'tmpdir' - -module EmergeCLI - module Commands - module BuildDistribution - class DownloadAndInstall < EmergeCLI::Commands::GlobalOptions - desc 'Download build from Build Distribution' - - option :api_token, type: :string, required: false, - desc: 'API token for authentication, defaults to ENV[EMERGE_API_TOKEN]' - option :build_id, type: :string, required: true, desc: 'Build ID to download' - option :install, type: :boolean, default: true, required: false, desc: 'Install the build on the device' - option :device_id, type: :string, desc: 'Specific device ID to target' - option :device_type, type: :string, enum: %w[virtual physical any], default: 'any', - desc: 'Type of device to target (virtual/physical/any)' - option :output, type: :string, required: false, desc: 'Output path for the downloaded build' - - def initialize(network: nil) - @network = network - end - - def call(**options) - @options = options - before(options) - - Sync do - api_token = @options[:api_token] || ENV.fetch('EMERGE_API_TOKEN', nil) - raise 'API token is required' unless api_token - - raise 'Build ID is required' unless @options[:build_id] - - output_name = nil - app_id = nil - - begin - @network ||= EmergeCLI::Network.new(api_token:) - - Logger.info 'Getting build URL...' - request = get_build_url(@options[:build_id]) - response = parse_response(request) - - platform = response['platform'] - download_url = response['downloadUrl'] - app_id = response['appId'] - - extension = platform == 'ios' ? 'ipa' : 'apk' - Logger.info 'Downloading build...' - output_name = @options[:output] || "#{@options[:build_id]}.#{extension}" - `curl --progress-bar -L '#{download_url}' -o #{output_name} ` - Logger.info "✅ Build downloaded to #{output_name}" - rescue StandardError => e - Logger.error "❌ Failed to download build: #{e.message}" - raise e - ensure - @network&.close - end - - begin - if @options[:install] && !output_name.nil? - if platform == 'ios' - install_ios_build(output_name, app_id) - elsif platform == 'android' - install_android_build(output_name) - end - end - rescue StandardError => e - Logger.error "❌ Failed to install build: #{e.message}" - raise e - end - end - end - - private - - def get_build_url(build_id) - @network.get( - path: '/distribution/downloadUrl', - max_retries: 3, - query: { - buildId: build_id - } - ) - end - - def parse_response(response) - case response.status - when 200 - JSON.parse(response.read) - when 400 - error_message = JSON.parse(response.read)['errorMessage'] - raise "Invalid parameters: #{error_message}" - when 401, 403 - raise 'Invalid API token' - else - raise "Getting build failed with status #{response.status}" - end - end - - def install_ios_build(build_path, app_id) - device_type = case @options[:device_type] - when 'simulator' - XcodeDeviceManager::DeviceType::VIRTUAL - when 'physical' - XcodeDeviceManager::DeviceType::PHYSICAL - else - XcodeDeviceManager::DeviceType::ANY - end - - device_manager = XcodeDeviceManager.new - device = if @options[:device_id] - device_manager.find_device_by_id(@options[:device_id]) - else - device_manager.find_device_by_type(device_type, build_path) - end - - Logger.info "Installing build on #{device.device_id}" - device.install_app(build_path) - Logger.info '✅ Build installed' - - Logger.info "Launching app #{app_id}..." - device.launch_app(app_id) - Logger.info '✅ Build launched' - end - - def install_android_build(build_path) - command = "adb -s #{@options[:device_id]} install #{build_path}" - Logger.debug "Running command: #{command}" - `#{command}` - - Logger.info '✅ Build installed' - end - end - end - end -end diff --git a/lib/commands/build_distribution/validate_app.rb b/lib/commands/build_distribution/validate_app.rb deleted file mode 100644 index 28d7285..0000000 --- a/lib/commands/build_distribution/validate_app.rb +++ /dev/null @@ -1,164 +0,0 @@ -require 'dry/cli' -require 'cfpropertylist' -require 'zip' -require 'rbconfig' - -module EmergeCLI - module Commands - module BuildDistribution - class ValidateApp < EmergeCLI::Commands::GlobalOptions - desc 'Validate app for build distribution' - - option :path, type: :string, required: true, desc: 'Path to the xcarchive, IPA or APK to validate' - - # Constants - PLIST_START = ' Time.now - Logger.info '✅ Provisioning profile hasn\'t expired' - else - Logger.info "❌ Provisioning profile is expired. Expiration date: #{expiration_date}" - end - - provisions_all_devices = parsed_data['ProvisionsAllDevices'] - if provisions_all_devices - Logger.info 'Provisioning profile supports all devices (likely an enterprise profile)' - else - devices = parsed_data['ProvisionedDevices'] - Logger.info 'Provisioning profile does not support all devices (likely a development profile).' - Logger.info "Devices: #{devices.inspect}" - end - end - - def check_supported_abis(apk_path) - abis = [] - - Zip::File.open(apk_path) do |zip_file| - zip_file.each do |entry| - if entry.name.start_with?('lib/') && entry.name.count('/') == 2 - abi = entry.name.split('/')[1] - abis << abi unless abis.include?(abi) - end - end - end - - unless abis.include?(EXPECTED_ABI) - raise "APK does not support #{EXPECTED_ABI} architecture, found: #{abis.join(', ')}" - end - - Logger.info "✅ APK supports #{EXPECTED_ABI} architecture" - end - end - end - end -end diff --git a/lib/commands/autofixes/exported_symbols.rb b/lib/commands/fix/exported_symbols.rb similarity index 99% rename from lib/commands/autofixes/exported_symbols.rb rename to lib/commands/fix/exported_symbols.rb index 1ec0691..cbfd988 100644 --- a/lib/commands/autofixes/exported_symbols.rb +++ b/lib/commands/fix/exported_symbols.rb @@ -3,7 +3,7 @@ module EmergeCLI module Commands - module Autofixes + module Fix class ExportedSymbols < EmergeCLI::Commands::GlobalOptions desc 'Remove exported symbols from built binaries' diff --git a/lib/commands/autofixes/minify_strings.rb b/lib/commands/fix/minify_strings.rb similarity index 99% rename from lib/commands/autofixes/minify_strings.rb rename to lib/commands/fix/minify_strings.rb index 287363c..4ed7a54 100644 --- a/lib/commands/autofixes/minify_strings.rb +++ b/lib/commands/fix/minify_strings.rb @@ -3,7 +3,7 @@ module EmergeCLI module Commands - module Autofixes + module Fix class MinifyStrings < EmergeCLI::Commands::GlobalOptions desc 'Minify strings in the app' diff --git a/lib/commands/autofixes/strip_binary_symbols.rb b/lib/commands/fix/strip_binary_symbols.rb similarity index 99% rename from lib/commands/autofixes/strip_binary_symbols.rb rename to lib/commands/fix/strip_binary_symbols.rb index 5074291..bde8637 100644 --- a/lib/commands/autofixes/strip_binary_symbols.rb +++ b/lib/commands/fix/strip_binary_symbols.rb @@ -3,7 +3,7 @@ module EmergeCLI module Commands - module Autofixes + module Fix class StripBinarySymbols < EmergeCLI::Commands::GlobalOptions desc 'Strip binary symbols from the app' diff --git a/lib/commands/order_files/download_order_files.rb b/lib/commands/order_files/download_order_files.rb index f94d5aa..425dfcf 100644 --- a/lib/commands/order_files/download_order_files.rb +++ b/lib/commands/order_files/download_order_files.rb @@ -2,75 +2,77 @@ module EmergeCLI module Commands - class DownloadOrderFiles < EmergeCLI::Commands::GlobalOptions - desc 'Download order files from Emerge' + module OrderFiles + class Download < EmergeCLI::Commands::GlobalOptions + desc 'Download order files from Emerge' - option :bundle_id, type: :string, required: true, desc: 'Bundle identifier to download order files for' + option :bundle_id, type: :string, required: true, desc: 'Bundle identifier to download order files for' - option :api_token, type: :string, required: false, - desc: 'API token for authentication, defaults to ENV[EMERGE_API_TOKEN]' + option :api_token, type: :string, required: false, + desc: 'API token for authentication, defaults to ENV[EMERGE_API_TOKEN]' - option :app_version, type: :string, required: true, - desc: 'App version to download order files for' + option :app_version, type: :string, required: true, + desc: 'App version to download order files for' - option :unzip, type: :boolean, required: false, - desc: 'Unzip the order file after downloading' + option :unzip, type: :boolean, required: false, + desc: 'Unzip the order file after downloading' - option :output, type: :string, required: false, - desc: 'Output name for the order file, defaults to bundle_id-app_version.gz' + option :output, type: :string, required: false, + desc: 'Output name for the order file, defaults to bundle_id-app_version.gz' - EMERGE_ORDER_FILE_URL = 'order-files-prod.emergetools.com'.freeze + EMERGE_ORDER_FILE_URL = 'order-files-prod.emergetools.com'.freeze - def initialize(network: nil) - @network = network - end + def initialize(network: nil) + @network = network + end - def call(**options) - @options = options - before(options) + def call(**options) + @options = options + before(options) - begin - api_token = @options[:api_token] || ENV.fetch('EMERGE_API_TOKEN', nil) - raise 'API token is required' unless api_token + begin + api_token = @options[:api_token] || ENV.fetch('EMERGE_API_TOKEN', nil) + raise 'API token is required' unless api_token - raise 'Bundle ID is required' unless @options[:bundle_id] - raise 'App version is required' unless @options[:app_version] + raise 'Bundle ID is required' unless @options[:bundle_id] + raise 'App version is required' unless @options[:app_version] - @network ||= EmergeCLI::Network.new(api_token:, base_url: EMERGE_ORDER_FILE_URL) - output_name = @options[:output] || "#{@options[:bundle_id]}-#{@options[:app_version]}.gz" - output_name = "#{output_name}.gz" unless output_name.end_with?('.gz') + @network ||= EmergeCLI::Network.new(api_token:, base_url: EMERGE_ORDER_FILE_URL) + output_name = @options[:output] || "#{@options[:bundle_id]}-#{@options[:app_version]}.gz" + output_name = "#{output_name}.gz" unless output_name.end_with?('.gz') - Sync do - request = get_order_file(options[:bundle_id], options[:app_version]) - response = request.read + Sync do + request = get_order_file(options[:bundle_id], options[:app_version]) + response = request.read - File.write(output_name, response) + File.write(output_name, response) - if @options[:unzip] - Logger.info 'Unzipping order file...' - Zlib::GzipReader.open(output_name) do |gz| - File.write(output_name.gsub('.gz', ''), gz.read) + if @options[:unzip] + Logger.info 'Unzipping order file...' + Zlib::GzipReader.open(output_name) do |gz| + File.write(output_name.gsub('.gz', ''), gz.read) + end end - end - Logger.info 'Order file downloaded successfully' + Logger.info 'Order file downloaded successfully' + end + rescue StandardError => e + Logger.error "Failed to download order file: #{e.message}" + Logger.error 'Check your parameters and try again' + raise e + ensure + @network&.close end - rescue StandardError => e - Logger.error "Failed to download order file: #{e.message}" - Logger.error 'Check your parameters and try again' - raise e - ensure - @network&.close end - end - private + private - def get_order_file(bundle_id, app_version) - @network.get( - path: "/#{bundle_id}/#{app_version}", - max_retries: 0 - ) + def get_order_file(bundle_id, app_version) + @network.get( + path: "/#{bundle_id}/#{app_version}", + max_retries: 0 + ) + end end end end diff --git a/lib/commands/order_files/validate_linkmaps.rb b/lib/commands/order_files/validate_linkmaps.rb index 41a7232..05d5ad3 100644 --- a/lib/commands/order_files/validate_linkmaps.rb +++ b/lib/commands/order_files/validate_linkmaps.rb @@ -3,52 +3,54 @@ module EmergeCLI module Commands - class ValidateLinkmaps < EmergeCLI::Commands::GlobalOptions - desc 'Validate linkmaps in xcarchive' + module OrderFiles + class ValidateLinkmaps < EmergeCLI::Commands::GlobalOptions + desc 'Validate linkmaps in xcarchive' - option :path, type: :string, required: true, desc: 'Path to the xcarchive to validate' + option :path, type: :string, required: true, desc: 'Path to the xcarchive to validate' - def initialize(network: nil) - @network = network - end + def initialize(network: nil) + @network = network + end - def call(**options) - @options = options - before(options) + def call(**options) + @options = options + before(options) - Sync do - executable_name = get_executable_name - raise 'Executable not found' if executable_name.nil? + Sync do + executable_name = get_executable_name + raise 'Executable not found' if executable_name.nil? - Logger.info "Using executable: #{executable_name}" + Logger.info "Using executable: #{executable_name}" - linkmaps_path = File.join(@options[:path], 'Linkmaps') - raise 'Linkmaps folder not found' unless File.directory?(linkmaps_path) + linkmaps_path = File.join(@options[:path], 'Linkmaps') + raise 'Linkmaps folder not found' unless File.directory?(linkmaps_path) - linkmaps = Dir.glob("#{linkmaps_path}/*.txt") - raise 'No linkmaps found' if linkmaps.empty? + linkmaps = Dir.glob("#{linkmaps_path}/*.txt") + raise 'No linkmaps found' if linkmaps.empty? - executable_linkmaps = linkmaps.select do |linkmap| - File.basename(linkmap).start_with?(executable_name) - end - raise 'No linkmaps found for executable' if executable_linkmaps.empty? + executable_linkmaps = linkmaps.select do |linkmap| + File.basename(linkmap).start_with?(executable_name) + end + raise 'No linkmaps found for executable' if executable_linkmaps.empty? - Logger.info "✅ Found linkmaps for #{executable_name}" + Logger.info "✅ Found linkmaps for #{executable_name}" + end end - end - private + private - def get_executable_name - raise 'Path must be an xcarchive' unless @options[:path].end_with?('.xcarchive') + def get_executable_name + raise 'Path must be an xcarchive' unless @options[:path].end_with?('.xcarchive') - app_path = Dir.glob("#{@options[:path]}/Products/Applications/*.app").first - info_path = File.join(app_path, 'Info.plist') - plist_data = File.read(info_path) - plist = CFPropertyList::List.new(data: plist_data) - parsed_data = CFPropertyList.native_types(plist.value) + app_path = Dir.glob("#{@options[:path]}/Products/Applications/*.app").first + info_path = File.join(app_path, 'Info.plist') + plist_data = File.read(info_path) + plist = CFPropertyList::List.new(data: plist_data) + parsed_data = CFPropertyList.native_types(plist.value) - parsed_data['CFBundleExecutable'] + parsed_data['CFBundleExecutable'] + end end end end diff --git a/lib/commands/order_files/validate_xcode_project.rb b/lib/commands/order_files/validate_xcode_project.rb index e44c29c..710e00e 100644 --- a/lib/commands/order_files/validate_xcode_project.rb +++ b/lib/commands/order_files/validate_xcode_project.rb @@ -3,67 +3,69 @@ module EmergeCLI module Commands - class ValidateXcodeProject < EmergeCLI::Commands::GlobalOptions - desc 'Validate xcodeproject for order files' + module OrderFiles + class ValidateXcodeProject < EmergeCLI::Commands::GlobalOptions + desc 'Validate xcodeproject for order files' - option :path, type: :string, required: true, desc: 'Path to the xcodeproject to validate' - option :target, type: :string, required: false, desc: 'Target to validate' - option :build_configuration, type: :string, required: false, - desc: 'Build configuration to validate (Release by default)' + option :path, type: :string, required: true, desc: 'Path to the xcodeproject to validate' + option :target, type: :string, required: false, desc: 'Target to validate' + option :build_configuration, type: :string, required: false, + desc: 'Build configuration to validate (Release by default)' - # Constants - LINK_MAPS_CONFIG = 'LD_GENERATE_MAP_FILE'.freeze - LINK_MAPS_PATH = 'LD_MAP_FILE_PATH'.freeze - PATH_TO_LINKMAP = '$(TARGET_TEMP_DIR)/$(PRODUCT_NAME)-LinkMap-$(CURRENT_VARIANT)-$(CURRENT_ARCH).txt'.freeze + # Constants + LINK_MAPS_CONFIG = 'LD_GENERATE_MAP_FILE'.freeze + LINK_MAPS_PATH = 'LD_MAP_FILE_PATH'.freeze + PATH_TO_LINKMAP = '$(TARGET_TEMP_DIR)/$(PRODUCT_NAME)-LinkMap-$(CURRENT_VARIANT)-$(CURRENT_ARCH).txt'.freeze - def call(**options) - @options = options - before(options) + def call(**options) + @options = options + before(options) - raise 'Path must be an xcodeproject' unless @options[:path].end_with?('.xcodeproj') - raise 'Path does not exist' unless File.exist?(@options[:path]) + raise 'Path must be an xcodeproject' unless @options[:path].end_with?('.xcodeproj') + raise 'Path does not exist' unless File.exist?(@options[:path]) - @options[:build_configuration] ||= 'Release' + @options[:build_configuration] ||= 'Release' - Sync do - project = Xcodeproj::Project.open(@options[:path]) + Sync do + project = Xcodeproj::Project.open(@options[:path]) - validate_xcproj(project) + validate_xcproj(project) + end end - end - private + private - def validate_xcproj(project) - project.targets.each do |target| - next if @options[:target] && target.name != @options[:target] - next unless target.product_type == 'com.apple.product-type.application' + def validate_xcproj(project) + project.targets.each do |target| + next if @options[:target] && target.name != @options[:target] + next unless target.product_type == 'com.apple.product-type.application' - target.build_configurations.each do |config| - next if config.name != @options[:build_configuration] - validate_target_config(target, config) + target.build_configurations.each do |config| + next if config.name != @options[:build_configuration] + validate_target_config(target, config) + end end end - end - def validate_target_config(target, config) - has_error = false - if config.build_settings[LINK_MAPS_CONFIG] != 'YES' - has_error = true - Logger.error "❌ Write Link Map File (#{LINK_MAPS_CONFIG}) is not set to YES" - end - if config.build_settings[LINK_MAPS_PATH] != '' - has_error = true - Logger.error "❌ Path to Link Map File (#{LINK_MAPS_PATH}) is not set, we recommend \ + def validate_target_config(target, config) + has_error = false + if config.build_settings[LINK_MAPS_CONFIG] != 'YES' + has_error = true + Logger.error "❌ Write Link Map File (#{LINK_MAPS_CONFIG}) is not set to YES" + end + if config.build_settings[LINK_MAPS_PATH] != '' + has_error = true + Logger.error "❌ Path to Link Map File (#{LINK_MAPS_PATH}) is not set, we recommend \ setting it to '#{PATH_TO_LINKMAP}'" - end + end - if has_error - Logger.error "❌ Target '#{target.name}' has errors, this means \ + if has_error + Logger.error "❌ Target '#{target.name}' has errors, this means \ that the linkmaps will not be generated as expected" - Logger.error "Use `emerge configure order-files-ios --project-path '#{@options[:path]}'` to fix this" - else - Logger.info "✅ Target '#{target.name}' is valid" + Logger.error "Use `emerge configure order-files-ios --project-path '#{@options[:path]}'` to fix this" + else + Logger.info "✅ Target '#{target.name}' is valid" + end end end end diff --git a/lib/emerge_cli.rb b/lib/emerge_cli.rb index ddad4f4..cc9d47a 100644 --- a/lib/emerge_cli.rb +++ b/lib/emerge_cli.rb @@ -1,25 +1,25 @@ require_relative 'version' require_relative 'commands/global_options' -require_relative 'commands/upload/snapshots/snapshots' -require_relative 'commands/upload/snapshots/client_libraries/swift_snapshot_testing' -require_relative 'commands/upload/snapshots/client_libraries/paparazzi' -require_relative 'commands/upload/snapshots/client_libraries/roborazzi' -require_relative 'commands/upload/snapshots/client_libraries/default' -require_relative 'commands/integrate/fastlane' +require_relative 'commands/build/distribution/validate' +require_relative 'commands/build/distribution/install' require_relative 'commands/config/snapshots/snapshots_ios' require_relative 'commands/config/orderfiles/orderfiles_ios' -require_relative 'commands/reaper/reaper' -require_relative 'commands/snapshots/validate_app' +require_relative 'commands/integrate/fastlane' +require_relative 'commands/fix/minify_strings' +require_relative 'commands/fix/strip_binary_symbols' +require_relative 'commands/fix/exported_symbols' require_relative 'commands/order_files/download_order_files' require_relative 'commands/order_files/validate_linkmaps' require_relative 'commands/order_files/validate_xcode_project' +require_relative 'commands/reaper/reaper' +require_relative 'commands/snapshots/validate_app' require_relative 'commands/upload/build' -require_relative 'commands/build_distribution/validate_app' -require_relative 'commands/build_distribution/download_and_install' -require_relative 'commands/autofixes/minify_strings' -require_relative 'commands/autofixes/strip_binary_symbols' -require_relative 'commands/autofixes/exported_symbols' +require_relative 'commands/upload/snapshots/snapshots' +require_relative 'commands/upload/snapshots/client_libraries/swift_snapshot_testing' +require_relative 'commands/upload/snapshots/client_libraries/paparazzi' +require_relative 'commands/upload/snapshots/client_libraries/roborazzi' +require_relative 'commands/upload/snapshots/client_libraries/default' require_relative 'reaper/ast_parser' require_relative 'reaper/code_deleter' @@ -44,41 +44,42 @@ module EmergeCLI extend Dry::CLI::Registry - register 'upload', aliases: ['u'] do |prefix| - prefix.register 'build', Commands::Upload::Build - prefix.register 'snapshots', Commands::Upload::Snapshots - end - - register 'integrate' do |prefix| - prefix.register 'fastlane-ios', Commands::Integrate::Fastlane, aliases: ['i'] - end - register 'configure' do |prefix| prefix.register 'snapshots-ios', Commands::Config::SnapshotsIOS prefix.register 'order-files-ios', Commands::Config::OrderFilesIOS end - register 'reaper', Commands::Reaper + register 'download' do |prefix| + prefix.register 'order-files', Commands::OrderFiles::Download + end - register 'snapshots' do |prefix| - prefix.register 'validate-app-ios', Commands::Snapshots::ValidateApp + register 'fix' do |prefix| + prefix.register 'minify-strings', Commands::Fix::MinifyStrings + prefix.register 'strip-binary-symbols', Commands::Fix::StripBinarySymbols + prefix.register 'exported-symbols', Commands::Fix::ExportedSymbols end - register 'order-files' do |prefix| - prefix.register 'download', Commands::DownloadOrderFiles - prefix.register 'validate-linkmaps', Commands::ValidateLinkmaps - prefix.register 'validate-xcode-project', Commands::ValidateXcodeProject + register 'integrate' do |prefix| + prefix.register 'fastlane-ios', Commands::Integrate::Fastlane, aliases: ['i'] end - register 'build-distribution' do |prefix| - prefix.register 'validate-app', Commands::BuildDistribution::ValidateApp - prefix.register 'install', Commands::BuildDistribution::DownloadAndInstall + register 'install' do |prefix| + prefix.register 'build', Commands::Build::Distribution::Install + end + + # TODO: make this command action oriented + register 'reaper', Commands::Reaper + + register 'upload', aliases: ['u'] do |prefix| + prefix.register 'build', Commands::Upload::Build + prefix.register 'snapshots', Commands::Upload::Snapshots end - register 'autofix' do |prefix| - prefix.register 'minify-strings', Commands::Autofixes::MinifyStrings - prefix.register 'strip-binary-symbols', Commands::Autofixes::StripBinarySymbols - prefix.register 'exported-symbols', Commands::Autofixes::ExportedSymbols + register 'validate' do |prefix| + prefix.register 'build-distribution', Commands::Build::Distribution::ValidateApp + prefix.register 'order-files-linkmaps', Commands::OrderFiles::ValidateLinkmaps + prefix.register 'order-files-xcode-project', Commands::OrderFiles::ValidateXcodeProject + prefix.register 'snapshots-app-ios', Commands::Snapshots::ValidateApp end end diff --git a/test/commands/autofixes/exported_symbols_test.rb b/test/commands/autofixes/exported_symbols_test.rb index 07bee19..647d221 100644 --- a/test/commands/autofixes/exported_symbols_test.rb +++ b/test/commands/autofixes/exported_symbols_test.rb @@ -11,7 +11,7 @@ class ExportedSymbolsTest < Minitest::Test __mh_execute_header).freeze def setup - @command = EmergeCLI::Commands::Autofixes::ExportedSymbols.new + @command = EmergeCLI::Commands::Fix::ExportedSymbols.new FileUtils.mkdir_p('tmp/test_autofix_exported_symbols') FileUtils.cp_r('test/test_files/ExampleApp.xcodeproj', diff --git a/test/commands/autofixes/minify_strings_test.rb b/test/commands/autofixes/minify_strings_test.rb index 5c4cd58..42e6674 100644 --- a/test/commands/autofixes/minify_strings_test.rb +++ b/test/commands/autofixes/minify_strings_test.rb @@ -10,7 +10,7 @@ class MinifyStringsTest < Minitest::Test STRINGS_FILE_OUTPUT_ENCODING_VALUE = 'UTF-8'.freeze def setup - @command = EmergeCLI::Commands::Autofixes::MinifyStrings.new + @command = EmergeCLI::Commands::Fix::MinifyStrings.new FileUtils.mkdir_p('tmp/test_autofix_strings') FileUtils.cp_r('test/test_files/ExampleApp.xcodeproj', 'tmp/test_autofix_strings/ExampleApp.xcodeproj') diff --git a/test/commands/autofixes/strip_binary_symbols_test.rb b/test/commands/autofixes/strip_binary_symbols_test.rb index dc7dbce..1a1e0ec 100644 --- a/test/commands/autofixes/strip_binary_symbols_test.rb +++ b/test/commands/autofixes/strip_binary_symbols_test.rb @@ -10,7 +10,7 @@ class StripBinarySymbolsTest < Minitest::Test 'Contents/Resources/DWARF/${EXECUTABLE_NAME}'.freeze def setup - @command = EmergeCLI::Commands::Autofixes::StripBinarySymbols.new + @command = EmergeCLI::Commands::Fix::StripBinarySymbols.new FileUtils.mkdir_p('tmp/test_autofix_strip_binary_symbols') FileUtils.cp_r('test/test_files/ExampleApp.xcodeproj', diff --git a/test/commands/orderfiles/download_order_files_test.rb b/test/commands/orderfiles/download_order_files_test.rb index 97e9cda..6740595 100644 --- a/test/commands/orderfiles/download_order_files_test.rb +++ b/test/commands/orderfiles/download_order_files_test.rb @@ -12,7 +12,7 @@ def test_unzips_file_when_unzip_flag_is_true @network = FakeNetwork.new( '/com.emerge.hn.Hacker-News/3.4.0' => File.read('test/test_files/com.emerge.hn.Hacker-News-3.4.0.gz') ) - @download_order_files = DownloadOrderFiles.new(network: @network) + @download_order_files = OrderFiles::Download.new(network: @network) options = { bundle_id: 'com.emerge.hn.Hacker-News',