class Pod::Command::Store::Push

Public Class Methods

new(argv) click to toggle source

Plugin Lifecycle

Calls superclass method Pod::Command::Store::new
# File lib/cocoapods-store/command/store/push.rb, line 22
def initialize(argv)
        super
end

Public Instance Methods

archive_cache() click to toggle source

Run steps

# File lib/cocoapods-store/command/store/push.rb, line 42
                      def archive_cache
@cache_dir = "#{Dir.pwd}/#{cache_dir_name}"
@zip_name = "#{cache_dir_name}.zip"
if File.exist?(File.join(@cache_dir, @zip_name))
  UI.puts "Found existed cache file: #{File.join(@cache_dir, @zip_name)}".yellow
  return
end

                              UI.puts "Creating cache directory: #{@cache_dir}"

                              FileUtils.rm_rf @cache_dir
                              FileUtils.mkdir_p @cache_dir

                              # Copy files to the cache folder
                              begin
                                      FileUtils.cp_r "#{Dir.pwd}/Pods", @cache_dir
                                      FileUtils.cp_r Dir.glob("#{Dir.pwd}/*.xcworkspace").first, @cache_dir
                                      FileUtils.cp_r "#{Dir.pwd}/Podfile.lock", @cache_dir
                              rescue RuntimeError => e
                                      UI.puts "[!] An error occurred - #{e.message}".red
                                      FileUtils.rm_rf @cache_dir
                                      exit 1
end

                              # Archive the cache folder
UI.puts "Creating zip file: #{@zip_name}"
system "ditto -ck --rsrc --sequesterRsrc #{cache_dir_name} #{@zip_name}"
                      end
push_cache() click to toggle source
# File lib/cocoapods-store/command/store/push.rb, line 71
def push_cache

        begin
                s3 = load_s3_bucket

                obj = s3.bucket(@bucket).object(@zip_name)
                UI.puts "Uploading #{@zip_name}"
                obj.upload_file("#{Dir.pwd}/#{@zip_name}")

                UI.puts "✔︎ Cache uploaded successfully".green.bold

        rescue Aws::Errors::MissingCredentialsError => e
                UI.puts "S3 upload failed: Credentials were not present".red.bold
        rescue Aws::S3::Errors::NoSuchBucket => e
                UI.puts "S3 upload failed: the bucket specified does not exist".red.bold
        rescue Aws::Errors::ServiceError => e
                UI.puts "[!] S3 upload failed: A service error occurred - #{e.message}".red.bold
        ensure
                FileUtils.rm_rf @cache_dir
                FileUtils.rm_rf "#{Dir.pwd}/#{@zip_name}"
        end

end
run() click to toggle source
# File lib/cocoapods-store/command/store/push.rb, line 30
                      def run
UI.puts "cocoapods-store version: #{CocoapodsStore::VERSION}"

                              verify_podfile_exists!
                              verify_lockfile_exists!

                              archive_cache
                              push_cache
                      end
validate!() click to toggle source
Calls superclass method Pod::Command::Store#validate!
# File lib/cocoapods-store/command/store/push.rb, line 26
def validate!
        super
end