cocoapods-imy-bin 0.2.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.
Files changed (64) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +22 -0
  3. data/README.md +541 -0
  4. data/lib/cocoapods-imy-bin.rb +2 -0
  5. data/lib/cocoapods-imy-bin/command.rb +2 -0
  6. data/lib/cocoapods-imy-bin/command/bin.rb +60 -0
  7. data/lib/cocoapods-imy-bin/command/bin/archive.rb +184 -0
  8. data/lib/cocoapods-imy-bin/command/bin/auto.rb +188 -0
  9. data/lib/cocoapods-imy-bin/command/bin/code.rb +237 -0
  10. data/lib/cocoapods-imy-bin/command/bin/imy.rb +46 -0
  11. data/lib/cocoapods-imy-bin/command/bin/init.rb +69 -0
  12. data/lib/cocoapods-imy-bin/command/bin/initHotKey.rb +70 -0
  13. data/lib/cocoapods-imy-bin/command/bin/install.rb +44 -0
  14. data/lib/cocoapods-imy-bin/command/bin/lib/lint.rb +69 -0
  15. data/lib/cocoapods-imy-bin/command/bin/local.rb +156 -0
  16. data/lib/cocoapods-imy-bin/command/bin/repo/update.rb +43 -0
  17. data/lib/cocoapods-imy-bin/command/bin/spec/create.rb +73 -0
  18. data/lib/cocoapods-imy-bin/command/bin/spec/push.rb +114 -0
  19. data/lib/cocoapods-imy-bin/command/bin/update.rb +148 -0
  20. data/lib/cocoapods-imy-bin/config/config.rb +137 -0
  21. data/lib/cocoapods-imy-bin/config/config_asker.rb +57 -0
  22. data/lib/cocoapods-imy-bin/config/config_builder.rb +179 -0
  23. data/lib/cocoapods-imy-bin/config/config_hot_key.rb +103 -0
  24. data/lib/cocoapods-imy-bin/config/config_hot_key_asker.rb +57 -0
  25. data/lib/cocoapods-imy-bin/gem_version.rb +10 -0
  26. data/lib/cocoapods-imy-bin/helpers.rb +4 -0
  27. data/lib/cocoapods-imy-bin/helpers/build_helper.rb +150 -0
  28. data/lib/cocoapods-imy-bin/helpers/framework.rb +62 -0
  29. data/lib/cocoapods-imy-bin/helpers/framework_builder.rb +307 -0
  30. data/lib/cocoapods-imy-bin/helpers/library.rb +54 -0
  31. data/lib/cocoapods-imy-bin/helpers/library_builder.rb +90 -0
  32. data/lib/cocoapods-imy-bin/helpers/local/loca_llibrary.rb +57 -0
  33. data/lib/cocoapods-imy-bin/helpers/local/local_build_helper.rb +146 -0
  34. data/lib/cocoapods-imy-bin/helpers/local/local_framework.rb +65 -0
  35. data/lib/cocoapods-imy-bin/helpers/local/local_framework_builder.rb +174 -0
  36. data/lib/cocoapods-imy-bin/helpers/local/local_library_builder.rb +92 -0
  37. data/lib/cocoapods-imy-bin/helpers/sources_helper.rb +33 -0
  38. data/lib/cocoapods-imy-bin/helpers/spec_creator.rb +170 -0
  39. data/lib/cocoapods-imy-bin/helpers/spec_files_helper.rb +77 -0
  40. data/lib/cocoapods-imy-bin/helpers/spec_source_creator.rb +171 -0
  41. data/lib/cocoapods-imy-bin/helpers/upload_helper.rb +84 -0
  42. data/lib/cocoapods-imy-bin/native.rb +19 -0
  43. data/lib/cocoapods-imy-bin/native/acknowledgements.rb +27 -0
  44. data/lib/cocoapods-imy-bin/native/analyzer.rb +53 -0
  45. data/lib/cocoapods-imy-bin/native/installation_options.rb +25 -0
  46. data/lib/cocoapods-imy-bin/native/installer.rb +115 -0
  47. data/lib/cocoapods-imy-bin/native/linter.rb +26 -0
  48. data/lib/cocoapods-imy-bin/native/path_source.rb +33 -0
  49. data/lib/cocoapods-imy-bin/native/pod_source_installer.rb +19 -0
  50. data/lib/cocoapods-imy-bin/native/podfile.rb +91 -0
  51. data/lib/cocoapods-imy-bin/native/podfile_env.rb +37 -0
  52. data/lib/cocoapods-imy-bin/native/podfile_generator.rb +190 -0
  53. data/lib/cocoapods-imy-bin/native/podspec_finder.rb +25 -0
  54. data/lib/cocoapods-imy-bin/native/resolver.rb +230 -0
  55. data/lib/cocoapods-imy-bin/native/sandbox_analyzer.rb +34 -0
  56. data/lib/cocoapods-imy-bin/native/source.rb +35 -0
  57. data/lib/cocoapods-imy-bin/native/sources_manager.rb +20 -0
  58. data/lib/cocoapods-imy-bin/native/specification.rb +31 -0
  59. data/lib/cocoapods-imy-bin/native/validator.rb +77 -0
  60. data/lib/cocoapods-imy-bin/source_provider_hook.rb +54 -0
  61. data/lib/cocoapods_plugin.rb +3 -0
  62. data/spec/command/bin_spec.rb +12 -0
  63. data/spec/spec_helper.rb +50 -0
  64. metadata +180 -0
@@ -0,0 +1,33 @@
1
+
2
+
3
+ require 'cocoapods-imy-bin/native/sources_manager.rb'
4
+
5
+ module CBin
6
+ module SourcesHelper
7
+ def sources_manager
8
+ Pod::Config.instance.sources_manager
9
+ end
10
+
11
+ def binary_source
12
+ sources_manager.binary_source
13
+ end
14
+
15
+ def code_source
16
+ sources_manager.code_source
17
+ end
18
+
19
+ # 优先采用对应依赖的 source
20
+ # cocoapods 内部会先匹配前面符合的 specification
21
+ # 只允许二进制的 specification subspec 比源码的 specification subspec 多
22
+ #
23
+ def valid_sources(code_dependencies = false)
24
+ sources = [binary_source, code_source]
25
+ sources.reverse! if code_dependencies
26
+ sources
27
+ end
28
+
29
+ def sources_option(code_dependencies, additional_sources)
30
+ (valid_sources(code_dependencies).map(&:url) + Array(additional_sources)).join(',')
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,170 @@
1
+
2
+
3
+ require 'cocoapods'
4
+ require 'cocoapods-imy-bin/config/config'
5
+
6
+ module CBin
7
+ class Specification
8
+ class Creator
9
+ attr_reader :code_spec
10
+ attr_reader :template_spec
11
+ attr_reader :spec
12
+
13
+ def initialize(code_spec, template_spec, platforms = 'ios')
14
+ @code_spec = code_spec
15
+ @template_spec = template_spec
16
+ @platforms = Array(platforms)
17
+ validate!
18
+ end
19
+
20
+ def validate!
21
+ raise Pod::Informative, '源码 podspec 不能为空 .' unless code_spec
22
+ if code_spec.subspecs.any? && template_spec.nil?
23
+ raise Pod::Informative, "不支持自动生成存在 subspec 的二进制 podspec , 需要提供模版文件 #{code_spec.name}.binary.podspec.template ."
24
+ end
25
+ end
26
+
27
+ def create
28
+ spec = template_spec ? create_from_code_spec_and_template_spec : create_from_code_spec
29
+
30
+ Pod::UI.message '生成二进制 podspec 内容: '
31
+ spec.to_pretty_json.split("\n").each do |text|
32
+ Pod::UI.message text
33
+ end
34
+
35
+ spec
36
+ end
37
+
38
+ def write_spec_file(file = filename)
39
+ create unless spec
40
+
41
+ File.open(file, 'w+') do |f|
42
+ f.write(spec.to_pretty_json)
43
+ end
44
+
45
+ @filename = file
46
+ end
47
+
48
+ def clear_spec_file
49
+ File.delete(filename) if File.exist?(filename)
50
+ end
51
+
52
+ def filename
53
+ @filename ||= "#{spec.name}.binary.podspec.json"
54
+ end
55
+
56
+ private
57
+
58
+ def create_from_code_spec
59
+ @spec = code_spec.dup
60
+ # vendored_frameworks | resources | source | source_files | public_header_files
61
+ # license | resource_bundles | vendored_libraries
62
+
63
+ # Project Linkin
64
+ @spec.vendored_frameworks = "#{code_spec.root.name}.framework"
65
+
66
+ # Resources
67
+ extnames = []
68
+ extnames << '*.bundle' if code_spec_consumer.resource_bundles.any?
69
+ if code_spec_consumer.resources.any?
70
+ extnames += code_spec_consumer.resources.map { |r| File.basename(r) }
71
+ end
72
+ if extnames.any?
73
+ @spec.resources = framework_contents('Resources').flat_map { |r| extnames.map { |e| "#{r}/#{e}" } }
74
+ end
75
+
76
+ # Source Location
77
+ @spec.source = binary_source
78
+
79
+ # Source Code
80
+ @spec.source_files = framework_contents('Headers/*')
81
+ @spec.public_header_files = framework_contents('Headers/*')
82
+
83
+ # Unused for binary
84
+ spec_hash = @spec.to_hash
85
+ # spec_hash.delete('license')
86
+ spec_hash.delete('resource_bundles')
87
+ spec_hash.delete('exclude_files')
88
+ spec_hash.delete('preserve_paths')
89
+ # 这里不确定 vendored_libraries 指定的时动态/静态库
90
+ # 如果是静态库的话,需要移除,否则就不移除
91
+ # 最好是静态库都独立成 Pod ,cocoapods-package 打静态库去 collect 目标文件时好做过滤
92
+ # 这里统一只对命名后缀 .a 文件做处理
93
+ # spec_hash.delete('vendored_libraries')
94
+ # libraries 只能假设为动态库不做处理了,如果有例外,需要开发者自行处理
95
+ spec_hash.delete('vendored_libraries')
96
+ spec_hash['vendored_libraries'] = binary_vendored_libraries
97
+
98
+ # vendored_libraries = Array(vendored_libraries).reject { |l| l.end_with?('.a') }
99
+ # if vendored_libraries.any?
100
+ # spec_hash['vendored_libraries'] = vendored_libraries
101
+ # end
102
+
103
+ # Filter platforms
104
+ platforms = spec_hash['platforms']
105
+ selected_platforms = platforms.select { |k, _v| @platforms.include?(k) }
106
+ spec_hash['platforms'] = selected_platforms.empty? ? platforms : selected_platforms
107
+
108
+ @spec = Pod::Specification.from_hash(spec_hash)
109
+ @spec
110
+ end
111
+
112
+ def create_from_code_spec_and_template_spec
113
+ @spec = template_spec.dup
114
+
115
+ @spec.version = code_spec.version
116
+ @spec.source = binary_source
117
+
118
+ @spec.source_files = binary_source_files
119
+ @spec.public_header_files = binary_public_header_files
120
+ @spec.vendored_libraries = binary_vendored_libraries
121
+
122
+ @spec.resources = binary_resources if @spec.attributes_hash.keys.include?("resources")
123
+
124
+
125
+
126
+ @spec
127
+ end
128
+
129
+ def binary_source
130
+ { http: format(CBin.config.binary_download_url, code_spec.root.name, code_spec.version), type: CBin.config.download_file_type }
131
+ end
132
+
133
+ def code_spec_consumer(_platform = :ios)
134
+ code_spec.consumer(:ios)
135
+ end
136
+
137
+ def framework_contents(name)
138
+ ["#{code_spec.root.name}.framework", "#{code_spec.root.name}.framework/Versions/A"].map { |path| "#{path}/#{name}" }
139
+ end
140
+
141
+ def binary_source_files
142
+ { http: format(CBin.config.binary_download_url, code_spec.root.name, code_spec.version), type: CBin.config.download_file_type }
143
+ end
144
+
145
+ def binary_source_files
146
+ "bin_#{code_spec.name}_#{code_spec.version}/Headers/*"
147
+ end
148
+
149
+ def binary_public_header_files
150
+ "bin_#{code_spec.name}_#{code_spec.version}/Headers/*.h"
151
+ end
152
+
153
+ def binary_vendored_libraries
154
+ "bin_#{code_spec.name}_#{code_spec.version}/*.a"
155
+ end
156
+
157
+ def binary_resources
158
+ "bin_#{code_spec.name}_#{code_spec.version}/Resources/*"
159
+ end
160
+
161
+ end
162
+ end
163
+ end
164
+ #模板框架begin
165
+ # s.source_files = "bin_#{s.name}_#{s.version}/Headers/*"
166
+ # s.public_header_files = "bin_#{s.name}_#{s.version}/Headers/*.h"
167
+ # s.vendored_libraries = "bin_#{s.name}_#{s.version}/*.a"
168
+ #有图片资源的,要带上
169
+ #s.resources = 'bin_#{s.name}_#{s.version}/Resources/*.{json,png,jpg,gif,js,xib,eot,svg,ttf,woff,db,sqlite,mp3,bundle}'
170
+ #模板框架end
@@ -0,0 +1,77 @@
1
+
2
+
3
+ require 'cocoapods-imy-bin/native/sources_manager.rb'
4
+ require 'cocoapods-imy-bin/helpers/spec_creator'
5
+
6
+ module CBin
7
+ module SpecFilesHelper
8
+ def spec_files
9
+ @spec_files ||= Pathname.glob('*.podspec{,.json}')
10
+ end
11
+
12
+ def binary_spec_files
13
+ @binary_spec_files ||= Pathname.glob('*.binary.podspec{,.json}')
14
+ end
15
+
16
+ def binary_template_spec_files
17
+ @binary_spec_template_files ||= Pathname.glob('*.binary-template.podspec{,.json}')
18
+ end
19
+
20
+ def binary_template_spec_file
21
+ @binary_spec_template_file ||= binary_template_spec_files.first
22
+ end
23
+
24
+ def code_spec_files
25
+ @code_spec_files ||= spec_files - binary_spec_files - binary_template_spec_files
26
+ end
27
+
28
+ def code_spec
29
+ if code_spec_files.first
30
+ Pod::Specification.from_file(code_spec_files.first)
31
+ end
32
+ end
33
+
34
+ def binary_spec
35
+ if binary_spec_files.first
36
+ Pod::Specification.from_file(binary_spec_files.first)
37
+ end
38
+ end
39
+
40
+ def binary_template_spec
41
+ if binary_template_spec_file
42
+ Pod::Specification.from_file(binary_template_spec_file)
43
+ end
44
+ end
45
+
46
+ def find_spec_file(podspec)
47
+ path = Pathname(podspec)
48
+ raise Pod::Informative, "无法找到 #{podspec}" unless path.exist?
49
+
50
+ path
51
+ end
52
+
53
+ def create_binary_spec_file(code_spec, template_spec)
54
+ # 1. code spec 是否有 subpsec
55
+ # 1.1 有,查找 template spec,并生成
56
+ # 1.2 没有,是否有 template spec
57
+ # 1.2.1 有,根据 template spec 生成
58
+ # 1.2.2 没有,根据 code spec 生成
59
+
60
+ unless code_spec
61
+ raise Pod::Informative, '没有二进制 podspec 的情况下,必须要提供源码 podspec.'
62
+ end
63
+ if code_spec.subspecs.any? && template_spec.nil?
64
+ raise Pod::Informative, '拥有 subspec 的组件,在生成二进制 podspec 时,必须要提供模版 podspec.'
65
+ end
66
+
67
+ @spec_creator = CBin::Specification::Creator.new(code_spec, template_spec)
68
+ @spec_creator.create
69
+ @spec_creator.write_spec_file
70
+ @spec_creator.filename
71
+ end
72
+
73
+ def clear_binary_spec_file_if_needed
74
+ @spec_creator&.clear_spec_file
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,171 @@
1
+
2
+
3
+ require 'cocoapods'
4
+ require 'cocoapods-imy-bin/config/config'
5
+
6
+ module CBin
7
+ class SpecificationSource
8
+ class Creator
9
+ attr_reader :code_spec
10
+ attr_reader :spec
11
+
12
+ def initialize(code_spec, platforms = 'ios')
13
+ @code_spec = code_spec
14
+ @platforms = Array(platforms)
15
+ validate!
16
+ end
17
+
18
+ def validate!
19
+ raise Pod::Informative, '源码 podspec 不能为空 .' unless code_spec
20
+ end
21
+
22
+ def create
23
+ spec = create_from_code_spec
24
+
25
+ # Pod::UI.message '生成二进制 podspec 内容: '
26
+ # spec.to_pretty_json.split("\n").each do |text|
27
+ # Pod::UI.message text
28
+ # end
29
+
30
+ spec
31
+ end
32
+
33
+ def write_spec_file(file = filename)
34
+ create unless spec
35
+
36
+ FileUtils.mkdir_p(CBin::Config::Builder.instance.binary_json_dir) unless File.exist?(CBin::Config::Builder.instance.binary_json_dir)
37
+ FileUtils.rm_rf(file) if File.exist?(file)
38
+
39
+ File.open(file, 'w+') do |f|
40
+ # f.write("# MARK: converted automatically by plugin cocoapods-imy-bin @slj \r\n")
41
+ f.write(spec.to_pretty_json)
42
+ end
43
+
44
+ @filename = file
45
+ end
46
+
47
+ def clear_spec_file
48
+ File.delete(filename) if File.exist?(filename)
49
+ end
50
+
51
+ def filename
52
+ @filename ||= "#{CBin::Config::Builder.instance.binary_json_dir_name}/#{spec.name}.binary.podspec.json"
53
+ end
54
+
55
+ private
56
+
57
+ def create_from_code_spec
58
+ @spec = code_spec.dup
59
+ # vendored_frameworks | resources | source | source_files | public_header_files
60
+ # license | resource_bundles | vendored_libraries
61
+
62
+ # Project Linkin
63
+ # @spec.vendored_frameworks = "#{code_spec.root.name}.framework"
64
+
65
+ # Resources
66
+ extnames = []
67
+ extnames << '*.bundle' if code_spec_consumer.resource_bundles.any?
68
+ if code_spec_consumer.resources.any?
69
+ extnames += code_spec_consumer.resources.map { |r| File.basename(r) }
70
+ end
71
+ if extnames.any?
72
+ @spec.resources = framework_contents('Resources').flat_map { |r| extnames.map { |e| "#{r}/#{e}" } }
73
+ end
74
+
75
+ # Source Location
76
+ @spec.source = binary_source
77
+
78
+ # Source Code
79
+ # @spec.source_files = framework_contents('Headers/*')
80
+ # @spec.public_header_files = framework_contents('Headers/*')
81
+
82
+ # Unused for binary
83
+ spec_hash = @spec.to_hash
84
+ # spec_hash.delete('license')
85
+ spec_hash.delete('resource_bundles')
86
+ spec_hash.delete('exclude_files')
87
+ spec_hash.delete('preserve_paths')
88
+
89
+ spec_hash.delete('subspecs')
90
+ spec_hash.delete('default_subspecs')
91
+ spec_hash.delete('default_subspec')
92
+ spec_hash.delete('vendored_frameworks')
93
+ spec_hash.delete('vendored_framework')
94
+
95
+ # 这里不确定 vendored_libraries 指定的时动态/静态库
96
+ # 如果是静态库的话,需要移除,否则就不移除
97
+ # 最好是静态库都独立成 Pod ,cocoapods-package 打静态库去 collect 目标文件时好做过滤
98
+ # 这里统一只对命名后缀 .a 文件做处理
99
+ # spec_hash.delete('vendored_libraries')
100
+ # libraries 只能假设为动态库不做处理了,如果有例外,需要开发者自行处理
101
+ spec_hash.delete('vendored_libraries')
102
+
103
+ # vendored_libraries = Array(vendored_libraries).reject { |l| l.end_with?('.a') }
104
+ # if vendored_libraries.any?
105
+ # spec_hash['vendored_libraries'] = vendored_libraries
106
+ # end
107
+
108
+ # Filter platforms
109
+ platforms = spec_hash['platforms']
110
+ selected_platforms = platforms.select { |k, _v| @platforms.include?(k) }
111
+ spec_hash['platforms'] = selected_platforms.empty? ? platforms : selected_platforms
112
+
113
+ @spec = Pod::Specification.from_hash(spec_hash)
114
+
115
+ #把命令 prepare_command 移除掉,如ReactiveCocoa会执行修改重命令的脚步
116
+ @spec.prepare_command = "" if @spec.prepare_command
117
+ @spec.version = code_spec.version
118
+ @spec.source = binary_source
119
+ @spec.source_files = binary_source_files
120
+ @spec.public_header_files = binary_public_header_files
121
+ @spec.vendored_libraries = binary_vendored_libraries
122
+ @spec.resources = binary_resources if @spec.attributes_hash.keys.include?("resources")
123
+ @spec.description = <<-EOF
124
+ 「 converted automatically by plugin cocoapods-imy-bin @slj 」
125
+ #{@spec.description}
126
+ EOF
127
+ @spec
128
+ end
129
+
130
+ def binary_source
131
+ { http: format(CBin.config.binary_download_url, code_spec.root.name, code_spec.version), type: CBin.config.download_file_type }
132
+ end
133
+
134
+ def code_spec_consumer(_platform = :ios)
135
+ code_spec.consumer(:ios)
136
+ end
137
+
138
+ def framework_contents(name)
139
+ ["#{code_spec.root.name}.framework", "#{code_spec.root.name}.framework/Versions/A"].map { |path| "#{path}/#{name}" }
140
+ end
141
+
142
+ def binary_source_files
143
+ { http: format(CBin.config.binary_download_url, code_spec.root.name, code_spec.version), type: CBin.config.download_file_type }
144
+ end
145
+
146
+ def binary_source_files
147
+ "bin_#{code_spec.name}_#{code_spec.version}/Headers/*"
148
+ end
149
+
150
+ def binary_public_header_files
151
+ "bin_#{code_spec.name}_#{code_spec.version}/Headers/*.h"
152
+ end
153
+
154
+ def binary_vendored_libraries
155
+ "bin_#{code_spec.name}_#{code_spec.version}/*.a"
156
+ end
157
+
158
+ def binary_resources
159
+ "bin_#{code_spec.name}_#{code_spec.version}/Resources/*"
160
+ end
161
+
162
+ end
163
+ end
164
+ end
165
+ #模板框架begin
166
+ # s.source_files = "bin_#{s.name}_#{s.version}/Headers/*"
167
+ # s.public_header_files = "bin_#{s.name}_#{s.version}/Headers/*.h"
168
+ # s.vendored_libraries = "bin_#{s.name}_#{s.version}/*.a"
169
+ #有图片资源的,要带上
170
+ #s.resources = 'bin_#{s.name}_#{s.version}/Resources/*.{json,png,jpg,gif,js,xib,eot,svg,ttf,woff,db,sqlite,mp3,bundle}'
171
+ #模板框架end