luna-binary-uploader 0.1.17 → 0.1.21

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5d663fbfaa88152aedca42571e25b0b406f606f8d891c2e425ea5b94f726113d
4
- data.tar.gz: dc877ae8656c5fd30f93f1e3d273e5b3652b6ed4cd654da9030c314353e56aa2
3
+ metadata.gz: c35f885ef76e95875084e78aef96e601a6ab189bfbaf12a3d8564bcf1997c1b6
4
+ data.tar.gz: 84241a1e0ef378017077aedde663beeda591d8348670b4c6a95142e32b9383f7
5
5
  SHA512:
6
- metadata.gz: 47d554b5f86b1562d277a923dc363fe5ed0e22191d5f65f9aa26034a7bdc9ab35f4a9ca4a1bb0a42555a7f71256620b8286fc8aa51b9e592fec10b0a6df6ae73
7
- data.tar.gz: 7d6c49478e2a77cd2fadd69025335fbe1c9600d786efa4a23c23455537940d31db9e3c413b8c5138fb7b0ba8766b0ef07b60a0c779ea6cbd5bc57c6ac6e7eb4f
6
+ metadata.gz: dd2e1662d7698405f2ca17f9296b689f319e1ac9f9da8ebd91c3f472539a4bed7395364758e97047857de27dbcc5c267d5aba7ec8f5abc28db03b6f803f8a27d
7
+ data.tar.gz: 7f80e36a16f32319013ea7f61f643e8582d39faaa79ef6bd28e421c5e22d7dd3756d1729fcd23875c459c981fb2fb81a679af070c0e0734fb4440716b81a3a4d
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- luna-binary-uploader (0.1.17)
4
+ luna-binary-uploader (0.1.21)
5
5
  cocoapods
6
6
  cocoapods-generate (~> 2.0.1)
7
7
  cocoapods-imy-bin (= 0.3.1.3)
data/bin/lbu CHANGED
@@ -1,14 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require "bundler/setup"
4
- require "luna/binary/uploader"
5
- require "luna/binary/delete"
6
- require "luna/binary/analysis"
7
- require "luna/binary/refresh"
8
- require "luna/binary/build"
9
- require "luna/binary/update"
10
- require "luna/binary/install"
11
- require "luna/binary/init"
4
+ require "luna-binary-uploader"
12
5
  require 'gli'
13
6
 
14
7
  # You can add fixtures and/or initialization code here to make experimenting
@@ -21,7 +14,7 @@ require 'gli'
21
14
  class App
22
15
  extend GLI::App
23
16
 
24
- program_desc 'luna cocopods-imy-bin自定义二进制上传'
17
+ program_desc 'luna-binary-uploader 自定义二进制上传'
25
18
 
26
19
  version Luna::Binary::Uploader::VERSION
27
20
 
@@ -73,9 +66,10 @@ class App
73
66
  arg_name '只接参数n, 表示不用二进制 '
74
67
  command :install do |c|
75
68
  c.action do |global_options,options,args|
76
- is_open = "false"
77
69
  if args[0] && args[0] != "n"
78
70
  raise "只接参数n, 表示不用二进制"
71
+ elsif args[0] && args[0] == "n"
72
+ is_open = "false"
79
73
  else
80
74
  is_open = "true"
81
75
  end
@@ -84,7 +78,7 @@ class App
84
78
  end
85
79
 
86
80
  desc '单个上传二进制文件'
87
- arg_name '1.模块名 git地址 git节点 xcode编译的缓存地址 \n 2.模块名 版本号 xcode编译的缓存地址 \n 3.模块名 本地podspec地址 xcode编译的缓存地址'
81
+ arg_name 'a.模块名 git地址 git节点 xcode编译的缓存地址 \n b.模块名 版本号 xcode编译的缓存地址 \n c.模块名 本地podspec地址 xcode编译的缓存地址'
88
82
  command :single do |c|
89
83
  c.action do |global_options,options,args|
90
84
  if args[3] #模式1
@@ -123,10 +117,14 @@ class App
123
117
  end
124
118
 
125
119
  desc '单个删除repo 里的podspec & 服务二进制文件'
126
- arg_name '模块名 版本号'
120
+ arg_name '1.模块名 2.版本号'
127
121
  command :del do |c|
128
122
  c.action do |global_options,options,args|
129
- Luna::Binary::Delete.new(args[0],args[1]).delete
123
+ if args[0] && args[1]
124
+ Luna::Binary::Delete.new(args[0],args[1]).delete
125
+ else
126
+ raise "缺少参数:1.模块名 2.版本号"
127
+ end
130
128
  end
131
129
  end
132
130
 
@@ -177,10 +175,14 @@ class App
177
175
  arg_name '1.xcworkspace 名称 eg:MyWorkSpace.xcworkspace 2.scheme eg: MyProject'
178
176
  command :build do |c|
179
177
  c.action do |global_options,options,args|
178
+ if args[0] && args[1]
180
179
  obj = Luna::Binary::Build.new()
181
180
  obj.workspace=args[0]
182
181
  obj.scheme=args[1]
183
182
  obj.run
183
+ else
184
+ raise "缺少参数:1.xcworkspace 名称 eg:MyWorkSpace.xcworkspace 2.scheme eg: MyProject"
185
+ end
184
186
  end
185
187
  end
186
188
 
@@ -188,8 +190,28 @@ class App
188
190
  arg_name '1.armPath 2.x86path'
189
191
  command :merge do |c|
190
192
  c.action do |global_options,options,args|
193
+ if args[0] && args[1]
191
194
  obj = Luna::Binary::Build.new()
192
195
  obj.mergeFrameWorks(args[0], args[1])
196
+ else
197
+ raise "缺少参数:1.armPath 2.x86path"
198
+ end
199
+ end
200
+ end
201
+
202
+ desc 'benchmark 二进制和非二进制'
203
+ arg_name '1.跑工程几次 2.workspace 3.scheme 4.normal正常模式下 binary二进制模式下,不传的话都跑'
204
+ command :benchmark do |c|
205
+ c.action do |global_options,options,args|
206
+ obj = Luna::Binary::BenchMark.new(Integer(args[0]), args[1], args[2])
207
+ if args[3] == "normal"
208
+ obj.run_no_binary
209
+ elsif args[3] == "binary"
210
+ obj.run_binary
211
+ else
212
+ obj.run
213
+ end
214
+ obj.print
193
215
  end
194
216
  end
195
217
 
@@ -20,21 +20,21 @@ module Luna
20
20
  end
21
21
 
22
22
  def validate!
23
- arr = Dir.glob(Luna::Binary::Common.instance.podFilePath)
23
+ arr = Dir.glob(Common.instance.podFilePath)
24
24
  if arr == nil
25
25
  raise '当前路径下没有Podfile'
26
26
  end
27
27
  end
28
28
 
29
29
  def lockfile
30
- return Luna::Binary::Common.instance.lockfile
30
+ return Common.instance.lockfile
31
31
  end
32
32
 
33
33
  def run
34
34
  failList = []
35
35
  successList = []
36
36
 
37
- dependenciesMapper = Luna::Binary::Common.instance.dependenciesMapper
37
+ dependenciesMapper = Common.instance.dependenciesMapper
38
38
  dedupingMapper = {}
39
39
  lockfile.pod_names.each { |item|
40
40
  moduleName = item.split('/').first
@@ -42,7 +42,7 @@ module Luna
42
42
  dedupingMapper[moduleName] = moduleName
43
43
  puts moduleName.yellow
44
44
  begin
45
- uploader = Luna::Binary::Common.instance.upload_lockitem(dependenciesMapper, moduleName, binary_path)
45
+ uploader = Common.instance.upload_lockitem(dependenciesMapper, moduleName, binary_path)
46
46
  if uploader != nil
47
47
  successList << uploader
48
48
  else
@@ -133,7 +133,7 @@ module Luna
133
133
  end
134
134
 
135
135
  def command(c)
136
- return Luna::Binary::Common.instance.command(c)
136
+ return Common.instance.command(c)
137
137
  end
138
138
 
139
139
  end
@@ -0,0 +1,115 @@
1
+ require 'date'
2
+ require "luna/binary/uploader/version"
3
+ require "cocoapods"
4
+ require 'cocoapods-imy-bin/native/sources_manager'
5
+ require 'cocoapods-imy-bin/config/config'
6
+ require 'cocoapods-imy-bin'
7
+ require 'json'
8
+ require 'luna/binary/common/common'
9
+
10
+
11
+ module Luna
12
+ module Binary
13
+
14
+ class DogTimer
15
+
16
+ attr_accessor :start_time
17
+ attr_accessor :end_time
18
+ attr_accessor :delta_time
19
+ def initialize()
20
+
21
+ end
22
+
23
+ def start
24
+ @start_time = Time.now()
25
+ puts start_time
26
+ end
27
+
28
+ def end
29
+ @end_time = Time.now()
30
+ puts end_time
31
+ end
32
+
33
+ def delta
34
+ @delta_time = @end_time - @start_time
35
+ end
36
+
37
+ def print
38
+ puts "start time: #{start_time.inspect} end time: #{end_time.inspect} delta time: #{delta}s ".yellow
39
+ end
40
+ end
41
+
42
+ class BenchMark
43
+ attr_reader :times
44
+ attr_reader :workspace
45
+ attr_reader :scheme
46
+ attr_reader :binary_time_arr
47
+ attr_reader :normal_time_arr
48
+
49
+ def initialize(times, workspace, scheme)
50
+ @times = times
51
+ @workspace = workspace
52
+ @scheme = scheme
53
+ @binary_time_arr = []
54
+ @normal_time_arr = []
55
+ end
56
+
57
+ def run
58
+ run_binary
59
+ run_no_binary
60
+ end
61
+
62
+ def run_binary
63
+ i = 0
64
+ Common.instance.command("lbu install")
65
+ while i < times
66
+ t = DogTimer.new()
67
+ t.start
68
+ Common.instance.command("xcodebuild -workspace #{workspace} -scheme #{scheme} -configuration Debug")
69
+ t.end
70
+ binary_time_arr << t
71
+ i = i + 1
72
+ end
73
+ end
74
+
75
+ def run_no_binary
76
+ Common.instance.command("lbu install n")
77
+ i = 0
78
+ while i < times
79
+ t = DogTimer.new()
80
+ t.start
81
+ Common.instance.command("xcodebuild -workspace #{workspace} -scheme #{scheme} -configuration Debug")
82
+ t.end
83
+ normal_time_arr << t
84
+ i = i + 1
85
+ end
86
+ end
87
+
88
+
89
+ def print
90
+ i = 0
91
+ sum_time = 0
92
+ normal_time_arr.each { |item|
93
+ item.print
94
+ sum_time += item.delta
95
+ p sum_time
96
+ i += 1
97
+ }
98
+
99
+ puts "normal average time: #{sum_time/i}"
100
+ i = 0
101
+ sum_time = 0
102
+ binary_time_arr.each { |item|
103
+ item.print
104
+ sum_time += item.delta
105
+ p sum_time
106
+ i += 1
107
+ }
108
+ puts "binary average time: #{sum_time/i}"
109
+ end
110
+ end
111
+
112
+
113
+ end
114
+ end
115
+
@@ -20,27 +20,25 @@ module Luna
20
20
  end
21
21
 
22
22
  def command(c)
23
- return Luna::Binary::Common.instance.command(c)
23
+ return Common.instance.command(c)
24
24
  end
25
25
 
26
26
  def createFrameworks
27
27
  isNext = true
28
28
  puts "请将二进制开关关闭,确保每个模块都是源码运行,因为二进制的因素有可能source缓存还是会引入二进制".yellow
29
- command("rm -rf #{Dir.pwd}/Pods")
30
-
31
- isNext = command("pod install")
32
- Luna::Binary::Common.instance.deleteDirectory(binary_path_arm)
33
- tempLunaUploaderPath = Luna::Binary::Common.instance.tempLunaUploaderPath
29
+ Install.new(false)
30
+ Common.instance.deleteDirectory(binary_path_arm)
31
+ tempLunaUploaderPath = Common.instance.tempLunaUploaderPath
34
32
  isNext = command("xcodebuild -workspace #{workspace} -scheme #{scheme} -configuration Debug -derivedDataPath '#{tempLunaUploaderPath}/build/arm/temp'") if isNext == true
35
33
  isNext = command("cp -r #{tempLunaUploaderPath}/build/arm/temp/Build/Products/Debug-iphoneos #{binary_path_arm}") if isNext == true #本可以用CONFIGURATION_BUILD_DIR直接指定结果文件夹,结果经常性的编译报错
36
- Luna::Binary::Common.instance.deleteDirectory(binary_path_x86)
34
+ Common.instance.deleteDirectory(binary_path_x86)
37
35
  isNext = command("xcodebuild -workspace #{workspace} -scheme #{scheme} -configuration Debug -derivedDataPath '#{tempLunaUploaderPath}/build/x86/temp' -destination 'platform=iOS Simulator,name=iPhone 11'") if isNext == true
38
36
  isNext = command("cp -r #{tempLunaUploaderPath}/build/x86/temp/Build/Products/Debug-iphonesimulator #{binary_path_x86}") if isNext == true
39
37
  mergeFrameWorks(binary_path_arm, binary_path_x86) if isNext == true
40
38
  end
41
39
 
42
40
  def mergeFrameWorks(binary_path_arm, binary_path_x86)
43
- Luna::Binary::Common.instance.deleteDirectory(binary_path_merged)
41
+ Common.instance.deleteDirectory(binary_path_merged)
44
42
  dedupingMapper = {}
45
43
  failList = []
46
44
  p lockfile.pod_names
@@ -74,7 +72,7 @@ module Luna
74
72
  end
75
73
 
76
74
  def lockfile
77
- return Luna::Binary::Common.instance.lockfile
75
+ return Common.instance.lockfile
78
76
  end
79
77
 
80
78
  def xcodeSimulators
@@ -99,15 +97,15 @@ module Luna
99
97
 
100
98
 
101
99
  def binary_path_merged
102
- return Luna::Binary::Common.instance.binary_path_merged
100
+ return Common.instance.binary_path_merged
103
101
  end
104
102
 
105
103
  def binary_path_arm
106
- return Luna::Binary::Common.instance.binary_path_arm
104
+ return Common.instance.binary_path_arm
107
105
  end
108
106
 
109
107
  def binary_path_x86
110
- return Luna::Binary::Common.instance.binary_path_x86
108
+ return Common.instance.binary_path_x86
111
109
  end
112
110
  end
113
111
  end
@@ -14,7 +14,12 @@ module Luna
14
14
  attr_accessor :version, :state
15
15
  attr_accessor :podFilePath
16
16
  attr_accessor :lockfile
17
-
17
+ attr_reader :bin_dev
18
+ attr_reader :binary_repo_url
19
+ attr_reader :binary_upload_url
20
+ attr_reader :binary_download_url
21
+ attr_reader :download_file_type
22
+
18
23
  def initialize()
19
24
  end
20
25
 
@@ -22,7 +27,7 @@ module Luna
22
27
  sources = Pod::Config.instance.sources_manager.all
23
28
  repoPath = nil
24
29
  sources.each { |item|
25
- if item.url == CBin.config.binary_repo_url
30
+ if item.url == Common.instance.binary_repo_url
26
31
  repoPath = item.repo
27
32
  end
28
33
  }
@@ -95,7 +100,7 @@ module Luna
95
100
  end
96
101
 
97
102
  def request_result_hash
98
- command = "curl #{CBin.config.binary_upload_url}"
103
+ command = "curl #{Common.instance.binary_upload_url}"
99
104
  p command
100
105
  result = %x(#{command})
101
106
  request_result_hash = JSON.parse(result)
@@ -105,7 +110,7 @@ module Luna
105
110
 
106
111
  def createNeedFrameworkMapper
107
112
  spec_repo_binary = {}
108
- puts "二进制repo地址 : #{CBin.config.binary_repo_url}".yellow
113
+ puts "二进制repo地址 : #{Common.instance.binary_repo_url}".yellow
109
114
  use_framework_list.each { |item|
110
115
  name = item.split('/').first
111
116
  if spec_repo_binary[name] == nil
@@ -214,6 +219,42 @@ module Luna
214
219
  return lockfile.dependencies.map { |item| [item.name.split("/").first, item]}.to_h
215
220
  end
216
221
 
222
+ def bin_dev
223
+ if @bin_dev == nil
224
+ @bin_dev = YAML.load_file("#{Pod::Config.instance.home_dir}/bin_dev.yml")
225
+ end
226
+ return @bin_dev
227
+ end
228
+
229
+ def binary_repo_url
230
+ if @binary_repo_url == nil
231
+ @binary_repo_url = bin_dev["binary_repo_url"]
232
+ end
233
+ return @binary_repo_url
234
+ end
235
+
236
+ def binary_upload_url
237
+ if @binary_upload_url == nil
238
+ cut_string = "/%s/%s/zip"
239
+ @binary_upload_url = binary_download_url[0,binary_download_url.length - cut_string.length]
240
+ end
241
+ return @binary_upload_url
242
+ end
243
+
244
+ def binary_download_url
245
+ if @binary_download_url == nil
246
+ @binary_download_url = bin_dev["binary_download_url"]
247
+ end
248
+ return @binary_download_url
249
+ end
250
+
251
+ def download_file_type
252
+ if @download_file_type == nil
253
+ @download_file_type = bin_dev["download_file_type"]
254
+ end
255
+ return @download_file_type
256
+ end
257
+
217
258
  end
218
259
  end
219
260
  end
@@ -33,15 +33,15 @@ module Luna
33
33
  end
34
34
 
35
35
  def deleteRepo
36
- command = "cd #{Luna::Binary::Common.instance.repoPath}; git stash;git checkout master;git pull origin master;"
36
+ command = "cd #{Common.instance.repoPath}; git stash;git checkout master;git pull origin master;"
37
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"
38
+ Common.instance.deleteDirectory("#{Common.instance.repoPath}/#{name}/#{version}")
39
+ commandADD = "cd #{Common.instance.repoPath};git add .; git commit -m 'DEL::#{name}-#{version} by LBU'; git push -f origin master"
40
40
  system commandADD
41
41
  end
42
42
 
43
43
  def deleteBinaryFramework
44
- command = "curl -X 'DELETE' #{CBin.config.binary_upload_url}/#{name}/#{version}"
44
+ command = "curl -X 'DELETE' #{Common.instance.binary_upload_url}/#{name}/#{version}"
45
45
  p command
46
46
  system command
47
47
  end
@@ -17,7 +17,7 @@ module Luna
17
17
 
18
18
  def run
19
19
  Common.instance.command("curl -o #{Pod::Config.instance.home_dir}/bin_dev.yml #{url}")
20
- Common.instance.command("pod repo add z-ios-framework-spec-repo #{CBin.config.binary_repo_url}")
20
+ Common.instance.command("pod repo add z-ios-framework-spec-repo #{Common.instance.binary_repo_url}")
21
21
  end
22
22
 
23
23
  end
@@ -9,8 +9,8 @@ module Luna
9
9
  attr_accessor :request_result_hash
10
10
 
11
11
  def run
12
- spec_repo_binary = Luna::Binary::Common.instance.createNeedFrameworkMapper
13
- dependencies_mapper = Luna::Binary::Common.instance.dependenciesMapper
12
+ spec_repo_binary = Common.instance.createNeedFrameworkMapper
13
+ dependencies_mapper = Common.instance.dependenciesMapper
14
14
  failList = []
15
15
  successList = []
16
16
  spec_repo_binary.each { |k,v|
@@ -18,9 +18,9 @@ module Luna
18
18
  begin
19
19
  puts "#{k} #{v}".yellow
20
20
 
21
- uploader = Luna::Binary::Common.instance.upload_lockitem(dependencies_mapper,k ,binary_path, true)
21
+ uploader = Common.instance.upload_lockitem(dependencies_mapper,k ,binary_path, true)
22
22
  if uploader != nil
23
- Luna::Binary::Delete.new(k,v).delete
23
+ Delete.new(k,v).delete
24
24
  puts "#{k} #{v} 重新制作上传".yellow
25
25
  uploader.upload
26
26
  successList << "#{k} #{v}"
@@ -57,12 +57,12 @@ module Luna
57
57
  end
58
58
 
59
59
  def lockfile
60
- return Luna::Binary::Common.instance.lockfile
60
+ return Common.instance.lockfile
61
61
  end
62
62
 
63
63
  def request_result_hash
64
64
  if @request_result_hash == nil
65
- @request_result_hash = Luna::Binary::Common.instance.request_result_hash
65
+ @request_result_hash = Common.instance.request_result_hash
66
66
  end
67
67
  return @request_result_hash
68
68
  end
@@ -1,7 +1,7 @@
1
1
  module Luna
2
2
  module Binary
3
3
  module Uploader
4
- VERSION = "0.1.17"
4
+ VERSION = "0.1.21"
5
5
  end
6
6
  end
7
7
  end
@@ -322,7 +322,7 @@ module Luna
322
322
  end
323
323
 
324
324
  def binary_source
325
- { http: format(CBin.config.binary_download_url, specification.root.name, specification.version), type: CBin.config.download_file_type }
325
+ { http: format(Common.instance.binary_download_url, specification.root.name, specification.version), type: Common.instance.download_file_type }
326
326
  end
327
327
 
328
328
  def source_files(suffix)
@@ -385,7 +385,7 @@ module Luna
385
385
  end
386
386
 
387
387
  def isHasFrameworkInService
388
- command = "curl #{format(CBin.config.binary_download_url, specification.root.name, specification.version).sub("#{CBin.config.download_file_type}","")}"
388
+ command = "curl #{format(Common.instance.binary_download_url, specification.root.name, specification.version).sub("#{Common.instance.download_file_type}","")}"
389
389
  p command
390
390
  result = %x(#{command})
391
391
  resultHash = JSON.parse(result)
@@ -405,7 +405,7 @@ module Luna
405
405
  zipCommand = "cd #{rootName};zip -r #{specification.root.name}.zip #{specification.root.name}"
406
406
  p zipCommand
407
407
  system zipCommand
408
- command = "cd #{rootName};curl #{CBin.config.binary_upload_url} -F \"name=#{specification.root.name}\" -F \"version=#{specification.version}\" -F \"annotate=#{specification.root.name}_#{specification.version}_log\" -F \"file=@#{specification.root.name}.zip\""
408
+ command = "cd #{rootName};curl #{Common.instance.binary_upload_url} -F \"name=#{specification.root.name}\" -F \"version=#{specification.version}\" -F \"annotate=#{specification.root.name}_#{specification.version}_log\" -F \"file=@#{specification.root.name}.zip\""
409
409
  p command
410
410
  system command
411
411
  end
@@ -0,0 +1,10 @@
1
+ require "luna/binary/uploader"
2
+ require "luna/binary/delete"
3
+ require "luna/binary/analysis"
4
+ require "luna/binary/refresh"
5
+ require "luna/binary/build"
6
+ require "luna/binary/update"
7
+ require "luna/binary/install"
8
+ require "luna/binary/init"
9
+ require "luna/binary/common/common"
10
+ require "luna/binary/benchmark"
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.17
4
+ version: 0.1.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - 车德超
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-22 00:00:00.000000000 Z
11
+ date: 2021-10-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -139,7 +139,9 @@ files:
139
139
  - Rakefile
140
140
  - bin/lbu
141
141
  - bin/setup
142
+ - lib/luna-binary-uploader.rb
142
143
  - lib/luna/binary/analysis.rb
144
+ - lib/luna/binary/benchmark.rb
143
145
  - lib/luna/binary/build.rb
144
146
  - lib/luna/binary/common/common.rb
145
147
  - lib/luna/binary/delete.rb