cocoapods-dev-env 2.1.9 → 2.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/cocoapods/dev/env/version.rb +2 -2
- data/lib/dev_env_entry.rb +36 -15
- data/lib/dev_env_utils.rb +146 -146
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 770d9cd062fae59894d853698e72d4b4e88f53e49a6dffc65304d1adb0df38eb
|
4
|
+
data.tar.gz: 3bfe86a60e7d68a08b7f0c54693105f95ee844f4e89d222fcf09d5e916aed625
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 245ade96b80c3aac4bcad5a472af479d9e2f6ddabef802e207baa4adc713c21b647740ec2873b1256d185220e6786041a6d3ddb9f7e2ea9d003616554b115fe0
|
7
|
+
data.tar.gz: 573365ba899db746a113472ac26a22e5cc8aedc1058b2d0ce8852575b528c61ffe84fee90926a23454b9329853290dbda04b859b57a610ba63cbb027d9b9bd88
|
data/README.md
CHANGED
@@ -42,7 +42,7 @@ 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
|
45
|
+
2.2.x 新增功能: 支持读取宿主工程的Podfile.lock文件,来获取宿主工程中的依赖,无需在单独的库的example工程中引用对应的pod
|
46
46
|
此功能默认开启, 等同于在顶部写入如下配置: use_parent_lock_info!
|
47
47
|
关闭方法 use_parent_lock_info! false
|
48
48
|
宿主工程路径默认为"../../../"(因为默认放到developing_pods子文件夹下,对应的库文件夹下的Example文件夹下,故需要回溯三层)
|
data/lib/dev_env_entry.rb
CHANGED
@@ -89,6 +89,7 @@ module Pod
|
|
89
89
|
|
90
90
|
defaultLocalPath = "./developing_pods/#{pod_name}"
|
91
91
|
UI.message "pod #{name.green} dev-env: #{dev_env.green}"
|
92
|
+
isFromSubProject = false
|
92
93
|
if dev_env == 'parent'
|
93
94
|
parentPodInfo = $parentPodlockDependencyHash[pod_name]
|
94
95
|
if parentPodInfo != nil
|
@@ -101,14 +102,15 @@ module Pod
|
|
101
102
|
if tag != nil
|
102
103
|
options[:tag] = tag
|
103
104
|
end
|
104
|
-
|
105
|
-
|
106
|
-
|
105
|
+
path = parentPodInfo.external_source[:path]
|
106
|
+
if path != nil
|
107
|
+
options[:path] = path
|
108
|
+
end
|
109
|
+
elsif (parentPodInfo.podspec_repo.start_with?("http") || parentPodInfo.podspec_repo.start_with?("git"))
|
110
|
+
#UI.puts 'XXXXXXXXXXXXXXXX123' + parentPodInfo.inspect
|
107
111
|
requirements.insert(0, parentPodInfo.requirement.to_s)
|
108
112
|
options[:source] = parentPodInfo.podspec_repo
|
109
113
|
end
|
110
|
-
|
111
|
-
# dependency.setRequirement(parentPodInfo.requirement
|
112
114
|
end
|
113
115
|
return
|
114
116
|
elsif options[:git] == nil
|
@@ -131,11 +133,12 @@ module Pod
|
|
131
133
|
options[:branch] = branch
|
132
134
|
options[:tag] = tag
|
133
135
|
if path != nil
|
134
|
-
options[:path] =
|
136
|
+
options[:path] = path
|
135
137
|
else
|
136
|
-
options[:path] =
|
138
|
+
options[:path] = defaultLocalPath
|
137
139
|
end
|
138
140
|
UI.puts "#{pod_name.green}采用了父组件的配置,并修改开发状态为#{dev_env.green}"
|
141
|
+
isFromSubProject = true
|
139
142
|
end
|
140
143
|
end
|
141
144
|
|
@@ -144,10 +147,15 @@ module Pod
|
|
144
147
|
git = options.delete(:git)
|
145
148
|
branch = options.delete(:branch)
|
146
149
|
tag = options.delete(:tag)
|
147
|
-
path = options.delete(:path)
|
150
|
+
path = options.delete(:path) # 执行命令用的path
|
148
151
|
if path == nil
|
149
152
|
path = defaultLocalPath
|
150
153
|
end
|
154
|
+
realpath = path
|
155
|
+
if isFromSubProject
|
156
|
+
realpath = $parrentPath + path
|
157
|
+
end
|
158
|
+
|
151
159
|
if git == nil || git.length == 0
|
152
160
|
raise "💔 #{pod_name.yellow} 未定义:git => 'xxx'库地址"
|
153
161
|
end
|
@@ -159,6 +167,9 @@ module Pod
|
|
159
167
|
end
|
160
168
|
|
161
169
|
if dev_env == 'subtree'
|
170
|
+
if isFromSubProject
|
171
|
+
raise "💔 子项目不支持subtree"
|
172
|
+
end
|
162
173
|
if !File.directory?(path)
|
163
174
|
_toplevelDir = `git rev-parse --show-toplevel`
|
164
175
|
_currentDir = `pwd`
|
@@ -178,19 +189,26 @@ module Pod
|
|
178
189
|
system(_cmd)
|
179
190
|
Dir.chdir(_currentDir)
|
180
191
|
end
|
181
|
-
options[:path] =
|
192
|
+
options[:path] = realpath
|
182
193
|
if requirements.length >= 2
|
183
194
|
requirements.delete_at(0)
|
184
195
|
end
|
185
196
|
UI.message "pod #{pod_name.green} enabled #{"subtree".green}-mode 🍺"
|
186
197
|
elsif dev_env == 'dev'
|
187
198
|
# 开发模式,使用path方式引用本地的submodule git库
|
188
|
-
if !File.directory?(
|
199
|
+
if !File.directory?(realpath)
|
189
200
|
UI.puts "add submodule for #{pod_name.green}".yellow
|
201
|
+
curProjectDir = `pwd`
|
202
|
+
if isFromSubProject
|
203
|
+
# 进入父目录,避免当前工程目录是个submodule,当在submudle中执行addsubmodule时路径会不正确
|
204
|
+
Dir.chdir($parrentPath)
|
205
|
+
end
|
190
206
|
_cmd = "git submodule add --force -b #{branch} #{git} #{path}"
|
191
207
|
UI.puts _cmd
|
192
208
|
system(_cmd)
|
193
|
-
|
209
|
+
if isFromSubProject
|
210
|
+
Dir.chdir(curProjectDir)
|
211
|
+
end
|
194
212
|
_currentDir = Dir.pwd
|
195
213
|
Dir.chdir(path)
|
196
214
|
|
@@ -216,7 +234,7 @@ module Pod
|
|
216
234
|
# DevEnvUtils.searchAndOpenLocalExample(path)
|
217
235
|
# end
|
218
236
|
end
|
219
|
-
options[:path] =
|
237
|
+
options[:path] = realpath
|
220
238
|
if requirements.length >= 2
|
221
239
|
requirements.delete_at(0)
|
222
240
|
end
|
@@ -232,8 +250,8 @@ module Pod
|
|
232
250
|
Dir.chdir(path)
|
233
251
|
# 已经进入到podspec的文件夹中了
|
234
252
|
DevEnvUtils.checkGitStatusAndPush(pod_name) # push一下
|
235
|
-
|
236
|
-
if
|
253
|
+
isRemoteTagExist = DevEnvUtils.checkRemoteTagExist(tag)
|
254
|
+
if isRemoteTagExist == true
|
237
255
|
# tag已经存在,要么没改动,要么已经手动打过tag,要么是需要引用老版本tag的代码
|
238
256
|
if DevEnvUtils.checkTagOrBranchIsEqalToHead(tag, "./")
|
239
257
|
UI.puts "#{pod_name.green} 检测到未做任何调整,或已手动打过Tag,直接引用远端库"
|
@@ -244,13 +262,16 @@ module Pod
|
|
244
262
|
end
|
245
263
|
else
|
246
264
|
# tag不存在,
|
265
|
+
DevEnvUtils.checkIsOnTrankBrach()
|
247
266
|
DevEnvUtils.changeVersionInCocoapods(pod_name, originTag)
|
248
267
|
DevEnvUtils.checkGitStatusAndPush(pod_name) # 再push一下
|
249
268
|
DevEnvUtils.addGitTagAndPush(tag, pod_name)
|
250
269
|
end
|
251
270
|
Dir.chdir(_currentDir)
|
252
271
|
DevEnvUtils.checkAndRemoveSubmodule(path)
|
253
|
-
|
272
|
+
if !isRemoteTagExist
|
273
|
+
UI.puts "🍺🍺 #{pod_name.green} #{tag.green} release successfully!!"
|
274
|
+
end
|
254
275
|
end
|
255
276
|
options[:git] = git
|
256
277
|
options[:tag] = tag
|
data/lib/dev_env_utils.rb
CHANGED
@@ -1,169 +1,169 @@
|
|
1
1
|
require 'cocoapods'
|
2
2
|
|
3
3
|
class DevEnvUtils
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
`open #{projPaths[0]}`
|
14
|
-
end
|
15
|
-
Dir.chdir(_currentDir)
|
4
|
+
def self.searchAndOpenLocalExample(path)
|
5
|
+
_currentDir = Dir.pwd
|
6
|
+
Dir.chdir(path)
|
7
|
+
Dir.chdir('Example')
|
8
|
+
`pod install`
|
9
|
+
projPaths = Dir.glob('*.xcworkspace')
|
10
|
+
if projPaths.count > 0
|
11
|
+
`open -a Terminal ./`
|
12
|
+
`open #{projPaths[0]}`
|
16
13
|
end
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
14
|
+
Dir.chdir(_currentDir)
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.checkAndRemoveSubmodule(path)
|
18
|
+
_currentDir = Dir.pwd
|
19
|
+
Dir.chdir(path)
|
20
|
+
output = `git status -s`
|
21
|
+
puts output
|
22
|
+
if output.length == 0
|
23
|
+
output = `git status`
|
24
|
+
raise "submodule #{path} 移除失败,有推送的修改" if output.include?('push')
|
25
|
+
else
|
26
|
+
raise "submodule #{path} 移除失败,有未提交的修改"
|
27
|
+
end
|
28
|
+
Dir.chdir(_currentDir)
|
29
|
+
`
|
33
30
|
git submodule deinit #{path}
|
34
31
|
rm -rf #{path}
|
35
32
|
git rm #{path}
|
36
33
|
`
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.checkTagIsEqualToHead(tag, path)
|
37
|
+
_currentDir = Dir.pwd
|
38
|
+
Dir.chdir(path)
|
39
|
+
result = `git describe --abbrev=4 HEAD`
|
40
|
+
Dir.chdir(_currentDir)
|
41
|
+
if result.include?(tag)
|
42
|
+
true
|
43
|
+
else
|
44
|
+
checkTagOrBranchIsEqalToHead(tag, path)
|
37
45
|
end
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
46
|
+
end
|
47
|
+
|
48
|
+
# 这个函数有问题有时候拿不到相同的commit id
|
49
|
+
def self.checkTagOrBranchIsEqalToHead(branchOrTag, path)
|
50
|
+
_currentDir = Dir.pwd
|
51
|
+
Dir.chdir(path)
|
52
|
+
headCommitID = `git rev-parse HEAD`
|
53
|
+
tagCommitID = `git rev-parse #{branchOrTag}`
|
54
|
+
Pod::UI.puts "#{`pwd`} headCommitID:#{headCommitID} \n #{branchOrTag}ComitID:#{tagCommitID}"
|
55
|
+
Dir.chdir(_currentDir)
|
56
|
+
(headCommitID.length > 0 && headCommitID == tagCommitID)
|
57
|
+
end
|
58
|
+
|
59
|
+
def self.checkGitStatusAndPush(pod_name)
|
60
|
+
output = `git status -s`
|
61
|
+
puts output
|
62
|
+
if output.length == 0
|
63
|
+
output = `git status`
|
64
|
+
if output.include?('push')
|
65
|
+
ret = system('git push')
|
66
|
+
raise "💔 #{pod_name.yellow} push 失败" if ret != true
|
67
|
+
end
|
68
|
+
else
|
69
|
+
raise "💔 #{pod_name.yellow} 有未提交的数据"
|
60
70
|
end
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
else
|
74
|
-
raise "💔 #{pod_name.yellow} 有未提交的数据"
|
75
|
-
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def self.checkRemoteTagExist(tag)
|
74
|
+
`git push --tags`
|
75
|
+
system("git ls-remote --exit-code origin refs/tags/#{tag}")
|
76
|
+
end
|
77
|
+
|
78
|
+
def self.addGitTagAndPush(tag, pod_name)
|
79
|
+
ret = system("git tag #{tag}")
|
80
|
+
if ret == true
|
81
|
+
ret = system("git push origin #{tag}")
|
82
|
+
raise "💔 #{pod_name.yellow} push tag 失败" if ret != true
|
76
83
|
end
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
84
|
+
ret
|
85
|
+
end
|
86
|
+
|
87
|
+
def self.inputNeedJumpForReson(str)
|
88
|
+
return false if ARGV.include? '--silent'
|
89
|
+
|
90
|
+
puts str.green
|
91
|
+
puts '是(Y), 任意其他输入或直接回车跳过'.green
|
92
|
+
input = STDIN.gets
|
93
|
+
input[0, 1] == 'Y'
|
94
|
+
end
|
95
|
+
|
96
|
+
# 检查是否在主分支上(main / master)
|
97
|
+
def self.checkIsOnTrankBrach()
|
98
|
+
branch = `git branch --show-current`.chomp
|
99
|
+
isOK = (branch == 'main' || branch == 'master')
|
100
|
+
if !isOK
|
101
|
+
puts ('💔 当前分支是: '.red + branch.green + ' 没在主分支,不符合规范,是否继续发布?'.red)
|
102
|
+
if !inputNeedJumpForReson("")
|
103
|
+
raise "已取消发布, 请切换子库分支到 master / main 后重新 pod install"
|
104
|
+
end
|
82
105
|
end
|
106
|
+
end
|
83
107
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
if ret != true
|
89
|
-
raise "💔 #{pod_name.yellow} push tag 失败"
|
90
|
-
end
|
91
|
-
end
|
92
|
-
return ret
|
108
|
+
def self.changeVersionInCocoapods(name, newVersion)
|
109
|
+
if newVersion.nil?
|
110
|
+
Pod::UI.puts '💔 传入的修改目标版本号为空,无法设置版本号'.yellow
|
111
|
+
return
|
93
112
|
end
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
end
|
109
|
-
|
110
|
-
def self.changeVersionInCocoapods(name, newVersion)
|
111
|
-
if (newVersion == nil)
|
112
|
-
Pod::UI.puts "💔 传入的修改目标版本号为空,无法设置版本号".yellow
|
113
|
-
return
|
114
|
-
end
|
115
|
-
newVersion = get_pure_version(newVersion)
|
116
|
-
specName = name + ".podspec"
|
117
|
-
FileProcesserManager.new(specName,
|
118
|
-
[
|
119
|
-
FileProcesser.new(-> (fileContent) {
|
120
|
-
return fileContent.gsub(/(\.version *= *')(.*')/, "\\1" + newVersion + "'")
|
121
|
-
})
|
122
|
-
]).process()
|
123
|
-
`git add #{specName}
|
113
|
+
newVersion = get_pure_version(newVersion)
|
114
|
+
specName = name + '.podspec'
|
115
|
+
FileProcesserManager.new(specName,
|
116
|
+
[
|
117
|
+
FileProcesser.new(lambda { |fileContent|
|
118
|
+
return fileContent.gsub(/(\.version *= *')(.*')/,
|
119
|
+
'\\1' + newVersion + "'")
|
120
|
+
}),
|
121
|
+
FileProcesser.new(lambda { |fileContent|
|
122
|
+
return fileContent.gsub(/(\.version *= *")(.*")/,
|
123
|
+
'\\1' + newVersion + '"')
|
124
|
+
})
|
125
|
+
]).process
|
126
|
+
`git add #{specName}
|
124
127
|
git commit -m "Mod: 修改版本号为:#{newVersion} by cocoapods_dev_env plugin"`
|
125
|
-
|
128
|
+
end
|
126
129
|
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
+
def self.get_pure_version(version)
|
131
|
+
version.split.last.scan(/\d+/).join('.')
|
132
|
+
end
|
130
133
|
end
|
131
134
|
|
132
|
-
|
133
|
-
class Podfile
|
134
|
-
|
135
|
+
module Pod
|
136
|
+
class Podfile
|
135
137
|
class TargetDefinition
|
138
|
+
def getReposStrForLint
|
139
|
+
return '' if podfile.sources.size == 0
|
136
140
|
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
str = " --sources="
|
142
|
-
podfile.sources.each do |source|
|
143
|
-
str += source
|
144
|
-
str += ","
|
145
|
-
end
|
146
|
-
Pod::UI.puts str
|
147
|
-
return str
|
148
|
-
end
|
149
|
-
|
150
|
-
def getUserRepoAddress()
|
151
|
-
if podfile.sources.size == 0
|
152
|
-
raise "💔 发布release必须配置仓库的地址, e.g.: source 'https://github.com/CocoaPods/Specs.git'"
|
153
|
-
end
|
154
|
-
index = nil
|
155
|
-
begin
|
156
|
-
Pod::UI.puts "\n\n⌨️ 请输入要发布到的cocoapods仓库序号, 按回车确认: ".yellow
|
157
|
-
num = 1
|
158
|
-
podfile.sources.each do |source|
|
159
|
-
Pod::UI.puts "#{num.to_s.yellow}. #{source.green}"
|
160
|
-
num += 1
|
161
|
-
end
|
162
|
-
index = STDIN.gets.to_i - 1
|
163
|
-
end until (index >= 0 && index < podfile.sources.size)
|
164
|
-
source = podfile.sources[index]
|
165
|
-
Pod::UI.puts "#{"选择了发布到: ".yellow}. #{source.green}(#{index + 1})"
|
166
|
-
return source
|
141
|
+
str = ' --sources='
|
142
|
+
podfile.sources.each do |source|
|
143
|
+
str += source
|
144
|
+
str += ','
|
167
145
|
end
|
146
|
+
Pod::UI.puts str
|
147
|
+
str
|
148
|
+
end
|
149
|
+
|
150
|
+
def getUserRepoAddress
|
151
|
+
raise "💔 发布release必须配置仓库的地址, e.g.: source 'https://github.com/CocoaPods/Specs.git'" if podfile.sources.size == 0
|
152
|
+
|
153
|
+
index = nil
|
154
|
+
begin
|
155
|
+
Pod::UI.puts "\n\n⌨️ 请输入要发布到的cocoapods仓库序号, 按回车确认: ".yellow
|
156
|
+
num = 1
|
157
|
+
podfile.sources.each do |source|
|
158
|
+
Pod::UI.puts "#{num.to_s.yellow}. #{source.green}"
|
159
|
+
num += 1
|
160
|
+
end
|
161
|
+
index = STDIN.gets.to_i - 1
|
162
|
+
end until (index >= 0 && index < podfile.sources.size)
|
163
|
+
source = podfile.sources[index]
|
164
|
+
Pod::UI.puts "#{'选择了发布到: '.yellow}. #{source.green}(#{index + 1})"
|
165
|
+
source
|
166
|
+
end
|
168
167
|
end
|
168
|
+
end
|
169
169
|
end
|
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.
|
4
|
+
version: 2.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- 吴锡苗
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-07-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: luna-binary-uploader
|