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,46 @@
1
+ require 'cocoapods-imy-bin/config/config_hot_key_asker'
2
+
3
+ module Pod
4
+ class Command
5
+ class Bin < Command
6
+ class Imy < Bin
7
+ self.summary = '快捷键'
8
+ self.description = <<-DESC
9
+ 创建 文件,在其中保存插件需要的配置信息,
10
+ 如二进制私有源地址、源码私有源地址等。
11
+ DESC
12
+
13
+ self.arguments = [
14
+ CLAide::Argument.new('1', false)
15
+ ]
16
+
17
+ def self.options
18
+ [
19
+ ].concat(super)
20
+ end
21
+
22
+ def initialize(argv)
23
+ @hot_key = argv.shift_argument || '1'
24
+ super
25
+ end
26
+
27
+ def run
28
+ CBin.config_hot_key.set_hot_key_index(@hot_key)
29
+ UI.puts "cd #{CBin.config_hot_key.hot_key_dir}".yellow
30
+
31
+ if Dir.exist?(CBin.config_hot_key.hot_key_dir)
32
+ Dir.chdir(CBin.config_hot_key.hot_key_dir) do
33
+ UI.puts " #{CBin.config_hot_key.hot_key_cmd}".yellow
34
+ system CBin.config_hot_key.hot_key_cmd
35
+ end
36
+ else
37
+ raise "配置项中文件目录不存在 #{CBin.config_hot_key.hot_key_dir}"
38
+ end
39
+
40
+
41
+ end
42
+
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,69 @@
1
+ require 'cocoapods-imy-bin/config/config_asker'
2
+
3
+ module Pod
4
+ class Command
5
+ class Bin < Command
6
+ class Init < Bin
7
+ self.summary = '初始化插件的快捷键.'
8
+ self.description = <<-DESC
9
+ 创建 文件,在其中保存插件需要的配置信息,
10
+ 如快捷键1 快捷键2 所对应执行的命令
11
+ DESC
12
+
13
+ def self.options
14
+ [
15
+ ['--bin-url=URL', '配置文件地址,直接从此地址下载配置文件']
16
+ ].concat(super)
17
+ end
18
+
19
+ def initialize(argv)
20
+ @bin_url = argv.option('bin-url')
21
+ super
22
+ end
23
+
24
+ def run
25
+ if @bin_url.nil?
26
+ config_with_asker
27
+ else
28
+ config_with_url(@bin_url)
29
+ end
30
+ end
31
+
32
+ private
33
+
34
+ def config_with_url(url)
35
+ require 'open-uri'
36
+
37
+ UI.puts "开始下载配置文件...\n"
38
+ file = open(url)
39
+ contents = YAML.safe_load(file.read)
40
+
41
+ UI.puts "开始同步配置文件...\n"
42
+ CBin.config.sync_config(contents.to_hash)
43
+ UI.puts "设置完成.\n".green
44
+ rescue Errno::ENOENT => e
45
+ raise Informative, "配置文件路径 #{url} 无效,请确认后重试."
46
+ end
47
+
48
+ def config_with_asker
49
+ asker = CBin::Config::Asker.new
50
+ asker.wellcome_message
51
+
52
+ config = {}
53
+ template_hash = CBin.config.template_hash
54
+ template_hash.each do |k, v|
55
+ default = begin
56
+ CBin.config.send(k)
57
+ rescue StandardError
58
+ nil
59
+ end
60
+ config[k] = asker.ask_with_answer(v[:description], default, v[:selection])
61
+ end
62
+
63
+ CBin.config.sync_config(config)
64
+ asker.done_message
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,70 @@
1
+
2
+ require 'cocoapods-imy-bin/config/config_hot_key_asker'
3
+
4
+ module Pod
5
+ class Command
6
+ class Bin < Command
7
+ class Inithk < Bin
8
+ self.summary = '初始化快捷键配置.'
9
+ self.description = <<-DESC
10
+ 创建 文件,在其中保存插件需要的配置信息,
11
+ 如二进制私有源地址、源码私有源地址等。
12
+ DESC
13
+
14
+ def self.options
15
+ [
16
+ ['--bin-url=URL', '配置文件地址,直接从此地址下载配置文件']
17
+ ].concat(super)
18
+ end
19
+
20
+ def initialize(argv)
21
+ @bin_url = argv.option('bin-url')
22
+ super
23
+ end
24
+
25
+ def run
26
+ if @bin_url.nil?
27
+ config_with_asker
28
+ else
29
+ config_with_url(@bin_url)
30
+ end
31
+ end
32
+
33
+ private
34
+
35
+ def config_with_url(url)
36
+ require 'open-uri'
37
+
38
+ UI.puts "开始下载配置文件...\n"
39
+ file = open(url)
40
+ contents = YAML.safe_load(file.read)
41
+
42
+ UI.puts "开始同步配置文件...\n"
43
+ CBin.config_hot_key.sync_config(contents.to_hash)
44
+ UI.puts "设置完成.\n".green
45
+ rescue Errno::ENOENT => e
46
+ raise Informative, "配置文件路径 #{url} 无效,请确认后重试."
47
+ end
48
+
49
+ def config_with_asker
50
+ asker = CBin::Config_Hot_Key::Asker.new
51
+ asker.wellcome_message
52
+
53
+ config = {}
54
+ template_hash = CBin.config_hot_key.template_hash
55
+ template_hash.each do |k, v|
56
+ default = begin
57
+ CBin.config_hot_key.send(k)
58
+ rescue StandardError
59
+ nil
60
+ end
61
+ config[k] = asker.ask_with_answer(v[:description], default, v[:selection])
62
+ end
63
+
64
+ CBin.config_hot_key.sync_config(config)
65
+ asker.done_message
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,44 @@
1
+
2
+ require 'cocoapods-imy-bin/command/bin/update'
3
+ module Pod
4
+ class Command
5
+ class Bin < Command
6
+ class Install < Bin
7
+ include Pod
8
+
9
+ self.summary = 'pod install 拦截器,会加载本地Podfile_local文件,DSL加载到原始Podfile文件中。'
10
+
11
+ self.description = <<-DESC
12
+ pod install 拦截器,会加载本地Podfile_local文件
13
+ 会通过DSL加载到原始Podfile文件中
14
+ 支持 pod 'xxx' 各种写法
15
+ 支持 post_install/pre_install钩子,采用覆盖做法
16
+ DESC
17
+ def self.options
18
+ [
19
+ ['--repo-update', 'Force running `pod repo update` before install'],
20
+ ['--deployment', 'Disallow any changes to the Podfile or the Podfile.lock during installation'],
21
+ ['--clean-install', 'Ignore the contents of the project cache and force a full pod installation. This only ' \
22
+ 'applies to projects that have enabled incremental installation']
23
+ ].concat(super).reject { |(name, _)| name == '--no-repo-update' }
24
+ end
25
+
26
+ def initialize(argv)
27
+ @update = argv.flag?('update')
28
+ super
29
+ @additional_args = argv.remainder!
30
+ end
31
+
32
+ def run
33
+ Update.load_local_podfile
34
+ argvs = [
35
+ *@additional_args
36
+ ]
37
+ gen = Pod::Command::Install.new(CLAide::ARGV.new(argvs))
38
+ gen.validate!
39
+ gen.run
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,69 @@
1
+ require 'cocoapods-imy-bin/config/config'
2
+ require 'cocoapods-imy-bin/native/podfile'
3
+
4
+ module Pod
5
+ class Command
6
+ class Bin < Command
7
+ class Lib < Bin
8
+ class Lint < Lib
9
+ self.summary = 'lint 组件.'
10
+ self.description = <<-DESC
11
+ lint 二进制组件 / 源码组件
12
+ DESC
13
+
14
+ self.arguments = [
15
+ CLAide::Argument.new('NAME.podspec', false)
16
+ ]
17
+
18
+ # lib lint 不会下载 source,所以不能进行二进制 lint
19
+ # 要 lint 二进制版本,需要进行 spec lint,此 lint 会去下载 source
20
+ def self.options
21
+ [
22
+ ['--code-dependencies', '使用源码依赖进行 lint'],
23
+ ['--loose-options', '添加宽松的 options, 包括 --use-libraries (可能会造成 entry point (start) undefined)'],
24
+ ['--allow-prerelease', '允许使用 prerelease 的版本 lint']
25
+ ].concat(Pod::Command::Lib::Lint.options).concat(super).uniq
26
+ end
27
+
28
+ def initialize(argv)
29
+ @loose_options = argv.flag?('loose-options')
30
+ @code_dependencies = argv.flag?('code-dependencies')
31
+ @sources = argv.option('sources') || []
32
+ @allow_prerelease = argv.flag?('allow-prerelease')
33
+ @podspec = argv.shift_argument
34
+ super
35
+
36
+ @additional_args = argv.remainder!
37
+ end
38
+
39
+ def run
40
+ Podfile.execute_with_bin_plugin do
41
+ Podfile.execute_with_allow_prerelease(@allow_prerelease) do
42
+ 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
+ ]
48
+
49
+ if @loose_options
50
+ argvs << '--allow-warnings'
51
+ if code_spec&.all_dependencies&.any?
52
+ argvs << '--use-libraries'
53
+ end
54
+ end
55
+
56
+ lint = Pod::Command::Lib::Lint.new(CLAide::ARGV.new(argvs))
57
+ lint.validate!
58
+ lint.run
59
+ end
60
+ end
61
+ end
62
+ end
63
+
64
+
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,156 @@
1
+
2
+ require 'cocoapods-imy-bin/native/podfile'
3
+ require 'cocoapods/command/gen'
4
+ require 'cocoapods/generate'
5
+ require 'cocoapods-imy-bin/helpers/local/local_framework_builder'
6
+ require 'cocoapods-imy-bin/helpers/local/local_library_builder'
7
+ require 'cocoapods-imy-bin/helpers/local/local_build_helper'
8
+ require 'cocoapods-imy-bin/helpers/spec_source_creator'
9
+ require 'cocoapods-imy-bin/config/config_builder'
10
+
11
+ module Pod
12
+ class Command
13
+ class Bin < Command
14
+ class Local < Bin
15
+ self.summary = '根据podfile中信息 将本地已存在的组件静态包 归档,需要归档的组件由外部传入'
16
+ self.description = <<-DESC
17
+ 根据podfile中信息 将本地已存在的组件静态包 归档,需要归档的组件由外部传入
18
+ 仅支持 iOS 平台
19
+ 此静态 framework/.a 不包含依赖组件的 symbol
20
+
21
+ 一个用ccache,一个是cocoapods-imy-bin插件支持下的,
22
+ 拿xcodebuild生成的中间构建产物,如生成的 libIMYYQHome.a,利用cocoapods-imy-bin 制作成二进制静态库,保存起来。
23
+ 下次pod update 工程时,在pod update时去捞已经生成的二进制组件打包。这样可以大大减少编译时间
24
+
25
+ 制作流程:
26
+ 每次pod update 时记录无二进制组件的库,build完后,自动制作缺失二进制组件库。
27
+ 如果pod update 时无二进制组件的库,采用源码编译,源码编译同时有ccache缓存支持,也能加快速度
28
+ DESC
29
+
30
+ def self.options
31
+ [
32
+ ['--no-clean', '保留构建中间产物'],
33
+ ['--framework-output', '输出framework文件'],
34
+ ['--no-zip', '不压缩静态 framework 为 zip'],
35
+ ['--make-binary-specs', '需要制作spec集合'],
36
+ ['--env', "该组件上传的环境 %w[dev debug_iphoneos release_iphoneos]"]
37
+ ].concat(Pod::Command::Gen.options).concat(super).uniq
38
+ end
39
+
40
+ def initialize(argv)
41
+ @env = argv.option('env') || 'dev'
42
+ CBin.config.set_configuration_env(@env)
43
+ UI.warn "====== cocoapods-imy-bin #{CBin::VERSION} 版本 ======== \n "
44
+ UI.warn "====== #{@env} 环境 ======== "
45
+
46
+
47
+ @make_binary_specs = argv.option('make-binary-specs') || []
48
+ @framework_output = argv.flag?('framework-output', false)
49
+ @clean = argv.flag?('no-clean', true)
50
+ @zip = argv.flag?('zip', true)
51
+ @sources = argv.option('sources') || []
52
+ @platform = Platform.new(:ios)
53
+
54
+ @target_name = CBin::Config::Builder.instance.target_name
55
+ @local_build_dir_name = CBin::Config::Builder.instance.xcode_build_name
56
+ @local_build_dir = CBin::Config::Builder.instance.xcode_build_dir
57
+
58
+ @framework_path
59
+ super
60
+ end
61
+
62
+ def run
63
+ # 清除之前的缓存
64
+ temp = File.join(@local_build_dir, @platform.to_s)
65
+ FileUtils.rm_r(temp) if File.exist? temp
66
+ if File.exist?(CBin::Config::Builder.instance.zip_dir)
67
+ FileUtils.rm_r(CBin::Config::Builder.instance.zip_dir)
68
+ end
69
+
70
+ sources_spec = []
71
+ Dir.chdir(CBin::Config::Builder.instance.local_psec_dir) do
72
+ spec_files = Dir.glob(%w[*.json *.podspec])
73
+ spec_files.each do |file|
74
+ spec = Pod::Specification.from_file(file)
75
+ sources_spec << spec
76
+ end
77
+ end
78
+
79
+ build(sources_spec)
80
+ end
81
+
82
+ def build(make_binary_specs)
83
+ # 如果没要求,就清空依赖库数据
84
+ sources_sepc = []
85
+ make_binary_specs.uniq.each do |spec|
86
+ next if spec.name.include?('/')
87
+ next if spec.name == @target_name
88
+ #过滤白名单
89
+ next if CBin::Config::Builder.instance.white_pod_list.include?(spec.name)
90
+ #过滤 git
91
+ if spec.source[:git] && spec.source[:git]
92
+ spec_git = spec.source[:git]
93
+ spec_git_res = false
94
+ CBin::Config::Builder.instance.ignore_git_list.each do |ignore_git|
95
+ spec_git_res = spec_git.include?(ignore_git)
96
+ break if spec_git_res
97
+ end
98
+ next if spec_git_res
99
+ end
100
+ UI.warn "#{spec.name}.podspec 带有 vendored_frameworks 字段,请检查是否有效!!!" if spec.attributes_hash['vendored_frameworks']
101
+ next if spec.attributes_hash['vendored_frameworks'] && @target_name != spec.name #过滤带有vendored_frameworks的
102
+ next if (spec.attributes_hash['ios'] && spec.attributes_hash['ios']['vendored_frameworks']) #过滤带有vendored_frameworks的
103
+ #获取没有制作二进制版本的spec集合
104
+
105
+ next unless library_exist(spec)
106
+
107
+ # 获取没有制作二进制版本的spec集合
108
+ sources_sepc << spec
109
+ end
110
+ fail_build_specs = []
111
+ sources_sepc.uniq.each do |spec|
112
+ begin
113
+ builder = CBin::LocalBuild::Helper.new(spec,
114
+ @platform,
115
+ @framework_output,
116
+ @zip,
117
+ @clean,
118
+ @target_name,
119
+ @local_build_dir_name,
120
+ @local_build_dir)
121
+ builder.build
122
+ CBin::Upload::Helper.new(spec, @code_dependencies, @sources).upload
123
+ rescue StandardError
124
+ fail_build_specs << spec
125
+ end
126
+ end
127
+
128
+ if fail_build_specs.any?
129
+ fail_build_specs.uniq.each do |spec|
130
+ UI.warn "【#{spec.name} | #{spec.version}】组件二进制版本编译失败 ."
131
+ end
132
+ end
133
+
134
+ success_specs = sources_sepc - fail_build_specs
135
+ if success_specs.any?
136
+ success_specs.uniq.each do |spec|
137
+ UI.warn " =======【 #{spec.name} | #{spec.version} 】二进制组件制作完成 !!!"
138
+ end
139
+ end
140
+ # pod repo update
141
+ UI.section("\nUpdating Spec Repositories\n".yellow) do
142
+ Pod::Command::Bin::Repo::Update.new(CLAide::ARGV.new([])).run
143
+ end
144
+ end
145
+
146
+ private
147
+
148
+ def library_exist(spec)
149
+ File.exist?(File.join(@local_build_dir, "lib#{spec.name}.a"))
150
+ end
151
+
152
+
153
+ end
154
+ end
155
+ end
156
+ end