lg_pod_plugin 1.1.0 → 1.1.1
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/command/command.rb +2 -0
- data/lib/command/init.rb +34 -0
- data/lib/lg_pod_plugin/database.rb +234 -104
- data/lib/lg_pod_plugin/downloader.rb +17 -53
- data/lib/lg_pod_plugin/gitlab_api.rb +151 -0
- data/lib/lg_pod_plugin/gitlab_archive.rb +287 -0
- data/lib/lg_pod_plugin/gitlab_download.rb +181 -0
- data/lib/lg_pod_plugin/install.rb +37 -20
- data/lib/lg_pod_plugin/l_cache.rb +5 -3
- data/lib/lg_pod_plugin/l_config.rb +83 -0
- data/lib/lg_pod_plugin/l_util.rb +117 -27
- data/lib/lg_pod_plugin/net-ping.rb +41 -0
- data/lib/lg_pod_plugin/podspec.rb +156 -0
- data/lib/lg_pod_plugin/request.rb +73 -75
- data/lib/lg_pod_plugin/string.rb +1 -1
- data/lib/lg_pod_plugin/version.rb +1 -1
- data/lib/lg_pod_plugin.rb +2 -1
- metadata +26 -6
- data/lib/lg_pod_plugin/git_util.rb +0 -331
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lg_pod_plugin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- dongzb01
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-10-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: git
|
@@ -25,19 +25,19 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 1.12.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: archive-zip
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 0.12.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 0.12.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: cocoapods
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,6 +72,20 @@ dependencies:
|
|
72
72
|
- - "<"
|
73
73
|
- !ruby/object:Gem::Version
|
74
74
|
version: '2.0'
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: sqlite3
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - "~>"
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '1.5'
|
82
|
+
type: :runtime
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - "~>"
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '1.5'
|
75
89
|
- !ruby/object:Gem::Dependency
|
76
90
|
name: bacon
|
77
91
|
requirement: !ruby/object:Gem::Requirement
|
@@ -127,17 +141,23 @@ files:
|
|
127
141
|
- bin/lg
|
128
142
|
- lib/command/cache.rb
|
129
143
|
- lib/command/command.rb
|
144
|
+
- lib/command/init.rb
|
130
145
|
- lib/command/install.rb
|
131
146
|
- lib/command/update.rb
|
132
147
|
- lib/lg_pod_plugin.rb
|
133
148
|
- lib/lg_pod_plugin/database.rb
|
134
149
|
- lib/lg_pod_plugin/downloader.rb
|
135
150
|
- lib/lg_pod_plugin/file_path.rb
|
136
|
-
- lib/lg_pod_plugin/
|
151
|
+
- lib/lg_pod_plugin/gitlab_api.rb
|
152
|
+
- lib/lg_pod_plugin/gitlab_archive.rb
|
153
|
+
- lib/lg_pod_plugin/gitlab_download.rb
|
137
154
|
- lib/lg_pod_plugin/install.rb
|
138
155
|
- lib/lg_pod_plugin/l_cache.rb
|
156
|
+
- lib/lg_pod_plugin/l_config.rb
|
139
157
|
- lib/lg_pod_plugin/l_util.rb
|
140
158
|
- lib/lg_pod_plugin/log.rb
|
159
|
+
- lib/lg_pod_plugin/net-ping.rb
|
160
|
+
- lib/lg_pod_plugin/podspec.rb
|
141
161
|
- lib/lg_pod_plugin/request.rb
|
142
162
|
- lib/lg_pod_plugin/string.rb
|
143
163
|
- lib/lg_pod_plugin/version.rb
|
@@ -1,331 +0,0 @@
|
|
1
|
-
require 'pp'
|
2
|
-
require 'git'
|
3
|
-
require_relative 'l_util'
|
4
|
-
require_relative 'request'
|
5
|
-
require_relative 'l_cache'
|
6
|
-
|
7
|
-
module LgPodPlugin
|
8
|
-
|
9
|
-
class LGitUtil
|
10
|
-
|
11
|
-
REQUIRED_ATTRS ||= %i[git tag path name commit branch].freeze
|
12
|
-
attr_accessor(*REQUIRED_ATTRS)
|
13
|
-
|
14
|
-
def initialize(name, options = {})
|
15
|
-
self.name = name
|
16
|
-
self.git = options[:git]
|
17
|
-
self.tag = options[:tag]
|
18
|
-
self.path = options[:path]
|
19
|
-
self.branch = options[:branch]
|
20
|
-
self.commit = options[:commit]
|
21
|
-
end
|
22
|
-
|
23
|
-
# 从 GitLab下载 zip包
|
24
|
-
# 根据branch 下载 zip 包
|
25
|
-
def gitlab_download_branch_zip(path, temp_name)
|
26
|
-
branch = self.branch ||= "master"
|
27
|
-
token = LRequest.shared.token
|
28
|
-
unless token
|
29
|
-
return self.git_clone_by_branch(path, temp_name)
|
30
|
-
end
|
31
|
-
file_name = "#{temp_name}.zip"
|
32
|
-
base_url = self.git[0...self.git.length - 4]
|
33
|
-
project_name = base_url.split("/").last
|
34
|
-
unless project_name
|
35
|
-
return self.git_clone_by_branch(path, temp_name)
|
36
|
-
end
|
37
|
-
download_url = base_url + "/-/archive/" + branch + "/#{project_name}-#{branch}.zip"
|
38
|
-
LgPodPlugin.log_blue "开始下载 => #{download_url}"
|
39
|
-
system("curl --header PRIVATE-TOKEN:#{token} -o #{file_name} --connect-timeout 60 --retry 3 #{download_url}")
|
40
|
-
unless File.exist?(file_name)
|
41
|
-
LgPodPlugin.log_red("下载zip包失败, 尝试git clone #{self.git}")
|
42
|
-
return self.git_clone_by_branch(path, temp_name)
|
43
|
-
end
|
44
|
-
# 解压文件
|
45
|
-
result = LUtils.unzip_file(path.join(file_name).to_path, "./")
|
46
|
-
new_file_name = "#{project_name}-#{branch}"
|
47
|
-
unless result && File.exist?(new_file_name)
|
48
|
-
LgPodPlugin.log_red("正在尝试git clone #{self.git}")
|
49
|
-
return self.git_clone_by_branch(path, temp_name)
|
50
|
-
end
|
51
|
-
path.join(new_file_name)
|
52
|
-
end
|
53
|
-
|
54
|
-
# 通过tag下载zip包
|
55
|
-
def gitlab_download_tag_zip(path, temp_name)
|
56
|
-
token = LRequest.shared.token
|
57
|
-
unless token
|
58
|
-
return self.git_clone_by_tag(path, temp_name)
|
59
|
-
end
|
60
|
-
base_url = self.git[0...self.git.length - 4]
|
61
|
-
project_name = base_url.split("/").last
|
62
|
-
unless project_name
|
63
|
-
return self.git_clone_by_tag(path, temp_name)
|
64
|
-
end
|
65
|
-
file_name = "#{temp_name}.zip"
|
66
|
-
download_url = base_url + "/-/archive/" + self.tag + "/#{project_name}-#{self.tag}.zip"
|
67
|
-
# 下载文件
|
68
|
-
LgPodPlugin.log_blue "开始下载 => #{download_url}"
|
69
|
-
system("curl -s --header PRIVATE-TOKEN:#{token} -o #{file_name} --connect-timeout 60 --retry 3 #{download_url}")
|
70
|
-
unless File.exist?(file_name)
|
71
|
-
LgPodPlugin.log_red("下载zip包失败, 尝试git clone #{self.git}")
|
72
|
-
return self.git_clone_by_tag(path, temp_name)
|
73
|
-
end
|
74
|
-
# 解压文件
|
75
|
-
result = LUtils.unzip_file(path.join(file_name).to_path, "./")
|
76
|
-
new_file_name = "#{project_name}-#{self.tag}"
|
77
|
-
unless result && File.exist?(new_file_name)
|
78
|
-
LgPodPlugin.log_red("正在尝试git clone #{self.git}")
|
79
|
-
return self.git_clone_by_tag(path, temp_name)
|
80
|
-
end
|
81
|
-
path.join(new_file_name)
|
82
|
-
end
|
83
|
-
|
84
|
-
# 通过 commit 下载zip包
|
85
|
-
def gitlab_download_commit_zip(path, temp_name)
|
86
|
-
token = LRequest.shared.token
|
87
|
-
unless token
|
88
|
-
return self.git_clone_by_commit(path, temp_name)
|
89
|
-
end
|
90
|
-
base_url = self.git[0...self.git.length - 4]
|
91
|
-
project_name = base_url.split("/").last
|
92
|
-
unless project_name
|
93
|
-
return self.git_clone_by_commit(path, temp_name)
|
94
|
-
end
|
95
|
-
file_name = "#{temp_name}.zip"
|
96
|
-
download_url = base_url + "/-/archive/" + self.commit + "/#{project_name}-#{self.commit}.zip"
|
97
|
-
# 下载文件
|
98
|
-
LgPodPlugin.log_blue "开始下载 => #{download_url}"
|
99
|
-
system("curl -s --header PRIVATE-TOKEN:#{token} -o #{file_name} --connect-timeout 60 --retry 3 #{download_url}")
|
100
|
-
unless File.exist?(file_name)
|
101
|
-
LgPodPlugin.log_red("正在尝试git clone #{self.git}")
|
102
|
-
return self.git_clone_by_commit(path, temp_name)
|
103
|
-
end
|
104
|
-
# 解压文件
|
105
|
-
result = LUtils.unzip_file(path.join(file_name).to_path, "./")
|
106
|
-
new_file_name = "#{project_name}-#{self.commit}"
|
107
|
-
unless result && File.exist?(new_file_name)
|
108
|
-
LgPodPlugin.log_red("正在尝试git clone #{self.git}")
|
109
|
-
return self.git_clone_by_commit(path, temp_name)
|
110
|
-
end
|
111
|
-
path.join(new_file_name)
|
112
|
-
end
|
113
|
-
|
114
|
-
# 从 Github下载 zip 包
|
115
|
-
# 根据branch 下载 zip 包
|
116
|
-
def github_download_branch_zip(path, temp_name)
|
117
|
-
file_name = "#{temp_name}.zip"
|
118
|
-
branch = self.branch ||= "master"
|
119
|
-
if self.git.include?(".git")
|
120
|
-
base_url = self.git[0...self.git.length - 4]
|
121
|
-
else
|
122
|
-
base_url = self.git
|
123
|
-
end
|
124
|
-
project_name = base_url.split("/").last if base_url
|
125
|
-
origin_url = base_url + "/archive/#{branch}.zip"
|
126
|
-
download_url = "https://gh.api.99988866.xyz/#{origin_url}"
|
127
|
-
LgPodPlugin.log_blue "开始下载 => #{download_url}"
|
128
|
-
system("curl -o #{file_name} --connect-timeout 60 --retry 3 #{download_url}")
|
129
|
-
unless File.exist?(file_name)
|
130
|
-
LgPodPlugin.log_red("下载zip包失败, 尝试git clone #{self.git}")
|
131
|
-
return self.git_clone_by_branch(path, temp_name)
|
132
|
-
end
|
133
|
-
# 解压文件
|
134
|
-
result = LUtils.unzip_file(path.join(file_name).to_path, "./")
|
135
|
-
new_file_name = "#{project_name}-#{branch}"
|
136
|
-
unless result && File.exist?(new_file_name)
|
137
|
-
LgPodPlugin.log_red("正在尝试git clone #{self.git}")
|
138
|
-
return self.git_clone_by_branch(path, temp_name)
|
139
|
-
end
|
140
|
-
path.join(new_file_name)
|
141
|
-
end
|
142
|
-
|
143
|
-
# 通过tag下载zip包
|
144
|
-
def github_download_tag_zip(path, temp_name)
|
145
|
-
file_name = "#{temp_name}.zip"
|
146
|
-
if self.git.include?(".git")
|
147
|
-
base_url = self.git[0...self.git.length - 4]
|
148
|
-
else
|
149
|
-
base_url = self.git
|
150
|
-
end
|
151
|
-
project_name = base_url.split("/").last if base_url
|
152
|
-
origin_url = base_url + "/archive/refs/tags/#{self.tag}.zip"
|
153
|
-
download_url = "https://gh.api.99988866.xyz/#{origin_url}"
|
154
|
-
# 下载文件
|
155
|
-
LgPodPlugin.log_blue "开始下载 => #{download_url}"
|
156
|
-
system("curl -s -o #{file_name} --connect-timeout 60 --retry 3 #{download_url}")
|
157
|
-
unless File.exist?(file_name)
|
158
|
-
LgPodPlugin.log_red("正在尝试git clone #{self.git}")
|
159
|
-
return self.git_clone_by_tag(path, temp_name)
|
160
|
-
end
|
161
|
-
# 解压文件
|
162
|
-
result = LUtils.unzip_file(path.join(file_name).to_path, "./")
|
163
|
-
if self.tag.include?("v") && self.tag[0...1] == "v"
|
164
|
-
this_tag = self.tag[1...self.tag.length]
|
165
|
-
else
|
166
|
-
this_tag = self.tag
|
167
|
-
end
|
168
|
-
new_file_name = "#{project_name}-#{this_tag}"
|
169
|
-
unless result && File.exist?(new_file_name)
|
170
|
-
LgPodPlugin.log_red("正在尝试git clone #{self.git}")
|
171
|
-
return self.git_clone_by_tag(path, temp_name)
|
172
|
-
end
|
173
|
-
path.join(new_file_name)
|
174
|
-
end
|
175
|
-
|
176
|
-
# 通过 commit 下载zip包
|
177
|
-
def github_download_commit_zip(path, temp_name)
|
178
|
-
file_name = "#{temp_name}.zip"
|
179
|
-
if self.git.include?(".git")
|
180
|
-
base_url = self.git[0...self.git.length - 4]
|
181
|
-
else
|
182
|
-
base_url = self.git
|
183
|
-
end
|
184
|
-
project_name = base_url.split("/").last if base_url
|
185
|
-
origin_url = base_url + "/archive/#{self.commit}.zip"
|
186
|
-
download_url = "https://gh.api.99988866.xyz/#{origin_url}"
|
187
|
-
# 下载文件
|
188
|
-
LgPodPlugin.log_blue "开始下载 => #{download_url}"
|
189
|
-
system("curl -s -o #{file_name} --connect-timeout 15 --retry 3 #{download_url}")
|
190
|
-
unless File.exist?(file_name)
|
191
|
-
LgPodPlugin.log_red("正在尝试git clone #{self.git}")
|
192
|
-
return self.git_clone_by_commit(path, temp_name)
|
193
|
-
end
|
194
|
-
# 解压文件
|
195
|
-
result = LUtils.unzip_file(path.join(file_name).to_path, "./")
|
196
|
-
new_file_name = "#{project_name}-#{self.commit}"
|
197
|
-
unless result && File.exist?(new_file_name)
|
198
|
-
LgPodPlugin.log_red("正在尝试git clone #{self.git}")
|
199
|
-
return self.git_clone_by_commit(path, temp_name)
|
200
|
-
end
|
201
|
-
path.join(new_file_name)
|
202
|
-
end
|
203
|
-
|
204
|
-
def git_clone_by_branch(path, temp_name)
|
205
|
-
if self.git && self.branch
|
206
|
-
LgPodPlugin.log_blue "git clone --depth=1 --branch #{self.branch} #{self.git}"
|
207
|
-
system("git clone --depth=1 -b #{self.branch} #{self.git} #{temp_name}")
|
208
|
-
else
|
209
|
-
LgPodPlugin.log_blue "git clone --depth=1 #{self.git}"
|
210
|
-
system("git clone --depth=1 #{self.git} #{temp_name}")
|
211
|
-
end
|
212
|
-
path.join(temp_name)
|
213
|
-
end
|
214
|
-
|
215
|
-
def git_clone_by_tag(path, temp_name)
|
216
|
-
LgPodPlugin.log_blue "git clone --tag #{self.tag} #{self.git}"
|
217
|
-
system("git clone --depth=1 -b #{self.tag} #{self.git} #{temp_name}")
|
218
|
-
path.join(temp_name)
|
219
|
-
end
|
220
|
-
|
221
|
-
def git_clone_by_commit(path, temp_name)
|
222
|
-
LgPodPlugin.log_blue "git clone #{self.git}"
|
223
|
-
Git.init(temp_name)
|
224
|
-
FileUtils.chdir(temp_name)
|
225
|
-
system("git remote add origin #{self.git}")
|
226
|
-
system("git fetch origin #{self.commit}")
|
227
|
-
system("git reset --hard FETCH_HEAD")
|
228
|
-
path.join(temp_name)
|
229
|
-
end
|
230
|
-
|
231
|
-
# clone 代码仓库
|
232
|
-
def git_clone_repository(path)
|
233
|
-
FileUtils.chdir(path)
|
234
|
-
temp_name = "lg_temp_pod"
|
235
|
-
if self.git && self.tag
|
236
|
-
if self.git.include?("capp/iOS")
|
237
|
-
return gitlab_download_tag_zip(path, temp_name)
|
238
|
-
elsif self.git.include?("https://github.com")
|
239
|
-
return github_download_tag_zip path, temp_name
|
240
|
-
else
|
241
|
-
return self.git_clone_by_tag(path, temp_name)
|
242
|
-
end
|
243
|
-
elsif self.git && self.branch
|
244
|
-
if self.git.include?("capp/iOS")
|
245
|
-
return self.gitlab_download_branch_zip(path, temp_name)
|
246
|
-
elsif self.git.include?("https://github.com")
|
247
|
-
return self.github_download_branch_zip path, temp_name
|
248
|
-
else
|
249
|
-
return self.git_clone_by_branch(path, temp_name)
|
250
|
-
end
|
251
|
-
elsif self.git && self.commit
|
252
|
-
if self.git.include?("capp/iOS")
|
253
|
-
return self.gitlab_download_commit_zip(path, temp_name)
|
254
|
-
elsif self.git.include?("https://github.com")
|
255
|
-
return self.github_download_commit_zip path, temp_name
|
256
|
-
else
|
257
|
-
return self.git_clone_by_commit(path, temp_name)
|
258
|
-
end
|
259
|
-
elsif self.git
|
260
|
-
if self.git.include?("capp/iOS")
|
261
|
-
return self.gitlab_download_branch_zip(path, temp_name)
|
262
|
-
elsif self.git.include?("https://github.com")
|
263
|
-
return self.github_download_branch_zip path, temp_name
|
264
|
-
else
|
265
|
-
return self.git_clone_by_branch(path, temp_name)
|
266
|
-
end
|
267
|
-
end
|
268
|
-
|
269
|
-
end
|
270
|
-
|
271
|
-
def pre_download_git_repository
|
272
|
-
temp_path = LFileManager.download_director.join("temp")
|
273
|
-
if temp_path.exist?
|
274
|
-
FileUtils.rm_rf(temp_path)
|
275
|
-
end
|
276
|
-
lg_pod_path = LRequest.shared.cache.cache_root
|
277
|
-
unless lg_pod_path.exist?
|
278
|
-
lg_pod_path.mkdir(0700)
|
279
|
-
end
|
280
|
-
get_temp_folder = git_clone_repository(lg_pod_path)
|
281
|
-
#下载 git 仓库失败
|
282
|
-
unless get_temp_folder.exist?
|
283
|
-
return nil
|
284
|
-
end
|
285
|
-
if LRequest.shared.single_git
|
286
|
-
LgPodPlugin::LCache.cache_pod(self.name, get_temp_folder, { :git => self.git })
|
287
|
-
end
|
288
|
-
LgPodPlugin::LCache.cache_pod(self.name, get_temp_folder, LRequest.shared.get_cache_key_params)
|
289
|
-
FileUtils.chdir(LFileManager.download_director)
|
290
|
-
FileUtils.rm_rf(lg_pod_path)
|
291
|
-
end
|
292
|
-
|
293
|
-
# 获取最新的一条 commit 信息
|
294
|
-
def self.git_ls_remote_refs(git, branch, tag, commit)
|
295
|
-
if branch
|
296
|
-
LgPodPlugin.log_yellow "git ls-remote #{git} #{branch}"
|
297
|
-
result = %x(git ls-remote #{git} #{branch})
|
298
|
-
new_commit = result.split(" ").first if result
|
299
|
-
return [branch, new_commit]
|
300
|
-
elsif tag
|
301
|
-
LgPodPlugin.log_yellow "git ls-remote #{git}"
|
302
|
-
ls = Git.ls_remote(git, :head => true)
|
303
|
-
map = ls["tags"]
|
304
|
-
keys = map.keys
|
305
|
-
idx = keys.index("#{tag}")
|
306
|
-
unless idx
|
307
|
-
return [nil, nil]
|
308
|
-
end
|
309
|
-
key = keys[idx]
|
310
|
-
new_commit = map[key][:sha]
|
311
|
-
return [nil, new_commit]
|
312
|
-
else
|
313
|
-
if commit
|
314
|
-
return nil, commit
|
315
|
-
else
|
316
|
-
LgPodPlugin.log_yellow "git ls-remote #{git}"
|
317
|
-
ls = Git.ls_remote(git, :head => true)
|
318
|
-
find_commit = ls["head"][:sha]
|
319
|
-
ls["branches"].each do |key, value|
|
320
|
-
sha = value[:sha]
|
321
|
-
next if sha != find_commit
|
322
|
-
return [key, find_commit]
|
323
|
-
end
|
324
|
-
return nil, find_commit
|
325
|
-
end
|
326
|
-
end
|
327
|
-
|
328
|
-
end
|
329
|
-
|
330
|
-
end
|
331
|
-
end
|