Sha256: e785b498f561d7432c5f9718fda761ef70c1106f5590070b4ea390f27a374246

Contents?: true

Size: 1.75 KB

Versions: 1

Compression:

Stored size: 1.75 KB

Contents

module Jxedt
    module CachePucher
        def self.push(output_dir, targets=nil, force_push=false)
            require_relative 'git_command'
            require_relative 'zip'

            repo = Jxedt.config.git_remote_repo
            cache_path = Jxedt.config.git_cache_path
            branch = Jxedt.config.cache_branch
            commander = Jxedt::GitCommand.new(cache_path)
            # fetch
            commander.git_fetch(repo, branch)

            output_dir = Pathname.new(output_dir)
            approve, refuse = [], []
            output_dir.children.each do |child|
                next unless child.directory?
                pod_name = child.basename.to_s
                next if targets && targets.is_a?(Array) && targets.size > 0 && !(targets.include?(pod_name))

                pod_checksum = child.children.select { |ch| ch.extname == '.checksum' }.first
                pod_checksum = pod_checksum.basename.sub_ext('').to_s unless pod_checksum.nil?
                next if pod_checksum.nil?

                to_dir = Pathname.new(cache_path) + "GeneratedFrameworks" + pod_name
                to_dir.mkpath unless to_dir.exist?
                zip_file = to_dir + "#{pod_checksum}.zip"
                skip = zip_file.exist? && !force_push
                next refuse << pod_name if skip

                approve << pod_name
                Jxedt::ZipUtils.zip(child.to_s, :zip_name => pod_checksum, :to_dir => to_dir)
            end

            # push
            commander.git_commit_and_push(branch) if approve.size > 0
            
            Pod::UI.puts "🎉  组件已缓存成功: #{approve}".yellow if approve.size > 0
            Pod::UI.puts "👻  组件缓存失败,存在相同的校验和: #{refuse}".red if refuse.size > 0
        end
    end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cocoapods-jxedt-0.0.21 lib/cocoapods-jxedt/git_helper/cache_pucher.rb