spaceship 0.17.0 → 0.18.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/spaceship/client.rb +6 -4
- data/lib/spaceship/portal/app.rb +17 -7
- data/lib/spaceship/portal/certificate.rb +51 -8
- data/lib/spaceship/portal/device.rb +21 -11
- data/lib/spaceship/portal/portal_client.rb +48 -27
- data/lib/spaceship/portal/provisioning_profile.rb +38 -18
- data/lib/spaceship/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 297086c54409e9b9aab8d1b628196287a9342c21
|
4
|
+
data.tar.gz: a565663758dcadccea84ee2c510a35e689ec37d5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c4380c49ef46b249e250249d7009d795c83e1258950e133a5f73d4427730ab8831b655029142c3506d3322a3b98fe1cec9a6e0ed89b37b6789736b1cdbbb4c52
|
7
|
+
data.tar.gz: f47667cc9250d8b826373d655ad9808645ebc5bea7fd668c1323c2722b4b39f99f0f793011e98a57d9136399294f3ba2a409a9eeef3124fee8ae9eb98d82bbe2
|
data/lib/spaceship/client.rb
CHANGED
@@ -6,6 +6,8 @@ require 'spaceship/ui'
|
|
6
6
|
require 'spaceship/helper/plist_middleware'
|
7
7
|
require 'spaceship/helper/net_http_generic_request'
|
8
8
|
|
9
|
+
Faraday::Utils.default_params_encoder = Faraday::FlatParamsEncoder
|
10
|
+
|
9
11
|
if ENV["DEBUG"]
|
10
12
|
require 'openssl'
|
11
13
|
# this has to be on top of this file, since the value can't be changed later
|
@@ -256,10 +258,10 @@ module Spaceship
|
|
256
258
|
end
|
257
259
|
|
258
260
|
def parse_response(response, expected_key = nil)
|
259
|
-
if
|
260
|
-
|
261
|
-
|
262
|
-
content = response.body
|
261
|
+
if response.body
|
262
|
+
# If we have an `expected_key`, select that from response.body Hash
|
263
|
+
# Else, don't.
|
264
|
+
content = expected_key ? response.body[expected_key] : response.body
|
263
265
|
end
|
264
266
|
|
265
267
|
if content.nil?
|
data/lib/spaceship/portal/app.rb
CHANGED
@@ -74,9 +74,10 @@ module Spaceship
|
|
74
74
|
self.new(attrs)
|
75
75
|
end
|
76
76
|
|
77
|
+
# @param mac [Bool] Fetches Mac apps if true
|
77
78
|
# @return (Array) Returns all apps available for this account
|
78
|
-
def all
|
79
|
-
client.apps.map { |app| self.factory(app) }
|
79
|
+
def all(mac: false)
|
80
|
+
client.apps(mac: mac).map { |app| self.factory(app) }
|
80
81
|
end
|
81
82
|
|
82
83
|
# Creates a new App ID on the Apple Dev Portal
|
@@ -84,22 +85,24 @@ module Spaceship
|
|
84
85
|
# if bundle_id ends with '*' then it is a wildcard id otherwise, it is an explicit id
|
85
86
|
# @param bundle_id [String] the bundle id (app_identifier) of the app associated with this provisioning profile
|
86
87
|
# @param name [String] the name of the App
|
88
|
+
# @param mac [Bool] is this a Mac app?
|
87
89
|
# @return (App) The app you just created
|
88
|
-
def create!(bundle_id: nil, name: nil)
|
90
|
+
def create!(bundle_id: nil, name: nil, mac: false)
|
89
91
|
if bundle_id.end_with?('*')
|
90
92
|
type = :wildcard
|
91
93
|
else
|
92
94
|
type = :explicit
|
93
95
|
end
|
94
96
|
|
95
|
-
new_app = client.create_app!(type, name, bundle_id)
|
97
|
+
new_app = client.create_app!(type, name, bundle_id, mac: mac)
|
96
98
|
self.new(new_app)
|
97
99
|
end
|
98
100
|
|
99
101
|
# Find a specific App ID based on the bundle_id
|
102
|
+
# @param mac [Bool] Searches Mac apps if true
|
100
103
|
# @return (App) The app you're looking for. This is nil if the app can't be found.
|
101
|
-
def find(bundle_id)
|
102
|
-
all.find do |app|
|
104
|
+
def find(bundle_id, mac: false)
|
105
|
+
all(mac: mac).find do |app|
|
103
106
|
app.bundle_id == bundle_id
|
104
107
|
end
|
105
108
|
end
|
@@ -109,7 +112,7 @@ module Spaceship
|
|
109
112
|
# or there are active profiles
|
110
113
|
# @return (App) The app you just deletd
|
111
114
|
def delete!
|
112
|
-
client.delete_app!(app_id)
|
115
|
+
client.delete_app!(app_id, mac: mac?)
|
113
116
|
self
|
114
117
|
end
|
115
118
|
|
@@ -123,6 +126,7 @@ module Spaceship
|
|
123
126
|
# Associate specific groups with this app
|
124
127
|
# @return (App) The updated detailed app. This is nil if the app couldn't be found
|
125
128
|
def associate_groups(groups)
|
129
|
+
raise "`associate_groups` not available for Mac apps" if mac?
|
126
130
|
app = client.associate_groups_with_app(self, groups)
|
127
131
|
self.class.factory(app)
|
128
132
|
end
|
@@ -130,9 +134,15 @@ module Spaceship
|
|
130
134
|
# Update a service for the app with given AppService object
|
131
135
|
# @return (App) The updated detailed app. This is nil if the app couldn't be found
|
132
136
|
def update_service(service)
|
137
|
+
raise "`update_service` not implemented for Mac apps" if mac?
|
133
138
|
app = client.update_service_for_app(self, service)
|
134
139
|
self.class.factory(app)
|
135
140
|
end
|
141
|
+
|
142
|
+
# @return (Bool) Is this a Mac app?
|
143
|
+
def mac?
|
144
|
+
platform == 'mac'
|
145
|
+
end
|
136
146
|
end
|
137
147
|
end
|
138
148
|
end
|
@@ -91,6 +91,21 @@ module Spaceship
|
|
91
91
|
# An In House code signing certificate used for enterprise distributions
|
92
92
|
class InHouse < Certificate; end
|
93
93
|
|
94
|
+
# A Mac development code signing certificate used for development environment
|
95
|
+
class MacDevelopment < Certificate; end
|
96
|
+
|
97
|
+
# A Mac production code signing certificate for building .app bundles
|
98
|
+
class MacAppDistribution < Certificate; end
|
99
|
+
|
100
|
+
# A Mac production code signing certificate for building .pkg installers
|
101
|
+
class MacInstallerDistribution < Certificate; end
|
102
|
+
|
103
|
+
# A Mac Developer ID signing certificate for building .app bundles
|
104
|
+
class DeveloperIDApplication < Certificate; end
|
105
|
+
|
106
|
+
# A Mac Developer ID signing certificate for building .pkg installers
|
107
|
+
class DeveloperIDInstaller < Certificate; end
|
108
|
+
|
94
109
|
#####################################################
|
95
110
|
# Certs that are specific for one app
|
96
111
|
#####################################################
|
@@ -117,7 +132,13 @@ module Spaceship
|
|
117
132
|
# ApplePay certificate
|
118
133
|
class ApplePay < Certificate; end
|
119
134
|
|
120
|
-
|
135
|
+
# A Mac push notification certificate for development environment
|
136
|
+
class MacDevelopmentPush < PushCertificate; end
|
137
|
+
|
138
|
+
# A Mac push notification certificate for production environment
|
139
|
+
class MacProductionPush < PushCertificate; end
|
140
|
+
|
141
|
+
IOS_CERTIFICATE_TYPE_IDS = {
|
121
142
|
"5QPB9NHCEI" => Development,
|
122
143
|
"R58UK2EWSO" => Production,
|
123
144
|
"9RQEK7MSXA" => InHouse,
|
@@ -130,6 +151,19 @@ module Spaceship
|
|
130
151
|
"4APLUP237T" => ApplePay
|
131
152
|
}
|
132
153
|
|
154
|
+
MAC_CERTIFICATE_TYPE_IDS = {
|
155
|
+
"749Y1QAGU7" => MacDevelopment,
|
156
|
+
"HXZEUKP0FP" => MacAppDistribution,
|
157
|
+
"2PQI8IDXNH" => MacInstallerDistribution,
|
158
|
+
"OYVN2GW35E" => DeveloperIDInstaller,
|
159
|
+
"W0EURJRMC5" => DeveloperIDApplication,
|
160
|
+
"CDZ7EMXIZ1" => MacProductionPush,
|
161
|
+
"HQ4KP3I34R" => MacDevelopmentPush,
|
162
|
+
"DIVN2GW3XT" => DeveloperIDApplication
|
163
|
+
}
|
164
|
+
|
165
|
+
CERTIFICATE_TYPE_IDS = IOS_CERTIFICATE_TYPE_IDS.merge(MAC_CERTIFICATE_TYPE_IDS)
|
166
|
+
|
133
167
|
# Class methods
|
134
168
|
class << self
|
135
169
|
# Create a new code signing request that can be used to
|
@@ -193,24 +227,28 @@ module Spaceship
|
|
193
227
|
klass.new(attrs)
|
194
228
|
end
|
195
229
|
|
230
|
+
# @param mac [Bool] Fetches Mac certificates if true. (Ignored if callsed from a subclass)
|
196
231
|
# @return (Array) Returns all certificates of this account.
|
197
232
|
# If this is called from a subclass of Certificate, this will
|
198
233
|
# only include certificates matching the current type.
|
199
|
-
def all
|
234
|
+
def all(mac: false)
|
200
235
|
if self == Certificate # are we the base-class?
|
201
|
-
|
236
|
+
type_ids = mac ? MAC_CERTIFICATE_TYPE_IDS : IOS_CERTIFICATE_TYPE_IDS
|
237
|
+
types = type_ids.keys
|
202
238
|
else
|
203
239
|
types = [CERTIFICATE_TYPE_IDS.key(self)]
|
240
|
+
mac = MAC_CERTIFICATE_TYPE_IDS.values.include? self
|
204
241
|
end
|
205
242
|
|
206
|
-
client.certificates(types).map do |cert|
|
243
|
+
client.certificates(types, mac: mac).map do |cert|
|
207
244
|
factory(cert)
|
208
245
|
end
|
209
246
|
end
|
210
247
|
|
248
|
+
# @param mac [Bool] Searches Mac certificates if true
|
211
249
|
# @return (Certificate) Find a certificate based on the ID of the certificate.
|
212
|
-
def find(certificate_id)
|
213
|
-
all.find do |c|
|
250
|
+
def find(certificate_id, mac: false)
|
251
|
+
all(mac: mac).find do |c|
|
214
252
|
c.id == certificate_id
|
215
253
|
end
|
216
254
|
end
|
@@ -253,7 +291,7 @@ module Spaceship
|
|
253
291
|
|
254
292
|
# @return (String) Download the raw data of the certificate without parsing
|
255
293
|
def download_raw
|
256
|
-
client.download_certificate(id, type_display_id)
|
294
|
+
client.download_certificate(id, type_display_id, mac: mac?)
|
257
295
|
end
|
258
296
|
|
259
297
|
# @return (OpenSSL::X509::Certificate) Downloads and parses the certificate
|
@@ -263,7 +301,7 @@ module Spaceship
|
|
263
301
|
|
264
302
|
# Revoke the certificate. You shouldn't use this method probably.
|
265
303
|
def revoke!
|
266
|
-
client.revoke_certificate!(id, type_display_id)
|
304
|
+
client.revoke_certificate!(id, type_display_id, mac: mac?)
|
267
305
|
end
|
268
306
|
|
269
307
|
# @return (Bool): Is this certificate a push profile for apps?
|
@@ -272,6 +310,11 @@ module Spaceship
|
|
272
310
|
self.kind_of? PushCertificate
|
273
311
|
end
|
274
312
|
# rubocop:enable Style/PredicateName
|
313
|
+
|
314
|
+
# @return (Bool) Is this a Mac profile?
|
315
|
+
def mac?
|
316
|
+
MAC_CERTIFICATE_TYPE_IDS.include? type_display_id
|
317
|
+
end
|
275
318
|
end
|
276
319
|
end
|
277
320
|
end
|
@@ -58,9 +58,10 @@ module Spaceship
|
|
58
58
|
self.new(attrs)
|
59
59
|
end
|
60
60
|
|
61
|
+
# @param mac [Bool] Fetches Mac devices if true
|
61
62
|
# @return (Array) Returns all devices registered for this account
|
62
|
-
def all
|
63
|
-
client.devices.map { |device| self.factory(device) }
|
63
|
+
def all(mac: false)
|
64
|
+
client.devices(mac: mac).map { |device| self.factory(device) }
|
64
65
|
end
|
65
66
|
|
66
67
|
# @return (Array) Returns all Apple TVs registered for this account
|
@@ -88,6 +89,11 @@ module Spaceship
|
|
88
89
|
client.devices_by_class('ipod').map { |device| self.factory(device) }
|
89
90
|
end
|
90
91
|
|
92
|
+
# @return (Array) Returns all Macs registered for this account
|
93
|
+
def all_macs
|
94
|
+
all(mac: true)
|
95
|
+
end
|
96
|
+
|
91
97
|
# @return (Array) Returns all devices that can be used for iOS profiles (all devices except TVs)
|
92
98
|
def all_ios_profile_devices
|
93
99
|
all.select { |device| device.device_type != "tvOS" }
|
@@ -102,24 +108,27 @@ module Spaceship
|
|
102
108
|
end
|
103
109
|
end
|
104
110
|
|
111
|
+
# @param mac [Bool] Searches for Macs if true
|
105
112
|
# @return (Device) Find a device based on the ID of the device. *Attention*:
|
106
113
|
# This is *not* the UDID. nil if no device was found.
|
107
|
-
def find(device_id)
|
108
|
-
all.find do |device|
|
114
|
+
def find(device_id, mac: false)
|
115
|
+
all(mac: mac).find do |device|
|
109
116
|
device.id == device_id
|
110
117
|
end
|
111
118
|
end
|
112
119
|
|
120
|
+
# @param mac [Bool] Searches for Macs if true
|
113
121
|
# @return (Device) Find a device based on the UDID of the device. nil if no device was found.
|
114
|
-
def find_by_udid(device_udid)
|
115
|
-
all.find do |device|
|
122
|
+
def find_by_udid(device_udid, mac: false)
|
123
|
+
all(mac: mac).find do |device|
|
116
124
|
device.udid == device_udid
|
117
125
|
end
|
118
126
|
end
|
119
127
|
|
128
|
+
# @param mac [Bool] Searches for Macs if true
|
120
129
|
# @return (Device) Find a device based on its name. nil if no device was found.
|
121
|
-
def find_by_name(device_name)
|
122
|
-
all.find do |device|
|
130
|
+
def find_by_name(device_name, mac: false)
|
131
|
+
all(mac: mac).find do |device|
|
123
132
|
device.name == device_name
|
124
133
|
end
|
125
134
|
end
|
@@ -127,23 +136,24 @@ module Spaceship
|
|
127
136
|
# Register a new device to this account
|
128
137
|
# @param name (String) (required): The name of the new device
|
129
138
|
# @param udid (String) (required): The UDID of the new device
|
139
|
+
# @param mac (Bool) (optional): Pass Mac if device is a Mac
|
130
140
|
# @example
|
131
141
|
# Spaceship.device.create!(name: "Felix Krause's iPhone 6", udid: "4c24a7ee5caaa4847f49aaab2d87483053f53b65")
|
132
142
|
# @return (Device): The newly created device
|
133
|
-
def create!(name: nil, udid: nil)
|
143
|
+
def create!(name: nil, udid: nil, mac: false)
|
134
144
|
# Check whether the user has passed in a UDID and a name
|
135
145
|
unless udid && name
|
136
146
|
raise "You cannot create a device without a device_id (UDID) and name"
|
137
147
|
end
|
138
148
|
|
139
149
|
# Find the device by UDID, raise an exception if it already exists
|
140
|
-
if self.find_by_udid(udid)
|
150
|
+
if self.find_by_udid(udid, mac: mac)
|
141
151
|
raise "The device UDID '#{udid}' already exists on this team."
|
142
152
|
end
|
143
153
|
|
144
154
|
# It is valid to have the same name for multiple devices
|
145
155
|
|
146
|
-
device = client.create_device!(name, udid)
|
156
|
+
device = client.create_device!(name, udid, mac: mac)
|
147
157
|
|
148
158
|
# Update self with the new device
|
149
159
|
self.new(device)
|
@@ -96,13 +96,22 @@ module Spaceship
|
|
96
96
|
@in_house = (team_information['type'] == 'In-House')
|
97
97
|
end
|
98
98
|
|
99
|
+
def platform_slug(mac)
|
100
|
+
if mac
|
101
|
+
'mac'
|
102
|
+
else
|
103
|
+
'ios'
|
104
|
+
end
|
105
|
+
end
|
106
|
+
private :platform_slug
|
107
|
+
|
99
108
|
#####################################################
|
100
109
|
# @!group Apps
|
101
110
|
#####################################################
|
102
111
|
|
103
|
-
def apps
|
112
|
+
def apps(mac: false)
|
104
113
|
paging do |page_number|
|
105
|
-
r = request(:post,
|
114
|
+
r = request(:post, "account/#{platform_slug(mac)}/identifiers/listAppIds.action", {
|
106
115
|
teamId: team_id,
|
107
116
|
pageNumber: page_number,
|
108
117
|
pageSize: page_size,
|
@@ -113,7 +122,7 @@ module Spaceship
|
|
113
122
|
end
|
114
123
|
|
115
124
|
def details_for_app(app)
|
116
|
-
r = request(:post,
|
125
|
+
r = request(:post, "account/#{platform_slug(app.mac?)}/identifiers/getAppIdDetail.action", {
|
117
126
|
teamId: team_id,
|
118
127
|
appIdId: app.app_id
|
119
128
|
})
|
@@ -142,7 +151,7 @@ module Spaceship
|
|
142
151
|
details_for_app(app)
|
143
152
|
end
|
144
153
|
|
145
|
-
def create_app!(type, name, bundle_id)
|
154
|
+
def create_app!(type, name, bundle_id, mac: false)
|
146
155
|
ident_params = case type.to_sym
|
147
156
|
when :explicit
|
148
157
|
{
|
@@ -168,12 +177,18 @@ module Spaceship
|
|
168
177
|
|
169
178
|
params.merge!(ident_params)
|
170
179
|
|
171
|
-
|
180
|
+
if csrf_tokens.count == 0
|
181
|
+
# If we directly create a new app without querying anything before
|
182
|
+
# we don't have a valid csrf token, that's why we have to do at least one request
|
183
|
+
apps
|
184
|
+
end
|
185
|
+
|
186
|
+
r = request(:post, "account/#{platform_slug(mac)}/identifiers/addAppId.action", params)
|
172
187
|
parse_response(r, 'appId')
|
173
188
|
end
|
174
189
|
|
175
|
-
def delete_app!(app_id)
|
176
|
-
r = request(:post,
|
190
|
+
def delete_app!(app_id, mac: false)
|
191
|
+
r = request(:post, "account/#{platform_slug(mac)}/identifiers/deleteAppId.action", {
|
177
192
|
teamId: team_id,
|
178
193
|
appIdId: app_id
|
179
194
|
})
|
@@ -217,9 +232,9 @@ module Spaceship
|
|
217
232
|
# @!group Devices
|
218
233
|
#####################################################
|
219
234
|
|
220
|
-
def devices
|
235
|
+
def devices(mac: false)
|
221
236
|
paging do |page_number|
|
222
|
-
r = request(:post,
|
237
|
+
r = request(:post, "account/#{platform_slug(mac)}/device/listDevices.action", {
|
223
238
|
teamId: team_id,
|
224
239
|
pageNumber: page_number,
|
225
240
|
pageSize: page_size,
|
@@ -242,9 +257,9 @@ module Spaceship
|
|
242
257
|
end
|
243
258
|
end
|
244
259
|
|
245
|
-
def create_device!(device_name, device_id)
|
260
|
+
def create_device!(device_name, device_id, mac: false)
|
246
261
|
req = request(:post) do |r|
|
247
|
-
r.url "https://developerservices2.apple.com/services/#{PROTOCOL_VERSION}/
|
262
|
+
r.url "https://developerservices2.apple.com/services/#{PROTOCOL_VERSION}/#{platform_slug(mac)}/addDevice.action"
|
248
263
|
r.params = {
|
249
264
|
teamId: team_id,
|
250
265
|
deviceNumber: device_id,
|
@@ -259,9 +274,9 @@ module Spaceship
|
|
259
274
|
# @!group Certificates
|
260
275
|
#####################################################
|
261
276
|
|
262
|
-
def certificates(types)
|
277
|
+
def certificates(types, mac: false)
|
263
278
|
paging do |page_number|
|
264
|
-
r = request(:post,
|
279
|
+
r = request(:post, "account/#{platform_slug(mac)}/certificate/listCertRequests.action", {
|
265
280
|
teamId: team_id,
|
266
281
|
types: types.join(','),
|
267
282
|
pageNumber: page_number,
|
@@ -288,10 +303,10 @@ module Spaceship
|
|
288
303
|
parse_response(r, 'certRequest')
|
289
304
|
end
|
290
305
|
|
291
|
-
def download_certificate(certificate_id, type)
|
306
|
+
def download_certificate(certificate_id, type, mac: false)
|
292
307
|
{ type: type, certificate_id: certificate_id }.each { |k, v| raise "#{k} must not be nil" if v.nil? }
|
293
308
|
|
294
|
-
r = request(:post,
|
309
|
+
r = request(:post, "https://developer.apple.com/account/#{platform_slug(mac)}/certificate/certificateContentDownload.action", {
|
295
310
|
teamId: team_id,
|
296
311
|
displayId: certificate_id,
|
297
312
|
type: type
|
@@ -304,8 +319,8 @@ module Spaceship
|
|
304
319
|
end
|
305
320
|
end
|
306
321
|
|
307
|
-
def revoke_certificate!(certificate_id, type)
|
308
|
-
r = request(:post,
|
322
|
+
def revoke_certificate!(certificate_id, type, mac: false)
|
323
|
+
r = request(:post, "account/#{platform_slug(mac)}/certificate/revokeCertificate.action", {
|
309
324
|
teamId: team_id,
|
310
325
|
certificateId: certificate_id,
|
311
326
|
type: type
|
@@ -317,9 +332,9 @@ module Spaceship
|
|
317
332
|
# @!group Provisioning Profiles
|
318
333
|
#####################################################
|
319
334
|
|
320
|
-
def provisioning_profiles
|
335
|
+
def provisioning_profiles(mac: false)
|
321
336
|
req = request(:post) do |r|
|
322
|
-
r.url "https://developerservices2.apple.com/services/#{PROTOCOL_VERSION}/
|
337
|
+
r.url "https://developerservices2.apple.com/services/#{PROTOCOL_VERSION}/#{platform_slug(mac)}/listProvisioningProfiles.action"
|
323
338
|
r.params = {
|
324
339
|
teamId: team_id,
|
325
340
|
includeInactiveProfiles: true,
|
@@ -330,8 +345,14 @@ module Spaceship
|
|
330
345
|
parse_response(req, 'provisioningProfiles')
|
331
346
|
end
|
332
347
|
|
333
|
-
def create_provisioning_profile!(name, distribution_method, app_id, certificate_ids, device_ids)
|
334
|
-
|
348
|
+
def create_provisioning_profile!(name, distribution_method, app_id, certificate_ids, device_ids, mac: false)
|
349
|
+
if csrf_tokens.count == 0
|
350
|
+
# If we directly create a new profile without querying anything before
|
351
|
+
# we don't have a valid csrf token, that's why we have to do at least one request
|
352
|
+
provisioning_profiles
|
353
|
+
end
|
354
|
+
|
355
|
+
r = request(:post, "account/#{platform_slug(mac)}/profile/createProvisioningProfile.action", {
|
335
356
|
teamId: team_id,
|
336
357
|
provisioningProfileName: name,
|
337
358
|
appIdId: app_id,
|
@@ -342,8 +363,8 @@ module Spaceship
|
|
342
363
|
parse_response(r, 'provisioningProfile')
|
343
364
|
end
|
344
365
|
|
345
|
-
def download_provisioning_profile(profile_id)
|
346
|
-
r = request(:get,
|
366
|
+
def download_provisioning_profile(profile_id, mac: false)
|
367
|
+
r = request(:get, "https://developer.apple.com/account/#{platform_slug(mac)}/profile/profileContentDownload.action", {
|
347
368
|
teamId: team_id,
|
348
369
|
displayId: profile_id
|
349
370
|
})
|
@@ -355,16 +376,16 @@ module Spaceship
|
|
355
376
|
end
|
356
377
|
end
|
357
378
|
|
358
|
-
def delete_provisioning_profile!(profile_id)
|
359
|
-
r = request(:post,
|
379
|
+
def delete_provisioning_profile!(profile_id, mac: false)
|
380
|
+
r = request(:post, "account/#{platform_slug(mac)}/profile/deleteProvisioningProfile.action", {
|
360
381
|
teamId: team_id,
|
361
382
|
provisioningProfileId: profile_id
|
362
383
|
})
|
363
384
|
parse_response(r)
|
364
385
|
end
|
365
386
|
|
366
|
-
def repair_provisioning_profile!(profile_id, name, distribution_method, app_id, certificate_ids, device_ids)
|
367
|
-
r = request(:post,
|
387
|
+
def repair_provisioning_profile!(profile_id, name, distribution_method, app_id, certificate_ids, device_ids, mac: false)
|
388
|
+
r = request(:post, "account/#{platform_slug(mac)}/profile/regenProvisioningProfile.action", {
|
368
389
|
teamId: team_id,
|
369
390
|
provisioningProfileId: profile_id,
|
370
391
|
provisioningProfileName: name,
|
@@ -192,12 +192,13 @@ module Spaceship
|
|
192
192
|
# @param devices (Array) (optional): An array of Device objects that should be used in this profile.
|
193
193
|
# It is recommend to not pass devices as spaceship will automatically add all devices for AdHoc
|
194
194
|
# and Development profiles and add none for AppStore and Enterprise Profiles
|
195
|
+
# @param mac (Bool) (optional): Pass true if you're making a Mac provisioning profile
|
195
196
|
# @return (ProvisioningProfile): The profile that was just created
|
196
|
-
def create!(name: nil, bundle_id: nil, certificate: nil, devices: [])
|
197
|
+
def create!(name: nil, bundle_id: nil, certificate: nil, devices: [], mac: false)
|
197
198
|
raise "Missing required parameter 'bundle_id'" if bundle_id.to_s.empty?
|
198
199
|
raise "Missing required parameter 'certificate'. e.g. use `Spaceship::Certificate::Production.all.first`" if certificate.to_s.empty?
|
199
200
|
|
200
|
-
app = Spaceship::App.find(bundle_id)
|
201
|
+
app = Spaceship::App.find(bundle_id, mac: mac)
|
201
202
|
raise "Could not find app with bundle id '#{bundle_id}'" unless app
|
202
203
|
|
203
204
|
# Fill in sensible default values
|
@@ -214,7 +215,11 @@ module Spaceship
|
|
214
215
|
if devices.nil? or devices.count == 0
|
215
216
|
if self == Development or self == AdHoc
|
216
217
|
# For Development and AdHoc we usually want all compatible devices by default
|
217
|
-
|
218
|
+
if mac
|
219
|
+
devices = Spaceship::Device.all_macs
|
220
|
+
else
|
221
|
+
devices = Spaceship::Device.all_for_profile_type(self.type)
|
222
|
+
end
|
218
223
|
end
|
219
224
|
end
|
220
225
|
|
@@ -223,7 +228,8 @@ module Spaceship
|
|
223
228
|
self.type,
|
224
229
|
app.app_id,
|
225
230
|
certificate_parameter,
|
226
|
-
devices.map(&:id)
|
231
|
+
devices.map(&:id),
|
232
|
+
mac: mac)
|
227
233
|
end
|
228
234
|
|
229
235
|
self.new(profile)
|
@@ -232,8 +238,8 @@ module Spaceship
|
|
232
238
|
# @return (Array) Returns all profiles registered for this account
|
233
239
|
# If you're calling this from a subclass (like AdHoc), this will
|
234
240
|
# only return the profiles that are of this type
|
235
|
-
def all
|
236
|
-
profiles = client.provisioning_profiles.map do |profile|
|
241
|
+
def all(mac: false)
|
242
|
+
profiles = client.provisioning_profiles(mac: mac).map do |profile|
|
237
243
|
self.factory(profile)
|
238
244
|
end
|
239
245
|
|
@@ -252,8 +258,8 @@ module Spaceship
|
|
252
258
|
# profiles matching the bundle identifier
|
253
259
|
# Returns [] if no profiles were found
|
254
260
|
# This may also contain invalid or expired profiles
|
255
|
-
def find_by_bundle_id(bundle_id)
|
256
|
-
all.find_all do |profile|
|
261
|
+
def find_by_bundle_id(bundle_id, mac: false)
|
262
|
+
all(mac: mac).find_all do |profile|
|
257
263
|
profile.app.bundle_id == bundle_id
|
258
264
|
end
|
259
265
|
end
|
@@ -295,12 +301,12 @@ module Spaceship
|
|
295
301
|
# @example
|
296
302
|
# File.write("path.mobileprovision", profile.download)
|
297
303
|
def download
|
298
|
-
client.download_provisioning_profile(self.id)
|
304
|
+
client.download_provisioning_profile(self.id, mac: mac?)
|
299
305
|
end
|
300
306
|
|
301
307
|
# Delete the provisioning profile
|
302
308
|
def delete!
|
303
|
-
client.delete_provisioning_profile!(self.id)
|
309
|
+
client.delete_provisioning_profile!(self.id, mac: mac?)
|
304
310
|
end
|
305
311
|
|
306
312
|
# Repair an existing provisioning profile
|
@@ -318,12 +324,20 @@ module Spaceship
|
|
318
324
|
# the repair method will generate a profile with a new ID
|
319
325
|
def update!
|
320
326
|
unless certificate_valid?
|
321
|
-
if
|
322
|
-
self.
|
323
|
-
|
324
|
-
|
327
|
+
if mac?
|
328
|
+
if self.kind_of? Development
|
329
|
+
self.certificates = [Spaceship::Certificate::MacDevelopment.all.first]
|
330
|
+
else
|
331
|
+
self.certificates = [Spaceship::Certificate::MacAppDistribution.all.first]
|
332
|
+
end
|
325
333
|
else
|
326
|
-
self.
|
334
|
+
if self.kind_of? Development
|
335
|
+
self.certificates = [Spaceship::Certificate::Development.all.first]
|
336
|
+
elsif self.kind_of? InHouse
|
337
|
+
self.certificates = [Spaceship::Certificate::InHouse.all.first]
|
338
|
+
else
|
339
|
+
self.certificates = [Spaceship::Certificate::Production.all.first]
|
340
|
+
end
|
327
341
|
end
|
328
342
|
end
|
329
343
|
|
@@ -334,12 +348,13 @@ module Spaceship
|
|
334
348
|
distribution_method,
|
335
349
|
app.app_id,
|
336
350
|
certificates.map(&:id),
|
337
|
-
devices.map(&:id)
|
351
|
+
devices.map(&:id),
|
352
|
+
mac: mac?
|
338
353
|
)
|
339
354
|
end
|
340
355
|
|
341
356
|
# We need to fetch the provisioning profile again, as the ID changes
|
342
|
-
profile = Spaceship::ProvisioningProfile.all.find do |p|
|
357
|
+
profile = Spaceship::ProvisioningProfile.all(mac: mac?).find do |p|
|
343
358
|
p.name == self.name # we can use the name as it's valid
|
344
359
|
end
|
345
360
|
|
@@ -351,7 +366,7 @@ module Spaceship
|
|
351
366
|
def certificate_valid?
|
352
367
|
return false if (certificates || []).count == 0
|
353
368
|
certificates.each do |c|
|
354
|
-
if Spaceship::Certificate.all.collect(&:id).include?(c.id)
|
369
|
+
if Spaceship::Certificate.all(mac: mac?).collect(&:id).include?(c.id)
|
355
370
|
return true
|
356
371
|
end
|
357
372
|
end
|
@@ -367,6 +382,11 @@ module Spaceship
|
|
367
382
|
def managed_by_xcode?
|
368
383
|
managing_app == 'Xcode'
|
369
384
|
end
|
385
|
+
|
386
|
+
# @return (Bool) Is this a Mac provisioning profile?
|
387
|
+
def mac?
|
388
|
+
platform == 'mac'
|
389
|
+
end
|
370
390
|
end
|
371
391
|
end
|
372
392
|
end
|
data/lib/spaceship/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spaceship
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.18.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Felix Krause
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-12-
|
12
|
+
date: 2015-12-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: credentials_manager
|