furion 1.0.8.1 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/furion +11 -3
- data/lib/furion.rb +42 -6
- data/lib/furion/file_editor.rb +3 -3
- data/lib/furion/ver_conflict_detector.rb +259 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 88af458021bc7618aeda209a06c96fefe324857cc36284d40aaf6ffe9e1a0a4f
|
4
|
+
data.tar.gz: 92100ff9ec52165dae9a1933d113e35b3fc483c6b716f253a1b8e13b6e71d633
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 866e8db42a8585fdb0e3b9176fa9a974663033fce27d3fbfa213551b044713a9c757286022e367edffa3b24257c7b9b152bd3df01212e7f8a6ceb5c535413c76
|
7
|
+
data.tar.gz: fba8475942b5e2b374635a68c8df43bcb287f062b6e4920869fb52261eb73ced1b2e7b0a0d5463cfa4b4dd52e1e77f1b970fbd3198942fa53c0778a9d195e2fe
|
data/bin/furion
CHANGED
@@ -11,12 +11,12 @@ OptionParser.new do |opts|
|
|
11
11
|
puts "Options and arguments:
|
12
12
|
-v : print the version number
|
13
13
|
-h : print the help message
|
14
|
-
init
|
15
|
-
|
14
|
+
init : run wrapper-pick work flow in existed project
|
15
|
+
update : update the config of sdk-wrapper
|
16
16
|
"
|
17
17
|
end
|
18
18
|
opts.on("-v", "--version", "Prints version") do |dh|
|
19
|
-
puts "1.0.
|
19
|
+
puts "1.0.9"
|
20
20
|
end
|
21
21
|
|
22
22
|
|
@@ -25,3 +25,11 @@ end.parse!
|
|
25
25
|
if ARGV[0] == "init"
|
26
26
|
Furion.makeConfig
|
27
27
|
end
|
28
|
+
|
29
|
+
if ARGV[0] == "confdet"
|
30
|
+
Furion.detectConflict
|
31
|
+
end
|
32
|
+
|
33
|
+
if ARGV[0] == "update"
|
34
|
+
Furion.updateConfig
|
35
|
+
end
|
data/lib/furion.rb
CHANGED
@@ -4,10 +4,12 @@ require 'json'
|
|
4
4
|
require 'plist'
|
5
5
|
require 'open-uri'
|
6
6
|
require 'furion/file_editor'
|
7
|
+
require 'furion/ver_conflict_detector'
|
7
8
|
class Furion
|
8
9
|
|
9
10
|
def self.fetchFile(fileName)
|
10
|
-
uri = "https://git.huya.com/chenguohao2/FurionTemplateResource/raw/master/"+fileName
|
11
|
+
uri = "https://git.huya.com/chenguohao2/FurionTemplateResource/raw/master/iOS/"+fileName
|
12
|
+
puts "download from "+uri
|
11
13
|
data = open(uri){|f| f.read}
|
12
14
|
file = File.new fileName, 'w+'
|
13
15
|
file.binmode
|
@@ -22,18 +24,55 @@ class Furion
|
|
22
24
|
self.fetchFile("example.code")
|
23
25
|
result = `python GenConfig.py `
|
24
26
|
File.write('data.json', result)
|
25
|
-
puts "finish writting"
|
26
|
-
FileEditor.editPodfile
|
27
27
|
`plutil -convert xml1 data.json -o MTPSDK.plist`
|
28
|
+
if !(File.exist?'MTPSDK.plist')
|
29
|
+
puts "error in Config Generation: "+result
|
30
|
+
end
|
31
|
+
|
32
|
+
FileEditor.editPodfile
|
33
|
+
|
28
34
|
File.delete('GenConfig.py')
|
29
35
|
File.delete('data.json')
|
30
36
|
FileEditor.insertExampleCode
|
31
37
|
File.delete('example.code')
|
38
|
+
puts "pod installing..."
|
32
39
|
`pod install`
|
33
40
|
projName = FileEditor.getCuriOSProjName
|
34
41
|
puts "Config finished, run "+projName+".xcworkspace to continue "
|
35
42
|
end
|
36
43
|
|
44
|
+
def self.updateConfig
|
45
|
+
|
46
|
+
if !(File.exist?'MTPSDK.plist')
|
47
|
+
puts "MTPSDK.plist not exist "
|
48
|
+
return
|
49
|
+
end
|
50
|
+
|
51
|
+
self.fetchFile("GenConfig.py")
|
52
|
+
sdkWrapperDict = Plist::parse_xml("MTPSDK.plist")
|
53
|
+
jsonObj = sdkWrapperDict.to_json
|
54
|
+
fJson = File.open("cachedConfig.json","w")
|
55
|
+
fJson.write(jsonObj)
|
56
|
+
fJson.close
|
57
|
+
result = `python GenConfig.py update`
|
58
|
+
File.write('data.json', result)
|
59
|
+
`plutil -convert xml1 data.json -o MTPSDK.plist`
|
60
|
+
if !(File.exist?'MTPSDK.plist')
|
61
|
+
puts "error in Config Generation: "+result
|
62
|
+
end
|
63
|
+
puts "pod installing..."
|
64
|
+
`pod install`
|
65
|
+
File.delete('GenConfig.py')
|
66
|
+
File.delete('data.json')
|
67
|
+
File.delete("cachedConfig.json")
|
68
|
+
projName = FileEditor.getCuriOSProjName
|
69
|
+
puts "Config finished, run "+projName+".xcworkspace to continue "
|
70
|
+
end
|
71
|
+
|
72
|
+
def self.detectConflict
|
73
|
+
ConflictDetector.detectConflict
|
74
|
+
end
|
75
|
+
|
37
76
|
def self.runCMD
|
38
77
|
cmd = ARGV[0]
|
39
78
|
if cmd == "init"
|
@@ -45,6 +84,3 @@ class Furion
|
|
45
84
|
end
|
46
85
|
end
|
47
86
|
end
|
48
|
-
|
49
|
-
|
50
|
-
|
data/lib/furion/file_editor.rb
CHANGED
@@ -20,7 +20,7 @@ class FileEditor
|
|
20
20
|
|
21
21
|
projName = self.getCuriOSProjName
|
22
22
|
|
23
|
-
if projName
|
23
|
+
if projName == nil
|
24
24
|
return
|
25
25
|
end
|
26
26
|
|
@@ -72,9 +72,9 @@ class FileEditor
|
|
72
72
|
def self.insertExampleCode
|
73
73
|
|
74
74
|
dict = Plist::parse_xml("MTPSDK.plist")
|
75
|
-
wrapperSDKDict = dict["sdkWrapper"]
|
75
|
+
#wrapperSDKDict = dict["sdkWrapper"]
|
76
76
|
params = dict["commonParams"]
|
77
|
-
keys = wrapperSDKDict.keys()
|
77
|
+
keys = []#wrapperSDKDict.keys()
|
78
78
|
keys.insert(0,"commonCode")
|
79
79
|
keys.append("finnalInit")
|
80
80
|
targetFilePath = ""
|
@@ -0,0 +1,259 @@
|
|
1
|
+
require 'cocoapods'
|
2
|
+
require 'etc'
|
3
|
+
class ConflictDetector
|
4
|
+
def self.detectConflict
|
5
|
+
@openingSpec = []
|
6
|
+
@specRequire = {}
|
7
|
+
# dict = Plist::parse_xml("MTPSDK.plist")
|
8
|
+
file = File.read('sdkConfig.json')
|
9
|
+
dict = JSON.parse(file)
|
10
|
+
# "sdk":{"hypushsdk": {"wrapperVersion": "0.1.13-dev", "sdkVersion": "*", "wrapper": "pushsdk-wrapper"}
|
11
|
+
sdkDict = {}
|
12
|
+
sdkWrapperDict = dict["sdk"]
|
13
|
+
for sdk in sdkWrapperDict.keys
|
14
|
+
sdkInfo = sdkWrapperDict[sdk]
|
15
|
+
sdkDict[sdk] = sdkInfo["sdkVersion"]
|
16
|
+
if sdkInfo.key?"wrapper"
|
17
|
+
sdkDict[sdkInfo["wrapper"]] = sdkInfo["wrapperVersion"]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
for sdk in sdkDict.keys
|
24
|
+
version = sdkDict[sdk]
|
25
|
+
self.loadSpec(sdk,version)
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
dependency = {}
|
30
|
+
conflictInfo = {}
|
31
|
+
for sdk in @specRequire.keys
|
32
|
+
requireinfo = @specRequire[sdk]
|
33
|
+
sdkConflict = self.compareRequire(sdk,requireinfo.values)
|
34
|
+
dependency[sdk] = {"conflict"=>sdkConflict,"requirement"=>requireinfo}
|
35
|
+
end
|
36
|
+
|
37
|
+
json = dependency.to_json
|
38
|
+
File.open("verionDependency.json", "w") do |out|
|
39
|
+
out.write(json)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.loadSpec(specName,version)
|
44
|
+
|
45
|
+
if @openingSpec.include?(specName)
|
46
|
+
return
|
47
|
+
end
|
48
|
+
|
49
|
+
user = Etc.getpwuid(Process.uid).name
|
50
|
+
sourcePath = "/Users/" + user + "/.cocoapods/repos/huya-ci_team-specs"
|
51
|
+
path = self.getSpecFromSDK(sourcePath,specName,version)
|
52
|
+
|
53
|
+
if path.length == 0
|
54
|
+
# SDK的文件夹没找到,就从wrapper文件夹开始找
|
55
|
+
sourcePath = "/Users/" + user + "/.cocoapods/repos/Wrapper-Specs"
|
56
|
+
path = self.getSpecFromSDK(sourcePath,specName,version)
|
57
|
+
end
|
58
|
+
|
59
|
+
if path.length == 0
|
60
|
+
# 如果在wrapper也没找到就说明找不到
|
61
|
+
puts "[FurionError]:spec load Error in "+path
|
62
|
+
return
|
63
|
+
end
|
64
|
+
|
65
|
+
|
66
|
+
@openingSpec.append(specName)
|
67
|
+
ret = Pod::Specification.from_file(path, subspec_name = specName)
|
68
|
+
if ret.dependencies.length == 0
|
69
|
+
return
|
70
|
+
end
|
71
|
+
|
72
|
+
|
73
|
+
for item in ret.dependencies
|
74
|
+
requireStr = String(item.requirement)
|
75
|
+
self.recordDependancy(item.name,requireStr,specName)
|
76
|
+
if self.isVersionSpecific(requireStr) == 0
|
77
|
+
content = self.wrapSpecificVersion(requireStr)
|
78
|
+
self.readSpecFromRepo(item.name,content)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def self.recordDependancy(sdk,requirement,subscriber)
|
84
|
+
requireInfo = @specRequire[sdk]
|
85
|
+
if requireInfo == nil
|
86
|
+
requireInfo = {}
|
87
|
+
end
|
88
|
+
requireInfo[subscriber] = requirement
|
89
|
+
@specRequire[sdk] = requireInfo
|
90
|
+
|
91
|
+
end
|
92
|
+
|
93
|
+
def self.isVersionSpecific(versionRequire)
|
94
|
+
symbols = ['~>','>=','<=','>','<']
|
95
|
+
for symbol in symbols
|
96
|
+
if versionRequire.include?(symbol)
|
97
|
+
return 1
|
98
|
+
end
|
99
|
+
end
|
100
|
+
return 0
|
101
|
+
end
|
102
|
+
|
103
|
+
def self.wrapSpecificVersion(versionStr)
|
104
|
+
content = String(versionStr)
|
105
|
+
content = content.sub(" ","")
|
106
|
+
content = content.sub("=","")
|
107
|
+
return content
|
108
|
+
end
|
109
|
+
|
110
|
+
def self.readSpecFromRepo(specName,version)
|
111
|
+
|
112
|
+
|
113
|
+
|
114
|
+
self.loadSpec(specName,version)
|
115
|
+
end
|
116
|
+
|
117
|
+
|
118
|
+
def self.getSpecFromSDK(groupPath,sdkName,version)
|
119
|
+
|
120
|
+
if version == "*"
|
121
|
+
allPath = groupPath + "/" + sdkName + "/" + version
|
122
|
+
subPathArray = Dir[allPath]
|
123
|
+
wrapperPath = subPathArray.last
|
124
|
+
else
|
125
|
+
wrapperPath = groupPath + "/" + sdkName + "/" + version
|
126
|
+
if !File.exist?(wrapperPath)
|
127
|
+
return ""
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
Find.find(wrapperPath) do |path|
|
134
|
+
if path.end_with? ".podspec"
|
135
|
+
return path
|
136
|
+
break
|
137
|
+
end
|
138
|
+
end
|
139
|
+
return ""
|
140
|
+
end
|
141
|
+
|
142
|
+
def self.compareRequire(sdk,requireArray)
|
143
|
+
# model a < x < b
|
144
|
+
smallVersion = "0"
|
145
|
+
min = smallVersion
|
146
|
+
containMin = 0 # 用于区分 < 和 <=
|
147
|
+
hugeVersion = "9999999.999999.999999"
|
148
|
+
max = hugeVersion
|
149
|
+
containMax = 0
|
150
|
+
|
151
|
+
depency = nil
|
152
|
+
isConflict = 0
|
153
|
+
for require in requireArray
|
154
|
+
|
155
|
+
depency = Pod::Dependency.new(sdk,require)
|
156
|
+
operator = depency.requirement.requirements.first[0]
|
157
|
+
version = depency.requirement.requirements.first[1]
|
158
|
+
if String(operator) == '>=' || String(operator) == '~>'
|
159
|
+
if self.isVersionBigger(version,min) == 1
|
160
|
+
min = version
|
161
|
+
containMin = 1
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
if String(operator) == '>'
|
166
|
+
if self.isVersionBigger(version,min) == 1
|
167
|
+
min = version
|
168
|
+
containMin = 0
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
if String(operator) == '<='
|
173
|
+
if self.isVersionBigger(version,max) == 1
|
174
|
+
max = version
|
175
|
+
containMax = 1
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
if String(operator) == '<'
|
180
|
+
if self.isVersionBigger(max,version) == 1
|
181
|
+
max = version
|
182
|
+
containMax = 0
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
if isVersionBigger(min,max) == 1
|
187
|
+
# 下限大于上限
|
188
|
+
isConflict = 1
|
189
|
+
else
|
190
|
+
if min == max
|
191
|
+
if containMax == 0 || containMin == 0
|
192
|
+
isConflict = 1
|
193
|
+
end
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
if String(operator) == '='
|
198
|
+
if isVersionBigger(version,max) == 1 || isVersionBigger(min,version) ==1
|
199
|
+
# 固定版本在已有范围之外
|
200
|
+
isConflict = 1
|
201
|
+
else
|
202
|
+
min = version
|
203
|
+
max = version
|
204
|
+
containMax = 1
|
205
|
+
containMin = 1
|
206
|
+
end
|
207
|
+
end
|
208
|
+
end
|
209
|
+
result = {"isConflict"=>isConflict}
|
210
|
+
if max != hugeVersion
|
211
|
+
maxOperater = containMax == 1 ? "<=" : "<"
|
212
|
+
maxRequire = maxOperater+ " " + String(max)
|
213
|
+
result["maxRequire"] = maxRequire
|
214
|
+
end
|
215
|
+
|
216
|
+
|
217
|
+
if min != smallVersion
|
218
|
+
minOperater = containMin == 1 ? ">=" : ">"
|
219
|
+
minRequire = minOperater+ " " + String(min)
|
220
|
+
result["minRequire"] = minRequire
|
221
|
+
end
|
222
|
+
|
223
|
+
return result
|
224
|
+
end
|
225
|
+
|
226
|
+
def self.isVersionBigger(version,otherVersion)
|
227
|
+
varNumArray1 = String(version).split("-")
|
228
|
+
verNum1 = varNumArray1[0]
|
229
|
+
if varNumArray1.length() > 1
|
230
|
+
verExt1 = varNumArray1[1]
|
231
|
+
else
|
232
|
+
verExt1 = "*"
|
233
|
+
end
|
234
|
+
|
235
|
+
varNumArray2 = String(otherVersion).split("-")
|
236
|
+
verNum2 = varNumArray1[0]
|
237
|
+
if varNumArray2.length() > 1
|
238
|
+
verExt2 = varNumArray2[1]
|
239
|
+
else
|
240
|
+
verExt2 = "*"
|
241
|
+
end
|
242
|
+
|
243
|
+
|
244
|
+
if Gem::Version.new(verNum1) > Gem::Version.new(otherVersion)
|
245
|
+
return 1
|
246
|
+
else
|
247
|
+
if Gem::Version.new(verNum1) == Gem::Version.new(otherVersion)
|
248
|
+
if verExt1 == '*' && verExt2 != '*'
|
249
|
+
return 1
|
250
|
+
end
|
251
|
+
end
|
252
|
+
end
|
253
|
+
return 0
|
254
|
+
end
|
255
|
+
|
256
|
+
def self.getLastVersionFromDir(dirPath)
|
257
|
+
|
258
|
+
end
|
259
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: furion
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- MTP Huya
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-11-21 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: MTP Huya is the best!!!
|
14
14
|
email: mtphuya@yandex.com
|
@@ -20,6 +20,7 @@ files:
|
|
20
20
|
- bin/furion
|
21
21
|
- lib/furion.rb
|
22
22
|
- lib/furion/file_editor.rb
|
23
|
+
- lib/furion/ver_conflict_detector.rb
|
23
24
|
homepage: https://rubygems.org/gems/furion
|
24
25
|
licenses:
|
25
26
|
- MIT
|