cocoapods-dev-env 0.9.9 → 2.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Gemfile.lock +121 -0
- data/README.md +8 -0
- data/cocoapods-dev-env.code-workspace +21 -0
- data/cocoapods-dev-env.gemspec +1 -0
- data/lib/cocoapods/dev/env/version.rb +1 -1
- data/lib/cocoapods_plugin.rb +407 -165
- metadata +19 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1b812296f28342f1708bda8556027923934872fc111920e70317d551e6dca5db
|
4
|
+
data.tar.gz: 532daa402827318f2110aaed1da2fa3896c1c97897e23bced39bbb723e2d867d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b5ded21c4b040ae5b50f72dba1627233af519d4de30d69f26c8249285d056a23a20220a589001e728f50103857ebf3537bdfbe9ae9e3060457a04c30170c8987
|
7
|
+
data.tar.gz: 8fbcaa555da7caed0cd31bb78855bdd0fe93c20a7717d537be71d914f364aab8b53aa61ba7e828a8486a40138f2136d203e453c5e0ac585161957f65f8c02337
|
data/.gitignore
CHANGED
data/Gemfile.lock
ADDED
@@ -0,0 +1,121 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
cocoapods-dev-env (2.1.8)
|
5
|
+
luna-binary-uploader
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
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)
|
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)
|
111
|
+
|
112
|
+
PLATFORMS
|
113
|
+
ruby
|
114
|
+
|
115
|
+
DEPENDENCIES
|
116
|
+
bundler (~> 2.0)
|
117
|
+
cocoapods-dev-env!
|
118
|
+
rake (~> 10.0)
|
119
|
+
|
120
|
+
BUNDLED WITH
|
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
|
+
}
|
data/cocoapods-dev-env.gemspec
CHANGED
@@ -28,6 +28,7 @@ Gem::Specification.new do |spec|
|
|
28
28
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
29
29
|
spec.require_paths = ["lib"]
|
30
30
|
|
31
|
+
spec.add_dependency 'luna-binary-uploader'
|
31
32
|
spec.add_development_dependency "bundler", "~> 2.0"
|
32
33
|
spec.add_development_dependency "rake", "~> 10.0"
|
33
34
|
end
|
data/lib/cocoapods_plugin.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'file_processer'
|
4
|
+
require 'luna-binary-uploader'
|
2
5
|
|
3
6
|
Pod::HooksManager.register('cocoapods-dev-env', :pre_install) do |installer|
|
4
|
-
|
5
|
-
#puts installer.instance_variables
|
7
|
+
# puts installer.instance_variables
|
6
8
|
# forbidden submodule not cloned
|
7
9
|
# 会引起submodule HEAD回滚,不靠谱,先注释掉
|
8
10
|
# `
|
@@ -11,190 +13,299 @@ Pod::HooksManager.register('cocoapods-dev-env', :pre_install) do |installer|
|
|
11
13
|
end
|
12
14
|
|
13
15
|
Pod::HooksManager.register('cocoapods-dev-env', :post_install) do |installer|
|
14
|
-
#puts installer.instance_variables
|
16
|
+
# puts installer.instance_variables
|
15
17
|
end
|
16
18
|
|
17
19
|
|
18
20
|
$processedPodsState = Hash.new
|
19
21
|
$processedPodsOptions = Hash.new
|
20
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
|
+
|
21
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
|
+
|
22
88
|
class DevEnv
|
23
89
|
def self.keyword
|
24
90
|
:dev_env # 'dev'/'beta'/'release'
|
25
91
|
end
|
92
|
+
def self.binary_key
|
93
|
+
:dev_env_use_binary # true / false
|
94
|
+
end
|
26
95
|
UI.message "🎉 plugin cocoapods-dev-env loaded 🎉".green
|
27
96
|
end
|
28
|
-
class Podfile
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
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."
|
111
|
+
end
|
40
112
|
end
|
41
|
-
Dir.chdir(_currentDir)
|
42
113
|
end
|
43
114
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
115
|
+
class TargetDefinition
|
116
|
+
attr_reader :binary_repo_url
|
117
|
+
attr_reader :binary_source
|
118
|
+
|
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]}`
|
53
128
|
end
|
54
|
-
|
55
|
-
raise "submodule #{path} 移除失败,有未提交的修改"
|
129
|
+
Dir.chdir(_currentDir)
|
56
130
|
end
|
57
|
-
Dir.chdir(_currentDir)
|
58
|
-
`
|
59
|
-
git submodule deinit #{path}
|
60
|
-
rm -rf #{path}
|
61
|
-
git rm #{path}
|
62
|
-
`
|
63
|
-
end
|
64
131
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
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} 移除失败,有推送的修改"
|
141
|
+
end
|
142
|
+
else
|
143
|
+
raise "submodule #{path} 移除失败,有未提交的修改"
|
144
|
+
end
|
145
|
+
Dir.chdir(_currentDir)
|
146
|
+
`
|
147
|
+
git submodule deinit #{path}
|
148
|
+
rm -rf #{path}
|
149
|
+
git rm #{path}
|
150
|
+
`
|
74
151
|
end
|
75
|
-
end
|
76
|
-
|
77
|
-
# 这个函数有问题有时候拿不到相同的commit id
|
78
|
-
def checkTagOrBranchIsEqalToHead(branchOrTag, path)
|
79
|
-
_currentDir = Dir.pwd
|
80
|
-
Dir.chdir(path)
|
81
|
-
headCommitID = `git rev-parse HEAD`
|
82
|
-
tagCommitID = `git rev-parse #{branchOrTag}`
|
83
|
-
UI.puts "#{`pwd`} headCommitID:#{headCommitID} \n #{branchOrTag}ComitID:#{tagCommitID}"
|
84
|
-
Dir.chdir(_currentDir)
|
85
|
-
return (headCommitID.length > 0 && headCommitID == tagCommitID)
|
86
|
-
end
|
87
152
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
if
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
end
|
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)
|
98
162
|
end
|
99
|
-
else
|
100
|
-
raise "💔 #{pod_name.yellow} 有未提交的数据"
|
101
163
|
end
|
102
|
-
end
|
103
164
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
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)
|
174
|
+
end
|
109
175
|
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
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} 有未提交的数据"
|
116
189
|
end
|
117
190
|
end
|
118
|
-
return ret
|
119
|
-
end
|
120
191
|
|
121
|
-
|
122
|
-
|
123
|
-
|
192
|
+
def checkRemoteTagExist(tag)
|
193
|
+
`git push --tags`
|
194
|
+
ret = system("git ls-remote --exit-code origin refs/tags/#{tag}")
|
195
|
+
return ret
|
124
196
|
end
|
125
197
|
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
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
|
205
|
+
end
|
206
|
+
return ret
|
133
207
|
end
|
134
|
-
end
|
135
208
|
|
136
|
-
|
137
|
-
|
138
|
-
|
209
|
+
def inputNeedJumpForReson(str)
|
210
|
+
if ARGV.include? '--silent'
|
211
|
+
return false
|
212
|
+
end
|
213
|
+
|
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
|
221
|
+
end
|
139
222
|
end
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
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
|
144
235
|
end
|
145
|
-
UI.puts str
|
146
|
-
return str
|
147
|
-
end
|
148
236
|
|
149
|
-
|
150
|
-
|
151
|
-
|
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
|
152
254
|
end
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
UI.puts "#{num.to_s.yellow}. #{source.green}"
|
159
|
-
num += 1
|
255
|
+
|
256
|
+
def changeVersionInCocoapods(name, newVersion)
|
257
|
+
if (newVersion == nil)
|
258
|
+
UI.puts "💔 切换版本号的版本现在为空,无法设置版本号".yellow
|
259
|
+
return
|
160
260
|
end
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
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"`
|
271
|
+
end
|
167
272
|
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
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)
|
179
290
|
|
180
|
-
|
181
|
-
|
182
|
-
options = requirements.last
|
183
|
-
pod_name = Specification.root_name(name)
|
184
|
-
last_options = $processedPodsOptions[pod_name]
|
291
|
+
# 主功能,根据dev_env标记来管理使用代码的方式
|
292
|
+
deal_dev_env_with_options(dev_env, options, pod_name, name, requirements)
|
185
293
|
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
294
|
+
# 处理二进制
|
295
|
+
if dev_env != 'dev'
|
296
|
+
binary_processer(dev_env, pod_name, use_binary, options, requirements)
|
297
|
+
end
|
298
|
+
|
299
|
+
|
300
|
+
if dev_env || use_binary
|
301
|
+
$processedPodsOptions[pod_name] = options.clone
|
302
|
+
requirements.pop if options.empty?
|
303
|
+
end
|
304
|
+
end
|
195
305
|
end
|
196
|
-
|
197
|
-
|
306
|
+
|
307
|
+
## --- 主功能函数 ---
|
308
|
+
def deal_dev_env_with_options(dev_env, options, pod_name, name, requirements)
|
198
309
|
if dev_env == nil
|
199
310
|
return
|
200
311
|
end
|
@@ -257,9 +368,12 @@ class Podfile
|
|
257
368
|
_cmd = "git reset --hard"
|
258
369
|
UI.puts _cmd
|
259
370
|
system(_cmd)
|
371
|
+
_cmd = "git pull"
|
372
|
+
UI.puts _cmd
|
373
|
+
system(_cmd)
|
260
374
|
end
|
261
375
|
Dir.chdir(_currentDir)
|
262
|
-
|
376
|
+
|
263
377
|
# if inputNeedJumpForReson("本地库#{pod_name} 开发模式加载完成,是否自动打开Example工程")
|
264
378
|
# searchAndOpenLocalExample(path)
|
265
379
|
# end
|
@@ -282,7 +396,7 @@ class Podfile
|
|
282
396
|
tag = "#{tag}_beta"
|
283
397
|
if File.directory?(path)
|
284
398
|
# 从Dev模式刚刚切换过来,需要打tag并且push
|
285
|
-
UI.puts "release beta-version for #{pod_name.green}".yellow
|
399
|
+
UI.puts "try to release beta-version for #{pod_name.green}".yellow
|
286
400
|
_currentDir = Dir.pwd
|
287
401
|
Dir.chdir(path)
|
288
402
|
# 已经进入到podspec的文件夹中了
|
@@ -291,9 +405,9 @@ class Podfile
|
|
291
405
|
if ret == true
|
292
406
|
# tag已经存在,要么没改动,要么已经手动打过tag,要么是需要引用老版本tag的代码
|
293
407
|
if checkTagOrBranchIsEqalToHead(tag, "./")
|
294
|
-
UI.puts "#{pod_name.green} 检测到未做任何调整,或已手动打过Tag"
|
408
|
+
UI.puts "#{pod_name.green} 检测到未做任何调整,或已手动打过Tag,直接引用远端库"
|
295
409
|
else
|
296
|
-
if !inputNeedJumpForReson("
|
410
|
+
if !inputNeedJumpForReson("#{pod_name.green} 检测到已经存在#{tag.yellow}的tag,且与当前本地节点不同,是否跳过beta发布并删除本地submodule(直接引用远端库)")
|
297
411
|
raise "💔 #{pod_name.yellow} tag:#{tag.yellow} 已存在, 且与当前Commit不对应. 请确认拉到本地之后已经在podfile中手动修改tag版本号"
|
298
412
|
end
|
299
413
|
end
|
@@ -327,7 +441,7 @@ class Podfile
|
|
327
441
|
raise "💔 #{pod_name.yellow} lint 失败"
|
328
442
|
end
|
329
443
|
checkGitStatusAndPush(pod_name)
|
330
|
-
changeVersionInCocoapods(pod_name,
|
444
|
+
changeVersionInCocoapods(pod_name, tag)
|
331
445
|
checkGitStatusAndPush(pod_name)
|
332
446
|
ret = addGitTagAndPush(tag, pod_name)
|
333
447
|
if ret == false
|
@@ -339,7 +453,7 @@ class Podfile
|
|
339
453
|
end
|
340
454
|
## TODO:: 发布到的目标库名称需要用变量设置
|
341
455
|
repoAddrs = getUserRepoAddress()
|
342
|
-
cmd = "pod repo push #{repoAddrs} #{pod_name}.podspec --skip-import-validation --allow-warnings#{getReposStrForLint()}"
|
456
|
+
cmd = "pod repo push #{repoAddrs} #{pod_name}.podspec --skip-import-validation --allow-warnings --use-modular-headers#{getReposStrForLint()}#{verboseParamStr}"
|
343
457
|
UI.puts cmd.green
|
344
458
|
ret = system(cmd)
|
345
459
|
if ret != true
|
@@ -351,25 +465,153 @@ class Podfile
|
|
351
465
|
checkAndRemoveSubmodule(path)
|
352
466
|
end
|
353
467
|
if requirements.length < 2
|
354
|
-
requirements.insert(0, "#{tag}")
|
468
|
+
requirements.insert(0, "#{get_pure_version(tag)}")
|
355
469
|
end
|
356
470
|
UI.message "enabled #{"release".green}-mode for #{pod_name.green}"
|
357
471
|
else
|
358
472
|
raise "💔 :dev_env 必须要设置成 dev/beta/release之一,不接受其他值"
|
359
473
|
end
|
360
|
-
$processedPodsOptions[pod_name] = options
|
361
|
-
requirements.pop if options.empty?
|
362
474
|
end
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
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
|
492
|
+
else
|
493
|
+
UI.puts "pod '#{pod_name}' :tag => #{options[:tag]} version: #{version} 没有找到: tag 对应的版本".red
|
494
|
+
end
|
495
|
+
rescue => exception
|
496
|
+
UI.puts "pod '#{pod_name}' :tag => #{options[:tag]} version: #{version} 没有找到: tag 对应的版本".red
|
497
|
+
else
|
498
|
+
|
499
|
+
end
|
500
|
+
else
|
501
|
+
options.delete(:git)
|
502
|
+
options.delete(:path)
|
503
|
+
options.delete(:tag)
|
504
|
+
options[:source] = binary_repo_url
|
505
|
+
end
|
506
|
+
|
507
|
+
else
|
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
|
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
|
+
|
524
|
+
end
|
525
|
+
end
|
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
|
530
|
+
end
|
531
|
+
|
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
|
537
|
+
end
|
538
|
+
|
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
|
544
|
+
end
|
545
|
+
|
546
|
+
def get_pure_version(version)
|
547
|
+
return version.split.last.scan(/\d+/).join('.')
|
548
|
+
end
|
549
|
+
|
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)
|
567
|
+
|
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
|
576
|
+
|
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()
|
372
614
|
end
|
373
615
|
end
|
374
616
|
end
|
375
|
-
|
617
|
+
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cocoapods-dev-env
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
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:
|
11
|
+
date: 2022-02-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: luna-binary-uploader
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: bundler
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -48,11 +62,13 @@ files:
|
|
48
62
|
- ".gitignore"
|
49
63
|
- CODE_OF_CONDUCT.md
|
50
64
|
- Gemfile
|
65
|
+
- Gemfile.lock
|
51
66
|
- LICENSE.txt
|
52
67
|
- README.md
|
53
68
|
- Rakefile
|
54
69
|
- bin/console
|
55
70
|
- bin/setup
|
71
|
+
- cocoapods-dev-env.code-workspace
|
56
72
|
- cocoapods-dev-env.gemspec
|
57
73
|
- lib/cocoapods/dev/env.rb
|
58
74
|
- lib/cocoapods/dev/env/version.rb
|
@@ -80,7 +96,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
80
96
|
- !ruby/object:Gem::Version
|
81
97
|
version: '0'
|
82
98
|
requirements: []
|
83
|
-
rubygems_version: 3.
|
99
|
+
rubygems_version: 3.2.5
|
84
100
|
signing_key:
|
85
101
|
specification_version: 4
|
86
102
|
summary: a cocoapod plugin for dev in mutipods
|