cocoapods-linkline 0.3.0 → 0.3.2
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 +4 -4
- data/lib/cocoapods-linkline/command/stable/stable.rb +174 -80
- data/lib/cocoapods-linkline/gem_version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d79a353346ff210b779060e35869594cf80059a3d31afe727e0300369e03e3b1
|
4
|
+
data.tar.gz: cb369acc183dee01e4a9d7ac377c1cb7654147103ecc8bb1a72218ea26278e16
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 895a4cf897d751ee6b73b5f402b4b844e6b68443c2e7a3fd215356402ca4612ae10d91be61173c76dadac825b6ddb77b21370d2a2e3ae32c5069ba3f0deb7132
|
7
|
+
data.tar.gz: 37793b18e8a2c76a8bc95721ed42bc5cdd59c25ff2ab623c8435c36dab3348a9d17ac0c24b85f25f23984d7e9f3d48ceb00a8376f4f313a377bd04bff30e5fee
|
@@ -1,77 +1,156 @@
|
|
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
|
+
######################################## Env ########################################
|
22
|
+
def env
|
23
|
+
File.join(File.expand_path('~/.cache'), 'cocoapods-linkline','stable',@ll_stable_source.split('/').last.chomp('.git').to_s)
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
######################################## Constant ########################################
|
28
|
+
def ll_stable_specs_func_name
|
29
|
+
"stable_specs"
|
13
30
|
end
|
31
|
+
def ll_stable_specs_business_func_name
|
32
|
+
"stable_specs_business"
|
33
|
+
end
|
34
|
+
def ll_stable_specs_local_func_name
|
35
|
+
"stable_specs_lock"
|
36
|
+
end
|
37
|
+
|
38
|
+
self.summary = 'a cocoapods plugin to fetch origin lock'
|
14
39
|
|
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
40
|
|
19
|
-
|
20
|
-
|
41
|
+
######################################## Main ########################################
|
42
|
+
def run
|
43
|
+
#1、first load source and origin lock name from podfile
|
44
|
+
ll_load_stable
|
21
45
|
|
22
|
-
#
|
46
|
+
#2、clone origin lock spec to cache dir
|
23
47
|
ll_cloneStable
|
24
48
|
|
25
|
-
#
|
26
|
-
|
49
|
+
#3、fetch newest code
|
50
|
+
git_reset
|
51
|
+
git_pull
|
27
52
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
#5、show origin_stable_lock diff with local_stable_lock
|
33
|
-
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)
|
34
57
|
|
35
|
-
#
|
36
|
-
ll_rewirte_stable_lock(
|
58
|
+
#5、rewirte local_stable_lock with origin_stable_lock
|
59
|
+
ll_rewirte_stable_lock(origin)
|
37
60
|
end
|
61
|
+
|
38
62
|
|
39
63
|
private
|
40
|
-
|
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
|
+
|
41
82
|
def ll_cloneStable
|
42
83
|
unless Dir.exist?(File.join(env))
|
43
84
|
clonePath = File.dirname(env)
|
44
85
|
FileUtils.mkdir_p clonePath
|
45
|
-
git_clone(
|
86
|
+
git_clone(@ll_stable_source,clonePath)
|
46
87
|
end
|
47
88
|
end
|
48
89
|
|
49
|
-
def
|
50
|
-
|
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
|
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
|
119
|
+
end
|
51
120
|
|
121
|
+
def ll_show_lock_diff(local_arr, origin_arr)
|
122
|
+
added, updated, rollbacked, deleted = ll_compare_specs(local_arr, origin_arr)
|
123
|
+
|
124
|
+
#31m: 红色 32m:绿色 33m:黄色 34m:蓝色
|
125
|
+
#puts "\e[34m#{string}\e[0m"
|
52
126
|
if added.any?
|
53
|
-
puts "新增了以下项目:"
|
127
|
+
puts "\n新增了以下项目:".send(:green)
|
54
128
|
puts added.join("\n")
|
55
129
|
end
|
56
130
|
|
57
131
|
if updated.any?
|
58
|
-
puts "\n更新了以下项目:"
|
59
|
-
puts updated.join("\n")
|
132
|
+
puts "\n更新了以下项目:". send(:yellow)
|
133
|
+
puts updated.join("\n")
|
60
134
|
end
|
61
135
|
|
62
136
|
if rollbacked.any?
|
63
|
-
puts "\n回滚了以下项目:"
|
64
|
-
puts rollbacked.join("\n")
|
137
|
+
puts "\n回滚了以下项目:".send(:red)
|
138
|
+
puts rollbacked.join("\n")
|
139
|
+
end
|
140
|
+
|
141
|
+
if deleted.any?
|
142
|
+
puts "\n移除了以下项目:".send(:red)
|
143
|
+
puts deleted.join("\n")
|
65
144
|
end
|
66
145
|
|
67
|
-
unless added.any? || updated.any? || added.any?
|
68
|
-
puts "\n已经是最新版本"
|
146
|
+
unless added.any? || updated.any? || added.any? || deleted.any?
|
147
|
+
puts "\n已经是最新版本".send(:green)
|
69
148
|
end
|
70
149
|
end
|
71
150
|
|
72
151
|
def ll_rewirte_stable_lock(stable_lock_origin_arr)
|
73
|
-
File.open("#{
|
74
|
-
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}"
|
75
154
|
file.puts "["
|
76
155
|
stable_lock_origin_arr.each_with_index do |spec, index|
|
77
156
|
if index == stable_lock_origin_arr.length - 1
|
@@ -85,43 +164,23 @@ module Pod
|
|
85
164
|
end
|
86
165
|
end
|
87
166
|
|
88
|
-
def
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
if versionGreat(version_2,matching_project_1[1])
|
101
|
-
updated_projects << "【#{project_name_2}】 (#{matching_project_1[1]}) -> (#{version_2.to_s.send(:red)})"
|
102
|
-
else
|
103
|
-
rollbacked_projects << "【#{project_name_2}】 (#{version_2.to_s.send(:red)}) <- (#{matching_project_1[1]})"
|
104
|
-
end
|
105
|
-
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
|
+
}
|
106
179
|
end
|
107
|
-
|
108
|
-
return added_projects, updated_projects, rollbacked_projects
|
109
180
|
end
|
110
181
|
|
111
|
-
def ll_create_stable_lock_template
|
112
|
-
unless File.exist?(File.join(Pathname.pwd,"#{ll_stable_lock}.rb"))
|
113
|
-
Dir.chdir(Pathname.pwd) {
|
114
|
-
File.open("#{ll_stable_lock}.rb", 'w') do |file|
|
115
|
-
file.puts "def #{ll_stable_lock}"
|
116
|
-
file.puts "["
|
117
|
-
file.puts "]"
|
118
|
-
file.puts "end"
|
119
|
-
end
|
120
|
-
}
|
121
|
-
end
|
122
|
-
end
|
123
182
|
|
124
|
-
|
183
|
+
######################################## Help ########################################
|
125
184
|
# compare tags (>=)
|
126
185
|
def versionGreatOrEqual(tag1, tag2)
|
127
186
|
tags1 = tag1.split(".")
|
@@ -154,27 +213,63 @@ module Pod
|
|
154
213
|
return result
|
155
214
|
end
|
156
215
|
|
157
|
-
|
158
|
-
def
|
159
|
-
|
160
|
-
|
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
|
161
238
|
|
162
|
-
|
163
|
-
|
164
|
-
|
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
|
165
245
|
end
|
166
246
|
|
167
|
-
|
168
|
-
|
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)
|
169
257
|
end
|
170
258
|
|
171
|
-
|
259
|
+
|
260
|
+
######################################## Git Command ########################################
|
172
261
|
def git(*args)
|
173
|
-
Dir.chdir(File.join(env)) {
|
262
|
+
Dir.chdir(File.join(env)) {
|
263
|
+
return git! args
|
264
|
+
}
|
265
|
+
end
|
266
|
+
|
267
|
+
def git_reset
|
268
|
+
git('reset','--hard') #fommate git command
|
174
269
|
end
|
175
270
|
|
176
|
-
def
|
177
|
-
git('
|
271
|
+
def git_pull
|
272
|
+
git('pull','origin','main','-f') #fommate git command
|
178
273
|
end
|
179
274
|
|
180
275
|
def git_clone(source, path)
|
@@ -182,7 +277,6 @@ module Pod
|
|
182
277
|
Dir.chdir(path) { git! ['clone', source] } #origin git command
|
183
278
|
end
|
184
279
|
end
|
185
|
-
|
186
280
|
end
|
187
281
|
end
|
188
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.2
|
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-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -83,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
83
83
|
- !ruby/object:Gem::Version
|
84
84
|
version: '0'
|
85
85
|
requirements: []
|
86
|
-
rubygems_version: 3.
|
86
|
+
rubygems_version: 3.4.19
|
87
87
|
signing_key:
|
88
88
|
specification_version: 4
|
89
89
|
summary: Build the component and all child inherit dependencies with dynamic framework pod
|