cert 0.1.1 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -0
- data/bin/cert +4 -19
- data/lib/cert.rb +5 -0
- data/lib/cert/cert_runner.rb +5 -2
- data/lib/cert/developer_center.rb +12 -11
- data/lib/cert/keychain_importer.rb +1 -1
- data/lib/cert/options.rb +38 -0
- data/lib/cert/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6259690b66a7e4c593ec0791ea5bb3c0942454e2
|
4
|
+
data.tar.gz: 30cd02aade4ab49c87a0bc9d8ac2f14eb7996adc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 20cb4cdb1b72596db16faca9bce5d3fa6fe0e24ade05d5a59e6efb707bdc98ac2b1ced4fd171e79f1c58b646c2082a69f275f8669ca29815a113cedd8a05b0f5
|
7
|
+
data.tar.gz: 94ab37d8f4216f5591b37675eae649239b035f2f15f83a0a6f701cdf55db24631cc96c2cc0ab3dfcfda2c00bab56b9c2d45f5d9fa8f97676c8380a99a905ddc4
|
data/README.md
CHANGED
@@ -90,6 +90,9 @@ You can pass your Apple ID:
|
|
90
90
|
|
91
91
|
cert -u cert@krausefx.com
|
92
92
|
|
93
|
+
For a list of available commands run
|
94
|
+
|
95
|
+
cert --help
|
93
96
|
|
94
97
|
## Environment Variables
|
95
98
|
In case you prefer environment variables:
|
@@ -97,6 +100,7 @@ In case you prefer environment variables:
|
|
97
100
|
- ```CERT_USERNAME```
|
98
101
|
- ```CERT_TEAM_ID```
|
99
102
|
- ```CERT_KEYCHAIN_PATH``` The path to a specific Keychain if you don't want to use the default one
|
103
|
+
- ```FASTLANE_TEAM_NAME``` (the Team Name, e.g. `Felix Krause`)
|
100
104
|
|
101
105
|
## Use with [`sigh`](https://github.com/KrauseFx/sigh)
|
102
106
|
|
data/bin/cert
CHANGED
@@ -6,6 +6,7 @@ require 'cert'
|
|
6
6
|
require 'commander'
|
7
7
|
require 'credentials_manager/password_manager'
|
8
8
|
require 'credentials_manager/appfile_config'
|
9
|
+
require 'cert/options'
|
9
10
|
|
10
11
|
HighLine.track_eof = false
|
11
12
|
|
@@ -22,34 +23,18 @@ class CertApplication
|
|
22
23
|
|
23
24
|
always_trace!
|
24
25
|
|
25
|
-
|
26
|
-
global_option '--development', 'Create a development certificate instead of a distribution one.'
|
26
|
+
FastlaneCore::CommanderGenerator.new.generate(Cert::Options.available_options)
|
27
27
|
|
28
28
|
command :create do |c|
|
29
29
|
c.syntax = 'cert create'
|
30
30
|
c.description = 'Create new iOS code signing certificates'
|
31
31
|
|
32
32
|
c.action do |args, options|
|
33
|
-
|
34
|
-
|
35
|
-
type = Cert::DeveloperCenter::DISTRIBUTION
|
36
|
-
type = Cert::DeveloperCenter::DEVELOPMENT if options.development
|
37
|
-
|
38
|
-
Cert::CertRunner.run(type)
|
39
|
-
|
40
|
-
installed = Cert::CertChecker.is_installed?ENV["CER_FILE_PATH"]
|
41
|
-
raise "Could not find the newly generated certificate installed" unless installed
|
33
|
+
Cert.config = FastlaneCore::Configuration.create(Cert::Options.available_options, options.__hash__)
|
34
|
+
Cert::CertRunner.run
|
42
35
|
end
|
43
36
|
end
|
44
37
|
|
45
|
-
def username(options)
|
46
|
-
user = options.username
|
47
|
-
user ||= ENV["CERT_USERNAME"]
|
48
|
-
user ||= CredentialsManager::AppfileConfig.try_fetch_value(:apple_id)
|
49
|
-
|
50
|
-
CredentialsManager::PasswordManager.shared_manager(user) if user
|
51
|
-
end
|
52
|
-
|
53
38
|
default_command :create
|
54
39
|
|
55
40
|
run!
|
data/lib/cert.rb
CHANGED
@@ -9,6 +9,11 @@ require 'cert/keychain_importer'
|
|
9
9
|
require 'fastlane_core'
|
10
10
|
|
11
11
|
module Cert
|
12
|
+
# Use this to just setup the configuration attribute and set it later somewhere else
|
13
|
+
class << self
|
14
|
+
attr_accessor :config
|
15
|
+
end
|
16
|
+
|
12
17
|
TMP_FOLDER = "/tmp/cert/"
|
13
18
|
FileUtils.mkdir_p TMP_FOLDER
|
14
19
|
|
data/lib/cert/cert_runner.rb
CHANGED
@@ -1,7 +1,10 @@
|
|
1
1
|
module Cert
|
2
2
|
class CertRunner
|
3
|
-
def self.run
|
4
|
-
Cert::DeveloperCenter.new.run
|
3
|
+
def self.run
|
4
|
+
Cert::DeveloperCenter.new.run
|
5
|
+
|
6
|
+
installed = Cert::CertChecker.is_installed?ENV["CER_FILE_PATH"]
|
7
|
+
raise "Could not find the newly generated certificate installed" unless installed
|
5
8
|
end
|
6
9
|
end
|
7
10
|
end
|
@@ -11,27 +11,28 @@ module Cert
|
|
11
11
|
|
12
12
|
# This will check if there is at least one of the certificates already installed on the local machine
|
13
13
|
# This will store the resulting file name in ENV 'CER_FILE_PATH' and the Cert ID in 'CER_CERTIFICATE_ID'
|
14
|
-
def run
|
15
|
-
|
14
|
+
def run
|
15
|
+
@type = (Cert.config[:development] ? DEVELOPMENT : DISTRIBUTION)
|
16
|
+
file = find_existing_cert
|
16
17
|
if file
|
17
18
|
# We don't need to do anything :)
|
18
19
|
ENV["CER_FILE_PATH"] = file
|
19
20
|
else
|
20
|
-
create_certificate
|
21
|
+
create_certificate
|
21
22
|
end
|
22
23
|
rescue => ex
|
23
24
|
error_occured(ex)
|
24
25
|
end
|
25
26
|
|
26
|
-
def find_existing_cert
|
27
|
-
if type == DEVELOPMENT
|
27
|
+
def find_existing_cert
|
28
|
+
if @type == DEVELOPMENT
|
28
29
|
visit CERTS_URL_DEV
|
29
30
|
else
|
30
31
|
visit CERTS_URL
|
31
32
|
end
|
32
33
|
|
33
34
|
# Download all available certs to check if they are installed using the SHA1 hash
|
34
|
-
certs = code_signing_certificate
|
35
|
+
certs = code_signing_certificate
|
35
36
|
certs.each do |current|
|
36
37
|
display_id = current['certificateId']
|
37
38
|
type_id = current['certificateTypeDisplayId']
|
@@ -54,7 +55,7 @@ module Cert
|
|
54
55
|
end
|
55
56
|
|
56
57
|
# This will actually create a new certificate
|
57
|
-
def create_certificate
|
58
|
+
def create_certificate
|
58
59
|
visit CREATE_CERT_URL
|
59
60
|
wait_for_elements("form[name='certificateSave']")
|
60
61
|
|
@@ -62,7 +63,7 @@ module Cert
|
|
62
63
|
|
63
64
|
# select certificate type
|
64
65
|
toggle_value = 'type-iosNoOCSP'
|
65
|
-
toggle_value = 'type-development' if type == DEVELOPMENT
|
66
|
+
toggle_value = 'type-development' if @type == DEVELOPMENT
|
66
67
|
app_store_toggle = first("input##{toggle_value}")
|
67
68
|
if !!app_store_toggle['disabled']
|
68
69
|
# Limit of certificates already reached
|
@@ -150,8 +151,8 @@ module Cert
|
|
150
151
|
# "certificateTypeDisplayId"=>"...",
|
151
152
|
# "serialNum"=>"....",
|
152
153
|
# "typeString"=>"iOS Distribution"},
|
153
|
-
def code_signing_certificate
|
154
|
-
if type == DEVELOPMENT
|
154
|
+
def code_signing_certificate
|
155
|
+
if @type == DEVELOPMENT
|
155
156
|
visit CERTS_URL_DEV
|
156
157
|
else
|
157
158
|
visit CERTS_URL
|
@@ -168,7 +169,7 @@ module Cert
|
|
168
169
|
available = []
|
169
170
|
|
170
171
|
certTypeName = 'iOS Distribution'
|
171
|
-
certTypeName = 'iOS Development' if type == DEVELOPMENT
|
172
|
+
certTypeName = 'iOS Development' if @type == DEVELOPMENT
|
172
173
|
certs = post_ajax(url)['certRequests']
|
173
174
|
certs.each do |current_cert|
|
174
175
|
if current_cert['typeString'] == certTypeName
|
@@ -2,7 +2,7 @@ module Cert
|
|
2
2
|
class KeychainImporter
|
3
3
|
def self.import_file(path)
|
4
4
|
raise "Could not find file '#{path}'".red unless File.exists?(path)
|
5
|
-
keychain =
|
5
|
+
keychain = Cert.config[:keychain_path] || "#{Dir.home}/Library/Keychains/login.keychain"
|
6
6
|
|
7
7
|
puts `security import '#{path}' -k '#{keychain}'`
|
8
8
|
end
|
data/lib/cert/options.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'fastlane_core'
|
2
|
+
|
3
|
+
module Cert
|
4
|
+
class Options
|
5
|
+
def self.available_options
|
6
|
+
@@options ||= [
|
7
|
+
FastlaneCore::ConfigItem.new(key: :development,
|
8
|
+
env_name: "CERT_DEVELOPMENT",
|
9
|
+
description: "Create a development certificate instead of a distribution one",
|
10
|
+
is_string: false),
|
11
|
+
FastlaneCore::ConfigItem.new(key: :username,
|
12
|
+
short_option: "-u",
|
13
|
+
env_name: "CERT_USERNAME",
|
14
|
+
description: "Your Apple ID Username",
|
15
|
+
default_value: CredentialsManager::AppfileConfig.try_fetch_value(:apple_id),
|
16
|
+
verify_block: Proc.new do |value|
|
17
|
+
CredentialsManager::PasswordManager.shared_manager(value)
|
18
|
+
end),
|
19
|
+
FastlaneCore::ConfigItem.new(key: :team_id,
|
20
|
+
short_option: "-t",
|
21
|
+
env_name: "CERT_TEAM_ID",
|
22
|
+
description: "The ID of your team if you're in multiple teams",
|
23
|
+
optional: true,
|
24
|
+
verify_block: Proc.new do |value|
|
25
|
+
ENV["FASTLANE_TEAM_ID"] = value
|
26
|
+
end),
|
27
|
+
FastlaneCore::ConfigItem.new(key: :keychain_path,
|
28
|
+
short_option: "-k",
|
29
|
+
env_name: "CERT_KEYCHAIN_PATH",
|
30
|
+
description: "Path to a custom keychain",
|
31
|
+
optional: true,
|
32
|
+
verify_block: Proc.new do |value|
|
33
|
+
raise "Keychain not found at path '#{value}'".red unless File.exists?value
|
34
|
+
end)
|
35
|
+
]
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/lib/cert/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cert
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
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-03-
|
11
|
+
date: 2015-03-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fastlane_core
|
@@ -139,6 +139,7 @@ files:
|
|
139
139
|
- lib/cert/dependency_checker.rb
|
140
140
|
- lib/cert/developer_center.rb
|
141
141
|
- lib/cert/keychain_importer.rb
|
142
|
+
- lib/cert/options.rb
|
142
143
|
- lib/cert/signing_request.rb
|
143
144
|
- lib/cert/version.rb
|
144
145
|
homepage: https://fastlane.tools
|