cocoapods-bb-bin 0.1.5 → 0.1.8.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 92aac3b42f5f900aa8994380291b97a8794502bb6983d850ce3bf3dc4ef005ee
4
- data.tar.gz: 7a103332b3845ba48a457b87a55e916afe4f8fe53e98e899a8f147e1785f90b7
3
+ metadata.gz: 3ed14a53820238e12852776bab7bbd9229b2dae2fc38a78b41c4998dbcc58261
4
+ data.tar.gz: 0bb09aed068cafaa633dd1bc0d84a545f5c2e0ccea091833b01ce04bc7e69780
5
5
  SHA512:
6
- metadata.gz: 6236774e980f7e3455944cf3cc825a0c270cde86f489c60a294cef5308c0d35ebea030f7e1ff142cd9e7b7a07ccd2e623d97dde99852d5215d6e03ccedc91960
7
- data.tar.gz: fd318d8fe2f1a9c6b8bf749ebc0e13df80996b48b7435e33b206638b2908a2403a0d88a343acac3d1c43201befecc5f286fdfd907d8393c34ba5db6b9279d2c5
6
+ metadata.gz: c3491aafbd2c3aca48bdf526a861b491b67e4dcd544cf2d39c9215b98e366fda139aed77f93000d4b821c5b778b91de5acb5a25a9d91ac6e531fffb635df89e5
7
+ data.tar.gz: a5cf6d9fcb8f22206d9951cd7bb15e611c7b1c38efe1ab8665ca1ad1af8431913776a0ee7c049ac5d81e7013c361cb29303811c5f1615fa89db75b1498d02f06
@@ -165,8 +165,8 @@ module Pod
165
165
  "--verbose",
166
166
  *@additional_args
167
167
  ]
168
-
169
- if File.exist?(Pod::Config.instance.podfile_path)
168
+ podfile_path = Pod::Config.instance.podfile_path
169
+ if podfile_path && File.exist?(podfile_path)
170
170
  argvs += ['--use-podfile']
171
171
  end
172
172
 
@@ -175,7 +175,7 @@ module Pod
175
175
  end
176
176
 
177
177
  argvs << spec_file if spec_file
178
- UI.puts "argvs:#{argvs}"
178
+ # UI.puts "argvs:#{argvs}"
179
179
  gen = Pod::Command::Gen.new(CLAide::ARGV.new(argvs))
180
180
  gen.validate!
181
181
  gen.run
@@ -29,12 +29,10 @@ module Pod
29
29
  @help = argv.flag?('help', false )
30
30
  if @help
31
31
  else
32
- puts "开始执行自动推送操作,"
33
- podfile_path = link_podfile # 创建软链接
34
-
35
32
  @env = argv.option('env') || 'dev'
36
33
  CBin.config.set_configuration_env(@env)
37
34
 
35
+ # podfile_path = link_podfile # 创建软链接 去除link操作 by hm 21/11/24
38
36
  @podspec = argv.shift_argument || find_podspec
39
37
  @specification = Specification.from_file(@podspec)
40
38
 
@@ -133,7 +131,7 @@ module Pod
133
131
  argvs += ["--env=#{@env}"]
134
132
  end
135
133
  argvs += ["--configuration=#{@config}"]
136
- puts "===auto argvs: #{argvs}"
134
+ # puts "===auto argvs: #{argvs}"
137
135
  archive = Pod::Command::Bin::Archive.new(CLAide::ARGV.new(argvs))
138
136
  archive.validate!
139
137
  sources_sepc = archive.run
@@ -190,7 +188,7 @@ module Pod
190
188
  def find_podspec
191
189
  name = nil
192
190
  Pathname.pwd.children.each do |child|
193
- puts child
191
+ # puts child
194
192
  if File.file?(child)
195
193
  if child.extname == '.podspec'
196
194
  name = File.basename(child)
@@ -200,6 +198,7 @@ module Pod
200
198
  end
201
199
  end
202
200
  end
201
+ raise Informative, "podspec File no exist, please check" unless name
203
202
  return name
204
203
  end
205
204
 
@@ -221,8 +220,8 @@ module Pod
221
220
  if filename == 'Podfile'
222
221
  podfile_path = File.join(filepath,"#{filename}")
223
222
  create_link(podfile_path, current_path)
224
- pods_path = File.join(filepath,"Pods")
225
- create_link(pods_path, current_path)
223
+ # pods_path = File.join(filepath,"Pods")
224
+ # create_link(pods_path, current_path)
226
225
  return podfile_path
227
226
  end
228
227
  end
@@ -234,8 +233,8 @@ module Pod
234
233
  podfile_path = File.join(current_path,"Example/Podfile")
235
234
  if File.file?(podfile_path)
236
235
  create_link(podfile_path, current_path)
237
- pods_path = File.join(current_path,"Example/Pods")
238
- create_link(pods_path, current_path)
236
+ # pods_path = File.join(current_path,"Example/Pods")
237
+ # create_link(pods_path, current_path)
239
238
  end
240
239
  end
241
240
 
@@ -1,18 +1,21 @@
1
1
  require 'cocoapods-bb-bin/config/config'
2
2
  require 'cocoapods-bb-bin/native/podfile'
3
+ require 'cocoapods/command/lib/lint'
4
+ require 'cocoapods'
3
5
 
4
6
  module Pod
5
7
  class Command
6
8
  class Bin < Command
7
9
  class Lib < Bin
8
10
  class Lint < Lib
9
- self.summary = 'lint 组件.'
11
+ self.summary = 'Validates a Pod'
12
+
10
13
  self.description = <<-DESC
11
- lint 二进制组件 / 源码组件
14
+ Validates the Pod using the files in the working directory.
12
15
  DESC
13
16
 
14
17
  self.arguments = [
15
- CLAide::Argument.new('NAME.podspec', false)
18
+ CLAide::Argument.new('NAME.podspec', false),
16
19
  ]
17
20
 
18
21
  # lib lint 不会下载 source,所以不能进行二进制 lint
@@ -21,46 +24,100 @@ module Pod
21
24
  [
22
25
  ['--code-dependencies', '使用源码依赖进行 lint'],
23
26
  ['--loose-options', '添加宽松的 options, 包括 --use-libraries (可能会造成 entry point (start) undefined)'],
24
- ['--allow-prerelease', '允许使用 prerelease 的版本 lint']
27
+ ['--allow-prerelease', '允许使用 prerelease 的版本 lint'],
28
+ ['--bb-env', 'bb Company environment(Internal use),support oc、swift project']
25
29
  ].concat(Pod::Command::Lib::Lint.options).concat(super).uniq
26
30
  end
27
31
 
28
32
  def initialize(argv)
29
33
  @loose_options = argv.flag?('loose-options')
30
- @code_dependencies = argv.flag?('code-dependencies')
34
+ @code_dependencies = argv.flag?('code-dependencies', true)
31
35
  @sources = argv.option('sources') || []
32
36
  @allow_prerelease = argv.flag?('allow-prerelease')
37
+ @bb_env = argv.flag?('bb-env', false)
33
38
  @podspec = argv.shift_argument
34
39
  super
35
-
36
40
  @additional_args = argv.remainder!
41
+ @verbose = argv.flag?('verbose', false)
37
42
  end
38
43
 
39
44
  def run
40
- Podfile.execute_with_bin_plugin do
41
- Podfile.execute_with_allow_prerelease(@allow_prerelease) do
45
+ # @bb_env = false
46
+ if @bb_env
47
+ Podfile.execute_with_bin_plugin do
42
48
  Podfile.execute_with_use_binaries(!@code_dependencies) do
43
- argvs = [
44
- @podspec || code_spec_files.first,
45
- "--sources=#{sources_option(@code_dependencies, @sources)}",
46
- *@additional_args
47
- ]
49
+ build_bb_lint
50
+ end
51
+ end
52
+ else
53
+ Podfile.execute_with_bin_plugin do
54
+ Podfile.execute_with_allow_prerelease(@allow_prerelease) do
55
+ Podfile.execute_with_use_binaries(!@code_dependencies) do
56
+ argvs = [
57
+ @podspec || code_spec_files.first,
58
+ "--sources=#{sources_option(@code_dependencies, @sources)}",
59
+ *@additional_args
60
+ ]
48
61
 
49
- if @loose_options
50
- argvs << '--allow-warnings'
51
- if code_spec&.all_dependencies&.any?
52
- argvs << '--use-libraries'
62
+ if @loose_options
63
+ argvs << '--allow-warnings'
64
+ if code_spec&.all_dependencies&.any?
65
+ argvs << '--use-libraries'
66
+ end
53
67
  end
54
- end
55
68
 
56
- lint = Pod::Command::Lib::Lint.new(CLAide::ARGV.new(argvs))
57
- lint.validate!
58
- lint.run
69
+ lint = Pod::Command::Lib::Lint.new(CLAide::ARGV.new(argvs))
70
+ lint.validate!
71
+ lint.run
72
+ end
59
73
  end
60
74
  end
61
75
  end
62
76
  end
63
77
 
78
+ private
79
+
80
+ def build_bb_lint
81
+ UI.section("\npod bin lib lint\n".yellow) do
82
+ begin
83
+ if @podspec && !@podspec.empty?
84
+ argvs = [
85
+ @podspec, # 业务方传入podspec,对于业务方没有传入podspec,内部由podspecs_to_lint进行遍历
86
+ # '--verbose',
87
+ '--allow-warnings',
88
+ '--use-static-frameworks',
89
+ '--no-clean',
90
+ '--skip-import-validation',
91
+ '--use-modular-headers',
92
+ "--sources=#{sources_option(@code_dependencies, @sources)}",
93
+ '--swift-version=5.0',
94
+ *@additional_args
95
+ ]
96
+ argvs += ['--verbose'] if @verbose
97
+ else
98
+ argvs = [
99
+ # '--verbose',
100
+ '--allow-warnings',
101
+ '--use-static-frameworks',
102
+ '--no-clean',
103
+ '--skip-import-validation',
104
+ '--use-modular-headers',
105
+ "--sources=#{sources_option(@code_dependencies, @sources)}",
106
+ '--swift-version=5.0',
107
+ *@additional_args
108
+ ]
109
+ argvs += ['--verbose'] if @verbose
110
+ end
111
+
112
+ # puts "pod lib lint argvs:#{argvs}"
113
+ lint = Pod::Command::Lib::Lint.new(CLAide::ARGV.new(argvs))
114
+ lint.validate!
115
+ lint.run
116
+ rescue Object => exception
117
+ UI.puts exception
118
+ end
119
+ end
120
+ end
64
121
 
65
122
  end
66
123
  end
@@ -0,0 +1,170 @@
1
+ require 'cocoapods-bb-bin/config/config'
2
+ require 'cocoapods-bb-bin/native/podfile'
3
+ require 'cocoapods-bb-bin/native/push'
4
+
5
+ module Pod
6
+ class Command
7
+ class Bin < Command
8
+ class Repo < Bin
9
+ class Push < Repo
10
+ self.summary = '发布组件.'
11
+ self.description = <<-DESC
12
+ 发布二进制组件 / 源码组件
13
+ DESC
14
+
15
+ self.arguments = [
16
+ CLAide::Argument.new('NAME.podspec', false)
17
+ ]
18
+
19
+ def self.options
20
+ [
21
+ ['--binary', '发布组件的二进制版本'],
22
+ ['--template-podspec=A.binary-template.podspec', '生成拥有 subspec 的二进制 spec 需要的模版 podspec, 插件会更改 version 和 source'],
23
+ ['--reserve-created-spec', '保留生成的二进制 spec 文件'],
24
+ ['--code-dependencies', '使用源码依赖进行 lint'],
25
+ ['--loose-options', '添加宽松的 options, 包括 --use-libraries (可能会造成 entry point (start) undefined)'],
26
+ ['--allow-prerelease', '允许使用 prerelease 的版本 lint'],
27
+ ['--use-static-frameworks', 'Lint uses static frameworks during installation,support modulemap'],
28
+ ['--bb-env', 'bb Company environment(Internal use),support oc、swift project']
29
+ ].concat(Pod::Command::Repo::Push.options).concat(super).uniq
30
+ end
31
+
32
+ def initialize(argv)
33
+ @podspec = argv.shift_argument
34
+ @binary = argv.flag?('binary')
35
+ @loose_options = argv.flag?('loose-options')
36
+ @code_dependencies = argv.flag?('code-dependencies', true)
37
+ @sources = argv.option('sources') || []
38
+ @reserve_created_spec = argv.flag?('reserve-created-spec')
39
+ @template_podspec = argv.option('template-podspec')
40
+ @allow_prerelease = argv.flag?('allow-prerelease')
41
+ @use_static_frameworks = argv.flag?('use-static-frameworks', true)
42
+ @bb_env = argv.flag?('bb-env', false)
43
+ super
44
+ @additional_args = argv.remainder!
45
+ @message = argv.option('commit-message')
46
+ @commit_message = argv.flag?('commit-message', false)
47
+ @use_json = argv.flag?('use-json')
48
+ @verbose = argv.flag?('verbose', false)
49
+ @local_only = argv.flag?('local-only')
50
+ end
51
+
52
+ def run
53
+ # @bb_env = false
54
+ if @bb_env
55
+ Podfile.execute_with_bin_plugin do
56
+ Podfile.execute_with_use_binaries(!@code_dependencies) do
57
+ build_bb_push
58
+ end
59
+ end
60
+ else
61
+ Podfile.execute_with_bin_plugin do
62
+ Podfile.execute_with_allow_prerelease(@allow_prerelease) do
63
+ Podfile.execute_with_use_binaries(!@code_dependencies) do
64
+ argvs = [
65
+ repo,
66
+ "--sources=#{sources_option(@code_dependencies, @sources)}",
67
+ *@additional_args
68
+ ]
69
+
70
+ argvs << spec_file if spec_file
71
+
72
+ if @loose_options
73
+ argvs += ['--allow-warnings', '--use-json']
74
+ if code_spec&.all_dependencies&.any?
75
+ argvs << '--use-libraries'
76
+ end
77
+ end
78
+
79
+ push = Pod::Command::Repo::Push.new(CLAide::ARGV.new(argvs))
80
+ push.validate!
81
+ push.run
82
+ end
83
+ end
84
+ end
85
+ end
86
+ ensure
87
+ clear_binary_spec_file_if_needed unless @reserve_created_spec
88
+ end
89
+
90
+ private
91
+ def build_bb_push
92
+ UI.section("\npod bin repo push\n".yellow) do
93
+ begin
94
+ unless @podspec && !@podspec.empty? # 遍历当前目录下podspec文件
95
+ podspecs = Pathname.glob(Pathname.pwd + '*.podspec{.json,}')
96
+ if podspecs.count.zero?
97
+ raise Informative, 'Unable to find a podspec in the working ' \
98
+ 'directory'
99
+ end
100
+ @podspec = podspecs.first
101
+ end
102
+ argvs = [
103
+ repo, # 内部判断区源码还是二进制
104
+ @podspec,
105
+ "--sources=#{sources_option(@code_dependencies, @sources)}",
106
+ # '--verbose'
107
+ '--allow-warnings',
108
+ '--use-static-frameworks',
109
+ '--skip-import-validation',
110
+ '--use-modular-headers',
111
+ '--swift-version=5.0',
112
+ '--use_cocoapods_validator', #cocoapods验证
113
+ *@additional_args
114
+ ]
115
+ argvs += ['--verbose'] if @verbose
116
+ argvs += ['--commit-message'] if @message
117
+ argvs += ['--use-json'] if @use_json
118
+ argvs += ['--local-only'] if @local_only
119
+
120
+ # UI.puts "pod repo push argvs:#{argvs}"
121
+ push = Pod::Command::Repo::Push.new(CLAide::ARGV.new(argvs))
122
+ push.validate!
123
+ push.run
124
+ rescue Object => exception
125
+ UI.puts exception
126
+ end
127
+ end
128
+ end
129
+
130
+ def template_spec_file
131
+ @template_spec_file ||= begin
132
+ if @template_podspec
133
+ find_spec_file(@template_podspec)
134
+ else
135
+ binary_template_spec_file
136
+ end
137
+ end
138
+ end
139
+
140
+ def spec_file
141
+ @spec_file ||= begin
142
+ if @podspec
143
+ find_spec_file(@podspec)
144
+ else
145
+ if code_spec_files.empty?
146
+ raise Informative, '当前目录下没有找到可用源码 podspec.'
147
+ end
148
+
149
+ spec_file = if @binary
150
+ code_spec = Pod::Specification.from_file(code_spec_files.first)
151
+ if template_spec_file
152
+ template_spec = Pod::Specification.from_file(template_spec_file)
153
+ end
154
+ create_binary_spec_file(code_spec, template_spec)
155
+ else
156
+ code_spec_files.first
157
+ end
158
+ spec_file
159
+ end
160
+ end
161
+ end
162
+
163
+ def repo
164
+ @binary ? binary_source.name : code_source.name
165
+ end
166
+ end
167
+ end
168
+ end
169
+ end
170
+ end
@@ -24,12 +24,12 @@ module CBin
24
24
  file = config_dev_file
25
25
  if configuration_env == "release_iphoneos"
26
26
  file = config_release_iphoneos_file
27
- puts "\n====== #{configuration_env} 环境 ========"
27
+ # puts "\n====== #{configuration_env} 环境 ========"
28
28
  elsif configuration_env == "debug_iphoneos"
29
29
  file = config_debug_iphoneos_file
30
- puts "\n====== #{configuration_env} 环境 ========"
30
+ # puts "\n====== #{configuration_env} 环境 ========"
31
31
  elsif configuration_env == "dev"
32
- puts "\n====== #{configuration_env} 环境 ========"
32
+ # puts "\n====== #{configuration_env} 环境 ========"
33
33
  else
34
34
  raise "\n===== #{configuration_env} 参数有误,请检查%w[dev debug_iphoneos release_iphoneos]===="
35
35
  end
@@ -143,6 +143,10 @@ module CBin
143
143
 
144
144
  #编译target名,如 seeyou
145
145
  def target_name
146
+ podfile_path = Pod::Config.instance.podfile_path
147
+ unless podfile_path
148
+ return ""
149
+ end
146
150
  @target_name ||= begin
147
151
  target_name_str = Pod::Config.instance.podfile.root_target_definitions.first.children.first.to_s
148
152
  target_name_str[5,target_name_str.length]
@@ -1,6 +1,6 @@
1
1
 
2
2
  module CBin
3
- VERSION = '0.1.5'
3
+ VERSION = '0.1.8.1'
4
4
  end
5
5
 
6
6
  module Pod
@@ -48,6 +48,10 @@ module CBin
48
48
 
49
49
  def Utils.uses_frameworks?
50
50
  uses_frameworks = false
51
+ podfile_path = Pod::Config.instance.podfile_path
52
+ unless podfile_path
53
+ return true
54
+ end
51
55
  Pod::Config.instance.podfile.target_definitions.each do |key,value|
52
56
  if key != "Pods"
53
57
  uses_frameworks = value.uses_frameworks?
@@ -186,7 +186,8 @@ module CBin
186
186
  archs = ios_architectures
187
187
  # archs = %w[arm64 armv7 armv7s]
188
188
  archs.map do |arch|
189
- xcodebuild(defines, "ARCHS=\'#{arch}\' OTHER_CFLAGS=\'-fembed-bitcode -Qunused-arguments\'","build-#{arch}",@build_model)
189
+ xcodebuild(defines, "-sdk iphoneos ARCHS=\'#{arch}\' OTHER_CFLAGS=\'-fembed-bitcode -Qunused-arguments\'","build-#{arch}",@build_model)
190
+ # xcodebuild(defines, "-sdk iphoneos ARCHS=\'#{arch}\' ","build-#{arch}",@build_model)
190
191
  end
191
192
  # else
192
193
  # xcodebuild(defines,options)
@@ -209,12 +210,12 @@ module CBin
209
210
  end
210
211
  end
211
212
 
212
- def xcodebuild(defines = '', args = '', build_dir = 'build', build_model = 'Debug')
213
-
213
+ def xcodebuild(defines = '', args = '', build_dir = 'build', build_model = 'Debug', configuration = 'Release')
214
+
214
215
  unless File.exist?("Pods.xcodeproj") #cocoapods-generate v2.0.0
215
- command = "xcodebuild #{defines} #{args} CONFIGURATION_BUILD_DIR=#{File.join(File.expand_path("..", build_dir), File.basename(build_dir))} clean build -configuration #{build_model} -target #{target_name} -project ./Pods/Pods.xcodeproj 2>&1"
216
+ command = "xcodebuild #{defines} #{args} CONFIGURATION_BUILD_DIR=#{File.join(File.expand_path("..", build_dir), File.basename(build_dir))} clean build -configuration #{configuration} -target #{target_name} -project ./Pods/Pods.xcodeproj 2>&1"
216
217
  else
217
- command = "xcodebuild #{defines} #{args} CONFIGURATION_BUILD_DIR=#{build_dir} clean build -configuration #{build_model} -target #{target_name} -project ./Pods.xcodeproj 2>&1"
218
+ command = "xcodebuild #{defines} #{args} CONFIGURATION_BUILD_DIR=#{build_dir} clean build -configuration #{configuration} -target #{target_name} -project ./Pods.xcodeproj 2>&1"
218
219
  end
219
220
 
220
221
  UI.message "command = #{command}"
@@ -265,14 +266,33 @@ module CBin
265
266
  module_map = File.read(module_map_file)
266
267
  end
267
268
  elsif public_headers.map(&:basename).map(&:to_s).include?("#{@spec.name}-umbrella.h")
268
- module_map = <<-MAP
269
- framework module #{@spec.name} {
270
- umbrella header "#{@spec.name}-umbrella.h"
271
-
272
- export *
273
- module * { export * }
274
- }
275
- MAP
269
+ archs = ios_architectures + ios_architectures_sim
270
+ swift_Compatibility_Header = "build-#{archs.first}/Swift\ Compatibility\ Header/#{@spec.name}-Swift.h"
271
+ # 策略:针对混编组件,modulemap写入-Swift.h by hm 21.11.15
272
+ if File.exist?(swift_Compatibility_Header) # swift或swift与oc混编工程
273
+ module_map = <<-MAP
274
+ framework module #{@spec.name} {
275
+ umbrella header "#{@spec.name}-umbrella.h"
276
+
277
+ export *
278
+ module * { export * }
279
+ }
280
+
281
+ module #{@spec.name}.Swift {
282
+ header "#{@spec.name}-Swift.h"
283
+ requires objc
284
+ }
285
+ MAP
286
+ else
287
+ module_map = <<-MAP
288
+ framework module #{@spec.name} {
289
+ umbrella header "#{@spec.name}-umbrella.h"
290
+
291
+ export *
292
+ module * { export * }
293
+ }
294
+ MAP
295
+ end
276
296
  end
277
297
 
278
298
  unless module_map.nil?
@@ -333,6 +353,8 @@ module CBin
333
353
  if bundles.count > 0
334
354
  UI.message "Copying bundle files #{bundles}"
335
355
  bundle_files = bundles.join(' ')
356
+ raise Informative, "source resource bundle no exist #{bundle_files}" unless File.exist?(bundle_files)
357
+ UI.message "[build dir]Copying resources current_path:#{Dir.pwd} bundle_files:#{bundle_files} res_path:#{framework.resources_path}"
336
358
  `cp -rp #{bundle_files} #{framework.resources_path} 2>&1`
337
359
  end
338
360
 
@@ -344,7 +366,7 @@ module CBin
344
366
  end
345
367
  raise "copy_resources #{spec_source_dir} no exist " unless File.exist?(spec_source_dir)
346
368
 
347
- spec_source_dir = File.join(Dir.pwd,"#{@spec.name}")
369
+ # spec_source_dir = File.join(Dir.pwd,"#{@spec.name}") # 去除重复赋值,有些资源放在pods/组件目录下
348
370
  real_source_dir = spec_source_dir
349
371
  end
350
372
 
@@ -363,8 +385,10 @@ module CBin
363
385
  resources.each do |source|
364
386
  escape_resource << Shellwords.join(source)
365
387
  end
366
- UI.message "Copying resources #{escape_resource}"
367
- `cp -rp #{escape_resource.join(' ')} #{framework.resources_path}`
388
+ bundle_files = escape_resource.join(' ')
389
+ raise Informative, "source resource bundle no exist #{bundle_files}" unless File.exist?(bundle_files)
390
+ UI.message "[search dir]Copying resources current_path:#{Dir.pwd} bundle_files:#{bundle_files} res_path:#{framework.resources_path}"
391
+ `cp -rp #{bundle_files} #{framework.resources_path} 2>&1`
368
392
  end
369
393
  end
370
394
 
@@ -8,7 +8,7 @@ require 'cocoapods/generate'
8
8
  require 'cocoapods-bb-bin/helpers/framework_builder'
9
9
  require 'cocoapods-bb-bin/helpers/library_builder'
10
10
  require 'cocoapods-bb-bin/helpers/sources_helper'
11
- require 'cocoapods-bb-bin/command/bin/spec/push'
11
+ require 'cocoapods-bb-bin/command/bin/repo/push'
12
12
 
13
13
  module CBin
14
14
  class Upload
@@ -35,7 +35,7 @@ module Pod
35
35
  generator.podfile_plugins.each do |name, options|
36
36
  plugin(*[name, options].compact)
37
37
  end
38
-
38
+ # Pod::UI::puts "====use_frameworks:#{generator.configuration.use_frameworks?}"
39
39
  use_frameworks!(generator.configuration.use_frameworks?)
40
40
 
41
41
  if (supported_swift_versions = generator.supported_swift_versions)
@@ -104,6 +104,10 @@ module Pod
104
104
  inhibit_all_warnings! if generator.inhibit_all_warnings?
105
105
  # use_modular_headers! if generator.use_modular_headers?
106
106
  # podfile 配置 use_frameworks! :linkage => :static 支持modulemap by hm 21/10/19
107
+ # Pod::UI::puts "====use_frameworks_value:#{generator.use_frameworks_value}"
108
+ unless generator.use_frameworks_value
109
+ use_modular_headers! # 默认组件没有配置或者没有podfile,支持modulemap by hm 21/10/20
110
+ end
107
111
  if generator.use_modular_headers? || generator.use_frameworks_value.to_s == '{:linkage=>:static}'
108
112
  use_modular_headers!
109
113
  end
@@ -0,0 +1,60 @@
1
+ require 'tempfile'
2
+ require 'fileutils'
3
+ require 'active_support/core_ext/string/inflections'
4
+
5
+ module Pod
6
+ class Command
7
+ class Repo < Command
8
+ class Push < Repo
9
+
10
+ def initialize(argv)
11
+ @allow_warnings = argv.flag?('allow-warnings')
12
+ @local_only = argv.flag?('local-only')
13
+ @repo = argv.shift_argument
14
+ @source = source_for_repo
15
+ @source_urls = argv.option('sources', config.sources_manager.all.map(&:url).append(Pod::TrunkSource::TRUNK_REPO_URL).uniq.join(',')).split(',')
16
+ @update_sources = argv.flag?('update-sources')
17
+ @podspec = argv.shift_argument
18
+ @use_frameworks = !argv.flag?('use-libraries')
19
+ @use_modular_headers = argv.flag?('use-modular-headers', false)
20
+ @use_static_frameworks = argv.flag?('use-static-frameworks')
21
+ @private = argv.flag?('private', true)
22
+ @message = argv.option('commit-message')
23
+ @commit_message = argv.flag?('commit-message', false)
24
+ @use_json = argv.flag?('use-json')
25
+ @swift_version = argv.option('swift-version', nil)
26
+ @skip_import_validation = argv.flag?('skip-import-validation', false)
27
+ @skip_tests = argv.flag?('skip-tests', false)
28
+ @allow_overwrite = argv.flag?('overwrite', true)
29
+ super
30
+ @use_cocoapods_validator = argv.flag?('use_cocoapods_validator', false)# 配置参数cocoapods进行验证,内部进行hook,二进制hook,源码cocoapods进行验证
31
+ end
32
+
33
+ # Performs a full lint against the podspecs.
34
+ #
35
+ def validate_podspec_files
36
+ UI.puts "\nbin Validating #{'spec'.pluralize(count)}".yellow
37
+ podspec_files.each do |podspec|
38
+ validator = Validator.new(podspec, @source_urls, [], @use_cocoapods_validator)
39
+ validator.allow_warnings = @allow_warnings
40
+ validator.use_frameworks = @use_frameworks
41
+ validator.use_static_frameworks = @use_static_frameworks
42
+ validator.use_modular_headers = @use_modular_headers
43
+ validator.ignore_public_only_results = @private
44
+ validator.swift_version = @swift_version
45
+ validator.skip_import_validation = @skip_import_validation
46
+ validator.skip_tests = @skip_tests
47
+ begin
48
+ validator.validate
49
+ rescue => e
50
+ raise Informative, "The `#{podspec}` specification does not validate." \
51
+ "\n\n#{e.message}"
52
+ end
53
+ raise Informative, "The `#{podspec}` specification does not validate." unless validator.validated?
54
+ end
55
+ end
56
+
57
+ end
58
+ end
59
+ end
60
+ end
@@ -2,23 +2,49 @@
2
2
 
3
3
  module Pod
4
4
  class Validator
5
- # def validate_source_url(spec)
6
- # return if spec.source.nil? || spec.source[:http].nil?
7
- # url = URI(spec.source[:http])
8
- # return if url.scheme == 'https' || url.scheme == 'file'
9
- # warning('http', "The URL (`#{url}`) doesn't use the encrypted HTTPs protocol. " \
10
- # 'It is crucial for Pods to be transferred over a secure protocol to protect your users from man-in-the-middle attacks. '\
11
- # 'This will be an error in future releases. Please update the URL to use https.')
12
- # end
5
+ # @return [Boolean] 使用cocoapods进行验证,二进制库推送默认不采用cocoapods(1.11.2)验证
13
6
  #
7
+ # attr_accessor :use_cocoapods_validator
8
+ def initialize(spec_or_path, source_urls, platforms = [], use_cocoapods_validator = false)
9
+ @use_cocoapods_validator = use_cocoapods_validator
10
+ @use_frameworks = true
11
+ @linter = Specification::Linter.new(spec_or_path)
12
+ @source_urls = if @linter.spec && @linter.spec.dependencies.empty? && @linter.spec.recursive_subspecs.all? { |s| s.dependencies.empty? }
13
+ []
14
+ else
15
+ source_urls.map { |url| config.sources_manager.source_with_name_or_url(url) }.map(&:url)
16
+ end
17
+
18
+ @platforms = platforms.map do |platform|
19
+ result = case platform.to_s.downcase
20
+ # Platform doesn't recognize 'macos' as being the same as 'osx' when initializing
21
+ when 'macos' then Platform.macos
22
+ else Platform.new(platform, nil)
23
+ end
24
+ unless valid_platform?(result)
25
+ raise Informative, "Unrecognized platform `#{platform}`. Valid platforms: #{VALID_PLATFORMS.join(', ')}"
26
+ end
27
+ result
28
+ end
29
+ @use_frameworks = true
30
+ end
31
+
14
32
  # Perform analysis for a given spec (or subspec)
15
33
  #
16
34
  def perform_extensive_analysis(spec)
35
+ if @use_cocoapods_validator
36
+ return cocoapods_perform_extensive_analysis(spec)
37
+ end
17
38
  return true
18
39
  end
19
40
 
20
41
  #覆盖
21
42
  def check_file_patterns
43
+ if @use_cocoapods_validator
44
+ cocoapods_check_file_patterns
45
+ return
46
+ end
47
+ # 二进制验证部分
22
48
  FILE_PATTERNS.each do |attr_name|
23
49
  next if %i(source_files resources).include? attr_name
24
50
  if respond_to?("_validate_#{attr_name}", true)
@@ -35,6 +61,91 @@ module Pod
35
61
  end
36
62
  end
37
63
 
38
- def validate_source_url(spec); end
64
+ def validate_source_url(spec)
65
+ if @use_cocoapods_validator
66
+ cocoapods_validate_source_url(spec)
67
+ return
68
+ end
69
+ end
70
+
71
+ # cocoapods(1.11.2) validator源码
72
+ private
73
+
74
+ # It checks that every file pattern specified in a spec yields
75
+ # at least one file. It requires the pods to be already present
76
+ # in the current working directory under Pods/spec.name.
77
+ #
78
+ # @return [void]
79
+ #
80
+ def cocoapods_check_file_patterns
81
+ FILE_PATTERNS.each do |attr_name|
82
+ if respond_to?("_validate_#{attr_name}", true)
83
+ send("_validate_#{attr_name}")
84
+ else
85
+ validate_nonempty_patterns(attr_name, :error)
86
+ end
87
+ end
88
+
89
+ _validate_header_mappings_dir
90
+ if consumer.spec.root?
91
+ _validate_license
92
+ _validate_module_map
93
+ end
94
+ end
95
+
96
+ # Performs validations related to the `source` -> `http` attribute (if exists)
97
+ #
98
+ def cocoapods_validate_source_url(spec)
99
+ return if spec.source.nil? || spec.source[:http].nil?
100
+ url = URI(spec.source[:http])
101
+ return if url.scheme == 'https' || url.scheme == 'file'
102
+ warning('http', "The URL (`#{url}`) doesn't use the encrypted HTTPS protocol. " \
103
+ 'It is crucial for Pods to be transferred over a secure protocol to protect your users from man-in-the-middle attacks. '\
104
+ 'This will be an error in future releases. Please update the URL to use https.')
105
+ end
106
+
107
+ # Perform analysis for a given spec (or subspec)
108
+ #
109
+ def cocoapods_perform_extensive_analysis(spec)
110
+ if spec.non_library_specification?
111
+ error('spec', "Validating a non library spec (`#{spec.name}`) is not supported.")
112
+ return false
113
+ end
114
+ validate_homepage(spec)
115
+ validate_screenshots(spec)
116
+ validate_social_media_url(spec)
117
+ validate_documentation_url(spec)
118
+ validate_source_url(spec)
119
+
120
+ platforms = platforms_to_lint(spec)
121
+
122
+ valid = platforms.send(fail_fast ? :all? : :each) do |platform|
123
+ UI.message "\n\n#{spec} - Analyzing on #{platform} platform.".green.reversed
124
+ @consumer = spec.consumer(platform)
125
+ setup_validation_environment
126
+ begin
127
+ create_app_project
128
+ download_pod
129
+ check_file_patterns
130
+ install_pod
131
+ validate_swift_version
132
+ add_app_project_import
133
+ validate_vendored_dynamic_frameworks
134
+ build_pod
135
+ test_pod unless skip_tests
136
+ ensure
137
+ tear_down_validation_environment
138
+ end
139
+ validated?
140
+ end
141
+ return false if fail_fast && !valid
142
+ perform_extensive_subspec_analysis(spec) unless @no_subspecs
143
+ rescue => e
144
+ message = e.to_s
145
+ message << "\n" << e.backtrace.join("\n") << "\n" if config.verbose?
146
+ error('unknown', "Encountered an unknown error (#{message}) during validation.")
147
+ false
148
+ end
149
+
39
150
  end
40
151
  end
@@ -12,12 +12,13 @@ if Pod.match_version?('~> 1.4')
12
12
  require 'cocoapods-bb-bin/native/linter'
13
13
  require 'cocoapods-bb-bin/native/resolver'
14
14
  require 'cocoapods-bb-bin/native/source'
15
- require 'cocoapods-bb-bin/native/validator'
15
+ require 'cocoapods-bb-bin/native/validator' #使用cocoapods-1.11.2
16
16
  require 'cocoapods-bb-bin/native/acknowledgements'
17
17
  require 'cocoapods-bb-bin/native/sandbox_analyzer'
18
18
  require 'cocoapods-bb-bin/native/podspec_finder'
19
19
  require 'cocoapods-bb-bin/native/file_accessor'
20
20
  require 'cocoapods-bb-bin/native/pod_target_installer'
21
21
  require 'cocoapods-bb-bin/native/target_validator'
22
+ require 'cocoapods-bb-bin/native/push' # 支持modulemap & swift与oc工程混编
22
23
 
23
24
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-bb-bin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - humin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-19 00:00:00.000000000 Z
11
+ date: 2021-11-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parallel
@@ -62,6 +62,9 @@ dependencies:
62
62
  name: cocoapods-bb-xcframework
63
63
  requirement: !ruby/object:Gem::Requirement
64
64
  requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: 0.2.2
65
68
  - - "<"
66
69
  - !ruby/object:Gem::Version
67
70
  version: '1.0'
@@ -69,6 +72,9 @@ dependencies:
69
72
  prerelease: false
70
73
  version_requirements: !ruby/object:Gem::Requirement
71
74
  requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: 0.2.2
72
78
  - - "<"
73
79
  - !ruby/object:Gem::Version
74
80
  version: '1.0'
@@ -122,9 +128,9 @@ files:
122
128
  - lib/cocoapods-bb-bin/command/bin/initHotKey.rb
123
129
  - lib/cocoapods-bb-bin/command/bin/install.rb
124
130
  - lib/cocoapods-bb-bin/command/bin/lib/lint.rb
131
+ - lib/cocoapods-bb-bin/command/bin/repo/push.rb
125
132
  - lib/cocoapods-bb-bin/command/bin/repo/update.rb
126
133
  - lib/cocoapods-bb-bin/command/bin/spec/create.rb
127
- - lib/cocoapods-bb-bin/command/bin/spec/push.rb
128
134
  - lib/cocoapods-bb-bin/command/bin/update.rb
129
135
  - lib/cocoapods-bb-bin/config/config.rb
130
136
  - lib/cocoapods-bb-bin/config/config_asker.rb
@@ -160,6 +166,7 @@ files:
160
166
  - lib/cocoapods-bb-bin/native/podfile_env.rb
161
167
  - lib/cocoapods-bb-bin/native/podfile_generator.rb
162
168
  - lib/cocoapods-bb-bin/native/podspec_finder.rb
169
+ - lib/cocoapods-bb-bin/native/push.rb
163
170
  - lib/cocoapods-bb-bin/native/resolver.rb
164
171
  - lib/cocoapods-bb-bin/native/sandbox_analyzer.rb
165
172
  - lib/cocoapods-bb-bin/native/source.rb
@@ -190,7 +197,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
190
197
  - !ruby/object:Gem::Version
191
198
  version: '0'
192
199
  requirements: []
193
- rubygems_version: 3.1.4
200
+ rubygems_version: 3.2.30
194
201
  signing_key:
195
202
  specification_version: 4
196
203
  summary: cocoapods-bb-bin is a plugin which helps develpers switching pods between
@@ -1,114 +0,0 @@
1
- require 'cocoapods-bb-bin/config/config'
2
- require 'cocoapods-bb-bin/native/podfile'
3
-
4
- module Pod
5
- class Command
6
- class Bin < Command
7
- class Repo < Bin
8
- class Push < Repo
9
- self.summary = '发布组件.'
10
- self.description = <<-DESC
11
- 发布二进制组件 / 源码组件
12
- DESC
13
-
14
- self.arguments = [
15
- CLAide::Argument.new('NAME.podspec', false)
16
- ]
17
-
18
- def self.options
19
- [
20
- ['--binary', '发布组件的二进制版本'],
21
- ['--template-podspec=A.binary-template.podspec', '生成拥有 subspec 的二进制 spec 需要的模版 podspec, 插件会更改 version 和 source'],
22
- ['--reserve-created-spec', '保留生成的二进制 spec 文件'],
23
- ['--code-dependencies', '使用源码依赖进行 lint'],
24
- ['--loose-options', '添加宽松的 options, 包括 --use-libraries (可能会造成 entry point (start) undefined)'],
25
- ['--allow-prerelease', '允许使用 prerelease 的版本 lint']
26
- ].concat(Pod::Command::Repo::Push.options).concat(super).uniq
27
- end
28
-
29
- def initialize(argv)
30
- @podspec = argv.shift_argument
31
- @binary = argv.flag?('binary')
32
- @loose_options = argv.flag?('loose-options')
33
- @code_dependencies = argv.flag?('code-dependencies')
34
- @sources = argv.option('sources') || []
35
- @reserve_created_spec = argv.flag?('reserve-created-spec')
36
- @template_podspec = argv.option('template-podspec')
37
- @allow_prerelease = argv.flag?('allow-prerelease')
38
- super
39
-
40
- @additional_args = argv.remainder!
41
- end
42
-
43
- def run
44
- Podfile.execute_with_bin_plugin do
45
- Podfile.execute_with_allow_prerelease(@allow_prerelease) do
46
- Podfile.execute_with_use_binaries(!@code_dependencies) do
47
- argvs = [
48
- repo,
49
- "--sources=#{sources_option(@code_dependencies, @sources)}",
50
- *@additional_args
51
- ]
52
-
53
- argvs << spec_file if spec_file
54
-
55
- if @loose_options
56
- argvs += ['--allow-warnings', '--use-json']
57
- if code_spec&.all_dependencies&.any?
58
- argvs << '--use-libraries'
59
- end
60
- end
61
-
62
- push = Pod::Command::Repo::Push.new(CLAide::ARGV.new(argvs))
63
- push.validate!
64
- push.run
65
- end
66
- end
67
- end
68
- ensure
69
- clear_binary_spec_file_if_needed unless @reserve_created_spec
70
- end
71
-
72
- private
73
-
74
- def template_spec_file
75
- @template_spec_file ||= begin
76
- if @template_podspec
77
- find_spec_file(@template_podspec)
78
- else
79
- binary_template_spec_file
80
- end
81
- end
82
- end
83
-
84
- def spec_file
85
- @spec_file ||= begin
86
- if @podspec
87
- find_spec_file(@podspec)
88
- else
89
- if code_spec_files.empty?
90
- raise Informative, '当前目录下没有找到可用源码 podspec.'
91
- end
92
-
93
- spec_file = if @binary
94
- code_spec = Pod::Specification.from_file(code_spec_files.first)
95
- if template_spec_file
96
- template_spec = Pod::Specification.from_file(template_spec_file)
97
- end
98
- create_binary_spec_file(code_spec, template_spec)
99
- else
100
- code_spec_files.first
101
- end
102
- spec_file
103
- end
104
- end
105
- end
106
-
107
- def repo
108
- @binary ? binary_source.name : code_source.name
109
- end
110
- end
111
- end
112
- end
113
- end
114
- end