adsedare 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/lib/adsedare/export_options.rb +5 -2
 - data/lib/adsedare/install_profiles.rb +76 -0
 - data/lib/adsedare/version.rb +1 -1
 - data/lib/adsedare.rb +1 -67
 - metadata +2 -1
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 4ecc75a51b623a2c9319dee4fb2ed9f276ec02789876663375bc73dc3abd7bae
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 6715ec7cf9f373608e442ba4916a097b1094efee050a05639fe14dfaf1c0dead
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 1251ab137c4071f94587385a0211273f71e93652d3714f7da8ac20a87df8caf5e55d8003a1b6a419b7ac33f9dccae7e89f1d6e71ae8bde1f7a7512c7dc171229
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 5cbb5c9c206799a6a7d70923e42494ef4ba9deb8ede37afc4fe5a8a6e8ed94847d7587a76afbc64aa7a4a547aab9a81e49cb04ef91e85c20fe3d1cb940307682
         
     | 
| 
         @@ -9,6 +9,8 @@ module Adsedare 
     | 
|
| 
       9 
9 
     | 
    
         
             
                  raise "Project path is not set" unless project_path
         
     | 
| 
       10 
10 
     | 
    
         
             
                  raise "Export path is not set" unless export_path
         
     | 
| 
       11 
11 
     | 
    
         | 
| 
      
 12 
     | 
    
         
            +
                  logger.info "Creating export options for project'"
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
       12 
14 
     | 
    
         
             
                  project = Xcodeproj::Project.open(project_path)
         
     | 
| 
       13 
15 
     | 
    
         
             
                  export_options = {
         
     | 
| 
       14 
16 
     | 
    
         
             
                    "method" => "ad-hoc",
         
     | 
| 
         @@ -82,9 +84,10 @@ module Adsedare 
     | 
|
| 
       82 
84 
     | 
    
         
             
                  end
         
     | 
| 
       83 
85 
     | 
    
         | 
| 
       84 
86 
     | 
    
         
             
                  options_plist = Plist::Emit.dump(export_options)
         
     | 
| 
       85 
     | 
    
         
            -
                  File. 
     | 
| 
      
 87 
     | 
    
         
            +
                  export_path = File.expand_path(export_path)
         
     | 
| 
      
 88 
     | 
    
         
            +
                  File.write(export_path, options_plist)
         
     | 
| 
       86 
89 
     | 
    
         | 
| 
       87 
     | 
    
         
            -
                   
     | 
| 
      
 90 
     | 
    
         
            +
                  logger.info "Export options created at '#{export_path}'"
         
     | 
| 
       88 
91 
     | 
    
         
             
                end
         
     | 
| 
       89 
92 
     | 
    
         
             
              end
         
     | 
| 
       90 
93 
     | 
    
         
             
            end
         
     | 
| 
         @@ -0,0 +1,76 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require "xcodeproj"
         
     | 
| 
      
 2 
     | 
    
         
            +
            require "base64"
         
     | 
| 
      
 3 
     | 
    
         
            +
            require "fileutils"
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            require_relative "../appstoreconnect"
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            module Adsedare
         
     | 
| 
      
 8 
     | 
    
         
            +
              class << self
         
     | 
| 
      
 9 
     | 
    
         
            +
                def install_profiles(project_path = nil)
         
     | 
| 
      
 10 
     | 
    
         
            +
                  raise "Project path is not set" unless project_path
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                  project = Xcodeproj::Project.open(project_path)
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
                  project_bundles = project.targets.map do |target|
         
     | 
| 
      
 15 
     | 
    
         
            +
                    target.build_configurations.map do |config|
         
     | 
| 
      
 16 
     | 
    
         
            +
                      config.build_settings["PRODUCT_BUNDLE_IDENTIFIER"]
         
     | 
| 
      
 17 
     | 
    
         
            +
                    end
         
     | 
| 
      
 18 
     | 
    
         
            +
                  end.flatten.uniq
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
                  bundles_with_profiles = AppStoreConnect::Client.get_bundles_with_profiles(project_bundles)
         
     | 
| 
      
 21 
     | 
    
         
            +
                  bundle_by_identifier = {}
         
     | 
| 
      
 22 
     | 
    
         
            +
                  profiles_by_id = {}
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                  bundles_with_profiles["data"].each do |bundle_id|
         
     | 
| 
      
 25 
     | 
    
         
            +
                    bundle_by_identifier[bundle_id["attributes"]["identifier"]] = bundle_id
         
     | 
| 
      
 26 
     | 
    
         
            +
                  end
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
                  bundles_with_profiles["included"].each do |profile|
         
     | 
| 
      
 29 
     | 
    
         
            +
                    profiles_by_id[profile["id"]] = profile
         
     | 
| 
      
 30 
     | 
    
         
            +
                  end
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
                  project_bundles.each do |bundle_identifier|
         
     | 
| 
      
 33 
     | 
    
         
            +
                    bundle_id = bundle_by_identifier[bundle_identifier]
         
     | 
| 
      
 34 
     | 
    
         
            +
                    unless bundle_id
         
     | 
| 
      
 35 
     | 
    
         
            +
                      logger.warn "Bundle '#{bundle_identifier}' is missing in App Store Connect. Skipping."
         
     | 
| 
      
 36 
     | 
    
         
            +
                      next
         
     | 
| 
      
 37 
     | 
    
         
            +
                    end
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
                    logger.info "Bundle '#{bundle_identifier}' resolved to Bundle ID '#{bundle_id["id"]}'"
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
                    profiles = bundle_id["relationships"]["profiles"]["data"]
         
     | 
| 
      
 42 
     | 
    
         
            +
                    unless profiles
         
     | 
| 
      
 43 
     | 
    
         
            +
                      logger.warn "Profile for Bundle ID '#{bundle_id["id"]}' is missing in App Store Connect. Skipping."
         
     | 
| 
      
 44 
     | 
    
         
            +
                      next
         
     | 
| 
      
 45 
     | 
    
         
            +
                    end
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
                    ad_hoc_profile = nil
         
     | 
| 
      
 48 
     | 
    
         
            +
                    profiles.each do |profile|
         
     | 
| 
      
 49 
     | 
    
         
            +
                      profile_id = profile["id"]
         
     | 
| 
      
 50 
     | 
    
         
            +
                      profile = profiles_by_id[profile_id]
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
                      if profile["attributes"]["profileType"] == "IOS_APP_ADHOC" && profile["attributes"]["profileState"] == "ACTIVE"
         
     | 
| 
      
 53 
     | 
    
         
            +
                        ad_hoc_profile = profile
         
     | 
| 
      
 54 
     | 
    
         
            +
                        break
         
     | 
| 
      
 55 
     | 
    
         
            +
                      end
         
     | 
| 
      
 56 
     | 
    
         
            +
                    end
         
     | 
| 
      
 57 
     | 
    
         
            +
             
     | 
| 
      
 58 
     | 
    
         
            +
                    unless ad_hoc_profile
         
     | 
| 
      
 59 
     | 
    
         
            +
                      logger.warn "Profile for Bundle ID '#{bundle_id["id"]}' is missing in App Store Connect. Skipping."
         
     | 
| 
      
 60 
     | 
    
         
            +
                      next
         
     | 
| 
      
 61 
     | 
    
         
            +
                    end
         
     | 
| 
      
 62 
     | 
    
         
            +
             
     | 
| 
      
 63 
     | 
    
         
            +
                    logger.info "Profile for Bundle ID '#{bundle_id["id"]}' resolved to Profile '#{ad_hoc_profile["attributes"]["name"]}'"
         
     | 
| 
      
 64 
     | 
    
         
            +
             
     | 
| 
      
 65 
     | 
    
         
            +
                    uuid = ad_hoc_profile["attributes"]["uuid"]
         
     | 
| 
      
 66 
     | 
    
         
            +
                    profile_content = Base64.decode64(ad_hoc_profile["attributes"]["profileContent"])
         
     | 
| 
      
 67 
     | 
    
         
            +
                    profile_path = "#{Dir.home}/Library/MobileDevice/Provisioning Profiles/#{uuid}.mobileprovision"
         
     | 
| 
      
 68 
     | 
    
         
            +
             
     | 
| 
      
 69 
     | 
    
         
            +
                    FileUtils.mkdir_p(File.dirname(profile_path))
         
     | 
| 
      
 70 
     | 
    
         
            +
                    File.write(profile_path, profile_content)
         
     | 
| 
      
 71 
     | 
    
         
            +
             
     | 
| 
      
 72 
     | 
    
         
            +
                    logger.info "Profile '#{ad_hoc_profile["attributes"]["name"]}' installed to '#{profile_path}'"
         
     | 
| 
      
 73 
     | 
    
         
            +
                  end
         
     | 
| 
      
 74 
     | 
    
         
            +
                end
         
     | 
| 
      
 75 
     | 
    
         
            +
              end
         
     | 
| 
      
 76 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/adsedare/version.rb
    CHANGED
    
    
    
        data/lib/adsedare.rb
    CHANGED
    
    | 
         @@ -11,6 +11,7 @@ require_relative "adsedare/capabilities" 
     | 
|
| 
       11 
11 
     | 
    
         
             
            require_relative "adsedare/keychain"
         
     | 
| 
       12 
12 
     | 
    
         
             
            require_relative "adsedare/xcodeproj"
         
     | 
| 
       13 
13 
     | 
    
         
             
            require_relative "adsedare/export_options"
         
     | 
| 
      
 14 
     | 
    
         
            +
            require_relative "adsedare/install_profiles"
         
     | 
| 
       14 
15 
     | 
    
         | 
| 
       15 
16 
     | 
    
         
             
            require_relative "logging"
         
     | 
| 
       16 
17 
     | 
    
         
             
            require_relative "starship"
         
     | 
| 
         @@ -89,73 +90,6 @@ module Adsedare 
     | 
|
| 
       89 
90 
     | 
    
         
             
                  end
         
     | 
| 
       90 
91 
     | 
    
         
             
                end
         
     | 
| 
       91 
92 
     | 
    
         | 
| 
       92 
     | 
    
         
            -
                def install_profiles(project_path = nil)
         
     | 
| 
       93 
     | 
    
         
            -
                  raise "Project path is not set" unless project_path
         
     | 
| 
       94 
     | 
    
         
            -
             
     | 
| 
       95 
     | 
    
         
            -
                  project = Xcodeproj::Project.open(project_path)
         
     | 
| 
       96 
     | 
    
         
            -
             
     | 
| 
       97 
     | 
    
         
            -
                  project_bundles = project.targets.map do |target|
         
     | 
| 
       98 
     | 
    
         
            -
                    target.build_configurations.map do |config|
         
     | 
| 
       99 
     | 
    
         
            -
                      config.build_settings["PRODUCT_BUNDLE_IDENTIFIER"]
         
     | 
| 
       100 
     | 
    
         
            -
                    end
         
     | 
| 
       101 
     | 
    
         
            -
                  end.flatten.uniq
         
     | 
| 
       102 
     | 
    
         
            -
             
     | 
| 
       103 
     | 
    
         
            -
                  bundles_with_profiles = AppStoreConnect::Client.get_bundles_with_profiles(project_bundles)
         
     | 
| 
       104 
     | 
    
         
            -
                  bundle_by_identifier = {}
         
     | 
| 
       105 
     | 
    
         
            -
                  profiles_by_id = {}
         
     | 
| 
       106 
     | 
    
         
            -
             
     | 
| 
       107 
     | 
    
         
            -
                  bundles_with_profiles["data"].each do |bundle_id|
         
     | 
| 
       108 
     | 
    
         
            -
                    bundle_by_identifier[bundle_id["attributes"]["identifier"]] = bundle_id
         
     | 
| 
       109 
     | 
    
         
            -
                  end
         
     | 
| 
       110 
     | 
    
         
            -
             
     | 
| 
       111 
     | 
    
         
            -
                  bundles_with_profiles["included"].each do |profile|
         
     | 
| 
       112 
     | 
    
         
            -
                    profiles_by_id[profile["id"]] = profile
         
     | 
| 
       113 
     | 
    
         
            -
                  end
         
     | 
| 
       114 
     | 
    
         
            -
             
     | 
| 
       115 
     | 
    
         
            -
                  project_bundles.each do |bundle_identifier|
         
     | 
| 
       116 
     | 
    
         
            -
                    bundle_id = bundle_by_identifier[bundle_identifier]
         
     | 
| 
       117 
     | 
    
         
            -
                    unless bundle_id
         
     | 
| 
       118 
     | 
    
         
            -
                      logger.warn "Bundle '#{bundle_identifier}' is missing in App Store Connect. Skipping."
         
     | 
| 
       119 
     | 
    
         
            -
                      next
         
     | 
| 
       120 
     | 
    
         
            -
                    end
         
     | 
| 
       121 
     | 
    
         
            -
             
     | 
| 
       122 
     | 
    
         
            -
                    logger.info "Bundle '#{bundle_identifier}' resolved to Bundle ID '#{bundle_id["id"]}'"
         
     | 
| 
       123 
     | 
    
         
            -
             
     | 
| 
       124 
     | 
    
         
            -
                    profiles = bundle_id["relationships"]["profiles"]["data"]
         
     | 
| 
       125 
     | 
    
         
            -
                    unless profiles
         
     | 
| 
       126 
     | 
    
         
            -
                      logger.warn "Profile for Bundle ID '#{bundle_id["id"]}' is missing in App Store Connect. Skipping."
         
     | 
| 
       127 
     | 
    
         
            -
                      next
         
     | 
| 
       128 
     | 
    
         
            -
                    end
         
     | 
| 
       129 
     | 
    
         
            -
             
     | 
| 
       130 
     | 
    
         
            -
                    ad_hoc_profile = nil
         
     | 
| 
       131 
     | 
    
         
            -
                    profiles.each do |profile|
         
     | 
| 
       132 
     | 
    
         
            -
                      profile_id = profile["id"]
         
     | 
| 
       133 
     | 
    
         
            -
                      profile = profiles_by_id[profile_id]
         
     | 
| 
       134 
     | 
    
         
            -
             
     | 
| 
       135 
     | 
    
         
            -
                      if profile["attributes"]["profileType"] == "IOS_APP_ADHOC" && profile["attributes"]["profileState"] == "ACTIVE"
         
     | 
| 
       136 
     | 
    
         
            -
                        ad_hoc_profile = profile
         
     | 
| 
       137 
     | 
    
         
            -
                        break
         
     | 
| 
       138 
     | 
    
         
            -
                      end
         
     | 
| 
       139 
     | 
    
         
            -
                    end
         
     | 
| 
       140 
     | 
    
         
            -
             
     | 
| 
       141 
     | 
    
         
            -
                    unless ad_hoc_profile
         
     | 
| 
       142 
     | 
    
         
            -
                      logger.warn "Profile for Bundle ID '#{bundle_id["id"]}' is missing in App Store Connect. Skipping."
         
     | 
| 
       143 
     | 
    
         
            -
                      next
         
     | 
| 
       144 
     | 
    
         
            -
                    end
         
     | 
| 
       145 
     | 
    
         
            -
             
     | 
| 
       146 
     | 
    
         
            -
                    logger.info "Profile for Bundle ID '#{bundle_id["id"]}' resolved to Profile '#{ad_hoc_profile["attributes"]["name"]}'"
         
     | 
| 
       147 
     | 
    
         
            -
             
     | 
| 
       148 
     | 
    
         
            -
                    uuid = ad_hoc_profile["attributes"]["uuid"]
         
     | 
| 
       149 
     | 
    
         
            -
                    profile_content = Base64.decode64(ad_hoc_profile["attributes"]["profileContent"])
         
     | 
| 
       150 
     | 
    
         
            -
                    profile_path = "#{Dir.home}/Library/MobileDevice/Provisioning Profiles/#{uuid}.mobileprovision"
         
     | 
| 
       151 
     | 
    
         
            -
             
     | 
| 
       152 
     | 
    
         
            -
                    FileUtils.mkdir_p(File.dirname(profile_path))
         
     | 
| 
       153 
     | 
    
         
            -
                    File.write(profile_path, profile_content)
         
     | 
| 
       154 
     | 
    
         
            -
             
     | 
| 
       155 
     | 
    
         
            -
                    logger.info "Profile '#{ad_hoc_profile["attributes"]["name"]}' installed to '#{profile_path}'"
         
     | 
| 
       156 
     | 
    
         
            -
                  end
         
     | 
| 
       157 
     | 
    
         
            -
                end
         
     | 
| 
       158 
     | 
    
         
            -
             
     | 
| 
       159 
93 
     | 
    
         
             
                def get_devices(team_id)
         
     | 
| 
       160 
94 
     | 
    
         
             
                  Starship::Client.get_devices(team_id)
         
     | 
| 
       161 
95 
     | 
    
         
             
                end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: adsedare
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.0.3
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - alexstrnik
         
     | 
| 
         @@ -114,6 +114,7 @@ files: 
     | 
|
| 
       114 
114 
     | 
    
         
             
            - lib/adsedare.rb
         
     | 
| 
       115 
115 
     | 
    
         
             
            - lib/adsedare/capabilities.rb
         
     | 
| 
       116 
116 
     | 
    
         
             
            - lib/adsedare/export_options.rb
         
     | 
| 
      
 117 
     | 
    
         
            +
            - lib/adsedare/install_profiles.rb
         
     | 
| 
       117 
118 
     | 
    
         
             
            - lib/adsedare/keychain.rb
         
     | 
| 
       118 
119 
     | 
    
         
             
            - lib/adsedare/version.rb
         
     | 
| 
       119 
120 
     | 
    
         
             
            - lib/adsedare/xcodeproj.rb
         
     |