-
Notifications
You must be signed in to change notification settings - Fork 1
/
AddNewDevice.rb
executable file
·79 lines (58 loc) · 1.76 KB
/
AddNewDevice.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/env ruby
$LOAD_PATH << '.'
require 'spaceship'
require 'openssl'
require 'fileutils'
require 'config'
PROFILES_LOCATION = File::expand_path("~/Library/MobileDevice/Provisioning\ Profiles")
def camel_case(str)
words = str.downcase.split
words.shift + words.map(&:capitalize).join
end
if ARGV[0].nil?
puts 'Please provide bundle id prefix'
exit
end
if ARGV[2].nil?
puts 'Please provide device id'
exit
end
if ARGV[1].nil?
puts 'Please provide device name'
exit
end
client = Spaceship.login(AppMakerConfig::DEV_USER, AppMakerConfig::DEV_PASSWORD)
puts "Logged in"
#Spaceship.select_team
client.team_id = 'P2WQ65BAA8'
#puts "Team Selected: #{client.team_information.name}"
#Spaceship.app.all.collect do |app|
# puts app
#end
#FileUtils::mkdir_p appName
app = Spaceship.app.find(ARGV[0])
if !app.nil?
puts 'Application Found:'
puts app.app_id
puts app.name
puts app.bundle_id
devices = Spaceship::Device.all
devProfiles = Spaceship.provisioning_profile.development.find_by_bundle_id(ARGV[0])
devProfile = devProfiles.first
puts "Profile uuid: #{devProfile.uuid}"
puts 'Removing old profile'
cmd = `rm '#{PROFILES_LOCATION}/#{devProfile.uuid}.mobileprovision'`
puts 'Creating New Device'
newDevice = Spaceship.device.create!(name: ARGV[1], udid: ARGV[2])
devProfile.devices = Spaceship.device.all
puts 'Updating provide'
devProfile.update!
puts "Installing new Profile"
devProfiles = Spaceship.provisioning_profile.development.find_by_bundle_id(ARGV[0])
devProfile = devProfiles.first
profileFileName = "#{PROFILES_LOCATION}/#{devProfile.uuid}.mobileprovision"
File.write(profileFileName, devProfile.download)
puts "Profile stored at #{profileFileName}"
exit
end
puts "Application '#{ARGV[0]}' not found."