Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Adding listing of certificates

Added distinction between development and distribution for profiles and certificates
  • Loading branch information...
commit 77adfc46b61819cb4008201610088abd3b820489 1 parent 916dac2
@mattt mattt authored
View
28 lib/cupertino/provisioning_portal/agent.rb
@@ -25,6 +25,30 @@ def get(uri, parameters = [], referer = nil, headers = {})
end
end
+ def list_certificates(type = :development)
+ url = case type
+ when :development
+ "https://developer.apple.com/ios/manage/certificates/team/index.action"
+ when :distribution
+ "https://developer.apple.com/ios/manage/certificates/team/distribute.action"
+ else
+ raise ArgumentError, "Certificate type must be :development or :distribution"
+ end
+
+ get(url)
+
+ certificates = []
+ page.parser.xpath('//div[@class="nt_multi"]/table/tbody/tr').each do |row|
+ certificate = Certificate.new
+ certificate.name = row.at_xpath('td[@class="name"]//p/text()').to_s.strip rescue nil
+ certificate.provisioning_profiles = row.at_xpath('td[@class="profiles"]/text()').to_s.strip.split(/\n+/) rescue []
+ certificate.expiration_date = row.at_xpath('td[@class="date"]/text()').to_s.strip rescue nil
+ certificate.status = row.at_xpath('td[@class="status"]/text()').to_s.strip rescue nil
+ certificates << certificate
+ end
+ certificates
+ end
+
def list_devices
get("https://developer.apple.com/ios/manage/devices/index.action")
@@ -61,7 +85,7 @@ def add_devices(*devices)
end
end
- def list_profiles(type = :development)
+ def list_profiles(type = :development)
url = case type
when :development
"https://developer.apple.com/ios/manage/provisioningprofiles/index.action"
@@ -70,7 +94,7 @@ def list_profiles(type = :development)
else
raise ArgumentError, "Provisioning profile type must be :development or :distribution"
end
-
+
get(url)
profiles = []
View
1  lib/cupertino/provisioning_portal/commands.rb
@@ -3,5 +3,6 @@
$:.push File.expand_path('../', __FILE__)
+require 'commands/certificates'
require 'commands/devices'
require 'commands/profiles'
View
32 lib/cupertino/provisioning_portal/commands/certificates.rb
@@ -0,0 +1,32 @@
+command :'certificates:list' do |c|
+ c.syntax = 'ios certificates:list [development|distribution]'
+ c.summary = 'Lists the Certificates'
+ c.description = ''
+
+ c.action do |args, options|
+ type = args.first.downcase.to_sym rescue nil
+ certificates = agent.list_certificates(type ||= :development)
+
+ say_warning "No #{type} certificates found." and abort if certificates.empty?
+ Struct.new(:name, :provisioning_profiles, :expiration_date, :status)
+
+ table = Terminal::Table.new do |t|
+ t << ["Name", "Provisioning Profiles", "Expiration Date", "Status"]
+ t.add_separator
+ certificates.each do |certificate|
+ status = case certificate.status
+ when "Issued"
+ certificate.status.green
+ else
+ certificate.status.red
+ end
+
+ t << [certificate.name, certificate.provisioning_profiles.join("\n"), certificate.expiration_date, status]
+ end
+ end
+
+ puts table
+ end
+end
+
+alias_command :certificates, :'certificates:list'
View
9 lib/cupertino/provisioning_portal/commands/profiles.rb
@@ -1,10 +1,13 @@
command :'profiles:list' do |c|
- c.syntax = 'ios profiles:list'
- c.summary = 'Lists the Provisioning Profiles in the Provisioning Portal'
+ c.syntax = 'ios profiles:list [development|distribution]'
+ c.summary = 'Lists the Provisioning Profiles'
c.description = ''
c.action do |args, options|
- profiles = agent.list_profiles
+ type = args.first.downcase.to_sym rescue nil
+ profiles = agent.list_profiles(type ||= :development)
+
+ say_warning "No #{type} provisioning profiles found." and abort if profiles.empty?
table = Terminal::Table.new do |t|
t << ["Profile", "App ID", "Status"]
Please sign in to comment.
Something went wrong with that request. Please try again.