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

Commit

Permalink
Added new sigh repair command
Browse files Browse the repository at this point in the history
  • Loading branch information
KrauseFx committed Jun 15, 2015
1 parent 8c67a33 commit f1e8861
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
11 changes: 11 additions & 0 deletions bin/sigh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,17 @@ class SighApplication
end
end

command :repair do |c|
c.syntax = 'sigh repair'
c.description = 'Repairs all expired or invalid provisioning profiles'

c.action do |args, options|
Sigh.config = FastlaneCore::Configuration.create(Sigh::Options.available_options, options.__hash__)
require 'sigh/repair'
Sigh::Repair.new.repair_all
end
end

command :resign do |c|
c.syntax = 'sigh resign'
c.description = 'Resigns an existing ipa file with the given provisioning profile'
Expand Down
30 changes: 30 additions & 0 deletions lib/sigh/repair.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
module Sigh
class Repair
def repair_all
Helper.log.info "Starting login"
Spaceship.login(Sigh.config[:username], nil)
Spaceship.select_team
Helper.log.info "Successfully logged in"

# Select all 'Invalid' or 'Expired' provisioning profiles
broken_profiles = Spaceship.provisioning_profile.all.find_all do |profile|
(profile.status == "Invalid" or profile.status == "Expired")
end

if broken_profiles.count == 0
Helper.log.info "All provisioning profiles are valid, nothing to do".green
return
end

Helper.log.info "Going to repair #{broken_profiles.count} provisioning profiles".green

# Iterate over all broken profiles and repair them
broken_profiles.each do |profile|
Helper.log.info "Repairing profile '#{profile.name}'..."
profile.repair! # yes, that's all you need to repair a profile
end

Helper.log.info "Successfully repaired #{broken_profiles.count} provisioning profiles".green
end
end
end

0 comments on commit f1e8861

Please sign in to comment.