From 38c744a34a75df1ad1bb64d0486c8451a8aa3f9f Mon Sep 17 00:00:00 2001 From: KrauseFx Date: Thu, 4 Feb 2016 07:45:05 -0800 Subject: [PATCH] Upgraded PEM to the new UI layer --- lib/pem/manager.rb | 25 ++++++++++++------------- pem.gemspec | 4 ++-- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/lib/pem/manager.rb b/lib/pem/manager.rb index cc656a3..ae3cbb5 100644 --- a/lib/pem/manager.rb +++ b/lib/pem/manager.rb @@ -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 @@ -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 @@ -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 @@ -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] @@ -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 diff --git a/pem.gemspec b/pem.gemspec index a4217fd..abe4069 100644 --- a/pem.gemspec +++ b/pem.gemspec @@ -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'