cocoapods-linkline 0.3.1 → 0.3.3
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d117490d018435edb6595c5154d1a7b04c3f279c86c12f66b1b5b54c311271bb
|
4
|
+
data.tar.gz: 503ffc8974e2ba3890a86fb90d8d20a0d87e0c52a2574f09ea422666d1164faa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e5011720de5a848307a2003e4352c0931493959024557b057beb8a9bd698f2086da3e00f9bbd64729e8ace7ea1ae9ed63542f5b268d54bbc69ad4b34d2989993
|
7
|
+
data.tar.gz: f631de91deebfd4dbb71f632bc10429c49d73b9f44c0cd51441b3135f3dc30810be584ebecc9126c780296d6127400dee19b1f86ed3f3d1e4c29e83f6cdcedb3
|
@@ -1,54 +1,125 @@
|
|
1
1
|
module Pod
|
2
|
+
|
3
|
+
# class StableOptions
|
4
|
+
# # define business specs,defalut is stable_specs
|
5
|
+
# option :business_specs, "stable_specs"
|
6
|
+
|
7
|
+
# # define custom lockSpecs tag
|
8
|
+
# option :tag, ""
|
9
|
+
|
10
|
+
# # define custom lockSpecs branch
|
11
|
+
# option :branch, ""
|
12
|
+
# end
|
13
|
+
|
2
14
|
class Command
|
3
15
|
class Stable < Command
|
4
16
|
require 'fileutils'
|
5
17
|
require 'cocoapods/executable.rb'
|
6
18
|
extend Executable
|
7
19
|
executable :git
|
8
|
-
|
9
|
-
self.summary = 'a cocoapods plugin to fetch origin lock'
|
10
20
|
|
11
|
-
|
12
|
-
|
21
|
+
|
22
|
+
######################################## Env ########################################
|
23
|
+
def env
|
24
|
+
File.join(File.expand_path('~/.cache'), 'cocoapods-linkline','stable',@ll_stable_source.split('/').last.chomp('.git').to_s)
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
######################################## Constant ########################################
|
29
|
+
def ll_stable_specs_func_name
|
30
|
+
"stable_specs"
|
31
|
+
end
|
32
|
+
def ll_stable_specs_business_func_name
|
33
|
+
"stable_specs_business"
|
34
|
+
end
|
35
|
+
def ll_stable_specs_local_func_name
|
36
|
+
"stable_specs_lock"
|
13
37
|
end
|
14
|
-
|
15
|
-
def run
|
16
|
-
#1、first create stable_lock.rb if no exit, and input a template function for the podfile
|
17
|
-
ll_create_stable_lock_template
|
18
38
|
|
19
|
-
#2、load podfile to fetch ll_stable_source and ll_stable_lock_origin
|
20
|
-
verify_podfile_exists!
|
21
39
|
|
22
|
-
|
40
|
+
######################################## Main ########################################
|
41
|
+
self.summary = 'a cocoapods plugin to fetch origin lock'
|
42
|
+
def run
|
43
|
+
#1、first load source and origin lock name from podfile
|
44
|
+
ll_load_stable
|
45
|
+
|
46
|
+
#2、clone origin lock spec to cache dir
|
23
47
|
ll_cloneStable
|
24
48
|
|
25
|
-
#
|
49
|
+
#3、fetch newest code
|
26
50
|
git_reset
|
27
51
|
git_pull
|
28
52
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
#5、show origin_stable_lock diff with local_stable_lock
|
34
|
-
ll_show_lock_diff(stable_lock_arr, stable_lock_origin_arr)
|
53
|
+
local = ll_fetch_local_stable_datas
|
54
|
+
origin = ll_fetch_origin_stable_datas
|
55
|
+
#4、show origin_stable_lock diff with local_stable_lock
|
56
|
+
ll_show_lock_diff(local, origin)
|
35
57
|
|
36
|
-
#
|
37
|
-
ll_rewirte_stable_lock(
|
58
|
+
#5、rewirte local_stable_lock with origin_stable_lock
|
59
|
+
ll_rewirte_stable_lock(origin)
|
38
60
|
end
|
61
|
+
|
39
62
|
|
40
63
|
private
|
41
|
-
|
64
|
+
######################################## API ########################################
|
65
|
+
def ll_load_stable
|
66
|
+
unless File.exist?(File.join(Pathname.pwd, "Podfile"))
|
67
|
+
err_msg = "- Error: #{File.join(Pathname.pwd, "Podfile")} is not exit"
|
68
|
+
Pod::UI.puts "#{err_msg}".send(:red)
|
69
|
+
exit -9001
|
70
|
+
end
|
71
|
+
|
72
|
+
matches = File.read(File.join(Pathname.pwd, "Podfile")).match(/^\s*stable!\s*'([^']+)'(?:,\s*(\w+):\s*'([^']+)')*/m)
|
73
|
+
unless matches
|
74
|
+
err_msg = "- Error: not stable define in the podfile! you can define like【stable 'https://git.babybus.co/babybus/ios/Specs/stable-specs.git', specs:'global_stable_specs'】in podfile"
|
75
|
+
Pod::UI.puts "#{err_msg}".send(:red)
|
76
|
+
exit -9002
|
77
|
+
end
|
78
|
+
|
79
|
+
eval(matches.to_s)
|
80
|
+
end
|
81
|
+
|
42
82
|
def ll_cloneStable
|
43
83
|
unless Dir.exist?(File.join(env))
|
44
84
|
clonePath = File.dirname(env)
|
45
85
|
FileUtils.mkdir_p clonePath
|
46
|
-
git_clone(
|
86
|
+
git_clone(@ll_stable_source,clonePath)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def ll_fetch_local_stable_datas
|
91
|
+
ll_create_stable_lock_template_if_need
|
92
|
+
eval(ll_stable_specs_local_func_name)
|
93
|
+
end
|
94
|
+
|
95
|
+
def ll_fetch_origin_stable_datas
|
96
|
+
unless File.exist?(File.join(env, "#{@ll_stable_file}.rb"))
|
97
|
+
err_msg = "- Error: #{@ll_stable_file}.rb is not exit in #{@ll_stable_source}"
|
98
|
+
Pod::UI.puts "#{err_msg}".send(:red)
|
99
|
+
exit -9003
|
47
100
|
end
|
101
|
+
|
102
|
+
require File.join(env, "#{@ll_stable_file}.rb")
|
103
|
+
|
104
|
+
if @ll_stable_file == ll_stable_specs_func_name #兼容默认只使用公共仓库锁的情况
|
105
|
+
unless defined?(stable_specs)
|
106
|
+
err_msg = "- Error: #{ll_stable_specs_func_name} function is not exit in #{@ll_stable_file}.rb"
|
107
|
+
Pod::UI.puts "#{err_msg}".send(:red)
|
108
|
+
exit -9004
|
109
|
+
end
|
110
|
+
eval(ll_stable_specs_func_name)
|
111
|
+
else
|
112
|
+
unless defined?(stable_specs_business)
|
113
|
+
err_msg = "- Error: #{ll_stable_specs_business_func_name} function is not exit in #{@ll_stable_file}.rb"
|
114
|
+
Pod::UI.puts "#{err_msg}".send(:red)
|
115
|
+
exit -9005
|
116
|
+
end
|
117
|
+
eval(ll_stable_specs_business_func_name)
|
118
|
+
end
|
48
119
|
end
|
49
120
|
|
50
|
-
def ll_show_lock_diff(
|
51
|
-
added, updated, rollbacked = ll_compare_specs(
|
121
|
+
def ll_show_lock_diff(local_arr, origin_arr)
|
122
|
+
added, updated, rollbacked, deleted = ll_compare_specs(local_arr, origin_arr)
|
52
123
|
|
53
124
|
#31m: 红色 32m:绿色 33m:黄色 34m:蓝色
|
54
125
|
#puts "\e[34m#{string}\e[0m"
|
@@ -58,7 +129,7 @@ module Pod
|
|
58
129
|
end
|
59
130
|
|
60
131
|
if updated.any?
|
61
|
-
puts "\n更新了以下项目:".send(:
|
132
|
+
puts "\n更新了以下项目:". send(:yellow)
|
62
133
|
puts updated.join("\n")
|
63
134
|
end
|
64
135
|
|
@@ -67,14 +138,19 @@ module Pod
|
|
67
138
|
puts rollbacked.join("\n")
|
68
139
|
end
|
69
140
|
|
70
|
-
|
141
|
+
if deleted.any?
|
142
|
+
puts "\n移除了以下项目:".send(:red)
|
143
|
+
puts deleted.join("\n")
|
144
|
+
end
|
145
|
+
|
146
|
+
unless added.any? || updated.any? || added.any? || deleted.any?
|
71
147
|
puts "\n已经是最新版本".send(:green)
|
72
148
|
end
|
73
149
|
end
|
74
150
|
|
75
151
|
def ll_rewirte_stable_lock(stable_lock_origin_arr)
|
76
|
-
File.open("#{
|
77
|
-
file.puts "def #{
|
152
|
+
File.open("#{ll_stable_specs_local_func_name}.rb", 'w') do |file|
|
153
|
+
file.puts "def #{ll_stable_specs_local_func_name}"
|
78
154
|
file.puts "["
|
79
155
|
stable_lock_origin_arr.each_with_index do |spec, index|
|
80
156
|
if index == stable_lock_origin_arr.length - 1
|
@@ -88,43 +164,23 @@ module Pod
|
|
88
164
|
end
|
89
165
|
end
|
90
166
|
|
91
|
-
def
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
if versionGreat(version_2,matching_project_1[1])
|
104
|
-
updated_projects << "【#{project_name_2}】 (#{matching_project_1[1]}) -> (#{version_2.to_s.send(:blue)})"
|
105
|
-
else
|
106
|
-
rollbacked_projects << "【#{project_name_2}】 (#{version_2.to_s.send(:red)}) <- (#{matching_project_1[1]})"
|
107
|
-
end
|
108
|
-
end
|
167
|
+
def ll_create_stable_lock_template_if_need
|
168
|
+
lockfilePath = File.join(Pathname.pwd,"#{ll_stable_specs_local_func_name}.rb")
|
169
|
+
require lockfilePath if File.exist?(lockfilePath)
|
170
|
+
unless File.exist?(lockfilePath) && defined?(stable_specs_lock)#判断方法是否存在只能使用 固定字符,不能通过变量间接判断
|
171
|
+
Dir.chdir(Pathname.pwd) {
|
172
|
+
File.open("#{ll_stable_specs_local_func_name}.rb", 'w') do |file|
|
173
|
+
file.puts "def #{ll_stable_specs_local_func_name}"
|
174
|
+
file.puts "["
|
175
|
+
file.puts "]"
|
176
|
+
file.puts "end"
|
177
|
+
end
|
178
|
+
}
|
109
179
|
end
|
110
|
-
|
111
|
-
return added_projects, updated_projects, rollbacked_projects
|
112
180
|
end
|
113
181
|
|
114
|
-
def ll_create_stable_lock_template
|
115
|
-
unless File.exist?(File.join(Pathname.pwd,"#{ll_stable_lock}.rb"))
|
116
|
-
Dir.chdir(Pathname.pwd) {
|
117
|
-
File.open("#{ll_stable_lock}.rb", 'w') do |file|
|
118
|
-
file.puts "def #{ll_stable_lock}"
|
119
|
-
file.puts "["
|
120
|
-
file.puts "]"
|
121
|
-
file.puts "end"
|
122
|
-
end
|
123
|
-
}
|
124
|
-
end
|
125
|
-
end
|
126
182
|
|
127
|
-
|
183
|
+
######################################## Help ########################################
|
128
184
|
# compare tags (>=)
|
129
185
|
def versionGreatOrEqual(tag1, tag2)
|
130
186
|
tags1 = tag1.split(".")
|
@@ -157,21 +213,51 @@ module Pod
|
|
157
213
|
return result
|
158
214
|
end
|
159
215
|
|
160
|
-
|
161
|
-
def
|
162
|
-
|
163
|
-
|
216
|
+
# compare specs
|
217
|
+
def ll_compare_specs(specs_1, specs_2)
|
218
|
+
added_projects = []
|
219
|
+
updated_projects = []
|
220
|
+
rollbacked_projects = []
|
221
|
+
deleted_projects = []
|
222
|
+
|
223
|
+
specs_2.each do |project_2|
|
224
|
+
project_name_2, version_2 = project_2
|
225
|
+
matching_project_1 = specs_1.find { |project_1| project_1[0] == project_name_2 }
|
226
|
+
|
227
|
+
if matching_project_1.nil?
|
228
|
+
added_projects << "【#{project_name_2}】 (#{version_2.to_s.send(:green)})"
|
229
|
+
elsif matching_project_1[1] != version_2
|
230
|
+
if versionGreat(version_2,matching_project_1[1])
|
231
|
+
updated_projects << "【#{project_name_2}】 (#{matching_project_1[1]}) -> (#{version_2.to_s.send(:yellow)})"
|
232
|
+
else
|
233
|
+
rollbacked_projects << "【#{project_name_2}】 (#{version_2.to_s.send(:red)}) <- (#{matching_project_1[1]})"
|
234
|
+
end
|
235
|
+
end
|
236
|
+
specs_1.delete(matching_project_1) if matching_project_1
|
237
|
+
end
|
164
238
|
|
165
|
-
|
166
|
-
|
167
|
-
|
239
|
+
#处理远端删除某个锁的情况
|
240
|
+
specs_1.each do |project_1|
|
241
|
+
project_name_1, version_1 = project_1
|
242
|
+
deleted_projects << "【#{project_name_1}】 (#{"delete".send(:red)}) <- (#{version_1})"
|
243
|
+
end unless specs_1.empty?
|
244
|
+
return added_projects, updated_projects, rollbacked_projects, deleted_projects
|
168
245
|
end
|
169
246
|
|
170
|
-
|
171
|
-
|
247
|
+
#help load podfile option
|
248
|
+
def stable!(source, options = {})
|
249
|
+
@ll_stable_source = source
|
250
|
+
if options.has_key?(:specs)
|
251
|
+
@ll_stable_file = options[:specs]
|
252
|
+
else
|
253
|
+
@ll_stable_file = ll_stable_specs_func_name
|
254
|
+
end
|
255
|
+
@ll_stable_tag = options[:tag] if options.has_key?(:tag)
|
256
|
+
@ll_stable_branch = options[:branch] if options.has_key?(:branch)
|
172
257
|
end
|
173
258
|
|
174
|
-
|
259
|
+
|
260
|
+
######################################## Git Command ########################################
|
175
261
|
def git(*args)
|
176
262
|
Dir.chdir(File.join(env)) {
|
177
263
|
return git! args
|
@@ -191,7 +277,6 @@ module Pod
|
|
191
277
|
Dir.chdir(path) { git! ['clone', source] } #origin git command
|
192
278
|
end
|
193
279
|
end
|
194
|
-
|
195
280
|
end
|
196
281
|
end
|
197
282
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cocoapods-linkline
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- youhui
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-09-
|
11
|
+
date: 2023-09-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|