diff --git a/emerge_cli.gemspec b/emerge_cli.gemspec index 9ef99b2..fc3815b 100644 --- a/emerge_cli.gemspec +++ b/emerge_cli.gemspec @@ -36,6 +36,7 @@ Gem::Specification.new do |spec| spec.add_dependency 'open3', '~> 0.2.1' spec.add_dependency 'ruby-macho', '~> 4.1.0' spec.add_dependency 'ruby_tree_sitter', '~> 1.9' + spec.add_dependency 'rubyzip', '~> 2.3.0' spec.add_dependency 'tty-prompt', '~> 0.23.1' spec.add_dependency 'tty-table', '~> 0.12.0' spec.add_dependency 'xcodeproj', '~> 1.27.0' diff --git a/lib/commands/build_distribution/validate_app.rb b/lib/commands/build_distribution/validate_app.rb new file mode 100644 index 0000000..28d7285 --- /dev/null +++ b/lib/commands/build_distribution/validate_app.rb @@ -0,0 +1,164 @@ +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/emerge_cli.rb b/lib/emerge_cli.rb index 8298b21..84f53f0 100644 --- a/lib/emerge_cli.rb +++ b/lib/emerge_cli.rb @@ -15,6 +15,7 @@ require_relative 'commands/order_files/validate_linkmaps' require_relative 'commands/order_files/validate_xcode_project' require_relative 'commands/upload/build' +require_relative 'commands/build_distribution/validate_app' require_relative 'reaper/ast_parser' require_relative 'reaper/code_deleter' @@ -61,6 +62,10 @@ module EmergeCLI prefix.register 'validate-linkmaps', Commands::ValidateLinkmaps prefix.register 'validate-xcode-project', Commands::ValidateXcodeProject end + + register 'build-distribution' do |prefix| + prefix.register 'validate-app', Commands::BuildDistribution::ValidateApp + end end # By default the log level is INFO, but can be overridden by the --debug flag