Skip to content
This repository has been archived by the owner on Nov 19, 2018. It is now read-only.

Commit

Permalink
Merge pull request #86 from fastlane/feature/new-ui
Browse files Browse the repository at this point in the history
Upgraded PEM to the new UI layer
  • Loading branch information
KrauseFx committed Feb 4, 2016
2 parents 359daff + 38c744a commit b283572
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
25 changes: 12 additions & 13 deletions lib/pem/manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ def start

if existing_certificate
remaining_days = (existing_certificate.expires - Time.now) / 60 / 60 / 24
Helper.log.info "Existing push notification profile '#{existing_certificate.owner_name}' is valid for #{remaining_days.round} more days."
UI.message "Existing push notification profile '#{existing_certificate.owner_name}' is valid for #{remaining_days.round} more days."
if remaining_days > 30
if PEM.config[:force]
Helper.log.info "You already have an existing push certificate, but a new one will be created since the --force option has been set.".green
UI.success "You already have an existing push certificate, but a new one will be created since the --force option has been set."
else
Helper.log.info "You already have a push certificate, which is active for more than 30 more days. No need to create a new one".green
Helper.log.info "If you still want to create a new one, use the --force option when running PEM.".green
UI.success "You already have a push certificate, which is active for more than 30 more days. No need to create a new one"
UI.success "If you still want to create a new one, use the --force option when running PEM."
return false
end
end
Expand All @@ -31,15 +31,15 @@ def start
end

def login
Helper.log.info "Starting login with user '#{PEM.config[:username]}'"
UI.message "Starting login with user '#{PEM.config[:username]}'"
Spaceship.login(PEM.config[:username], nil)
Spaceship.client.select_team
Helper.log.info "Successfully logged in"
UI.message "Successfully logged in"
end

# rubocop:disable Metrics/AbcSize
def create_certificate
Helper.log.warn "Creating a new push certificate for app '#{PEM.config[:app_identifier]}'."
UI.important "Creating a new push certificate for app '#{PEM.config[:app_identifier]}'."

csr, pkey = Spaceship.certificate.create_certificate_signing_request

Expand All @@ -48,9 +48,8 @@ def create_certificate
rescue => ex
if ex.to_s.include? "You already have a current"
# That's the most common failure probably
Helper.log.info ex.to_s
Helper.log.error "You already have 2 active push profiles for this application/environment.".red
Helper.log.error "You'll need to revoke an old certificate to make room for a new one".red
UI.message ex.to_s
UI.user_error!("You already have 2 active push profiles for this application/environment. You'll need to revoke an old certificate to make room for a new one")
else
raise ex
end
Expand All @@ -64,7 +63,7 @@ def create_certificate
if PEM.config[:save_private_key]
private_key_path = File.join(PEM.config[:output_path], "#{filename_base}.pkey")
File.write(private_key_path, pkey.to_pem)
Helper.log.info "Private key: ".green + Pathname.new(private_key_path).realpath.to_s
UI.message("Private key: ".green + Pathname.new(private_key_path).realpath.to_s)
end

if PEM.config[:generate_p12]
Expand All @@ -73,12 +72,12 @@ def create_certificate
p12_cert_path = File.join(output_path, "#{filename_base}.p12")
p12 = OpenSSL::PKCS12.create(PEM.config[:p12_password], certificate_type, pkey, x509_certificate)
File.write(p12_cert_path, p12.to_der)
Helper.log.info "p12 certificate: ".green + Pathname.new(p12_cert_path).realpath.to_s
UI.message("p12 certificate: ".green + Pathname.new(p12_cert_path).realpath.to_s)
end

x509_cert_path = File.join(PEM.config[:output_path], "#{filename_base}.pem")
File.write(x509_cert_path, x509_certificate.to_pem + pkey.to_pem)
Helper.log.info "PEM: ".green + Pathname.new(x509_cert_path).realpath.to_s
UI.message("PEM: ".green + Pathname.new(x509_cert_path).realpath.to_s)
return x509_cert_path
end
# rubocop:enable Metrics/AbcSize
Expand Down
4 changes: 2 additions & 2 deletions pem.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ Gem::Specification.new do |spec|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ["lib"]

spec.add_dependency 'fastlane_core', '>= 0.30.0', '< 1.0.0' # all shared code and dependencies
spec.add_dependency 'spaceship', '>= 0.18.1', '< 1.0.0' # Communicating with the Apple Dev Portal
spec.add_dependency 'fastlane_core', '>= 0.36.1', '< 1.0.0' # all shared code and dependencies
spec.add_dependency 'spaceship', '>= 0.19.3', '< 1.0.0' # Communicating with the Apple Dev Portal

# Development only
spec.add_development_dependency 'bundler'
Expand Down

0 comments on commit b283572

Please sign in to comment.