lg_pod_plugin 1.1.2 → 1.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/command/install.rb +1 -1
- data/lib/command/update.rb +1 -1
- data/lib/lg_pod_plugin/database.rb +4 -12
- data/lib/lg_pod_plugin/gitlab_api.rb +30 -34
- data/lib/lg_pod_plugin/gitlab_archive.rb +72 -14
- data/lib/lg_pod_plugin/gitlab_download.rb +23 -77
- data/lib/lg_pod_plugin/install.rb +2 -77
- data/lib/lg_pod_plugin/l_cache.rb +8 -12
- data/lib/lg_pod_plugin/l_util.rb +14 -3
- data/lib/lg_pod_plugin/release-pod.rb +90 -0
- data/lib/lg_pod_plugin/request.rb +62 -26
- data/lib/lg_pod_plugin/runner.rb +114 -0
- data/lib/lg_pod_plugin/specification.rb +52 -0
- data/lib/lg_pod_plugin/version.rb +1 -1
- data/lib/lg_pod_plugin.rb +1 -9
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz: '
|
3
|
+
metadata.gz: 3edf15fe0a8e9cfcc59a9224cd55aa947dc4c347f3a2dedbbdab3bb07b4b1f65
|
4
|
+
data.tar.gz: '09cbcc226c7176f819d23b950adfaaab4d4cefa918403edac8b2cd8eec9e0cef'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e422b84be0ca83287c305152a8543a195ca27fa742937d81113f30a0e697d97865b114ca71222e5280eb62c196985e2da333a71f07e2b718bf71515b497ff2e5
|
7
|
+
data.tar.gz: 686b7cb744ed6857dee9317bb74eaa3841fd34e75f388be3912ca2ea1dd7ac2eeccbce9fdec1ac563e28ffd34b59f478a68f9cf9d0aa48d2d1517c776e588fc8
|
data/lib/command/install.rb
CHANGED
data/lib/command/update.rb
CHANGED
@@ -39,17 +39,9 @@ module LgPodPlugin
|
|
39
39
|
self.commit = commit
|
40
40
|
end
|
41
41
|
|
42
|
-
def self.get_pod_id(name, git
|
43
|
-
|
44
|
-
|
45
|
-
return Digest::MD5.hexdigest(key)
|
46
|
-
elsif git && tag
|
47
|
-
key = name + git + tag
|
48
|
-
return Digest::MD5.hexdigest(key)
|
49
|
-
else
|
50
|
-
key = name + git
|
51
|
-
return Digest::MD5.hexdigest(key)
|
52
|
-
end
|
42
|
+
def self.get_pod_id(name, git)
|
43
|
+
key = name + git
|
44
|
+
return Digest::MD5.hexdigest(key)
|
53
45
|
end
|
54
46
|
|
55
47
|
end
|
@@ -202,7 +194,7 @@ module LgPodPlugin
|
|
202
194
|
end
|
203
195
|
|
204
196
|
def insert_pod_refs(name, git, branch, tag , commit)
|
205
|
-
id = LPodLatestRefs.get_pod_id(name, git
|
197
|
+
id = LPodLatestRefs.get_pod_id(name, git)
|
206
198
|
pod = LPodLatestRefs.new(id, name, git, branch, tag, commit)
|
207
199
|
if self.query_pod_refs(id) != nil
|
208
200
|
self.db.execute_batch(
|
@@ -38,7 +38,7 @@ module LgPodPlugin
|
|
38
38
|
user_id = LUserAuthInfo.get_user_id(host)
|
39
39
|
user_model = LUserAuthInfo.new(user_id, username, password, host, access_token, refresh_token, (created_at + expires_in))
|
40
40
|
LSqliteDb.shared.insert_user_info(user_model)
|
41
|
-
GitLabAPI.get_user_projects(access_token, host, 1)
|
41
|
+
# GitLabAPI.get_user_projects(access_token, host, 1)
|
42
42
|
LgPodPlugin.log_green "请求成功: `access_token` => #{access_token}, expires_in => #{expires_in}"
|
43
43
|
rescue => exception
|
44
44
|
LgPodPlugin.log_red "获取 `access_token` 失败, error => #{exception.to_s}"
|
@@ -46,39 +46,35 @@ module LgPodPlugin
|
|
46
46
|
end
|
47
47
|
|
48
48
|
#获取用户所有项目
|
49
|
-
def self.get_user_projects(access_token, host, page)
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
end
|
79
|
-
|
80
|
-
end
|
81
|
-
end
|
49
|
+
# def self.get_user_projects(access_token, host, page)
|
50
|
+
# begin
|
51
|
+
# hash_map = Hash.new
|
52
|
+
# hash_map["page"] = page
|
53
|
+
# hash_map["per_page"] = 20
|
54
|
+
# hash_map["access_token"] = access_token
|
55
|
+
# uri = URI("#{host}/api/v4/projects")
|
56
|
+
# uri.query = URI.encode_www_form(hash_map)
|
57
|
+
# res = Net::HTTP.get_response(uri)
|
58
|
+
# array = JSON.parse(res.body) if res.body
|
59
|
+
# unless array.is_a?(Array)
|
60
|
+
# return
|
61
|
+
# end
|
62
|
+
# # pp array
|
63
|
+
# array.each do |json|
|
64
|
+
# id = json["id"]
|
65
|
+
# name = json["name"]
|
66
|
+
# path = json["path"]
|
67
|
+
# web_url = json["web_url"]
|
68
|
+
# description = json["description"]
|
69
|
+
# ssh_url_to_repo = json["ssh_url_to_repo"]
|
70
|
+
# http_url_to_repo = json["http_url_to_repo"]
|
71
|
+
# path_with_namespace = json["path_with_namespace"] ||= ""
|
72
|
+
# name_with_namespace = (json["name_with_namespace"] ||= "").gsub(/[ ]/, '')
|
73
|
+
# project = ProjectModel.new(id, name, description, path, ssh_url_to_repo, http_url_to_repo, web_url, name_with_namespace, path_with_namespace)
|
74
|
+
# LSqliteDb.shared.insert_project(project)
|
75
|
+
# end
|
76
|
+
# end
|
77
|
+
# end
|
82
78
|
|
83
79
|
# 刷新gitlab_token
|
84
80
|
def self.refresh_gitlab_access_token(host, refresh_token)
|
@@ -43,7 +43,9 @@ module LgPodPlugin
|
|
43
43
|
end
|
44
44
|
LUtils.download_gitlab_zip_file(download_url, token, temp_name)
|
45
45
|
return nil unless File.exist?(temp_name)
|
46
|
-
|
46
|
+
result = LUtils.unzip_file(temp_name, "./")
|
47
|
+
FileUtils.rm_rf temp_name unless result
|
48
|
+
return nil unless result
|
47
49
|
temp_zip_folder = nil
|
48
50
|
path.each_child do |f|
|
49
51
|
ftype = File::ftype(f)
|
@@ -202,9 +204,13 @@ module LgPodPlugin
|
|
202
204
|
else
|
203
205
|
base_url = self.git
|
204
206
|
end
|
205
|
-
origin_url = base_url + "/archive/#{branch}.zip"
|
206
207
|
project_name = base_url.split("/").last if base_url
|
207
|
-
|
208
|
+
url_path = base_url.split("https://github.com/").last
|
209
|
+
if branch == "HEAD"
|
210
|
+
download_url = "https://gh.api.99988866.xyz/" + "#{base_url}" + "/archive/#{branch}.zip"
|
211
|
+
else
|
212
|
+
download_url = "https://codeload.github.com/#{url_path}/zip/refs/heads/#{branch}"
|
213
|
+
end
|
208
214
|
LgPodPlugin.log_blue "开始下载 => #{download_url}"
|
209
215
|
LUtils.download_github_zip_file(download_url, file_name)
|
210
216
|
unless File.exist?(file_name)
|
@@ -236,9 +242,9 @@ module LgPodPlugin
|
|
236
242
|
else
|
237
243
|
base_url = self.git
|
238
244
|
end
|
245
|
+
uri = URI(base_url)
|
239
246
|
project_name = base_url.split("/").last if base_url
|
240
|
-
|
241
|
-
download_url = "https://gh.api.99988866.xyz/#{origin_url}"
|
247
|
+
download_url = "https://codeload.github.com#{uri.path}/zip/refs/tags/#{self.tag}"
|
242
248
|
# 下载文件
|
243
249
|
LgPodPlugin.log_blue "开始下载 => #{download_url}"
|
244
250
|
LUtils.download_github_zip_file(download_url, file_name)
|
@@ -248,17 +254,20 @@ module LgPodPlugin
|
|
248
254
|
end
|
249
255
|
# 解压文件
|
250
256
|
result = LUtils.unzip_file(path.join(file_name).to_path, "./")
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
257
|
+
temp_zip_folder = nil
|
258
|
+
path.each_child do |f|
|
259
|
+
ftype = File::ftype(f)
|
260
|
+
next unless ftype == "directory"
|
261
|
+
version = self.tag.split("v").last ||= self.tag
|
262
|
+
next unless f.to_path.include?("#{project_name}") || f.to_path.include?(version)
|
263
|
+
temp_zip_folder = f
|
264
|
+
break
|
255
265
|
end
|
256
|
-
|
257
|
-
unless result && File.exist?(new_file_name)
|
266
|
+
unless temp_zip_folder && File.exist?(temp_zip_folder)
|
258
267
|
LgPodPlugin.log_red("正在尝试git clone #{self.git}")
|
259
268
|
return self.git_clone_by_tag(path, temp_name)
|
260
269
|
end
|
261
|
-
|
270
|
+
temp_zip_folder
|
262
271
|
end
|
263
272
|
|
264
273
|
# 通过 commit 下载zip包
|
@@ -269,9 +278,9 @@ module LgPodPlugin
|
|
269
278
|
else
|
270
279
|
base_url = self.git
|
271
280
|
end
|
281
|
+
uri = URI(base_url)
|
272
282
|
project_name = base_url.split("/").last if base_url
|
273
|
-
|
274
|
-
download_url = "https://gh.api.99988866.xyz/#{origin_url}"
|
283
|
+
download_url = "https://codeload.github.com#{uri.path}/zip/#{self.commit}"
|
275
284
|
# 下载文件
|
276
285
|
LgPodPlugin.log_blue "开始下载 => #{download_url}"
|
277
286
|
LUtils.download_github_zip_file(download_url, file_name)
|
@@ -289,6 +298,55 @@ module LgPodPlugin
|
|
289
298
|
path.join(new_file_name)
|
290
299
|
end
|
291
300
|
|
301
|
+
def git_clone_by_branch(path, temp_name)
|
302
|
+
download_temp_path = path.join(temp_name)
|
303
|
+
if self.git && self.branch
|
304
|
+
git_download_command(temp_name, self.git, self.branch, nil)
|
305
|
+
else
|
306
|
+
git_download_command(temp_name, self.git, nil, nil)
|
307
|
+
if File.exist?(temp_name)
|
308
|
+
system("git -C #{download_temp_path.to_path} rev-parse HEAD")
|
309
|
+
end
|
310
|
+
end
|
311
|
+
download_temp_path
|
312
|
+
end
|
313
|
+
|
314
|
+
def git_clone_by_tag(path, temp_name)
|
315
|
+
git_download_command(temp_name, self.git, nil, self.tag)
|
316
|
+
path.join(temp_name)
|
317
|
+
end
|
318
|
+
|
319
|
+
# git clone commit
|
320
|
+
def git_clone_by_commit(path, temp_name)
|
321
|
+
Git.init(temp_name)
|
322
|
+
FileUtils.chdir(temp_name)
|
323
|
+
LgPodPlugin.log_blue "git clone #{self.git}"
|
324
|
+
system("git remote add origin #{self.git}")
|
325
|
+
system("git fetch origin #{self.commit}")
|
326
|
+
system("git reset --hard FETCH_HEAD")
|
327
|
+
path.join(temp_name)
|
328
|
+
end
|
329
|
+
|
330
|
+
# 封装 git clone命令
|
331
|
+
def git_download_command(temp_name, git, branch, tag)
|
332
|
+
cmds = ['git']
|
333
|
+
cmds << "clone"
|
334
|
+
cmds << "#{git}"
|
335
|
+
cmds << "#{temp_name} "
|
336
|
+
cmds << "--template="
|
337
|
+
cmds << "--single-branch --depth 1"
|
338
|
+
if branch
|
339
|
+
cmds << "--branch"
|
340
|
+
cmds << branch
|
341
|
+
elsif tag
|
342
|
+
cmds << "--branch"
|
343
|
+
cmds << tag
|
344
|
+
end
|
345
|
+
cmds_to_s = cmds.join(" ")
|
346
|
+
LgPodPlugin.log_blue cmds_to_s
|
347
|
+
system(cmds_to_s)
|
348
|
+
end
|
349
|
+
|
292
350
|
end
|
293
351
|
|
294
352
|
end
|
@@ -23,54 +23,6 @@ module LgPodPlugin
|
|
23
23
|
self.branch = options[:branch]
|
24
24
|
self.commit = options[:commit]
|
25
25
|
end
|
26
|
-
# 封装 git clone命令
|
27
|
-
def git_download_command(temp_name, git, branch, tag)
|
28
|
-
cmds = ['git']
|
29
|
-
cmds << "clone"
|
30
|
-
cmds << "#{git}"
|
31
|
-
cmds << "#{temp_name} "
|
32
|
-
cmds << "--template="
|
33
|
-
cmds << "--single-branch --depth 1"
|
34
|
-
if branch
|
35
|
-
cmds << "--branch"
|
36
|
-
cmds << branch
|
37
|
-
elsif tag
|
38
|
-
cmds << "--branch"
|
39
|
-
cmds << tag
|
40
|
-
end
|
41
|
-
cmds_to_s = cmds.join(" ")
|
42
|
-
LgPodPlugin.log_blue cmds_to_s
|
43
|
-
system(cmds_to_s)
|
44
|
-
end
|
45
|
-
|
46
|
-
def git_clone_by_branch(path, temp_name)
|
47
|
-
download_temp_path = path.join(temp_name)
|
48
|
-
if self.git && self.branch
|
49
|
-
git_download_command(temp_name, self.git, self.branch, nil)
|
50
|
-
else
|
51
|
-
git_download_command(temp_name, self.git, nil, nil)
|
52
|
-
if File.exist?(temp_name)
|
53
|
-
system("git -C #{download_temp_path.to_path} rev-parse HEAD")
|
54
|
-
end
|
55
|
-
end
|
56
|
-
download_temp_path
|
57
|
-
end
|
58
|
-
|
59
|
-
def git_clone_by_tag(path, temp_name)
|
60
|
-
git_download_command(temp_name, self.git, nil, self.tag)
|
61
|
-
path.join(temp_name)
|
62
|
-
end
|
63
|
-
|
64
|
-
# git clone commit
|
65
|
-
def git_clone_by_commit(path, temp_name)
|
66
|
-
Git.init(temp_name)
|
67
|
-
FileUtils.chdir(temp_name)
|
68
|
-
LgPodPlugin.log_blue "git clone #{self.git}"
|
69
|
-
system("git remote add origin #{self.git}")
|
70
|
-
system("git fetch origin #{self.commit}")
|
71
|
-
system("git reset --hard FETCH_HEAD")
|
72
|
-
path.join(temp_name)
|
73
|
-
end
|
74
26
|
|
75
27
|
# clone 代码仓库
|
76
28
|
def git_clone_repository(path)
|
@@ -84,10 +36,10 @@ module LgPodPlugin
|
|
84
36
|
elsif self.git.include?("https://github.com")
|
85
37
|
return git_archive.github_download_tag_zip path, temp_name
|
86
38
|
else
|
87
|
-
return
|
39
|
+
return git_archive.git_clone_by_tag(path, temp_name)
|
88
40
|
end
|
89
41
|
rescue
|
90
|
-
return
|
42
|
+
return git_archive.git_clone_by_tag(path, temp_name)
|
91
43
|
end
|
92
44
|
elsif self.git && self.branch
|
93
45
|
begin
|
@@ -96,10 +48,10 @@ module LgPodPlugin
|
|
96
48
|
elsif self.git.include?("https://github.com")
|
97
49
|
return git_archive.github_download_branch_zip path, temp_name
|
98
50
|
else
|
99
|
-
return
|
51
|
+
return git_archive.git_clone_by_branch(path, temp_name)
|
100
52
|
end
|
101
53
|
rescue
|
102
|
-
return
|
54
|
+
return git_archive.git_clone_by_branch(path, temp_name)
|
103
55
|
end
|
104
56
|
elsif self.git && self.commit
|
105
57
|
if LUtils.is_use_gitlab_archive_file(self.git)
|
@@ -107,7 +59,7 @@ module LgPodPlugin
|
|
107
59
|
elsif self.git.include?("https://github.com")
|
108
60
|
return git_archive.github_download_commit_zip path, temp_name
|
109
61
|
else
|
110
|
-
return
|
62
|
+
return git_archive.git_clone_by_commit(path, temp_name)
|
111
63
|
end
|
112
64
|
elsif self.git
|
113
65
|
if LUtils.is_use_gitlab_archive_file(self.git)
|
@@ -115,7 +67,7 @@ module LgPodPlugin
|
|
115
67
|
elsif self.git.include?("https://github.com")
|
116
68
|
return git_archive.github_download_branch_zip path, temp_name
|
117
69
|
else
|
118
|
-
return
|
70
|
+
return git_archive.git_clone_by_branch(path, temp_name)
|
119
71
|
end
|
120
72
|
end
|
121
73
|
|
@@ -124,21 +76,13 @@ module LgPodPlugin
|
|
124
76
|
# git 预下载
|
125
77
|
def pre_download_git_repository
|
126
78
|
temp_path = LFileManager.download_director.join("temp")
|
127
|
-
if temp_path.exist?
|
128
|
-
FileUtils.rm_rf(temp_path)
|
129
|
-
end
|
79
|
+
FileUtils.rm_rf(temp_path) if temp_path.exist?
|
130
80
|
lg_pod_path = LRequest.shared.cache.cache_root
|
131
|
-
unless lg_pod_path.exist?
|
132
|
-
lg_pod_path.mkdir(0700)
|
133
|
-
end
|
81
|
+
lg_pod_path.mkdir(0700) unless lg_pod_path.exist?
|
134
82
|
get_temp_folder = git_clone_repository(lg_pod_path)
|
135
83
|
#下载 git 仓库失败
|
136
|
-
unless get_temp_folder && get_temp_folder.exist?
|
137
|
-
|
138
|
-
end
|
139
|
-
if LRequest.shared.single_git
|
140
|
-
LgPodPlugin::LCache.cache_pod(self.name, get_temp_folder, { :git => self.git })
|
141
|
-
end
|
84
|
+
return nil unless (get_temp_folder && get_temp_folder.exist?)
|
85
|
+
LgPodPlugin::LCache.cache_pod(self.name, get_temp_folder, { :git => self.git }) if LRequest.shared.single_git
|
142
86
|
LgPodPlugin::LCache.cache_pod(self.name, get_temp_folder, LRequest.shared.get_cache_key_params)
|
143
87
|
FileUtils.chdir(LFileManager.download_director)
|
144
88
|
FileUtils.rm_rf(lg_pod_path)
|
@@ -157,12 +101,12 @@ module LgPodPlugin
|
|
157
101
|
result = %x(git ls-remote #{git} #{branch})
|
158
102
|
end
|
159
103
|
unless result && result != ""
|
160
|
-
id = LPodLatestRefs.get_pod_id(name, git
|
104
|
+
id = LPodLatestRefs.get_pod_id(name, git)
|
161
105
|
pod_info = LSqliteDb.shared.query_pod_refs(id)
|
162
106
|
new_commit = pod_info.commit if pod_info
|
163
107
|
return [branch, new_commit]
|
164
108
|
end
|
165
|
-
new_commit = LUtils.commit_from_ls_remote(result, branch)
|
109
|
+
new_commit, new_branch = LUtils.commit_from_ls_remote(result, branch)
|
166
110
|
if new_commit
|
167
111
|
LSqliteDb.shared.insert_pod_refs(name, git, branch, tag, new_commit)
|
168
112
|
end
|
@@ -175,16 +119,17 @@ module LgPodPlugin
|
|
175
119
|
result = %x(git ls-remote --tags #{git})
|
176
120
|
end
|
177
121
|
unless result && result != ""
|
178
|
-
id = LPodLatestRefs.get_pod_id(name, git
|
122
|
+
id = LPodLatestRefs.get_pod_id(name, git)
|
179
123
|
pod_info = LSqliteDb.shared.query_pod_refs(id)
|
180
124
|
new_commit = pod_info.commit if pod_info
|
181
|
-
|
125
|
+
new_branch = pod_info.branch if pod_info
|
126
|
+
return [new_branch, new_commit]
|
182
127
|
end
|
183
|
-
new_commit = LUtils.commit_from_ls_remote(result, tag)
|
128
|
+
new_commit, new_branch = LUtils.commit_from_ls_remote(result, tag)
|
184
129
|
if new_commit
|
185
130
|
LSqliteDb.shared.insert_pod_refs(name, git, branch, tag, new_commit)
|
186
131
|
end
|
187
|
-
return [
|
132
|
+
return [new_branch, new_commit]
|
188
133
|
elsif commit
|
189
134
|
return nil, commit
|
190
135
|
else
|
@@ -195,16 +140,17 @@ module LgPodPlugin
|
|
195
140
|
result = %x(git ls-remote -- #{git})
|
196
141
|
end
|
197
142
|
unless result && result != ""
|
198
|
-
id = LPodLatestRefs.get_pod_id(name, git
|
143
|
+
id = LPodLatestRefs.get_pod_id(name, git)
|
199
144
|
pod_info = LSqliteDb.shared.query_pod_refs(id)
|
200
145
|
new_commit = pod_info.commit if pod_info
|
201
|
-
|
146
|
+
new_branch = pod_info.branch if pod_info
|
147
|
+
return [new_branch, new_commit]
|
202
148
|
end
|
203
|
-
new_commit = LUtils.commit_from_ls_remote(result, "HEAD")
|
149
|
+
new_commit, new_branch = LUtils.commit_from_ls_remote(result, "HEAD")
|
204
150
|
if new_commit
|
205
|
-
LSqliteDb.shared.insert_pod_refs(name, git,
|
151
|
+
LSqliteDb.shared.insert_pod_refs(name, git, new_branch, tag, new_commit)
|
206
152
|
end
|
207
|
-
return [
|
153
|
+
return [new_branch, new_commit]
|
208
154
|
end
|
209
155
|
end
|
210
156
|
|
@@ -6,6 +6,7 @@ require_relative 'request'
|
|
6
6
|
require_relative 'database'
|
7
7
|
require_relative 'downloader'
|
8
8
|
require 'cocoapods-core/podfile'
|
9
|
+
require_relative 'release-pod'
|
9
10
|
require_relative 'gitlab_download'
|
10
11
|
require 'cocoapods-core/podfile/target_definition'
|
11
12
|
|
@@ -37,11 +38,7 @@ module LgPodPlugin
|
|
37
38
|
tag = requirements[:tag]
|
38
39
|
commit = requirements[:commit]
|
39
40
|
branch = requirements[:branch]
|
40
|
-
hash_map = Hash.new
|
41
|
-
hash_map[:git] = git if git
|
42
|
-
hash_map[:tag] = tag if tag
|
43
|
-
hash_map[:commit] = commit if commit
|
44
|
-
hash_map[:branch] = branch if branch
|
41
|
+
hash_map = Hash.new.merge!(requirements)
|
45
42
|
if git
|
46
43
|
if tag
|
47
44
|
hash_map.delete(:branch)
|
@@ -80,77 +77,5 @@ module LgPodPlugin
|
|
80
77
|
end
|
81
78
|
end
|
82
79
|
|
83
|
-
public
|
84
|
-
# 执行pod install/update命令
|
85
|
-
def self.run_pod_install(update, libs, options = {})
|
86
|
-
verbose = options[:verbose]
|
87
|
-
repo_update = options[:repo_update]
|
88
|
-
if update
|
89
|
-
if libs.empty?
|
90
|
-
LgPodPlugin.log_red "no external pod update, you can use `pod update` to update --all pods"
|
91
|
-
system("bundle exec arch -x86_64 pod update #{repo_update ? "--repo-update" : "--no-repo-update"} #{verbose ? "--verbose" : ""} ")
|
92
|
-
else
|
93
|
-
pod_names = libs.join(" ")
|
94
|
-
LgPodPlugin.log_green libs.join("\n")
|
95
|
-
LgPodPlugin.log_green "bundle exec arch -x86_64 pod update #{repo_update ? "--repo-update" : "--no-repo-update"} #{verbose ? "--verbose" : ""} "
|
96
|
-
system("bundle exec arch -x86_64 pod update #{pod_names} #{repo_update ? "--repo-update" : "--no-repo-update"} #{verbose ? "--verbose" : ""} ")
|
97
|
-
end
|
98
|
-
else
|
99
|
-
LgPodPlugin.log_green "bundle exec arch -x86_64 pod install #{repo_update ? "--repo-update" : "--no-repo-update"} #{verbose ? "--verbose" : ""}"
|
100
|
-
system("bundle exec arch -x86_64 pod install #{repo_update ? "--repo-update" : "--no-repo-update"} #{verbose ? "--verbose" : ""}")
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
#执行lg install/update命令
|
105
|
-
def self.run(command, options = {})
|
106
|
-
work_space = Pathname(Dir.pwd)
|
107
|
-
LgPodPlugin.log_green "当前工作目录 #{work_space}"
|
108
|
-
podfile_path = work_space.join("Podfile")
|
109
|
-
unless podfile_path.exist?
|
110
|
-
LgPodPlugin.log_red "no such file `Podfile`"
|
111
|
-
return
|
112
|
-
end
|
113
|
-
LRequest.shared.is_update = (command == "update")
|
114
|
-
podfile = Pod::Podfile.from_file(podfile_path)
|
115
|
-
target = podfile.send(:current_target_definition)
|
116
|
-
local_pods = []
|
117
|
-
release_pods = []
|
118
|
-
install_hash_map = {}
|
119
|
-
children = target.children
|
120
|
-
children.each do |s|
|
121
|
-
internal_hash = s.send(:internal_hash)
|
122
|
-
next unless internal_hash.is_a?(Hash)
|
123
|
-
dependencies = internal_hash["dependencies"]
|
124
|
-
next unless dependencies.is_a?(Array)
|
125
|
-
dependencies.each { |e|
|
126
|
-
next unless e.is_a?(Hash)
|
127
|
-
next if (key = e.keys.first) == nil
|
128
|
-
next if (val = e[key].last) == nil
|
129
|
-
if val.is_a?(Hash)
|
130
|
-
next unless val[:podspec] == nil
|
131
|
-
path = val[:path]
|
132
|
-
local_pods.append(key) if path
|
133
|
-
next unless path == nil
|
134
|
-
install_hash_map[key] = val
|
135
|
-
else
|
136
|
-
release_pods.append(key)
|
137
|
-
end
|
138
|
-
}
|
139
|
-
end
|
140
|
-
LRequest.shared.libs = install_hash_map
|
141
|
-
LgPodPlugin.log_red "预下载Pod"
|
142
|
-
install_hash_map.each do |key, val|
|
143
|
-
Installer.new(podfile, key, val)
|
144
|
-
end
|
145
|
-
|
146
|
-
LgPodPlugin.log_red "开始安装pod"
|
147
|
-
#切换工作目录到当前工程下, 开始执行pod install
|
148
|
-
FileUtils.chdir(podfile_path.dirname)
|
149
|
-
libs = LRequest.shared.libs.keys.empty? ? (release_pods + local_pods) : (LRequest.shared.libs.keys + local_pods)
|
150
|
-
# 执行pod install/ update 方法入口
|
151
|
-
update_pod = (command == "update")
|
152
|
-
run_pod_install(update_pod, libs, options)
|
153
|
-
end
|
154
|
-
|
155
80
|
end
|
156
81
|
end
|
@@ -21,7 +21,7 @@ module LgPodPlugin
|
|
21
21
|
request = LCache.download_request(name, hash_map)
|
22
22
|
destination = LCache.path_for_pod(request, {})
|
23
23
|
cache_pod_spec = LCache.path_for_spec(request, {})
|
24
|
-
if File.exist?(destination) && File.exist?(cache_pod_spec)
|
24
|
+
if (File.exist?(destination) && File.exist?(cache_pod_spec))
|
25
25
|
false
|
26
26
|
else
|
27
27
|
true
|
@@ -34,7 +34,9 @@ module LgPodPlugin
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def self.download_request(name, params)
|
37
|
-
|
37
|
+
spec = LRequest.shared.checkout_options[:spec] ||= nil
|
38
|
+
released_pod = LRequest.shared.checkout_options[:release_pod] ||= false
|
39
|
+
Pod::Downloader::Request.new(spec: spec, released: released_pod, name: name, params: params)
|
38
40
|
end
|
39
41
|
|
40
42
|
def self.path_for_pod(request, slug_opts = {})
|
@@ -142,27 +144,21 @@ module LgPodPlugin
|
|
142
144
|
|
143
145
|
# 拷贝 pod 缓存文件到 sandbox
|
144
146
|
def self.cache_pod(name, target, options = {})
|
145
|
-
|
147
|
+
checkout_options = Hash.new.deep_merge(options).reject do |key, val|
|
146
148
|
!key || !val
|
147
149
|
end
|
148
|
-
request = LCache.download_request(name,
|
150
|
+
request = LCache.download_request(name, checkout_options)
|
149
151
|
result, pods_pecs = get_local_spec(request, target)
|
150
|
-
result.location = nil
|
151
|
-
result.checkout_options = hash_map
|
152
152
|
pods_pecs.each do |s_name, s_spec|
|
153
|
-
destination = path_for_pod(request, :name => name, :params =>
|
153
|
+
destination = path_for_pod(request, :name => name, :params => checkout_options)
|
154
154
|
unless File.exist?(destination)
|
155
155
|
LgPodPlugin.log_green "Copying #{name} from `#{target}` to `#{destination}` "
|
156
156
|
copy_and_clean(target, destination, s_spec)
|
157
157
|
end
|
158
|
-
cache_pod_spec = path_for_spec(request, :name => name, :params =>
|
158
|
+
cache_pod_spec = path_for_spec(request, :name => name, :params => checkout_options)
|
159
159
|
unless File.exist?(cache_pod_spec)
|
160
160
|
write_spec(s_spec, cache_pod_spec)
|
161
161
|
end
|
162
|
-
if request.name == s_name
|
163
|
-
result.location = destination
|
164
|
-
end
|
165
|
-
|
166
162
|
end
|
167
163
|
|
168
164
|
end
|
data/lib/lg_pod_plugin/l_util.rb
CHANGED
@@ -71,12 +71,23 @@ module LgPodPlugin
|
|
71
71
|
return nil if branch_name.nil?
|
72
72
|
encoded_branch_name = branch_name.dup.force_encoding(Encoding::ASCII_8BIT)
|
73
73
|
if branch_name == "HEAD"
|
74
|
-
|
74
|
+
match1 = %r{([a-z0-9]*)\t#{Regexp.quote(encoded_branch_name)}}.match(output)
|
75
|
+
sha = match1[1] unless match1.nil?
|
76
|
+
refs = output.split("\n")
|
77
|
+
return [sha, nil] unless refs.is_a?(Array)
|
78
|
+
refs.each do |element|
|
79
|
+
next if element.include?("HEAD") || element.include?("refs/tags")
|
80
|
+
next unless element.include?(sha)
|
81
|
+
find_branch = element.split("refs/heads/").last
|
82
|
+
return [sha, find_branch]
|
83
|
+
end
|
75
84
|
else
|
76
85
|
match = %r{([a-z0-9]*)\trefs\/(heads|tags)\/#{Regexp.quote(encoded_branch_name)}}.match(output)
|
86
|
+
sha = match[1] unless match.nil?
|
87
|
+
ref = match[0].split("refs/heads/").last unless match.nil?
|
88
|
+
return [sha, ref]
|
77
89
|
end
|
78
|
-
|
79
|
-
match[1] unless match.nil?
|
90
|
+
|
80
91
|
end
|
81
92
|
|
82
93
|
#截取git-url 拿到项目绝对名称 比如 l-base-ios
|
@@ -0,0 +1,90 @@
|
|
1
|
+
require 'cocoapods'
|
2
|
+
require 'cocoapods-core'
|
3
|
+
require_relative 'l_util'
|
4
|
+
require_relative 'l_cache'
|
5
|
+
|
6
|
+
module LgPodPlugin
|
7
|
+
|
8
|
+
class ReleasePod
|
9
|
+
|
10
|
+
def self.resolve_dependencies(work_space, podfile, lockfile, installer, external_pods)
|
11
|
+
installer.resolve_dependencies
|
12
|
+
analysis_result = installer.send(:analysis_result)
|
13
|
+
return unless analysis_result
|
14
|
+
root_specs = analysis_result.specifications.map(&:root).uniq
|
15
|
+
root_specs = root_specs.reject! do |spec|
|
16
|
+
spec_name = spec.send(:attributes_hash)["name"]
|
17
|
+
external_pods[spec_name] || external_pods[spec_name.split("/").first]
|
18
|
+
end unless external_pods.empty?
|
19
|
+
return unless root_specs
|
20
|
+
root_specs.sort_by(&:name).each do |spec|
|
21
|
+
attributes_hash = spec.send(:attributes_hash)
|
22
|
+
next unless attributes_hash.is_a?(Hash)
|
23
|
+
pod_name = attributes_hash["name"]
|
24
|
+
checksum = spec.send(:checksum)
|
25
|
+
if lockfile && checksum
|
26
|
+
internal_data = lockfile.send(:internal_data)
|
27
|
+
lock_checksums = internal_data["SPEC CHECKSUMS"] ||= {}
|
28
|
+
lock_checksum = lock_checksums[pod_name]
|
29
|
+
next if lock_checksum == checksum
|
30
|
+
end
|
31
|
+
pod_version = attributes_hash["version"]
|
32
|
+
source = attributes_hash['source']
|
33
|
+
next unless source.is_a?(Hash)
|
34
|
+
git = source["git"]
|
35
|
+
tag = source["tag"]
|
36
|
+
next unless (git && tag) && (git.include?("https://github.com"))
|
37
|
+
requirements = { :git => git, :tag => tag, :release_pod => true, :spec => spec}
|
38
|
+
LRequest.shared.checkout_options = requirements
|
39
|
+
next unless LCache.new(work_space).find_pod_cache(pod_name, { :git => git, :tag => tag })
|
40
|
+
LgPodPlugin::Installer.new(podfile, pod_name, requirements)
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.dependencies(installer)
|
46
|
+
installer.download_dependencies
|
47
|
+
installer.send(:validate_targets)
|
48
|
+
installation_options = installer.send(:installation_options)
|
49
|
+
skip_pods_project_generation = installation_options.send(:skip_pods_project_generation)
|
50
|
+
if skip_pods_project_generation
|
51
|
+
installer.show_skip_pods_project_generation_message
|
52
|
+
else
|
53
|
+
installer.integrate
|
54
|
+
end
|
55
|
+
installer.send(:write_lockfiles)
|
56
|
+
installer.send(:perform_post_install_actions)
|
57
|
+
end
|
58
|
+
|
59
|
+
def self.install_release_pod(work_space, podfile, repo_update, update, external_pods, local_pods)
|
60
|
+
#切换工作目录到当前工程下, 开始执行pod install
|
61
|
+
FileUtils.chdir(work_space)
|
62
|
+
# 安装 relase_pod
|
63
|
+
LgPodPlugin.log_green "Pre-downloading Release Pods"
|
64
|
+
Pod::Config.instance.verbose = true
|
65
|
+
pods_path = work_space.join('Pods')
|
66
|
+
lockfile_path = work_space.join("Podfile.lock")
|
67
|
+
lock_file = Pod::Lockfile.from_file(lockfile_path) if lockfile_path.exist?
|
68
|
+
sandobx = Pod::Sandbox.new(pods_path)
|
69
|
+
installer = Pod::Installer.new(sandobx, podfile, lock_file)
|
70
|
+
installer.repo_update = repo_update
|
71
|
+
if update
|
72
|
+
if external_pods.empty?
|
73
|
+
installer.update = true
|
74
|
+
else
|
75
|
+
pods = LRequest.shared.libs.merge!(local_pods)
|
76
|
+
installer.update = { :pods => pods.keys}
|
77
|
+
end
|
78
|
+
else
|
79
|
+
installer.update = false
|
80
|
+
end
|
81
|
+
installer.deployment = false
|
82
|
+
installer.clean_install = false
|
83
|
+
installer.prepare
|
84
|
+
resolve_dependencies(work_space, podfile, lock_file, installer, external_pods)
|
85
|
+
dependencies(installer)
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
@@ -1,7 +1,6 @@
|
|
1
|
-
require 'yaml'
|
2
|
-
require 'json'
|
3
1
|
require 'net/http'
|
4
2
|
require 'singleton'
|
3
|
+
require 'cocoapods-core'
|
5
4
|
require_relative 'l_config'
|
6
5
|
require_relative 'l_cache'
|
7
6
|
require_relative 'net-ping'
|
@@ -42,18 +41,32 @@ module LgPodPlugin
|
|
42
41
|
|
43
42
|
public
|
44
43
|
def get_lock_info
|
45
|
-
|
46
|
-
if
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
44
|
+
lock_file_path = self.workspace.join("Podfile.lock")
|
45
|
+
if lock_file_path.exist?
|
46
|
+
lock_file = Pod::Lockfile.from_file(lock_file_path)
|
47
|
+
internal_data = lock_file.send(:internal_data)
|
48
|
+
release_pods = Hash.new
|
49
|
+
pods = internal_data["PODS"] ||= {}
|
50
|
+
pods.each do |key, val|
|
51
|
+
if LUtils.is_string(key)
|
52
|
+
pod_name = key.split(" ").first if key.include?(" ")
|
53
|
+
tag = key[/(?<=\().*?(?=\))/]
|
54
|
+
release_pods[pod_name] = tag
|
55
|
+
elsif key.is_a?(Hash)
|
56
|
+
key_name = key.keys.first
|
57
|
+
next unless key_name
|
58
|
+
pod_name = key_name.split(" ").first if key_name.include?(" ")
|
59
|
+
tag = key_name[/(?<=\().*?(?=\))/]
|
60
|
+
release_pods[pod_name] = tag
|
61
|
+
else
|
62
|
+
next
|
63
|
+
end
|
51
64
|
end
|
52
|
-
external_source =
|
53
|
-
checkout_options =
|
54
|
-
{ "external_source" => external_source, "checkout_options" => checkout_options }
|
65
|
+
external_source = internal_data["EXTERNAL SOURCES"] ||= {}
|
66
|
+
checkout_options = internal_data["CHECKOUT OPTIONS"] ||= {}
|
67
|
+
{ "external_source" => external_source, "checkout_options" => checkout_options, "release_pods" => release_pods }
|
55
68
|
else
|
56
|
-
{ "external_source" => {}, "checkout_options" => {} }
|
69
|
+
{ "external_source" => {}, "checkout_options" => {}, "release_pods" => {} }
|
57
70
|
end
|
58
71
|
end
|
59
72
|
|
@@ -80,9 +93,11 @@ module LgPodPlugin
|
|
80
93
|
public
|
81
94
|
def get_lock_params
|
82
95
|
begin
|
96
|
+
_release_pods = self.lock_info["release_pods"] ||= {}
|
83
97
|
_external_source = self.lock_info["external_source"][self.name] ||= {}
|
84
98
|
_checkout_options = self.lock_info["checkout_options"][self.name] ||= {}
|
85
99
|
rescue
|
100
|
+
_release_pods = {}
|
86
101
|
_external_source = {}
|
87
102
|
_checkout_options = {}
|
88
103
|
end
|
@@ -92,23 +107,31 @@ module LgPodPlugin
|
|
92
107
|
commit = self.checkout_options[:commit]
|
93
108
|
branch = self.checkout_options[:branch]
|
94
109
|
|
95
|
-
|
110
|
+
lock_git = _external_source[:git] ||= _checkout_options[:git]
|
111
|
+
lock_tag = _external_source[:tag] ||= _release_pods[self.name]
|
96
112
|
lock_branch = _external_source[:branch] ||= ""
|
113
|
+
lock_commit = _checkout_options[:commit] ||= ""
|
114
|
+
|
97
115
|
hash_map = Hash.new
|
98
116
|
hash_map[:git] = git if git
|
99
117
|
if git && tag
|
100
118
|
hash_map[:tag] = tag
|
119
|
+
if tag != lock_tag
|
120
|
+
hash_map["is_delete"] = false
|
121
|
+
else
|
122
|
+
hash_map["is_delete"] = true
|
123
|
+
end
|
101
124
|
return hash_map
|
102
125
|
elsif git && branch
|
126
|
+
hash_map[:branch] = branch
|
103
127
|
if branch == lock_branch && !self.is_update
|
104
|
-
hash_map[:branch] = branch if branch
|
105
128
|
if lock_commit && !lock_commit.empty?
|
106
129
|
hash_map[:commit] = lock_commit
|
107
130
|
end
|
131
|
+
hash_map["is_delete"] = true
|
108
132
|
return hash_map
|
109
133
|
else
|
110
|
-
|
111
|
-
_, new_commit = LGitUtil.git_ls_remote_refs(self.name ,git, branch, tag, commit)
|
134
|
+
_, new_commit = LGitUtil.git_ls_remote_refs(self.name ,git, branch, nil, nil)
|
112
135
|
if new_commit && !new_commit.empty?
|
113
136
|
hash_map[:commit] = new_commit
|
114
137
|
elsif lock_commit && !lock_commit.empty?
|
@@ -123,28 +146,41 @@ module LgPodPlugin
|
|
123
146
|
end
|
124
147
|
end
|
125
148
|
elsif git && commit
|
126
|
-
|
149
|
+
if commit != lock_commit
|
150
|
+
hash_map["is_delete"] = false
|
151
|
+
else
|
152
|
+
hash_map["is_delete"] = true
|
153
|
+
end
|
154
|
+
hash_map[:commit] = commit
|
127
155
|
return hash_map
|
128
156
|
else
|
129
|
-
|
157
|
+
if lock_git && !self.is_update
|
158
|
+
id = LPodLatestRefs.get_pod_id(self.name, git)
|
159
|
+
pod_info = LSqliteDb.shared.query_pod_refs(id)
|
160
|
+
if pod_info && pod_info.commit
|
161
|
+
new_commit = pod_info.commit if pod_info
|
162
|
+
new_branch = pod_info.branch if pod_info
|
163
|
+
hash_map[:commit] = new_commit if new_commit
|
164
|
+
hash_map[:branch] = new_branch if new_branch
|
165
|
+
hash_map["is_delete"] = true
|
166
|
+
return hash_map
|
167
|
+
end
|
168
|
+
end
|
169
|
+
new_branch, new_commit = LGitUtil.git_ls_remote_refs(self.name, git, nil, nil, nil)
|
170
|
+
hash_map[:branch] = new_branch if new_branch
|
130
171
|
if new_commit && !new_commit.empty?
|
131
172
|
hash_map[:commit] = new_commit
|
132
|
-
elsif lock_commit && !lock_commit.empty?
|
133
|
-
hash_map[:commit] = lock_commit
|
134
173
|
end
|
135
|
-
if !new_commit ||
|
136
|
-
hash_map["is_delete"] = false
|
137
|
-
elsif (new_commit != lock_commit)
|
138
|
-
hash_map["is_delete"] = false
|
139
|
-
else
|
174
|
+
if !new_commit || new_commit.empty?
|
140
175
|
hash_map["is_delete"] = true
|
176
|
+
else
|
177
|
+
hash_map["is_delete"] = false
|
141
178
|
end
|
142
179
|
end
|
143
180
|
hash_map
|
144
181
|
end
|
145
182
|
|
146
183
|
public
|
147
|
-
|
148
184
|
#获取下载参数
|
149
185
|
def get_request_params
|
150
186
|
if self.lock_info == nil
|
@@ -0,0 +1,114 @@
|
|
1
|
+
require 'cocoapods'
|
2
|
+
require 'cocoapods-core'
|
3
|
+
require_relative 'l_util'
|
4
|
+
require_relative 'install'
|
5
|
+
require_relative 'request'
|
6
|
+
require_relative 'release-pod'
|
7
|
+
# require_relative 'specification'
|
8
|
+
|
9
|
+
module LgPodPlugin
|
10
|
+
class Main
|
11
|
+
|
12
|
+
public
|
13
|
+
|
14
|
+
def self.run(command, options = {})
|
15
|
+
is_update = (command == "update")
|
16
|
+
work_space = Pathname(Dir.pwd)
|
17
|
+
LgPodPlugin.log_green "当前工作目录 #{work_space}"
|
18
|
+
podfile_path = work_space.join("Podfile")
|
19
|
+
unless podfile_path.exist?
|
20
|
+
LgPodPlugin.log_red "no such file `Podfile`"
|
21
|
+
return
|
22
|
+
end
|
23
|
+
LRequest.shared.is_update = is_update
|
24
|
+
podfile = Pod::Podfile.from_file(podfile_path)
|
25
|
+
target = podfile.send(:current_target_definition)
|
26
|
+
local_pods = Hash.new
|
27
|
+
release_pods = Hash.new
|
28
|
+
install_hash_map = {}
|
29
|
+
children = target.children
|
30
|
+
children.each do |s|
|
31
|
+
internal_hash = s.send(:internal_hash)
|
32
|
+
next unless internal_hash.is_a?(Hash)
|
33
|
+
dependencies = internal_hash["dependencies"]
|
34
|
+
next unless dependencies.is_a?(Array)
|
35
|
+
dependencies.each { |e|
|
36
|
+
next unless e.is_a?(Hash)
|
37
|
+
next if (key = e.keys.first) == nil
|
38
|
+
pod_name = key
|
39
|
+
val = e[key].last
|
40
|
+
pod_name = key.split("/").first if key.include?("/")
|
41
|
+
next unless val.is_a?(Hash)
|
42
|
+
next unless val[:podspec] == nil
|
43
|
+
if path = val[:path]
|
44
|
+
local_pods[pod_name] = val
|
45
|
+
else
|
46
|
+
install_hash_map[pod_name] = val
|
47
|
+
end
|
48
|
+
}
|
49
|
+
end
|
50
|
+
# 安装开发版本pod
|
51
|
+
self.install_external_pod(work_space, podfile, Hash.new.merge!(install_hash_map))
|
52
|
+
# 下载 release_pod
|
53
|
+
repo_update = options[:repo_update] ||= false
|
54
|
+
external_pods = install_hash_map.merge!(local_pods)
|
55
|
+
ReleasePod.install_release_pod(work_space, podfile,repo_update, is_update, Hash.new.merge!(external_pods), local_pods)
|
56
|
+
# LgPodPlugin.log_green "开始安装Pod"
|
57
|
+
# #切换工作目录到当前工程下, 开始执行pod install
|
58
|
+
# FileUtils.chdir(work_space)
|
59
|
+
# libs = Set[]
|
60
|
+
# libs += Array(local_pods)
|
61
|
+
# libs += LRequest.shared.libs.keys
|
62
|
+
# 执行pod install/ update 方法入口
|
63
|
+
# update_pod = (command == "update")
|
64
|
+
# run_pod_install(update_pod, libs, options)
|
65
|
+
end
|
66
|
+
|
67
|
+
def self.install_external_pod(work_space, podfile, install_hash_map)
|
68
|
+
#下载 External pods
|
69
|
+
LRequest.shared.libs = Hash.new.merge!(install_hash_map)
|
70
|
+
LgPodPlugin.log_green "Pre-downloading External Pods" unless install_hash_map.empty?
|
71
|
+
install_hash_map.each do |key, val|
|
72
|
+
git = val[:git]
|
73
|
+
tag = val[:tag]
|
74
|
+
commit = val[:commit]
|
75
|
+
if git && tag
|
76
|
+
LRequest.shared.checkout_options = { :git => git, :tag => tag, :spec => nil, :release_pod => false }
|
77
|
+
unless LCache.new(work_space).find_pod_cache(key, { :git => git, :tag => tag })
|
78
|
+
LRequest.shared.libs.delete(key)
|
79
|
+
next
|
80
|
+
end
|
81
|
+
elsif git && commit
|
82
|
+
LRequest.shared.checkout_options = { :git => git, :commit => commit, :spec => nil, :release_pod => false }
|
83
|
+
unless LCache.new(work_space).find_pod_cache(key, { :git => git, :commit => commit })
|
84
|
+
LRequest.shared.libs.delete(key)
|
85
|
+
next
|
86
|
+
end
|
87
|
+
end
|
88
|
+
LgPodPlugin::Installer.new(podfile, key, val)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
public
|
93
|
+
# 执行pod install/update命令
|
94
|
+
def self.run_pod_install(update, libs, options = {})
|
95
|
+
verbose = options[:verbose]
|
96
|
+
repo_update = options[:repo_update]
|
97
|
+
if update
|
98
|
+
if libs.empty?
|
99
|
+
LgPodPlugin.log_red "no external pod update, you can use `pod update` to update --all pods"
|
100
|
+
system("bundle exec arch -x86_64 pod update #{repo_update ? "--repo-update" : "--no-repo-update"} #{verbose ? "--verbose" : ""} ")
|
101
|
+
else
|
102
|
+
pod_names = Array(libs).join(" ")
|
103
|
+
LgPodPlugin.log_green Array(libs).join("\n")
|
104
|
+
LgPodPlugin.log_green "bundle exec arch -x86_64 pod update #{repo_update ? "--repo-update" : "--no-repo-update"} #{verbose ? "--verbose" : ""} "
|
105
|
+
system("bundle exec arch -x86_64 pod update #{pod_names} #{repo_update ? "--repo-update" : "--no-repo-update"} #{verbose ? "--verbose" : ""} ")
|
106
|
+
end
|
107
|
+
else
|
108
|
+
LgPodPlugin.log_green "bundle exec arch -x86_64 pod install #{repo_update ? "--repo-update" : "--no-repo-update"} #{verbose ? "--verbose" : ""}"
|
109
|
+
system("bundle exec arch -x86_64 pod install #{repo_update ? "--repo-update" : "--no-repo-update"} #{verbose ? "--verbose" : ""}")
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
end
|
114
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'cocoapods'
|
2
|
+
require 'cocoapods-core'
|
3
|
+
require_relative 'l_util'
|
4
|
+
require_relative 'l_cache'
|
5
|
+
require_relative 'request'
|
6
|
+
require_relative 'install'
|
7
|
+
|
8
|
+
module LgPodPlugin
|
9
|
+
|
10
|
+
class Specification
|
11
|
+
attr_accessor :spec
|
12
|
+
attr_accessor :podfile
|
13
|
+
attr_accessor :work_space
|
14
|
+
attr_accessor :attributes_hash
|
15
|
+
attr_accessor :dependencies
|
16
|
+
def initialize(work_space, podfile, name = nil, version = nil)
|
17
|
+
config = Pod::Config.instance
|
18
|
+
sources_manager = config.send(:sources_manager)
|
19
|
+
dependency = Pod::Dependency.new(name, version)
|
20
|
+
set = sources_manager.search(dependency)
|
21
|
+
self.podfile = podfile
|
22
|
+
self.work_space = work_space
|
23
|
+
self.spec = set.send(:specification)
|
24
|
+
self.attributes_hash = self.spec.send(:attributes_hash)
|
25
|
+
self.dependencies = self.attributes_hash["dependencies"]
|
26
|
+
end
|
27
|
+
|
28
|
+
def install
|
29
|
+
pod_name = self.attributes_hash["name"]
|
30
|
+
if pod_name.include?("/")
|
31
|
+
real_name = pod_name.split("/").first
|
32
|
+
else
|
33
|
+
real_name = pod_name
|
34
|
+
end
|
35
|
+
return if LRequest.shared.libs[real_name]
|
36
|
+
pod_version = self.attributes_hash["version"]
|
37
|
+
prepare_command = self.attributes_hash['prepare_command']
|
38
|
+
return if prepare_command
|
39
|
+
source = self.attributes_hash['source']
|
40
|
+
return unless source.is_a?(Hash)
|
41
|
+
git = source["git"] ||= ""
|
42
|
+
tag = source["tag"] ||= ""
|
43
|
+
return unless git.include?("https://github.com")
|
44
|
+
requirements = {:git => git, :tag => tag, :spec => spec, :release_pod => true }
|
45
|
+
LRequest.shared.checkout_options = requirements
|
46
|
+
return unless LCache.new(self.work_space).find_pod_cache(real_name, {:git => git, :tag => tag})
|
47
|
+
LRequest.shared.libs[real_name] = requirements
|
48
|
+
LgPodPlugin::Installer.new(self.podfile, real_name, requirements)
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
end
|
data/lib/lg_pod_plugin.rb
CHANGED
@@ -3,6 +3,7 @@ require 'claide'
|
|
3
3
|
require 'cocoapods-downloader'
|
4
4
|
require "lg_pod_plugin/version"
|
5
5
|
require_relative 'lg_pod_plugin/log'
|
6
|
+
require_relative 'lg_pod_plugin/runner'
|
6
7
|
require_relative 'lg_pod_plugin/install'
|
7
8
|
require_relative 'lg_pod_plugin/request'
|
8
9
|
require_relative 'lg_pod_plugin/database'
|
@@ -14,13 +15,4 @@ require 'cocoapods-core/podfile/target_definition'
|
|
14
15
|
module LgPodPlugin
|
15
16
|
autoload :Command, 'command/command'
|
16
17
|
class Error < StandardError; end
|
17
|
-
|
18
|
-
def self.install(options = {})
|
19
|
-
LgPodPlugin::Installer.run("install", options)
|
20
|
-
end
|
21
|
-
|
22
|
-
def self.update(options = {})
|
23
|
-
LgPodPlugin::Installer.run("update", options)
|
24
|
-
end
|
25
|
-
|
26
18
|
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.
|
4
|
+
version: 1.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- dongzb01
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-10-
|
11
|
+
date: 2022-10-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: git
|
@@ -158,7 +158,10 @@ files:
|
|
158
158
|
- lib/lg_pod_plugin/log.rb
|
159
159
|
- lib/lg_pod_plugin/net-ping.rb
|
160
160
|
- lib/lg_pod_plugin/podspec.rb
|
161
|
+
- lib/lg_pod_plugin/release-pod.rb
|
161
162
|
- lib/lg_pod_plugin/request.rb
|
163
|
+
- lib/lg_pod_plugin/runner.rb
|
164
|
+
- lib/lg_pod_plugin/specification.rb
|
162
165
|
- lib/lg_pod_plugin/string.rb
|
163
166
|
- lib/lg_pod_plugin/version.rb
|
164
167
|
homepage: https://gitee.com/fmdb_beantech_admin/lg_pod_plugin
|