lg_pod_plugin 1.1.5.6 → 1.1.5.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lg_pod_plugin/config/l_config.rb +1 -1
- data/lib/lg_pod_plugin/downloader/downloader.rb +1 -6
- data/lib/lg_pod_plugin/downloader/l_cache.rb +2 -2
- data/lib/lg_pod_plugin/git/gitlab_api.rb +4 -40
- data/lib/lg_pod_plugin/git/gitlab_archive.rb +9 -9
- data/lib/lg_pod_plugin/installer/PodDownload +0 -0
- data/lib/lg_pod_plugin/installer/install.rb +10 -20
- data/lib/lg_pod_plugin/net/l_uri.rb +43 -34
- data/lib/lg_pod_plugin/net/net-ping.rb +1 -1
- data/lib/lg_pod_plugin/version.rb +1 -1
- 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: ebaf5437bed598ffa64a8ed94863d10c05c0cfcb848e9edbf726ad212662878b
|
4
|
+
data.tar.gz: 1e10a6ad2ec5b02e8771a2580db0374d635998320aaa8739bb4bebcf80eba0ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 629fa53e19b009413466cd44b9c6ecf28bffcfd7e500524cdf449d4ef6ef0f298a925f7eb0390b734d0937f57712f7cc078227afbe60950d39a923f845b4c026
|
7
|
+
data.tar.gz: 7772b927826ef6fe0476db3933e9863b27a98aced13853b58583d3141cdf89c09ff5655e2da90e2258f82e1697155aa2a6c0d24d1bb1729b288df6b6b93578fe
|
@@ -23,7 +23,7 @@ module LgPodPlugin
|
|
23
23
|
user_info = LSqliteDb.shared.query_user_info(user_id)
|
24
24
|
# 用户授权 token 不存在, 提示用户输入用户名密码
|
25
25
|
unless user_info
|
26
|
-
user_info = GitLabAPI.get_gitlab_access_token_input(uri, user_id, nil
|
26
|
+
user_info = GitLabAPI.get_gitlab_access_token_input(uri, user_id,nil ,nil )
|
27
27
|
return nil unless user_info
|
28
28
|
end
|
29
29
|
time_now = Time.now.to_i
|
@@ -50,11 +50,7 @@ module LgPodPlugin
|
|
50
50
|
end
|
51
51
|
hash_map = self.request.get_cache_key_params
|
52
52
|
# 发现本地有缓存, 不需要更新缓存
|
53
|
-
|
54
|
-
pod_is_exist, destination, cache_pod_spec = LCache.new.pod_cache_exist(name, hash_map, podspec, self.request.released_pod)
|
55
|
-
else
|
56
|
-
pod_is_exist, destination, cache_pod_spec = LCache.new.pod_cache_exist(name, hash_map, podspec, self.request.released_pod)
|
57
|
-
end
|
53
|
+
pod_is_exist, destination, cache_pod_spec = LCache.new.pod_cache_exist(name, hash_map, podspec, self.request.released_pod)
|
58
54
|
if pod_is_exist
|
59
55
|
is_delete = self.request.params["is_delete"] ||= false
|
60
56
|
LProject.shared.need_update_pods.delete(name) if is_delete
|
@@ -102,7 +98,6 @@ module LgPodPlugin
|
|
102
98
|
download_params.delete("podspec_content")
|
103
99
|
end
|
104
100
|
end
|
105
|
-
FileUtils.rm_rf podspec_path
|
106
101
|
end
|
107
102
|
return download_params
|
108
103
|
elsif File.exist?(download_params.to_s) && download_params
|
@@ -14,8 +14,8 @@ module LgPodPlugin
|
|
14
14
|
public
|
15
15
|
def pod_cache_exist(name, options, spec = nil, released_pod = false)
|
16
16
|
destination, cache_pod_spec = self.find_pod_cache name, options, spec, released_pod
|
17
|
-
if (File.exist?(destination) && !destination.children.empty?)
|
18
|
-
[true, destination, cache_pod_spec]
|
17
|
+
if (File.exist?(destination) && !destination.children.empty?) && cache_pod_spec.exist?
|
18
|
+
return [true, destination, cache_pod_spec]
|
19
19
|
else
|
20
20
|
[false, destination, cache_pod_spec]
|
21
21
|
end
|
@@ -27,19 +27,10 @@ module LgPodPlugin
|
|
27
27
|
uri = URI("#{host}/oauth/token")
|
28
28
|
hash_map = { "grant_type" => "password", "username" => username, "password" => password }
|
29
29
|
LgPodPlugin.log_green "开始请求 access_token, url => #{uri.to_s} "
|
30
|
-
req = Net::HTTP
|
31
|
-
req.
|
32
|
-
|
33
|
-
|
34
|
-
http.read_timeout = 15
|
35
|
-
http.request(req)
|
36
|
-
end
|
37
|
-
case res
|
38
|
-
when Net::HTTPSuccess, Net::HTTPRedirection
|
39
|
-
json = JSON.parse(res.body)
|
40
|
-
else
|
41
|
-
json = JSON.parse(res.body)
|
42
|
-
error = json["error"]
|
30
|
+
req = Net::HTTP.post_form(uri, hash_map)
|
31
|
+
json = JSON.parse(req.body)
|
32
|
+
error = json["error"]
|
33
|
+
if error != nil
|
43
34
|
if error == "invalid_grant"
|
44
35
|
LSqliteDb.shared.delete_user_info(user_id)
|
45
36
|
end
|
@@ -195,34 +186,7 @@ module LgPodPlugin
|
|
195
186
|
end
|
196
187
|
end
|
197
188
|
|
198
|
-
#获取项目中仓库文件和目录的列表
|
199
|
-
# def self.get_gitlab_repository_tree(host, token, project_id, sha)
|
200
|
-
# begin
|
201
|
-
# hash_map = Hash.new
|
202
|
-
# hash_map["ref"] = sha
|
203
|
-
# hash_map["access_token"] = token
|
204
|
-
# hash_map["per_page"] = 50
|
205
|
-
# uri = URI("#{host}/api/v4/projects/#{project_id}/repository/tree")
|
206
|
-
# uri.query = URI.encode_www_form(hash_map)
|
207
|
-
# res = Net::HTTP.get_response(uri)
|
208
|
-
# if res.body
|
209
|
-
# array = JSON.parse(res.body)
|
210
|
-
# else
|
211
|
-
# array = nil
|
212
|
-
# end
|
213
|
-
# return Set.new unless array && array.is_a?(Array)
|
214
|
-
# files = array.collect { |dict|
|
215
|
-
# dict["path"]
|
216
|
-
# }
|
217
|
-
# set = Set.new.merge files
|
218
|
-
# return set
|
219
|
-
# rescue
|
220
|
-
# return Set.new
|
221
|
-
# end
|
222
|
-
# end
|
223
|
-
|
224
189
|
public
|
225
|
-
|
226
190
|
def self.get_podspec_file_content(host, token, project_id, sha, filepath)
|
227
191
|
begin
|
228
192
|
hash_map = Hash.new
|
@@ -68,17 +68,17 @@ module LgPodPlugin
|
|
68
68
|
end
|
69
69
|
pod_spec_file_path = sandbox_path.join("#{podspec_filename}")
|
70
70
|
lg_spec = LgPodPlugin::PodSpec.form_string(podspec_content, pod_spec_file_path)
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
f.write podspec_content
|
76
|
-
end
|
77
|
-
rescue => exception
|
78
|
-
LgPodPlugin.log_red "#{exception}"
|
71
|
+
if podspec_content
|
72
|
+
begin
|
73
|
+
File.open(pod_spec_file_path, "w+") do |f|
|
74
|
+
f.write podspec_content
|
79
75
|
end
|
80
|
-
|
76
|
+
rescue => exception
|
77
|
+
LgPodPlugin.log_red "#{exception}"
|
81
78
|
end
|
79
|
+
@podspec_content = podspec_content
|
80
|
+
end
|
81
|
+
unless lg_spec
|
82
82
|
download_url = host + "/api/v4/projects/" + "#{project.id}" + "/repository/archive.tar.bz2\\?" + "sha\\=#{sha}"
|
83
83
|
download_url += "\\&access_token\\=#{token}" if token
|
84
84
|
return [{ "filename" => "#{self.name}.tar.bz2", "url" => download_url }]
|
Binary file
|
@@ -37,29 +37,13 @@ module LgPodPlugin
|
|
37
37
|
if request.lg_spec
|
38
38
|
cache_podspec = request.lg_spec.spec
|
39
39
|
else
|
40
|
-
cache_podspec = nil
|
41
|
-
end
|
42
|
-
|
43
|
-
unless cache_podspec
|
44
40
|
cache_podspec = LProject.shared.cache_specs[name]
|
45
41
|
request.lg_spec = LgPodPlugin::PodSpec.form_pod_spec cache_podspec if cache_podspec
|
46
42
|
end
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
pod_is_exist = true
|
52
|
-
else
|
53
|
-
pod_is_exist = false
|
54
|
-
end
|
55
|
-
else
|
56
|
-
destination = self.download_params["destination"]
|
57
|
-
if destination && File.exist?(destination) && !Pathname(destination).children.empty?
|
58
|
-
pod_is_exist = true
|
59
|
-
else
|
60
|
-
pod_is_exist = false
|
61
|
-
end
|
62
|
-
cache_pod_spec_path = self.download_params["cache_pod_spec_path"]
|
43
|
+
destination = self.download_params["destination"]
|
44
|
+
cache_pod_spec_path = self.download_params["cache_pod_spec_path"]
|
45
|
+
# podspec.json 不存在
|
46
|
+
unless cache_podspec
|
63
47
|
local_spec_path = destination.glob("#{name}.podspec{,.json}").last
|
64
48
|
if local_spec_path && File.exist?(local_spec_path)
|
65
49
|
cache_podspec = Pod::Specification.from_file local_spec_path
|
@@ -71,6 +55,12 @@ module LgPodPlugin
|
|
71
55
|
end
|
72
56
|
request.lg_spec = LgPodPlugin::PodSpec.form_pod_spec cache_podspec if cache_podspec
|
73
57
|
end
|
58
|
+
# 判断缓存是否下载成功
|
59
|
+
if (destination && File.exist?(destination) && !Pathname(destination).children.empty?) && (cache_pod_spec_path && File.exist?(cache_pod_spec_path))
|
60
|
+
pod_is_exist = true
|
61
|
+
else
|
62
|
+
pod_is_exist = false
|
63
|
+
end
|
74
64
|
if pod_is_exist
|
75
65
|
is_delete = request.params["is_delete"] ||= false
|
76
66
|
LProject.shared.need_update_pods.delete(name) if is_delete
|
@@ -5,7 +5,6 @@ module LgPodPlugin
|
|
5
5
|
|
6
6
|
class LURI
|
7
7
|
public
|
8
|
-
attr_reader :ip
|
9
8
|
attr_reader :path
|
10
9
|
attr_reader :host
|
11
10
|
attr_reader :scheme
|
@@ -29,53 +28,63 @@ module LgPodPlugin
|
|
29
28
|
end
|
30
29
|
end
|
31
30
|
return unless uri
|
32
|
-
ip_address = getaddress(uri)
|
33
|
-
return unless ip_address
|
34
31
|
if git.include?("ssh") || git.include?("git@gitlab") || git.include?("git@")
|
35
|
-
|
32
|
+
redirect_url = get_redirect_url("https://#{uri.host}#{uri.path}")
|
33
|
+
@uri = URI(redirect_url)
|
36
34
|
else
|
37
|
-
|
35
|
+
redirect_url = get_redirect_url("#{uri.scheme}://#{uri.host}#{uri.path}")
|
36
|
+
@uri = URI(redirect_url)
|
38
37
|
end
|
39
|
-
@ip = ip_address
|
40
38
|
@host = @uri.host ||= ""
|
41
39
|
@path = @uri.path ||= ""
|
42
40
|
@scheme = @uri.scheme ||= ""
|
43
41
|
@hostname = @scheme + "://" + @host
|
44
42
|
end
|
45
43
|
|
46
|
-
|
47
|
-
|
48
|
-
def is_address(host)
|
49
|
-
match = %r{^((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)$}.match(host)
|
50
|
-
!(match.nil?)
|
51
|
-
end
|
52
|
-
|
53
|
-
# 获取 ip 地址
|
54
|
-
private
|
55
|
-
def getaddress(uri)
|
44
|
+
def get_redirect_url(host)
|
45
|
+
redirect_url = Net::HTTP.get_response(URI(host))['location']
|
56
46
|
begin
|
57
|
-
|
58
|
-
|
59
|
-
return ip
|
60
|
-
else
|
61
|
-
ip_address = Resolv.getaddress uri.host
|
62
|
-
return ip_address
|
63
|
-
end
|
47
|
+
uri = URI(redirect_url)
|
48
|
+
return uri.scheme + "://" + uri.host
|
64
49
|
rescue
|
65
|
-
|
66
|
-
return if !result || result == "" || result.include?("timeout")
|
67
|
-
match = %r{\d+.\d+.\d+.\d+}.match(result)
|
68
|
-
return if match.nil?
|
69
|
-
ip_address = match ? match[0] : ""
|
70
|
-
begin
|
71
|
-
return ip_address if IPAddr.new(ip_address)
|
72
|
-
rescue => exception
|
73
|
-
LgPodPlugin.log_red exception
|
74
|
-
return nil
|
75
|
-
end
|
50
|
+
return host
|
76
51
|
end
|
77
52
|
end
|
78
53
|
|
54
|
+
|
55
|
+
private
|
56
|
+
#判断是否是 IP 地址
|
57
|
+
# def is_address(host)
|
58
|
+
# match = %r{^((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)$}.match(host)
|
59
|
+
# !(match.nil?)
|
60
|
+
# end
|
61
|
+
|
62
|
+
# 获取 ip 地址
|
63
|
+
# private
|
64
|
+
# def getaddress(uri)
|
65
|
+
# begin
|
66
|
+
# if self.is_address(uri.host)
|
67
|
+
# ip = uri.host
|
68
|
+
# return ip
|
69
|
+
# else
|
70
|
+
# ip_address = Resolv.getaddress uri.host
|
71
|
+
# return ip_address
|
72
|
+
# end
|
73
|
+
# rescue
|
74
|
+
# result = %x(ping #{uri.host} -t 1)
|
75
|
+
# return if !result || result == "" || result.include?("timeout")
|
76
|
+
# match = %r{\d+.\d+.\d+.\d+}.match(result)
|
77
|
+
# return if match.nil?
|
78
|
+
# ip_address = match ? match[0] : ""
|
79
|
+
# begin
|
80
|
+
# return ip_address if IPAddr.new(ip_address)
|
81
|
+
# rescue => exception
|
82
|
+
# LgPodPlugin.log_red exception
|
83
|
+
# return nil
|
84
|
+
# end
|
85
|
+
# end
|
86
|
+
# end
|
87
|
+
|
79
88
|
public def to_s
|
80
89
|
return "" unless @uri
|
81
90
|
@uri.to_s
|
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.5.
|
4
|
+
version: 1.1.5.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- dongzb01
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-02-
|
11
|
+
date: 2023-02-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cocoapods
|