deploygate 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZWQyZmNkNWY5MDkxMjc2YmUxOTM4MTMwZTY4MmFlMTZiNzc4MTQxNg==
4
+ MDIxOWM0M2U2OThlNmZlYjVmNTMwMmE4MTliNWNhNGRmZjRiN2E1OQ==
5
5
  data.tar.gz: !binary |-
6
- MWU0NWVmZDViMTYxZWJjNjg1NTc3YTc1MWExNTM4YWMyYTE5NDgxNA==
6
+ NGQyZThlNGQ5ZjQyYzA2ZmNlODhiMTk1NzdhZWVkZTZkNzkzMWU3MQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MDkxMmZiYzVkYWQ0NjhhNjM3YzNmNTAzMjExODY0NmJhZDFiNDhiNTZiZWM1
10
- ZDZjZTZkOGRhZTgzOGUyZDMxMGQ4YTBmZDM1MTJlMTg2OGQ5OTJkNmEyMmVh
11
- NTM5Yjg4ODU1ZDJlMzA0MWU4YThkZmYyZmY3MDA4MDFjZTJjNzA=
9
+ NWIyOGU4YjFhMTg4NTU4MjRiYTA1M2Q0ZDQ3ODU2OThmODI0YTI1NTE4MDNk
10
+ MDZmY2JiYzQ2ZDFmNzUwYmI5MmNmOWUzMDI3MDZlYzE2MGFkMDlhYmJhNmNm
11
+ M2M2NDBmNWViNzczOTg5NjIzNDU5ZDllZmMyODkzOTQ2MTExZjA=
12
12
  data.tar.gz: !binary |-
13
- MWVjOGRhNWFiNTE1ODcyNzk2MzlhMGI1OGFhYzRjNDkzMDE4MzdmODg5NjFk
14
- NTk5Y2NiZDAzMjEyNDRhYjJlZGYxNDBjMDNhOTAyZDE4MGZkNTE2ZDIwNmJj
15
- NzJhOTIyODZjMWVlZTEzMzdlYjI3MDQ2ZGY4NzU4MGQ3NDdhZmE=
13
+ ZjA0YTI4MTU4ZGY2OTAxMDM5NGRhZDJlZWVhMzc4MDI1MzdmMzZjYjM4N2Jm
14
+ OGIyY2YyNGM2M2JhOThhOTJiMTY0MmI4ZTJhYzVmNDZmMGM2NjFmYzFmYjRm
15
+ YzU0NGViZWQ4OTFiNTdjMDMxYTlmYTQ5YmZiNDZlMDRhMWI5MTc=
@@ -125,7 +125,7 @@ en:
125
125
  provisioning_profile: 'Error: Failed to create provisioning profile'
126
126
  select_teams:
127
127
  prompt: 'Please select a team'
128
- choice: '%{team_id} %{team_name}'
128
+ choice: '%{team_name} %{team_id}'
129
129
  check_local_certificates:
130
130
  not_local_install_certificate:
131
131
  error_message: 'Error: No applicable iPhone Distribution certificate found on your Mac.'
@@ -162,3 +162,6 @@ en:
162
162
 
163
163
  Note: Your password will be stored to your Keychain and never be sent to DeployGate.
164
164
  email: 'Email: '
165
+ provisioning_profile:
166
+ not_installed_certificate_error: 'No iPhone Distribution Certificate associated with private key was found in local Keychain'
167
+ not_exist_uuid_provisioning_profile_error: 'No provisioning profile found for the specified UUID (%{uuid})'
data/deploygate.gemspec CHANGED
@@ -32,12 +32,12 @@ POST_INSTALL_MESSAGE
32
32
  spec.add_dependency 'activesupport', '~> 4.2.4'
33
33
  spec.add_dependency 'i18n'
34
34
  spec.add_dependency 'launchy'
35
+ spec.add_dependency 'locale'
35
36
 
36
37
  # ios build
37
- spec.add_dependency 'gym', '~> 1.0.0'
38
- spec.add_dependency 'spaceship', '~> 0.12.3'
39
- spec.add_dependency 'sigh', '~> 1.1.0'
40
- spec.add_dependency 'locale'
38
+ spec.add_dependency 'gym', '~> 1.4.0'
39
+ spec.add_dependency 'spaceship', '~> 0.19.0'
40
+ spec.add_dependency 'sigh', '~> 1.2.2'
41
41
 
42
42
  spec.add_development_dependency "bundler", "~> 1.3"
43
43
  spec.add_development_dependency "rake"
@@ -153,6 +153,7 @@ EOF
153
153
  def error_handling(command, error)
154
154
  STDERR.puts HighLine.color(I18n.t('command_builder.error_handling.message', message: error.message), HighLine::RED)
155
155
 
156
+ return if error.kind_of?(DeployGate::NotIssueError)
156
157
  puts ''
157
158
  if HighLine.agree(I18n.t('command_builder.error_handling.agree')) {|q| q.default = "n"}
158
159
  url = create_issue_url(command, error)
@@ -1,10 +1,10 @@
1
1
  module DeployGate
2
2
  class Deploy
3
- class NotLoginError < StandardError
3
+ class NotLoginError < DeployGate::NotIssueError
4
4
  end
5
- class NotFileExistError < StandardError
5
+ class NotFileExistError < DeployGate::NotIssueError
6
6
  end
7
- class UploadError < StandardError
7
+ class UploadError < DeployGate::NotIssueError
8
8
  end
9
9
 
10
10
  class << self
@@ -0,0 +1,4 @@
1
+ module DeployGate
2
+ class NotIssueError < StandardError
3
+ end
4
+ end
@@ -1,6 +1,6 @@
1
1
  module DeployGate
2
2
  class Session
3
- class LoginError < StandardError
3
+ class LoginError < DeployGate::NotIssueError
4
4
  end
5
5
 
6
6
  attr_reader :name, :token
@@ -1,3 +1,3 @@
1
1
  module DeployGate
2
- VERSION = "0.1.2"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -3,9 +3,6 @@ module DeployGate
3
3
  class Analyze
4
4
  attr_reader :workspaces, :scheme_workspace, :build_workspace, :scheme
5
5
 
6
- class NotLocalProvisioningProfileError < StandardError
7
- end
8
-
9
6
  BASE_WORK_DIR_NAME = 'project.xcworkspace'
10
7
  BUILD_CONFIGRATION = 'Release'
11
8
 
@@ -12,17 +12,17 @@ module DeployGate
12
12
  # @param [String] uuid
13
13
  # @return [String]
14
14
  def provisioning_profile(bundle_identifier, uuid = nil)
15
- data = DeployGate::Xcode::Export.find_local_data(bundle_identifier, uuid)
16
- profiles = data[:profiles]
17
- teams = data[:teams]
15
+ local_teams = DeployGate::Xcode::Export.find_local_data(bundle_identifier, uuid)
18
16
 
19
17
  target_provisioning_profile = nil
20
- if teams.empty?
21
- target_provisioning_profile = create_provisioning(bundle_identifier, uuid)
22
- elsif teams.count == 1
23
- target_provisioning_profile = select_profile(profiles[teams.keys.first])
24
- elsif teams.count >= 2
25
- target_provisioning_profile = select_teams(teams, profiles)
18
+ case local_teams.teams_count
19
+ when 0
20
+ target_provisioning_profile = create_provisioning(bundle_identifier, uuid)
21
+ when 1
22
+ target_provisioning_profile = select_profile(local_teams.first_team_profile_paths)
23
+ else
24
+ # when many teams
25
+ target_provisioning_profile = select_teams(local_teams)
26
26
  end
27
27
 
28
28
  target_provisioning_profile
@@ -30,10 +30,10 @@ module DeployGate
30
30
 
31
31
  # @param [String] bundle_identifier
32
32
  # @param [String] uuid
33
- # @return [Hash]
33
+ # @return [LocalTeams]
34
34
  def find_local_data(bundle_identifier, uuid = nil)
35
- result_profiles = {}
36
- teams = {}
35
+ local_teams = LocalTeams.new
36
+
37
37
  profile_paths = load_profile_paths
38
38
  profiles = profile_paths.map{|p| profile_to_plist(p)}
39
39
  profiles.reject! {|profile| profile['UUID'] != uuid} unless uuid.nil?
@@ -41,25 +41,20 @@ module DeployGate
41
41
  profiles.each do |profile|
42
42
  entities = profile['Entitlements']
43
43
  unless entities['get-task-allow']
44
- team = entities['com.apple.developer.team-identifier']
44
+ team_id = entities['com.apple.developer.team-identifier']
45
45
  application_id = entities['application-identifier']
46
- application_id.slice!(/^#{team}\./)
46
+ application_id.slice!(/^#{team_id}\./)
47
47
  application_id = '.' + application_id if application_id == '*'
48
48
  if bundle_identifier.match(application_id) &&
49
49
  DateTime.now < profile['ExpirationDate'] &&
50
50
  installed_certificate?(profile['Path'])
51
51
 
52
- teams[team] = profile['TeamName'] if teams[team].nil?
53
- result_profiles[team] = [] if result_profiles[team].nil?
54
- result_profiles[team].push(profile['Path'])
52
+ local_teams.add(team_id, profile['TeamName'], profile['Path'])
55
53
  end
56
54
  end
57
55
  end
58
56
 
59
- {
60
- :teams => teams,
61
- :profiles => result_profiles
62
- }
57
+ local_teams
63
58
  end
64
59
 
65
60
  # @param [String] profile_path
@@ -226,17 +221,17 @@ module DeployGate
226
221
  select_profile(provisioning_profiles)
227
222
  end
228
223
 
229
- # @param [Hash] teams
230
- # @param [Hash] profiles
224
+ # @param [LocalTeams] local_teams
231
225
  # @return [String]
232
- def select_teams(teams, profiles)
226
+ def select_teams(local_teams)
233
227
  result = nil
234
228
  cli = HighLine.new
235
229
  cli.choose do |menu|
236
230
  menu.prompt = I18n.t('xcode.export.select_teams.prompt')
237
- teams.each_with_index do |team, index|
238
- menu.choice(I18n.t('xcode.export.select_teams.choice', team_id: team[1], team_name: team[0])) {
239
- result = DeployGate::Xcode::Export.select_profile(profiles[team])
231
+ local_teams.teams.each do |team|
232
+ menu.choice(I18n.t('xcode.export.select_teams.choice', team_name: team[:name], team_id: team[:id])) {
233
+ profile_paths = local_teams.profile_paths(team[:id])
234
+ result = DeployGate::Xcode::Export.select_profile(profile_paths)
240
235
  }
241
236
  end
242
237
  end
@@ -4,7 +4,7 @@ module DeployGate
4
4
  WORK_DIR_EXTNAME = '.xcworkspace'
5
5
  PROJECT_DIR_EXTNAME = '.xcodeproj'
6
6
 
7
- class NotSupportExportMethodError < StandardError
7
+ class NotSupportExportMethodError < DeployGate::NotIssueError
8
8
  end
9
9
 
10
10
  class << self
@@ -0,0 +1,60 @@
1
+ module DeployGate
2
+ module Xcode
3
+ class LocalTeams
4
+
5
+ def initialize
6
+ @team_ids = []
7
+ @team_names = []
8
+ @team_profile_paths = {}
9
+ end
10
+
11
+ # @param [String] id
12
+ # @param [String] name
13
+ # @param [String] profile_path
14
+ # @return [void]
15
+ def add(id, name, profile_path)
16
+ unless @team_ids.include?(id)
17
+ @team_ids.push(id)
18
+ @team_names.push(name)
19
+
20
+ @team_profile_paths[id] = []
21
+ end
22
+
23
+ @team_profile_paths[id].push(profile_path) unless @team_profile_paths.include?(profile_path)
24
+ end
25
+
26
+ # @return [Fixnum]
27
+ def teams_count
28
+ @team_ids.count
29
+ end
30
+
31
+ # @return [Array<String>]
32
+ def first_team_profile_paths
33
+ return [] if @team_ids.empty?
34
+ profile_paths(@team_ids.first)
35
+ end
36
+
37
+ # @return [Array<Hash>]
38
+ #
39
+ # [
40
+ # {id: xxxx, name: xxxxx},
41
+ # {id: xxxx, name: xxxxx}
42
+ # ]
43
+ #
44
+ def teams
45
+ teams = []
46
+ @team_ids.each_with_index{|id, index| teams.push({id: id, name: @team_names[index]})}
47
+
48
+ teams
49
+ end
50
+
51
+ # @param [String] id
52
+ # @return [Array<String>]
53
+ def profile_paths(id)
54
+ return [] unless @team_ids.include?(id)
55
+
56
+ @team_profile_paths[id]
57
+ end
58
+ end
59
+ end
60
+ end
@@ -4,6 +4,11 @@ module DeployGate
4
4
  class ProvisioningProfile
5
5
  attr_reader :member_center, :app_identifier
6
6
 
7
+ class NotInstalledCertificateError < DeployGate::NotIssueError
8
+ end
9
+ class NotExistUUIDProvisioningProfileError < DeployGate::NotIssueError
10
+ end
11
+
7
12
  OUTPUT_PATH = '/tmp/dg/provisioning_profile/'
8
13
  CERTIFICATE_OUTPUT_PATH = '/tmp/dg/certificate/'
9
14
 
@@ -45,7 +50,7 @@ module DeployGate
45
50
  File.write(path, raw_data)
46
51
  distribution_cert_ids.push(cert.id) if FastlaneCore::CertChecker.installed?(path)
47
52
  end
48
- raise 'Not local install certificate' if distribution_cert_ids.empty?
53
+ raise NotInstalledCertificateError, I18n.t('xcode.member_center.provisioning_profile.not_installed_certificate_error') if distribution_cert_ids.empty?
49
54
 
50
55
  provisionings = []
51
56
  distribution_cert_ids.each do |cert_id|
@@ -62,7 +67,7 @@ module DeployGate
62
67
  def download(uuid)
63
68
  profiles = Spaceship.provisioning_profile.all.reject!{|p| p.uuid != uuid}
64
69
 
65
- raise 'Not Xcode selected Provisioning Profile' if profiles.empty?
70
+ raise NotExistUUIDProvisioningProfileError, I18n.t('xcode.member_center.provisioning_profile.not_exist_uuid_provisioning_profile_error', uuid: uuid) if profiles.empty?
66
71
  select_profile = profiles.first
67
72
  method = select_profile.kind_of?(Spaceship::Portal::ProvisioningProfile::AdHoc)
68
73
 
data/lib/deploygate.rb CHANGED
@@ -31,6 +31,7 @@ require "xcodeproj"
31
31
  module DeployGate
32
32
  end
33
33
 
34
+ require "deploygate/not_issue_error"
34
35
  require "deploygate/api/v1/base"
35
36
  require "deploygate/api/v1/session"
36
37
  require "deploygate/api/v1/push"
@@ -56,6 +57,7 @@ require "deploygate/xcode/member_center"
56
57
  require "deploygate/xcode/member_centers/app"
57
58
  require "deploygate/xcode/member_centers/provisioning_profile"
58
59
  require "deploygate/xcode/member_centers/device"
60
+ require "deploygate/xcode/local_teams"
59
61
  require "deploygate/xcode/export"
60
62
  require "deploygate/xcode/analyze"
61
63
  require "deploygate/xcode/ios"
@@ -0,0 +1,45 @@
1
+ describe DeployGate::Xcode::LocalTeams do
2
+
3
+ let(:local_teams) { DeployGate::Xcode::LocalTeams.new }
4
+
5
+ context '#add' do
6
+ it 'not count up when add already team id' do
7
+ local_teams.add('1', 'name', 'path')
8
+ local_teams.add('1', 'name', 'path')
9
+
10
+ expect(local_teams.teams_count).to eq 1
11
+ end
12
+
13
+ it 'count up when add team id' do
14
+ local_teams.add('1', 'name', 'path')
15
+ local_teams.add('2', 'name', 'path')
16
+
17
+ expect(local_teams.teams_count).to eq 2
18
+ end
19
+ end
20
+
21
+ context '#profile_paths' do
22
+ before do
23
+ local_teams.add('1', 'name', 'path')
24
+ end
25
+
26
+ it 'should empty not register team id profile_paths' do
27
+ expect(local_teams.profile_paths('not_id').empty?).to be_truthy
28
+ end
29
+
30
+ it 'should not empty registered team id profile_paths' do
31
+ expect(local_teams.profile_paths('1')).to eq ['path']
32
+ end
33
+ end
34
+
35
+ context 'first_team_profile_paths' do
36
+ it 'should return empty not register team' do
37
+ expect(local_teams.first_team_profile_paths.empty?).to be_truthy
38
+ end
39
+
40
+ it 'should return first team profile paths' do
41
+ local_teams.add('1', 'name', 'path')
42
+ expect(local_teams.first_team_profile_paths).to eq ['path']
43
+ end
44
+ end
45
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deploygate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - deploygate
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-06 00:00:00.000000000 Z
11
+ date: 2016-01-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -179,61 +179,61 @@ dependencies:
179
179
  - !ruby/object:Gem::Version
180
180
  version: '0'
181
181
  - !ruby/object:Gem::Dependency
182
- name: gym
182
+ name: locale
183
183
  requirement: !ruby/object:Gem::Requirement
184
184
  requirements:
185
- - - ~>
185
+ - - ! '>='
186
186
  - !ruby/object:Gem::Version
187
- version: 1.0.0
187
+ version: '0'
188
188
  type: :runtime
189
189
  prerelease: false
190
190
  version_requirements: !ruby/object:Gem::Requirement
191
191
  requirements:
192
- - - ~>
192
+ - - ! '>='
193
193
  - !ruby/object:Gem::Version
194
- version: 1.0.0
194
+ version: '0'
195
195
  - !ruby/object:Gem::Dependency
196
- name: spaceship
196
+ name: gym
197
197
  requirement: !ruby/object:Gem::Requirement
198
198
  requirements:
199
199
  - - ~>
200
200
  - !ruby/object:Gem::Version
201
- version: 0.12.3
201
+ version: 1.4.0
202
202
  type: :runtime
203
203
  prerelease: false
204
204
  version_requirements: !ruby/object:Gem::Requirement
205
205
  requirements:
206
206
  - - ~>
207
207
  - !ruby/object:Gem::Version
208
- version: 0.12.3
208
+ version: 1.4.0
209
209
  - !ruby/object:Gem::Dependency
210
- name: sigh
210
+ name: spaceship
211
211
  requirement: !ruby/object:Gem::Requirement
212
212
  requirements:
213
213
  - - ~>
214
214
  - !ruby/object:Gem::Version
215
- version: 1.1.0
215
+ version: 0.19.0
216
216
  type: :runtime
217
217
  prerelease: false
218
218
  version_requirements: !ruby/object:Gem::Requirement
219
219
  requirements:
220
220
  - - ~>
221
221
  - !ruby/object:Gem::Version
222
- version: 1.1.0
222
+ version: 0.19.0
223
223
  - !ruby/object:Gem::Dependency
224
- name: locale
224
+ name: sigh
225
225
  requirement: !ruby/object:Gem::Requirement
226
226
  requirements:
227
- - - ! '>='
227
+ - - ~>
228
228
  - !ruby/object:Gem::Version
229
- version: '0'
229
+ version: 1.2.2
230
230
  type: :runtime
231
231
  prerelease: false
232
232
  version_requirements: !ruby/object:Gem::Requirement
233
233
  requirements:
234
- - - ! '>='
234
+ - - ~>
235
235
  - !ruby/object:Gem::Version
236
- version: '0'
236
+ version: 1.2.2
237
237
  - !ruby/object:Gem::Dependency
238
238
  name: bundler
239
239
  requirement: !ruby/object:Gem::Requirement
@@ -345,6 +345,7 @@ files:
345
345
  - lib/deploygate/config/cache_version.rb
346
346
  - lib/deploygate/config/credential.rb
347
347
  - lib/deploygate/deploy.rb
348
+ - lib/deploygate/not_issue_error.rb
348
349
  - lib/deploygate/project.rb
349
350
  - lib/deploygate/session.rb
350
351
  - lib/deploygate/user.rb
@@ -352,6 +353,7 @@ files:
352
353
  - lib/deploygate/xcode/analyze.rb
353
354
  - lib/deploygate/xcode/export.rb
354
355
  - lib/deploygate/xcode/ios.rb
356
+ - lib/deploygate/xcode/local_teams.rb
355
357
  - lib/deploygate/xcode/member_center.rb
356
358
  - lib/deploygate/xcode/member_centers/app.rb
357
359
  - lib/deploygate/xcode/member_centers/device.rb
@@ -369,6 +371,7 @@ files:
369
371
  - spec/deploygate/xcode/analyze_spec.rb
370
372
  - spec/deploygate/xcode/export_spec.rb
371
373
  - spec/deploygate/xcode/ios_spec.rb
374
+ - spec/deploygate/xcode/local_teams_spec.rb
372
375
  - spec/deploygate/xcode/member_center_spec.rb
373
376
  - spec/deploygate/xcode/member_centers/app_spec.rb
374
377
  - spec/deploygate/xcode/member_centers/provisioning_profile_spec.rb
@@ -412,6 +415,7 @@ test_files:
412
415
  - spec/deploygate/xcode/analyze_spec.rb
413
416
  - spec/deploygate/xcode/export_spec.rb
414
417
  - spec/deploygate/xcode/ios_spec.rb
418
+ - spec/deploygate/xcode/local_teams_spec.rb
415
419
  - spec/deploygate/xcode/member_center_spec.rb
416
420
  - spec/deploygate/xcode/member_centers/app_spec.rb
417
421
  - spec/deploygate/xcode/member_centers/provisioning_profile_spec.rb