cocoapods-tdfire-binary 1.0.10 → 1.1.0

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
  SHA1:
3
- metadata.gz: f18d003702464d5348466610a3bf47a5b8b7f051
4
- data.tar.gz: aa789bc5aa73e6b9daf31b4bd2f2a3fd1ac0141b
3
+ metadata.gz: 2c3223e645db7605a686c87ec21cd8e9f65137f7
4
+ data.tar.gz: 2d77cd8c5f649508103672cf68e620121a358ca7
5
5
  SHA512:
6
- metadata.gz: 58d963064f599b58aebdf327526b9b7d2ce21fd9b1ef4fd1fe4e6c3b6016b5d1aceaf93bfa7a928f4bf7805e5b59900fc1a6597567cfb4f54c0f7537d8b0101b
7
- data.tar.gz: 63b57e9f55de5e684b669b573722cb4d8650728a838fa1bfccccfda3e8fc1ca530983b7bcbe8e9c6a8a9dd61ae518d37581ba3f4b83d9f30095fe9d5a3ac5b2d
6
+ metadata.gz: dec1824477e3e4733e3d4a427512a6e3a7131f02bd5ae244753ca9ef0a0732be3287d7b1580ea1f921e6015e8d1a59408efb418f73a5ad1779116b6db7769169
7
+ data.tar.gz: 5ec985ed6396951b4bf3e7b9938e183cdb38fdc5d6128ac261a38b1a31b4888d87e1088cb57214cf95b29523400fe7865e7a8c9f01c13839fb465b6dbc3178a6
data/.bundle/config ADDED
@@ -0,0 +1,2 @@
1
+ ---
2
+ BUNDLE_BIN: "bin"
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
1
  .DS_Store
2
2
  pkg
3
3
  .idea/
4
+ bin/
data/.travis.yml ADDED
@@ -0,0 +1,8 @@
1
+ osx_image: xcode7.3
2
+ language: ruby
3
+ cache: bundler
4
+ before_install:
5
+ - bundle install
6
+ - bundle exec pod repo update --silent
7
+ script:
8
+ - bundle exec rake spec
@@ -0,0 +1,64 @@
1
+ {
2
+ // 使用 IntelliSense 了解相关属性。
3
+ // 悬停以查看现有属性的描述。
4
+ // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
5
+ "version": "0.2.0",
6
+ "configurations": [
7
+ {
8
+ "name": "Debug Local File",
9
+ "type": "Ruby",
10
+ "request": "launch",
11
+ "cwd": "${workspaceRoot}",
12
+ "program": "${workspaceRoot}/main.rb"
13
+ },
14
+ {
15
+ "name": "Listen for rdebug-ide",
16
+ "type": "Ruby",
17
+ "request": "attach",
18
+ "cwd": "${workspaceRoot}",
19
+ "remoteHost": "127.0.0.1",
20
+ "remotePort": "1234",
21
+ "remoteWorkspaceRoot": "${workspaceRoot}"
22
+ },
23
+ {
24
+ "name": "Rails server",
25
+ "type": "Ruby",
26
+ "request": "launch",
27
+ "cwd": "${workspaceRoot}",
28
+ "program": "${workspaceRoot}/bin/rails",
29
+ "args": [
30
+ "server"
31
+ ]
32
+ },
33
+ {
34
+ "name": "RSpec - all",
35
+ "type": "Ruby",
36
+ "request": "launch",
37
+ "cwd": "${workspaceRoot}",
38
+ "program": "${workspaceRoot}/bin/rspec",
39
+ "args": [
40
+ "-I",
41
+ "${workspaceRoot}"
42
+ ]
43
+ },
44
+ {
45
+ "name": "RSpec - active spec file only",
46
+ "type": "Ruby",
47
+ "request": "launch",
48
+ "cwd": "${workspaceRoot}",
49
+ "program": "${workspaceRoot}/bin/rspec",
50
+ "args": [
51
+ "-I",
52
+ "${workspaceRoot}",
53
+ "${file}"
54
+ ]
55
+ },
56
+ {
57
+ "name": "Cucumber",
58
+ "type": "Ruby",
59
+ "request": "launch",
60
+ "cwd": "${workspaceRoot}",
61
+ "program": "${workspaceRoot}/bin/cucumber"
62
+ }
63
+ ]
64
+ }
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cocoapods-tdfire-binary (1.0.10)
4
+ cocoapods-tdfire-binary (1.1.0)
5
5
  cocoapods (~> 1.2)
6
6
  cocoapods-packager (~> 1.5.0)
7
7
 
@@ -17,27 +17,27 @@ GEM
17
17
  atomos (0.1.2)
18
18
  bacon (1.2.0)
19
19
  claide (1.0.2)
20
- cocoapods (1.2.1)
20
+ cocoapods (1.5.0)
21
21
  activesupport (>= 4.0.2, < 5)
22
- claide (>= 1.0.1, < 2.0)
23
- cocoapods-core (= 1.2.1)
24
- cocoapods-deintegrate (>= 1.0.1, < 2.0)
25
- cocoapods-downloader (>= 1.1.3, < 2.0)
22
+ claide (>= 1.0.2, < 2.0)
23
+ cocoapods-core (= 1.5.0)
24
+ cocoapods-deintegrate (>= 1.0.2, < 2.0)
25
+ cocoapods-downloader (>= 1.2.0, < 2.0)
26
26
  cocoapods-plugins (>= 1.0.0, < 2.0)
27
27
  cocoapods-search (>= 1.0.0, < 2.0)
28
28
  cocoapods-stats (>= 1.0.0, < 2.0)
29
- cocoapods-trunk (>= 1.2.0, < 2.0)
29
+ cocoapods-trunk (>= 1.3.0, < 2.0)
30
30
  cocoapods-try (>= 1.1.0, < 2.0)
31
31
  colored2 (~> 3.1)
32
32
  escape (~> 0.0.4)
33
33
  fourflusher (~> 2.0.1)
34
34
  gh_inspector (~> 1.0)
35
- molinillo (~> 0.5.7)
35
+ molinillo (~> 0.6.5)
36
36
  nap (~> 1.0)
37
37
  ruby-macho (~> 1.1)
38
- xcodeproj (>= 1.4.4, < 2.0)
39
- cocoapods-core (1.2.1)
40
- activesupport (>= 4.0.2, < 5)
38
+ xcodeproj (>= 1.5.7, < 2.0)
39
+ cocoapods-core (1.5.0)
40
+ activesupport (>= 4.0.2, < 6)
41
41
  fuzzy_match (~> 2.0.4)
42
42
  nap (~> 1.0)
43
43
  cocoapods-deintegrate (1.0.2)
@@ -66,7 +66,7 @@ GEM
66
66
  metaclass (~> 0.0.1)
67
67
  mocha-on-bacon (0.2.3)
68
68
  mocha (>= 0.13.0)
69
- molinillo (0.5.7)
69
+ molinillo (0.6.5)
70
70
  nanaimo (0.2.5)
71
71
  nap (1.1.0)
72
72
  netrc (0.11.0)
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- x# cocoapods-tdfire-binary
1
+ # cocoapods-tdfire-binary
2
2
 
3
3
  A description of cocoapods-tdfire-binary.
4
4
 
@@ -0,0 +1,92 @@
1
+ require 'yaml'
2
+ require 'fileutils'
3
+
4
+ module Pod
5
+ module Tdfire
6
+ class BinaryConfig
7
+ public
8
+
9
+ REPO_URL_KEY = 'repo_url'.freeze
10
+ SERVER_ROOT_KEY = 'server_host'.freeze
11
+ TEMPLATE_URL_KEY = 'template_url'.freeze
12
+
13
+ def self.instance
14
+ @instance ||= new
15
+ end
16
+
17
+ def repo_url
18
+ setting_for_key(REPO_URL_KEY)
19
+ end
20
+
21
+ def server_host
22
+ setting_for_key(SERVER_ROOT_KEY)
23
+ end
24
+
25
+ def template_url
26
+ setting_for_key(TEMPLATE_URL_KEY)
27
+ end
28
+
29
+ def setting_hash
30
+ @setting ||= begin
31
+ if File.exist?(binary_setting_file)
32
+ @setting = YAML.load_file(binary_setting_file)
33
+ end
34
+ end
35
+ @setting
36
+ end
37
+
38
+ def setting_file_name
39
+ 'binary_config.yml'
40
+ end
41
+
42
+ def binary_setting_file
43
+ config.home_dir + setting_file_name
44
+ end
45
+
46
+ def config_with_setting(setting)
47
+ File.open(binary_setting_file, 'w+') do |f|
48
+ f.write(setting.to_yaml)
49
+ end
50
+ end
51
+
52
+ def private_sources(keywords = repo_url)
53
+ config.sources_manager.all.select do |source|
54
+ source.url.downcase.include? keywords
55
+ end
56
+ end
57
+
58
+ private
59
+
60
+ def config
61
+ Config.instance
62
+ end
63
+
64
+ def setting_for_key(key)
65
+ validate_setting_file
66
+
67
+ setting = setting_hash[key]
68
+ if setting.nil?
69
+ raise Pod::Informative, "获取不到 #{key} 的配置信息,执行 pod binary init 或手动在 #{binary_setting_file} 设置."
70
+ end
71
+ setting
72
+ end
73
+
74
+ def validate_setting_file
75
+ return if binary_setting_file.exist?
76
+
77
+ # 公司内部就不用自己配置了
78
+ sources = private_sources('2dfire')
79
+ if sources.empty?
80
+ raise Pod::Informative, '获取不到配置信息,执行 pod binary init 初始化配置信息.'
81
+ end
82
+
83
+ FileUtils.cd(config.home_dir) do
84
+ `git clone http://git.2dfire-inc.com/qingmu/cocoapods-tdfire-binary-config`
85
+
86
+ FileUtils.mv("cocoapods-tdfire-binary-config/#{setting_file_name}", '.')
87
+ FileUtils.rm_rf(config.home_dir + 'cocoapods-tdfire-binary-config')
88
+ end
89
+ end
90
+ end
91
+ end
92
+ end
@@ -103,9 +103,23 @@ module Pod
103
103
  # 所以这里需要暴露 static framework 中的 bundle ,明确让 CocoaPods 拷贝 bundle 到 main bundle,
104
104
  # 可以查看 高德地图 和 友盟等 framework ,都已这种方式处理
105
105
  #
106
- target_spec.resources = ["#{target_spec.root.name}.framework/Resources/*.bundle", "#{target_spec.root.name}.framework/Versions/A/Resources/*.bundle"]
107
- # target_spec.source_files = ["#{target_spec.root.name}.framework/Headers/*", "#{target_spec.root.name}.framework/Versions/A/Headers/*"]
108
- # target_spec.public_header_files = ["#{target_spec.root.name}.framework/Headers/*", "#{target_spec.root.name}.framework/Versions/A/Headers/*"]
106
+ # 如果组件不是用的 resource_bundle,而是用的 resources ,那么这里就不会拷贝组件的资源文件
107
+ #
108
+
109
+ framework_resources = spec.tdfire_recursive_value('resources', :ios)
110
+ resource_bundles = spec.tdfire_recursive_value('resource_bundles', :ios)
111
+ # 不判断 lint 会报错 did not match any file
112
+ target_spec.resources = ["#{target_spec.root.name}.framework/Resources/*", "#{target_spec.root.name}.framework/Versions/A/Resources/*"] if resource_bundles.select(&:any?).any? || framework_resources.any?
113
+ Pod::UI.message "Tdfire: resources for binary: #{target_spec.tdfire_recursive_value('resources', :ios).join(', ')}"
114
+
115
+ # cococapods 会将以下头文件添加入 user search path ,这样使用者可以使用 " " 对头文件进行引用
116
+ #
117
+ #
118
+ # 不能通过下面这种方式判断
119
+ # Dir.glob("#{target_spec.root.name}.framework/Headers/*").count
120
+
121
+ target_spec.source_files = ["#{target_spec.root.name}.framework/Headers/*", "#{target_spec.root.name}.framework/Versions/A/Headers/*"]
122
+ target_spec.public_header_files = ["#{target_spec.root.name}.framework/Headers/*", "#{target_spec.root.name}.framework/Versions/A/Headers/*"]
109
123
 
110
124
  available_platforms(spec).each do |platform|
111
125
  Pod::UI.section("Tdfire: copying configuration for platform #{platform}") do
@@ -139,28 +153,27 @@ module Pod
139
153
  # spec 是源码依赖时的配置
140
154
  def set_preserve_paths(spec)
141
155
  available_platforms(spec).each do |platform|
142
- Pod::UI.section("Tdfire: set preserve paths for platform #{platform}") do
143
- # 源码、资源文件
144
- #
145
- source_files = spec.tdfire_recursive_value('source_files', platform)
146
- resources = spec.tdfire_recursive_value('resources', platform)
147
- resource_bundles = spec.tdfire_recursive_value('resource_bundles', platform)
156
+ Pod::UI.message("Tdfire: set preserve paths for platform #{platform}")
157
+ # 源码、资源文件
158
+ #
159
+ source_files = spec.tdfire_recursive_value('source_files', platform)
160
+ resources = spec.tdfire_recursive_value('resources', platform)
161
+ resource_bundles = spec.tdfire_recursive_value('resource_bundles', platform)
148
162
 
149
- source_preserve_paths = source_files + resources + resource_bundles.map(&:values).flatten
163
+ source_preserve_paths = source_files + resources + resource_bundles.map(&:values).flatten
150
164
 
151
- # 二进制文件
152
- framework_preserve_paths = [framework_name]
153
- preserve_paths = source_preserve_paths + framework_preserve_paths
165
+ # 二进制文件
166
+ framework_preserve_paths = [framework_name]
167
+ preserve_paths = source_preserve_paths + framework_preserve_paths
154
168
 
155
- # 保留原有的 preserve_paths
156
- target_preserve_paths = target_spec.tdfire_recursive_value('preserve_paths', platform)
157
- preserve_paths += target_preserve_paths unless target_preserve_paths.empty?
169
+ # 保留原有的 preserve_paths
170
+ target_preserve_paths = target_spec.tdfire_recursive_value('preserve_paths', platform)
171
+ preserve_paths += target_preserve_paths unless target_preserve_paths.empty?
158
172
 
159
- target_platform = target_spec.send(platform.to_sym)
160
- target_platform.preserve_paths = preserve_paths.uniq
173
+ target_platform = target_spec.send(platform.to_sym)
174
+ target_platform.preserve_paths = preserve_paths.uniq
161
175
 
162
- Pod::UI.message "Tdfire: preserve paths for #{platform}: #{preserve_paths.join(', ')}"
163
- end
176
+ Pod::UI.message "Tdfire: preserve paths for #{platform}: #{preserve_paths.join(', ')}"
164
177
  end
165
178
  end
166
179
 
@@ -1,10 +1,10 @@
1
+ require 'cocoapods-tdfire-binary/binary_config'
2
+
1
3
  module Pod
2
4
  module Tdfire
3
5
  class BinaryUrlManager
4
- HOST = "http://iosframeworkserver-shopkeeperclient.cloudapps.2dfire.com"
5
-
6
- def self.pull_url_for_pod_version(pod, version)
7
- HOST + "/getframework/PRODUCTION/#{pod}/#{version}"
6
+ def self.pull_url_for_pod_version(pod, version)
7
+ host + "/download/#{pod}/#{version}"
8
8
  end
9
9
 
10
10
  def self.get_pull_url_for_pod_version(pod, version)
@@ -14,29 +14,51 @@ module Pod
14
14
  end
15
15
 
16
16
  def self.push_url
17
- HOST + "/upload" #+ param
17
+ host + "/upload" #+ param
18
18
  end
19
19
 
20
20
  def self.post_push_url(name, version, path, commit = nil, commit_hash = nil)
21
- 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
+ param = %Q[-F "frameworkName=#{name}" -F "version=#{version}" -F "changelog=#{commit}" -F "featureName=#{commit}" -F "framework=@#{path}" -F "commitHash=#{commit_hash}"]
22
22
  command = "curl #{push_url} #{param}"
23
23
 
24
24
  run_curl command
25
25
  end
26
26
 
27
+ def self.delete_binary(name, version)
28
+ command = "curl -X 'DELETE' #{host}/framework/#{name}/#{version} -O -J"
29
+ run_curl command
30
+ end
31
+
32
+ def self.list_binary()
33
+ command = "curl #{host}/frameworks\?allinfo=true"
34
+ run_curl command
35
+ end
36
+
37
+ def self.search_binary(name)
38
+ command = "curl #{host}/framework/#{name}"
39
+ run_curl command
40
+ end
41
+
27
42
  def self.run_curl(command)
28
43
  Pod::UI.message "CURL: \n" + command + "\n"
29
44
 
30
- system command
45
+ result = `#{command} -s -m 5`
46
+
47
+ raise Pod::Informative, "执行 #{command} 失败,查看网络或者 binary_config.yml 配置." if $?.exitstatus != 0
48
+
49
+ result
31
50
  end
32
51
 
52
+ def self.host
53
+ BinaryConfig.instance.server_host
54
+ end
55
+
33
56
  def self.private_cocoapods_url
34
- "git@git.2dfire-inc.com:ios/cocoapods-spec.git"
35
- # "git@git.2dfire-inc.com:qingmu/private_cocoapods.git"
57
+ BinaryConfig.instance.repo_url
36
58
  end
37
59
 
38
60
  def self.template_lib_url
39
- "git@git.2dfire-inc.com:ios/binary-pod-template.git"
61
+ BinaryConfig.instance.template_url
40
62
  end
41
63
  end
42
64
  end
@@ -5,6 +5,11 @@ require 'cocoapods-tdfire-binary/command/pull'
5
5
  require 'cocoapods-tdfire-binary/command/push'
6
6
  require 'cocoapods-tdfire-binary/command/assemble'
7
7
  require 'cocoapods-tdfire-binary/command/lib'
8
+ require 'cocoapods-tdfire-binary/command/delete'
9
+ require 'cocoapods-tdfire-binary/command/search'
10
+ require 'cocoapods-tdfire-binary/command/list'
11
+ require 'cocoapods-tdfire-binary/command/init'
12
+ require 'cocoapods-tdfire-binary/binary_config'
8
13
 
9
14
  module Pod
10
15
  class Command
@@ -15,17 +20,16 @@ module Pod
15
20
  2Dfire 二进制工具库,提供打包、lint、推送、拉取、发布等命令
16
21
  DESC
17
22
 
18
- FIRE_FLAG = "2dfire"
19
- # FIRE_FLAG = "private"
23
+ def binary_config
24
+ Tdfire::BinaryConfig.instance
25
+ end
20
26
 
21
27
  def first_podspec
22
28
  Dir["#{Dir.pwd}/*.podspec"].first
23
29
  end
24
30
 
25
- def fire_sources
26
- config.sources_manager.all.select do |source|
27
- source.url.downcase.include? FIRE_FLAG
28
- end
31
+ def private_sources
32
+ binary_config.private_sources
29
33
  end
30
34
  end
31
35
  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 Delete < Binary
7
+
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
+ CLAide::Argument.new('VERSION', true)
17
+ ]
18
+
19
+ def initialize(argv)
20
+ @name = argv.shift_argument
21
+ @version = argv.shift_argument
22
+ super
23
+ end
24
+
25
+ def validate!
26
+ super
27
+ help! "必须为删除组件指定名称" if @name.nil?
28
+ help! "必须为删除组件指定版本" if @version.nil?
29
+ end
30
+
31
+ def run
32
+ UI.section("Tdfire: deleting binary file #{@name} #{@version} ...") do
33
+ Pod::Tdfire::BinaryUrlManager.delete_binary(@name, @version)
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,36 @@
1
+ require 'cocoapods-tdfire-binary/binary_url_manager'
2
+ require 'cocoapods-tdfire-binary/init_asker'
3
+
4
+ module Pod
5
+ class Command
6
+ class Binary < Command
7
+ class Init < Binary
8
+
9
+ self.abstract_command = false
10
+ self.summary = '初始化二进制插件'
11
+ self.description = <<-DESC
12
+ 初始化二进制插件
13
+ DESC
14
+
15
+ def initialize(argv)
16
+ @asker = Tdfire::InitAsker.new
17
+ super
18
+ end
19
+
20
+ def run
21
+ @asker.wellcome_message
22
+
23
+ hash = binary_config.setting_hash
24
+
25
+ Tdfire::InitAsker::QUESTIONS.each do |k, v|
26
+ hash[k] = @asker.ask_with_answer(v, hash[k])
27
+ end
28
+
29
+ binary_config.config_with_setting(hash)
30
+
31
+ @asker.done_message
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -9,8 +9,8 @@ module Pod
9
9
  self.summary = '二进制模版库操作'
10
10
  self.description = <<-DESC
11
11
  二进制模版库操作
12
- DESC
13
- end
12
+ DESC
13
+ end
14
14
  end
15
15
  end
16
16
  end
@@ -15,13 +15,16 @@ module Pod
15
15
  ['--sources', '私有源地址'],
16
16
  ['--clean', '执行成功后,删除 zip 文件外的所有生成文件'],
17
17
  ['--one-binary', '只让 Lint 的 Pod 进行二进制依赖,其余都用源码'],
18
+ ['--subspec', 'lint 特定 subspec']
18
19
  ].concat(super)
19
20
  end
20
21
 
21
22
  def initialize(argv)
22
23
  @clean = argv.flag?('clean')
23
24
  @sources = argv.option('sources')
25
+ @subspec = argv.option('subspec')
24
26
  @one_binary = argv.flag?('one-binary')
27
+
25
28
  @spec_file = first_podspec
26
29
  @spec_name = @spec_file.split('/').last.split('.').first unless @spec_file.nil?
27
30
  unzip_framework
@@ -57,6 +60,8 @@ module Pod
57
60
  '--verbose'
58
61
  ]
59
62
 
63
+ argvs << "--subspec=#{@subspec}" unless @subspec.nil?
64
+
60
65
  lint= Pod::Command::Lib::Lint.new(CLAide::ARGV.new(argvs))
61
66
  lint.validate!
62
67
  lint.run
@@ -0,0 +1,38 @@
1
+
2
+ require 'json'
3
+ require 'cocoapods-tdfire-binary/binary_url_manager'
4
+
5
+ module Pod
6
+ class Command
7
+ class Binary < Command
8
+ class List < Binary
9
+
10
+ self.abstract_command = false
11
+ self.summary = '查看所有二进制版本信息'
12
+ self.description = <<-DESC
13
+ 查看所有二进制版本信息
14
+ DESC
15
+
16
+ def initialize(argv)
17
+ super
18
+ end
19
+
20
+ def validate!
21
+ super
22
+ end
23
+
24
+ def run
25
+ result = Pod::Tdfire::BinaryUrlManager.list_binary
26
+ pods = JSON.parse(result) unless result.nil?
27
+ pods ||= []
28
+
29
+ pods.sort.each do |pod, versions|
30
+ UI.puts " #{pod + " " + versions.last}\n"
31
+ end
32
+
33
+ UI.puts "\n#{pods.keys.count} pods were found"
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -19,7 +19,8 @@ module Pod
19
19
  ['--clean', '执行成功后,删除 zip 文件外的所有生成文件'],
20
20
  ['--spec-sources', '私有源地址'],
21
21
  # ['--local', '使用本地代码'],
22
- ['--use-carthage', 'carthage使用carthage进行打包'],
22
+ ['--use-carthage', 'carthage使用carthage进行打包,三方库提供carthage的优先'],
23
+ ['--subspecs', '打包子组件']
23
24
  ].concat(super)
24
25
  end
25
26
 
@@ -28,6 +29,7 @@ module Pod
28
29
  @local = argv.flag?('local')
29
30
  @use_carthage = argv.flag?('use-carthage')
30
31
  @spec_sources = argv.option('spec-sources')
32
+ @subspecs= argv.option('subspecs')
31
33
  @spec_file = first_podspec
32
34
  super
33
35
  end
@@ -38,18 +40,57 @@ module Pod
38
40
  end
39
41
 
40
42
  def run
41
- # 组件有多个 platform 时,限制 cocoapods-packager 只打 ios 代码
42
- Pod::Tdfire::BinaryStateStore.limit_platform = true
43
-
44
- spec = Specification.from_file(@spec_file)
45
- prepare(spec)
46
- package(spec)
47
- zip(spec)
48
-
49
- Pod::Tdfire::BinaryStateStore.limit_platform = false
43
+ if @use_carthage
44
+ build_by_carthage
45
+ else
46
+ build_by_pod_packager
47
+ end
50
48
  end
51
49
 
52
50
  private
51
+ def build_by_pod_packager
52
+ # 组件有多个 platform 时,限制 cocoapods-packager 只打 ios 代码
53
+ Pod::Tdfire::BinaryStateStore.limit_platform = true
54
+
55
+ spec = Specification.from_file(@spec_file)
56
+ prepare(spec)
57
+ package(spec)
58
+ zip_packager_framework(spec)
59
+
60
+ Pod::Tdfire::BinaryStateStore.limit_platform = false
61
+ end
62
+
63
+ def build_by_carthage
64
+ build_script = <<-EOF
65
+ if [[ -d swift-staticlibs ]]; then
66
+ rm -fr swift-staticlibs
67
+ fi
68
+
69
+ if [[ ! $(command -v carthage) ]]; then
70
+ brew install carthage
71
+ fi
72
+
73
+ git clone git@git.2dfire-inc.com:cocoapods-repos/swift-staticlibs.git
74
+
75
+ xcconfig=$(mktemp /tmp/static.xcconfig.XXXXXX)
76
+ trap 'rm -f "$xcconfig"' INT TERM HUP EXIT
77
+
78
+ echo "LD = $PWD/swift-staticlibs/ld.py" >> $xcconfig
79
+ echo "DEBUG_INFORMATION_FORMAT = dwarf" >> $xcconfig
80
+
81
+ export XCODE_XCCONFIG_FILE="$xcconfig"
82
+
83
+ carthage build "$@" --no-skip-current --platform iOS
84
+
85
+ rm -fr swift-staticlibs
86
+ EOF
87
+
88
+ system build_script
89
+
90
+ spec = Specification.from_file(@spec_file)
91
+ zip_carthage_framework(spec)
92
+ end
93
+
53
94
 
54
95
  def prepare(spec)
55
96
  UI.section("Tdfire: prepare for packaging ...") do
@@ -68,6 +109,7 @@ module Pod
68
109
  ]
69
110
 
70
111
  argvs << "--local" if @local
112
+ argvs << "--subspecs=#{@subspecs}" unless @subspecs.nil?
71
113
 
72
114
  package = Pod::Command::Package.new(CLAide::ARGV.new(argvs))
73
115
  package.validate!
@@ -75,7 +117,7 @@ module Pod
75
117
  end
76
118
  end
77
119
 
78
- def zip(spec)
120
+ def zip_packager_framework(spec)
79
121
  framework_directory = "#{spec.name}-#{spec.version}/ios"
80
122
  framework_name = "#{spec.name}.framework"
81
123
  framework_path = "#{framework_directory}/#{framework_name}"
@@ -86,8 +128,11 @@ module Pod
86
128
  # 这里把多余的 bundle 删除
87
129
  # https://github.com/CocoaPods/cocoapods-packager/pull/199
88
130
  resource_bundles = spec.tdfire_recursive_value('resource_bundles').map(&:keys).flatten.uniq
131
+ resources= spec.tdfire_recursive_value('resources').map { |r| r.split('/').last }
89
132
  FileUtils.chdir("#{framework_path}/Versions/A/Resources") do
90
- dependency_bundles = Dir.glob('*.bundle').select { |b| !resource_bundles.include?(b.split('.').first) }
133
+ dependency_bundles = Dir.glob('*.bundle').select do |b|
134
+ !resource_bundles.include?(b.split('.').first) && !resources.include?(b)
135
+ end
91
136
  unless dependency_bundles.empty?
92
137
  Pod::UI::puts "Tdfire: remove dependency bundles: #{dependency_bundles.join(', ')}"
93
138
 
@@ -97,18 +142,33 @@ module Pod
97
142
  end
98
143
  end if File.exist? "#{framework_path}/Versions/A/Resources"
99
144
 
100
- output_name = "#{framework_name}.zip"
101
- UI.section("Tdfire: zip #{framework_path} ...") do
145
+ zip_framework(spec, framework_directory)
146
+
147
+ clean(spec) if @clean
148
+ end
149
+
150
+ def zip_carthage_framework(spec)
151
+ framework_directory = "Carthage/Build/iOS"
152
+ framework_name = "#{spec.name}.framework"
153
+ framework_path = "#{framework_directory}/#{framework_name}"
154
+
155
+ raise Informative, "没有需要压缩的 framework 文件:#{framework_path}" unless File.exist?(framework_path)
156
+
157
+ zip_framework(spec, framework_directory)
158
+ end
159
+
160
+ def zip_framework(spec, framework_directory)
161
+ framework_name = "#{spec.name}.framework"
162
+ output_name = "#{framework_name}.zip"
163
+ UI.section("Tdfire: zip #{framework_directory}/#{framework_name} ...") do
102
164
  FileUtils.chdir(framework_directory) do
103
165
  system "zip --symlinks -r #{output_name} #{framework_name}"
104
- system "mv #{output_name} ../../"
166
+ system "mv #{output_name} #{framework_directory.split('/').count.times.reduce("") { |r, n| r + "../" }}"
105
167
  end
106
168
  end
107
169
 
108
170
  Pod::UI::puts "Tdfire: save framework zip file to #{Dir.pwd}/#{output_name}".green
109
-
110
- clean(spec) if @clean
111
- end
171
+ end
112
172
 
113
173
  def clean(spec)
114
174
  file = "#{spec.name}-#{spec.version}"
@@ -37,7 +37,7 @@ module Pod
37
37
 
38
38
  UI.section("Tdfire: start publishing #{spec.name} ...") do
39
39
  argvs = [
40
- fire_sources.first.name,
40
+ private_sources.first.name,
41
41
  @spec_file,
42
42
  '--allow-warnings',
43
43
  '--use-libraries',
@@ -53,7 +53,7 @@ module Pod
53
53
 
54
54
  private
55
55
  def commit_prefix(spec)
56
- output_path = fire_sources.first.pod_path(spec.name) + spec.version.to_s
56
+ output_path = private_sources.first.pod_path(spec.name) + spec.version.to_s
57
57
  if output_path.exist?
58
58
  message = "[Fix] #{spec}"
59
59
  elsif output_path.dirname.directory?
@@ -0,0 +1,47 @@
1
+
2
+ require 'json'
3
+ require 'cocoapods-tdfire-binary/binary_url_manager'
4
+
5
+ module Pod
6
+ class Command
7
+ class Binary < Command
8
+ class Search < Binary
9
+
10
+ self.abstract_command = false
11
+ self.summary = '查找二进制版本信息'
12
+ self.description = <<-DESC
13
+ 查找二进制版本信息
14
+ DESC
15
+
16
+ self.arguments = [
17
+ CLAide::Argument.new('NAME', true)
18
+ ]
19
+
20
+ def initialize(argv)
21
+ @name = argv.shift_argument
22
+ super
23
+ end
24
+
25
+ def validate!
26
+ super
27
+ help! "必须指定有效组件名" if @name.nil?
28
+ end
29
+
30
+ def run
31
+ result = Pod::Tdfire::BinaryUrlManager.search_binary(@name)
32
+ pod = JSON.parse(result) unless result.nil?
33
+ pod ||= {'' => []}
34
+
35
+ name = pod['name'] || @name
36
+ versions = pod['versions'] || []
37
+
38
+ title = "-> #{name} (#{versions.last})".green
39
+
40
+ Pod::UI::title(title, '', 1) do
41
+ Pod::UI::labeled('Versions', versions.join(', '))
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -1,3 +1,3 @@
1
1
  module CocoapodsTdfireBinary
2
- VERSION = "1.0.10"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -0,0 +1,55 @@
1
+ require 'cocoapods-tdfire-binary/binary_config'
2
+
3
+ module Pod
4
+ module Tdfire
5
+ class InitAsker
6
+ QUESTIONS = {
7
+ BinaryConfig::SERVER_ROOT_KEY => '输入二进制服务器地址 (比如 http://xxxxx:8080)',
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)'
10
+ }
11
+
12
+ def show_prompt
13
+ print ' > '.green
14
+ end
15
+
16
+ def ask_with_answer(question, pre_answer)
17
+ print "\n#{question}\n"
18
+
19
+ print "旧值:#{pre_answer}\n" unless pre_answer.nil?
20
+
21
+ answer = ''
22
+ loop do
23
+ show_prompt
24
+ answer = STDIN.gets.chomp
25
+
26
+ if answer == '' && !pre_answer.nil?
27
+ answer = pre_answer
28
+ print answer.yellow
29
+ print "\n"
30
+ end
31
+
32
+ break unless answer.empty?
33
+ end
34
+
35
+ answer
36
+ end
37
+
38
+ def wellcome_message
39
+ print <<-EOF
40
+
41
+ 开始设置二进制化初始信息.
42
+ 所有的信息都会保存在 binary_config.yaml 文件中.
43
+ 你可以在 #{BinaryConfig.instance.binary_setting_file} 目录下手动添加编辑该文件.
44
+ #{BinaryConfig.instance.binary_setting_file} 文件包含配置信息如下:
45
+
46
+ #{QUESTIONS.to_yaml}
47
+ EOF
48
+ end
49
+
50
+ def done_message
51
+ print "\n设置完成.\n"
52
+ end
53
+ end
54
+ end
55
+ end
@@ -40,8 +40,6 @@ module Pod
40
40
  Pod::Tdfire::BinaryStateStore.printed_pods << root.name
41
41
  end
42
42
 
43
- yield self if block_given?
44
-
45
43
  # name 一定要有,否则 subspec dependecy 会出现 split nil 错误
46
44
  @tdfire_reference_spec = Specification.new(nil, 'TdfireSpecification')
47
45
  configurator.call @tdfire_reference_spec
@@ -53,6 +51,8 @@ module Pod
53
51
  else
54
52
  tdfire_refactor.configure_binary(@tdfire_reference_spec)
55
53
  end
54
+
55
+ yield self if block_given?
56
56
  end
57
57
  end
58
58
 
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.0.10
4
+ version: 1.1.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-04-18 00:00:00.000000000 Z
11
+ date: 2018-05-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -73,7 +73,10 @@ executables: []
73
73
  extensions: []
74
74
  extra_rdoc_files: []
75
75
  files:
76
+ - ".bundle/config"
76
77
  - ".gitignore"
78
+ - ".travis.yml"
79
+ - ".vscode/launch.json"
77
80
  - Gemfile
78
81
  - Gemfile.lock
79
82
  - LICENSE.txt
@@ -81,20 +84,26 @@ files:
81
84
  - Rakefile
82
85
  - cocoapods-tdfire-binary.gemspec
83
86
  - lib/cocoapods-tdfire-binary.rb
87
+ - lib/cocoapods-tdfire-binary/binary_config.rb
84
88
  - lib/cocoapods-tdfire-binary/binary_specification_refactor.rb
85
89
  - lib/cocoapods-tdfire-binary/binary_state_store.rb
86
90
  - lib/cocoapods-tdfire-binary/binary_url_manager.rb
87
91
  - lib/cocoapods-tdfire-binary/command.rb
88
92
  - lib/cocoapods-tdfire-binary/command/assemble.rb
89
93
  - lib/cocoapods-tdfire-binary/command/binary.rb
94
+ - lib/cocoapods-tdfire-binary/command/delete.rb
95
+ - lib/cocoapods-tdfire-binary/command/init.rb
90
96
  - lib/cocoapods-tdfire-binary/command/lib.rb
91
97
  - lib/cocoapods-tdfire-binary/command/lib/create.rb
92
98
  - lib/cocoapods-tdfire-binary/command/lint.rb
99
+ - lib/cocoapods-tdfire-binary/command/list.rb
93
100
  - lib/cocoapods-tdfire-binary/command/package.rb
94
101
  - lib/cocoapods-tdfire-binary/command/publish.rb
95
102
  - lib/cocoapods-tdfire-binary/command/pull.rb
96
103
  - lib/cocoapods-tdfire-binary/command/push.rb
104
+ - lib/cocoapods-tdfire-binary/command/search.rb
97
105
  - lib/cocoapods-tdfire-binary/gem_version.rb
106
+ - lib/cocoapods-tdfire-binary/init_asker.rb
98
107
  - lib/cocoapods-tdfire-binary/podfile_dsl.rb
99
108
  - lib/cocoapods-tdfire-binary/podfile_hook.rb
100
109
  - lib/cocoapods-tdfire-binary/source_chain_analyzer.rb