cocoapods-tdfire-binary 1.3.14 → 1.3.16

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
  SHA1:
3
- metadata.gz: 883e1a1c94c672658d46a121897a9094d9bd8f63
4
- data.tar.gz: e5f4d957511d1d4007d7301ba408a53551beb068
3
+ metadata.gz: 11e5d6d061eadbd1f569b23e47b6551d04d42109
4
+ data.tar.gz: 19b0fa97a2de0352ab859fbf6690671e5a944c60
5
5
  SHA512:
6
- metadata.gz: ad1384b7d38ef95ced53d4525ebef6d4def6a0979287ab4b871d64f87af4b5864f790154594c805105cf3d6193dbdbf795f1230b4872c278b8cefa6599cfd91b
7
- data.tar.gz: 15aeaf03300f530689dbd08c6fabe4bfc6d42708abb787759d09add7776f62f018e6425ea394902f58dc88a12fbaa24178f2daa16c16ab1aeb20f53e0f27804f
6
+ metadata.gz: 926ea1b71d07aedf60826d437fd67d0d4401b95099920dc6187ca83fe408ff48f0819064c8ec5b3c0fc2c0924c847c7d14733ee42b17252c661b009fac5ec372
7
+ data.tar.gz: f9f323d29a788faa56b7b8e40ed622b575e55880cf7b7b171ba54b1cbcf352b9e32bf18de4b964b880472c355db2b207ae195b5106ee9b5bb3eb64af8ea0f40b
data/README.md CHANGED
@@ -2,97 +2,269 @@
2
2
 
3
3
  <a href="https://travis-ci.org/tripleCC/cocoapods-tdfire-binary"><img src="https://img.shields.io/travis/tripleCC/cocoapods-tdfire-binary/master.svg"></a>
4
4
 
5
+ 组件二进制化辅助 CocoaPods 插件,**通过提前将组件打包成静态 framework,加快正式打包、组件 lint、组件发布的编译速度**。
5
6
 
7
+ 提供简易的源码/二进制依赖切换功能,方便开发调试。
6
8
 
7
- 辅助组件二进制组件化的 CocoaPods 插件,适合希望解决以下业务场景的开发者:
9
+ ## 安装
8
10
 
11
+ $ gem install cocoapods-tdfire-binary
9
12
 
13
+ ## 使用
10
14
 
11
- 1. 通过提前将组件打包成 static-framework,减少主 App 打包时间
15
+ 插件分为 pod binary 命令, 二进制 DSL 两部分。
12
16
 
13
- 2. 提供源码和二进制依赖切换功能,方便开发调试
17
+ 由于组件的二进制版本并不存放在 GitLab 上,插件需要一个二进制服务器进行上传和下载,服务器部分可查看 [binary-server](https://github.com/tripleCC/binary-server) 。使用插件前,需要先启动二进制服务器,否则插件二进制相关的功能将不可用。
14
18
 
15
- 3. 尽量减少二进制化的工作量,以及对原发布流程的影响
16
19
 
17
- 4. 规避维护两套 podspec 和对应的 tag
20
+ ## pod binary 命令
18
21
 
19
- 5. 体验尽量贴近 CocoaPods 原生 DSL
22
+ 以下命令都可以追加 `--verbose` 查看执行的详细流程。
20
23
 
21
-
24
+ 执行 `pod binary`:
22
25
 
26
+ ```shell
27
+ ➜ TDF pod binary
28
+ Usage:
23
29
 
30
+ $ pod binary COMMAND
24
31
 
25
- ## 安装
32
+ 2Dfire 二进制工具库,提供打包、lint、推送、拉取、发布等命令
26
33
 
27
- $ gem install cocoapods-tdfire-binary
34
+ Commands:
35
+
36
+ + assemble 执行二进制组件发布操作集合
37
+ + delete 删除二进制版本
38
+ + init 初始化二进制插件
39
+ + lib 二进制模版库操作
40
+ + lint 对本地组件进行 Lint
41
+ + list 查看所有二进制版本信息
42
+ + package 二进制打包
43
+ + publish 正式发布二进制组件
44
+ + pull 下载二进制 zip 包
45
+ + push 推送二进制 zip 包
46
+ + search 查找二进制版本信息
28
47
 
48
+ Options:
29
49
 
50
+ --silent Show nothing
51
+ --verbose Show more debugging information
52
+ --no-ansi Show output without ANSI codes
53
+ --help Show help banner of specified command
54
+ ```
30
55
 
31
- ## 使用
56
+ ### pod binary init
32
57
 
58
+ 初始化二进制插件(公司内部可以忽略此步骤,插件内部会下载默认配置文件)。执行命令后,展示以下交互界面:
33
59
 
60
+ ```
61
+ 开始设置二进制化初始信息.
62
+ 所有的信息都会保存在 binary_config.yaml 文件中.
63
+ 你可以在 /Users/songruiwang/.cocoapods/binary_config.yml 目录下手动添加编辑该文件.
64
+ /Users/songruiwang/.cocoapods/binary_config.yml 文件包含配置信息如下:
65
+
66
+ ---
67
+ server_host: 输入二进制服务器地址 (比如 http://xxxxx:8080)
68
+ repo_url: 输入私有源 Git 地址 (比如 https://github.com/tripleCC/PrivateSpecRepo.git)
69
+ template_url: 输入 pod 模版 Git 地址 (比如 https://github.com/CocoaPods/pod-template.git)
70
+ three_party_group: 输入三方库所在的 group (比如 cocoapods-repos)
71
+
72
+ 输入二进制服务器地址 (比如 http://xxxxx:8080)
73
+ >
74
+ ```
34
75
 
35
- 此插件需要结合二进制服务器使用,其中主要接口如下:
76
+ 使用者需要提供以下信息:
36
77
 
78
+ - server_host
79
+ - 二进制服务器地址,供插件的二进制功能部分使用
80
+ - repo_url
81
+ - 私有源 Git 地址,通过插件 lint 、发布等功能时使用
82
+ - template_url
83
+ - pod 模版 Git 地址,通过插件创建模版时使用
84
+ - three_party_group:
85
+ - 三方库所在的 group ,设置三方组件使用二进制时使用
37
86
 
87
+ 如果存在旧值,直接键入回车键表示采用旧值。
38
88
 
39
89
  ```
40
-
90
+ 输入二进制服务器地址 (比如 http://xxxxx:8080)
91
+ 旧值:http:xxxxxx
92
+ >
93
+ http:xxxxxx
41
94
  ```
42
95
 
96
+ ### pod binary lib create
43
97
 
98
+ > pod binary lib create NAME
44
99
 
100
+ 创建二进制模版库。内部为 `pod lib create --template-url=xxx` 的一层简单包装,其中的 `--template-url` 对应上一小节 `binary_config.yaml` 中的 `template_url` 配置项。
45
101
 
102
+ 推荐在模版库中预置项目组开发常用信息,如添加 CI/CD 配置文件,在 Podfile 中设置业务组件常见底层依赖等。
46
103
 
47
- ```
104
+ ### pod binary lib import
48
105
 
106
+ > pod binary lib import [PATH]
49
107
 
50
- Usage:
108
+ 根据 podspec 生成与组件同名伞头文件。在没有指定 PATH 的情况下,默认在执行命令目录生成伞头文件。当指定目录伞头文件已存在时,会执行替换操作。
51
109
 
52
- $ pod binary COMMAND
53
110
 
54
- 2Dfire 二进制工具库,提供打包、lint、推送、拉取、发布等命令
111
+ ### pod binary list
55
112
 
56
- Commands:
113
+ 查看所有二进制版本信息。和 `pod list` 输出格式一致。
57
114
 
58
- + assemble 执行二进制组件发布操作集合
59
- + delete 删除二进制版本
60
- + init 初始化二进制插件
61
- + lib 二进制模版库操作
62
- + lint 对本地二进制进行 Lint
63
- + list 查看所有二进制版本信息
64
- + package 二进制打包
65
- + publish 正式发布二进制组件
66
- + pull 下载二进制 zip 包
67
- + push 推送二进制 zip 包
68
- + search 查找二进制版本信息
115
+ ### pod binary lint
69
116
 
70
- ```
117
+ > pod binary lint --sources=xxxx --binary-first
71
118
 
72
- ### For .gitignore
119
+ 对本地组件进行 lint。内部为 `pod lib lint` 的封装。
73
120
 
74
- ```
75
- ...
121
+ - `--binary-first`
122
+ - 在没有指定 `--binary-first` 的情况下,和 `pod lib lint` 效果一致,指定之后,插件会优先采用**依赖组件的二进制版本**加快 lint ,lint 组件自身依然会采用源码。如果依赖的某些组件没有二进制版本,插件会对这些组件采用源码依赖。
123
+ - `--sources`
124
+ - 私有源地址,在没有指定 `--sources` 的情况下,使用的 sources 为 `binary_config.yaml` 中的 `repo_url` 配置。
125
+
126
+ ### pod binary search
127
+
128
+ > pod binary search NAME
129
+
130
+ 查找二进制版本信息。和 `pod search` 输出格式一致。
131
+
132
+ ### pod binary package
133
+
134
+ > pod binary package --spec-sources=xxxx --subspecs=xxxx --use-carthage --clean --binary-first
135
+
136
+ 将源码打包成二进制,并压缩成 zip 包。其中二进制为静态 framework 封装格式。
137
+
138
+ - `--spec-sources`
139
+ - 私有源地址,在没有指定的情况下,使用的 sources 为 `binary_config.yaml` 中的 `repo_url` 配置。
140
+ - `--subspecs`
141
+ - 打包目标子组件,默认会打包所有组件
142
+ - `--use-carthage`
143
+ - 使用 carthage 进行打包,三方库提供 carthage 的优先。没有指定的话,使用 `cocoapods-packager` 插件进行打包。
144
+ - `--binary-first`
145
+ - 打包时,依赖组件优先采用二进制版本,加快编译。如果依赖的某些组件没有二进制版本,插件会对这些组件采用源码依赖。
146
+ - `--clean`
147
+ - 执行成功后,删除 zip 文件外的所有生成文件
148
+
149
+ ### pod binary pull
150
+
151
+ > pod binary pull NAME VERSION
76
152
 
153
+ 下载二进制 zip 包。
154
+
155
+ ### pod binary push
156
+
157
+ > pod binary push [PATH] --name=xxxx --version=xxxx --commit=xxxx
158
+
159
+ 将二进制 zip 包推送至二进制服务器。 PATH 为 zip 包所在地址。
160
+
161
+ - `--name`
162
+ - 推送二进制的组件名,没指定时,采用当前 podspec 中的组件名
163
+ - `--versio`
164
+ - 推送二进制的版本号,没指定时,采用当前 podspec 中的版本号
165
+ - `--commit`
166
+ - 推送二进制的版本日志,没指定时,采用当前分支最新 commit sha
167
+
168
+ ### pod binary publish
169
+
170
+ > pod binary publish [NAME.podspec] --commit=xxxx --sources=xxxx --binary-first
171
+
172
+ 正式发布二进制组件版本。内部为 `pod repo push` 的封装。
173
+
174
+ - `--commit`
175
+ - 发布的 commit 信息
176
+ - `--binary-first`
177
+ - 发布时,依赖组件优先采用二进制版本,加快编译。如果依赖的某些组件没有二进制版本,插件会对这些组件采用源码依赖。
178
+ - `--sources`
179
+ - 私有源地址,在没有指定的情况下,使用的 sources 为 `binary_config.yaml` 中的 `repo_url` 配置。
180
+
181
+ ### pod binary delete
182
+
183
+ > pod binary delete NAME VERSION
184
+
185
+ 将二进制从服务器中删除。
186
+
187
+
188
+ ## 二进制 DSL
189
+
190
+ 在二进制化前,需要先在组件仓库中的 `.gitignore` 中添加 :
191
+
192
+ ```
77
193
  *.framework
78
194
  *.zip
79
195
  ```
80
196
 
81
- > For Podfile
197
+ **由于插件内部下载缓存机制,如果 tag 中存在 .framework 文件,则不下载二进制服务器的二进制文件**。这就容易出现二进制版本和源码对不上问题,所以忽略 .framework 文件是必要的。
198
+
199
+ 推荐将 `.gitignore` 放到 `pod-template` 中,使用 `pod binary lib create` 创建新组件工程。
200
+
201
+ ### podspec DSL
202
+
203
+ > 只支持 iOS 平台, Objective-C 项目(插件内部也会进行限制)
204
+
205
+ 一份标准的二进制组件 podspec 如下所示:
206
+
207
+ ```ruby
208
+ ....
209
+
210
+ tdfire_source_configurator = lambda do |s|
211
+ # 源码依赖配置
212
+ s.source_files = '${POD_NAME}/Classes/**/*'
213
+ s.public_header_files = '${POD_NAME}/Classes/**/*.{h}'
214
+ # s.private_header_files =
215
+
216
+ # 资源依赖必须使用 bundle
217
+ # s.resource_bundles = {
218
+ # '${POD_NAME}' => ['${POD_NAME}/Assets/*']
219
+ # }
220
+
221
+ # s.dependency 'TDFModuleKit'
222
+ end
82
223
 
224
+ unless %w[tdfire_set_binary_download_configurations tdfire_source tdfire_binary].reduce(true) { |r, m| s.respond_to?(m) & r }
225
+ tdfire_source_configurator.call s
226
+ else
227
+ s.tdfire_source tdfire_source_configurator
228
+ s.tdfire_binary tdfire_source_configurator
229
+
230
+ #s.tdfire_binary tdfire_source_configurator do |s|
231
+ # 额外配置 (一般不用)
232
+ #end
233
+
234
+ s.tdfire_set_binary_download_configurations
235
+ end
83
236
  ```
237
+
238
+ 以上代码,除了 lambda `tdfire_source_configurator` 中的代码由使用者配置外,剩余代码都是固定的。使用者只需要将原来的源码配置,挪进 lambda 中即可。
239
+
240
+
241
+ ### Podfile DSL
242
+
243
+ 一份采用二进制组件的 Podfile 如下所示:
244
+
245
+ ```ruby
84
246
  ...
85
247
  plugin 'cocoapods-tdfire-binary'
86
248
 
87
249
  tdfire_use_binary!
88
- tdfire_use_source_pods ['AFNetworking']
89
-
90
- use_frameworks!
91
250
 
251
+ # tdfire_third_party_use_binary!
252
+ tdfire_use_source_pods ['AFNetworking']
92
253
  ...
93
254
 
94
255
  ```
95
256
 
257
+ `plugin` 方法为 CocoaPods 原生 DSL ,表示引入二进制化插件。
258
+
259
+ - `tdfire_use_binary!`
260
+ - 所有组件优先采用二进制版本。
261
+ - `tdfire_third_party_use_binary!`
262
+ - 三方组件优先采用二进制版本。
263
+ - `tdfire_use_source_pods`
264
+ - 使用源码依赖的组件。在采用二进制版本时,如果想某些组件采用源码,可以向该方法传入组件名数组。
265
+
266
+
267
+ <!--
96
268
  ### For podspec
97
269
 
98
270
  > 目前只支持 iOS 平台 (插件内部也会进行限制)
@@ -172,11 +344,4 @@ end
172
344
  - tdfire_force_use_binary
173
345
  - 强制使用二进制依赖,确认值 1
174
346
  - 基本无用,在验证当前版本是否有对应二进制版本时可使用
175
-
176
-
177
- 例子:
178
-
179
- ```
180
- env tdfire_use_binary=1 tdfire_unpublished_pods=PodA pod lib lint xxxx
181
- env tdfire_force_use_source=1 pod install
182
- ```
347
+ -->
@@ -63,7 +63,12 @@ module Pod
63
63
  @invalid_specs ||= begin
64
64
  use_binary_specs.reject do |s|
65
65
  json_string = Pod::Tdfire::BinaryUrlManager.search_binary(s.root.name)
66
- pod = JSON.parse(json_string, object_class: OpenStruct)
66
+ begin
67
+ pod = JSON.parse(json_string, object_class: OpenStruct)
68
+ rescue JSON::ParserError => err
69
+ pod = OpenStruct.new
70
+ puts "获取 #{s.root.name} 二进制信息失败, 具体信息 #{err}"
71
+ end
67
72
  versions = pod.versions || []
68
73
  versions.include?(s.version.to_s)
69
74
  end
@@ -9,6 +9,7 @@ module Pod
9
9
  REPO_URL_KEY = 'repo_url'.freeze
10
10
  SERVER_ROOT_KEY = 'server_host'.freeze
11
11
  TEMPLATE_URL_KEY = 'template_url'.freeze
12
+ THREE_PARTY_GROUP_KEY = 'three_party_group'.freeze
12
13
 
13
14
  def self.instance
14
15
  @instance ||= new
@@ -26,6 +27,10 @@ module Pod
26
27
  setting_for_key(TEMPLATE_URL_KEY)
27
28
  end
28
29
 
30
+ def three_party_group
31
+ setting_for_key(THREE_PARTY_GROUP_KEY, 'cocoapods-repos')
32
+ end
33
+
29
34
  def setting_hash
30
35
  @setting ||= begin
31
36
  if File.exist?(binary_setting_file)
@@ -61,14 +66,14 @@ module Pod
61
66
  Config.instance
62
67
  end
63
68
 
64
- def setting_for_key(key)
69
+ def setting_for_key(key, default = nil)
65
70
  validate_setting_file
66
71
 
67
72
  setting = setting_hash[key]
68
- if setting.nil?
73
+ if setting.nil? && default.nil?
69
74
  raise Pod::Informative, "获取不到 #{key} 的配置信息,执行 pod binary init 或手动在 #{binary_setting_file} 设置."
70
75
  end
71
- setting
76
+ setting || default
72
77
  end
73
78
 
74
79
  def validate_setting_file
@@ -1,3 +1,3 @@
1
1
  module CocoapodsTdfireBinary
2
- VERSION = "1.3.14"
2
+ VERSION = "1.3.16"
3
3
  end
@@ -6,7 +6,8 @@ module Pod
6
6
  QUESTIONS = {
7
7
  BinaryConfig::SERVER_ROOT_KEY => '输入二进制服务器地址 (比如 http://xxxxx:8080)',
8
8
  BinaryConfig::REPO_URL_KEY => '输入私有源 Git 地址 (比如 https://github.com/tripleCC/PrivateSpecRepo.git)',
9
- BinaryConfig::TEMPLATE_URL_KEY => '输入 pod 模版 Git 地址 (比如 https://github.com/CocoaPods/pod-template.git)'
9
+ BinaryConfig::TEMPLATE_URL_KEY => '输入 pod 模版 Git 地址 (比如 https://github.com/CocoaPods/pod-template.git)',
10
+ BinaryConfig::THREE_PARTY_GROUP_KEY => '输入三方库所在的 group (比如 cocoapods-repos)'
10
11
  }
11
12
 
12
13
  def show_prompt
@@ -1,5 +1,6 @@
1
1
  require 'cocoapods-tdfire-binary/binary_state_store'
2
2
  require 'cocoapods-tdfire-binary/binary_specification_refactor'
3
+ require 'cocoapods-tdfire-binary/binary_config'
3
4
  require 'colored2'
4
5
 
5
6
  module Pod
@@ -101,7 +102,7 @@ module Pod
101
102
  private
102
103
  def tdfire_third_party?
103
104
  if source && source[:git]
104
- source[:git].include?('cocoapods-repos')
105
+ source[:git].include?(BinaryConfig.instance.three_party_group)
105
106
  # source[:git]&.include?('cocoapods-repos')
106
107
  else
107
108
  false
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-tdfire-binary
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.14
4
+ version: 1.3.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - tripleCC
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-09-27 00:00:00.000000000 Z
11
+ date: 2018-10-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler