cocoapods-tdf-bin 0.0.17 → 0.0.21

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
  SHA256:
3
- metadata.gz: 3f577bfd3e7fcecd47e17b0e1bcbcde05f610607a643bb17108cf302ee3d380c
4
- data.tar.gz: e716d34c5ffbd2dba9b565fbd62f6c84b4e5013278f3e1d0f46733ace03377ac
3
+ metadata.gz: bfea2311ea4e2995ab9b416f7b7dee4cabf04228255ac3412f41bedd31563fc6
4
+ data.tar.gz: f7b77c4dc7d711472080d13dab237e3c76c1415dab6631f7855bb90bf3e42330
5
5
  SHA512:
6
- metadata.gz: 913994c6be4e81d2bc8a9678f288b2b9b3496d128a081cd174f0b2838bad714f4fc2dd4adbf2616f075e031c0e44566c04104faf7c3ec25dcf3c89e26873b58e
7
- data.tar.gz: b74dcc1705407ada38305239078378f22b3a379e14a2065ebd6895a2f43608773c828fb427a0e55c67bf17fc35c824174004db3b6c3bb6eb1029742dab2e24d2
6
+ metadata.gz: 2b1d5866284cf17a891b61e775db54c84242d6631f1e545c4bff1674dee3aada2d7fb32c0e3dcb38721c8045ee1c2ff1d0c0b6a5f7e0e6596972f0b98f3eddb8
7
+ data.tar.gz: c27895d1a9a506f6bd6888939c8d13959158bb67f8b6f6964651e8e4d54cd78dc8c279cfa1e012a53668c8d70137caa79a81446d7c6a902e9f27aa2500b660c2
@@ -15,36 +15,140 @@ 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
+ new_str = v.dup.gsub! /\s/, '_'
69
+ new_str == nil ? v : new_str
70
+ end
71
+ arg = arg.join(" ")
72
+ puts "============== #{path} 开始执行 git #{arg} 命令 ==============".blue
73
+ puts `git -C #{path} #{arg}`
74
+ end
75
+ end
76
+
77
+ def done_all(podfile_instance)
78
+ # 通过 local_batch 找出对应的group 和 branch 并分组
79
+ local_pods = podfile_instance.get_batch_local_pods
80
+ group_map = {}
81
+ local_pods.each_key do |name|
82
+ path = local_pods[name][0][:path]
83
+ git_url = `git -C #{path} remote get-url --push origin`
84
+ current_branch = `git -C #{path} branch --show-current`.delete!("\n")
85
+ group_name = get_group_with_repo(git_url)
86
+ puts "============== #{name} 当前分支 #{current_branch} 当前组 #{group_name} ==============".blue
87
+
88
+ group_key = "#{group_name}&&#{current_branch}"
89
+ repo_arr = group_map[group_key]
90
+ if repo_arr.is_a? Array
91
+ repo_arr << name
92
+ else
93
+ arr = [name]
94
+ group_map[group_key] = arr
95
+ end
96
+ end
97
+
98
+ # 生成对应的 bacth_pod_remte 字符串
99
+ pod_remote_str = ""
100
+ group_map.each_key do |key|
101
+ pod_remote_str << " batch_pod_remote [\n"
102
+ pod_names = group_map[key]
103
+ pod_names.each do |name|
104
+ pod_remote_str << " \"#{name}\",\n"
105
+ end
106
+ group = key.split("&&")[0]
107
+ branch = key.split("&&")[1]
108
+ pod_remote_str << " ], \"#{branch}\", \"#{group}\"\n\n"
109
+ end
110
+ puts "将 local_batch 依赖 替换为 \n#{pod_remote_str}".blue
111
+
112
+ # 替换 podfile 中的local batch
113
+ podfile = File.join(Pathname.pwd, "Podfile")
114
+ podfile_str = File.read(podfile).gsub(/ *batch_pod_local *\[([^\].]*)\], *".*"/, pod_remote_str)
115
+ File.open(podfile, "r+") do |podfile|
116
+ podfile << podfile_str
117
+ end
118
+ puts "替换成功".blue
119
+ end
120
+
121
+ def find_repo_with_pod(pod_name)
122
+ sources = config.sources_manager.all
123
+ sources = sources.select do |s|
124
+ s.name == "2dfire-cocoapods-spec"
125
+ end
126
+ source = sources[0]
127
+ repo_path = source.repo.to_s + "/#{pod_name}"
128
+ versions = `ls #{repo_path}`.split("\n")
129
+ versions = versions.sort do |x ,y|
130
+ y<=>x
131
+ end
132
+ last_version = versions[0]
133
+ spec_file = `ls #{repo_path}/#{last_version}`.split("\n")[0]
134
+ spec = Pod::Spec.from_file("#{repo_path}/#{last_version}/#{spec_file}")
135
+ git_url = spec.attributes_hash["source"]["git"]
136
+ git_url
137
+ end
138
+
139
+ def get_group_with_repo(repo_url)
140
+ if repo_url.start_with?("http")
141
+ re = Regexp.new("git.2dfire.net/.*/")
142
+ repo_group = repo_url.match(re)[0][15..-2]
143
+ else
144
+ re = Regexp.new("git.2dfire.net:.*/")
145
+ repo_group = repo_url.match(re)[0][15..-2]
146
+ end
147
+ repo_group
148
+ end
149
+
150
+ private :clone_all, :run_git, :find_repo_with_pod, :done_all, :get_group_with_repo
151
+
48
152
  end
49
153
  end
50
154
  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.17'
3
+ VERSION = '0.0.21'
4
4
  end
5
5
 
6
6
  module Pod
@@ -43,9 +43,12 @@ module Pod
43
43
 
44
44
  local_pod_hash = get_batch_local_pods
45
45
  remote_pod_hash = get_batch_remote_pods
46
- requirements = remote_pod_hash[name].nil? ? requirements : remote_pod_hash[name];
47
- requirements = local_pod_hash[name].nil? ? requirements : local_pod_hash[name];
48
-
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
49
52
  current_target_definition.store_pod(name, *requirements)
50
53
  end
51
54
 
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.17
4
+ version: 0.0.21
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-24 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