Sha256: 84dd4527b1272be28104bbafccf408fcec3afd72cda58e5245d05bce6dd766a3

Contents?: true

Size: 1.73 KB

Versions: 8

Compression:

Stored size: 1.73 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.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

8 entries across 8 versions & 1 rubygems

Version Path
cocoapods-jxedt-0.0.20 lib/cocoapods-jxedt/git_helper/cache_pucher.rb
cocoapods-jxedt-0.0.19 lib/cocoapods-jxedt/git_helper/cache_pucher.rb
cocoapods-jxedt-0.0.18 lib/cocoapods-jxedt/git_helper/cache_pucher.rb
cocoapods-jxedt-0.0.17 lib/cocoapods-jxedt/git_helper/cache_pucher.rb
cocoapods-jxedt-0.0.16 lib/cocoapods-jxedt/git_helper/cache_pucher.rb
cocoapods-jxedt-0.0.15 lib/cocoapods-jxedt/git_helper/cache_pucher.rb
cocoapods-jxedt-0.0.14 lib/cocoapods-jxedt/git_helper/cache_pucher.rb
cocoapods-jxedt-0.0.13 lib/cocoapods-jxedt/git_helper/cache_pucher.rb