lg_pod_plugin 1.1.3 → 1.1.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/lg +2 -2
- data/lib/command/command.rb +1 -2
- data/lib/command/install.rb +7 -2
- data/lib/command/update.rb +4 -1
- data/lib/lg_pod_plugin/config/l_config.rb +59 -0
- data/lib/lg_pod_plugin/config/lockfile_model.rb +59 -0
- data/lib/lg_pod_plugin/config/podspec.rb +266 -0
- data/lib/lg_pod_plugin/config/target.rb +33 -0
- data/lib/lg_pod_plugin/{database.rb → db/database.rb} +76 -16
- data/lib/lg_pod_plugin/downloader/downloader.rb +156 -0
- data/lib/lg_pod_plugin/{l_cache.rb → downloader/l_cache.rb} +42 -23
- data/lib/lg_pod_plugin/downloader/request.rb +239 -0
- data/lib/lg_pod_plugin/git/git_clone.rb +85 -0
- data/lib/lg_pod_plugin/git/git_download.rb +53 -0
- data/lib/lg_pod_plugin/git/github_api.rb +137 -0
- data/lib/lg_pod_plugin/git/github_archive.rb +165 -0
- data/lib/lg_pod_plugin/git/gitlab_api.rb +266 -0
- data/lib/lg_pod_plugin/git/gitlab_archive.rb +180 -0
- data/lib/lg_pod_plugin/git/http_download.rb +39 -0
- data/lib/lg_pod_plugin/installer/PodDownload +0 -0
- data/lib/lg_pod_plugin/installer/concurrency.rb +21 -0
- data/lib/lg_pod_plugin/installer/install.rb +111 -0
- data/lib/lg_pod_plugin/installer/main.rb +63 -0
- data/lib/lg_pod_plugin/installer/project.rb +47 -0
- data/lib/lg_pod_plugin/net/l_uri.rb +87 -0
- data/lib/lg_pod_plugin/net/net-ping.rb +27 -0
- data/lib/lg_pod_plugin/pod/external_pod.rb +21 -0
- data/lib/lg_pod_plugin/pod/release-pod.rb +158 -0
- data/lib/lg_pod_plugin/utils/aes-crypt.rb +82 -0
- data/lib/lg_pod_plugin/{file_path.rb → utils/file_path.rb} +3 -5
- data/lib/lg_pod_plugin/utils/l_util.rb +133 -0
- data/lib/lg_pod_plugin/{log.rb → utils/log.rb} +1 -1
- data/lib/lg_pod_plugin/{string.rb → utils/string.rb} +0 -0
- data/lib/lg_pod_plugin/version.rb +1 -1
- data/lib/lg_pod_plugin.rb +24 -9
- data/lib/sqlite3-1.5.3-arm64-darwin/API_CHANGES.md +49 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/CHANGELOG.md +462 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/CONTRIBUTING.md +24 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/ChangeLog.cvs +88 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/README.md +235 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/dependencies.yml +14 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/ext/sqlite3/aggregator.c +274 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/ext/sqlite3/aggregator.h +12 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/ext/sqlite3/backup.c +168 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/ext/sqlite3/backup.h +15 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/ext/sqlite3/database.c +853 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/ext/sqlite3/database.h +17 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/ext/sqlite3/exception.c +98 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/ext/sqlite3/exception.h +8 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/ext/sqlite3/extconf.rb +251 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/ext/sqlite3/sqlite3.c +163 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/ext/sqlite3/sqlite3_ruby.h +48 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/ext/sqlite3/statement.c +442 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/ext/sqlite3/statement.h +16 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/faq/faq.md +431 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/faq/faq.rb +145 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/faq/faq.yml +426 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/2.6/sqlite3_native.bundle +0 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/2.7/sqlite3_native.bundle +0 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/3.0/sqlite3_native.bundle +0 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/3.1/sqlite3_native.bundle +0 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/constants.rb +50 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/database.rb +741 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/errors.rb +35 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/pragmas.rb +595 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/resultset.rb +187 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/statement.rb +145 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/translator.rb +118 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/value.rb +57 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/version.rb +23 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3.rb +15 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/test/helper.rb +27 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/test/test_backup.rb +33 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/test/test_collation.rb +82 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/test/test_database.rb +545 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/test/test_database_flags.rb +95 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/test/test_database_readonly.rb +36 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/test/test_database_readwrite.rb +41 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/test/test_deprecated.rb +44 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/test/test_encoding.rb +155 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/test/test_integration.rb +507 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/test/test_integration_aggregate.rb +336 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/test/test_integration_open_close.rb +30 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/test/test_integration_pending.rb +115 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/test/test_integration_resultset.rb +142 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/test/test_integration_statement.rb +194 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/test/test_result_set.rb +37 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/test/test_sqlite3.rb +30 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/test/test_statement.rb +263 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/test/test_statement_execute.rb +35 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/API_CHANGES.md +49 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/CHANGELOG.md +462 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/CONTRIBUTING.md +24 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/ChangeLog.cvs +88 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/README.md +235 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/dependencies.yml +14 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/ext/sqlite3/aggregator.c +274 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/ext/sqlite3/aggregator.h +12 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/ext/sqlite3/backup.c +168 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/ext/sqlite3/backup.h +15 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/ext/sqlite3/database.c +853 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/ext/sqlite3/database.h +17 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/ext/sqlite3/exception.c +98 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/ext/sqlite3/exception.h +8 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/ext/sqlite3/extconf.rb +251 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/ext/sqlite3/sqlite3.c +163 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/ext/sqlite3/sqlite3_ruby.h +48 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/ext/sqlite3/statement.c +442 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/ext/sqlite3/statement.h +16 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/faq/faq.md +431 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/faq/faq.rb +145 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/faq/faq.yml +426 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3/2.6/sqlite3_native.bundle +0 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3/2.7/sqlite3_native.bundle +0 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3/3.0/sqlite3_native.bundle +0 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3/3.1/sqlite3_native.bundle +0 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3/constants.rb +50 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3/database.rb +741 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3/errors.rb +35 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3/pragmas.rb +595 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3/resultset.rb +187 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3/statement.rb +145 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3/translator.rb +118 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3/value.rb +57 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3/version.rb +23 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3.rb +15 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/test/helper.rb +27 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_backup.rb +33 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_collation.rb +82 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_database.rb +545 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_database_flags.rb +95 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_database_readonly.rb +36 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_database_readwrite.rb +41 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_deprecated.rb +44 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_encoding.rb +155 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_integration.rb +507 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_integration_aggregate.rb +336 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_integration_open_close.rb +30 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_integration_pending.rb +115 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_integration_resultset.rb +142 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_integration_statement.rb +194 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_result_set.rb +37 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_sqlite3.rb +30 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_statement.rb +263 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_statement_execute.rb +35 -0
- metadata +146 -53
- data/lib/lg_pod_plugin/downloader.rb +0 -57
- data/lib/lg_pod_plugin/gitlab_api.rb +0 -147
- data/lib/lg_pod_plugin/gitlab_archive.rb +0 -352
- data/lib/lg_pod_plugin/gitlab_download.rb +0 -159
- data/lib/lg_pod_plugin/install.rb +0 -81
- data/lib/lg_pod_plugin/l_config.rb +0 -83
- data/lib/lg_pod_plugin/l_util.rb +0 -145
- data/lib/lg_pod_plugin/net-ping.rb +0 -41
- data/lib/lg_pod_plugin/podspec.rb +0 -156
- data/lib/lg_pod_plugin/release-pod.rb +0 -90
- data/lib/lg_pod_plugin/request.rb +0 -221
- data/lib/lg_pod_plugin/runner.rb +0 -114
- data/lib/lg_pod_plugin/specification.rb +0 -52
@@ -0,0 +1,180 @@
|
|
1
|
+
require 'uri'
|
2
|
+
require_relative 'git_download'
|
3
|
+
require_relative '../utils/l_util'
|
4
|
+
|
5
|
+
module LgPodPlugin
|
6
|
+
|
7
|
+
class GitLabArchive
|
8
|
+
|
9
|
+
private
|
10
|
+
attr_reader :source_files
|
11
|
+
attr_reader :podspec_content
|
12
|
+
attr_reader :checkout_options
|
13
|
+
|
14
|
+
public
|
15
|
+
REQUIRED_ATTRS ||= %i[git tag name commit branch config path spec].freeze
|
16
|
+
attr_accessor(*REQUIRED_ATTRS)
|
17
|
+
|
18
|
+
def initialize(checkout_options = {})
|
19
|
+
self.git = checkout_options[:git]
|
20
|
+
self.tag = checkout_options[:tag]
|
21
|
+
self.name = checkout_options[:name]
|
22
|
+
self.path = checkout_options[:path]
|
23
|
+
self.spec = checkout_options[:spec]
|
24
|
+
self.config = checkout_options[:config]
|
25
|
+
self.commit = checkout_options[:commit]
|
26
|
+
self.branch = checkout_options[:branch]
|
27
|
+
@checkout_options = checkout_options
|
28
|
+
end
|
29
|
+
|
30
|
+
def download
|
31
|
+
if self.git && self.tag
|
32
|
+
self.gitlab_download_tag_zip self.path
|
33
|
+
elsif self.git && self.branch
|
34
|
+
self.gitlab_download_branch_zip self.path
|
35
|
+
elsif self.git && self.commit
|
36
|
+
self.gitlab_download_commit_zip self.path
|
37
|
+
else
|
38
|
+
nil
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
# 下载某个文件zip格式
|
43
|
+
def download_archive_zip(sandbox_path)
|
44
|
+
host = self.config.host
|
45
|
+
project = self.config.project
|
46
|
+
token = self.config.access_token
|
47
|
+
unless host
|
48
|
+
http = Ping.new(project.web_url)
|
49
|
+
host = http.uri.scheme + "://" + http.uri.hostname
|
50
|
+
end
|
51
|
+
if self.git && self.tag
|
52
|
+
sha = self.tag
|
53
|
+
elsif self.git && self.branch
|
54
|
+
sha = self.branch
|
55
|
+
elsif self.git && self.commit
|
56
|
+
sha = self.commit
|
57
|
+
else
|
58
|
+
return nil
|
59
|
+
end
|
60
|
+
lg_spec = self.spec
|
61
|
+
unless lg_spec
|
62
|
+
podspec_filename = self.name + ".podspec"
|
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
|
+
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}"
|
79
|
+
end
|
80
|
+
@podspec_content = podspec_content
|
81
|
+
end
|
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#{"\\?"}" + "path#{"\\="}#{path}#{"\\&"}sha#{"\\="}#{sha}"
|
94
|
+
download_url += "\\&access_token\\=#{token}" if token
|
95
|
+
download_params.append({ "filename" => "#{path}.tar.bz2", "url" => download_url })
|
96
|
+
end
|
97
|
+
if download_params.empty?
|
98
|
+
download_url = host + "/api/v4/projects/" + "#{project.id}" + "/repository/archive.tar.bz2\\?" + "sha\\=#{sha}"
|
99
|
+
download_url += "\\&access_token\\=#{token}" if token
|
100
|
+
[{ "filename" => "#{self.name}.tar.bz2", "url" => download_url }]
|
101
|
+
else
|
102
|
+
download_params
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
# 根据branch 下载 zip 包
|
107
|
+
def gitlab_download_branch_zip(root_path)
|
108
|
+
token = self.config.access_token
|
109
|
+
download_urls = self.download_archive_zip(root_path)
|
110
|
+
return nil unless download_urls
|
111
|
+
download_params = Hash.new
|
112
|
+
download_params["token"] = token
|
113
|
+
download_params["name"] = self.name
|
114
|
+
download_params["type"] = "gitlab-branch"
|
115
|
+
if self.spec
|
116
|
+
download_params["podspec"] = self.spec
|
117
|
+
else
|
118
|
+
download_params["podspec_content"] = @podspec_content
|
119
|
+
end
|
120
|
+
download_params["path"] = root_path.to_path
|
121
|
+
if @source_files
|
122
|
+
download_params["source_files"] = @source_files
|
123
|
+
else
|
124
|
+
download_params["source_files"] = "All"
|
125
|
+
end
|
126
|
+
download_params["download_urls"] = download_urls
|
127
|
+
download_params
|
128
|
+
end
|
129
|
+
|
130
|
+
# 通过tag下载zip包
|
131
|
+
def gitlab_download_tag_zip(root_path)
|
132
|
+
token = self.config.access_token
|
133
|
+
download_urls = self.download_archive_zip(root_path)
|
134
|
+
return nil unless download_urls
|
135
|
+
download_params = Hash.new
|
136
|
+
download_params["token"] = token
|
137
|
+
download_params["name"] = self.name
|
138
|
+
download_params["type"] = "gitlab-tag"
|
139
|
+
if self.spec
|
140
|
+
download_params["podspec"] = self.spec
|
141
|
+
else
|
142
|
+
download_params["podspec_content"] = @podspec_content
|
143
|
+
end
|
144
|
+
download_params["path"] = root_path.to_path
|
145
|
+
if @source_files
|
146
|
+
download_params["source_files"] = @source_files
|
147
|
+
else
|
148
|
+
download_params["source_files"] = "All"
|
149
|
+
end
|
150
|
+
download_params["download_urls"] = download_urls
|
151
|
+
download_params
|
152
|
+
end
|
153
|
+
|
154
|
+
# 通过 commit 下载zip包
|
155
|
+
def gitlab_download_commit_zip(root_path)
|
156
|
+
token = self.config.access_token
|
157
|
+
download_urls = self.download_archive_zip(root_path)
|
158
|
+
return nil unless download_urls
|
159
|
+
download_params = Hash.new
|
160
|
+
download_params["token"] = token
|
161
|
+
download_params["name"] = self.name
|
162
|
+
if self.spec
|
163
|
+
download_params["podspec"] = self.spec
|
164
|
+
else
|
165
|
+
download_params["podspec_content"] = @podspec_content
|
166
|
+
end
|
167
|
+
download_params["type"] = "gitlab-commit"
|
168
|
+
download_params["path"] = root_path.to_path
|
169
|
+
if @source_files
|
170
|
+
download_params["source_files"] = @source_files
|
171
|
+
else
|
172
|
+
download_params["source_files"] = "All"
|
173
|
+
end
|
174
|
+
download_params["download_urls"] = download_urls
|
175
|
+
download_params
|
176
|
+
end
|
177
|
+
|
178
|
+
end
|
179
|
+
|
180
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'uri'
|
2
|
+
require_relative 'git_download'
|
3
|
+
require_relative '../utils/l_util'
|
4
|
+
require_relative '../config/podspec'
|
5
|
+
|
6
|
+
module LgPodPlugin
|
7
|
+
|
8
|
+
class HTTPDownloader
|
9
|
+
|
10
|
+
private
|
11
|
+
attr_reader :checkout_options
|
12
|
+
public
|
13
|
+
REQUIRED_ATTRS ||= %i[http name path lg_spec].freeze
|
14
|
+
attr_accessor(*REQUIRED_ATTRS)
|
15
|
+
def initialize(checkout_options = {})
|
16
|
+
self.name = checkout_options[:name]
|
17
|
+
self.path = checkout_options[:path]
|
18
|
+
self.http = checkout_options[:http]
|
19
|
+
self.lg_spec = checkout_options[:spec]
|
20
|
+
@checkout_options = checkout_options
|
21
|
+
end
|
22
|
+
|
23
|
+
def download
|
24
|
+
download_params = Hash.new
|
25
|
+
new_filename = self.http.split("/").last ||= "lg_temp_pod.tar"
|
26
|
+
download_params["path"] = self.path.to_path
|
27
|
+
download_params["name"] = self.name
|
28
|
+
download_params["type"] = "http"
|
29
|
+
download_params["download_urls"] = [{ "filename" => (new_filename ? new_filename : filename), "url" => http }]
|
30
|
+
if self.lg_spec
|
31
|
+
download_params["podspec"] = self.lg_spec
|
32
|
+
download_params["source_files"] = self.lg_spec.source_files.keys
|
33
|
+
end
|
34
|
+
download_params
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
Binary file
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'aescrypt'
|
3
|
+
|
4
|
+
module LgPodPlugin
|
5
|
+
|
6
|
+
class Concurrency
|
7
|
+
|
8
|
+
public
|
9
|
+
def self.async_download_pods(installers)
|
10
|
+
return if installers.empty?
|
11
|
+
json_text = installers.map(&:download_params).uniq.to_json
|
12
|
+
arvg = LUtils.encrypt json_text, "AZMpxzVxzbo3sFDLRZMpxzVxzbo3sFDZ"
|
13
|
+
return unless arvg && !arvg.empty?
|
14
|
+
pwd = Pathname.new(File.dirname(__FILE__)).realpath
|
15
|
+
FileUtils.chdir pwd
|
16
|
+
system("./PodDownload #{arvg}")
|
17
|
+
installers.each(&:copy_file_to_caches)
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,111 @@
|
|
1
|
+
require 'pp'
|
2
|
+
# require 'git'
|
3
|
+
require 'cgi'
|
4
|
+
require 'cocoapods'
|
5
|
+
require 'cocoapods-core'
|
6
|
+
|
7
|
+
module LgPodPlugin
|
8
|
+
|
9
|
+
class LPodInstaller
|
10
|
+
public
|
11
|
+
attr_accessor :download_params
|
12
|
+
private
|
13
|
+
attr_accessor :downloader
|
14
|
+
|
15
|
+
public
|
16
|
+
def initialize
|
17
|
+
end
|
18
|
+
|
19
|
+
#安装 pod
|
20
|
+
public
|
21
|
+
def install(pod)
|
22
|
+
hash = pod.checkout_options
|
23
|
+
path = hash[:path]
|
24
|
+
return nil if path
|
25
|
+
@downloader = LDownloader.new(pod)
|
26
|
+
self.download_params = @downloader.pre_download_pod
|
27
|
+
return self.download_params
|
28
|
+
end
|
29
|
+
|
30
|
+
public
|
31
|
+
def copy_file_to_caches
|
32
|
+
request = @downloader.send(:request)
|
33
|
+
name = request.send(:name)
|
34
|
+
params = Hash.new.merge!(request.params)
|
35
|
+
checkout_options = Hash.new.merge!(request.checkout_options)
|
36
|
+
commit = checkout_options[:commit] ||= params[:commit]
|
37
|
+
if request.lg_spec
|
38
|
+
cache_podspec = request.lg_spec.spec
|
39
|
+
else
|
40
|
+
cache_podspec = nil
|
41
|
+
end
|
42
|
+
|
43
|
+
unless cache_podspec
|
44
|
+
cache_podspec = LProject.shared.cache_specs[name]
|
45
|
+
request.lg_spec = LgPodPlugin::PodSpec.form_pod_spec cache_podspec if cache_podspec
|
46
|
+
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"]
|
63
|
+
local_spec_path = destination.glob("#{name}.podspec{,.json}").last
|
64
|
+
if local_spec_path && File.exist?(local_spec_path)
|
65
|
+
cache_podspec = Pod::Specification.from_file local_spec_path
|
66
|
+
if cache_podspec
|
67
|
+
LProject.shared.cache_specs[name] = cache_podspec
|
68
|
+
LCache.write_spec cache_podspec, cache_pod_spec_path
|
69
|
+
LCache.clean_pod_unused_files destination, cache_podspec
|
70
|
+
end
|
71
|
+
end
|
72
|
+
request.lg_spec = LgPodPlugin::PodSpec.form_pod_spec cache_podspec if cache_podspec
|
73
|
+
end
|
74
|
+
if pod_is_exist
|
75
|
+
is_delete = request.params["is_delete"] ||= false
|
76
|
+
LProject.shared.need_update_pods.delete(name) if is_delete
|
77
|
+
request.checkout_options.delete(:branch) if commit
|
78
|
+
request.checkout_options[:commit] = commit if commit
|
79
|
+
else
|
80
|
+
git = checkout_options[:git]
|
81
|
+
return unless git
|
82
|
+
cache_podspec = request.lg_spec.spec if request.lg_spec
|
83
|
+
branch = checkout_options[:branch]
|
84
|
+
checkout_options[:name] = name if name
|
85
|
+
unless branch
|
86
|
+
branch = self.request.params[:branch] if request.params[:branch]
|
87
|
+
checkout_options[:branch] = branch if branch
|
88
|
+
end
|
89
|
+
lg_pod_path = LFileManager.cache_workspace(LProject.shared.workspace)
|
90
|
+
lg_pod_path.mkdir(0700) unless lg_pod_path.exist?
|
91
|
+
checkout_options[:path] = lg_pod_path
|
92
|
+
FileUtils.chdir lg_pod_path
|
93
|
+
git_clone = GitRepository.new(checkout_options)
|
94
|
+
download_params = git_clone.download
|
95
|
+
return unless download_params && File.exist?(download_params)
|
96
|
+
FileUtils.chdir download_params
|
97
|
+
if request.single_git
|
98
|
+
LgPodPlugin::LCache.cache_pod(name, download_params, { :git => git }, cache_podspec, request.released_pod)
|
99
|
+
else
|
100
|
+
LgPodPlugin::LCache.cache_pod(name, download_params, request.get_cache_key_params, cache_podspec, request.released_pod)
|
101
|
+
end
|
102
|
+
FileUtils.chdir(LFileManager.download_director)
|
103
|
+
FileUtils.rm_rf(download_params)
|
104
|
+
request.checkout_options.delete(:branch) if commit
|
105
|
+
request.checkout_options[:commit] = commit if commit
|
106
|
+
end
|
107
|
+
|
108
|
+
end
|
109
|
+
|
110
|
+
end
|
111
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'cocoapods'
|
2
|
+
require 'cocoapods-core'
|
3
|
+
require_relative '../installer/concurrency'
|
4
|
+
|
5
|
+
module LgPodPlugin
|
6
|
+
|
7
|
+
class Main
|
8
|
+
|
9
|
+
#删除旧的换成目录
|
10
|
+
def self.clean_sandbox
|
11
|
+
sand_box = LFileManager.download_director
|
12
|
+
sand_box.each_child do |f|
|
13
|
+
ftype = File::ftype(f)
|
14
|
+
next unless ftype == "directory"
|
15
|
+
next if f.to_path.include?("database")
|
16
|
+
FileUtils.rm_rf f.to_path
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
public
|
21
|
+
def self.run(command, options = {})
|
22
|
+
self.clean_sandbox
|
23
|
+
workspace = Pathname(Dir.pwd)
|
24
|
+
update = (command == "update")
|
25
|
+
LSqliteDb.shared.init_database
|
26
|
+
repo_update = options[:repo_update] ||= false
|
27
|
+
LgPodPlugin.log_blue "当前工作目录 #{workspace}"
|
28
|
+
podfile_path = check_podfile_exist?(workspace)
|
29
|
+
return unless podfile_path
|
30
|
+
project = LProject.shared.setup(workspace, podfile_path, update, repo_update)
|
31
|
+
self.install_external_pod(project)
|
32
|
+
# # 安装开发版本pod
|
33
|
+
verbose = options[:verbose] ||= false
|
34
|
+
ReleasePod.install_release_pod(update, repo_update, verbose)
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.install_external_pod(project)
|
38
|
+
#下载 External pods
|
39
|
+
LgPodPlugin.log_blue "Pre-downloading External Pods" unless project.targets.empty?
|
40
|
+
all_installers = Hash.new
|
41
|
+
project.targets.each do |target|
|
42
|
+
target.dependencies.each do |_, pod|
|
43
|
+
installer = LPodInstaller.new
|
44
|
+
download_params = installer.install(pod)
|
45
|
+
if download_params
|
46
|
+
all_installers[download_params["name"]] = installer
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
# 通过 swift 可执行文件进行异步下载任务
|
51
|
+
LgPodPlugin::Concurrency.async_download_pods(all_installers.values)
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.check_podfile_exist?(workspace)
|
55
|
+
podfile_path = workspace.join("Podfile")
|
56
|
+
return podfile_path if podfile_path.exist?
|
57
|
+
podfile_path = workspace.join("Podfile.rb")
|
58
|
+
return podfile_path if podfile_path.exist?
|
59
|
+
raise Informative, "No `Podfile' found in the project directory."
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'singleton'
|
2
|
+
require 'cocoapods'
|
3
|
+
require 'cocoapods-core'
|
4
|
+
|
5
|
+
module LgPodPlugin
|
6
|
+
|
7
|
+
class LProject
|
8
|
+
include Singleton
|
9
|
+
|
10
|
+
attr_reader :podfile
|
11
|
+
attr_reader :lockfile
|
12
|
+
attr_reader :update
|
13
|
+
attr_reader :targets
|
14
|
+
attr_reader :workspace
|
15
|
+
attr_reader :repo_update
|
16
|
+
attr_reader :external_pods
|
17
|
+
attr_reader :need_update_pods
|
18
|
+
attr_accessor :cache_specs
|
19
|
+
def setup(workspace,podfile_path, update, repo_update)
|
20
|
+
@podfile = Pod::Podfile.from_file(podfile_path)
|
21
|
+
@update = update
|
22
|
+
@workspace = workspace
|
23
|
+
@repo_update = repo_update
|
24
|
+
lockfile_path = workspace.join("Podfile.lock")
|
25
|
+
@lockfile = Pod::Lockfile.from_file(lockfile_path) if lockfile_path.exist?
|
26
|
+
target = @podfile.send(:current_target_definition)
|
27
|
+
children = target.children
|
28
|
+
@targets = Array.new
|
29
|
+
external_pods = Hash.new
|
30
|
+
children.each do |s|
|
31
|
+
target = LPodTarget.new(s)
|
32
|
+
external_pods.merge!(target.dependencies)
|
33
|
+
@targets.append(target)
|
34
|
+
end
|
35
|
+
@cache_specs = Hash.new
|
36
|
+
@external_pods = Hash.new.merge!(external_pods)
|
37
|
+
@need_update_pods = Hash.new.merge!(external_pods)
|
38
|
+
self
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.shared
|
42
|
+
return LProject.instance
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
require 'uri'
|
2
|
+
require 'resolv'
|
3
|
+
|
4
|
+
module LgPodPlugin
|
5
|
+
|
6
|
+
class LURI
|
7
|
+
public
|
8
|
+
attr_reader :ip
|
9
|
+
attr_reader :path
|
10
|
+
attr_reader :host
|
11
|
+
attr_reader :scheme
|
12
|
+
attr_reader :hostname
|
13
|
+
private
|
14
|
+
attr_reader :uri
|
15
|
+
public
|
16
|
+
def initialize(git)
|
17
|
+
begin
|
18
|
+
uri = URI(git)
|
19
|
+
rescue => exception
|
20
|
+
if git.include?("git@") && git.include?(":")
|
21
|
+
match = %r{(?<=git@).*?(?=:)}.match(git)
|
22
|
+
host = match ? match[0] : ""
|
23
|
+
base_url = LUtils.get_gitlab_base_url(git)
|
24
|
+
path = base_url.split(":").last
|
25
|
+
uri = URI("http://#{host}/#{path}")
|
26
|
+
else
|
27
|
+
LgPodPlugin.log_red exception
|
28
|
+
uri = nil
|
29
|
+
end
|
30
|
+
end
|
31
|
+
return unless uri
|
32
|
+
ip_address = getaddress(uri)
|
33
|
+
return unless ip_address
|
34
|
+
if git.include?("ssh") || git.include?("git@gitlab") || git.include?("git@")
|
35
|
+
@uri = URI("http://#{ip_address}#{uri.path}")
|
36
|
+
else
|
37
|
+
@uri = URI("#{uri.scheme}://#{ip_address}#{uri.path}")
|
38
|
+
end
|
39
|
+
@ip = ip_address
|
40
|
+
@host = @uri.host ||= ""
|
41
|
+
@path = @uri.path ||= ""
|
42
|
+
@scheme = @uri.scheme ||= ""
|
43
|
+
@hostname = @scheme + "://" + @host
|
44
|
+
end
|
45
|
+
|
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)
|
56
|
+
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
|
64
|
+
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
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
public def to_s
|
80
|
+
return "" unless @uri
|
81
|
+
@uri.to_s
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
85
|
+
|
86
|
+
|
87
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'uri'
|
2
|
+
require 'resolv'
|
3
|
+
require "ipaddr"
|
4
|
+
|
5
|
+
module LgPodPlugin
|
6
|
+
|
7
|
+
class Ping
|
8
|
+
attr_accessor :ip
|
9
|
+
attr_accessor :network_ok
|
10
|
+
attr_accessor :uri
|
11
|
+
def initialize(url)
|
12
|
+
uri = LURI.new(url)
|
13
|
+
if uri.host
|
14
|
+
self.uri = uri
|
15
|
+
self.ip = uri.ip
|
16
|
+
self.network_ok = true
|
17
|
+
else
|
18
|
+
self.uri = nil
|
19
|
+
self.ip = nil
|
20
|
+
self.network_ok = false
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
|
2
|
+
require_relative '../config/podspec'
|
3
|
+
|
4
|
+
module LgPodPlugin
|
5
|
+
|
6
|
+
class ExternalPod
|
7
|
+
attr_reader :spec
|
8
|
+
attr_reader :target
|
9
|
+
attr_reader :name
|
10
|
+
attr_reader :released_pod
|
11
|
+
attr_reader :checkout_options
|
12
|
+
def initialize(target, name, hash)
|
13
|
+
@target = target
|
14
|
+
@released_pod = false
|
15
|
+
@checkout_options = hash
|
16
|
+
@name = LUtils.pod_real_name(name)
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|