cocoapods-dev-env 2.0.2 → 2.1.8

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: 87f011b42c1df26a04c8ac866532a91eef0f0d7e1d854bf97e369714107c0844
4
- data.tar.gz: 9befa3b3fe9f53aa5adbd201be02fa44d33ff48b56bada40c433e90235706f0d
3
+ metadata.gz: 1b812296f28342f1708bda8556027923934872fc111920e70317d551e6dca5db
4
+ data.tar.gz: 532daa402827318f2110aaed1da2fa3896c1c97897e23bced39bbb723e2d867d
5
5
  SHA512:
6
- metadata.gz: ce2e9238b1dfb6dad9ce583adb3b9cd61bf7744e91e376dd51dfd7a516d2cbe1c8f95b2469a212c41d4b1f9cbb4be9f915f9ccb0d0b2055f52ff140fa23fe069
7
- data.tar.gz: 7d30f8dd72ef7bc78625f144e5fdd517c10f55ffec6c6985ae00fe9023673d3c6132f8cca17908f350c2bf15e55845769c684c606d729a2932ed2f5073c69f03
6
+ metadata.gz: b5ded21c4b040ae5b50f72dba1627233af519d4de30d69f26c8249285d056a23a20220a589001e728f50103857ebf3537bdfbe9ae9e3060457a04c30170c8987
7
+ data.tar.gz: 8fbcaa555da7caed0cd31bb78855bdd0fe93c20a7717d537be71d914f364aab8b53aa61ba7e828a8486a40138f2136d203e453c5e0ac585161957f65f8c02337
data/Gemfile.lock CHANGED
@@ -1,12 +1,113 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cocoapods-dev-env (2.0.2)
4
+ cocoapods-dev-env (2.1.8)
5
+ luna-binary-uploader
5
6
 
6
7
  GEM
7
8
  remote: https://rubygems.org/
8
9
  specs:
10
+ CFPropertyList (3.0.5)
11
+ rexml
12
+ activesupport (6.1.4.6)
13
+ concurrent-ruby (~> 1.0, >= 1.0.2)
14
+ i18n (>= 1.6, < 2)
15
+ minitest (>= 5.1)
16
+ tzinfo (~> 2.0)
17
+ zeitwerk (~> 2.3)
18
+ addressable (2.8.0)
19
+ public_suffix (>= 2.0.2, < 5.0)
20
+ algoliasearch (1.27.5)
21
+ httpclient (~> 2.8, >= 2.8.3)
22
+ json (>= 1.5.1)
23
+ atomos (0.1.3)
24
+ claide (1.1.0)
25
+ cocoapods (1.11.2)
26
+ addressable (~> 2.8)
27
+ claide (>= 1.0.2, < 2.0)
28
+ cocoapods-core (= 1.11.2)
29
+ cocoapods-deintegrate (>= 1.0.3, < 2.0)
30
+ cocoapods-downloader (>= 1.4.0, < 2.0)
31
+ cocoapods-plugins (>= 1.0.0, < 2.0)
32
+ cocoapods-search (>= 1.0.0, < 2.0)
33
+ cocoapods-trunk (>= 1.4.0, < 2.0)
34
+ cocoapods-try (>= 1.1.0, < 2.0)
35
+ colored2 (~> 3.1)
36
+ escape (~> 0.0.4)
37
+ fourflusher (>= 2.3.0, < 3.0)
38
+ gh_inspector (~> 1.0)
39
+ molinillo (~> 0.8.0)
40
+ nap (~> 1.0)
41
+ ruby-macho (>= 1.0, < 3.0)
42
+ xcodeproj (>= 1.21.0, < 2.0)
43
+ cocoapods-core (1.11.2)
44
+ activesupport (>= 5.0, < 7)
45
+ addressable (~> 2.8)
46
+ algoliasearch (~> 1.0)
47
+ concurrent-ruby (~> 1.1)
48
+ fuzzy_match (~> 2.0.4)
49
+ nap (~> 1.0)
50
+ netrc (~> 0.11)
51
+ public_suffix (~> 4.0)
52
+ typhoeus (~> 1.0)
53
+ cocoapods-deintegrate (1.0.5)
54
+ cocoapods-disable-podfile-validations (0.1.1)
55
+ cocoapods-downloader (1.5.1)
56
+ cocoapods-generate (2.0.1)
57
+ cocoapods-disable-podfile-validations (~> 0.1.1)
58
+ cocoapods-imy-bin (0.3.1.3)
59
+ cocoapods
60
+ cocoapods-generate (~> 2.0.0)
61
+ parallel
62
+ cocoapods-plugins (1.0.0)
63
+ nap
64
+ cocoapods-search (1.0.1)
65
+ cocoapods-trunk (1.6.0)
66
+ nap (>= 0.8, < 2.0)
67
+ netrc (~> 0.11)
68
+ cocoapods-try (1.2.0)
69
+ colored2 (3.1.2)
70
+ concurrent-ruby (1.1.9)
71
+ escape (0.0.4)
72
+ ethon (0.14.0)
73
+ ffi (>= 1.15.0)
74
+ ffi (1.15.3)
75
+ fourflusher (2.3.1)
76
+ fuzzy_match (2.0.4)
77
+ gh_inspector (1.1.3)
78
+ gli (2.19.0)
79
+ httpclient (2.8.3)
80
+ i18n (1.9.1)
81
+ concurrent-ruby (~> 1.0)
82
+ json (2.5.1)
83
+ luna-binary-uploader (0.1.26)
84
+ cocoapods
85
+ cocoapods-generate (~> 2.0.1)
86
+ cocoapods-imy-bin (= 0.3.1.3)
87
+ gli (= 2.19.0)
88
+ parallel
89
+ minitest (5.15.0)
90
+ molinillo (0.8.0)
91
+ nanaimo (0.3.0)
92
+ nap (1.1.0)
93
+ netrc (0.11.0)
94
+ parallel (1.21.0)
95
+ public_suffix (4.0.6)
9
96
  rake (10.5.0)
97
+ rexml (3.2.5)
98
+ ruby-macho (2.5.1)
99
+ typhoeus (1.4.0)
100
+ ethon (>= 0.9.0)
101
+ tzinfo (2.0.4)
102
+ concurrent-ruby (~> 1.0)
103
+ xcodeproj (1.21.0)
104
+ CFPropertyList (>= 2.3.3, < 4.0)
105
+ atomos (~> 0.1.3)
106
+ claide (>= 1.0.2, < 2.0)
107
+ colored2 (~> 3.1)
108
+ nanaimo (~> 0.3.0)
109
+ rexml (~> 3.2.4)
110
+ zeitwerk (2.5.4)
10
111
 
11
112
  PLATFORMS
12
113
  ruby
@@ -17,4 +118,4 @@ DEPENDENCIES
17
118
  rake (~> 10.0)
18
119
 
19
120
  BUNDLED WITH
20
- 2.1.4
121
+ 2.2.20
data/README.md CHANGED
@@ -42,6 +42,14 @@ Finally the state clean submodule will be removed automatically.
42
42
  3. When you define "dev_env" to "release", and run ```pod install``` .
43
43
  We want to use the release version in cocoapods repo. And do many check for state, and help you to release the not released pod.
44
44
 
45
+ 新增功能: 支持读取宿主工程的Podfile.lock文件,来获取宿主工程中的依赖,无需在单独的库的example工程中引用对应的pod
46
+ 此功能默认开启, 等同于在顶部写入如下配置: use_parent_lock_info!
47
+ 关闭方法 use_parent_lock_info! false
48
+ 宿主工程路径默认为"../../../"(因为默认放到developing_pods子文件夹下,对应的库文件夹下的Example文件夹下,故需要回溯三层)
49
+ 配置宿主工程相对路径的方法 use_parent_lock_info! :path => '../'
50
+ 暂不支持配置绝对路径,未来也不建议配置绝对路径指向固定的位置
51
+
52
+
45
53
 
46
54
  ## Development
47
55
 
@@ -0,0 +1,21 @@
1
+ {
2
+ "folders": [
3
+ {
4
+ "path": "."
5
+ }
6
+ ],
7
+ "settings": {
8
+ "ruby.useBundler": true, //run non-lint commands with bundle exec
9
+ "ruby.useLanguageServer": true, // use the internal language server (see below)
10
+ "ruby.lint": {
11
+ "rubocop": {
12
+ "useBundler": false // enable rubocop via bundler
13
+ }
14
+ },
15
+ "ruby.format": "rubocop",
16
+ "ruby.codeCompletion": "rcodetools",
17
+ "ruby.intellisense": "rubyLocate",
18
+ "editor.formatOnPaste": true,
19
+ "editor.formatOnSave": true, // use rubocop for formatting
20
+ }
21
+ }
@@ -1,7 +1,7 @@
1
1
  module Cocoapods
2
2
  module Dev
3
3
  module Env
4
- VERSION = "2.0.2"
4
+ VERSION = '2.1.8'
5
5
  end
6
6
  end
7
7
  end
@@ -1,9 +1,10 @@
1
- require "file_processer"
2
- require "luna-binary-uploader"
1
+ # frozen_string_literal: true
2
+
3
+ require 'file_processer'
4
+ require 'luna-binary-uploader'
3
5
 
4
6
  Pod::HooksManager.register('cocoapods-dev-env', :pre_install) do |installer|
5
- podfile = installer.podfile
6
- #puts installer.instance_variables
7
+ # puts installer.instance_variables
7
8
  # forbidden submodule not cloned
8
9
  # 会引起submodule HEAD回滚,不靠谱,先注释掉
9
10
  # `
@@ -12,14 +13,78 @@ Pod::HooksManager.register('cocoapods-dev-env', :pre_install) do |installer|
12
13
  end
13
14
 
14
15
  Pod::HooksManager.register('cocoapods-dev-env', :post_install) do |installer|
15
- #puts installer.instance_variables
16
+ # puts installer.instance_variables
16
17
  end
17
18
 
18
19
 
19
20
  $processedPodsState = Hash.new
20
21
  $processedPodsOptions = Hash.new
21
22
 
23
+ $podFileContentPodNameHash = Hash.new
24
+
25
+ $parentPodlockDependencyHash = Hash.new
26
+
27
+ $processedParentPods = Hash.new # 从父项目里读出来的pod当次已经下载或者加载过了就不需要再做一遍
28
+
29
+ $parrentPath = '../../../'
30
+
31
+ module Pod
32
+ class Dependency
33
+ def setRequirement(requirement)
34
+ @requirement = requirement
35
+ end
36
+ end
37
+ end
38
+
39
+
22
40
  module Pod
41
+
42
+ class Resolver
43
+
44
+ def search_for(dependency)
45
+ UI.message "fake search_for" + dependency.inspect
46
+ if $podFileContentPodNameHash.has_key?(dependency.root_name)
47
+ # 双重保证已经存在在pofile里的不再重复下载覆盖成父项目的配置
48
+ UI.message "parrent extenal source has downloaded"
49
+ else
50
+ parentPodInfo = $parentPodlockDependencyHash[dependency.root_name]
51
+ if parentPodInfo != nil
52
+ dependency.external_source = parentPodInfo.external_source
53
+ dependency.setRequirement(parentPodInfo.requirement)
54
+ #dependency.external_source = Hash[:path => '../../ZYSDK']
55
+ # dependency.external_source = Hash.new
56
+ UI.message "fake create_set_from_sources, changeexternal:" + dependency.inspect
57
+ dep = dependency
58
+ if !$processedParentPods.has_key?(dependency.root_name) && dependency.external_source != nil
59
+ $processedParentPods[dependency.root_name] = true
60
+ # 这里有缺陷: 已经下载过的不需要再下载了,但是不下载又进不到系统里,导致最后没有使用指定的依赖
61
+ # 这个没用 podfile.pod(dependency.root_name, dependency.external_source)
62
+ # if sandbox.specification_path(dep.root_name).nil? ||
63
+ # !dep.external_source[:path].nil? ||
64
+ # !sandbox.pod_dir(dep.root_name).directory? ||
65
+ # checkout_requires_update?(dep)
66
+ # # 已经存在就不再下载
67
+ source = ExternalSources.from_dependency(dependency, podfile.defined_in_file, true)
68
+ source.fetch(sandbox)
69
+ # end
70
+ end
71
+ end
72
+ end
73
+
74
+ aggregate_for_dependency(dependency).search(dependency)
75
+
76
+ @search[dependency] ||= begin
77
+ additional_requirements = if locked_requirement = requirement_for_locked_pod_named(dependency.name)
78
+ [locked_requirement]
79
+ else
80
+ Array(@podfile_requirements_by_root_name[dependency.root_name])
81
+ end
82
+
83
+ specifications_for_dependency(dependency, additional_requirements).freeze
84
+ end
85
+ end
86
+ end
87
+
23
88
  class DevEnv
24
89
  def self.keyword
25
90
  :dev_env # 'dev'/'beta'/'release'
@@ -29,457 +94,524 @@ module Pod
29
94
  end
30
95
  UI.message "🎉 plugin cocoapods-dev-env loaded 🎉".green
31
96
  end
32
- class Podfile
33
- class TargetDefinition
34
- attr_reader :binary_repo_url
35
- attr_reader :binary_source
36
-
37
- def searchAndOpenLocalExample(path)
38
- _currentDir = Dir.pwd
39
- Dir.chdir(path)
40
- Dir.chdir("Example")
41
- `pod install`
42
- projPaths = Dir::glob("*.xcworkspace")
43
- if projPaths.count > 0
44
- `open -a Terminal ./`
45
- `open #{projPaths[0]}`
46
- end
47
- Dir.chdir(_currentDir)
48
- end
49
-
50
- def checkAndRemoveSubmodule(path)
51
- _currentDir = Dir.pwd
52
- Dir.chdir(path)
53
- output = `git status -s`
54
- puts output
55
- if output.length == 0
56
- output = `git status`
57
- if output.include?("push")
58
- raise "submodule #{path} 移除失败,有推送的修改"
97
+ class Podfile
98
+ module DSL
99
+ def use_parent_lock_info!(option = true)
100
+ case option
101
+ when true, false
102
+ if !option
103
+ $parrentPath = ''
104
+ TargetDefinition.cleanParrentLockFile()
105
+ end
106
+ when Hash
107
+ $parrentPath = option.fetch(:path)
108
+ TargetDefinition.readParrentLockFile()
109
+ else
110
+ raise ArgumentError, "Got `#{option.inspect}`, should be a boolean or hash."
59
111
  end
60
- else
61
- raise "submodule #{path} 移除失败,有未提交的修改"
62
112
  end
63
- Dir.chdir(_currentDir)
64
- `
65
- git submodule deinit #{path}
66
- rm -rf #{path}
67
- git rm #{path}
68
- `
69
113
  end
70
114
 
71
- def checkTagIsEqualToHead(tag, path)
72
- _currentDir = Dir.pwd
73
- Dir.chdir(path)
74
- result = `git describe --abbrev=4 HEAD`
75
- Dir.chdir(_currentDir)
76
- if result.include?(tag)
77
- return true
78
- else
79
- return checkTagOrBranchIsEqalToHead(tag, path)
80
- end
81
- end
115
+ class TargetDefinition
116
+ attr_reader :binary_repo_url
117
+ attr_reader :binary_source
82
118
 
83
- # 这个函数有问题有时候拿不到相同的commit id
84
- def checkTagOrBranchIsEqalToHead(branchOrTag, path)
85
- _currentDir = Dir.pwd
86
- Dir.chdir(path)
87
- headCommitID = `git rev-parse HEAD`
88
- tagCommitID = `git rev-parse #{branchOrTag}`
89
- UI.puts "#{`pwd`} headCommitID:#{headCommitID} \n #{branchOrTag}ComitID:#{tagCommitID}"
90
- Dir.chdir(_currentDir)
91
- return (headCommitID.length > 0 && headCommitID == tagCommitID)
92
- end
119
+ def searchAndOpenLocalExample(path)
120
+ _currentDir = Dir.pwd
121
+ Dir.chdir(path)
122
+ Dir.chdir("Example")
123
+ `pod install`
124
+ projPaths = Dir::glob("*.xcworkspace")
125
+ if projPaths.count > 0
126
+ `open -a Terminal ./`
127
+ `open #{projPaths[0]}`
128
+ end
129
+ Dir.chdir(_currentDir)
130
+ end
93
131
 
94
- def checkGitStatusAndPush(pod_name)
95
- output = `git status -s`
96
- puts output
97
- if output.length == 0
98
- output = `git status`
99
- if output.include?("push")
100
- ret = system("git push")
101
- if ret != true
102
- raise "💔 #{pod_name.yellow} push 失败"
132
+ def checkAndRemoveSubmodule(path)
133
+ _currentDir = Dir.pwd
134
+ Dir.chdir(path)
135
+ output = `git status -s`
136
+ puts output
137
+ if output.length == 0
138
+ output = `git status`
139
+ if output.include?("push")
140
+ raise "submodule #{path} 移除失败,有推送的修改"
103
141
  end
142
+ else
143
+ raise "submodule #{path} 移除失败,有未提交的修改"
104
144
  end
105
- else
106
- raise "💔 #{pod_name.yellow} 有未提交的数据"
145
+ Dir.chdir(_currentDir)
146
+ `
147
+ git submodule deinit #{path}
148
+ rm -rf #{path}
149
+ git rm #{path}
150
+ `
107
151
  end
108
- end
109
-
110
- def checkRemoteTagExist(tag)
111
- `git push --tags`
112
- ret = system("git ls-remote --exit-code origin refs/tags/#{tag}")
113
- return ret
114
- end
115
152
 
116
- def addGitTagAndPush(tag, pod_name)
117
- ret = system("git tag #{tag}")
118
- if ret == true
119
- ret = system("git push origin #{tag}")
120
- if ret != true
121
- raise "💔 #{pod_name.yellow} push tag 失败"
153
+ def checkTagIsEqualToHead(tag, path)
154
+ _currentDir = Dir.pwd
155
+ Dir.chdir(path)
156
+ result = `git describe --abbrev=4 HEAD`
157
+ Dir.chdir(_currentDir)
158
+ if result.include?(tag)
159
+ return true
160
+ else
161
+ return checkTagOrBranchIsEqalToHead(tag, path)
122
162
  end
123
163
  end
124
- return ret
125
- end
126
164
 
127
- def inputNeedJumpForReson(str)
128
- if ARGV.include? '--silent'
129
- return false
165
+ # 这个函数有问题有时候拿不到相同的commit id
166
+ def checkTagOrBranchIsEqalToHead(branchOrTag, path)
167
+ _currentDir = Dir.pwd
168
+ Dir.chdir(path)
169
+ headCommitID = `git rev-parse HEAD`
170
+ tagCommitID = `git rev-parse #{branchOrTag}`
171
+ UI.puts "#{`pwd`} headCommitID:#{headCommitID} \n #{branchOrTag}ComitID:#{tagCommitID}"
172
+ Dir.chdir(_currentDir)
173
+ return (headCommitID.length > 0 && headCommitID == tagCommitID)
130
174
  end
131
175
 
132
- puts str.green
133
- puts '是(Y), 任意其他输入或直接回车跳过'.green
134
- input = STDIN.gets
135
- if input[0,1] == "Y"
136
- return true
137
- else
138
- return false
176
+ def checkGitStatusAndPush(pod_name)
177
+ output = `git status -s`
178
+ puts output
179
+ if output.length == 0
180
+ output = `git status`
181
+ if output.include?("push")
182
+ ret = system("git push")
183
+ if ret != true
184
+ raise "💔 #{pod_name.yellow} push 失败"
185
+ end
186
+ end
187
+ else
188
+ raise "💔 #{pod_name.yellow} 有未提交的数据"
189
+ end
139
190
  end
140
- end
141
191
 
142
- def getReposStrForLint()
143
- if podfile.sources.size == 0
144
- return ""
145
- end
146
- str = " --sources="
147
- podfile.sources.each do |source|
148
- str += source
149
- str += ","
192
+ def checkRemoteTagExist(tag)
193
+ `git push --tags`
194
+ ret = system("git ls-remote --exit-code origin refs/tags/#{tag}")
195
+ return ret
150
196
  end
151
- UI.puts str
152
- return str
153
- end
154
197
 
155
- def getUserRepoAddress()
156
- if podfile.sources.size == 0
157
- raise "💔 发布release必须配置仓库的地址, e.g.: source 'https://github.com/CocoaPods/Specs.git'"
158
- end
159
- index = nil
160
- begin
161
- UI.puts "\n\n⌨️ 请输入要发布到的cocoapods仓库序号, 按回车确认: ".yellow
162
- num = 1
163
- podfile.sources.each do |source|
164
- UI.puts "#{num.to_s.yellow}. #{source.green}"
165
- num += 1
198
+ def addGitTagAndPush(tag, pod_name)
199
+ ret = system("git tag #{tag}")
200
+ if ret == true
201
+ ret = system("git push origin #{tag}")
202
+ if ret != true
203
+ raise "💔 #{pod_name.yellow} push tag 失败"
204
+ end
166
205
  end
167
- index = STDIN.gets.to_i - 1
168
- end until (index >= 0 && index < podfile.sources.size)
169
- source = podfile.sources[index]
170
- UI.puts "#{"选择了发布到: ".yellow}. #{source.green}(#{index + 1})"
171
- return source
172
- end
173
-
174
- def changeVersionInCocoapods(name, newVersion)
175
- if (newVersion == nil)
176
- UI.puts "💔 切换版本号的版本现在为空,无法设置版本号".yellow
177
- return
206
+ return ret
178
207
  end
179
- newVersion = get_pure_version(newVersion)
180
- specName = name + ".podspec"
181
- FileProcesserManager.new(specName,
182
- [
183
- FileProcesser.new(-> (fileContent) {
184
- return fileContent.gsub(/(\.version *= *')(.*')/, "\\1" + newVersion + "'")
185
- })
186
- ]).process()
187
- `git add #{specName}
188
- git commit -m "Mod: 修改版本号为:#{newVersion} by cocoapods_dev_env plugin"`
189
- end
190
208
 
191
- ## --- option for setting using prebuild framework ---
192
-
193
- def parse_pod_dev_env(name, requirements)
194
- options = requirements.last
195
- pod_name = Specification.root_name(name)
196
- last_options = $processedPodsOptions[pod_name]
197
-
198
- if (last_options != nil)
199
- UI.message "#{name.green} use last_options: #{last_options.to_s.green}"
200
- if options != nil && options.is_a?(Hash)
201
- requirements[requirements.length - 1] = last_options
202
- else
203
- requirements.push(last_options)
204
- end
205
- elsif options.is_a?(Hash)
206
- use_binary = options.delete(Pod::DevEnv::binary_key)
207
- dev_env = options.delete(Pod::DevEnv::keyword)
208
-
209
- deal_dev_env_with_options(dev_env, options, pod_name, name, requirements)
210
- if dev_env != 'dev'
211
- binary_processer(dev_env, pod_name, use_binary, options, requirements)
209
+ def inputNeedJumpForReson(str)
210
+ if ARGV.include? '--silent'
211
+ return false
212
212
  end
213
213
 
214
-
215
- if dev_env || use_binary
216
- $processedPodsOptions[pod_name] = options.clone
217
- requirements.pop if options.empty?
214
+ puts str.green
215
+ puts '是(Y), 任意其他输入或直接回车跳过'.green
216
+ input = STDIN.gets
217
+ if input[0,1] == "Y"
218
+ return true
219
+ else
220
+ return false
218
221
  end
219
- end
220
- end
221
-
222
- def deal_dev_env_with_options(dev_env, options, pod_name, name, requirements)
223
- if dev_env == nil
224
- return
225
222
  end
226
- UI.message "pod #{name.green} dev-env: #{dev_env.green}"
227
- git = options.delete(:git)
228
- branch = options.delete(:branch)
229
- tag = options.delete(:tag)
230
- path = options.delete(:path)
231
- if path == nil
232
- path = "./developing_pods/#{pod_name}"
233
- end
234
- if git == nil || git.length == 0
235
- raise "💔 #{pod_name.yellow} 未定义:git => 'xxx'库地址"
223
+
224
+ def getReposStrForLint()
225
+ if podfile.sources.size == 0
226
+ return ""
227
+ end
228
+ str = " --sources="
229
+ podfile.sources.each do |source|
230
+ str += source
231
+ str += ","
232
+ end
233
+ UI.puts str
234
+ return str
236
235
  end
237
- if branch == nil || branch.length == 0
238
- raise "💔 #{pod_name.yellow} 未定义:branch => 'xxx'"
236
+
237
+ def getUserRepoAddress()
238
+ if podfile.sources.size == 0
239
+ raise "💔 发布release必须配置仓库的地址, e.g.: source 'https://github.com/CocoaPods/Specs.git'"
240
+ end
241
+ index = nil
242
+ begin
243
+ UI.puts "\n\n⌨️ 请输入要发布到的cocoapods仓库序号, 按回车确认: ".yellow
244
+ num = 1
245
+ podfile.sources.each do |source|
246
+ UI.puts "#{num.to_s.yellow}. #{source.green}"
247
+ num += 1
248
+ end
249
+ index = STDIN.gets.to_i - 1
250
+ end until (index >= 0 && index < podfile.sources.size)
251
+ source = podfile.sources[index]
252
+ UI.puts "#{"选择了发布到: ".yellow}. #{source.green}(#{index + 1})"
253
+ return source
239
254
  end
240
- if tag == nil || tag.length == 0
241
- raise "💔 #{pod_name.yellow} 未定义:tag => 'xxx', tag 将会作为 dev模式下载最新代码检查的依据,beta模式引用的tag 以及 release模式引用的版本号"
255
+
256
+ def changeVersionInCocoapods(name, newVersion)
257
+ if (newVersion == nil)
258
+ UI.puts "💔 切换版本号的版本现在为空,无法设置版本号".yellow
259
+ return
260
+ end
261
+ newVersion = get_pure_version(newVersion)
262
+ specName = name + ".podspec"
263
+ FileProcesserManager.new(specName,
264
+ [
265
+ FileProcesser.new(-> (fileContent) {
266
+ return fileContent.gsub(/(\.version *= *')(.*')/, "\\1" + newVersion + "'")
267
+ })
268
+ ]).process()
269
+ `git add #{specName}
270
+ git commit -m "Mod: 修改版本号为:#{newVersion} by cocoapods_dev_env plugin"`
242
271
  end
243
272
 
244
- if dev_env == 'subtree'
245
- if !File.directory?(path)
246
- _toplevelDir = `git rev-parse --show-toplevel`
247
- _currentDir = `pwd`
248
- _subtreeDir = path
249
- if _currentDir != _toplevelDir
250
- Dir.chdir(_toplevelDir)
251
- _end = path
252
- if _end[0,2] == './'
253
- _end = _end[1, _end.length - 1]
254
- else
255
- _end = '/' + _end
256
- end
257
- _subtreeDir = './' + _currentDir[_toplevelDir.length, _currentDir.length - _toplevelDir.length] + path
273
+ ## --- hook的入口函数 ---
274
+ def parse_pod_dev_env(name, requirements)
275
+ options = requirements.last
276
+ pod_name = Specification.root_name(name)
277
+ last_options = $processedPodsOptions[pod_name]
278
+ $podFileContentPodNameHash[pod_name] = true
279
+
280
+ if (last_options != nil)
281
+ UI.message "#{name.green} use last_options: #{last_options.to_s.green}"
282
+ if options != nil && options.is_a?(Hash)
283
+ requirements[requirements.length - 1] = last_options
284
+ else
285
+ requirements.push(last_options)
286
+ end
287
+ elsif options.is_a?(Hash)
288
+ use_binary = options.delete(Pod::DevEnv::binary_key)
289
+ dev_env = options.delete(Pod::DevEnv::keyword)
290
+
291
+ # 主功能,根据dev_env标记来管理使用代码的方式
292
+ deal_dev_env_with_options(dev_env, options, pod_name, name, requirements)
293
+
294
+ # 处理二进制
295
+ if dev_env != 'dev'
296
+ binary_processer(dev_env, pod_name, use_binary, options, requirements)
258
297
  end
259
- _cmd = "git subtree add --prefix #{_subtreeDir} #{git} #{branch} --squash"
260
- UI.puts _cmd
261
- system(_cmd)
262
- Dir.chdir(_currentDir)
298
+
299
+
300
+ if dev_env || use_binary
301
+ $processedPodsOptions[pod_name] = options.clone
302
+ requirements.pop if options.empty?
303
+ end
304
+ end
305
+ end
306
+
307
+ ## --- 主功能函数 ---
308
+ def deal_dev_env_with_options(dev_env, options, pod_name, name, requirements)
309
+ if dev_env == nil
310
+ return
263
311
  end
264
- options[:path] = path
265
- if requirements.length >= 2
266
- requirements.delete_at(0)
312
+ UI.message "pod #{name.green} dev-env: #{dev_env.green}"
313
+ git = options.delete(:git)
314
+ branch = options.delete(:branch)
315
+ tag = options.delete(:tag)
316
+ path = options.delete(:path)
317
+ if path == nil
318
+ path = "./developing_pods/#{pod_name}"
267
319
  end
268
- UI.message "pod #{pod_name.green} enabled #{"subtree".green}-mode 🍺"
269
- elsif dev_env == 'dev'
270
- # 开发模式,使用path方式引用本地的submodule git库
271
- if !File.directory?(path)
272
- UI.puts "add submodule for #{pod_name.green}".yellow
273
- _cmd = "git submodule add --force -b #{branch} #{git} #{path}"
274
- UI.puts _cmd
275
- system(_cmd)
276
-
277
- _currentDir = Dir.pwd
278
- Dir.chdir(path)
279
-
280
- curGitRemoteUrl = `git remote get-url origin`.rstrip()
281
- if curGitRemoteUrl == git
282
- _cmd = "git reset --hard"
320
+ if git == nil || git.length == 0
321
+ raise "💔 #{pod_name.yellow} 未定义:git => 'xxx'库地址"
322
+ end
323
+ if branch == nil || branch.length == 0
324
+ raise "💔 #{pod_name.yellow} 未定义:branch => 'xxx'"
325
+ end
326
+ if tag == nil || tag.length == 0
327
+ raise "💔 #{pod_name.yellow} 未定义:tag => 'xxx', tag 将会作为 dev模式下载最新代码检查的依据,beta模式引用的tag 以及 release模式引用的版本号"
328
+ end
329
+
330
+ if dev_env == 'subtree'
331
+ if !File.directory?(path)
332
+ _toplevelDir = `git rev-parse --show-toplevel`
333
+ _currentDir = `pwd`
334
+ _subtreeDir = path
335
+ if _currentDir != _toplevelDir
336
+ Dir.chdir(_toplevelDir)
337
+ _end = path
338
+ if _end[0,2] == './'
339
+ _end = _end[1, _end.length - 1]
340
+ else
341
+ _end = '/' + _end
342
+ end
343
+ _subtreeDir = './' + _currentDir[_toplevelDir.length, _currentDir.length - _toplevelDir.length] + path
344
+ end
345
+ _cmd = "git subtree add --prefix #{_subtreeDir} #{git} #{branch} --squash"
283
346
  UI.puts _cmd
284
347
  system(_cmd)
348
+ Dir.chdir(_currentDir)
285
349
  end
286
- Dir.chdir(_currentDir)
287
-
288
- # if inputNeedJumpForReson("本地库#{pod_name} 开发模式加载完成,是否自动打开Example工程")
289
- # searchAndOpenLocalExample(path)
290
- # end
291
- if !checkTagIsEqualToHead(tag, path) && !checkTagIsEqualToHead("#{tag}_beta", path)
292
- raise "💔 #{pod_name.yellow} branch:#{branch.yellow} 与 tag:#{tag.yellow}[_beta] 内容不同步,请自行确认所用分支和tag后重新执行 pod install"
350
+ options[:path] = path
351
+ if requirements.length >= 2
352
+ requirements.delete_at(0)
293
353
  end
294
- else
295
- # if inputNeedJumpForReson("本地库#{pod_name} 处于开发模式,是否自动打开Example工程")
296
- # searchAndOpenLocalExample(path)
297
- # end
298
- end
299
- options[:path] = path
300
- if requirements.length >= 2
301
- requirements.delete_at(0)
302
- end
303
- UI.message "pod #{pod_name.green} enabled #{"dev".green}-mode 🍺"
304
- elsif dev_env == 'beta'
305
- # Beta模式,使用tag引用远端git库的代码
306
- originTag = tag
307
- tag = "#{tag}_beta"
308
- if File.directory?(path)
309
- # 从Dev模式刚刚切换过来,需要打tag并且push
310
- UI.puts "release beta-version for #{pod_name.green}".yellow
311
- _currentDir = Dir.pwd
312
- Dir.chdir(path)
313
- # 已经进入到podspec的文件夹中了
314
- checkGitStatusAndPush(pod_name) # push一下
315
- ret = checkRemoteTagExist(tag)
316
- if ret == true
317
- # tag已经存在,要么没改动,要么已经手动打过tag,要么是需要引用老版本tag的代码
318
- if checkTagOrBranchIsEqalToHead(tag, "./")
319
- UI.puts "#{pod_name.green} 检测到未做任何调整,或已手动打过Tag"
320
- else
321
- if !inputNeedJumpForReson("是否跳过beta发布并删除本地submodule(直接引用远端库)")
322
- raise "💔 #{pod_name.yellow} tag:#{tag.yellow} 已存在, 且与当前Commit不对应. 请确认拉到本地之后已经在podfile中手动修改tag版本号"
323
- end
354
+ UI.message "pod #{pod_name.green} enabled #{"subtree".green}-mode 🍺"
355
+ elsif dev_env == 'dev'
356
+ # 开发模式,使用path方式引用本地的submodule git库
357
+ if !File.directory?(path)
358
+ UI.puts "add submodule for #{pod_name.green}".yellow
359
+ _cmd = "git submodule add --force -b #{branch} #{git} #{path}"
360
+ UI.puts _cmd
361
+ system(_cmd)
362
+
363
+ _currentDir = Dir.pwd
364
+ Dir.chdir(path)
365
+
366
+ curGitRemoteUrl = `git remote get-url origin`.rstrip()
367
+ if curGitRemoteUrl == git
368
+ _cmd = "git reset --hard"
369
+ UI.puts _cmd
370
+ system(_cmd)
371
+ _cmd = "git pull"
372
+ UI.puts _cmd
373
+ system(_cmd)
374
+ end
375
+ Dir.chdir(_currentDir)
376
+
377
+ # if inputNeedJumpForReson("本地库#{pod_name} 开发模式加载完成,是否自动打开Example工程")
378
+ # searchAndOpenLocalExample(path)
379
+ # end
380
+ if !checkTagIsEqualToHead(tag, path) && !checkTagIsEqualToHead("#{tag}_beta", path)
381
+ raise "💔 #{pod_name.yellow} branch:#{branch.yellow} 与 tag:#{tag.yellow}[_beta] 内容不同步,请自行确认所用分支和tag后重新执行 pod install"
324
382
  end
325
383
  else
326
- # tag不存在,
327
- changeVersionInCocoapods(pod_name, originTag)
328
- checkGitStatusAndPush(pod_name) # 再push一下
329
- addGitTagAndPush(tag, pod_name)
330
- end
331
- Dir.chdir(_currentDir)
332
- checkAndRemoveSubmodule(path)
333
- end
334
- options[:git] = git
335
- options[:tag] = tag
336
- if requirements.length >= 2
337
- requirements.delete_at(0)
338
- end
339
- UI.message "enabled #{"beta".green}-mode for #{pod_name.green}"
340
- elsif dev_env == 'release'
341
- # Release模式,直接使用远端对应的版本
342
- if File.directory?(path)
343
- UI.puts "release release-version for #{pod_name.green}".yellow
344
- _currentDir = Dir.pwd
345
- Dir.chdir(path)
346
- verboseParamStr = ""
347
- if Config.instance.verbose
348
- verboseParamStr = " --verbose"
384
+ # if inputNeedJumpForReson("本地库#{pod_name} 处于开发模式,是否自动打开Example工程")
385
+ # searchAndOpenLocalExample(path)
386
+ # end
349
387
  end
350
- ret = system("pod lib lint --skip-import-validation --fail-fast --allow-warnings#{getReposStrForLint()}#{verboseParamStr}")
351
- if ret != true
352
- raise "💔 #{pod_name.yellow} lint 失败"
388
+ options[:path] = path
389
+ if requirements.length >= 2
390
+ requirements.delete_at(0)
353
391
  end
354
- checkGitStatusAndPush(pod_name)
355
- changeVersionInCocoapods(pod_name, tag)
356
- checkGitStatusAndPush(pod_name)
357
- ret = addGitTagAndPush(tag, pod_name)
358
- if ret == false
359
- if checkTagOrBranchIsEqalToHead(tag, "./")
360
- UI.puts "#{pod_name.green} 已经打过tag".yellow
392
+ UI.message "pod #{pod_name.green} enabled #{"dev".green}-mode 🍺"
393
+ elsif dev_env == 'beta'
394
+ # Beta模式,使用tag引用远端git库的代码
395
+ originTag = tag
396
+ tag = "#{tag}_beta"
397
+ if File.directory?(path)
398
+ # 从Dev模式刚刚切换过来,需要打tag并且push
399
+ UI.puts "try to release beta-version for #{pod_name.green}".yellow
400
+ _currentDir = Dir.pwd
401
+ Dir.chdir(path)
402
+ # 已经进入到podspec的文件夹中了
403
+ checkGitStatusAndPush(pod_name) # push一下
404
+ ret = checkRemoteTagExist(tag)
405
+ if ret == true
406
+ # tag已经存在,要么没改动,要么已经手动打过tag,要么是需要引用老版本tag的代码
407
+ if checkTagOrBranchIsEqalToHead(tag, "./")
408
+ UI.puts "#{pod_name.green} 检测到未做任何调整,或已手动打过Tag,直接引用远端库"
409
+ else
410
+ if !inputNeedJumpForReson("#{pod_name.green} 检测到已经存在#{tag.yellow}的tag,且与当前本地节点不同,是否跳过beta发布并删除本地submodule(直接引用远端库)")
411
+ raise "💔 #{pod_name.yellow} tag:#{tag.yellow} 已存在, 且与当前Commit不对应. 请确认拉到本地之后已经在podfile中手动修改tag版本号"
412
+ end
413
+ end
361
414
  else
362
- raise "💔 #{pod_name.yellow} tag:#{tag.yellow} 已存在, 请确认已经手动修改tag版本号"
415
+ # tag不存在,
416
+ changeVersionInCocoapods(pod_name, originTag)
417
+ checkGitStatusAndPush(pod_name) # 再push一下
418
+ addGitTagAndPush(tag, pod_name)
363
419
  end
420
+ Dir.chdir(_currentDir)
421
+ checkAndRemoveSubmodule(path)
364
422
  end
365
- ## TODO:: 发布到的目标库名称需要用变量设置
366
- repoAddrs = getUserRepoAddress()
367
- cmd = "pod repo push #{repoAddrs} #{pod_name}.podspec --skip-import-validation --allow-warnings --use-modular-headers#{getReposStrForLint()}#{verboseParamStr}"
368
- UI.puts cmd.green
369
- ret = system(cmd)
370
- if ret != true
371
- raise "💔 #{pod_name.yellow} 发布失败"
423
+ options[:git] = git
424
+ options[:tag] = tag
425
+ if requirements.length >= 2
426
+ requirements.delete_at(0)
372
427
  end
373
- ## 到最后统一执行,判断如果当次release过
374
- `pod repo update`
375
- Dir.chdir(_currentDir)
376
- checkAndRemoveSubmodule(path)
377
- end
378
- if requirements.length < 2
379
- requirements.insert(0, "#{get_pure_version(tag)}")
428
+ UI.message "enabled #{"beta".green}-mode for #{pod_name.green}"
429
+ elsif dev_env == 'release'
430
+ # Release模式,直接使用远端对应的版本
431
+ if File.directory?(path)
432
+ UI.puts "release release-version for #{pod_name.green}".yellow
433
+ _currentDir = Dir.pwd
434
+ Dir.chdir(path)
435
+ verboseParamStr = ""
436
+ if Config.instance.verbose
437
+ verboseParamStr = " --verbose"
438
+ end
439
+ ret = system("pod lib lint --skip-import-validation --fail-fast --allow-warnings#{getReposStrForLint()}#{verboseParamStr}")
440
+ if ret != true
441
+ raise "💔 #{pod_name.yellow} lint 失败"
442
+ end
443
+ checkGitStatusAndPush(pod_name)
444
+ changeVersionInCocoapods(pod_name, tag)
445
+ checkGitStatusAndPush(pod_name)
446
+ ret = addGitTagAndPush(tag, pod_name)
447
+ if ret == false
448
+ if checkTagOrBranchIsEqalToHead(tag, "./")
449
+ UI.puts "#{pod_name.green} 已经打过tag".yellow
450
+ else
451
+ raise "💔 #{pod_name.yellow} tag:#{tag.yellow} 已存在, 请确认已经手动修改tag版本号"
452
+ end
453
+ end
454
+ ## TODO:: 发布到的目标库名称需要用变量设置
455
+ repoAddrs = getUserRepoAddress()
456
+ cmd = "pod repo push #{repoAddrs} #{pod_name}.podspec --skip-import-validation --allow-warnings --use-modular-headers#{getReposStrForLint()}#{verboseParamStr}"
457
+ UI.puts cmd.green
458
+ ret = system(cmd)
459
+ if ret != true
460
+ raise "💔 #{pod_name.yellow} 发布失败"
461
+ end
462
+ ## 到最后统一执行,判断如果当次release过
463
+ `pod repo update`
464
+ Dir.chdir(_currentDir)
465
+ checkAndRemoveSubmodule(path)
466
+ end
467
+ if requirements.length < 2
468
+ requirements.insert(0, "#{get_pure_version(tag)}")
469
+ end
470
+ UI.message "enabled #{"release".green}-mode for #{pod_name.green}"
471
+ else
472
+ raise "💔 :dev_env 必须要设置成 dev/beta/release之一,不接受其他值"
380
473
  end
381
- UI.message "enabled #{"release".green}-mode for #{pod_name.green}"
382
- else
383
- raise "💔 :dev_env 必须要设置成 dev/beta/release之一,不接受其他值"
384
474
  end
385
- end
386
-
387
- def binary_processer(dev_env, pod_name, use_binary, options, requirements)
388
- if use_binary && use_binary == true
389
- if options[:tag] != nil
390
- begin
391
- version = get_pure_version(options[:tag])
392
- spec = binary_source.specification_path(pod_name, Version.new(version))
393
- if spec
394
- if requirements.length < 2
395
- options.delete(:git)
396
- options.delete(:path)
397
- options.delete(:tag)
398
- options[:source] = binary_repo_url
399
- requirements.insert(0, "#{version}")
475
+
476
+ def binary_processer(dev_env, pod_name, use_binary, options, requirements)
477
+ if use_binary && use_binary == true
478
+ if options[:tag] != nil
479
+ begin
480
+ version = get_pure_version(options[:tag])
481
+ spec = binary_source.specification_path(pod_name, Version.new(version))
482
+ if spec
483
+ if requirements.length < 2
484
+ options.delete(:git)
485
+ options.delete(:path)
486
+ options.delete(:tag)
487
+ options[:source] = binary_repo_url
488
+ requirements.insert(0, "#{version}")
489
+ else
490
+ UI.puts "pod '#{pod_name}' :tag => #{options[:tag]} version: #{version} 对应的版本,但是已经标记版本号#{requirements}, 不知道用哪个".red
491
+ end
400
492
  else
401
- UI.puts "pod '#{pod_name}' :tag => #{options[:tag]} version: #{version} 对应的版本,但是已经标记版本号#{requirements}, 不知道用哪个".red
493
+ UI.puts "pod '#{pod_name}' :tag => #{options[:tag]} version: #{version} 没有找到: tag 对应的版本".red
402
494
  end
403
- else
495
+ rescue => exception
404
496
  UI.puts "pod '#{pod_name}' :tag => #{options[:tag]} version: #{version} 没有找到: tag 对应的版本".red
497
+ else
498
+
405
499
  end
406
- rescue => exception
407
- UI.puts "pod '#{pod_name}' :tag => #{options[:tag]} version: #{version} 没有找到: tag 对应的版本".red
408
500
  else
409
-
501
+ options.delete(:git)
502
+ options.delete(:path)
503
+ options.delete(:tag)
504
+ options[:source] = binary_repo_url
410
505
  end
506
+
411
507
  else
412
- options.delete(:git)
413
- options.delete(:path)
414
- options.delete(:tag)
415
- options[:source] = binary_repo_url
416
- end
417
-
418
- else
419
- if options[:source] == nil
420
- begin
421
- sources = find_pod_repos(pod_name).sources.select{|item| item.url.downcase != binary_repo_url.downcase } if options.empty?
422
- if sources != nil
423
- if sources.length >= 2
424
- UI.puts "#{pod_name.green} 有多个source #{sources}".yellow
425
- source_url = sources.detect{|item| item.url.downcase != Pod::TrunkSource::TRUNK_REPO_URL.downcase && item.url.downcase != "https://github.com/CocoaPods/Specs.git".downcase}.url
426
- else
427
- source_url = sources.first.url
508
+ if options[:source] == nil
509
+ begin
510
+ sources = find_pod_repos(pod_name).sources.select{|item| item.url.downcase != binary_repo_url.downcase } if options.empty?
511
+ if sources != nil
512
+ if sources.length >= 2
513
+ UI.puts "#{pod_name.green} 有多个source #{sources}".yellow
514
+ source_url = sources.detect{|item| item.url.downcase != Pod::TrunkSource::TRUNK_REPO_URL.downcase && item.url.downcase != "https://github.com/CocoaPods/Specs.git".downcase}.url
515
+ else
516
+ source_url = sources.first.url
517
+ end
428
518
  end
519
+ options[:source] = source_url if source_url != nil
520
+ rescue => exception
521
+ UI.puts "#{pod_name} exception:#{exception}".red
522
+ else
523
+
429
524
  end
430
- options[:source] = source_url if source_url != nil
431
- rescue => exception
432
- UI.puts "#{pod_name} exception:#{exception}".red
433
- else
434
-
435
525
  end
436
526
  end
527
+ UI.puts "#{pod_name.green} :source=> #{options[:source].green} by cocoapods-dev-env" if options[:source] != nil
528
+ UI.message "#{pod_name.yellow} options #{options} by cocoapods-dev-env" if options[:source] != nil
529
+ UI.message "#{pod_name.yellow} requirements #{requirements} by cocoapods-dev-env" if options[:source] != nil
437
530
  end
438
- UI.puts "#{pod_name.green} :source=> #{options[:source].green} by cocoapods-dev-env" if options[:source] != nil
439
- UI.message "#{pod_name.yellow} options #{options} by cocoapods-dev-env" if options[:source] != nil
440
- UI.message "#{pod_name.yellow} requirements #{requirements} by cocoapods-dev-env" if options[:source] != nil
441
- end
442
531
 
443
- def binary_repo_url
444
- if @binary_repo_url == nil
445
- @binary_repo_url = Luna::Binary::Common.instance.binary_repo_url #从luna-binary-uploader里获取binary_repo_url
532
+ def binary_repo_url
533
+ if @binary_repo_url == nil
534
+ @binary_repo_url = Luna::Binary::Common.instance.binary_repo_url #从luna-binary-uploader里获取binary_repo_url
535
+ end
536
+ return @binary_repo_url
446
537
  end
447
- return @binary_repo_url
448
- end
449
538
 
450
- def binary_source
451
- if @binary_source == nil
452
- @binary_source = Pod::Config.instance.sources_manager.all.detect{|item| item.url.downcase == binary_repo_url.downcase}
539
+ def binary_source
540
+ if @binary_source == nil
541
+ @binary_source = Pod::Config.instance.sources_manager.all.detect{|item| item.url.downcase == binary_repo_url.downcase}
542
+ end
543
+ return @binary_source
453
544
  end
454
- return @binary_source
455
- end
456
545
 
457
- def get_pure_version(version)
458
- return version.split.last.scan(/\d+/).join('.')
459
- end
546
+ def get_pure_version(version)
547
+ return version.split.last.scan(/\d+/).join('.')
548
+ end
460
549
 
461
- def find_pod_repos(pod_name) #等同pod search
462
- sets = Pod::Config.instance.sources_manager.search_by_name(pod_name)
463
- if sets.count == 1
464
- set = sets.first
465
- elsif sets.map(&:name).include?(pod_name)
466
- set = sets.find { |s| s.name == pod_name }
467
- else
468
- names = sets.map(&:name) * ', '
469
- raise Informative, "More than one spec found for '#{pod_name}':\n#{names}"
470
- end
471
- return set
472
- end
550
+ def find_pod_repos(pod_name) #等同pod search
551
+ sets = Pod::Config.instance.sources_manager.search_by_name(pod_name)
552
+ if sets.count == 1
553
+ set = sets.first
554
+ elsif sets.map(&:name).include?(pod_name)
555
+ set = sets.find { |s| s.name == pod_name }
556
+ else
557
+ names = sets.map(&:name) * ', '
558
+ raise Informative, "More than one spec found for '#{pod_name}':\n#{names}"
559
+ end
560
+ return set
561
+ end
562
+
563
+ # ---- patch method ----
564
+ # We want modify `store_pod` method, but it's hard to insert a line in the
565
+ # implementation. So we patch a method called in `store_pod`.
566
+ old_method = instance_method(:parse_inhibit_warnings)
473
567
 
474
- # ---- patch method ----
475
- # We want modify `store_pod` method, but it's hard to insert a line in the
476
- # implementation. So we patch a method called in `store_pod`.
477
- old_method = instance_method(:parse_inhibit_warnings)
568
+ define_method(:parse_inhibit_warnings) do |name, requirements|
569
+ parse_pod_dev_env(name, requirements)
570
+ old_method.bind(self).(name, requirements)
571
+ end
572
+
573
+ def self.cleanParrentLockFile()
574
+ $parentPodlockDependencyHash = Hash.new
575
+ end
478
576
 
479
- define_method(:parse_inhibit_warnings) do |name, requirements|
480
- parse_pod_dev_env(name, requirements)
481
- old_method.bind(self).(name, requirements)
577
+ # 类方法
578
+ def self.readParrentLockFile()
579
+ # 获取路径(之后外边直接配置)
580
+ localPath = Pathname.new(Dir.pwd + "/" + $parrentPath)
581
+ lockPath ||= localPath + "Podfile.lock"
582
+ # 读取lockfile
583
+ _lockfile = Pod::Lockfile.from_file(lockPath)
584
+ if _lockfile == nil
585
+ UI.message "dev_env, 读取父库的lockfile找不到对应路径的lock文件:" + lockPath.inspect
586
+ return
587
+ end
588
+ # 读取lockfile中的依赖信息,用于之后提取使用,其中数据为 Pod::Dependency类型
589
+ localPodsMaps = Hash.new()
590
+ localpods = _lockfile.dependencies
591
+ localpods.each do |dep|
592
+ # 数据为 Pod::Dependency类型
593
+ if (dep.external_source == nil && dep.requirement == nil) || localPodsMaps.has_key?(dep.root_name)
594
+ next
595
+ end
596
+ if dep.external_source == nil && dep.requirement.to_s == '>= 0'
597
+ # dependence里可能没有版本信息(很奇怪,从version里单独取一下,写死版本限制)
598
+ version = _lockfile.version(dep.root_name)
599
+ dep.setRequirement(Requirement.new(version))
600
+ end
601
+ if dep.local?
602
+ dep.external_source[:path] = $parrentPath + dep.external_source[:path]
603
+ end
604
+ # 测试代码 UI.puts "测试获取父项目podlock里的pod依赖列表: " + dep.inspect
605
+ localPodsMaps[dep.root_name] = dep
606
+ end
607
+ $parentPodlockDependencyHash = localPodsMaps
608
+ # 读取 示例: ydASRInfo = localPodsMaps['YDASR']
609
+ # UI.puts ydASRInfo.inspect
610
+ # UI.puts "YDASR path:\n" + ydASRInfo.external_source[:path]
611
+ end
612
+
613
+ readParrentLockFile()
482
614
  end
483
615
  end
484
616
  end
485
- end
617
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-dev-env
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
4
+ version: 2.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - 吴锡苗
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-10-27 00:00:00.000000000 Z
11
+ date: 2022-02-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: luna-binary-uploader
@@ -68,6 +68,7 @@ files:
68
68
  - Rakefile
69
69
  - bin/console
70
70
  - bin/setup
71
+ - cocoapods-dev-env.code-workspace
71
72
  - cocoapods-dev-env.gemspec
72
73
  - lib/cocoapods/dev/env.rb
73
74
  - lib/cocoapods/dev/env/version.rb
@@ -95,7 +96,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
95
96
  - !ruby/object:Gem::Version
96
97
  version: '0'
97
98
  requirements: []
98
- rubygems_version: 3.0.3
99
+ rubygems_version: 3.2.5
99
100
  signing_key:
100
101
  specification_version: 4
101
102
  summary: a cocoapod plugin for dev in mutipods