cocoapods-tdfire-binary 0.1.10 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +4 -1
- data/README.md +93 -15
- data/cocoapods-tdfire-binary.gemspec +1 -0
- data/lib/cocoapods-tdfire-binary/binary_specification_refactor.rb +162 -0
- data/lib/cocoapods-tdfire-binary/binary_state_store.rb +3 -1
- data/lib/cocoapods-tdfire-binary/binary_url_manager.rb +41 -0
- data/lib/cocoapods-tdfire-binary/command.rb +1 -0
- data/lib/cocoapods-tdfire-binary/command/assemble.rb +36 -0
- data/lib/cocoapods-tdfire-binary/command/binary.rb +32 -0
- data/lib/cocoapods-tdfire-binary/command/lib.rb +16 -0
- data/lib/cocoapods-tdfire-binary/command/lib/create.rb +42 -0
- data/lib/cocoapods-tdfire-binary/command/lint.rb +17 -0
- data/lib/cocoapods-tdfire-binary/command/package.rb +87 -0
- data/lib/cocoapods-tdfire-binary/command/publish.rb +68 -0
- data/lib/cocoapods-tdfire-binary/command/pull.rb +39 -0
- data/lib/cocoapods-tdfire-binary/command/push.rb +78 -0
- data/lib/cocoapods-tdfire-binary/gem_version.rb +1 -1
- data/lib/cocoapods-tdfire-binary/podfile_dsl.rb +30 -17
- data/lib/cocoapods-tdfire-binary/podfile_hook.rb +24 -16
- data/lib/cocoapods-tdfire-binary/source_chain_analyzer.rb +1 -1
- data/lib/cocoapods-tdfire-binary/specification_dsl.rb +49 -79
- data/lib/cocoapods_plugin.rb +1 -0
- metadata +28 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 94e8dc020c5e66365a856c284dcdd3c7b1a00898
|
4
|
+
data.tar.gz: 9e8eddca9a7c4c3697a5b4cce1256f329d1656fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 51f6ec7edc094cf223b6569ccd75b8da5b4a01e2f7c459a3eebc43923d477cc3cc503776a78b1bb7b4d3f8e83c5ac2b1d3efbf7df95e1738dfc235544071fe1c
|
7
|
+
data.tar.gz: cbcffa261842a595262f2881eb8ae4e4ff446d05f76c88e3702a5c0277d1fe09b84d63b04e8893413dcc8477cfd011158eb3825abbe8f63ebf2099918f5de138
|
data/Gemfile.lock
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
cocoapods-tdfire-binary (0.
|
4
|
+
cocoapods-tdfire-binary (1.0.0)
|
5
5
|
cocoapods (~> 1.4)
|
6
|
+
cocoapods-packager (~> 1.5.0)
|
6
7
|
|
7
8
|
GEM
|
8
9
|
remote: https://rubygems.org/
|
@@ -41,6 +42,8 @@ GEM
|
|
41
42
|
nap (~> 1.0)
|
42
43
|
cocoapods-deintegrate (1.0.2)
|
43
44
|
cocoapods-downloader (1.1.3)
|
45
|
+
cocoapods-packager (1.5.0)
|
46
|
+
cocoapods (>= 1.1.1, < 2.0)
|
44
47
|
cocoapods-plugins (1.0.0)
|
45
48
|
nap
|
46
49
|
cocoapods-search (1.0.0)
|
data/README.md
CHANGED
@@ -5,15 +5,40 @@ A description of cocoapods-tdfire-binary.
|
|
5
5
|
## Installation
|
6
6
|
|
7
7
|
$ gem install cocoapods-tdfire-binary
|
8
|
+
|
9
|
+
|
10
|
+
## TODO
|
11
|
+
|
12
|
+
1. 拥有 Subspec 的组件二进制依赖方式
|
13
|
+
2. 本地 Lint 二进制
|
8
14
|
|
9
15
|
## Usage
|
10
16
|
|
11
|
-
|
17
|
+
```
|
18
|
+
|
19
|
+
Usage:
|
20
|
+
|
21
|
+
$ pod binary COMMAND
|
22
|
+
|
23
|
+
2Dfire 二进制工具库,提供打包、lint、推送、拉取、发布等命令
|
24
|
+
|
25
|
+
Commands:
|
26
|
+
|
27
|
+
+ lint 对本地二进制进行 Lint
|
28
|
+
+ package 二进制打包
|
29
|
+
+ publish 正式发布二进制组件
|
30
|
+
+ pull 下载二进制 zip 包
|
31
|
+
+ push 推送二进制 zip 包
|
32
|
+
|
33
|
+
```
|
34
|
+
|
35
|
+
### For .gitignore
|
12
36
|
|
13
37
|
```
|
14
38
|
...
|
15
39
|
|
16
40
|
*.framework
|
41
|
+
*.zip
|
17
42
|
```
|
18
43
|
|
19
44
|
> For Podfile
|
@@ -31,31 +56,84 @@ use_frameworks!
|
|
31
56
|
|
32
57
|
```
|
33
58
|
|
34
|
-
|
59
|
+
### For podspec
|
35
60
|
|
36
61
|
```
|
37
62
|
...
|
38
63
|
|
39
|
-
|
64
|
+
tdfire_source_configurator = lambda do |s|
|
40
65
|
# source configuration
|
66
|
+
# s.source_files = 'PodA/Classes/**/*'
|
67
|
+
# s.resource_bundles = {
|
68
|
+
# 'PodA' => ['PodA/Assets/*']
|
69
|
+
# }
|
41
70
|
end
|
42
71
|
|
43
|
-
unless %w[
|
72
|
+
unless %w[tdfire_set_binary_download_configurations tdfire_source tdfire_binary].reduce(true) { |r, m| s.respond_to?(m) & r }
|
44
73
|
|
45
|
-
|
74
|
+
tdfire_source_configurator.call s
|
46
75
|
else
|
47
|
-
s.tdfire_source
|
48
|
-
|
49
|
-
s.
|
50
|
-
|
51
|
-
|
52
|
-
|
76
|
+
s.tdfire_source tdfire_source_configurator
|
77
|
+
s.tdfire_binary tdfire_source_configurator
|
78
|
+
s.tdfire_set_binary_download_configurations
|
79
|
+
end
|
80
|
+
|
81
|
+
```
|
53
82
|
|
54
|
-
|
83
|
+
- tdfire_source_proc
|
84
|
+
- 配置源码依赖
|
85
|
+
|
86
|
+
- tdfire_binary
|
87
|
+
- 配置二进制依赖,其中 `vendored_framework`、`source_files`、`public_header_files` 内部设置成如下路径
|
88
|
+
|
89
|
+
```
|
90
|
+
s.vendored_framework = "#{s.name}.framework"
|
91
|
+
s.source_files = "#{s.name}.framework/Headers/*"
|
92
|
+
s.public_header_files = "#{s.name}.framework/Headers/*"
|
93
|
+
```
|
94
|
+
- 提取 subspec 中的依赖、frameworks、 libraries、 weak_frameworks,至二进制组件对应属性中
|
95
|
+
- 在组件源码依赖有 subspec 的情况下,插件会在二进制依赖时,动态创建 default subspec `TdfireBinary`,以及源码依赖时的 subspec ,并且让后者的所有 subspec 依赖 `TdfireBinary`
|
96
|
+
- 由于此方案对二进制中的 subspec 并**不做区分**,统一打包成一个二进制文件,所以如果在使用二进制依赖时,依赖了 subspec ,插件还是会去下载完整的二进制文件,并且从最终生成的结果看,目录中只有 `TdfireBinary` subspec
|
97
|
+
- 此插件不支持嵌套 subspec 场景,如
|
98
|
+
|
99
|
+
```ruby
|
100
|
+
Pod::Spec.new do |s|
|
101
|
+
s.name = 'Root'
|
102
|
+
s.subspec 'Level_1' do |sp|
|
103
|
+
sp.subspec 'Level_2' do |ssp|
|
104
|
+
end
|
105
|
+
end
|
55
106
|
end
|
107
|
+
```
|
108
|
+
|
109
|
+
- tdfire_set_binary_download_configurations
|
110
|
+
- 强制设置 static_framework 为 true,规避使用 use_frameworks! 时,动态库依赖链(动态库依赖静态库问题)、影响启动时间问题
|
111
|
+
- 设置 preserve_paths,让 cache 保留源码、资源、二进制全部文件
|
112
|
+
- preserve_paths 由组件,子组件的源码、资源路径,以及 Framework 路径组成
|
113
|
+
- 设置下载 prepare_command,未发布组件将会略过这一步骤
|
114
|
+
|
115
|
+
### For Lib Env
|
116
|
+
|
117
|
+
> Warning: 在发布二进制组件前,走二进制依赖流程,无法下载到对应 framework
|
118
|
+
|
119
|
+
|
120
|
+
- Env Key
|
121
|
+
- tdfire_use_binary
|
122
|
+
- 使用二进制依赖,确认值 1
|
123
|
+
- tdfire_unpublished_pods
|
124
|
+
- 未发布的组件,用 `|` 隔开 (如 PodA|PodB, 一般只有一个,即当前开发组件),设置后对应组件走源码依赖流程。
|
125
|
+
- 二进制 lint 时,无法通过 Podfile 的 plugin 获取当前的 development pod (即当前开发组件) ,在发布对应二进制版本前,走二进制依赖流程,是下不到对应二进制版本的,所以需要自己设置当前开发组件名,对这一部分进行源码依赖。
|
126
|
+
- tdfire_force_use_source
|
127
|
+
- 强制使用源码依赖,确认值 1
|
128
|
+
- 源码 lint 、未发布二进制组件前 CI 中 pod install / update (优先级比 Podfile 中的设置高) 时可使用
|
129
|
+
- tdfire_force_use_binary
|
130
|
+
- 强制使用二进制依赖,确认值 1
|
131
|
+
- 基本无用,在验证当前版本是否有对应二进制版本时可使用
|
56
132
|
|
57
|
-
|
58
|
-
|
59
|
-
end
|
133
|
+
|
134
|
+
例子:
|
60
135
|
|
61
136
|
```
|
137
|
+
env tdfire_use_binary=1 tdfire_unpublished_pods=PodA pod lib lint xxxx
|
138
|
+
env tdfire_force_use_source=1 pod install
|
139
|
+
```
|
@@ -0,0 +1,162 @@
|
|
1
|
+
require 'cocoapods-tdfire-binary/binary_url_manager'
|
2
|
+
|
3
|
+
module Pod
|
4
|
+
class Specification
|
5
|
+
#--------------------------------------------------------------------#
|
6
|
+
# => 获取自身以及子组件的属性合并值
|
7
|
+
#--------------------------------------------------------------------#
|
8
|
+
def all_value_for_attribute(name)
|
9
|
+
(Array(self) + Array(recursive_subspecs))
|
10
|
+
.map { |s| s.attributes_hash[name] }
|
11
|
+
.compact
|
12
|
+
end
|
13
|
+
|
14
|
+
def all_hash_value_for_attribute(name)
|
15
|
+
all_value_for_attribute(name).reduce({}, :merge)
|
16
|
+
end
|
17
|
+
|
18
|
+
def all_array_value_for_attribute(name)
|
19
|
+
all_value_for_attribute(name).flatten
|
20
|
+
end
|
21
|
+
|
22
|
+
def store_array_value_with_attribute_and_reference_spec(name, spec)
|
23
|
+
temp = spec.all_array_value_for_attribute(name)
|
24
|
+
temp += attributes_hash[name] unless attributes_hash[name].nil?
|
25
|
+
store_attribute(name, temp) unless temp.empty?
|
26
|
+
end
|
27
|
+
|
28
|
+
def store_hash_value_with_attribute_and_reference_spec(name, spec, &select)
|
29
|
+
temp = spec.all_hash_value_for_attribute(name)
|
30
|
+
temp.merge!(attributes_hash[name]) unless attributes_hash[name].nil?
|
31
|
+
temp.select! { |k, v| yield k if block_given? }
|
32
|
+
store_attribute(name, temp) unless temp.empty?
|
33
|
+
end
|
34
|
+
#--------------------------------------------------------------------#
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
module Tdfire
|
39
|
+
class BinarySpecificationRefactor
|
40
|
+
attr_accessor :target_spec
|
41
|
+
|
42
|
+
def initialize(target_spec)
|
43
|
+
@target_spec = target_spec
|
44
|
+
end
|
45
|
+
|
46
|
+
#--------------------------------------------------------------------#
|
47
|
+
# 生成default subspec TdfireBinary ,并将源码依赖时的配置转移到此 subspec 上
|
48
|
+
def configure_binary_default_subspec_with_reference_spec(spec)
|
49
|
+
default_subspec = "TdfireBinary"
|
50
|
+
target_spec.subspec default_subspec do |ss|
|
51
|
+
subspec_refactor = BinarySpecificationRefactor.new(ss)
|
52
|
+
subspec_refactor.configure_binary_with_reference_spec(spec)
|
53
|
+
end
|
54
|
+
|
55
|
+
# 创建源码依赖时的 subspec,并且设置所有的 subspec 依赖 default_subspec
|
56
|
+
spec.subspecs.each do |s|
|
57
|
+
target_spec.subspec s.base_name do |ss|
|
58
|
+
ss.dependency "#{target_spec.root.name}/#{default_subspec}"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
target_spec.default_subspec = default_subspec
|
63
|
+
target_spec.default_subspec = default_subspec
|
64
|
+
|
65
|
+
Pod::UI.message "Tdfire: subspecs for #{target_spec.name}: #{target_spec.subspecs.map(&:name).join(', ')}"
|
66
|
+
end
|
67
|
+
|
68
|
+
#--------------------------------------------------------------------#
|
69
|
+
# spec 是二进制依赖时的配置
|
70
|
+
def configure_binary_with_reference_spec(spec)
|
71
|
+
# 组件 frameworks 的依赖
|
72
|
+
target_spec.vendored_frameworks = "#{target_spec.root.name}.framework"
|
73
|
+
target_spec.source_files = "#{target_spec.root.name}.framework/Headers/*"
|
74
|
+
target_spec.public_header_files = "#{target_spec.root.name}.framework/Headers/*"
|
75
|
+
|
76
|
+
# 保留对 frameworks lib 的依赖
|
77
|
+
%w[frameworks libraries weak_frameworks].each do |name|
|
78
|
+
target_spec.store_array_value_with_attribute_and_reference_spec(name, spec)
|
79
|
+
end
|
80
|
+
|
81
|
+
# 保留对其他组件的依赖
|
82
|
+
target_spec.store_hash_value_with_attribute_and_reference_spec('dependencies', spec) do |name|
|
83
|
+
# 去除对自身子组件的依赖
|
84
|
+
name.split('/').first != target_spec.root.name
|
85
|
+
end
|
86
|
+
|
87
|
+
Pod::UI.message "Tdfire: dependencies for #{target_spec.name}: #{target_spec.dependencies.map(&:name).join(', ')}"
|
88
|
+
end
|
89
|
+
|
90
|
+
#--------------------------------------------------------------------#
|
91
|
+
# spec 是源码依赖时的配置
|
92
|
+
def set_preserve_paths_with_reference_spec(spec)
|
93
|
+
# 源码、资源文件
|
94
|
+
source_files = spec.all_array_value_for_attribute('source_files')
|
95
|
+
resources = spec.all_array_value_for_attribute('resources')
|
96
|
+
resource_bundles = spec.all_hash_value_for_attribute('resource_bundles')
|
97
|
+
source_preserve_paths = source_files + resources + resource_bundles.values.flatten
|
98
|
+
|
99
|
+
# 二进制文件
|
100
|
+
framework_preserve_paths = [framework_name]
|
101
|
+
preserve_paths = source_preserve_paths + framework_preserve_paths
|
102
|
+
|
103
|
+
# 保留原有的 preserve_paths
|
104
|
+
preserve_paths += target_spec.attributes_hash['preserve_paths'] unless target_spec.attributes_hash['preserve_paths'].nil?
|
105
|
+
target_spec.preserve_paths = preserve_paths.uniq
|
106
|
+
|
107
|
+
Pod::UI.message "Tdfire: preserve paths for #{target_spec.name}: #{preserve_paths.join(', ')}"
|
108
|
+
end
|
109
|
+
|
110
|
+
#--------------------------------------------------------------------#
|
111
|
+
|
112
|
+
def set_use_static_framework
|
113
|
+
target_spec.static_framework = true
|
114
|
+
end
|
115
|
+
|
116
|
+
#--------------------------------------------------------------------#
|
117
|
+
def set_framework_download_script
|
118
|
+
download_url = BinaryUrlManager.pull_url_for_pod_version(target_spec.root.name, target_spec.version)
|
119
|
+
|
120
|
+
download_script = <<-EOF
|
121
|
+
#!/bin/sh
|
122
|
+
|
123
|
+
if [[ -d #{framework_name} ]]; then
|
124
|
+
echo "Tdfire: #{framework_name} is not empty"
|
125
|
+
exit 0
|
126
|
+
fi
|
127
|
+
|
128
|
+
if [[ ! -d tdfire_download_temp ]]; then
|
129
|
+
mkdir tdfire_download_temp
|
130
|
+
fi
|
131
|
+
|
132
|
+
cd tdfire_download_temp
|
133
|
+
|
134
|
+
curl --fail -O -J -v #{download_url}
|
135
|
+
|
136
|
+
if [[ -f #{framework_name}.zip ]]; then
|
137
|
+
echo "Tdfire: copying #{framework_name} ..."
|
138
|
+
|
139
|
+
unzip #{framework_name}.zip
|
140
|
+
cp -fr #{framework_name} ../
|
141
|
+
fi
|
142
|
+
|
143
|
+
cd ..
|
144
|
+
rm -fr tdfire_download_temp
|
145
|
+
|
146
|
+
echo "pod cache path for #{target_spec.root.name}: $(pwd)"
|
147
|
+
EOF
|
148
|
+
|
149
|
+
combined_download_script = %Q[echo '#{download_script}' > download.sh && sh download.sh && rm download.sh]
|
150
|
+
combined_download_script += " && " << target_spec.prepare_command unless target_spec.prepare_command.nil?
|
151
|
+
|
152
|
+
target_spec.prepare_command = combined_download_script
|
153
|
+
end
|
154
|
+
|
155
|
+
#--------------------------------------------------------------------#
|
156
|
+
private
|
157
|
+
|
158
|
+
def framework_name
|
159
|
+
"#{target_spec.root.name}.framework"
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
@@ -7,9 +7,11 @@ module Tdfire
|
|
7
7
|
attr_accessor :use_source_pods
|
8
8
|
attr_reader :printed_pods
|
9
9
|
attr_accessor :use_frameworks
|
10
|
+
attr_accessor :use_source
|
10
11
|
end
|
11
|
-
|
12
|
+
|
12
13
|
@use_source_pods = []
|
14
|
+
@use_binary_pods = []
|
13
15
|
@printed_pods = []
|
14
16
|
@use_frameworks = false
|
15
17
|
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Tdfire
|
2
|
+
class BinaryUrlManager
|
3
|
+
HOST = "http://iosframeworkserver-shopkeeperclient.cloudapps.2dfire.com"
|
4
|
+
|
5
|
+
def self.pull_url_for_pod_version(pod, version)
|
6
|
+
HOST + "/getframework/PRODUCTION/#{pod}/#{version}"
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.get_pull_url_for_pod_version(pod, version)
|
10
|
+
command = "curl #{pull_url_for_pod_version(pod, version)} > #{pod}.framework.zip"
|
11
|
+
|
12
|
+
run_curl command
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.push_url
|
16
|
+
HOST + "/upload" #+ param
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.post_push_url(name, version, path, commit = nil, commit_hash = nil)
|
20
|
+
param = %Q[-F "frameworkName=#{name}" -F "version=#{version}" -F "environment=PRODUCTION" -F "changelog=#{commit}" -F "featureName=#{commit}" -F "framework=@#{path}" -F "commitHash=#{commit_hash}"]
|
21
|
+
command = "curl #{push_url} #{param}"
|
22
|
+
|
23
|
+
run_curl command
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.run_curl(command)
|
27
|
+
Pod::UI.message "CURL: \n" + command
|
28
|
+
|
29
|
+
system command
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.private_cocoapods_url
|
33
|
+
"git@git.2dfire-inc.com:ios/cocoapods-spec.git"
|
34
|
+
# "git@git.2dfire-inc.com:qingmu/private_cocoapods.git"
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.template_lib_url
|
38
|
+
"git@git.2dfire-inc.com:ios/binary-pod-template.git"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'cocoapods-tdfire-binary/command/binary'
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'cocoapods-tdfire-binary/command/package'
|
2
|
+
require 'cocoapods-tdfire-binary/command/lint'
|
3
|
+
require 'cocoapods-tdfire-binary/command/publish'
|
4
|
+
require 'cocoapods-tdfire-binary/command/push'
|
5
|
+
|
6
|
+
module Pod
|
7
|
+
class Command
|
8
|
+
class Binary < Command
|
9
|
+
class Assemble < Binary
|
10
|
+
self.abstract_command = false
|
11
|
+
self.summary = '执行二进制组件发布操作集合'
|
12
|
+
self.description = <<-DESC
|
13
|
+
执行二进制组件发布操作集合,依次为 package、lint、push、publish
|
14
|
+
DESC
|
15
|
+
|
16
|
+
def validate!
|
17
|
+
super
|
18
|
+
help! "当前目录下找不到有效的 podspec 文件" if first_podspec.nil?
|
19
|
+
end
|
20
|
+
|
21
|
+
def run
|
22
|
+
run_command Package
|
23
|
+
run_command Lint
|
24
|
+
run_command Push
|
25
|
+
run_command Publish
|
26
|
+
end
|
27
|
+
|
28
|
+
def run_command(command_class, argv = [])
|
29
|
+
lint = command_class::new(CLAide::ARGV.new(argv))
|
30
|
+
lint.validate!
|
31
|
+
lint.run
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'cocoapods-tdfire-binary/command/lint'
|
2
|
+
require 'cocoapods-tdfire-binary/command/package'
|
3
|
+
require 'cocoapods-tdfire-binary/command/publish'
|
4
|
+
require 'cocoapods-tdfire-binary/command/pull'
|
5
|
+
require 'cocoapods-tdfire-binary/command/push'
|
6
|
+
require 'cocoapods-tdfire-binary/command/assemble'
|
7
|
+
require 'cocoapods-tdfire-binary/command/lib'
|
8
|
+
|
9
|
+
module Pod
|
10
|
+
class Command
|
11
|
+
class Binary < Command
|
12
|
+
self.abstract_command = true
|
13
|
+
self.summary = '2Dfire 二进制工具库'
|
14
|
+
self.description = <<-DESC
|
15
|
+
2Dfire 二进制工具库,提供打包、lint、推送、拉取、发布等命令
|
16
|
+
DESC
|
17
|
+
|
18
|
+
FIRE_FLAG = "2dfire"
|
19
|
+
# FIRE_FLAG = "private"
|
20
|
+
|
21
|
+
def first_podspec
|
22
|
+
Dir["#{Dir.pwd}/*.podspec"].first
|
23
|
+
end
|
24
|
+
|
25
|
+
def fire_sources
|
26
|
+
config.sources_manager.all.select do |source|
|
27
|
+
source.url.downcase.include? FIRE_FLAG
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'cocoapods-tdfire-binary/command/lib/create'
|
2
|
+
|
3
|
+
module Pod
|
4
|
+
class Command
|
5
|
+
class Binary < Command
|
6
|
+
class Lib < Binary
|
7
|
+
self.abstract_command = true
|
8
|
+
self.default_subcommand = 'create'
|
9
|
+
self.summary = '二进制模版库操作'
|
10
|
+
self.description = <<-DESC
|
11
|
+
二进制模版库操作
|
12
|
+
DESC
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'cocoapods-tdfire-binary/binary_url_manager'
|
2
|
+
|
3
|
+
module Pod
|
4
|
+
class Command
|
5
|
+
class Binary < Command
|
6
|
+
class Lib < Binary
|
7
|
+
class Create < Lib
|
8
|
+
self.abstract_command = false
|
9
|
+
self.summary = '创建二进制模版库'
|
10
|
+
self.description = <<-DESC
|
11
|
+
创建二进制模版库
|
12
|
+
DESC
|
13
|
+
|
14
|
+
self.arguments = [
|
15
|
+
CLAide::Argument.new('NAME', true),
|
16
|
+
]
|
17
|
+
|
18
|
+
def initialize(argv)
|
19
|
+
@name = argv.shift_argument
|
20
|
+
super
|
21
|
+
end
|
22
|
+
|
23
|
+
def validate!
|
24
|
+
super
|
25
|
+
help! "必须提供有效组件名称" if @name.nil?
|
26
|
+
end
|
27
|
+
|
28
|
+
def run
|
29
|
+
argvs = [
|
30
|
+
"--template-url=#{Tdfire::BinaryUrlManager.template_lib_url}",
|
31
|
+
@name
|
32
|
+
]
|
33
|
+
|
34
|
+
create = Pod::Command::Lib::Create.new(CLAide::ARGV.new(argvs))
|
35
|
+
create.validate!
|
36
|
+
create.run
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
require 'colored2'
|
2
|
+
require 'fileutils'
|
3
|
+
require 'cocoapods-tdfire-binary/binary_url_manager'
|
4
|
+
require 'cocoapods-tdfire-binary/binary_specification_refactor'
|
5
|
+
|
6
|
+
module Pod
|
7
|
+
class Command
|
8
|
+
class Binary < Command
|
9
|
+
class Package < Binary
|
10
|
+
self.abstract_command = false
|
11
|
+
self.summary = '二进制打包'
|
12
|
+
self.description = <<-DESC
|
13
|
+
将源码打包成二进制,并压缩成 zip 包
|
14
|
+
DESC
|
15
|
+
|
16
|
+
def self.options
|
17
|
+
[
|
18
|
+
['--clean', '执行成功后,删除 zip 文件外的所有生成文件'],
|
19
|
+
['--spec-sources', '私有源地址'],
|
20
|
+
].concat(super)
|
21
|
+
end
|
22
|
+
|
23
|
+
def initialize(argv)
|
24
|
+
@clean = argv.flag?('clean')
|
25
|
+
@spec_sources = argv.option('spec-sources')
|
26
|
+
@spec_file = first_podspec
|
27
|
+
super
|
28
|
+
end
|
29
|
+
|
30
|
+
def validate!
|
31
|
+
super
|
32
|
+
help! '当前目录下没有podspec文件.' if @spec_file.nil?
|
33
|
+
end
|
34
|
+
|
35
|
+
def run
|
36
|
+
spec = Specification.from_file(@spec_file)
|
37
|
+
package(spec)
|
38
|
+
zip(spec)
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def package(spec)
|
44
|
+
UI.section("Tdfire: package #{spec.name} ...") do
|
45
|
+
system "pod package #{spec.name}.podspec --exclude-deps --force --no-mangle --spec-sources=#{@spec_sources || Tdfire::BinaryUrlManager.private_cocoapods_url}"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def zip(spec)
|
50
|
+
framework_directory = "#{spec.name}-#{spec.version}/ios"
|
51
|
+
framework_name = "#{spec.name}.framework"
|
52
|
+
framework_path = "#{framework_directory}/#{framework_name}"
|
53
|
+
|
54
|
+
raise Informative, "没有需要压缩的 framework 文件:#{framework_path}" unless File.exist?(framework_path)
|
55
|
+
|
56
|
+
# cocoapods-packager 使用了 --exclude-deps 后,虽然没有把 dependency 的符号信息打进可执行文件,但是它把 dependency 的 bundle 给拷贝过来了 (builder.rb 229 copy_resources)
|
57
|
+
# 这里把多余的 bundle 删除
|
58
|
+
# https://github.com/CocoaPods/cocoapods-packager/pull/199
|
59
|
+
resource_bundles = spec.all_hash_value_for_attribute('resource_bundles').keys.flatten.uniq
|
60
|
+
FileUtils.chdir("#{framework_path}/Versions/A/Resources") do
|
61
|
+
dependency_bundles = Dir.glob('*.bundle').select { |b| !resource_bundles.include?(b.split('.').first) }
|
62
|
+
unless dependency_bundles.empty?
|
63
|
+
Pod::UI::puts "Tdfire: remove dependency bundles: #{dependency_bundles.join(', ')}"
|
64
|
+
|
65
|
+
dependency_bundles.each do |b|
|
66
|
+
FileUtils.rm_rf(b)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
output_name = "#{framework_name}.zip"
|
72
|
+
UI.section("Tdfire: zip #{framework_path} ...") do
|
73
|
+
FileUtils.chdir(framework_directory) do
|
74
|
+
system "zip --symlinks -r #{output_name} #{framework_name}"
|
75
|
+
system "mv #{output_name} ../../"
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
Pod::UI::puts "Tdfire: save framework zip file to #{Dir.pwd}/#{output_name}".green
|
80
|
+
|
81
|
+
system "rm -fr #{spec.name}-#{@spec.version}" if @clean
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
module Pod
|
2
|
+
class Command
|
3
|
+
class Binary < Command
|
4
|
+
class Publish < Binary
|
5
|
+
self.abstract_command = false
|
6
|
+
self.summary = '正式发布二进制组件'
|
7
|
+
self.description = <<-DESC
|
8
|
+
正式发布二进制组件版本
|
9
|
+
DESC
|
10
|
+
|
11
|
+
self.arguments = [
|
12
|
+
CLAide::Argument.new('NAME.podspec', false),
|
13
|
+
]
|
14
|
+
|
15
|
+
def self.options
|
16
|
+
[
|
17
|
+
['--commit="Fix some bugs"', '发布的 commit 信息']
|
18
|
+
].concat(super)
|
19
|
+
end
|
20
|
+
|
21
|
+
def initialize(argv)
|
22
|
+
spec_file = argv.shift_argument
|
23
|
+
@commit = argv.option('commit')
|
24
|
+
|
25
|
+
spec_file = first_podspec if spec_file.nil?
|
26
|
+
@spec_file = spec_file
|
27
|
+
super
|
28
|
+
end
|
29
|
+
|
30
|
+
def validate!
|
31
|
+
super
|
32
|
+
help! "当前目录下找不到有效的 podspec 文件" if @spec_file.nil?
|
33
|
+
end
|
34
|
+
|
35
|
+
def run
|
36
|
+
spec = Specification.from_file(@spec_file)
|
37
|
+
|
38
|
+
UI.section("Tdfire: start publishing #{spec.name} ...") do
|
39
|
+
argvs = [
|
40
|
+
fire_sources.first.name,
|
41
|
+
@spec_file,
|
42
|
+
'--allow-warnings',
|
43
|
+
'--use-libraries',
|
44
|
+
'--verbose'
|
45
|
+
]
|
46
|
+
argvs << %Q[--commit-message=#{commit_prefix(spec) + "\n" + @commit}] unless @commit.to_s.empty?
|
47
|
+
|
48
|
+
push = Pod::Command::Repo::Push.new(CLAide::ARGV.new(argvs))
|
49
|
+
push.validate!
|
50
|
+
push.run
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
def commit_prefix(spec)
|
56
|
+
output_path = fire_sources.first.pod_path(spec.name) + spec.version.to_s
|
57
|
+
if output_path.exist?
|
58
|
+
message = "[Fix] #{spec}"
|
59
|
+
elsif output_path.dirname.directory?
|
60
|
+
message = "[Update] #{spec}"
|
61
|
+
else
|
62
|
+
message = "[Add] #{spec}"
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'cocoapods-tdfire-binary/binary_url_manager'
|
2
|
+
|
3
|
+
module Pod
|
4
|
+
class Command
|
5
|
+
class Binary < Command
|
6
|
+
class Pull < Binary
|
7
|
+
self.abstract_command = false
|
8
|
+
self.summary = '下载二进制 zip 包'
|
9
|
+
self.description = <<-DESC
|
10
|
+
通过 NAME 和 VERSION ,下载二进制 zip 包
|
11
|
+
DESC
|
12
|
+
|
13
|
+
self.arguments = [
|
14
|
+
CLAide::Argument.new('NAME', true),
|
15
|
+
CLAide::Argument.new('VERSION', true)
|
16
|
+
]
|
17
|
+
|
18
|
+
def initialize(argv)
|
19
|
+
@name = argv.shift_argument
|
20
|
+
@version = argv.shift_argument
|
21
|
+
super
|
22
|
+
end
|
23
|
+
|
24
|
+
def validate!
|
25
|
+
super
|
26
|
+
help! "必须提供有效组件名" if @name.nil?
|
27
|
+
help! "必须提供有效版本号" if @version.nil?
|
28
|
+
end
|
29
|
+
|
30
|
+
def run
|
31
|
+
UI.section("Tdfire: start pulling framework zip file ...") do
|
32
|
+
UI.puts "Tdfire: get argvs: name -> #{@name}, version -> #{@version}"
|
33
|
+
Tdfire::BinaryUrlManager.get_pull_url_for_pod_version(@name, @version)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
|
2
|
+
require 'cocoapods-tdfire-binary/binary_url_manager'
|
3
|
+
|
4
|
+
module Pod
|
5
|
+
class Command
|
6
|
+
class Binary < Command
|
7
|
+
class Push < Binary
|
8
|
+
ZIP_SUBFFIX = '.framework.zip'
|
9
|
+
|
10
|
+
self.abstract_command = false
|
11
|
+
self.summary = '推送二进制 zip 包'
|
12
|
+
self.description = <<-DESC
|
13
|
+
将二进制 zip 包推送至二进制服务器
|
14
|
+
DESC
|
15
|
+
|
16
|
+
self.arguments = [
|
17
|
+
CLAide::Argument.new('PATH', false)
|
18
|
+
]
|
19
|
+
|
20
|
+
def self.options
|
21
|
+
[
|
22
|
+
['--name=组件名', '推送二进制的组件名'],
|
23
|
+
['--version=版本号', '推送二进制的版本号'],
|
24
|
+
['--commit=版本日志', '推送二进制的版本日志'],
|
25
|
+
].concat(super)
|
26
|
+
end
|
27
|
+
|
28
|
+
def initialize(argv)
|
29
|
+
path = argv.shift_argument
|
30
|
+
name = argv.option('name')
|
31
|
+
version = argv.option('version')
|
32
|
+
commit = argv.option('commit')
|
33
|
+
|
34
|
+
unless first_podspec.nil?
|
35
|
+
if path.nil?
|
36
|
+
path = first_podspec.split('.').first
|
37
|
+
end
|
38
|
+
|
39
|
+
spec = Specification.from_file(Pathname.new(first_podspec))
|
40
|
+
version = spec.version if version.nil?
|
41
|
+
name = spec.name
|
42
|
+
end
|
43
|
+
|
44
|
+
path += ZIP_SUBFFIX unless path.end_with?(ZIP_SUBFFIX)
|
45
|
+
|
46
|
+
|
47
|
+
@path = path
|
48
|
+
@name = name || path.split('/').last - ZIP_SUBFFIX
|
49
|
+
@version = version
|
50
|
+
@commit = commit
|
51
|
+
super
|
52
|
+
end
|
53
|
+
|
54
|
+
def validate!
|
55
|
+
super
|
56
|
+
help! "指定目录下没有可推送文件: #{@path}" unless File.exist?(@path)
|
57
|
+
help! "必须为推送组件指定版本(--version)" if @version.nil?
|
58
|
+
end
|
59
|
+
|
60
|
+
def run
|
61
|
+
tag_log = `git tag -l -n #{@version}`
|
62
|
+
tag_log = tag_log.split(' ')[1..-1].join('') unless tag_log.empty?
|
63
|
+
|
64
|
+
|
65
|
+
hash_log = `git show-ref #{@version}`
|
66
|
+
hash_log = hash_log.split(' ').first unless hash_log.empty?
|
67
|
+
|
68
|
+
commit = @commit || tag_log || @version
|
69
|
+
|
70
|
+
UI.section("Tdfire: start pushing framework zip file ...") do
|
71
|
+
UI.puts "Tdfire: post argvs: name -> #{@name}, version -> #{@version}, path -> #{@path}, commit -> #{commit}, commit hash -> #{hash_log}"
|
72
|
+
Tdfire::BinaryUrlManager.post_push_url(@name, @version, @path, commit, hash_log)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -15,6 +15,19 @@ module Pod
|
|
15
15
|
Tdfire::BinaryStateStore.set_use_binary
|
16
16
|
end
|
17
17
|
|
18
|
+
# 因为暂时无法将全部组件二进制化,tdfire_use_binary! 默认全部进行二进制依赖不利于渐进测试
|
19
|
+
# 所以添加 tdfire_use_source! 默认全部进行源码依赖,开放指定二进制依赖组件接口
|
20
|
+
#
|
21
|
+
# 使用二进制依赖的pod
|
22
|
+
# 与 tdfire_use_binary 互斥
|
23
|
+
# def tdfire_use_binary_pods(pods)
|
24
|
+
# Pod::UI.puts "Tdfire: set use binary pods: #{Array(pods).join(', ')}"
|
25
|
+
# Tdfire::BinaryStateStore.use_binary_pods = Array(pods)
|
26
|
+
# end
|
27
|
+
#
|
28
|
+
# def tdfire_use_source!
|
29
|
+
# end
|
30
|
+
|
18
31
|
# 强制使用二进制依赖,忽略未发布和依赖源码设置
|
19
32
|
# def tdfire_force_use_binary!
|
20
33
|
# Tdfire::BinaryStateStore.set_force_use_binary
|
@@ -24,27 +37,27 @@ module Pod
|
|
24
37
|
def tdfire_external_pods(pods, *rest)
|
25
38
|
argvs = rest.last || {}
|
26
39
|
if !argvs.kind_of?(Hash)
|
27
|
-
info =
|
28
|
-
输入参数错误.
|
40
|
+
info = <<~EOF
|
41
|
+
输入参数错误.
|
29
42
|
|
30
|
-
Example:
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
43
|
+
Example:
|
44
|
+
tdfire_external_pods ['TDFCore'], source:'git', group:'ios', branch:'develop'
|
45
|
+
tdfire_external_pods 'TDFCore', source:'git', group:'ios', branch:'develop'
|
46
|
+
tdfire_external_pods ['TDFCore'], group:'cocoapods'
|
47
|
+
...
|
35
48
|
|
36
|
-
默认值:
|
37
|
-
|
38
|
-
|
39
|
-
|
49
|
+
默认值:
|
50
|
+
source:path
|
51
|
+
group:ios
|
52
|
+
branch:develop
|
40
53
|
|
41
|
-
所有值:
|
42
|
-
|
43
|
-
|
44
|
-
|
54
|
+
所有值:
|
55
|
+
source -> git path
|
56
|
+
group -> 任意
|
57
|
+
branch -> 任意
|
45
58
|
|
46
|
-
格式可以和pod语法一致
|
47
|
-
EOF
|
59
|
+
格式可以和pod语法一致
|
60
|
+
EOF
|
48
61
|
raise Pod::Informative, info
|
49
62
|
end
|
50
63
|
|
@@ -5,13 +5,19 @@ module CocoapodsTdfireBinary
|
|
5
5
|
include Tdfire
|
6
6
|
|
7
7
|
Pod::HooksManager.register('cocoapods-tdfire-binary', :pre_install) do |context, _|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
8
|
+
# 使用 cocoapods package 打包,不使用 carthage 了,不用设置 share schemes
|
9
|
+
# 如果使用 carhtage ,一定要让需要二进制化的 target shared,此 target 不能是 static framework / library ,必须是 dynamic framework.
|
10
|
+
# 并且需要在这里做个标记,记录目标 target ,让这个 target 对应的 podspec 跳过 set_use_static_framework 这一步.
|
11
|
+
# pod install 时,强制使用源码,然后使用 --no-skip-current iOS --no-use-binaries
|
12
|
+
# carthage 生成 static framework 参照 https://github.com/Carthage/Carthage/blob/master/Documentation/StaticFrameworks.md
|
13
|
+
#
|
14
|
+
# first_target_definition = context.podfile.target_definition_list.select{ |d| d.name != 'Pods' }.first
|
15
|
+
# development_pod = first_target_definition.name.split('_').first unless first_target_definition.nil?
|
16
|
+
#
|
17
|
+
# Pod::UI.section("Tdfire: auto set share scheme for development pod: \'#{development_pod}\'") do
|
18
|
+
# # carthage 需要 shared scheme 构建 framework
|
19
|
+
# context.podfile.install!('cocoapods', :share_schemes_for_development_pods => [development_pod])
|
20
|
+
# end unless development_pod.nil?
|
15
21
|
|
16
22
|
|
17
23
|
# 标明未发布的pod,因为未发布pod没有对应的二进制版本,无法下载
|
@@ -22,17 +28,19 @@ module CocoapodsTdfireBinary
|
|
22
28
|
Pod::UI.message "> Tdfire: unpublished pods: #{BinaryStateStore.unpublished_pods.join(', ')}"
|
23
29
|
end
|
24
30
|
|
31
|
+
# 使用 static_framework ,不用 dynamic_framework ,不需要关心 dynamic_framework 的依赖链了
|
32
|
+
#
|
25
33
|
# 没有标识use_frameworks!,进行源码依赖需要设置Pod依赖链上,依赖此源码Pod的也进行源码依赖
|
26
|
-
BinaryStateStore.use_frameworks = first_target_definition.uses_frameworks?
|
27
|
-
unless BinaryStateStore.use_frameworks
|
28
|
-
|
29
|
-
|
34
|
+
# BinaryStateStore.use_frameworks = first_target_definition.uses_frameworks?
|
35
|
+
# unless BinaryStateStore.use_frameworks
|
36
|
+
# Pod::UI.section("Tdfire: analyze chain pods depend on use source pods: #{BinaryStateStore.use_source_pods.join(', ')}") do
|
37
|
+
# chain_pods = SourceChainAnalyzer.new(context.podfile).analyze(BinaryStateStore.use_source_pods)
|
30
38
|
|
31
|
-
|
39
|
+
# Pod::UI.message "> Tdfire: find chain pods: #{chain_pods.join(', ')}"
|
32
40
|
|
33
|
-
|
34
|
-
|
35
|
-
end
|
41
|
+
# BinaryStateStore.use_source_pods += chain_pods
|
42
|
+
# end unless BinaryStateStore.use_source_pods.empty?
|
43
|
+
# end
|
36
44
|
end
|
37
45
|
|
38
46
|
#fix `Shell Script` Build Phase Fails When Input / Output Files List is Too Large
|
@@ -54,7 +62,7 @@ module CocoapodsTdfireBinary
|
|
54
62
|
|
55
63
|
context.umbrella_targets.map(&:user_project).each do |project|
|
56
64
|
project.save
|
57
|
-
end
|
65
|
+
end
|
58
66
|
end
|
59
67
|
|
60
68
|
Pod::UI.puts "Tdfire: all source dependency pods: #{BinaryStateStore.real_use_source_pods.join(', ')}" if BinaryStateStore.use_binary?
|
@@ -1,116 +1,86 @@
|
|
1
1
|
require 'cocoapods-tdfire-binary/binary_state_store'
|
2
|
+
require 'cocoapods-tdfire-binary/binary_specification_refactor'
|
2
3
|
require 'colored2'
|
3
4
|
|
4
5
|
module Pod
|
5
6
|
class Specification
|
6
|
-
|
7
|
+
include Tdfire
|
7
8
|
|
8
|
-
|
9
|
+
def tdfire_refactor
|
10
|
+
@refactor ||= BinarySpecificationRefactor.new(self)
|
11
|
+
end
|
9
12
|
|
10
|
-
|
11
|
-
(!Tdfire::BinaryStateStore.force_use_binary? &&
|
12
|
-
(!Tdfire::BinaryStateStore.use_binary? || Tdfire::BinaryStateStore.real_use_source_pods.include?(name))) ||
|
13
|
-
Tdfire::BinaryStateStore.force_use_source?
|
14
|
-
end
|
13
|
+
module DSL
|
15
14
|
|
16
|
-
|
15
|
+
public
|
17
16
|
|
17
|
+
# 此次操作,Podfile 是否使用了 use_frameworks!
|
18
18
|
def tdfire_use_frameworks?
|
19
19
|
Tdfire::BinaryStateStore.use_frameworks
|
20
20
|
end
|
21
21
|
|
22
|
-
|
23
|
-
def tdfire_source(
|
24
|
-
if
|
25
|
-
if !Tdfire::BinaryStateStore.printed_pods.include?(name)
|
26
|
-
|
27
|
-
Tdfire::BinaryStateStore.printed_pods << name
|
22
|
+
# 源码依赖配置
|
23
|
+
def tdfire_source(configurator)
|
24
|
+
if tdfire_use_source?
|
25
|
+
if !Tdfire::BinaryStateStore.printed_pods.include?(root.name)
|
26
|
+
UI.message "Source".magenta.bold + " dependecy for " + "#{root.name} #{version}".green.bold
|
27
|
+
Tdfire::BinaryStateStore.printed_pods << root.name
|
28
28
|
end
|
29
29
|
|
30
|
-
|
30
|
+
configurator.call self
|
31
|
+
|
32
|
+
# 在设置了 use_frameworks! 的情况下才会生效
|
33
|
+
tdfire_refactor.set_use_static_framework
|
31
34
|
end
|
32
35
|
end
|
33
36
|
|
34
37
|
# 二进制依赖配置
|
35
|
-
def tdfire_binary(&block)
|
36
|
-
if !
|
37
|
-
if !Tdfire::BinaryStateStore.printed_pods.include?(name)
|
38
|
-
|
39
|
-
Tdfire::BinaryStateStore.printed_pods << name
|
38
|
+
def tdfire_binary(configurator, &block)
|
39
|
+
if !tdfire_use_source?
|
40
|
+
if !Tdfire::BinaryStateStore.printed_pods.include?(root.name)
|
41
|
+
UI.message "Binary".cyan.bold + " dependecy for " + "#{root.name} #{version}".green.bold
|
42
|
+
Tdfire::BinaryStateStore.printed_pods << root.name
|
40
43
|
end
|
41
44
|
|
42
45
|
yield self if block_given?
|
46
|
+
|
47
|
+
# name 一定要有,否则 subspec dependecy 会出现 split nil 错误
|
48
|
+
@tdfire_reference_spec = Specification.new(nil, 'TdfireSpecification')
|
49
|
+
configurator.call @tdfire_reference_spec
|
50
|
+
|
51
|
+
# 如果存在 subspec,则生成 default subpsec ,并将所有的 subspec 配置转移到此 subspec 中
|
52
|
+
# 已存在的 subspec 依赖此 subspec
|
53
|
+
unless @tdfire_reference_spec.subspecs.empty?
|
54
|
+
tdfire_refactor.configure_binary_default_subspec_with_reference_spec( @tdfire_reference_spec)
|
55
|
+
else
|
56
|
+
tdfire_refactor.configure_binary_with_reference_spec( @tdfire_reference_spec)
|
57
|
+
end
|
43
58
|
end
|
44
59
|
end
|
45
60
|
|
46
61
|
# 配置二进制文件下载、cache 住解压好的 framework
|
47
|
-
def
|
62
|
+
def tdfire_set_binary_download_configurations
|
63
|
+
tdfire_refactor.set_preserve_paths_with_reference_spec(tdfire_reference_spec)
|
48
64
|
|
49
65
|
# 没有发布的pod,没有二进制版本,不进行下载配置
|
50
|
-
return if !Tdfire::BinaryStateStore.force_use_binary? && Tdfire::BinaryStateStore.unpublished_pods.include?(name)
|
51
|
-
|
52
|
-
raise Pod::Informative, "You must invoke the method after setting name and version" if name.nil? || version.nil?
|
53
|
-
|
54
|
-
set_framework_preserve_paths
|
55
|
-
set_framework_download_script(download_url || framework_url_for_pod_version(name, version))
|
56
|
-
end
|
57
|
-
|
58
|
-
private
|
59
|
-
|
60
|
-
def framework_url_for_pod_version(pod, version)
|
61
|
-
"http://iosframeworkserver-shopkeeperclient.cloudapps.2dfire.com/getframework/PRODUCTION/#{pod}/#{version}"
|
62
|
-
end
|
63
|
-
|
64
|
-
def set_framework_preserve_paths
|
65
|
-
framework_preserve_paths = ["#{name}.framework"]
|
66
|
-
framework_preserve_paths += consumer(Platform.ios).preserve_paths unless consumer(Platform.ios).preserve_paths.nil?
|
66
|
+
return if !Tdfire::BinaryStateStore.force_use_binary? && Tdfire::BinaryStateStore.unpublished_pods.include?(root.name)
|
67
67
|
|
68
|
-
|
69
|
-
source_preserve_paths = ["#{name}/**/**/*", "Classes/**/*"]
|
68
|
+
raise Pod::Informative, "You must invoke the method after setting name and version" if root.name.nil? || version.nil?
|
70
69
|
|
71
|
-
|
72
|
-
store_attribute('preserve_paths', framework_preserve_paths + source_preserve_paths)
|
70
|
+
tdfire_refactor.set_framework_download_script
|
73
71
|
end
|
72
|
+
end
|
74
73
|
|
75
|
-
|
76
|
-
framework_name = "#{name}.framework"
|
77
|
-
framework_relative_path = "Carthage/Build/iOS/#{framework_name}"
|
78
|
-
|
79
|
-
download_script = <<-EOF
|
80
|
-
#!/bin/sh
|
81
|
-
|
82
|
-
if [[ -d #{framework_name} ]]; then
|
83
|
-
echo "Tdfire: #{framework_name} is not empty"
|
84
|
-
exit 0
|
85
|
-
fi
|
86
|
-
|
87
|
-
if [[ ! -d tdfire_download_temp ]]; then
|
88
|
-
mkdir tdfire_download_temp
|
89
|
-
fi
|
90
|
-
|
91
|
-
cd tdfire_download_temp
|
92
|
-
|
93
|
-
curl --fail -O -J -v #{download_url}
|
94
|
-
|
95
|
-
if [[ -f #{framework_name}.zip ]]; then
|
96
|
-
echo "Tdfire: copying #{framework_name} ..."
|
97
|
-
|
98
|
-
unzip #{framework_name}.zip
|
99
|
-
cp -fr #{framework_relative_path} ../
|
100
|
-
fi
|
101
|
-
|
102
|
-
cd ..
|
103
|
-
rm -fr tdfire_download_temp
|
104
|
-
|
105
|
-
echo "pod cache path for #{name}: $(pwd)"
|
106
|
-
EOF
|
74
|
+
private
|
107
75
|
|
108
|
-
|
109
|
-
|
76
|
+
def tdfire_reference_spec
|
77
|
+
@tdfire_reference_spec || self
|
78
|
+
end
|
110
79
|
|
111
|
-
|
112
|
-
|
113
|
-
|
80
|
+
def tdfire_use_source?
|
81
|
+
(!Tdfire::BinaryStateStore.force_use_binary? &&
|
82
|
+
(!Tdfire::BinaryStateStore.use_binary? || Tdfire::BinaryStateStore.real_use_source_pods.include?(root.name))) ||
|
83
|
+
Tdfire::BinaryStateStore.force_use_source?
|
114
84
|
end
|
115
85
|
end
|
116
86
|
end
|
data/lib/cocoapods_plugin.rb
CHANGED
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: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- tripleCC
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-04-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '1.4'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: cocoapods-packager
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.5.0
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 1.5.0
|
55
69
|
description: cocoapods-tdfire-binary is a plugin which helps developer switching there
|
56
70
|
project dependency between source and binary.
|
57
71
|
email:
|
@@ -68,7 +82,19 @@ files:
|
|
68
82
|
- Rakefile
|
69
83
|
- cocoapods-tdfire-binary.gemspec
|
70
84
|
- lib/cocoapods-tdfire-binary.rb
|
85
|
+
- lib/cocoapods-tdfire-binary/binary_specification_refactor.rb
|
71
86
|
- lib/cocoapods-tdfire-binary/binary_state_store.rb
|
87
|
+
- lib/cocoapods-tdfire-binary/binary_url_manager.rb
|
88
|
+
- lib/cocoapods-tdfire-binary/command.rb
|
89
|
+
- lib/cocoapods-tdfire-binary/command/assemble.rb
|
90
|
+
- lib/cocoapods-tdfire-binary/command/binary.rb
|
91
|
+
- lib/cocoapods-tdfire-binary/command/lib.rb
|
92
|
+
- lib/cocoapods-tdfire-binary/command/lib/create.rb
|
93
|
+
- lib/cocoapods-tdfire-binary/command/lint.rb
|
94
|
+
- lib/cocoapods-tdfire-binary/command/package.rb
|
95
|
+
- lib/cocoapods-tdfire-binary/command/publish.rb
|
96
|
+
- lib/cocoapods-tdfire-binary/command/pull.rb
|
97
|
+
- lib/cocoapods-tdfire-binary/command/push.rb
|
72
98
|
- lib/cocoapods-tdfire-binary/gem_version.rb
|
73
99
|
- lib/cocoapods-tdfire-binary/podfile_dsl.rb
|
74
100
|
- lib/cocoapods-tdfire-binary/podfile_hook.rb
|