cocoapods-cafswitcher 0.0.9 → 0.0.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +0 -1
- data/Gemfile.lock +1 -4
- data/lib/cocoapods-cafswitcher/Main.rb +74 -60
- data/lib/cocoapods-cafswitcher/gem_version.rb +1 -1
- data/lib/cocoapods-cafswitcher/podfile_switch.rb +53 -61
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b7c82ff0bdb57b01a57970524a9811430ebf59c3ae17d0ed77a1ff7c215dead
|
4
|
+
data.tar.gz: c6430a5d542b76bdbb7a9558e5f56016284f63b34595ed393e6c16ffbf4eaee2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 266791826feee895c04cee0faffcb67a6b9e620eae2258a33d475c675c5ef76c80c32d6a77834057566064447a592f57a9c55c1984b3db2ea71477bddb7ab2f4
|
7
|
+
data.tar.gz: 11b9ad02463d0be2fabeae5be0fd71c7af11575e9a9aa42eafe6d86bcb3fc35e8919a0aa0c7db353288c3c7eaaf5b888540120054c5aac31c0789d93c7c2e1a4
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
cocoapods-cafswitcher (0.0.
|
4
|
+
cocoapods-cafswitcher (0.0.10)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
@@ -40,8 +40,6 @@ GEM
|
|
40
40
|
nap (~> 1.0)
|
41
41
|
cocoapods-deintegrate (1.0.2)
|
42
42
|
cocoapods-downloader (1.2.1)
|
43
|
-
cocoapods-packager (1.5.0)
|
44
|
-
cocoapods (>= 1.1.1, < 2.0)
|
45
43
|
cocoapods-plugins (1.0.0)
|
46
44
|
nap
|
47
45
|
cocoapods-search (1.0.0)
|
@@ -90,7 +88,6 @@ DEPENDENCIES
|
|
90
88
|
bundler (~> 1.3)
|
91
89
|
cocoapods
|
92
90
|
cocoapods-cafswitcher!
|
93
|
-
cocoapods-packager
|
94
91
|
cocoapods-plugins
|
95
92
|
mocha
|
96
93
|
mocha-on-bacon
|
@@ -35,6 +35,9 @@ Pod::HooksManager.register('cocoapods-cafswitcher', :pre_install) do |installer_
|
|
35
35
|
#
|
36
36
|
allNames = Pod::Podfile.allPodName.uniq
|
37
37
|
needUpdatePodList = Pod::Podfile.needUpdatePodList.uniq
|
38
|
+
currentSourceList = Pod::Podfile.sourceList.uniq
|
39
|
+
currentArchiveList = Pod::Podfile.archiveList.uniq
|
40
|
+
currentFrameworkList = Pod::Podfile.frameworkList.uniq
|
38
41
|
|
39
42
|
if ENV['IS_ARCHIVE']
|
40
43
|
ENV.delete('IS_ARCHIVE')
|
@@ -50,41 +53,47 @@ Pod::HooksManager.register('cocoapods-cafswitcher', :pre_install) do |installer_
|
|
50
53
|
end
|
51
54
|
end
|
52
55
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
setEnv(name, "_DEBUG")
|
57
|
-
# ENV["#{name}_DEBUG"] = '1'
|
58
|
-
end
|
56
|
+
# 对于git和path的直接设置成源码
|
57
|
+
for name in needUpdatePodList
|
58
|
+
currentSourceList = currentSourceList << name if !currentSourceList.include?(name)
|
59
59
|
end
|
60
60
|
|
61
|
-
# 对debug和release切换,release级别高
|
62
|
-
for debugName in Pod::Podfile.debugPackageList.uniq
|
63
|
-
cleanDebugENV(debugName)
|
64
|
-
setEnv(debugName, "_DEBUG")
|
65
|
-
# ENV["#{debugName}_DEBUG"] = '1'
|
66
|
-
end
|
67
61
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
62
|
+
# if ENV['IS_DEBUG']
|
63
|
+
# ENV.delete('IS_DEBUG')
|
64
|
+
# for name in allNames
|
65
|
+
# setEnv(name, "_DEBUG")
|
66
|
+
# # ENV["#{name}_DEBUG"] = '1'
|
67
|
+
# end
|
68
|
+
# end
|
69
|
+
|
70
|
+
# 对debug和release切换,release级别高
|
71
|
+
# for debugName in Pod::Podfile.debugPackageList.uniq
|
72
|
+
# cleanDebugENV(debugName)
|
73
|
+
# setEnv(debugName, "_DEBUG")
|
74
|
+
# # ENV["#{debugName}_DEBUG"] = '1'
|
75
|
+
# end
|
76
|
+
#
|
77
|
+
# for releaseName in Pod::Podfile.releasePackageList.uniq
|
78
|
+
# cleanDebugENV(releaseName)
|
79
|
+
# setEnv(releaseName, "_RELEASE")
|
80
|
+
# # ENV["#{releaseName}_RELEASE"] = '1'
|
81
|
+
# end
|
73
82
|
|
74
83
|
# 二进制切换
|
75
|
-
for sourceName in
|
84
|
+
for sourceName in currentSourceList
|
76
85
|
cleanENV(sourceName)
|
77
86
|
setEnv(sourceName, "_SOURCE")
|
78
87
|
# ENV["#{sourceName}_SOURCE"] = '1'
|
79
88
|
end
|
80
89
|
|
81
|
-
for archiveName in
|
90
|
+
for archiveName in currentArchiveList
|
82
91
|
cleanENV(archiveName)
|
83
92
|
setEnv(archiveName, "_ARCHIVE")
|
84
93
|
# ENV["#{archiveName}_ARCHIVE"] = '1'
|
85
94
|
end
|
86
95
|
|
87
|
-
for frameworkName in
|
96
|
+
for frameworkName in currentFrameworkList
|
88
97
|
cleanENV(frameworkName)
|
89
98
|
setEnv(frameworkName, "_FRAMEWORK")
|
90
99
|
# ENV["#{frameworkName}_FRAMEWORK"] = '1'
|
@@ -93,19 +102,20 @@ Pod::HooksManager.register('cocoapods-cafswitcher', :pre_install) do |installer_
|
|
93
102
|
sourceList = Array.new
|
94
103
|
archiveList = Array.new
|
95
104
|
frameworkList = Array.new
|
96
|
-
debugPackageList = Array.new
|
97
|
-
releasePackageList = Array.new
|
105
|
+
# debugPackageList = Array.new
|
106
|
+
# releasePackageList = Array.new
|
98
107
|
|
99
108
|
for name in allNames
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
109
|
+
envName = name.gsub(/[\/]/, '_')
|
110
|
+
# if ENV["#{name}_DEBUG"] == '1'
|
111
|
+
# debugPackageList << name
|
112
|
+
# else
|
113
|
+
# releasePackageList << name
|
114
|
+
# end
|
115
|
+
|
116
|
+
if ENV["#{envName}_SOURCE"] == '1'
|
107
117
|
sourceList << name
|
108
|
-
elsif ENV["#{
|
118
|
+
elsif ENV["#{envName}_ARCHIVE"] == '1'
|
109
119
|
archiveList << name
|
110
120
|
else
|
111
121
|
frameworkList << name
|
@@ -115,8 +125,8 @@ Pod::HooksManager.register('cocoapods-cafswitcher', :pre_install) do |installer_
|
|
115
125
|
Pod::UI.puts "is Source :\n #{sourceList}"
|
116
126
|
Pod::UI.puts "is Archive :\n #{archiveList}"
|
117
127
|
Pod::UI.puts "is Framework :\n #{frameworkList}"
|
118
|
-
Pod::UI.puts "is debugPackage :\n #{debugPackageList}"
|
119
|
-
Pod::UI.puts "is releasePackage :\n #{releasePackageList}"
|
128
|
+
# Pod::UI.puts "is debugPackage :\n #{debugPackageList}"
|
129
|
+
# Pod::UI.puts "is releasePackage :\n #{releasePackageList}"
|
120
130
|
|
121
131
|
# 如果某一个Pod和上一次比发生变化,需要清除缓存
|
122
132
|
# 1. 清除pod缓存
|
@@ -126,8 +136,10 @@ Pod::HooksManager.register('cocoapods-cafswitcher', :pre_install) do |installer_
|
|
126
136
|
# 3. 保存本次配置
|
127
137
|
#
|
128
138
|
|
129
|
-
caf_hash = Hash["sourceList" => sourceList, "archiveList" => archiveList, "frameworkList" => frameworkList,
|
130
|
-
|
139
|
+
# caf_hash = Hash["sourceList" => sourceList, "archiveList" => archiveList, "frameworkList" => frameworkList,
|
140
|
+
# "debugPackageList" => debugPackageList, "releasePackageList" => releasePackageList]
|
141
|
+
caf_hash = Hash["sourceList" => sourceList, "archiveList" => archiveList, "frameworkList" => frameworkList]
|
142
|
+
|
131
143
|
|
132
144
|
config = Pod::Config.instance
|
133
145
|
|
@@ -141,17 +153,18 @@ Pod::HooksManager.register('cocoapods-cafswitcher', :pre_install) do |installer_
|
|
141
153
|
cafConfig = YAML.load(File.open(configFile))
|
142
154
|
else
|
143
155
|
FileUtils.touch configFile
|
144
|
-
cafConfig = Hash["sourceList" => [], "archiveList" => [], "frameworkList" => [],
|
145
|
-
|
156
|
+
# cafConfig = Hash["sourceList" => [], "archiveList" => [], "frameworkList" => [],
|
157
|
+
# "debugPackageList" => [], "releasePackageList" => []]
|
158
|
+
cafConfig = Hash["sourceList" => [], "archiveList" => [], "frameworkList" => []]
|
146
159
|
end
|
147
160
|
# 比较不同
|
148
161
|
changedSubPods = Array.new
|
149
162
|
cafConfig.each do |key, value|
|
150
|
-
if key == "debugPackageList"
|
151
|
-
|
152
|
-
elsif key == "releasePackageList"
|
153
|
-
|
154
|
-
|
163
|
+
# if key == "debugPackageList"
|
164
|
+
# changedSubPods |= (value | debugPackageList) - (value & debugPackageList)
|
165
|
+
# elsif key == "releasePackageList"
|
166
|
+
# changedSubPods |= (value | releasePackageList) - (value & releasePackageList)
|
167
|
+
if key == "sourceList"
|
155
168
|
changedSubPods |= (value | sourceList) - (value & sourceList)
|
156
169
|
elsif key == "archiveList"
|
157
170
|
changedSubPods |= (value | archiveList) - (value & archiveList)
|
@@ -162,11 +175,9 @@ Pod::HooksManager.register('cocoapods-cafswitcher', :pre_install) do |installer_
|
|
162
175
|
Pod::UI.puts "\nchanged sub Pod is:\n " + changedSubPods.to_s if changedSubPods.length > 0
|
163
176
|
# changedPod 里是根据subspec来存的,需要进行合并,找到pod库而不是含有subspec的库
|
164
177
|
changedPods = Array.new
|
165
|
-
changedSubPods.each do
|
166
|
-
subPod.
|
167
|
-
|
168
|
-
subPod.chomp!("_FRAMEWORK")
|
169
|
-
changedPods << subPod
|
178
|
+
changedSubPods.each do |subPod|
|
179
|
+
podName = subPod.split("/")[0]
|
180
|
+
changedPods << podName
|
170
181
|
end
|
171
182
|
# changedPods = changedPods | needUpdatePodList
|
172
183
|
changedPods.uniq!
|
@@ -175,14 +186,15 @@ Pod::HooksManager.register('cocoapods-cafswitcher', :pre_install) do |installer_
|
|
175
186
|
|
176
187
|
# 根据不同删除cache
|
177
188
|
podRoot = config.project_pods_root
|
178
|
-
|
179
|
-
|
189
|
+
changedSubPods.each do |changedSubPod|
|
190
|
+
changedPod = changedSubPod.split("/")[0]
|
191
|
+
if needUpdatePodList.delete(changedSubPod)
|
180
192
|
Pod::UI.puts "正在清理#{changedPod}的缓存"
|
181
193
|
cacheCleanCMD = "pod cache clean #{changedPod} --all"
|
182
194
|
out = `#{cacheCleanCMD}`.lines.to_a
|
183
195
|
Pod::UI.puts out
|
184
196
|
end
|
185
|
-
if
|
197
|
+
if changedSubPod =~ /^(?i)LJ/ or changedSubPod =~ /^(?i)Lianjia/
|
186
198
|
# 清除目录 pods 文件夹下的缓存
|
187
199
|
changedPodPath = podRoot + changedPod
|
188
200
|
FileUtils.rm_r(changedPodPath) if changedPodPath.exist?
|
@@ -190,28 +202,30 @@ Pod::HooksManager.register('cocoapods-cafswitcher', :pre_install) do |installer_
|
|
190
202
|
end
|
191
203
|
|
192
204
|
# 把新的配置写入file
|
193
|
-
File.open(configFile, "wb") {|f| YAML.dump(caf_hash, f) }
|
205
|
+
File.open(configFile, "wb") {|f| YAML.dump(caf_hash, f) } if changedSubPods.length > 0
|
194
206
|
end
|
195
207
|
|
196
208
|
|
197
209
|
def setEnv(name, suffix)
|
198
|
-
|
199
|
-
|
210
|
+
envName = name.gsub(/[\/]/, '_')
|
211
|
+
ENV["#{envName}#{suffix}"] = '1'
|
212
|
+
podName = name.split("/")[0]
|
200
213
|
ENV["#{podName}#{suffix}"] = '1'
|
201
214
|
end
|
202
215
|
|
203
216
|
|
204
217
|
|
205
218
|
def cleanENV(name)
|
206
|
-
|
207
|
-
ENV.delete("#{
|
208
|
-
ENV.delete("#{
|
219
|
+
envName = name.gsub(/[\/]/, '_')
|
220
|
+
ENV.delete("#{envName}_SOURCE")
|
221
|
+
ENV.delete("#{envName}_ARCHIVE")
|
222
|
+
ENV.delete("#{envName}_FRAMEWORK")
|
209
223
|
ENV.delete('IS_SOURCE')
|
210
224
|
ENV.delete('IS_ARCHIVE')
|
211
225
|
end
|
212
226
|
|
213
|
-
def cleanDebugENV(name)
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
end
|
227
|
+
# def cleanDebugENV(name)
|
228
|
+
# ENV.delete("#{name}_DEBUG")
|
229
|
+
# ENV.delete("#{name}_RELEASE")
|
230
|
+
# ENV.delete('IS_DEBUG')
|
231
|
+
# end
|
@@ -21,15 +21,15 @@ module Pod
|
|
21
21
|
|
22
22
|
# add flag
|
23
23
|
# :isDebugPackage
|
24
|
-
def self.isDebugPackage
|
25
|
-
|
26
|
-
end
|
24
|
+
# def self.isDebugPackage
|
25
|
+
# :isDebugPackage
|
26
|
+
# end
|
27
27
|
|
28
28
|
# add flag
|
29
29
|
# :isReleasePackage
|
30
|
-
def self.isReleasePackage
|
31
|
-
|
32
|
-
end
|
30
|
+
# def self.isReleasePackage
|
31
|
+
# :isReleasePackage
|
32
|
+
# end
|
33
33
|
|
34
34
|
@@sourceList = Array.new
|
35
35
|
|
@@ -49,17 +49,17 @@ module Pod
|
|
49
49
|
@@frameworkList
|
50
50
|
end
|
51
51
|
|
52
|
-
@@debugPackageList = Array.new
|
53
|
-
|
54
|
-
def Podfile.debugPackageList
|
55
|
-
|
56
|
-
end
|
57
|
-
|
58
|
-
@@releasePackageList = Array.new
|
59
|
-
|
60
|
-
def Podfile.releasePackageList
|
61
|
-
|
62
|
-
end
|
52
|
+
# @@debugPackageList = Array.new
|
53
|
+
#
|
54
|
+
# def Podfile.debugPackageList
|
55
|
+
# @@debugPackageList
|
56
|
+
# end
|
57
|
+
#
|
58
|
+
# @@releasePackageList = Array.new
|
59
|
+
#
|
60
|
+
# def Podfile.releasePackageList
|
61
|
+
# @@releasePackageList
|
62
|
+
# end
|
63
63
|
|
64
64
|
# all the name of Pod
|
65
65
|
@@allPodName = Array.new
|
@@ -90,9 +90,9 @@ module Pod
|
|
90
90
|
|
91
91
|
# Enable debug package for all pods
|
92
92
|
# it has a lower priority to other binary settings
|
93
|
-
def all_debug_package!
|
94
|
-
|
95
|
-
end
|
93
|
+
# def all_debug_package!
|
94
|
+
# ENV['IS_DEBUG'] = '1'
|
95
|
+
# end
|
96
96
|
|
97
97
|
end
|
98
98
|
|
@@ -105,7 +105,7 @@ module Pod
|
|
105
105
|
isFramework = options.has_key?(Pod::Podfile.isFramework)
|
106
106
|
# pod_name = Specification.root_name(name)
|
107
107
|
if isFramework
|
108
|
-
Pod::Podfile.frameworkList << name
|
108
|
+
Pod::Podfile.frameworkList << name
|
109
109
|
end
|
110
110
|
requirements.pop if options.empty?
|
111
111
|
end
|
@@ -117,7 +117,7 @@ module Pod
|
|
117
117
|
isSource = options.has_key?(Pod::Podfile.isSource)
|
118
118
|
# pod_name = Specification.root_name(name)
|
119
119
|
if isSource
|
120
|
-
Pod::Podfile.sourceList << name
|
120
|
+
Pod::Podfile.sourceList << name
|
121
121
|
end
|
122
122
|
requirements.pop if options.empty?
|
123
123
|
end
|
@@ -129,35 +129,35 @@ module Pod
|
|
129
129
|
isArchive = options.has_key?(Pod::Podfile.isArchive)
|
130
130
|
# pod_name = Specification.root_name(name)
|
131
131
|
if isArchive
|
132
|
-
Pod::Podfile.archiveList << name
|
132
|
+
Pod::Podfile.archiveList << name
|
133
133
|
end
|
134
134
|
|
135
135
|
requirements.pop if options.empty?
|
136
136
|
end
|
137
137
|
|
138
|
-
def parse_debug_package(name, requirements)
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
end
|
149
|
-
|
150
|
-
def parse_release_package(name, requirements)
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
end
|
138
|
+
# def parse_debug_package(name, requirements)
|
139
|
+
# options = requirements.last
|
140
|
+
# return requirements unless options.is_a?(Hash)
|
141
|
+
#
|
142
|
+
# isDebugPackage = options.has_key?(Pod::Podfile.isDebugPackage)
|
143
|
+
# # pod_name = Specification.root_name(name)
|
144
|
+
# if isDebugPackage
|
145
|
+
# Pod::Podfile.debugPackageList << name.gsub(/[\/]/, '_')
|
146
|
+
# end
|
147
|
+
# requirements.pop if options.empty?
|
148
|
+
# end
|
149
|
+
#
|
150
|
+
# def parse_release_package(name, requirements)
|
151
|
+
# options = requirements.last
|
152
|
+
# return requirements unless options.is_a?(Hash)
|
153
|
+
#
|
154
|
+
# isReleasePackage = options.has_key?(Pod::Podfile.isReleasePackage)
|
155
|
+
# # pod_name = Specification.root_name(name)
|
156
|
+
# if isReleasePackage
|
157
|
+
# Pod::Podfile.releasePackageList << name.gsub(/[\/]/, '_')
|
158
|
+
# end
|
159
|
+
# requirements.pop if options.empty?
|
160
|
+
# end
|
161
161
|
|
162
162
|
def parse_needUpdatePod_git(name, requirements)
|
163
163
|
options = requirements.last
|
@@ -166,11 +166,7 @@ module Pod
|
|
166
166
|
isGitPath = options.has_key?(:git)
|
167
167
|
# pod_name = Specification.root_name(name)
|
168
168
|
if isGitPath
|
169
|
-
|
170
|
-
if not index
|
171
|
-
index = name.length
|
172
|
-
end
|
173
|
-
Pod::Podfile.needUpdatePodList << name[0,index]
|
169
|
+
Pod::Podfile.needUpdatePodList << name
|
174
170
|
end
|
175
171
|
requirements.pop if options.empty?
|
176
172
|
end
|
@@ -182,11 +178,7 @@ module Pod
|
|
182
178
|
isPath = options.has_key?(:path)
|
183
179
|
# pod_name = Specification.root_name(name)
|
184
180
|
if isPath
|
185
|
-
|
186
|
-
if not index
|
187
|
-
index = name.length
|
188
|
-
end
|
189
|
-
Pod::Podfile.needUpdatePodList << name[0,index]
|
181
|
+
Pod::Podfile.needUpdatePodList << name
|
190
182
|
end
|
191
183
|
requirements.pop if options.empty?
|
192
184
|
end
|
@@ -200,12 +192,12 @@ module Pod
|
|
200
192
|
parse_isFramework(name, requirements)
|
201
193
|
parse_isSource(name, requirements)
|
202
194
|
parse_isArchive(name, requirements)
|
203
|
-
parse_debug_package(name, requirements)
|
204
|
-
parse_release_package(name, requirements)
|
195
|
+
# parse_debug_package(name, requirements)
|
196
|
+
# parse_release_package(name, requirements)
|
205
197
|
parse_needUpdatePod_git(name, requirements)
|
206
198
|
parse_needUpdatePod_path(name, requirements)
|
207
199
|
# pod_name = Specification.root_name(name)
|
208
|
-
Pod::Podfile.allPodName << name
|
200
|
+
Pod::Podfile.allPodName << name
|
209
201
|
old_method.bind(self).(name, requirements)
|
210
202
|
end
|
211
203
|
|
@@ -221,8 +213,8 @@ module Pod
|
|
221
213
|
isFramework = options.delete(Pod::Podfile.isFramework)
|
222
214
|
isSource = options.delete(Pod::Podfile.isSource)
|
223
215
|
isArchive = options.delete(Pod::Podfile.isArchive)
|
224
|
-
isDebugPackage = options.delete(Pod::Podfile.isDebugPackage)
|
225
|
-
isReleasePackage = options.delete(Pod::Podfile.isReleasePackage)
|
216
|
+
# isDebugPackage = options.delete(Pod::Podfile.isDebugPackage)
|
217
|
+
# isReleasePackage = options.delete(Pod::Podfile.isReleasePackage)
|
226
218
|
tmp_hash.pop if options.empty?
|
227
219
|
tmp_hash
|
228
220
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cocoapods-cafswitcher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- handa
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-10-
|
11
|
+
date: 2018-10-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|