cocoapods-tdf-bin 0.0.19 → 0.0.20

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: b58f1137fcf3c0bcfc65f809f0946fd507cbf343283526c0461b91fb7a3f87a9
4
- data.tar.gz: 8cd669301226f7796ebe3962d757fed9c7d75c8714a035d343c7fc8f7ea06f41
3
+ metadata.gz: 0c0aa092f0b877d34f9d83f058a11fd05a1ba66970ea31d052139c6cf20ce067
4
+ data.tar.gz: 84105568bae6e85ba0a53fba5920542e3bcdd98dfd1c0cdb63c299f40c880b85
5
5
  SHA512:
6
- metadata.gz: fdf308408a6030c385995956553f2cdf13de2b41a964c17e4b5d1ef811fd91809694048d260ebd0e39fbb3573f5818b1e19775953fb23fb0eb50d4737d2c52a0
7
- data.tar.gz: 4f6201140a65d724e4409ac7f3067eab97b22f2d7bf7e60deba4fe4a47be302c075f6cca324a532ab6c7148d958c5ab68de40911431f0166a1390881a7152b3b
6
+ metadata.gz: c11d27a445a8e609e2eee91dc2d82bd23ed8fcdb43f435173d728963f96a1bfd1767f514ac597bbc12c2c89fab4b329325cc57f37e2ff227815245e76788451a
7
+ data.tar.gz: e444caa31f9bc67f4e06770d57f738e9906a1fd57082f8108f611af260116fa3214db85a2d68198f0cfcc4e9b5cfc3aae57d8f6d21f683bdcb5dae92c462da21
@@ -16,6 +16,7 @@ module Pod
16
16
  def self.options
17
17
  [
18
18
  ['clone', '本地库全部 clone 到指定本地目录'],
19
+ ['done', '完成本地库,自动将本地的 local 依赖改为remote依赖'],
19
20
  ['{ git 命令 }', '本地库全部执行 git 命令,比如 pod bin batch pull, pod bin batch checkout -b feature/***'],
20
21
  ]
21
22
  end
@@ -33,11 +34,23 @@ module Pod
33
34
  end
34
35
  if @arguments.size == 1 && @arguments[0] == "clone"
35
36
  clone_all(podfile_instance)
37
+ elsif @arguments.size == 1 && @arguments[0] == "done"
38
+ done_all(podfile_instance)
36
39
  else
37
40
  run_git(podfile_instance)
38
41
  end
39
42
  end
40
43
 
44
+ def validate!
45
+ if @arguments.size < 1
46
+ help! "命令参数不够"
47
+ end
48
+ git = `which git`
49
+ if git.empty?
50
+ help! "没有安装 git 命令"
51
+ end
52
+ end
53
+
41
54
  def clone_all(podfile_instance)
42
55
  local_pods = podfile_instance.get_batch_local_pods
43
56
  local_pods.each_key do |name|
@@ -57,6 +70,50 @@ module Pod
57
70
  end
58
71
  end
59
72
 
73
+ def done_all(podfile_instance)
74
+ # 通过 local_batch 找出对应的group 和 branch 并分组
75
+ local_pods = podfile_instance.get_batch_local_pods
76
+ group_map = {}
77
+ local_pods.each_key do |name|
78
+ path = local_pods[name][0][:path]
79
+ git_url = `git -C #{path} remote get-url --push origin`
80
+ current_branch = `git -C #{path} branch --show-current`.delete!("\n")
81
+ group_name = get_group_with_repo(git_url)
82
+ puts "============== #{name} 当前分支 #{current_branch} 当前组 #{group_name} ==============".blue
83
+
84
+ group_key = "#{group_name}&&#{current_branch}"
85
+ repo_arr = group_map[group_key]
86
+ if repo_arr.is_a? Array
87
+ repo_arr << name
88
+ else
89
+ arr = [name]
90
+ group_map[group_key] = arr
91
+ end
92
+ end
93
+
94
+ # 生成对应的 bacth_pod_remte 字符串
95
+ pod_remote_str = ""
96
+ group_map.each_key do |key|
97
+ pod_remote_str << " batch_pod_remote [\n"
98
+ pod_names = group_map[key]
99
+ pod_names.each do |name|
100
+ pod_remote_str << " \"#{name}\",\n"
101
+ end
102
+ group = key.split("&&")[0]
103
+ branch = key.split("&&")[1]
104
+ pod_remote_str << " ], \"#{branch}\", \"#{group}\"\n\n"
105
+ end
106
+ puts "将 local_batch 依赖 替换为 \n#{pod_remote_str}".blue
107
+
108
+ # 替换 podfile 中的local batch
109
+ podfile = File.join(Pathname.pwd, "Podfile")
110
+ podfile_str = File.read(podfile).gsub(/ *batch_pod_local *\[([^\].]*)\], *".*"/, pod_remote_str)
111
+ File.open(podfile, "r+") do |podfile|
112
+ podfile << podfile_str
113
+ end
114
+ puts "替换成功".blue
115
+ end
116
+
60
117
  def find_repo_with_pod(pod_name)
61
118
  sources = config.sources_manager.all
62
119
  sources = sources.select do |s|
@@ -75,16 +132,19 @@ module Pod
75
132
  git_url
76
133
  end
77
134
 
78
- def validate!
79
- if @arguments.size < 1
80
- help! "命令参数不够"
81
- end
82
- git = `which git`
83
- if git.empty?
84
- help! "没有安装 git 命令"
135
+ def get_group_with_repo(repo_url)
136
+ if repo_url.start_with?("http")
137
+ re = Regexp.new("git.2dfire.net/.*/")
138
+ repo_group = repo_url.match(re)[0][15..-2]
139
+ else
140
+ re = Regexp.new("git.2dfire.net:.*/")
141
+ repo_group = repo_url.match(re)[0][15..-2]
85
142
  end
143
+ repo_group
86
144
  end
87
145
 
146
+ private :clone_all, :run_git, :find_repo_with_pod, :done_all, :get_group_with_repo
147
+
88
148
  end
89
149
  end
90
150
  end
@@ -1,14 +1,9 @@
1
1
 
2
- require 'cocoapods-tdf-bin/command/bin/initHotKey'
3
2
  require 'cocoapods-tdf-bin/command/bin/init'
4
3
  require 'cocoapods-tdf-bin/command/bin/archive'
5
4
  require 'cocoapods-tdf-bin/command/bin/auto'
6
5
  require 'cocoapods-tdf-bin/command/bin/code'
7
- require 'cocoapods-tdf-bin/command/bin/update'
8
- require 'cocoapods-tdf-bin/command/bin/install'
9
- require 'cocoapods-tdf-bin/command/bin/imy'
10
6
  require 'cocoapods-tdf-bin/command/bin/batch'
11
-
12
7
  require 'cocoapods-tdf-bin/helpers'
13
8
 
14
9
  module Pod
@@ -1,6 +1,6 @@
1
1
 
2
2
  module CBin
3
- VERSION = '0.0.19'
3
+ VERSION = '0.0.20'
4
4
  end
5
5
 
6
6
  module Pod
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.19
4
+ version: 0.0.20
5
5
  platform: ruby
6
6
  authors:
7
7
  - gaijiaofan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-16 00:00:00.000000000 Z
11
+ date: 2021-11-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parallel
@@ -97,15 +97,11 @@ files:
97
97
  - lib/cocoapods-tdf-bin/command/bin/auto.rb
98
98
  - lib/cocoapods-tdf-bin/command/bin/batch.rb
99
99
  - lib/cocoapods-tdf-bin/command/bin/code.rb
100
- - lib/cocoapods-tdf-bin/command/bin/imy.rb
101
100
  - lib/cocoapods-tdf-bin/command/bin/init.rb
102
- - lib/cocoapods-tdf-bin/command/bin/initHotKey.rb
103
- - lib/cocoapods-tdf-bin/command/bin/install.rb
104
101
  - lib/cocoapods-tdf-bin/command/bin/lib/lint.rb
105
102
  - lib/cocoapods-tdf-bin/command/bin/repo/update.rb
106
103
  - lib/cocoapods-tdf-bin/command/bin/spec/create.rb
107
104
  - lib/cocoapods-tdf-bin/command/bin/spec/push.rb
108
- - lib/cocoapods-tdf-bin/command/bin/update.rb
109
105
  - lib/cocoapods-tdf-bin/config/config.rb
110
106
  - lib/cocoapods-tdf-bin/config/config_asker.rb
111
107
  - lib/cocoapods-tdf-bin/config/config_builder.rb
@@ -1,46 +0,0 @@
1
- require 'cocoapods-tdf-bin/config/config_hot_key_asker'
2
-
3
- module Pod
4
- class Command
5
- class Bin < Command
6
- class Imy < Bin
7
- self.summary = '快捷键'
8
- self.description = <<-DESC
9
- 创建 文件,在其中保存插件需要的配置信息,
10
- 如二进制私有源地址、源码私有源地址等。
11
- DESC
12
-
13
- self.arguments = [
14
- CLAide::Argument.new('1', false)
15
- ]
16
-
17
- def self.options
18
- [
19
- ].concat(super)
20
- end
21
-
22
- def initialize(argv)
23
- @hot_key = argv.shift_argument || '1'
24
- super
25
- end
26
-
27
- def run
28
- CBin.config_hot_key.set_hot_key_index(@hot_key)
29
- UI.puts "cd #{CBin.config_hot_key.hot_key_dir}".yellow
30
-
31
- if Dir.exist?(CBin.config_hot_key.hot_key_dir)
32
- Dir.chdir(CBin.config_hot_key.hot_key_dir) do
33
- UI.puts " #{CBin.config_hot_key.hot_key_cmd}".yellow
34
- system CBin.config_hot_key.hot_key_cmd
35
- end
36
- else
37
- raise "配置项中文件目录不存在 #{CBin.config_hot_key.hot_key_dir}"
38
- end
39
-
40
-
41
- end
42
-
43
- end
44
- end
45
- end
46
- end
@@ -1,70 +0,0 @@
1
-
2
- require 'cocoapods-tdf-bin/config/config_hot_key_asker'
3
-
4
- module Pod
5
- class Command
6
- class Bin < Command
7
- class Inithk < Bin
8
- self.summary = '初始化快捷键配置.'
9
- self.description = <<-DESC
10
- 创建 文件,在其中保存插件需要的配置信息,
11
- 如二进制私有源地址、源码私有源地址等。
12
- DESC
13
-
14
- def self.options
15
- [
16
- ['--bin-url=URL', '配置文件地址,直接从此地址下载配置文件']
17
- ].concat(super)
18
- end
19
-
20
- def initialize(argv)
21
- @bin_url = argv.option('bin-url')
22
- super
23
- end
24
-
25
- def run
26
- if @bin_url.nil?
27
- config_with_asker
28
- else
29
- config_with_url(@bin_url)
30
- end
31
- end
32
-
33
- private
34
-
35
- def config_with_url(url)
36
- require 'open-uri'
37
-
38
- UI.puts "开始下载配置文件...\n"
39
- file = open(url)
40
- contents = YAML.safe_load(file.read)
41
-
42
- UI.puts "开始同步配置文件...\n"
43
- CBin.config_hot_key.sync_config(contents.to_hash)
44
- UI.puts "设置完成.\n".green
45
- rescue Errno::ENOENT => e
46
- raise Informative, "配置文件路径 #{url} 无效,请确认后重试."
47
- end
48
-
49
- def config_with_asker
50
- asker = CBin::Config_Hot_Key::Asker.new
51
- asker.wellcome_message
52
-
53
- config = {}
54
- template_hash = CBin.config_hot_key.template_hash
55
- template_hash.each do |k, v|
56
- default = begin
57
- CBin.config_hot_key.send(k)
58
- rescue StandardError
59
- nil
60
- end
61
- config[k] = asker.ask_with_answer(v[:description], default, v[:selection])
62
- end
63
-
64
- CBin.config_hot_key.sync_config(config)
65
- asker.done_message
66
- end
67
- end
68
- end
69
- end
70
- end
@@ -1,44 +0,0 @@
1
-
2
- require 'cocoapods-tdf-bin/command/bin/update'
3
- module Pod
4
- class Command
5
- class Bin < Command
6
- class Install < Bin
7
- include Pod
8
-
9
- self.summary = 'pod install 拦截器,会加载本地Podfile_local文件,DSL加载到原始Podfile文件中。'
10
-
11
- self.description = <<-DESC
12
- pod install 拦截器,会加载本地Podfile_local文件
13
- 会通过DSL加载到原始Podfile文件中
14
- 支持 pod 'xxx' 各种写法
15
- 支持 post_install/pre_install钩子,采用覆盖做法
16
- DESC
17
- def self.options
18
- [
19
- ['--repo-update', 'Force running `pod repo update` before install'],
20
- ['--deployment', 'Disallow any changes to the Podfile or the Podfile.lock during installation'],
21
- ['--clean-install', 'Ignore the contents of the project cache and force a full pod installation. This only ' \
22
- 'applies to projects that have enabled incremental installation']
23
- ].concat(super).reject { |(name, _)| name == '--no-repo-update' }
24
- end
25
-
26
- def initialize(argv)
27
- @update = argv.flag?('update')
28
- super
29
- @additional_args = argv.remainder!
30
- end
31
-
32
- def run
33
- Update.load_local_podfile
34
- argvs = [
35
- *@additional_args
36
- ]
37
- gen = Pod::Command::Install.new(CLAide::ARGV.new(argvs))
38
- gen.validate!
39
- gen.run
40
- end
41
- end
42
- end
43
- end
44
- end
@@ -1,157 +0,0 @@
1
-
2
- require 'cocoapods'
3
- require 'cocoapods-tdf-bin/native/podfile_env'
4
- require 'cocoapods-tdf-bin/native/podfile'
5
-
6
- module Pod
7
- class Command
8
- class Bin < Command
9
- class Update < Bin
10
- include Pod
11
- include Pod::Podfile::DSL
12
-
13
- self.summary = 'pod update 拦截器,会加载本地Podfile_local文件,DSL加载到原始Podfile文件中。'
14
-
15
- self.description = <<-DESC
16
- pod update 拦截器,会加载本地Podfile_local文件
17
- 会通过DSL加载到原始Podfile文件中
18
- 支持 pod 'xxx' 各种写法
19
- 支持 post_install/pre_install钩子,采用覆盖做法
20
- DESC
21
- def self.options
22
- [
23
- ["--sources=#{Pod::TrunkSource::TRUNK_REPO_URL}", 'The sources from which to update dependent pods. ' \
24
- 'Multiple sources must be comma-delimited'],
25
- ['--exclude-pods=podName', 'Pods to exclude during update. Multiple pods must be comma-delimited'],
26
- ['--clean-install', 'Ignore the contents of the project cache and force a full pod installation. This only ' \
27
- 'applies to projects that have enabled incremental installation'],
28
- ['--project-directory=/project/dir/', 'The path to the root of the project directory'],
29
- ['--no-repo-update', 'Skip running `pod repo update` before install']
30
- ].concat(super)
31
- end
32
-
33
- def initialize(argv)
34
- @update = argv.flag?('update')
35
- super
36
- @additional_args = argv.remainder!
37
- end
38
-
39
- def run
40
- Update.load_local_podfile
41
-
42
- argvs = [
43
- *@additional_args
44
- ]
45
-
46
- gen = Pod::Command::Update.new(CLAide::ARGV.new(argvs))
47
- gen.validate!
48
- gen.run
49
- end
50
-
51
- def self.load_local_podfile
52
- # 同步 Podfile_local 文件
53
- project_root = Pod::Config.instance.project_root
54
- path = File.join(project_root.to_s, 'Podfile_local')
55
- unless File.exist?(path)
56
- path = File.join(project_root.to_s, 'Podfile_local')
57
- end
58
-
59
- if File.exist?(path)
60
- contents = File.open(path, 'r:utf-8', &:read)
61
-
62
- podfile = Pod::Config.instance.podfile
63
- local_podfile = Podfile.from_file(path)
64
-
65
- if local_podfile
66
- local_pre_install_callback = nil
67
- local_post_install_callback = nil
68
- local_podfile.instance_eval do
69
- local_pre_install_callback = @pre_install_callback
70
- local_post_install_callback = @post_install_callback
71
- end
72
- end
73
-
74
- podfile.instance_eval do
75
- begin
76
-
77
- # podfile HASH_KEYS才有plugins字段,否则会被限制
78
- if local_podfile.plugins.any?
79
- hash_plugins = podfile.plugins || {}
80
- hash_plugins = hash_plugins.merge(local_podfile.plugins)
81
- set_hash_value(%w[plugins].first, hash_plugins)
82
-
83
- # 加入源码白名单,避免本地库被二进制了
84
- podfile.set_use_source_pods(local_podfile.use_source_pods) if local_podfile.use_source_pods
85
- podfile.use_binaries!(local_podfile.use_binaries?)
86
- end
87
-
88
- # 在target把local-target中到dependencies值删除了,再设置
89
- # 把本地和原始到dependencies 合并,设置dependencies
90
- local_podfile&.target_definition_list&.each do |local_target|
91
- next if local_target.name == 'Pods'
92
-
93
- target_definition_list.each do |target|
94
-
95
- unless target.name == local_target.name &&
96
- (local_target.to_hash['dependencies'] &&local_target.to_hash['dependencies'].any?)
97
- next
98
- end
99
-
100
-
101
-
102
- target.instance_exec do
103
- # 在target把local-target中到dependencies值删除了,再设置
104
-
105
- local_dependencies = local_target.to_hash['dependencies']
106
- target_dependencies = target.to_hash['dependencies']
107
-
108
- local_dependencies.each do |local_dependency|
109
- unless local_dependency.is_a?(Hash) && local_dependency.keys.first
110
- next
111
- end
112
-
113
- target_dependencies.each do |target_dependency|
114
- dp_hash_equal = target_dependency.is_a?(Hash) &&
115
- target_dependency.keys.first &&
116
- target_dependency.keys.first == local_dependency.keys.first
117
- dp_str_equal = target_dependency.is_a?(String) &&
118
- target_dependency == local_dependency.keys.first
119
- next unless dp_hash_equal || dp_str_equal
120
-
121
- target_dependencies.delete target_dependency
122
- break
123
- end
124
- end
125
- # 把本地和原始到dependencies 合并,设置dependencies
126
- local_dependencies.each do |d|
127
- UI.message "Development Pod #{d.to_yaml}"
128
- if podfile.plugins.keys.include?('cocoapods-tdf-bin')
129
- podfile.set_use_source_pods(d.keys.first) if (d.is_a?(Hash) && d.keys.first)
130
- end
131
- end
132
- new_dependencies = target_dependencies + local_dependencies
133
- set_hash_value(%w[dependencies].first, new_dependencies)
134
-
135
- end
136
- end
137
-
138
- end
139
-
140
- if local_pre_install_callback
141
- @pre_install_callback = local_pre_install_callback
142
- end
143
- if local_post_install_callback
144
- @post_install_callback = local_post_install_callback
145
- end
146
- rescue Exception => e
147
- message = "Invalid `#{path}` file: #{e.message}"
148
- raise Pod::DSLError.new(message, path, e, contents)
149
- end
150
- end
151
-
152
- end
153
- end
154
- end
155
- end
156
- end
157
- end