luna-binary-uploader 0.1.29 → 0.1.31
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/lbu +38 -34
- data/lib/luna/binary/build.rb +10 -0
- data/lib/luna/binary/common/common.rb +4 -4
- data/lib/luna/binary/init.rb +1 -1
- data/lib/luna/binary/uploader/version.rb +1 -1
- data/lib/luna/binary/uploader.rb +21 -6
- data/lib/luna/binary/util/file_processer.rb +111 -0
- data/lib/luna/binary/util/util.rb +40 -0
- data/lib/luna-binary-uploader.rb +1 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8dd0d0b6939b899cce6afd8f6facda8c39953c3087b36979c2946695a96aaa4e
|
4
|
+
data.tar.gz: 3802bd473598d0086a817bcbc717b432fb06df527a0bcc7ca5462faaca1136f9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8924d7c279fca47b5877d469a31e05f2340f203c3da2809538bb0ff3a59286f2e0324a5874fe6b35c8d77898db0f95bb8b3df79a9e1fb12cc3d7bb28935296d6
|
7
|
+
data.tar.gz: 219f74424351db948c80bc4c06de92857ba31e436f1634c891d7f9190ff105f25258518644a8875338268dac676650734e45630f18f3b7c633a518a45ee43274
|
data/bin/lbu
CHANGED
@@ -25,8 +25,12 @@ class App
|
|
25
25
|
arg_name 'url地址'
|
26
26
|
command :init do |c|
|
27
27
|
c.action do |global_options,options,args|
|
28
|
-
help_now!('url is required') if args.empty?
|
29
|
-
|
28
|
+
# help_now!('url is required') if args.empty?
|
29
|
+
templateFileUrl = 'http://ydlunacommon-cdn.nosdn.127.net/38cb10ff0440170ca11d93d02e4ed562.yml'
|
30
|
+
if args.count > 0
|
31
|
+
templateFileUrl = args[0]
|
32
|
+
end
|
33
|
+
Luna::Binary::Init.new(templateFileUrl)
|
30
34
|
end
|
31
35
|
end
|
32
36
|
|
@@ -49,13 +53,15 @@ class App
|
|
49
53
|
desc '单个上传二进制文件'
|
50
54
|
arg_name 'a.模块名 git地址 git节点 xcode编译的缓存地址 \n b.模块名 版本号 xcode编译的缓存地址 \n c.模块名 本地podspec地址 xcode编译的缓存地址'
|
51
55
|
command :single do |c|
|
56
|
+
c.desc '强制上传 -f or --force'
|
57
|
+
c.switch [:f,:force]
|
52
58
|
c.action do |global_options,options,args|
|
53
59
|
if args[3] #模式1
|
54
60
|
Luna::Binary::Uploader::SingleUploader.new(args[0],args[1],args[2], args[3]).upload
|
55
61
|
else
|
56
62
|
moduleName = args[0]
|
57
63
|
args1 = args[1]
|
58
|
-
binaryPath= args[2]
|
64
|
+
binaryPath= args[2] != nil ? args[2] : Luna::Binary::Common.instance.binary_path_merged
|
59
65
|
version = args1
|
60
66
|
if File.exist?(args1)
|
61
67
|
spec = Pod::Specification.from_file(Pathname.new(args1))
|
@@ -70,6 +76,11 @@ class App
|
|
70
76
|
spec = Pod::Specification.from_file(pathArr.first)
|
71
77
|
uploader = Luna::Binary::Uploader::SingleUploader.new(moduleName, "", "", binaryPath)
|
72
78
|
uploader.specification=spec
|
79
|
+
if options[:force]
|
80
|
+
puts '先删除现有的: ' + moduleName + " " + version
|
81
|
+
uploader.refresh_specification_work
|
82
|
+
Luna::Binary::Delete.new(moduleName, version).delete
|
83
|
+
end
|
73
84
|
uploader.upload
|
74
85
|
else
|
75
86
|
raise "没有找到#{moduleName}"
|
@@ -116,8 +127,9 @@ class App
|
|
116
127
|
command :refresh do |c|
|
117
128
|
c.desc '是否需要build, 不需要的话 -n or --no'
|
118
129
|
c.switch [:n,:no]
|
130
|
+
c.desc '是否快速执行, -q or --quick 开启后将不会重新执行pod install'
|
119
131
|
c.switch [:q,:quick]
|
120
|
-
c.action do |global_options,options,args|
|
132
|
+
c.action do |global_options, options, args|
|
121
133
|
if options[:no]
|
122
134
|
obj = Luna::Binary::Refresh.new()
|
123
135
|
if args[0] != nil
|
@@ -127,16 +139,7 @@ class App
|
|
127
139
|
end
|
128
140
|
obj.run
|
129
141
|
else
|
130
|
-
|
131
|
-
help_now!('workspace is required') if args[0] == nil
|
132
|
-
help_now!('scheme is required') if args[1] == nil
|
133
|
-
build = Luna::Binary::Build.new()
|
134
|
-
build.workspace=args[0]
|
135
|
-
build.scheme=args[1]
|
136
|
-
if options[:quick]
|
137
|
-
build.needPodInstall = false
|
138
|
-
end
|
139
|
-
if build.run
|
142
|
+
if build(global_options, options, args)
|
140
143
|
obj = Luna::Binary::Refresh.new()
|
141
144
|
obj.binary_path = Luna::Binary::Common.instance.binary_path_merged
|
142
145
|
obj.run
|
@@ -146,21 +149,29 @@ class App
|
|
146
149
|
end
|
147
150
|
end
|
148
151
|
|
152
|
+
def self.build(global_options, options, args)
|
153
|
+
workspace = args[0] != nil ? args[0] : Luna::Binary::Common.instance.bin_dev['workspace']
|
154
|
+
scheme = args[1] != nil ? args[1] : Luna::Binary::Common.instance.bin_dev['scheme']
|
155
|
+
help_now!('workspace is required and no config in bin_config.yml') if workspace == nil
|
156
|
+
help_now!('scheme is required and no config in bin_config.yml') if scheme == nil
|
157
|
+
build = Luna::Binary::Build.new()
|
158
|
+
build.workspace = workspace
|
159
|
+
build.scheme = scheme
|
160
|
+
if options[:quick]
|
161
|
+
build.needPodInstall = false
|
162
|
+
else
|
163
|
+
build.needPodInstall = true
|
164
|
+
end
|
165
|
+
build.run
|
166
|
+
end
|
167
|
+
|
149
168
|
desc 'build项目并合成带有arm64&x86的framework'
|
150
169
|
arg_name '1.xcworkspace 名称 eg:MyWorkSpace.xcworkspace 2.scheme eg: MyProject'
|
151
170
|
command :build do |c|
|
171
|
+
c.desc '是否快速执行, -q or --quick 开启后将不会重新执行pod install'
|
152
172
|
c.switch [:q,:quick]
|
153
|
-
c.action do |global_options,options,args|
|
154
|
-
|
155
|
-
help_now!('workspace is required') if args[0] == nil
|
156
|
-
help_now!('scheme is required') if args[1] == nil
|
157
|
-
obj = Luna::Binary::Build.new()
|
158
|
-
obj.workspace=args[0]
|
159
|
-
obj.scheme=args[1]
|
160
|
-
if options[:quick]
|
161
|
-
build.needPodInstall = false
|
162
|
-
end
|
163
|
-
obj.run
|
173
|
+
c.action do |global_options, options, args|
|
174
|
+
build(global_options, options, args)
|
164
175
|
end
|
165
176
|
end
|
166
177
|
|
@@ -200,6 +211,7 @@ class App
|
|
200
211
|
command :publish do |c|
|
201
212
|
c.desc '是否需要build, 不需要的话 -n or --no'
|
202
213
|
c.switch [:n,:no]
|
214
|
+
c.desc '是否快速执行, -q or --quick 开启后将不会重新执行pod install'
|
203
215
|
c.switch [:q,:quick]
|
204
216
|
c.action do |global_options,options,args|
|
205
217
|
if options[:no]
|
@@ -211,15 +223,7 @@ class App
|
|
211
223
|
end
|
212
224
|
update.run
|
213
225
|
else
|
214
|
-
|
215
|
-
help_now!('scheme is required') if args[1] == nil
|
216
|
-
build = Luna::Binary::Build.new()
|
217
|
-
build.workspace=args[0]
|
218
|
-
build.scheme=args[1]
|
219
|
-
if options[:quick]
|
220
|
-
build.needPodInstall = false
|
221
|
-
end
|
222
|
-
if build.run
|
226
|
+
if build(global_options, options, args)
|
223
227
|
update = Luna::Binary::Update.new()
|
224
228
|
update.binary_path = Luna::Binary::Common.instance.binary_path_merged
|
225
229
|
update.run
|
data/lib/luna/binary/build.rb
CHANGED
@@ -5,6 +5,7 @@ require 'cocoapods-imy-bin/config/config'
|
|
5
5
|
require 'cocoapods-imy-bin'
|
6
6
|
require 'json'
|
7
7
|
require 'luna/binary/common/common'
|
8
|
+
require 'luna/binary/util/file_processer'
|
8
9
|
|
9
10
|
module Luna
|
10
11
|
module Binary
|
@@ -89,6 +90,15 @@ module Luna
|
|
89
90
|
def mergeFrameWork(moduleName, path1, path2)
|
90
91
|
command("mkdir -p #{binary_path_merged}; cp -r #{File.dirname(path1)} #{binary_path_merged}; cp -r #{File.dirname(path2)} #{binary_path_merged}; mv #{binary_path_merged}/#{File.basename(File.dirname(path1))} #{binary_path_merged}/#{moduleName};")
|
91
92
|
framework_name = moduleName.gsub("-", "_")
|
93
|
+
|
94
|
+
# 修复Xcode14编译出来的framework里的header写死了x86判断的问题
|
95
|
+
FileProcesserManager.new("#{binary_path_merged}/#{moduleName}/#{framework_name}.framework/Headers/*",
|
96
|
+
[
|
97
|
+
FileProcesser.new(-> (fileContent) {
|
98
|
+
return fileContent.sub( "#elif defined(__x86_64__) && __x86_64__", "#elif (defined(__x86_64__) && __x86_64__) || (defined(__arm64__) && __arm64__)" )
|
99
|
+
})
|
100
|
+
]).process()
|
101
|
+
|
92
102
|
return command("lipo -create #{path2}/#{framework_name} #{path1}/#{framework_name} -output #{binary_path_merged}/#{moduleName}/#{framework_name}.framework/#{framework_name}")
|
93
103
|
end
|
94
104
|
|
@@ -76,9 +76,9 @@ module Luna
|
|
76
76
|
@podFilePath = Pathname.new(result.strip! + "/Podfile.lock")
|
77
77
|
end
|
78
78
|
|
79
|
-
def command(
|
80
|
-
|
81
|
-
return system
|
79
|
+
def command(commandStr)
|
80
|
+
puts commandStr.yellow
|
81
|
+
return system commandStr
|
82
82
|
end
|
83
83
|
|
84
84
|
def findLintPodspec(moduleName)
|
@@ -221,7 +221,7 @@ module Luna
|
|
221
221
|
|
222
222
|
def bin_dev
|
223
223
|
if @bin_dev == nil
|
224
|
-
@bin_dev = YAML.load_file("
|
224
|
+
@bin_dev = YAML.load_file("./bin_config.yml")
|
225
225
|
end
|
226
226
|
return @bin_dev
|
227
227
|
end
|
data/lib/luna/binary/init.rb
CHANGED
@@ -16,7 +16,7 @@ module Luna
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def run
|
19
|
-
Common.instance.command("curl -o
|
19
|
+
Common.instance.command("curl -o ./bin_config.yml #{url}")
|
20
20
|
Common.instance.command("pod repo add z-ios-framework-spec-repo #{Common.instance.binary_repo_url}")
|
21
21
|
end
|
22
22
|
|
data/lib/luna/binary/uploader.rb
CHANGED
@@ -37,7 +37,6 @@ module Luna
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def upload
|
40
|
-
specificationWork
|
41
40
|
push
|
42
41
|
end
|
43
42
|
|
@@ -72,16 +71,32 @@ module Luna
|
|
72
71
|
|
73
72
|
ensure
|
74
73
|
download_git
|
75
|
-
|
76
|
-
if
|
77
|
-
|
78
|
-
|
79
|
-
else
|
74
|
+
|
75
|
+
if local_path != nil
|
76
|
+
localSpecUpVersion
|
77
|
+
elsif isHasSpecInRepo == true || isHasFrameworkInService == true
|
80
78
|
raise "已存在repo or 二进制服务 #{specification.name} #{specification.version}"
|
81
79
|
end
|
80
|
+
|
81
|
+
|
82
|
+
@spec = createFrameworkSpec
|
83
|
+
write_spec_file(@spec)
|
82
84
|
end
|
83
85
|
end
|
84
86
|
|
87
|
+
def localSpecUpVersion
|
88
|
+
nowTime = Time.now
|
89
|
+
timeStamp = "#{nowTime.year}-#{nowTime.month}-#{nowTime.day}"
|
90
|
+
specification.version = Util.writeVersionUp(local_path, specification.version)
|
91
|
+
branchName = "lbu-#{timeStamp}"
|
92
|
+
command("git checkout -b #{branchName}")
|
93
|
+
# 保证最新节点防止push不上去
|
94
|
+
command("git pull origin #{branchName}")
|
95
|
+
command("git add #{local_path};")
|
96
|
+
command("git commit -m 'Mod: 修改版本号为:#{specification.version.to_s} by LBU';")
|
97
|
+
command("git push -f origin #{branchName}")
|
98
|
+
end
|
99
|
+
|
85
100
|
def refresh_specification_work
|
86
101
|
begin
|
87
102
|
clearTempFile
|
@@ -0,0 +1,111 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
$LOAD_PATH << '.'
|
4
|
+
|
5
|
+
class YDFileUtils
|
6
|
+
def self.writeFile (filePath, buffer)
|
7
|
+
File.open(filePath, "w") { |source_file|
|
8
|
+
source_file.write buffer
|
9
|
+
}
|
10
|
+
return
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class FileProcesserInterface
|
15
|
+
def process(filePath)
|
16
|
+
puts filePath
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
class FileProcesser < FileProcesserInterface
|
21
|
+
def initialize(processFunc)
|
22
|
+
@processFunc = processFunc
|
23
|
+
end
|
24
|
+
|
25
|
+
def process(filePath)
|
26
|
+
fileContent = File.read(filePath)
|
27
|
+
result = @processFunc.call(fileContent)
|
28
|
+
File.write(filePath, result)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
class RegexFileProcesser < FileProcesserInterface
|
33
|
+
|
34
|
+
def initialize(regex, genLineFunc)
|
35
|
+
@regex = regex
|
36
|
+
@genLineFunc = genLineFunc
|
37
|
+
end
|
38
|
+
|
39
|
+
def process(filePath)
|
40
|
+
buffer = ""
|
41
|
+
IO.foreach(filePath) { |line|
|
42
|
+
current_number_regex = line =~ @regex
|
43
|
+
if current_number_regex
|
44
|
+
regexCatchedValue = $~
|
45
|
+
buffer += line.gsub(@regex, @genLineFunc.call(regexCatchedValue))
|
46
|
+
else
|
47
|
+
buffer += line
|
48
|
+
end
|
49
|
+
}
|
50
|
+
YDYDFileUtils.writeFile(filePath, buffer)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
|
56
|
+
class FileProcesserManager
|
57
|
+
|
58
|
+
def initialize(files, fileProcesserList)
|
59
|
+
@files = files
|
60
|
+
@fileProcesserList = fileProcesserList
|
61
|
+
end
|
62
|
+
|
63
|
+
private def getFiles()
|
64
|
+
mappingFiles = Dir::glob(@files)
|
65
|
+
return mappingFiles
|
66
|
+
end
|
67
|
+
|
68
|
+
private def processFile(filePath)
|
69
|
+
@fileProcesserList.each { |processer|
|
70
|
+
processer.process(filePath)
|
71
|
+
}
|
72
|
+
end
|
73
|
+
|
74
|
+
public def process()
|
75
|
+
ocFiles = getFiles()
|
76
|
+
puts "共发现 #{ocFiles.count} 个文件可能需要替换"
|
77
|
+
|
78
|
+
@@count = 0
|
79
|
+
ocFiles.each do |filePath|
|
80
|
+
processFile(filePath)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
##### 最简调用示例
|
86
|
+
# FileProcesserManager.new("../**/*.{m,mm}", [FileProcesserInterface.new()]).process()
|
87
|
+
|
88
|
+
#### 通过 RegexFileProcesser 处理文件
|
89
|
+
# FileProcesserManager.new("../YoudaoDict/Vendor/SwipeView/SwipeView.m",
|
90
|
+
# [
|
91
|
+
# RegexFileProcesser.new(/SwipeView/, -> (regexCatchedValue) {
|
92
|
+
# return "#{regexCatchedValue.to_s}aaa"
|
93
|
+
# })
|
94
|
+
# ]).process()
|
95
|
+
|
96
|
+
#### 通过gsub处理文件
|
97
|
+
# FileProcesserManager.new("../YoudaoDict/Vendor/SwipeView/SwipeView.m",
|
98
|
+
# [
|
99
|
+
# FileProcesser.new(-> (fileContent) {
|
100
|
+
# fileContent.gsub(/(SwipeView)/, "aaa\\1")
|
101
|
+
# })
|
102
|
+
# ]).process()
|
103
|
+
|
104
|
+
# FileProcesserManager.new("../YoudaoDict/Vendor/SwipeView/SwipeView.m",
|
105
|
+
# [
|
106
|
+
# FileProcesser.new(-> (fileContent) {
|
107
|
+
# fileContent.gsub(/(SwipeView)/) do |ste|
|
108
|
+
# "#{$1} use gsub block"
|
109
|
+
# end
|
110
|
+
# })
|
111
|
+
# ]).process()
|
@@ -0,0 +1,40 @@
|
|
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
|
+
class Util
|
12
|
+
def initialize
|
13
|
+
super.initialize
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.versionUp(version)
|
17
|
+
newVersion = "#{version.major}.#{version.minor}.#{version.patch + 1}"
|
18
|
+
return Pod::Version.new(newVersion)
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.writeVersionUp(path, version)
|
22
|
+
newVersion = versionUp(version)
|
23
|
+
buffer = ""
|
24
|
+
File.open(path, 'r:utf-8') do |f|
|
25
|
+
f.each_line do |item|
|
26
|
+
if item[".version"]
|
27
|
+
buffer += item.gsub(/(\.version *= *')(.*')/, "\\1" + newVersion.to_s + "'")
|
28
|
+
else
|
29
|
+
buffer += item
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
File.open(path, 'w+') do |f|
|
35
|
+
f.write(buffer)
|
36
|
+
end
|
37
|
+
return newVersion
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/lib/luna-binary-uploader.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: luna-binary-uploader
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.31
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- 车德超
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-09-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -153,6 +153,8 @@ files:
|
|
153
153
|
- lib/luna/binary/update.rb
|
154
154
|
- lib/luna/binary/uploader.rb
|
155
155
|
- lib/luna/binary/uploader/version.rb
|
156
|
+
- lib/luna/binary/util/file_processer.rb
|
157
|
+
- lib/luna/binary/util/util.rb
|
156
158
|
- luna-binary-uploader.gemspec
|
157
159
|
homepage: https://github.com/YoudaoMobile/luna-binary-uploader
|
158
160
|
licenses:
|