pem 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/bin/pem +48 -40
- data/lib/pem/developer_center.rb +49 -26
- data/lib/pem/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: 5113d3a0b7c34285b2ae53df264b7ff74c14d631
|
4
|
+
data.tar.gz: 25849e4e7815c1756c4cc3be3d09269a1199e920
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f385fe1bdfa680067687e8431345d315a5b6df8f67f3a7323551c190d3b15ba1ff4bccc9399e9fc75b303f4b9937a7a21406a2a7034da224327f93f64944a70d
|
7
|
+
data.tar.gz: 8551602780f0c56612f4b76a64e0628215bea5a75078b5f99f6056f13afa44a25890fb2f6ec8f16e5aa5df373094fc3ac3dfeab1a03cab093fc4120aa4e7e3e1
|
data/README.md
CHANGED
@@ -109,7 +109,7 @@ There are 2 actions involved:
|
|
109
109
|
|
110
110
|
|
111
111
|
## How is my password stored?
|
112
|
-
```PEM``` uses the password manager
|
112
|
+
```PEM``` uses the [password manager](https://github.com/KrauseFx/CredentialsManager) from `fastlane`. Take a look the [CredentialsManager README](https://github.com/KrauseFx/CredentialsManager) for more information.
|
113
113
|
|
114
114
|
# Tips
|
115
115
|
|
@@ -129,7 +129,7 @@ It will show you the ```pem``` files like this:
|
|
129
129
|
|
130
130
|
|
131
131
|
# Need help?
|
132
|
-
- If there is a technical problem with ```PEM```, submit an issue.
|
132
|
+
- If there is a technical problem with ```PEM```, submit an issue.
|
133
133
|
- I'm available for contract work - drop me an email: pem@krausefx.com
|
134
134
|
|
135
135
|
# License
|
data/bin/pem
CHANGED
@@ -3,61 +3,69 @@
|
|
3
3
|
$:.push File.expand_path("../../lib", __FILE__)
|
4
4
|
|
5
5
|
require 'pem'
|
6
|
-
require 'commander
|
6
|
+
require 'commander'
|
7
7
|
require 'credentials_manager/password_manager'
|
8
8
|
require 'credentials_manager/appfile_config'
|
9
9
|
|
10
10
|
HighLine.track_eof = false
|
11
11
|
|
12
|
+
class PemApplication
|
13
|
+
include Commander::Methods
|
12
14
|
|
13
|
-
|
14
|
-
program :version, PEM::VERSION
|
15
|
-
program :description, 'CLI for \'PEM\' - Automatically generate and renew your push notification profiles'
|
16
|
-
program :help, 'Author', 'Felix Krause <pem@krausefx.com>'
|
17
|
-
program :help, 'Website', 'http://fastlane.tools'
|
18
|
-
program :help, 'GitHub', 'https://github.com/krausefx/PEM'
|
19
|
-
program :help_formatter, :compact
|
15
|
+
def run
|
16
|
+
program :version, PEM::VERSION
|
17
|
+
program :description, 'CLI for \'PEM\' - Automatically generate and renew your push notification profiles'
|
18
|
+
program :help, 'Author', 'Felix Krause <pem@krausefx.com>'
|
19
|
+
program :help, 'Website', 'http://fastlane.tools'
|
20
|
+
program :help, 'GitHub', 'https://github.com/krausefx/PEM'
|
21
|
+
program :help_formatter, :compact
|
20
22
|
|
21
|
-
|
23
|
+
always_trace!
|
22
24
|
|
25
|
+
global_option '--development', 'Renew the development push certificate instead of the production one'
|
26
|
+
global_option '-u', '--username STRING', 'Your Apple ID username'
|
27
|
+
global_option '-a', '--identifier STRING', String, 'The bundle identifier of your app'
|
23
28
|
|
24
|
-
command :renew do |c|
|
25
|
-
|
26
|
-
|
29
|
+
command :renew do |c|
|
30
|
+
c.syntax = 'pem renew'
|
31
|
+
c.description = 'Renews the certificate (in case it expired) and shows the path to the generated pem file'
|
27
32
|
|
28
|
-
|
29
|
-
|
30
|
-
|
33
|
+
c.action do |args, options|
|
34
|
+
app = app_identifier(options)
|
35
|
+
username(options)
|
31
36
|
|
32
|
-
|
33
|
-
app = app_identifier(options)
|
34
|
-
username(options)
|
37
|
+
path = PEM::CertManager.new.run(app, !options.development)
|
35
38
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
39
|
+
if path
|
40
|
+
file_name = File.basename(path)
|
41
|
+
output = "./#{file_name}"
|
42
|
+
FileUtils.mv(path, output)
|
43
|
+
puts output.green
|
44
|
+
end
|
45
|
+
end
|
43
46
|
end
|
47
|
+
|
48
|
+
default_command :renew
|
49
|
+
|
50
|
+
run!
|
44
51
|
end
|
45
|
-
end
|
46
52
|
|
47
|
-
|
53
|
+
def username(options)
|
54
|
+
user = options.username
|
55
|
+
user ||= ENV["PEM_USERNAME"]
|
56
|
+
user ||= CredentialsManager::AppfileConfig.try_fetch_value(:apple_id)
|
57
|
+
|
58
|
+
CredentialsManager::PasswordManager.shared_manager(user) if user
|
59
|
+
end
|
48
60
|
|
49
|
-
def
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
end
|
61
|
+
def app_identifier(options)
|
62
|
+
value = options.identifier
|
63
|
+
value ||= ENV["PEM_APP_IDENTIFIER"]
|
64
|
+
value ||= CredentialsManager::AppfileConfig.try_fetch_value(:app_identifier)
|
65
|
+
value ||= ask("App Identifier (Bundle ID, e.g. com.krausefx.app): ")
|
66
|
+
return value
|
67
|
+
end
|
56
68
|
|
57
|
-
def app_identifier(options)
|
58
|
-
value = options.identifier
|
59
|
-
value ||= ENV["PEM_APP_IDENTIFIER"]
|
60
|
-
value ||= CredentialsManager::AppfileConfig.try_fetch_value(:app_identifier)
|
61
|
-
value ||= ask("App Identifier (Bundle ID, e.g. com.krausefx.app): ")
|
62
|
-
return value
|
63
69
|
end
|
70
|
+
|
71
|
+
PemApplication.new.run
|
data/lib/pem/developer_center.rb
CHANGED
@@ -68,7 +68,7 @@ module PEM
|
|
68
68
|
user ||= CredentialsManager::PasswordManager.shared_manager.username
|
69
69
|
password ||= CredentialsManager::PasswordManager.shared_manager.password
|
70
70
|
|
71
|
-
result = visit
|
71
|
+
result = visit APP_IDS_URL
|
72
72
|
raise "Could not open Developer Center" unless result['status'] == 'success'
|
73
73
|
|
74
74
|
wait_for_elements(".button.blue").first.click
|
@@ -86,37 +86,17 @@ module PEM
|
|
86
86
|
all(".button.large.blue.signin-button").first.click
|
87
87
|
|
88
88
|
begin
|
89
|
-
if page.has_content?"Select
|
90
|
-
|
91
|
-
unless team_id
|
92
|
-
Helper.log.info "You can store you preferred team using the environment variable `PEM_TEAM_ID`".green
|
93
|
-
Helper.log.info "Your ID belongs to the following teams:".green
|
94
|
-
|
95
|
-
teams = find("select").all('option') # Grab all the teams data
|
96
|
-
teams.each_with_index do |val, index|
|
97
|
-
team_text = val.text
|
98
|
-
description_text = val.value
|
99
|
-
description_text = " (#{description_text})" unless description_text.empty? # Include the team description if any
|
100
|
-
Helper.log.info "\t#{index + 1}. #{team_text}#{description_text}".green # Print the team index and team name
|
101
|
-
end
|
102
|
-
|
103
|
-
team_index = ask("Please select the team number you would like to access: ".green)
|
104
|
-
team_id = teams[team_index.to_i - 1].value # Select the desired team
|
105
|
-
end
|
106
|
-
within 'select' do
|
107
|
-
find("option[value='#{team_id}']").select_option
|
89
|
+
if page.has_content?"Select Team" # If the user is not on multiple teams
|
90
|
+
select_team
|
108
91
|
end
|
109
|
-
|
110
|
-
all("#saveTeamSelection_saveTeamSelection").first.click
|
111
|
-
end
|
112
92
|
rescue => ex
|
113
93
|
Helper.log.debug ex
|
114
94
|
raise DeveloperCenterLoginError.new("Error loggin in user #{user}. User is on multiple teams and we were unable to correctly retrieve them.")
|
115
95
|
end
|
116
96
|
|
117
97
|
begin
|
118
|
-
|
119
|
-
wait_for_elements('
|
98
|
+
visit APP_IDS_URL
|
99
|
+
wait_for_elements('.ios.bundles.gridList')
|
120
100
|
rescue => ex
|
121
101
|
Helper.log.debug ex
|
122
102
|
raise DeveloperCenterLoginError.new("Error logging in user #{user} with the given password. Make sure you entered them correctly.")
|
@@ -130,6 +110,49 @@ module PEM
|
|
130
110
|
end
|
131
111
|
end
|
132
112
|
|
113
|
+
def select_team
|
114
|
+
team_id = ENV["PEM_TEAM_ID"]
|
115
|
+
team_id = nil if team_id.to_s.length == 0
|
116
|
+
|
117
|
+
unless team_id
|
118
|
+
Helper.log.info "You can store you preferred team using the environment variable `PEM_TEAM_ID`".green
|
119
|
+
Helper.log.info "Your ID belongs to the following teams:".green
|
120
|
+
end
|
121
|
+
|
122
|
+
available_options = []
|
123
|
+
|
124
|
+
teams = find("div.input").all('.team-value') # Grab all the teams data
|
125
|
+
teams.each_with_index do |val, index|
|
126
|
+
current_team_id = '"' + val.find("input").value + '"'
|
127
|
+
team_text = val.find(".label-primary").text
|
128
|
+
description_text = val.find(".label-secondary").text
|
129
|
+
description_text = "(#{description_text})" unless description_text.empty? # Include the team description if any
|
130
|
+
index_text = (index + 1).to_s + "."
|
131
|
+
|
132
|
+
available_options << [index_text, current_team_id, team_text, description_text].join(" ")
|
133
|
+
end
|
134
|
+
|
135
|
+
unless team_id
|
136
|
+
puts available_options.join("\n").green
|
137
|
+
team_index = ask("Please select the team number you would like to access: ".green)
|
138
|
+
team_id = teams[team_index.to_i - 1].find(".radio").value
|
139
|
+
end
|
140
|
+
|
141
|
+
team_button = first(:xpath, "//input[@type='radio' and @value='#{team_id}']") # Select the desired team
|
142
|
+
if team_button
|
143
|
+
team_button.click
|
144
|
+
else
|
145
|
+
Helper.log.fatal "Could not find given Team. Available options: ".red
|
146
|
+
puts available_options.join("\n").yellow
|
147
|
+
raise DeveloperCenterLoginError.new("Error finding given team #{team_id}.".red)
|
148
|
+
end
|
149
|
+
|
150
|
+
all(".button.large.blue.submit").first.click
|
151
|
+
|
152
|
+
result = visit APP_IDS_URL
|
153
|
+
raise "Could not open Developer Center" unless result['status'] == 'success'
|
154
|
+
end
|
155
|
+
|
133
156
|
# This method will enable push for the given app
|
134
157
|
# and download the cer file in any case, no matter if it existed before or not
|
135
158
|
# @return the path to the push file
|
@@ -160,6 +183,7 @@ module PEM
|
|
160
183
|
def open_app_page(app_identifier)
|
161
184
|
begin
|
162
185
|
visit APP_IDS_URL
|
186
|
+
sleep 5
|
163
187
|
|
164
188
|
apps = all(:xpath, "//td[@title='#{app_identifier}']")
|
165
189
|
if apps.count == 1
|
@@ -264,7 +288,6 @@ module PEM
|
|
264
288
|
|
265
289
|
counter += 1
|
266
290
|
if counter > 100
|
267
|
-
Helper.log.debug page.html
|
268
291
|
Helper.log.debug caller
|
269
292
|
raise DeveloperCenterGeneralError.new("Couldn't find element '#{name}' after waiting for quite some time")
|
270
293
|
end
|
data/lib/pem/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pem
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Felix Krause
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-01-
|
11
|
+
date: 2015-01-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|