cocoapods-tdf-bin 0.0.18 → 0.0.22

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: e942896253a1d129115b23c8d16e0e8a48132ca908fd55c65418d8a5bc2eb852
4
- data.tar.gz: f21420c824eccac318f510e969b2283e0dd84719dc4b2f119365c0ca4b402701
3
+ metadata.gz: 5a9056382c20f2100f7822d00940ccbdd7b39f9cb3c351fef8972afd299e06e6
4
+ data.tar.gz: a64bc11f1037ba6213fe2796009848ae210ddbf29d75cbbffaab078447e2a446
5
5
  SHA512:
6
- metadata.gz: 1e4ba88019303f1233cf55550f68b29393211c8f722c6e3de943d4c8f7049eb9f265d61f298de6e15397994a64f655ef71c74881dd2117b9e45b5cbc50b1174d
7
- data.tar.gz: deb0038838eb9790bc855469bc738c589d5025592a411d4b6851b5db0f56f4f3958b6240706f4dc9df024d36edf325eaadcda28e4341167e04ec90f049b5615d
6
+ metadata.gz: df99a6379cd2e1f20914ec71986404ff8c516ae8ad484004989f51c2f6ce2593fc73598a9d66bc01731eb4805784ab8188ecbd339e07cefae63a99d85bf93fc7
7
+ data.tar.gz: 66783cc41156b058cc4766c480b1b0edb978ebba9fb1307081d7d6e12af58dc135c024fa69b3bea0d5ae8ccd8d0244c74d040c9509b7b938423425b012fae9e9
@@ -15,36 +15,143 @@ module Pod
15
15
 
16
16
  def self.options
17
17
  [
18
- ['pull', '本地库全部拉取'],
19
- ['push', '本地库全部推送'],
20
- ['chenckout {分支名}', '切换指定分支'],
21
- ['chenckout -b {分支名}', '切出指定分支'],
18
+ ['clone', '本地库全部 clone 到指定本地目录'],
19
+ ['done', '完成本地库,自动将本地的 local 依赖改为remote依赖'],
20
+ ['{ git 命令 }', '本地库全部执行 git 命令,比如 pod bin batch pull, pod bin batch checkout -b feature/***'],
22
21
  ]
23
22
  end
24
23
 
25
24
  def initialize(argv)
26
- @arguments = argv.arguments
25
+ @arguments = argv.arguments.map
27
26
  super
28
27
  end
29
28
 
30
29
  def run
31
30
  podfile = File.join(Pathname.pwd, "Podfile")
32
31
  podfile_instance = Pod::Podfile.from_file(podfile)
33
- podfile_instance.get_batch_local_pods.each_value do |value|
34
- path = value[0][:path]
35
- arg = @arguments.join(" ")
36
- puts "============== #{path} 开始执行 git #{arg} 命令 ==============".blue
37
- puts `git -C #{path} #{arg}`
32
+ if podfile_instance.get_batch_local_pods == nil
33
+ help! "没有本地依赖的组件"
34
+ end
35
+ if @arguments.size == 1 && @arguments[0] == "clone"
36
+ clone_all(podfile_instance)
37
+ elsif @arguments.size == 1 && @arguments[0] == "done"
38
+ done_all(podfile_instance)
39
+ else
40
+ run_git(podfile_instance)
38
41
  end
39
42
  end
40
43
 
41
44
  def validate!
45
+ if @arguments.size < 1
46
+ help! "命令参数不够"
47
+ end
42
48
  git = `which git`
43
49
  if git.empty?
44
50
  help! "没有安装 git 命令"
45
51
  end
46
52
  end
47
53
 
54
+ def clone_all(podfile_instance)
55
+ local_pods = podfile_instance.get_batch_local_pods
56
+ local_pods.each_key do |name|
57
+ path = local_pods[name][0][:path]
58
+ repo_url = find_repo_with_pod(name)
59
+ puts "============== #{name} 开始 clone 到 #{path}==============".blue
60
+ puts `git clone #{repo_url} #{path}`
61
+ end
62
+ end
63
+
64
+ def run_git(podfile_instance)
65
+ podfile_instance.get_batch_local_pods.each_value do |value|
66
+ path = value[0][:path]
67
+ arg = @arguments.map do |v|
68
+ match_str = /\s/.match(v)
69
+ if nil != match_str
70
+ v = "\"#{v}\""
71
+ end
72
+ v
73
+ end
74
+ arg = arg.join(" ")
75
+ puts "============== #{path} 开始执行 git #{arg} 命令 ==============".blue
76
+ puts `git -C #{path} #{arg}`
77
+ end
78
+ end
79
+
80
+ def done_all(podfile_instance)
81
+ # 通过 local_batch 找出对应的group 和 branch 并分组
82
+ local_pods = podfile_instance.get_batch_local_pods
83
+ group_map = {}
84
+ local_pods.each_key do |name|
85
+ path = local_pods[name][0][:path]
86
+ git_url = `git -C #{path} remote get-url --push origin`
87
+ current_branch = `git -C #{path} branch --show-current`.delete!("\n")
88
+ group_name = get_group_with_repo(git_url)
89
+ puts "============== #{name} 当前分支 #{current_branch} 当前组 #{group_name} ==============".blue
90
+
91
+ group_key = "#{group_name}&&#{current_branch}"
92
+ repo_arr = group_map[group_key]
93
+ if repo_arr.is_a? Array
94
+ repo_arr << name
95
+ else
96
+ arr = [name]
97
+ group_map[group_key] = arr
98
+ end
99
+ end
100
+
101
+ # 生成对应的 bacth_pod_remte 字符串
102
+ pod_remote_str = ""
103
+ group_map.each_key do |key|
104
+ pod_remote_str << " batch_pod_remote [\n"
105
+ pod_names = group_map[key]
106
+ pod_names.each do |name|
107
+ pod_remote_str << " \"#{name}\",\n"
108
+ end
109
+ group = key.split("&&")[0]
110
+ branch = key.split("&&")[1]
111
+ pod_remote_str << " ], \"#{branch}\", \"#{group}\"\n\n"
112
+ end
113
+ puts "将 local_batch 依赖 替换为 \n#{pod_remote_str}".blue
114
+
115
+ # 替换 podfile 中的local batch
116
+ podfile = File.join(Pathname.pwd, "Podfile")
117
+ podfile_str = File.read(podfile).gsub(/ *batch_pod_local *\[([^\].]*)\], *".*"/, pod_remote_str)
118
+ File.open(podfile, "r+") do |podfile|
119
+ podfile << podfile_str
120
+ end
121
+ puts "替换成功".blue
122
+ end
123
+
124
+ def find_repo_with_pod(pod_name)
125
+ sources = config.sources_manager.all
126
+ sources = sources.select do |s|
127
+ s.name == "2dfire-cocoapods-spec"
128
+ end
129
+ source = sources[0]
130
+ repo_path = source.repo.to_s + "/#{pod_name}"
131
+ versions = `ls #{repo_path}`.split("\n")
132
+ versions = versions.sort do |x ,y|
133
+ y<=>x
134
+ end
135
+ last_version = versions[0]
136
+ spec_file = `ls #{repo_path}/#{last_version}`.split("\n")[0]
137
+ spec = Pod::Spec.from_file("#{repo_path}/#{last_version}/#{spec_file}")
138
+ git_url = spec.attributes_hash["source"]["git"]
139
+ git_url
140
+ end
141
+
142
+ def get_group_with_repo(repo_url)
143
+ if repo_url.start_with?("http")
144
+ re = Regexp.new("git.2dfire.net/.*/")
145
+ repo_group = repo_url.match(re)[0][15..-2]
146
+ else
147
+ re = Regexp.new("git.2dfire.net:.*/")
148
+ repo_group = repo_url.match(re)[0][15..-2]
149
+ end
150
+ repo_group
151
+ end
152
+
153
+ private :clone_all, :run_git, :find_repo_with_pod, :done_all, :get_group_with_repo
154
+
48
155
  end
49
156
  end
50
157
  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.18'
3
+ VERSION = '0.0.22'
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.18
4
+ version: 0.0.22
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-15 00:00:00.000000000 Z
11
+ date: 2021-11-25 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