cocoapods-tdfire-binary 0.1.4 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -1
- data/cocoapods-tdfire-binary.gemspec +1 -1
- data/lib/cocoapods-tdfire-binary/binary_state_store.rb +19 -15
- data/lib/cocoapods-tdfire-binary/gem_version.rb +1 -1
- data/lib/cocoapods-tdfire-binary/podfile_dsl.rb +5 -16
- data/lib/cocoapods-tdfire-binary/podfile_hook.rb +20 -16
- data/lib/cocoapods-tdfire-binary/source_chain_analyzer.rb +66 -0
- data/lib/cocoapods-tdfire-binary/specification_dsl.rb +4 -4
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 557565f493e63f0aae84418d13f594d10765a227
|
4
|
+
data.tar.gz: 57905b4d491285860bdfd6969273e3be26c6abaa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 75e7b0d512ce521dcbac84ca4dece0c17942b244f060b588657d587d0b8c4caae6f460294753a8eaf5e3fbab3d126b2c60a1b02690bf37aef6f3a521f4fa54b7
|
7
|
+
data.tar.gz: 3368ae748ea31de56c94c77fada4d23ad04a86dc5a1077651a61caa4e4f55eafba9baf7f995e0d99347ba95b64e2226462544aabf67e47fdb238acc5d81539cf
|
data/Gemfile.lock
CHANGED
@@ -3,16 +3,24 @@ module Tdfire
|
|
3
3
|
public
|
4
4
|
|
5
5
|
class << self
|
6
|
-
attr_accessor :unpublished_pods
|
7
|
-
|
6
|
+
# attr_accessor :unpublished_pods
|
7
|
+
attr_accessor :use_source_pods
|
8
8
|
attr_reader :printed_pods
|
9
9
|
end
|
10
|
-
@unpublished_pods = []
|
10
|
+
# @unpublished_pods = []
|
11
11
|
@use_source_pods = []
|
12
12
|
@printed_pods = []
|
13
13
|
|
14
|
-
def self.
|
15
|
-
(@use_source_pods +
|
14
|
+
def self.real_use_source_pods
|
15
|
+
(@use_source_pods + unpublished_pods).uniq
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.unpublished_pods
|
19
|
+
String(ENV[UNPBLISHED_PODS]).split('|')
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.unpublished_pods=(pods)
|
23
|
+
ENV[UNPBLISHED_PODS] = Array(pods).join('|')
|
16
24
|
end
|
17
25
|
|
18
26
|
def self.use_binary?
|
@@ -27,21 +35,17 @@ module Tdfire
|
|
27
35
|
ENV[FORCE_USE_BINARY_KEY] == USE_SURE_VALUE
|
28
36
|
end
|
29
37
|
|
30
|
-
def self.
|
31
|
-
ENV[
|
38
|
+
def self.set_force_use_binary
|
39
|
+
ENV[FORCE_USE_BINARY_KEY] = USE_SURE_VALUE
|
32
40
|
end
|
33
41
|
|
34
|
-
def self.
|
35
|
-
ENV[
|
36
|
-
end
|
37
|
-
|
38
|
-
def self.set_auto_set_default_unpublished_pod
|
39
|
-
ENV[AUTO_SET_DEFAULT_UNPUBLISHED_POD_KEY] = USE_SURE_VALUE
|
42
|
+
def self.force_use_source?
|
43
|
+
ENV[FORCE_USE_SOURCE_KEY] == USE_SURE_VALUE
|
40
44
|
end
|
41
45
|
|
42
46
|
private
|
43
|
-
|
44
|
-
|
47
|
+
|
48
|
+
UNPBLISHED_PODS = "tdfire_unpublished_pods"
|
45
49
|
FORCE_USE_SOURCE_KEY = 'tdfire_force_use_source'
|
46
50
|
FORCE_USE_BINARY_KEY = 'tdfire_force_use_binary'
|
47
51
|
USE_BINARY_KEY = 'tdfire_use_binary'
|
@@ -10,21 +10,15 @@ module Pod
|
|
10
10
|
Tdfire::BinaryStateStore.use_source_pods = Array(pods)
|
11
11
|
end
|
12
12
|
|
13
|
-
# 标明未发布的pod,因为未发布pod没有对应的二进制版本,无法下载
|
14
|
-
# 未发布的pod,一定是源码依赖的
|
15
|
-
def tdfire_unpublished_pods(pods)
|
16
|
-
Pod::UI.puts "Tdfire: set unpublished pods: #{Array(pods).join(', ')}"
|
17
|
-
Tdfire::BinaryStateStore.unpublished_pods = Array(pods)
|
18
|
-
end
|
19
|
-
|
20
13
|
# 使用二进制依赖
|
21
14
|
def tdfire_use_binary!
|
22
15
|
Tdfire::BinaryStateStore.set_use_binary
|
23
|
-
end
|
16
|
+
end
|
24
17
|
|
25
|
-
|
26
|
-
|
27
|
-
|
18
|
+
# 强制使用二进制依赖,忽略未发布和依赖源码设置
|
19
|
+
# def tdfire_force_use_binary!
|
20
|
+
# Tdfire::BinaryStateStore.set_force_use_binary
|
21
|
+
# end
|
28
22
|
|
29
23
|
# 外源组件依赖
|
30
24
|
def tdfire_external_pods(pods, *rest)
|
@@ -74,11 +68,6 @@ EOF
|
|
74
68
|
end
|
75
69
|
else
|
76
70
|
end
|
77
|
-
|
78
|
-
# 除了依赖私有源正式版本的组件,其余组件一律视为未发布组件,进行源码依赖
|
79
|
-
Tdfire::BinaryStateStore.unpublished_pods += Array(pods)
|
80
|
-
|
81
|
-
# Tdfire::BinaryStateStore.use_source_pods = Array(pods) + Tdfire::BinaryStateStore.use_source_pods
|
82
71
|
end
|
83
72
|
end
|
84
73
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
require 'cocoapods-tdfire-binary/binary_state_store'
|
2
|
+
require 'cocoapods-tdfire-binary/source_chain_analyzer'
|
2
3
|
|
3
4
|
module CocoapodsTdfireBinary
|
4
5
|
|
5
|
-
tdfire_default_development_pod = nil
|
6
6
|
Pod::HooksManager.register('cocoapods-tdfire-binary', :pre_install) do |context, _|
|
7
7
|
first_target_definition = context.podfile.target_definition_list.select{ |d| d.name != 'Pods' }.first
|
8
8
|
development_pod = first_target_definition.name.split('_').first unless first_target_definition.nil?
|
@@ -12,13 +12,24 @@ module CocoapodsTdfireBinary
|
|
12
12
|
context.podfile.install!('cocoapods', :share_schemes_for_development_pods => [development_pod])
|
13
13
|
end unless development_pod.nil?
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
15
|
+
|
16
|
+
# 标明未发布的pod,因为未发布pod没有对应的二进制版本,无法下载
|
17
|
+
# 未发布的pod,一定是源码依赖的
|
18
|
+
Pod::UI.section("Tdfire: auto set unpublished pods") do
|
19
|
+
Tdfire::BinaryStateStore.unpublished_pods = context.podfile.dependencies.select(&:external?).map(&:root_name)
|
20
|
+
|
21
|
+
Pod::UI.message "> Tdfire: unpublished pods: #{Tdfire::BinaryStateStore.unpublished_pods.join(', ')}"
|
22
|
+
end
|
23
|
+
|
24
|
+
# 没有标识use_frameworks!,进行源码依赖需要设置Pod依赖链上,依赖此源码Pod的也进行源码依赖
|
25
|
+
unless first_target_definition.uses_frameworks?
|
26
|
+
Pod::UI.section("Tdfire: analyze chain pods depend on use source pods: #{Tdfire::BinaryStateStore.use_source_pods.join(', ')}") do
|
27
|
+
chain_pods = Tdfire::SourceChainAnalyzer.new(context.podfile).analyze(Tdfire::BinaryStateStore.use_source_pods)
|
28
|
+
|
29
|
+
Pod::UI.message "> Tdfire: find chain pods: #{chain_pods.join(', ')}"
|
30
|
+
|
31
|
+
Tdfire::BinaryStateStore.use_source_pods += chain_pods
|
32
|
+
end unless Tdfire::BinaryStateStore.use_source_pods.empty?
|
22
33
|
end
|
23
34
|
end
|
24
35
|
|
@@ -44,14 +55,7 @@ module CocoapodsTdfireBinary
|
|
44
55
|
end
|
45
56
|
end
|
46
57
|
|
47
|
-
|
48
|
-
if Tdfire::BinaryStateStore.use_binary?
|
49
|
-
all_development_pods = context.sandbox.development_pods.keys - Array(tdfire_default_development_pod) - Tdfire::BinaryStateStore.use_source_pods
|
50
|
-
all_development_pods_displayed_text = all_development_pods.map { |p| "'#{p}'" }.join(',')
|
51
|
-
Pod::UI.puts "Tdfire: You should add following code to your `Podfile`, and then run `pod install or pod update` again. \n\ntdfire_unpublished_pods [#{all_development_pods_displayed_text}]\n".cyan unless all_development_pods.empty?
|
52
|
-
end
|
53
|
-
|
54
|
-
Pod::UI.puts "Tdfire: all source dependency pods: #{Tdfire::BinaryStateStore.use_source_pods.join(', ')}"
|
58
|
+
Pod::UI.puts "Tdfire: all source dependency pods: #{Tdfire::BinaryStateStore.real_use_source_pods.join(', ')}"
|
55
59
|
Pod::UI.puts "Tdfire: all unpublished pods: #{Tdfire::BinaryStateStore.unpublished_pods.join(', ')}"
|
56
60
|
end
|
57
61
|
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
module Tdfire
|
2
|
+
class SourceChainAnalyzer
|
3
|
+
|
4
|
+
def initialize(podfile)
|
5
|
+
@lockfile = generate_lockfile(podfile)
|
6
|
+
@pods_data = @lockfile.internal_data['PODS']
|
7
|
+
@parent_pods = []
|
8
|
+
end
|
9
|
+
|
10
|
+
public
|
11
|
+
|
12
|
+
def analyze(pods)
|
13
|
+
pods.each do |pod|
|
14
|
+
find_parent_pods(pod, @pods_data) unless @parent_pods.include?(pod)
|
15
|
+
end unless @lockfile.nil?
|
16
|
+
|
17
|
+
@parent_pods.uniq
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def find_parent_pods(pod, pods_data)
|
23
|
+
return if pod.nil?
|
24
|
+
|
25
|
+
parent_pod_hashes = pods_data.select{ |pod_data| pod_data.is_a?(Hash) && pod_data.values.flatten.include?(pod) }
|
26
|
+
parent_pod_hashes.each do |hold_pod_hash|
|
27
|
+
hold_pod_name = hold_pod_hash.keys.first.split('(').first.strip
|
28
|
+
@parent_pods << hold_pod_name
|
29
|
+
find_parent_pods(hold_pod_name, pods_data - parent_pod_hashes)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
def generate_lockfile(podfile)
|
35
|
+
fetch_external_source = false
|
36
|
+
|
37
|
+
lockfile = Pod::Lockfile.from_file(Pathname.new('Podfile.lock'))
|
38
|
+
|
39
|
+
# 如果手动去删除 Pods/Local Podspecs 里面的文件,那就会直接报错了
|
40
|
+
if lockfile.nil? || !Pathname.new('Pods').exist?
|
41
|
+
fetch_external_source = true
|
42
|
+
else
|
43
|
+
external = podfile.dependencies.select(&:external?)
|
44
|
+
external_source = {}
|
45
|
+
external.each { |d| external_source[d.root_name] = d.external_source }
|
46
|
+
lockfile_external_source = lockfile.internal_data['EXTERNAL SOURCES']
|
47
|
+
fetch_external_source = external_source != lockfile_external_source
|
48
|
+
end
|
49
|
+
|
50
|
+
sandbox = Pod::Config.instance.sandbox
|
51
|
+
analyzer = Pod::Installer::Analyzer.new(sandbox, podfile, lockfile)
|
52
|
+
specs = Pod::Config.instance.with_changes(skip_repo_update: true) do
|
53
|
+
# allow fetch ,初次install时,或者新增external source 时,由于Pods/Local Podspecs 是空,会抛出找不到specification异常
|
54
|
+
begin
|
55
|
+
analyzer.analyze(fetch_external_source).specs_by_target.values.flatten(1)
|
56
|
+
rescue
|
57
|
+
Pod::UI.message "> Tdfire: allow to fetch external source and try again".yellow
|
58
|
+
analyzer.analyze(true).specs_by_target.values.flatten(1)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
Pod::Lockfile.generate(podfile, specs, {}) || lockfile
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'cocoapods-tdfire-binary/binary_state_store'
|
2
|
-
require '
|
2
|
+
require 'colored2'
|
3
3
|
|
4
4
|
module Pod
|
5
5
|
class Specification
|
@@ -9,7 +9,7 @@ module Pod
|
|
9
9
|
|
10
10
|
def use_source?
|
11
11
|
(!Tdfire::BinaryStateStore.force_use_binary? &&
|
12
|
-
(!Tdfire::BinaryStateStore.use_binary? || Tdfire::BinaryStateStore.
|
12
|
+
(!Tdfire::BinaryStateStore.use_binary? || Tdfire::BinaryStateStore.real_use_source_pods.include?(name))) ||
|
13
13
|
Tdfire::BinaryStateStore.force_use_source?
|
14
14
|
end
|
15
15
|
|
@@ -19,7 +19,7 @@ module Pod
|
|
19
19
|
def tdfire_source(&block)
|
20
20
|
if use_source?
|
21
21
|
if !Tdfire::BinaryStateStore.printed_pods.include?(name)
|
22
|
-
UI.puts "Source".magenta.bold + " dependecy for " + "#{name} #{version}".
|
22
|
+
UI.puts "Source".magenta.bold + " dependecy for " + "#{name} #{version}".green.bold
|
23
23
|
Tdfire::BinaryStateStore.printed_pods << name
|
24
24
|
end
|
25
25
|
|
@@ -31,7 +31,7 @@ module Pod
|
|
31
31
|
def tdfire_binary(&block)
|
32
32
|
if !use_source?
|
33
33
|
if !Tdfire::BinaryStateStore.printed_pods.include?(name)
|
34
|
-
UI.puts "Binary".cyan.bold + " dependecy for " + "#{name} #{version}".
|
34
|
+
UI.puts "Binary".cyan.bold + " dependecy for " + "#{name} #{version}".green.bold
|
35
35
|
Tdfire::BinaryStateStore.printed_pods << name
|
36
36
|
end
|
37
37
|
|
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.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- tripleCC
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-03-
|
11
|
+
date: 2018-03-21 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: colored2
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.1'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.1'
|
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:
|
@@ -72,6 +86,7 @@ files:
|
|
72
86
|
- lib/cocoapods-tdfire-binary/gem_version.rb
|
73
87
|
- lib/cocoapods-tdfire-binary/podfile_dsl.rb
|
74
88
|
- lib/cocoapods-tdfire-binary/podfile_hook.rb
|
89
|
+
- lib/cocoapods-tdfire-binary/source_chain_analyzer.rb
|
75
90
|
- lib/cocoapods-tdfire-binary/specification_dsl.rb
|
76
91
|
- lib/cocoapods_plugin.rb
|
77
92
|
- spec/command/binary_spec.rb
|