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
|
# File 'lib/cocoapods-jxedt/command/binary/command/clean.rb', line 32
def run
podfile = Pod::Config.instance.podfile
help! '请检查命令执行路径,需要在Podfile文件所在目录执行' if podfile.nil?
require 'cocoapods-jxedt/git_helper/git_command'
repo = Jxedt.config.git_remote_repo
cache_path = Jxedt.config.git_cache_path
branch = Jxedt.config.cache_branch
local_cache_dir = Pod::Config.instance.sandbox.root + Jxedt.config.binary_dir
commander = nil
commander = Jxedt::GitCommand.new(cache_path) if !@local && Jxedt.config.cache_repo_enabled?
commander.git_fetch(repo, branch) if commander
if @names.size > 0
local_deleted, remote_deleted = [], []
@names.each do |name|
local_cache = local_cache_dir + name
if local_cache.exist?
local_cache.rmtree
local_deleted << name
end
if commander
remote_cache_dir = Pathname.new(cache_path) + "GeneratedFrameworks"
remote_cache = remote_cache_dir + name
if remote_cache.exist?
remote_cache.rmtree
remote_deleted << name
end
end
end
commander.git_commit_and_push(branch) if commander && remote_deleted.size > 0
UI.puts "⚠️ ⚠️ ⚠️ 本地缓存文件已清除: #{local_deleted}" if local_deleted.size > 0
UI.puts "⚠️ ⚠️ ⚠️ 远程缓存文件已清除: #{remote_deleted}" if remote_deleted.size > 0
else
random = (0...10).map { (97 + rand(26)).chr }.join
input = get_stdin("你确认要清除所有缓存吗?包括远程仓库的缓存。确认请输入: #{random}")
help! "输入错误,自动退出" if random != input
local_cache_dir.rmtree if local_cache_dir.exist?
if commander
remote_cache_dir = Pathname.new(cache_path) + "GeneratedFrameworks"
if remote_cache_dir.exist?
remote_cache_dir.rmtree
commander.git_commit_and_push(branch)
end
end
UI.puts "⚠️ ⚠️ ⚠️ 所有缓存文件已清除"
end
end
|