17
18
19
20
21
22
23
24
25
26
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
107
108
109
110
111
112
113
114
115
|
# File 'lib/fastlane/plugin/rocket/sync/sync_main.rb', line 17
def self.run(params,available_options)
Tools.formatLog(params,available_options);
git = ENV["R_SYNC_GIT"]
branch = ENV["R_SYNC_BRANCH"]
Tools.title("拉取壳工程仓库")
Tools.log("缓存地址 => #{SYNC_PATH}")
Tools.clone(git,branch,MAIN_XCODEPROJ_PATH,false)
Tools.title("同步壳工程")
commit = Tools.return_shell("cd #{MAIN_XCODEPROJ_PATH}&&git rev-parse --short HEAD")
pwd_path = Tools.return_shell("pwd")
gitignore_path = "#{pwd_path}/.gitignore"
example = "rocketExample"
example_path = "#{pwd_path}/#{example}"
yml_path = "#{example_path}/Podfile.yml"
pods_path = "#{example_path}/Pods"
example_git_path = "#{example_path}/.git"
example_gitlab_path = "#{example_path}/.gitlab"
example_arcconfig_path = "#{example_path}/.arcconfig"
example_gitignore_path = "#{example_path}/.gitignore"
str = "#壳工程分支:#{branch} 壳工程commit:#{commit}"
shell_str = "echo '#{str}' >> #{yml_path}"
unless File.directory?(example_path)
Tools.shell("mkdir -p #{example_path}")
end
unless FileTest::exist?(yml_path)
Tools.shell(shell_str)
else
note = Tools.return_shell("fgrep '#壳工程分支' '#{yml_path}'")
if note == -1
textAll = File.read(yml_path)
textAll = str + "\n" + textAll
f = open("#{yml_path}","w")
f.puts(textAll)
f.close
else
Tools.shell("sed -i '' \"s/#{note}/#{str}/g\" '#{yml_path}'")
end
end
podspecs = Dir.glob("#{pwd_path}/*.podspec")
podspecs.each do |podspec|
pod_name = File.basename(podspec,".podspec")
pod_import = "pod '#{pod_name}' ,:path => '../'"
note = Tools.return_shell("fgrep \"'#{pod_name}'\" '#{yml_path}'")
if note == -1
f = open("#{yml_path}","a")
f.puts("#{pod_import}")
f.close
end
end
Tools.deleteDirPath(example_path,[yml_path,pods_path],example_path)
FileUtils.copy_entry(MAIN_XCODEPROJ_PATH,example_path)
Tools.deleteDirPath(example_git_path)
Tools.deleteDirPath(example_gitlab_path)
Tools.deleteDirPath(example_arcconfig_path)
Tools.deleteDirPath(example_gitignore_path)
note = Tools.return_shell("fgrep '#{example}' '#{gitignore_path}'")
if note == -1
f = open("#{gitignore_path}","a")
f.puts("\n#{example}/*\n!#{example}/Podfile.yml")
f.close
end
end
|