cocoapods-tdf-bin 0.0.15 → 0.0.19

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
  SHA256:
3
- metadata.gz: 86a91d0128afbce92cb49c569930af615972ff11440d4272345e0a077a6a1fa1
4
- data.tar.gz: 01c470b5ac5dc999e4a3abcbd8cb39f355780358f4a738de7e053156a0d26b3c
3
+ metadata.gz: b58f1137fcf3c0bcfc65f809f0946fd507cbf343283526c0461b91fb7a3f87a9
4
+ data.tar.gz: 8cd669301226f7796ebe3962d757fed9c7d75c8714a035d343c7fc8f7ea06f41
5
5
  SHA512:
6
- metadata.gz: 2d450a0cd70705f4a4603bf64e40313c3c2ca1015aa9dc39fa24d2c1e069f594812cfdb48a9c228cc0605e126c00264a578171f33afb075ccb068fae1517d7c0
7
- data.tar.gz: 40eb0a9bb0963bf0b1009d00f82c30c68104542d8a55a739e626a7da2fb42b441af52485e30f5b4ba727780cab78ff7cb7dd17b17bcaed519af14adcba58263b
6
+ metadata.gz: fdf308408a6030c385995956553f2cdf13de2b41a964c17e4b5d1ef811fd91809694048d260ebd0e39fbb3573f5818b1e19775953fb23fb0eb50d4737d2c52a0
7
+ data.tar.gz: 4f6201140a65d724e4409ac7f3067eab97b22f2d7bf7e60deba4fe4a47be302c075f6cca324a532ab6c7148d958c5ab68de40911431f0166a1390881a7152b3b
@@ -0,0 +1,91 @@
1
+ require 'cocoapods-tdf-bin/native/podfile_env'
2
+ require 'cocoapods-tdf-bin/native/podfile'
3
+ require 'cocoapods-tdf-bin/helpers/string_helper'
4
+
5
+ module Pod
6
+ class Command
7
+ class Bin < Command
8
+ class Batch < Bin
9
+
10
+ self.summary = "批量操作本地依赖组件的 git 命令"
11
+ self.description = <<-DESC
12
+ 用来批量操作通过 batch_pod_local 本地依赖的组件库,比如 pod bin batch pull, pod bin batch checkout master 等等;
13
+ 操作的是是通过 batch_pod_local 依赖的本地组件
14
+ DESC
15
+
16
+ def self.options
17
+ [
18
+ ['clone', '本地库全部 clone 到指定本地目录'],
19
+ ['{ git 命令 }', '本地库全部执行 git 命令,比如 pod bin batch pull, pod bin batch checkout -b feature/***'],
20
+ ]
21
+ end
22
+
23
+ def initialize(argv)
24
+ @arguments = argv.arguments
25
+ super
26
+ end
27
+
28
+ def run
29
+ podfile = File.join(Pathname.pwd, "Podfile")
30
+ podfile_instance = Pod::Podfile.from_file(podfile)
31
+ if podfile_instance.get_batch_local_pods == nil
32
+ help! "没有本地依赖的组件"
33
+ end
34
+ if @arguments.size == 1 && @arguments[0] == "clone"
35
+ clone_all(podfile_instance)
36
+ else
37
+ run_git(podfile_instance)
38
+ end
39
+ end
40
+
41
+ def clone_all(podfile_instance)
42
+ local_pods = podfile_instance.get_batch_local_pods
43
+ local_pods.each_key do |name|
44
+ path = local_pods[name][0][:path]
45
+ repo_url = find_repo_with_pod(name)
46
+ puts "============== #{name} 开始 clone 到 #{path}==============".blue
47
+ puts `git clone #{repo_url} #{path}`
48
+ end
49
+ end
50
+
51
+ def run_git(podfile_instance)
52
+ podfile_instance.get_batch_local_pods.each_value do |value|
53
+ path = value[0][:path]
54
+ arg = @arguments.join(" ")
55
+ puts "============== #{path} 开始执行 git #{arg} 命令 ==============".blue
56
+ puts `git -C #{path} #{arg}`
57
+ end
58
+ end
59
+
60
+ def find_repo_with_pod(pod_name)
61
+ sources = config.sources_manager.all
62
+ sources = sources.select do |s|
63
+ s.name == "2dfire-cocoapods-spec"
64
+ end
65
+ source = sources[0]
66
+ repo_path = source.repo.to_s + "/#{pod_name}"
67
+ versions = `ls #{repo_path}`.split("\n")
68
+ versions = versions.sort do |x ,y|
69
+ y<=>x
70
+ end
71
+ last_version = versions[0]
72
+ spec_file = `ls #{repo_path}/#{last_version}`.split("\n")[0]
73
+ spec = Pod::Spec.from_file("#{repo_path}/#{last_version}/#{spec_file}")
74
+ git_url = spec.attributes_hash["source"]["git"]
75
+ git_url
76
+ end
77
+
78
+ def validate!
79
+ if @arguments.size < 1
80
+ help! "命令参数不够"
81
+ end
82
+ git = `which git`
83
+ if git.empty?
84
+ help! "没有安装 git 命令"
85
+ end
86
+ end
87
+
88
+ end
89
+ end
90
+ end
91
+ end
@@ -7,6 +7,7 @@ require 'cocoapods-tdf-bin/command/bin/code'
7
7
  require 'cocoapods-tdf-bin/command/bin/update'
8
8
  require 'cocoapods-tdf-bin/command/bin/install'
9
9
  require 'cocoapods-tdf-bin/command/bin/imy'
10
+ require 'cocoapods-tdf-bin/command/bin/batch'
10
11
 
11
12
  require 'cocoapods-tdf-bin/helpers'
12
13
 
@@ -1,6 +1,6 @@
1
1
 
2
2
  module CBin
3
- VERSION = '0.0.15'
3
+ VERSION = '0.0.19'
4
4
  end
5
5
 
6
6
  module Pod
@@ -0,0 +1,30 @@
1
+ class String
2
+ # colorization
3
+ def colorize(color_code)
4
+ "\e[#{color_code}m#{self}\e[0m"
5
+ end
6
+
7
+ def red
8
+ colorize(31)
9
+ end
10
+
11
+ def green
12
+ colorize(32)
13
+ end
14
+
15
+ def yellow
16
+ colorize(33)
17
+ end
18
+
19
+ def blue
20
+ colorize(34)
21
+ end
22
+
23
+ def pink
24
+ colorize(35)
25
+ end
26
+
27
+ def light_blue
28
+ colorize(36)
29
+ end
30
+ end
@@ -21,6 +21,7 @@ module Pod
21
21
  def use_frameworks_value
22
22
  {:linkage => :static}
23
23
  end
24
+
24
25
  end
25
26
  end
26
27
  end
@@ -12,6 +12,46 @@ module Pod
12
12
  set_internal_hash_value(ALLOW_PRERELEASE, true)
13
13
  end
14
14
 
15
+ def batch_pod_local(pods, path = "../../")
16
+ pod_hash = Hash.new
17
+ pods.each do |name|
18
+ pod_hash[name] = [ :path => "#{path}#{name}" ]
19
+ end
20
+ if get_batch_local_pods.nil?
21
+ set_internal_hash_value(BATCH_POD_LOCAL, pod_hash)
22
+ else
23
+ set_internal_hash_value(BATCH_POD_LOCAL, get_internal_hash_value(BATCH_POD_LOCAL).merge(pod_hash))
24
+ end
25
+ end
26
+
27
+ def batch_pod_remote(pods, branch , group = 'ios')
28
+ pod_hash = Hash.new
29
+ pods.each do |name|
30
+ pod_hash[name] = [ :git => "git@git.2dfire.net:#{group}/#{name}.git", :branch => "#{branch}" ]
31
+ end
32
+ if get_batch_remote_pods.nil?
33
+ set_internal_hash_value(BATCH_POD_REMOTE, pod_hash)
34
+ else
35
+ set_internal_hash_value(BATCH_POD_REMOTE, get_internal_hash_value(BATCH_POD_REMOTE).merge(pod_hash))
36
+ end
37
+ end
38
+
39
+ def pod(name = nil, *requirements)
40
+ unless name
41
+ raise StandardError, 'A dependency requires a name.'
42
+ end
43
+
44
+ local_pod_hash = get_batch_local_pods
45
+ remote_pod_hash = get_batch_remote_pods
46
+ if remote_pod_hash != nil
47
+ requirements = remote_pod_hash[name].nil? ? requirements : remote_pod_hash[name];
48
+ end
49
+ if local_pod_hash != nil
50
+ requirements = local_pod_hash[name].nil? ? requirements : local_pod_hash[name];
51
+ end
52
+ current_target_definition.store_pod(name, *requirements)
53
+ end
54
+
15
55
  def use_binaries!(flag = true)
16
56
  set_internal_hash_value(USE_BINARIES, flag)
17
57
  end
@@ -61,6 +101,14 @@ module Pod
61
101
  get_internal_hash_value(USE_BINARIES, false) || ENV[USE_BINARIES] == 'true'
62
102
  end
63
103
 
104
+ def get_batch_local_pods
105
+ get_internal_hash_value(BATCH_POD_LOCAL)
106
+ end
107
+
108
+ def get_batch_remote_pods
109
+ get_internal_hash_value(BATCH_POD_REMOTE)
110
+ end
111
+
64
112
  def use_source_pods
65
113
  get_internal_hash_value(USE_SOURCE_PODS, []) + String(ENV[USE_SOURCE_PODS]).split('|').uniq
66
114
  end
@@ -8,6 +8,8 @@ module Pod
8
8
  ALLOW_PRERELEASE = 'allow_prerelease'
9
9
  USE_PLUGINS = 'use_plugins'
10
10
  CONFIGURATION_ENV = 'configuration_env'
11
+ BATCH_POD_LOCAL = 'batch_pod_local'
12
+ BATCH_POD_REMOTE = 'batch_pod_remote'
11
13
 
12
14
  module ENVExecutor
13
15
  def execute_with_bin_plugin(&block)
@@ -36,6 +36,7 @@ module Pod
36
36
  end
37
37
 
38
38
  use_frameworks!(generator.use_frameworks_value)
39
+ use_binaries!
39
40
 
40
41
  if (supported_swift_versions = generator.supported_swift_versions)
41
42
  supports_swift_versions(supported_swift_versions)
@@ -175,12 +175,14 @@ module Pod
175
175
  end
176
176
  # used_by_only = rspec.respond_to?(:used_by_tests_only) ? rspec.used_by_tests_only : rspec.used_by_non_library_targets_only
177
177
  # 组装新的 rspec ,替换原 rspec
178
- rspec = if Pod.match_version?('~> 1.4.0')
179
- ResolverSpecification.new(specification, used_by_only)
180
- else
181
- ResolverSpecification.new(specification, used_by_only, source)
182
- end
183
- UI.message "组装新的 rspec ,替换原 rspec #{rspec.root.name} #{spec_version} \r\n specification =#{specification} \r\n #{rspec} "
178
+ if rspec.source != false
179
+ rspec = if Pod.match_version?('~> 1.4.0')
180
+ ResolverSpecification.new(specification, used_by_only)
181
+ else
182
+ ResolverSpecification.new(specification, used_by_only, source)
183
+ end
184
+ UI.message "组装新的 rspec ,替换原 rspec #{rspec.root.name} #{spec_version} \r\n specification =#{specification} \r\n #{rspec} "
185
+ end
184
186
 
185
187
  rescue Pod::StandardError => e
186
188
  # 没有从新的 source 找到对应版本组件,直接返回原 rspec
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-tdf-bin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.15
4
+ version: 0.0.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - gaijiaofan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-07-06 00:00:00.000000000 Z
11
+ date: 2021-11-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parallel
@@ -95,6 +95,7 @@ files:
95
95
  - lib/cocoapods-tdf-bin/command/bin.rb
96
96
  - lib/cocoapods-tdf-bin/command/bin/archive.rb
97
97
  - lib/cocoapods-tdf-bin/command/bin/auto.rb
98
+ - lib/cocoapods-tdf-bin/command/bin/batch.rb
98
99
  - lib/cocoapods-tdf-bin/command/bin/code.rb
99
100
  - lib/cocoapods-tdf-bin/command/bin/imy.rb
100
101
  - lib/cocoapods-tdf-bin/command/bin/init.rb
@@ -123,6 +124,7 @@ files:
123
124
  - lib/cocoapods-tdf-bin/helpers/spec_creator.rb
124
125
  - lib/cocoapods-tdf-bin/helpers/spec_files_helper.rb
125
126
  - lib/cocoapods-tdf-bin/helpers/spec_source_creator.rb
127
+ - lib/cocoapods-tdf-bin/helpers/string_helper.rb
126
128
  - lib/cocoapods-tdf-bin/helpers/upload_helper.rb
127
129
  - lib/cocoapods-tdf-bin/native.rb
128
130
  - lib/cocoapods-tdf-bin/native/acknowledgements.rb