27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
# File 'lib/cocoapods-jxedt/command/binary/command/statistics.rb', line 27
def run
podfile = Pod::Config.instance.podfile
lockfile = Pod::Config.instance.lockfile
help! '请检查命令执行路径,需要在Podfile文件所在目录执行' if podfile.nil? || lockfile.nil?
require 'cocoapods-jxedt/binary/config'
require 'cocoapods-jxedt/binary/helper/podfile_options'
pods_root = Pathname.new(File.dirname(podfile.defined_in_file)) + "Pods"
binary_dir = pods_root + Jxedt.config.binary_dir
used_binary = []
Dir.glob("#{pods_root}/*/_Prebuild") do |file_path|
next unless File.directory?(file_path)
next if Dir["#{file_path}/*"].empty?
dir_name = File.dirname(file_path)
name = File.basename(dir_name).to_s
target_path = binary_dir + name
next unless target_path.exist?
new_hash = {}
new_hash[:name] = name
configuration_enable = target_path.children().select { |path| "#{path.basename}" == 'Debug' || "#{path.basename}" == 'Release' }.count == 2
new_hash[:multiple_configuration] = configuration_enable
checksum_files = target_path.children().select { |path| path.extname == '.checksum' }
checksum_file = checksum_files.first
new_hash[:checksum] = checksum_file.basename.to_s.gsub('.checksum', '') unless checksum_file.nil?
new_hash[:checksum_count] = checksum_files.count
used_binary << new_hash
end
index, failed = 0, []
used_binary.sort_by {|hash| hash[:name].capitalize }.each do |hash|
name = hash[:name]
next unless lockfile.internal_data["SPEC CHECKSUMS"].include?(name)
checksum = lockfile.spec_checksums_hash_key(name)
validation_passed = checksum && checksum == hash[:checksum] && hash[:checksum_count] == 1
failed << name unless validation_passed
checkout_options = lockfile.internal_data["CHECKOUT OPTIONS"] || {}
is_git_commitid = checkout_options[name] && checkout_options[name][:commit]
if validation_passed
next if @check_failed
index += 1
log = " \#{index}). \#{name}:\n multiple configuration: \#{hash[:multiple_configuration]}\n checksum\#{\"\uFF08git commitid\uFF09\" if is_git_commitid}: \#{hash[:checksum]}\n LOG\n Pod::UI.puts log\n else\n index += 1\n log = <<~LOG\n \#{index}). \#{name}:\n multiple configuration: \#{hash[:multiple_configuration]}\n checksum: \#{hash[:checksum]}\n checksum in lockfile\#{\"\uFF08git commitid\uFF09\" if is_git_commitid}: \#{checksum}\n checksum file count: \#{hash[:checksum_count]}\n LOG\n Pod::UI.puts log.red\n end\n end\n Pod::UI.puts \"checksum\u6821\u9A8C\u5931\u8D25\u7684\u7EC4\u4EF6: \#{failed}\".red if failed.size > 0\n Pod::UI.puts \"\u5EFA\u8BAE\u4F7F\u7528\u547D\u4EE4\u6E05\u9664prebuild\u7F13\u5B58\uFF0C\u518D\u91CD\u65B0pod install\u6216\u4F7F\u7528pod jxedt binary build\u3002clean\u547D\u4EE4\uFF1A`pod jxedt binary clean --name=\#{failed.join(',')}`\".red if failed.size > 0\nend\n"
|