lg_pod_plugin 1.1.7.4 → 1.1.8.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/command/init.rb +1 -1
- data/lib/lg_pod_plugin/db/database.rb +1 -1
- data/lib/lg_pod_plugin/downloader/downloader.rb +9 -48
- data/lib/lg_pod_plugin/downloader/l_cache.rb +79 -62
- data/lib/lg_pod_plugin/downloader/overload_cache.rb +1 -296
- data/lib/lg_pod_plugin/downloader/request.rb +2 -5
- data/lib/lg_pod_plugin/git/github_api.rb +2 -49
- data/lib/lg_pod_plugin/git/github_archive.rb +14 -32
- data/lib/lg_pod_plugin/git/gitlab_api.rb +45 -46
- data/lib/lg_pod_plugin/git/gitlab_archive.rb +7 -80
- data/lib/lg_pod_plugin/git/http_download.rb +3 -8
- data/lib/lg_pod_plugin/installer/PodDownload +0 -0
- data/lib/lg_pod_plugin/installer/install.rb +15 -13
- data/lib/lg_pod_plugin/installer/main.rb +5 -0
- data/lib/lg_pod_plugin/net/l_uri.rb +1 -34
- data/lib/lg_pod_plugin/pod/external_pod.rb +0 -1
- data/lib/lg_pod_plugin/pod/release-pod.rb +4 -4
- data/lib/lg_pod_plugin/utils/file_path.rb +5 -0
- data/lib/lg_pod_plugin/utils/l_util.rb +0 -24
- data/lib/lg_pod_plugin/version.rb +1 -1
- data/lib/lg_pod_plugin.rb +1 -1
- metadata +9 -26
- data/lib/lg_pod_plugin/config/lockfile_model.rb +0 -58
- data/lib/lg_pod_plugin/config/podspec.rb +0 -266
- data/lib/lg_pod_plugin/utils/aes-crypt.rb +0 -82
@@ -5,7 +5,7 @@ module LgPodPlugin
|
|
5
5
|
|
6
6
|
class GithubAPI
|
7
7
|
|
8
|
-
|
8
|
+
# 获取 gitlab最新 commit_id
|
9
9
|
def self.request_github_refs_heads(git, branch)
|
10
10
|
base_url = LUtils.get_gitlab_base_url git
|
11
11
|
if base_url.include?("https://github.com/")
|
@@ -55,6 +55,7 @@ module LgPodPlugin
|
|
55
55
|
end
|
56
56
|
|
57
57
|
public
|
58
|
+
|
58
59
|
def self.get_gitlab_repository_tree(git, sha)
|
59
60
|
base_url = LUtils.get_gitlab_base_url git
|
60
61
|
if base_url.include?("https://github.com/")
|
@@ -85,54 +86,6 @@ module LgPodPlugin
|
|
85
86
|
end
|
86
87
|
end
|
87
88
|
|
88
|
-
public
|
89
|
-
|
90
|
-
def self.get_podspec_file_content(git, sha, filename)
|
91
|
-
base_url = LUtils.get_gitlab_base_url git
|
92
|
-
if base_url.include?("https://github.com/")
|
93
|
-
repo_name = base_url.split("https://github.com/", 0).last
|
94
|
-
elsif base_url.include?("git@github.com:")
|
95
|
-
repo_name = base_url.split("git@github.com:", 0).last
|
96
|
-
else
|
97
|
-
repo_name = nil
|
98
|
-
end
|
99
|
-
return nil unless repo_name
|
100
|
-
trees = self.get_gitlab_repository_tree git, sha
|
101
|
-
return nil if trees.empty?
|
102
|
-
request_url = nil
|
103
|
-
trees.each do |dict|
|
104
|
-
type = dict["type"]
|
105
|
-
next if type == "tree"
|
106
|
-
path = dict["path"]
|
107
|
-
next unless path.include?(".podspec")
|
108
|
-
if path == filename
|
109
|
-
request_url = dict["url"]
|
110
|
-
break
|
111
|
-
end
|
112
|
-
end
|
113
|
-
begin
|
114
|
-
uri = URI(request_url)
|
115
|
-
res = Net::HTTP.get_response(uri)
|
116
|
-
if res.body
|
117
|
-
json = JSON.parse(res.body)
|
118
|
-
else
|
119
|
-
json = nil
|
120
|
-
end
|
121
|
-
return nil unless json && json.is_a?(Hash)
|
122
|
-
content = json["content"]
|
123
|
-
return nil unless content && LUtils.is_a_string?(content)
|
124
|
-
encoding = json["encoding"] ||= "base64"
|
125
|
-
if encoding == "base64"
|
126
|
-
content = LUtils.base64_decode(content)
|
127
|
-
return content
|
128
|
-
else
|
129
|
-
return nil
|
130
|
-
end
|
131
|
-
rescue
|
132
|
-
return nil
|
133
|
-
end
|
134
|
-
end
|
135
|
-
|
136
89
|
end
|
137
90
|
|
138
91
|
end
|
@@ -1,15 +1,17 @@
|
|
1
1
|
require 'uri'
|
2
2
|
require_relative 'git_download'
|
3
3
|
require_relative '../utils/l_util'
|
4
|
-
require_relative '../config/podspec'
|
5
4
|
|
6
5
|
module LgPodPlugin
|
7
6
|
|
8
7
|
class GitHubArchive
|
9
8
|
private
|
9
|
+
|
10
10
|
attr_reader :checkout_options
|
11
|
+
|
11
12
|
public
|
12
|
-
|
13
|
+
|
14
|
+
REQUIRED_ATTRS ||= %i[git tag name commit branch config path].freeze
|
13
15
|
attr_accessor(*REQUIRED_ATTRS)
|
14
16
|
|
15
17
|
def initialize(checkout_options = {})
|
@@ -17,7 +19,6 @@ module LgPodPlugin
|
|
17
19
|
self.tag = checkout_options[:tag]
|
18
20
|
self.name = checkout_options[:name]
|
19
21
|
self.path = checkout_options[:path]
|
20
|
-
self.spec = checkout_options[:spec]
|
21
22
|
self.config = checkout_options[:config]
|
22
23
|
self.commit = checkout_options[:commit]
|
23
24
|
self.branch = checkout_options[:branch]
|
@@ -38,18 +39,11 @@ module LgPodPlugin
|
|
38
39
|
project_name = LUtils.get_git_project_name self.git
|
39
40
|
download_urls = self.download_archive_zip(project_name)
|
40
41
|
download_params = Hash.new
|
42
|
+
download_params["token"] = ""
|
41
43
|
download_params["name"] = self.name
|
42
44
|
download_params["type"] = "github-tag"
|
43
45
|
download_params["path"] = root_path.to_path
|
44
|
-
download_params
|
45
|
-
if self.spec
|
46
|
-
download_params["podspec"] = self.spec
|
47
|
-
download_params["source_files"] = self.spec.source_files.keys
|
48
|
-
download_params["podspec_content"] = nil
|
49
|
-
else
|
50
|
-
download_params["podspec"] = nil
|
51
|
-
download_params["source_files"] = ["All"]
|
52
|
-
end
|
46
|
+
download_params = download_params.merge(download_urls)
|
53
47
|
download_params
|
54
48
|
end
|
55
49
|
|
@@ -58,16 +52,10 @@ module LgPodPlugin
|
|
58
52
|
download_urls = self.download_archive_zip(project_name)
|
59
53
|
download_params = Hash.new
|
60
54
|
download_params["name"] = self.name
|
55
|
+
download_params["token"] = ""
|
61
56
|
download_params["type"] = "github-branch"
|
62
57
|
download_params["path"] = root_path.to_path
|
63
|
-
download_params
|
64
|
-
if self.spec
|
65
|
-
download_params["podspec"] = self.spec
|
66
|
-
download_params["source_files"] = self.spec.source_files.keys
|
67
|
-
else
|
68
|
-
download_params["podspec"] = nil
|
69
|
-
download_params["source_files"] = ["All"]
|
70
|
-
end
|
58
|
+
download_params = download_params.merge(download_urls)
|
71
59
|
download_params
|
72
60
|
end
|
73
61
|
|
@@ -75,17 +63,11 @@ module LgPodPlugin
|
|
75
63
|
project_name = LUtils.get_git_project_name self.git
|
76
64
|
download_urls = self.download_archive_zip(project_name)
|
77
65
|
download_params = Hash.new
|
66
|
+
download_params["token"] = ""
|
78
67
|
download_params["name"] = self.name
|
79
68
|
download_params["type"] = "github-commit"
|
80
69
|
download_params["path"] = root_path.to_path
|
81
|
-
download_params
|
82
|
-
if self.spec
|
83
|
-
download_params["podspec"] = self.spec
|
84
|
-
download_params["source_files"] = self.spec.source_files.keys
|
85
|
-
else
|
86
|
-
download_params["podspec"] = nil
|
87
|
-
download_params["source_files"] = ["All"]
|
88
|
-
end
|
70
|
+
download_params = download_params.merge(download_urls)
|
89
71
|
download_params
|
90
72
|
end
|
91
73
|
|
@@ -102,18 +84,18 @@ module LgPodPlugin
|
|
102
84
|
return nil unless repo_name
|
103
85
|
if self.git && self.tag
|
104
86
|
download_url = "https://codeload.github.com/#{repo_name}/tar.gz/refs/tags/#{self.tag}"
|
105
|
-
|
87
|
+
{ "filename" => "#{project_name}.tar.gz", "url" => download_url }
|
106
88
|
elsif self.git && self.branch
|
107
89
|
if self.branch == "HEAD"
|
108
90
|
download_url = "https://gh.api.99988866.xyz/" + "#{base_url}" + "/archive/#{self.branch}.tar.gz"
|
109
|
-
|
91
|
+
{ "filename" => "#{project_name}.tar.gz", "url" => download_url }
|
110
92
|
else
|
111
93
|
download_url = "https://codeload.github.com/#{repo_name}/tar.gz/refs/heads/#{self.branch}"
|
112
|
-
|
94
|
+
{ "filename" => "#{project_name}.tar.gz", "url" => download_url }
|
113
95
|
end
|
114
96
|
elsif self.git && self.commit
|
115
97
|
download_url = "https://codeload.github.com/#{repo_name}/tar.gz/#{self.commit}"
|
116
|
-
return
|
98
|
+
return { "filename" => "#{project_name}.tar.gz", "url" => download_url }
|
117
99
|
else
|
118
100
|
nil
|
119
101
|
end
|
@@ -14,13 +14,12 @@ module LgPodPlugin
|
|
14
14
|
token_file = db_path.join("access_token.json")
|
15
15
|
return self.get_gitlab_access_token_input(uri, user_id, nil, nil) unless token_file.exist?
|
16
16
|
json = JSON.parse(File.read("#{token_file.to_path}"))
|
17
|
-
|
18
|
-
return self.get_gitlab_access_token_input(uri, user_id, nil, nil) if
|
19
|
-
access_token = LUtils.decrypt(encrypt_access_token, "AZMpxzVxzbo3sFDLRZMpxzVxzbo3sFDZ")
|
17
|
+
access_token = json["access_token"]
|
18
|
+
return self.get_gitlab_access_token_input(uri, user_id, nil, nil) if access_token.nil?
|
20
19
|
token_vaild = GitLabAPI.request_user_emails(uri.hostname, access_token)
|
21
20
|
if token_vaild == "invalid token"
|
22
21
|
FileUtils.rm_rf token_file
|
23
|
-
return self.get_gitlab_access_token_input(uri, user_id, nil, nil)
|
22
|
+
return self.get_gitlab_access_token_input(uri, user_id, nil, nil)
|
24
23
|
end
|
25
24
|
user_id = LUserAuthInfo.get_user_id(uri.hostname)
|
26
25
|
now_time = Time.now.to_i
|
@@ -68,11 +67,11 @@ module LgPodPlugin
|
|
68
67
|
else
|
69
68
|
# 判断 token 是否失效
|
70
69
|
if user_info.expires_in <= time_now
|
71
|
-
return
|
70
|
+
return refresh_user_token uri, refresh_token, user_info.id, user_info.username, user_info.password
|
72
71
|
else
|
73
72
|
update_time = user_info.update_time.to_i
|
74
73
|
if time_now - update_time > 1800
|
75
|
-
user_info =
|
74
|
+
user_info = refresh_user_token uri, refresh_token, user_info.id, user_info.username, user_info.password
|
76
75
|
return user_info
|
77
76
|
else
|
78
77
|
return user_info
|
@@ -264,46 +263,46 @@ module LgPodPlugin
|
|
264
263
|
end
|
265
264
|
end
|
266
265
|
|
267
|
-
public
|
268
|
-
def self.get_podspec_file_content(host, token, project_id, sha, filepath)
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
end
|
266
|
+
# public
|
267
|
+
# def self.get_podspec_file_content(host, token, project_id, sha, filepath)
|
268
|
+
# begin
|
269
|
+
# hash_map = Hash.new
|
270
|
+
# hash_map["ref"] = sha
|
271
|
+
# hash_map["access_token"] = token
|
272
|
+
# uri = URI("#{host}/api/v4/projects/#{project_id}/repository/files/#{filepath}")
|
273
|
+
# uri.query = URI.encode_www_form(hash_map)
|
274
|
+
# res = Net::HTTP.get_response(uri)
|
275
|
+
# case res
|
276
|
+
# when Net::HTTPSuccess, Net::HTTPRedirection
|
277
|
+
# json = JSON.parse(res.body)
|
278
|
+
# else
|
279
|
+
# body = JSON.parse(res.body)
|
280
|
+
# message = body["message"]
|
281
|
+
# if message == "404 Project Not Found"
|
282
|
+
# LSqliteDb.shared.delete_project_by_id(project_id)
|
283
|
+
# end
|
284
|
+
# json = nil
|
285
|
+
# end
|
286
|
+
# return nil unless json && json.is_a?(Hash)
|
287
|
+
# content = json["content"]
|
288
|
+
# return nil unless content && LUtils.is_a_string?(content)
|
289
|
+
# encoding = json["encoding"] ||= "base64"
|
290
|
+
# if encoding == "base64"
|
291
|
+
# require 'base64'
|
292
|
+
# content = Base64.decode64(content)
|
293
|
+
# if content.respond_to?(:encoding) && content.encoding.name != 'UTF-8'
|
294
|
+
# text = content.force_encoding("gb2312").force_encoding("utf-8")
|
295
|
+
# return text
|
296
|
+
# else
|
297
|
+
# return content
|
298
|
+
# end
|
299
|
+
# else
|
300
|
+
# return nil
|
301
|
+
# end
|
302
|
+
# rescue
|
303
|
+
# return nil
|
304
|
+
# end
|
305
|
+
# end
|
307
306
|
|
308
307
|
# 通过名称搜索项目信息
|
309
308
|
public
|
@@ -12,7 +12,7 @@ module LgPodPlugin
|
|
12
12
|
attr_reader :checkout_options
|
13
13
|
|
14
14
|
public
|
15
|
-
REQUIRED_ATTRS ||= %i[git tag name commit branch config path
|
15
|
+
REQUIRED_ATTRS ||= %i[git tag name commit branch config path].freeze
|
16
16
|
attr_accessor(*REQUIRED_ATTRS)
|
17
17
|
|
18
18
|
def initialize(checkout_options = {})
|
@@ -20,7 +20,6 @@ module LgPodPlugin
|
|
20
20
|
self.tag = checkout_options[:tag]
|
21
21
|
self.name = checkout_options[:name]
|
22
22
|
self.path = checkout_options[:path]
|
23
|
-
self.spec = checkout_options[:spec]
|
24
23
|
self.config = checkout_options[:config]
|
25
24
|
self.commit = checkout_options[:commit]
|
26
25
|
self.branch = checkout_options[:branch]
|
@@ -57,51 +56,9 @@ module LgPodPlugin
|
|
57
56
|
else
|
58
57
|
return nil
|
59
58
|
end
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
podspec_content = GitLabAPI.get_podspec_file_content(host, token, project.id, sha, podspec_filename)
|
64
|
-
unless podspec_content && LUtils.is_a_string?(podspec_content)
|
65
|
-
download_url = host + "/api/v4/projects/" + "#{project.id}" + "/repository/archive.tar.bz2\\?" + "sha\\=#{sha}"
|
66
|
-
download_url += "\\&access_token\\=#{token}" if token
|
67
|
-
return [{ "filename" => "#{self.name}.tar.bz2", "url" => download_url }]
|
68
|
-
end
|
69
|
-
pod_spec_file_path = sandbox_path.join("#{podspec_filename}")
|
70
|
-
lg_spec = LgPodPlugin::PodSpec.form_string(podspec_content, pod_spec_file_path)
|
71
|
-
if podspec_content
|
72
|
-
begin
|
73
|
-
File.open(pod_spec_file_path, "w+") do |f|
|
74
|
-
f.write podspec_content
|
75
|
-
end
|
76
|
-
rescue => exception
|
77
|
-
LgPodPlugin.log_red "#{exception}"
|
78
|
-
end
|
79
|
-
@podspec_content = podspec_content
|
80
|
-
end
|
81
|
-
unless lg_spec
|
82
|
-
download_url = host + "/api/v4/projects/" + "#{project.id}" + "/repository/archive.tar.bz2\\?" + "sha\\=#{sha}"
|
83
|
-
download_url += "\\&access_token\\=#{token}" if token
|
84
|
-
return [{ "filename" => "#{self.name}.tar.bz2", "url" => download_url }]
|
85
|
-
end
|
86
|
-
self.spec = lg_spec
|
87
|
-
end
|
88
|
-
download_params = Array.new
|
89
|
-
@source_files = lg_spec.source_files.keys
|
90
|
-
lg_spec.source_files.each_key do |key|
|
91
|
-
next if key == "All" || key == "LICENSE" || key == "License"
|
92
|
-
path = LUtils.url_encode(key)
|
93
|
-
# download_url = host + "/api/v4/projects/" + "#{project.id}" + "/repository/archive.tar.bz2#{"\\?"}" + "sha#{"\\="}#{sha}"
|
94
|
-
download_url = host + "/api/v4/projects/" + "#{project.id}" + "/repository/archive.tar.bz2#{"\\?"}" + "path#{"\\="}#{path}#{"\\&"}sha#{"\\="}#{sha}"
|
95
|
-
download_url += "\\&access_token\\=#{token}" if token
|
96
|
-
download_params.append({ "filename" => "#{path}.tar.bz2", "url" => download_url })
|
97
|
-
end
|
98
|
-
if download_params.empty?
|
99
|
-
download_url = host + "/api/v4/projects/" + "#{project.id}" + "/repository/archive.tar.bz2\\?" + "sha\\=#{sha}"
|
100
|
-
download_url += "\\&access_token\\=#{token}" if token
|
101
|
-
[{ "filename" => "#{self.name}.tar.bz2", "url" => download_url }]
|
102
|
-
else
|
103
|
-
download_params
|
104
|
-
end
|
59
|
+
download_url = host + "/api/v4/projects/" + "#{project.id}" + "/repository/archive.tar.bz2\\?" + "sha\\=#{sha}"
|
60
|
+
download_url += "\\&access_token\\=#{token}" if token
|
61
|
+
download_params = { "filename" => "#{self.name}.tar.bz2", "url" => download_url }
|
105
62
|
end
|
106
63
|
|
107
64
|
# 根据branch 下载 zip 包
|
@@ -113,18 +70,8 @@ module LgPodPlugin
|
|
113
70
|
download_params["token"] = token
|
114
71
|
download_params["name"] = self.name
|
115
72
|
download_params["type"] = "gitlab-branch"
|
116
|
-
if self.spec
|
117
|
-
download_params["podspec"] = self.spec
|
118
|
-
else
|
119
|
-
download_params["podspec_content"] = @podspec_content
|
120
|
-
end
|
121
73
|
download_params["path"] = root_path.to_path
|
122
|
-
|
123
|
-
download_params["source_files"] = @source_files
|
124
|
-
else
|
125
|
-
download_params["source_files"] = "All"
|
126
|
-
end
|
127
|
-
download_params["download_urls"] = download_urls
|
74
|
+
download_params = download_params.merge(download_urls)
|
128
75
|
download_params
|
129
76
|
end
|
130
77
|
|
@@ -137,18 +84,8 @@ module LgPodPlugin
|
|
137
84
|
download_params["token"] = token
|
138
85
|
download_params["name"] = self.name
|
139
86
|
download_params["type"] = "gitlab-tag"
|
140
|
-
if self.spec
|
141
|
-
download_params["podspec"] = self.spec
|
142
|
-
else
|
143
|
-
download_params["podspec_content"] = @podspec_content
|
144
|
-
end
|
145
87
|
download_params["path"] = root_path.to_path
|
146
|
-
|
147
|
-
download_params["source_files"] = @source_files
|
148
|
-
else
|
149
|
-
download_params["source_files"] = "All"
|
150
|
-
end
|
151
|
-
download_params["download_urls"] = download_urls
|
88
|
+
download_params = download_params.merge(download_urls)
|
152
89
|
download_params
|
153
90
|
end
|
154
91
|
|
@@ -160,19 +97,9 @@ module LgPodPlugin
|
|
160
97
|
download_params = Hash.new
|
161
98
|
download_params["token"] = token
|
162
99
|
download_params["name"] = self.name
|
163
|
-
if self.spec
|
164
|
-
download_params["podspec"] = self.spec
|
165
|
-
else
|
166
|
-
download_params["podspec_content"] = @podspec_content
|
167
|
-
end
|
168
100
|
download_params["type"] = "gitlab-commit"
|
169
101
|
download_params["path"] = root_path.to_path
|
170
|
-
|
171
|
-
download_params["source_files"] = @source_files
|
172
|
-
else
|
173
|
-
download_params["source_files"] = "All"
|
174
|
-
end
|
175
|
-
download_params["download_urls"] = download_urls
|
102
|
+
download_params = download_params.merge(download_urls)
|
176
103
|
download_params
|
177
104
|
end
|
178
105
|
|
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'uri'
|
2
2
|
require_relative 'git_download'
|
3
3
|
require_relative '../utils/l_util'
|
4
|
-
require_relative '../config/podspec'
|
5
4
|
|
6
5
|
module LgPodPlugin
|
7
6
|
|
@@ -10,13 +9,12 @@ module LgPodPlugin
|
|
10
9
|
private
|
11
10
|
attr_reader :checkout_options
|
12
11
|
public
|
13
|
-
REQUIRED_ATTRS ||= %i[http name path
|
12
|
+
REQUIRED_ATTRS ||= %i[http name path].freeze
|
14
13
|
attr_accessor(*REQUIRED_ATTRS)
|
15
14
|
def initialize(checkout_options = {})
|
16
15
|
self.name = checkout_options[:name]
|
17
16
|
self.path = checkout_options[:path]
|
18
17
|
self.http = checkout_options[:http]
|
19
|
-
self.lg_spec = checkout_options[:spec]
|
20
18
|
@checkout_options = checkout_options
|
21
19
|
end
|
22
20
|
|
@@ -26,11 +24,8 @@ module LgPodPlugin
|
|
26
24
|
download_params["path"] = self.path.to_path
|
27
25
|
download_params["name"] = self.name
|
28
26
|
download_params["type"] = "http"
|
29
|
-
download_params["
|
30
|
-
|
31
|
-
download_params["podspec"] = self.lg_spec
|
32
|
-
download_params["source_files"] = self.lg_spec.source_files.keys
|
33
|
-
end
|
27
|
+
download_params["filename"] = (new_filename ? new_filename : filename)
|
28
|
+
download_params["url"] = http
|
34
29
|
download_params
|
35
30
|
end
|
36
31
|
|
Binary file
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'pp'
|
2
|
-
# require 'git'
|
3
2
|
require 'cgi'
|
4
3
|
require 'cocoapods'
|
5
4
|
require 'cocoapods-core'
|
@@ -29,34 +28,37 @@ module LgPodPlugin
|
|
29
28
|
|
30
29
|
public
|
31
30
|
def copy_file_to_caches
|
32
|
-
request =
|
33
|
-
name = request.
|
31
|
+
request = downloader.request
|
32
|
+
name = request.name
|
34
33
|
params = Hash.new.merge!(request.params)
|
35
34
|
checkout_options = Hash.new.merge!(request.checkout_options)
|
36
35
|
commit = checkout_options[:commit] ||= params[:commit]
|
37
|
-
if request.
|
38
|
-
cache_podspec = request.
|
36
|
+
if request.podspec
|
37
|
+
cache_podspec = request.podspec
|
39
38
|
else
|
40
39
|
cache_podspec = LProject.shared.cache_specs[name]
|
41
|
-
request.
|
40
|
+
request.podspec = cache_podspec if cache_podspec
|
42
41
|
end
|
43
42
|
destination = self.download_params["destination"]
|
44
43
|
cache_pod_spec_path = self.download_params["cache_pod_spec_path"]
|
45
|
-
|
46
|
-
|
47
|
-
local_spec_path = destination.glob("#{name}.podspec{,.json}").last
|
44
|
+
if cache_podspec.nil?
|
45
|
+
local_spec_path = Pathname(destination).glob("#{name}.podspec{,.json}").last
|
48
46
|
if local_spec_path && File.exist?(local_spec_path)
|
49
47
|
cache_podspec = Pod::Specification.from_file local_spec_path
|
50
48
|
if cache_podspec
|
51
49
|
LProject.shared.cache_specs[name] = cache_podspec
|
50
|
+
LCache.copy_and_clean nil, destination, cache_podspec
|
52
51
|
LCache.write_spec cache_podspec, cache_pod_spec_path
|
53
|
-
LCache.clean_pod_unused_files destination, cache_podspec
|
54
52
|
end
|
55
53
|
end
|
56
|
-
request.
|
54
|
+
request.podspec = cache_podspec if cache_podspec
|
55
|
+
else
|
56
|
+
LProject.shared.cache_specs[name] = cache_podspec
|
57
|
+
LCache.copy_and_clean nil, destination, cache_podspec
|
58
|
+
LCache.write_spec cache_podspec, cache_pod_spec_path
|
57
59
|
end
|
58
60
|
# 判断缓存是否下载成功
|
59
|
-
if
|
61
|
+
if destination && destination.exist? && !destination.children.empty?
|
60
62
|
pod_is_exist = true
|
61
63
|
else
|
62
64
|
pod_is_exist = false
|
@@ -65,7 +67,7 @@ module LgPodPlugin
|
|
65
67
|
|
66
68
|
git = checkout_options[:git]
|
67
69
|
return unless git
|
68
|
-
cache_podspec = request.
|
70
|
+
cache_podspec = request.podspec
|
69
71
|
branch = checkout_options[:branch] ||= request.params[:branch]
|
70
72
|
checkout_options[:name] = name if name
|
71
73
|
checkout_options[:branch] = branch if branch
|
@@ -16,9 +16,14 @@ module LgPodPlugin
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
+
def self.ensure_matching_version
|
20
|
+
cache = Pod::Downloader::Cache.new(LFileManager.cache_root_path)
|
21
|
+
end
|
22
|
+
|
19
23
|
public
|
20
24
|
def self.run(command, options = {})
|
21
25
|
clean_sandbox()
|
26
|
+
ensure_matching_version()
|
22
27
|
workspace = Pathname(Dir.pwd)
|
23
28
|
update = (command == "update")
|
24
29
|
LSqliteDb.shared.init_database
|
@@ -35,46 +35,13 @@ module LgPodPlugin
|
|
35
35
|
@hostname = @scheme + "://" + @host
|
36
36
|
end
|
37
37
|
|
38
|
-
# def get_redirect_url(host)
|
39
|
-
# redirect_url = Net::HTTP.get_response(URI(host))['location']
|
40
|
-
# return host unless redirect_url
|
41
|
-
# uri = URI(redirect_url)
|
42
|
-
# return uri.scheme + "://" + uri.host
|
43
|
-
# end
|
44
|
-
|
45
38
|
private
|
46
39
|
#判断是否是 IP 地址
|
47
40
|
def is_address(host)
|
48
41
|
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)
|
49
42
|
!(match.nil?)
|
50
43
|
end
|
51
|
-
|
52
|
-
# 获取 ip 地址
|
53
|
-
# private
|
54
|
-
# def getaddress(uri)
|
55
|
-
# begin
|
56
|
-
# if self.is_address(uri.host)
|
57
|
-
# ip = uri.host
|
58
|
-
# return ip
|
59
|
-
# else
|
60
|
-
# ip_address = Resolv.getaddress uri.host
|
61
|
-
# return ip_address
|
62
|
-
# end
|
63
|
-
# rescue
|
64
|
-
# result = %x(ping #{uri.host} -t 1)
|
65
|
-
# return if !result || result == "" || result.include?("timeout")
|
66
|
-
# match = %r{\d+.\d+.\d+.\d+}.match(result)
|
67
|
-
# return if match.nil?
|
68
|
-
# ip_address = match ? match[0] : ""
|
69
|
-
# begin
|
70
|
-
# return ip_address if IPAddr.new(ip_address)
|
71
|
-
# rescue => exception
|
72
|
-
# LgPodPlugin.log_red exception
|
73
|
-
# return nil
|
74
|
-
# end
|
75
|
-
# end
|
76
|
-
# end
|
77
|
-
|
44
|
+
|
78
45
|
public def to_s
|
79
46
|
return "" unless @uri
|
80
47
|
@uri.to_s
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'cocoapods'
|
2
2
|
require 'cocoapods-core'
|
3
3
|
require 'cocoapods/user_interface'
|
4
|
-
require_relative '../config/podspec'
|
4
|
+
# require_relative '../config/podspec'
|
5
5
|
require_relative '../installer/concurrency'
|
6
6
|
|
7
7
|
module LgPodPlugin
|
@@ -46,7 +46,8 @@ module LgPodPlugin
|
|
46
46
|
http = "https://ghproxy.com/" + http
|
47
47
|
source["http"] = http
|
48
48
|
end
|
49
|
-
|
49
|
+
version = attributes_hash["version"] ||= ""
|
50
|
+
requirements = {:http => http, :version => version}
|
50
51
|
elsif git && tag
|
51
52
|
tag = tag.to_s unless LUtils.is_a_string? tag
|
52
53
|
requirements = { :git => git, :tag => tag }
|
@@ -55,8 +56,7 @@ module LgPodPlugin
|
|
55
56
|
end
|
56
57
|
next if check_release_pod_exist(pod_name, requirements, spec, true)
|
57
58
|
LProject.shared.cache_specs[pod_name] = spec
|
58
|
-
|
59
|
-
release_pod = ReleasePod.new(nil, pod_name, requirements, lg_spec)
|
59
|
+
release_pod = ReleasePod.new(nil, pod_name, requirements, spec)
|
60
60
|
pod_install = LgPodPlugin::LPodInstaller.new
|
61
61
|
download_params = pod_install.install(release_pod)
|
62
62
|
all_installers.append pod_install if download_params
|