lg_pod_plugin 1.1.5.6 → 1.1.5.9

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: f1a582e75b0b0847e488e68ee221be42aca9fe30556d85a9e280ff8e46a0a729
4
- data.tar.gz: bfab01e6cc1f088c88c571157f8b42376b821e709725bff99f0d47cb62697a6e
3
+ metadata.gz: ebaf5437bed598ffa64a8ed94863d10c05c0cfcb848e9edbf726ad212662878b
4
+ data.tar.gz: 1e10a6ad2ec5b02e8771a2580db0374d635998320aaa8739bb4bebcf80eba0ba
5
5
  SHA512:
6
- metadata.gz: 4049ace3059b7139348e5c36e700fdc52f5d7bb33f768cc45092ae618c99bcef44747de19bcfc41b204f01d5c10587d9453d724b500b5715165509d8e59df61f
7
- data.tar.gz: 1941ad03e70d5a9d5e4bbb7496ac3b4df5f2ee037c10dd9fee6209bed74d7900163b9bacac8041572c740ba4fabc8617997862f58c5c1f5d18a3c9187fa84dda
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, 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
- if self.request.single_git
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::Post.new(uri)
31
- req.set_form_data(hash_map)
32
- res = Net::HTTP.start((uri.hostname ||= ""), uri.port) do |http|
33
- http.open_timeout = 15
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
- unless lg_spec
72
- if podspec_content
73
- begin
74
- File.open(pod_spec_file_path, "w+") do |f|
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
- @podspec_content = podspec_content
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 }]
@@ -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
- if cache_podspec
49
- destination = self.download_params["destination"]
50
- if destination && File.exist?(destination) && !Pathname(destination).children.empty?
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
- @uri = URI("http://#{ip_address}#{uri.path}")
32
+ redirect_url = get_redirect_url("https://#{uri.host}#{uri.path}")
33
+ @uri = URI(redirect_url)
36
34
  else
37
- @uri = URI("#{uri.scheme}://#{ip_address}#{uri.path}")
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
- private
47
- #判断是否是 IP 地址
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
- if self.is_address(uri.host)
58
- ip = uri.host
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
- result = %x(ping #{uri.host} -t 1)
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
@@ -12,7 +12,7 @@ module LgPodPlugin
12
12
  uri = LURI.new(url)
13
13
  if uri.host
14
14
  self.uri = uri
15
- self.ip = uri.ip
15
+ self.ip = uri.host
16
16
  self.network_ok = true
17
17
  else
18
18
  self.uri = nil
@@ -1,3 +1,3 @@
1
1
  module LgPodPlugin
2
- VERSION = "1.1.5.6"
2
+ VERSION = "1.1.5.9"
3
3
  end
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.6
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-02 00:00:00.000000000 Z
11
+ date: 2023-02-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cocoapods