diff --git a/bin/sigh b/bin/sigh index fc733ab..50eb6ab 100755 --- a/bin/sigh +++ b/bin/sigh @@ -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' diff --git a/lib/sigh/repair.rb b/lib/sigh/repair.rb new file mode 100644 index 0000000..6c7601f --- /dev/null +++ b/lib/sigh/repair.rb @@ -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 \ No newline at end of file