luna-binary-uploader 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +174 -0
- data/LICENSE.txt +21 -0
- data/README.md +44 -0
- data/Rakefile +2 -0
- data/bin/lbu +189 -0
- data/bin/setup +8 -0
- data/lib/luna/binary/analysis.rb +179 -0
- data/lib/luna/binary/build.rb +91 -0
- data/lib/luna/binary/common/common.rb +125 -0
- data/lib/luna/binary/delete.rb +50 -0
- data/lib/luna/binary/refresh.rb +75 -0
- data/lib/luna/binary/update.rb +118 -0
- data/lib/luna/binary/uploader/version.rb +7 -0
- data/lib/luna/binary/uploader.rb +410 -0
- data/luna-binary-uploader.gemspec +39 -0
- metadata +174 -0
@@ -0,0 +1,179 @@
|
|
1
|
+
require "luna/binary/uploader/version"
|
2
|
+
require "cocoapods"
|
3
|
+
require 'cocoapods-imy-bin/native/sources_manager'
|
4
|
+
require 'cocoapods-imy-bin/config/config'
|
5
|
+
require 'cocoapods-imy-bin'
|
6
|
+
require 'json'
|
7
|
+
require 'luna/binary/common/common'
|
8
|
+
|
9
|
+
|
10
|
+
module Luna
|
11
|
+
module Binary
|
12
|
+
class Analysis
|
13
|
+
|
14
|
+
attr_accessor :need_upload
|
15
|
+
attr_accessor :binary_path
|
16
|
+
|
17
|
+
|
18
|
+
def initialize
|
19
|
+
validate!
|
20
|
+
end
|
21
|
+
|
22
|
+
def validate!
|
23
|
+
arr = Dir.glob(Luna::Binary::Common.instance.podFilePath)
|
24
|
+
if arr == nil
|
25
|
+
raise '当前路径下没有Podfile'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def lockfile
|
30
|
+
return Luna::Binary::Common.instance.lockfile
|
31
|
+
end
|
32
|
+
|
33
|
+
def run
|
34
|
+
|
35
|
+
failList = []
|
36
|
+
successList = []
|
37
|
+
localPathMapper = {}
|
38
|
+
|
39
|
+
dependenciesMapper = lockfile.dependencies.map { |item| [item.name, item]}.to_h
|
40
|
+
dedupingMapper = {}
|
41
|
+
lockfile.pod_names.each { |item|
|
42
|
+
moduleName = item.split('/').first
|
43
|
+
if !moduleName["/"] && dedupingMapper[moduleName] == nil
|
44
|
+
dedupingMapper[moduleName] = moduleName
|
45
|
+
Pod::UserInterface.puts moduleName.yellow
|
46
|
+
if dependenciesMapper[moduleName]
|
47
|
+
lockContent = lockfile.dependencies_to_lock_pod_named(moduleName)
|
48
|
+
if lockContent #dependencies 应该拿不到所有的spec的依赖,我理解只能拿到podfile里面标明的,词典碰到dependency 没有bonmot的情况
|
49
|
+
lockContent.each { |lockItem|
|
50
|
+
begin
|
51
|
+
if lockItem.external_source == nil
|
52
|
+
uploader = uploadLintPodSpec(moduleName, lockItem.specific_version, binary_path)
|
53
|
+
if uploader != nil
|
54
|
+
successList << uploader
|
55
|
+
end
|
56
|
+
else
|
57
|
+
p lockItem.external_source
|
58
|
+
gitURL = lockItem.external_source['git'.parameterize.underscore.to_sym]
|
59
|
+
tag = lockItem.external_source['tag'.parameterize.underscore.to_sym]
|
60
|
+
path = lockItem.external_source['path'.parameterize.underscore.to_sym]
|
61
|
+
p "#{moduleName} git: #{gitURL} tag: #{tag} path: #{path}"
|
62
|
+
if path
|
63
|
+
pathArr = Dir.glob("#{Dir.pwd}/#{path}/**/#{moduleName}.podspec")
|
64
|
+
if pathArr
|
65
|
+
uploader = Luna::Binary::Uploader::SingleUploader.new(moduleName, "", "", binary_path)
|
66
|
+
uploader.specification=Pod::Specification.from_file(pathArr.first)
|
67
|
+
uploader.specificationWork
|
68
|
+
localPathMapper[moduleName] = pathArr.first
|
69
|
+
end
|
70
|
+
|
71
|
+
elsif gitURL && tag && !moduleName["/"]
|
72
|
+
uploader = Luna::Binary::Uploader::SingleUploader.new(moduleName, gitURL, tag, binary_path)
|
73
|
+
uploader.specificationWork
|
74
|
+
successList << uploader
|
75
|
+
end
|
76
|
+
end
|
77
|
+
rescue => exception
|
78
|
+
failList << exception
|
79
|
+
ensure
|
80
|
+
|
81
|
+
end
|
82
|
+
}
|
83
|
+
end
|
84
|
+
else
|
85
|
+
begin
|
86
|
+
uploader = uploadLintPodSpec(moduleName, lockfile.version(moduleName), binary_path)
|
87
|
+
if uploader != nil
|
88
|
+
successList << uploader
|
89
|
+
end
|
90
|
+
rescue => exception
|
91
|
+
failList << exception
|
92
|
+
ensure
|
93
|
+
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
}
|
98
|
+
p "-=-=-=-=-=-=-=-=-=-=-=-命令生成=-=-=-=-=-=-=-=-=-=-=-=-=-="
|
99
|
+
hasInCocopodsSpec = []
|
100
|
+
externalSpec = []
|
101
|
+
failPrint = []
|
102
|
+
|
103
|
+
successList.each { |item|
|
104
|
+
if item.gitUrl.length > 0
|
105
|
+
externalSpec << item
|
106
|
+
else
|
107
|
+
hasInCocopodsSpec << item
|
108
|
+
end
|
109
|
+
}
|
110
|
+
hasInCocopodsSpec.each { |item|
|
111
|
+
begin
|
112
|
+
item.printPreUploadCommand
|
113
|
+
rescue => exception
|
114
|
+
# p exception
|
115
|
+
failPrint << "#{exception}"
|
116
|
+
ensure
|
117
|
+
|
118
|
+
end
|
119
|
+
}
|
120
|
+
externalSpec.each { |item|
|
121
|
+
begin
|
122
|
+
item.printPreUploadCommand
|
123
|
+
rescue => exception
|
124
|
+
# p exception
|
125
|
+
failPrint << "#{exception}"
|
126
|
+
ensure
|
127
|
+
|
128
|
+
end
|
129
|
+
}
|
130
|
+
|
131
|
+
localPathMapper.each { |k,v|
|
132
|
+
p "lbu single #{k} #{v} #{binary_path}"
|
133
|
+
}
|
134
|
+
|
135
|
+
p "-=-=-=-=-=-=-=-=-=-=-=-命令生成end=-=-=-=-=-=-=-=-=-=-=-=-=-="
|
136
|
+
p "错误信息:#{failPrint}"
|
137
|
+
execUpload(hasInCocopodsSpec)
|
138
|
+
execUpload(externalSpec)
|
139
|
+
end
|
140
|
+
|
141
|
+
def findLintPodspec(moduleName)
|
142
|
+
return Luna::Binary::Common.instance.findLintPodspec(moduleName)
|
143
|
+
end
|
144
|
+
|
145
|
+
def uploadLintPodSpec(moduleName, specificVersion, binaryPath)
|
146
|
+
set = findLintPodspec(moduleName)
|
147
|
+
if set
|
148
|
+
pathArr = set.specification_paths_for_version(specificVersion)
|
149
|
+
if pathArr.length > 0
|
150
|
+
uploader = Luna::Binary::Uploader::SingleUploader.new(moduleName, "", "", binaryPath)
|
151
|
+
uploader.specification=Pod::Specification.from_file(pathArr.first)
|
152
|
+
uploader.specificationWork
|
153
|
+
end
|
154
|
+
end
|
155
|
+
return uploader
|
156
|
+
end
|
157
|
+
|
158
|
+
def execUpload(items)
|
159
|
+
if need_upload != nil && need_upload == "upload"
|
160
|
+
items.each { |item|
|
161
|
+
begin
|
162
|
+
item.upload
|
163
|
+
rescue => exception
|
164
|
+
p "异常上传过程中出现了:#{exception}"
|
165
|
+
else
|
166
|
+
|
167
|
+
end
|
168
|
+
|
169
|
+
}
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
def command(c)
|
174
|
+
return Luna::Binary::Common.instance.command(c)
|
175
|
+
end
|
176
|
+
|
177
|
+
end
|
178
|
+
end
|
179
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
require "luna/binary/uploader/version"
|
2
|
+
require "cocoapods"
|
3
|
+
require 'cocoapods-imy-bin/native/sources_manager'
|
4
|
+
require 'cocoapods-imy-bin/config/config'
|
5
|
+
require 'cocoapods-imy-bin'
|
6
|
+
require 'json'
|
7
|
+
require 'luna/binary/common/common'
|
8
|
+
|
9
|
+
module Luna
|
10
|
+
module Binary
|
11
|
+
class Build
|
12
|
+
attr_accessor :workspace
|
13
|
+
attr_accessor :scheme
|
14
|
+
def initialize
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
def run
|
19
|
+
createFrameworks
|
20
|
+
end
|
21
|
+
|
22
|
+
def command(c)
|
23
|
+
return Luna::Binary::Common.instance.command(c)
|
24
|
+
end
|
25
|
+
|
26
|
+
def createFrameworks
|
27
|
+
isNext = true
|
28
|
+
Pod::UserInterface.puts "请将二进制开关关闭,确保每个模块都是源码运行,因为二进制的因素有可能source缓存还是会引入二进制".yellow
|
29
|
+
Luna::Binary::Common.instance.deleteDirectory(Dir.pwd + "/Pods")
|
30
|
+
isNext = command("pod install")
|
31
|
+
Luna::Binary::Common.instance.deleteDirectory(binary_path_arm)
|
32
|
+
isNext = command("xcodebuild -workspace #{workspace} -scheme #{scheme} -configuration Debug -derivedDataPath '#{Dir.pwd}/build/arm' CONFIGURATION_BUILD_DIR='#{binary_path_arm}'") if isNext == true
|
33
|
+
Luna::Binary::Common.instance.deleteDirectory(binary_path_x86)
|
34
|
+
isNext = command("xcodebuild -workspace #{workspace} -scheme #{scheme} -configuration Debug -derivedDataPath '#{Dir.pwd}/build/x86' CONFIGURATION_BUILD_DIR='#{binary_path_x86}' -destination 'platform=iOS Simulator,name=iPhone 11'") if isNext == true
|
35
|
+
mergeFrameWorks(binary_path_arm, binary_path_x86) if isNext == true
|
36
|
+
end
|
37
|
+
|
38
|
+
def mergeFrameWorks(binary_path_arm, binary_path_x86)
|
39
|
+
Luna::Binary::Common.instance.deleteDirectory(binary_path_merged)
|
40
|
+
dedupingMapper = {}
|
41
|
+
lockfile.pod_names.each { |item|
|
42
|
+
if item["/"] == nil && dedupingMapper[item] == nil
|
43
|
+
Pod::UserInterface.puts item.yellow
|
44
|
+
armPath = findFramework(item,binary_path_arm)
|
45
|
+
x86Path = findFramework(item,binary_path_x86)
|
46
|
+
mergeFrameWork(item, armPath, x86Path) if armPath != nil && x86Path != nil
|
47
|
+
dedupingMapper[item] = item
|
48
|
+
end
|
49
|
+
}
|
50
|
+
|
51
|
+
Pod::UserInterface.puts "合并后的framework的路径为:#{binary_path_merged}".yellow
|
52
|
+
end
|
53
|
+
|
54
|
+
def lockfile
|
55
|
+
return Luna::Binary::Common.instance.lockfile
|
56
|
+
end
|
57
|
+
|
58
|
+
def xcodeSimulators
|
59
|
+
# simulators = JSON.parse(%x("xcodebuild -workspace #{workspace} -scheme #{scheme} -showdestinations"))
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
def mergeFrameWork(moduleName, path1, path2)
|
64
|
+
command("mkdir -p #{binary_path_merged}; cp -r #{File.dirname(path1)} #{binary_path_merged}; mv #{binary_path_merged}/#{File.basename(File.dirname(path1))} #{binary_path_merged}/#{moduleName};")
|
65
|
+
return command("lipo -create #{path2}/#{moduleName} #{path1}/#{moduleName} -output #{binary_path_merged}/#{moduleName}/#{moduleName}.framework/#{moduleName}")
|
66
|
+
end
|
67
|
+
|
68
|
+
def findFramework(moduleName, binary_path)
|
69
|
+
pathArr = Dir.glob("#{binary_path}/**/#{moduleName}.framework")
|
70
|
+
if pathArr != nil
|
71
|
+
return pathArr.first
|
72
|
+
else
|
73
|
+
return nil
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
|
78
|
+
def binary_path_merged
|
79
|
+
return Luna::Binary::Common.instance.binary_path_merged
|
80
|
+
end
|
81
|
+
|
82
|
+
def binary_path_arm
|
83
|
+
return Luna::Binary::Common.instance.binary_path_arm
|
84
|
+
end
|
85
|
+
|
86
|
+
def binary_path_x86
|
87
|
+
return Luna::Binary::Common.instance.binary_path_x86
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,125 @@
|
|
1
|
+
require "luna/binary/uploader/version"
|
2
|
+
require "cocoapods"
|
3
|
+
require 'cocoapods-imy-bin/native/sources_manager'
|
4
|
+
require 'cocoapods-imy-bin/config/config'
|
5
|
+
require 'cocoapods-imy-bin'
|
6
|
+
require 'json'
|
7
|
+
require 'singleton'
|
8
|
+
|
9
|
+
module Luna
|
10
|
+
module Binary
|
11
|
+
class Common
|
12
|
+
include Singleton
|
13
|
+
|
14
|
+
attr_accessor :version, :state
|
15
|
+
attr_accessor :podFilePath
|
16
|
+
attr_accessor :lockfile
|
17
|
+
|
18
|
+
def initialize()
|
19
|
+
end
|
20
|
+
|
21
|
+
def repoPath
|
22
|
+
sources = Pod::Config.instance.sources_manager.all
|
23
|
+
repoPath = nil
|
24
|
+
sources.each { |item|
|
25
|
+
if item.url == CBin.config.binary_repo_url
|
26
|
+
repoPath = item.repo
|
27
|
+
end
|
28
|
+
}
|
29
|
+
if repoPath == nil
|
30
|
+
raise '没找到repo路径'
|
31
|
+
end
|
32
|
+
return repoPath
|
33
|
+
end
|
34
|
+
|
35
|
+
def deleteDirectory(dirPath)
|
36
|
+
if File.directory?(dirPath)
|
37
|
+
Dir.foreach(dirPath) do |subFile|
|
38
|
+
if subFile != '.' and subFile != '..'
|
39
|
+
deleteDirectory(File.join(dirPath, subFile));
|
40
|
+
end
|
41
|
+
end
|
42
|
+
Dir.rmdir(dirPath);
|
43
|
+
else
|
44
|
+
if File.exist?(dirPath)
|
45
|
+
File.delete(dirPath);
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def tempLunaUploaderPath
|
51
|
+
result = `pwd`
|
52
|
+
rootName = result.strip! + "/temp-luna-uploader"
|
53
|
+
return rootName
|
54
|
+
end
|
55
|
+
|
56
|
+
def binary_path_merged
|
57
|
+
return tempLunaUploaderPath + "/merged"
|
58
|
+
end
|
59
|
+
|
60
|
+
def binary_path_arm
|
61
|
+
return tempLunaUploaderPath + "/arm64"
|
62
|
+
end
|
63
|
+
|
64
|
+
def binary_path_x86
|
65
|
+
return tempLunaUploaderPath + "/x86"
|
66
|
+
end
|
67
|
+
|
68
|
+
def podFilePath
|
69
|
+
result = `pwd`
|
70
|
+
@podFilePath = Pathname.new(result.strip! + "/Podfile.lock")
|
71
|
+
end
|
72
|
+
|
73
|
+
def command(c)
|
74
|
+
p c
|
75
|
+
return system c
|
76
|
+
end
|
77
|
+
|
78
|
+
def findLintPodspec(moduleName)
|
79
|
+
sets = Pod::Config.instance.sources_manager.search_by_name(moduleName)
|
80
|
+
# p sets
|
81
|
+
if sets.count == 1
|
82
|
+
set = sets.first
|
83
|
+
elsif sets.map(&:name).include?(moduleName)
|
84
|
+
set = sets.find { |s| s.name == moduleName }
|
85
|
+
else
|
86
|
+
names = sets.map(&:name) * ', '
|
87
|
+
# raise Informative, "More than one spec found for '#{moduleName}':\n#{names}"
|
88
|
+
end
|
89
|
+
return set
|
90
|
+
end
|
91
|
+
|
92
|
+
def lockfile
|
93
|
+
@lockfile ||= begin
|
94
|
+
Pod::Lockfile.from_file(podFilePath) if podFilePath.exist?
|
95
|
+
end
|
96
|
+
|
97
|
+
def use_framework_list
|
98
|
+
list = []
|
99
|
+
File.open(Dir.pwd+"/Podfile", 'r:utf-8') do |f|
|
100
|
+
f.each_line do |item|
|
101
|
+
if item[":dev_env_use_binary"]
|
102
|
+
matchs = item.match(/pod \'([\u4E00-\u9FA5A-Za-z0-9_-]+)\'/)
|
103
|
+
if matchs != nil
|
104
|
+
list << matchs[1]
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
return list
|
110
|
+
end
|
111
|
+
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
|
116
|
+
end
|
117
|
+
|
118
|
+
# def pushInRepo(name, version)
|
119
|
+
|
120
|
+
|
121
|
+
# end
|
122
|
+
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require "luna/binary/uploader/version"
|
2
|
+
require "cocoapods"
|
3
|
+
require 'cocoapods-imy-bin/native/sources_manager'
|
4
|
+
require 'cocoapods-imy-bin/config/config'
|
5
|
+
require 'cocoapods-imy-bin'
|
6
|
+
require 'json'
|
7
|
+
|
8
|
+
module Luna
|
9
|
+
module Binary
|
10
|
+
class Delete
|
11
|
+
attr_reader :name
|
12
|
+
attr_reader :version
|
13
|
+
|
14
|
+
def initialize(name, version)
|
15
|
+
@name = name
|
16
|
+
@version = version
|
17
|
+
validate!
|
18
|
+
end
|
19
|
+
|
20
|
+
def validate!
|
21
|
+
raise "缺少参数" unless name
|
22
|
+
raise "缺少参数" unless version
|
23
|
+
end
|
24
|
+
|
25
|
+
def delete
|
26
|
+
begin
|
27
|
+
deleteRepo
|
28
|
+
rescue => exception
|
29
|
+
|
30
|
+
ensure
|
31
|
+
deleteBinaryFramework
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def deleteRepo
|
36
|
+
command = "cd #{Luna::Binary::Common.instance.repoPath}; git stash;git checkout master;git pull origin master;"
|
37
|
+
system command
|
38
|
+
Luna::Binary::Common.instance.deleteDirectory("#{Luna::Binary::Common.instance.repoPath}/#{name}/#{version}")
|
39
|
+
commandADD = "cd #{Luna::Binary::Common.instance.repoPath};git add .; git commit -m 'DEL::#{name}-#{version} by LBU'; git push -f origin master"
|
40
|
+
system commandADD
|
41
|
+
end
|
42
|
+
|
43
|
+
def deleteBinaryFramework
|
44
|
+
command = "curl -X 'DELETE' #{CBin.config.binary_upload_url}/#{name}/#{version} -O -J"
|
45
|
+
p command
|
46
|
+
system command
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'luna/binary/common/common'
|
2
|
+
require 'luna/binary/delete'
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
module Luna
|
6
|
+
module Binary
|
7
|
+
class Refresh
|
8
|
+
attr_accessor :binary_path
|
9
|
+
attr_accessor :request_result_hash
|
10
|
+
|
11
|
+
def run
|
12
|
+
spec_repo_binary = createNeedFrameworkMapper
|
13
|
+
rootPath = "#{Luna::Binary::Common.instance.tempLunaUploaderPath}/refresh"
|
14
|
+
Luna::Binary::Common.instance.deleteDirectory("#{rootPath}")
|
15
|
+
system "mkdir -p #{rootPath};"
|
16
|
+
failList = []
|
17
|
+
spec_repo_binary.each { |k,v|
|
18
|
+
if request_result_hash[k] != nil && request_result_hash[k].include?(v)
|
19
|
+
begin
|
20
|
+
pathArr = Dir.glob("#{binary_path}/**/#{k.sub("-","_")}.framework")
|
21
|
+
if pathArr != nil
|
22
|
+
Pod::UserInterface.puts "#{pathArr.first} #{k}".yellow
|
23
|
+
srcPath = File.dirname(pathArr.first)
|
24
|
+
File.rename(srcPath, "#{rootPath}/#{k}")
|
25
|
+
system "cp -r #{srcPath} #{rootPath}; "
|
26
|
+
zipCommand = "cd #{rootPath};zip -r #{k}.zip #{k}"
|
27
|
+
p zipCommand
|
28
|
+
system zipCommand
|
29
|
+
Luna::Binary::Delete.new(k,v).deleteBinaryFramework
|
30
|
+
command = "cd #{rootPath};curl #{CBin.config.binary_upload_url} -F \"name=#{k}\" -F \"version=#{v}\" -F \"annotate=#{k}_#{v}_log\" -F \"file=@#{k}.zip\""
|
31
|
+
p command
|
32
|
+
system command
|
33
|
+
end
|
34
|
+
rescue => exception
|
35
|
+
p exception
|
36
|
+
failList << "#{k} #{exception}"
|
37
|
+
else
|
38
|
+
|
39
|
+
end
|
40
|
+
else
|
41
|
+
failList << "name: #{k}"
|
42
|
+
end
|
43
|
+
}
|
44
|
+
p "exception:#{failList}"
|
45
|
+
end
|
46
|
+
|
47
|
+
def lockfile
|
48
|
+
return Luna::Binary::Common.instance.lockfile
|
49
|
+
end
|
50
|
+
|
51
|
+
def request_result_hash
|
52
|
+
if @request_result_hash == nil
|
53
|
+
command = "curl #{CBin.config.binary_upload_url}"
|
54
|
+
p command
|
55
|
+
result = %x(#{command})
|
56
|
+
@request_result_hash = JSON.parse(result)
|
57
|
+
p @request_result_hash
|
58
|
+
end
|
59
|
+
return @request_result_hash
|
60
|
+
end
|
61
|
+
|
62
|
+
def createNeedFrameworkMapper
|
63
|
+
spec_repo_binary = {}
|
64
|
+
Pod::UserInterface.puts "二进制repo地址 : #{CBin.config.binary_repo_url}".yellow
|
65
|
+
Luna::Binary::Common.instance.use_framework_list.each { |item|
|
66
|
+
if spec_repo_binary[item] == nil && item["/"] == nil
|
67
|
+
name = item.split('/').first
|
68
|
+
spec_repo_binary[name] = lockfile.version(name).version
|
69
|
+
end
|
70
|
+
}
|
71
|
+
return spec_repo_binary
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,118 @@
|
|
1
|
+
require 'luna/binary/common/common'
|
2
|
+
require 'luna/binary/delete'
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
module Luna
|
6
|
+
module Binary
|
7
|
+
class Update
|
8
|
+
attr_accessor :binary_path
|
9
|
+
attr_accessor :request_result_hash
|
10
|
+
|
11
|
+
def run
|
12
|
+
spec_repo_binary = createNeedFrameworkMapper
|
13
|
+
rootPath = "#{Luna::Binary::Common.instance.tempLunaUploaderPath}/update"
|
14
|
+
Luna::Binary::Common.instance.deleteDirectory("#{rootPath}")
|
15
|
+
system "mkdir -p #{rootPath};"
|
16
|
+
failList = []
|
17
|
+
dependenciesMapper = lockfile.dependencies.map { |item| [item.name, item]}.to_h
|
18
|
+
spec_repo_binary.each { |k,v|
|
19
|
+
if request_result_hash[k] == nil || request_result_hash[k].include?(v) == false
|
20
|
+
moduleName = k
|
21
|
+
if dependenciesMapper[moduleName]
|
22
|
+
lockContent = lockfile.dependencies_to_lock_pod_named(moduleName)
|
23
|
+
if lockContent #dependencies 应该拿不到所有的spec的依赖,我理解只能拿到podfile里面标明的,词典碰到dependency 没有bonmot的情况
|
24
|
+
lockContent.each { |lockItem|
|
25
|
+
begin
|
26
|
+
if lockItem.external_source == nil
|
27
|
+
uploader = uploadLintPodSpec(moduleName, lockItem.specific_version, binary_path)
|
28
|
+
if uploader != nil
|
29
|
+
successList << uploader
|
30
|
+
end
|
31
|
+
else
|
32
|
+
p lockItem.external_source
|
33
|
+
gitURL = lockItem.external_source['git'.parameterize.underscore.to_sym]
|
34
|
+
tag = lockItem.external_source['tag'.parameterize.underscore.to_sym]
|
35
|
+
path = lockItem.external_source['path'.parameterize.underscore.to_sym]
|
36
|
+
p "#{moduleName} git: #{gitURL} tag: #{tag} path: #{path}"
|
37
|
+
if gitURL && tag && !moduleName["/"]
|
38
|
+
uploader = Luna::Binary::Uploader::SingleUploader.new(moduleName, gitURL, tag, binary_path)
|
39
|
+
uploader.specificationWork
|
40
|
+
successList << uploader
|
41
|
+
end
|
42
|
+
end
|
43
|
+
rescue => exception
|
44
|
+
# raise exception
|
45
|
+
ensure
|
46
|
+
|
47
|
+
end
|
48
|
+
}
|
49
|
+
end
|
50
|
+
else
|
51
|
+
begin
|
52
|
+
uploader = uploadLintPodSpec(moduleName, lockfile.version(moduleName), binary_path)
|
53
|
+
if uploader != nil
|
54
|
+
successList << uploader
|
55
|
+
end
|
56
|
+
rescue => exception
|
57
|
+
|
58
|
+
ensure
|
59
|
+
|
60
|
+
end
|
61
|
+
end
|
62
|
+
else
|
63
|
+
failList << "已存在name: #{k}"
|
64
|
+
end
|
65
|
+
}
|
66
|
+
|
67
|
+
successList.each { |item|
|
68
|
+
item.upload
|
69
|
+
}
|
70
|
+
p "exception:#{failList}"
|
71
|
+
end
|
72
|
+
|
73
|
+
def lockfile
|
74
|
+
return Luna::Binary::Common.instance.lockfile
|
75
|
+
end
|
76
|
+
|
77
|
+
def findLintPodspec(moduleName)
|
78
|
+
return Luna::Binary::Common.instance.findLintPodspec(moduleName)
|
79
|
+
end
|
80
|
+
|
81
|
+
def uploadLintPodSpec(moduleName, specificVersion, binaryPath)
|
82
|
+
set = findLintPodspec(moduleName)
|
83
|
+
if set
|
84
|
+
pathArr = set.specification_paths_for_version(specificVersion)
|
85
|
+
if pathArr.length > 0
|
86
|
+
uploader = Luna::Binary::Uploader::SingleUploader.new(moduleName, "", "", binaryPath)
|
87
|
+
uploader.specification=Pod::Specification.from_file(pathArr.first)
|
88
|
+
uploader.specificationWork
|
89
|
+
end
|
90
|
+
end
|
91
|
+
return uploader
|
92
|
+
end
|
93
|
+
|
94
|
+
def request_result_hash
|
95
|
+
if @request_result_hash == nil
|
96
|
+
command = "curl #{CBin.config.binary_upload_url}"
|
97
|
+
p command
|
98
|
+
result = %x(#{command})
|
99
|
+
@request_result_hash = JSON.parse(result)
|
100
|
+
p @request_result_hash
|
101
|
+
end
|
102
|
+
return @request_result_hash
|
103
|
+
end
|
104
|
+
|
105
|
+
def createNeedFrameworkMapper
|
106
|
+
spec_repo_binary = {}
|
107
|
+
Pod::UserInterface.puts "二进制repo地址 : #{CBin.config.binary_repo_url}".yellow
|
108
|
+
Luna::Binary::Common.instance.use_framework_list.each { |item|
|
109
|
+
if spec_repo_binary[item] == nil && item["/"] == nil
|
110
|
+
name = item.split('/').first
|
111
|
+
spec_repo_binary[name] = lockfile.version(name).version
|
112
|
+
end
|
113
|
+
}
|
114
|
+
return spec_repo_binary
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|