Module: DeployGate::Commands::AddDevices
- Defined in:
- lib/deploygate/commands/add_devices.rb
Class Method Summary collapse
- .build!(bundle_id, args, options) ⇒ Object
- .bundle_id(work_dir, build_configuration) ⇒ String
- .device_register(session, owner, udid, device_name, bundle_id, args, options) ⇒ Object
- .fetch_devices(token, owner, bundle_id) ⇒ Object
- .ios_only_command ⇒ void
- .not_application(owner, bundle_id) ⇒ void
- .not_device ⇒ void
- .register!(devices) ⇒ Object
- .run(args, options) ⇒ Object
- .run_server(session, owner, bundle_id, distribution_key, args, options) ⇒ Object
- .select_devices(devices) ⇒ Array
- .success_registered_device(device) ⇒ void
- .unknown_user ⇒ Object
Class Method Details
.build!(bundle_id, args, options) ⇒ Object
67 68 69 70 71 72 73 74 75 76 |
# File 'lib/deploygate/commands/add_devices.rb', line 67 def build!(bundle_id, args, ) app = DeployGate::Xcode::MemberCenters::App.new(bundle_id) app.create! unless app.created? DeployGate::Xcode::MemberCenters::ProvisioningProfile.new(bundle_id).create! team = DeployGate::Xcode::MemberCenter.instance.team DeployGate::Xcode::Export.clean_provisioning_profiles(bundle_id, team) DeployGate::Commands::Deploy::Build.run(args, ) end |
.bundle_id(work_dir, build_configuration) ⇒ String
100 101 102 103 104 105 |
# File 'lib/deploygate/commands/add_devices.rb', line 100 def bundle_id(work_dir, build_configuration) root_path = DeployGate::Xcode::Ios.project_root_path(work_dir) workspaces = DeployGate::Xcode::Ios.find_workspaces(root_path) analyze = DeployGate::Xcode::Analyze.new(workspaces, build_configuration) analyze.target_bundle_identifier end |
.device_register(session, owner, udid, device_name, bundle_id, args, options) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/deploygate/commands/add_devices.rb', line 37 def device_register(session, owner, udid, device_name, bundle_id, args, ) if udid.nil? && device_name.nil? devices = fetch_devices(session.token, owner, bundle_id) select_devices = select_devices(devices) not_device if select_devices.empty? register!(select_devices) else register_udid = udid || HighLine.ask(I18n.t('commands.add_devices.input_udid')) register_device_name = device_name || HighLine.ask(I18n.t('commands.add_devices.input_device_name')) device = DeployGate::Xcode::MemberCenters::Device.new(register_udid, '', register_device_name) puts device.to_s if HighLine.agree(I18n.t('commands.add_devices.device_register_confirm')) {|q| q.default = "y"} register!([device]) else not_device end end build!(bundle_id, args, ) end |
.fetch_devices(token, owner, bundle_id) ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/deploygate/commands/add_devices.rb', line 78 def fetch_devices(token, owner, bundle_id) res = DeployGate::API::V1::Users::App.not_provisioned_udids(token, owner, bundle_id) if res[:error] case res[:message] when 'unknown app' not_application(owner, bundle_id) when 'unknown user' unknown_user else raise res[:message] end end results = res[:results] devices = results.map{|r| DeployGate::Xcode::MemberCenters::Device.new(r[:udid], r[:user_name], r[:device_name])} devices end |
.ios_only_command ⇒ void
This method returns an undefined value.
136 137 138 139 |
# File 'lib/deploygate/commands/add_devices.rb', line 136 def ios_only_command puts HighLine.color(I18n.t('commands.add_devices.ios_only_command'), HighLine::YELLOW) exit end |
.not_application(owner, bundle_id) ⇒ void
This method returns an undefined value.
144 145 146 147 148 149 |
# File 'lib/deploygate/commands/add_devices.rb', line 144 def not_application(owner, bundle_id) puts '' puts I18n.t('commands.add_devices.unknown_application.data', owner: owner, bundle_id: bundle_id) puts HighLine.color(I18n.t('commands.add_devices.unknown_application.message'), HighLine::YELLOW) exit end |
.not_device ⇒ void
This method returns an undefined value.
130 131 132 133 |
# File 'lib/deploygate/commands/add_devices.rb', line 130 def not_device puts HighLine.color(I18n.t('commands.add_devices.not_device'), HighLine::YELLOW) exit end |
.register!(devices) ⇒ Object
60 61 62 63 64 65 |
# File 'lib/deploygate/commands/add_devices.rb', line 60 def register!(devices) devices.each do |device| device.register! success_registered_device(device) end end |
.run(args, options) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/deploygate/commands/add_devices.rb', line 8 def run(args, ) work_dir = args.empty? ? Dir.pwd : args.first ios_only_command unless DeployGate::Project.ios?(work_dir) session = DeployGate::Session.new unless session.login? Login.start_login_or_create_account() session = DeployGate::Session.new() end owner = .user || session.name udid = .udid device_name = .device_name distribution_key = .distribution_key server = .server bundle_id = bundle_id(work_dir, .configuration) if server run_server(session, owner, bundle_id, distribution_key, args, ) else device_register(session, owner, udid, device_name, bundle_id, args, ) end end |
.run_server(session, owner, bundle_id, distribution_key, args, options) ⇒ Object
33 34 35 |
# File 'lib/deploygate/commands/add_devices.rb', line 33 def run_server(session, owner, bundle_id, distribution_key, args, ) DeployGate::AddDevicesServer.new().start(session.token, owner, bundle_id, distribution_key, args, ) end |
.select_devices(devices) ⇒ Array
109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/deploygate/commands/add_devices.rb', line 109 def select_devices(devices) return [] if devices.empty? select = [] cli = HighLine.new devices.each do |device| puts '' puts I18n.t('commands.add_devices.select_devices.device_info', device: device.to_s) select.push(device) if cli.agree(I18n.t('commands.add_devices.select_devices.agree')) {|q| q.default = "y"} end select end |
.success_registered_device(device) ⇒ void
This method returns an undefined value.
125 126 127 |
# File 'lib/deploygate/commands/add_devices.rb', line 125 def success_registered_device(device) puts HighLine.color(I18n.t('commands.add_devices.success_registered_device', device: device.to_s), HighLine::GREEN) end |
.unknown_user ⇒ Object
151 152 153 154 155 |
# File 'lib/deploygate/commands/add_devices.rb', line 151 def unknown_user puts '' puts HighLine.color(I18n.t('commands.add_devices.unknown_user'), HighLine::RED) exit end |