Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,8 @@ spec/examples.txt
Gemfile.lock

# DS_Store
.DS_Store
.DS_Store

# Ignore build files downloaded for testing
*.apk
*.ipa
25 changes: 24 additions & 1 deletion lib/commands/build/distribution/install.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
require 'zip'
require 'rbconfig'
require 'tmpdir'
require 'tty-prompt'

module EmergeCLI
module Commands
Expand Down Expand Up @@ -128,12 +129,34 @@ def install_ios_build(build_path, app_id)
end

def install_android_build(build_path)
command = "adb -s #{@options[:device_id]} install #{build_path}"
device_id = @options[:device_id] || select_android_device
raise 'No Android devices found' unless device_id

command = "adb -s #{device_id} install #{build_path}"
Logger.debug "Running command: #{command}"
`#{command}`

Logger.info '✅ Build installed'
end

def select_android_device
devices = get_android_devices
return nil if devices.empty?
return devices.first if devices.length == 1

prompt = TTY::Prompt.new
Logger.info 'Multiple Android devices found.'
prompt.select('Choose a device:', devices)
end

def get_android_devices
output = `adb devices`
# Split output into lines, remove first line (header), and extract device IDs
output.split("\n")[1..]
.map(&:strip)
.reject(&:empty?)
.map { |line| line.split("\t").first }
end
end
end
end
Expand Down
Loading