lg_pod_plugin 1.1.2 → 1.1.4
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} +80 -28
- data/lib/lg_pod_plugin/downloader/downloader.rb +156 -0
- data/lib/lg_pod_plugin/{l_cache.rb → downloader/l_cache.rb} +44 -29
- data/lib/lg_pod_plugin/downloader/request.rb +233 -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 +265 -0
- data/lib/lg_pod_plugin/git/gitlab_archive.rb +177 -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 +88 -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 -17
- 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 -50
- data/lib/lg_pod_plugin/downloader.rb +0 -57
- data/lib/lg_pod_plugin/gitlab_api.rb +0 -151
- data/lib/lg_pod_plugin/gitlab_archive.rb +0 -294
- data/lib/lg_pod_plugin/gitlab_download.rb +0 -213
- data/lib/lg_pod_plugin/install.rb +0 -156
- data/lib/lg_pod_plugin/l_config.rb +0 -83
- data/lib/lg_pod_plugin/l_util.rb +0 -134
- data/lib/lg_pod_plugin/net-ping.rb +0 -41
- data/lib/lg_pod_plugin/podspec.rb +0 -156
- data/lib/lg_pod_plugin/request.rb +0 -185
@@ -0,0 +1,156 @@
|
|
1
|
+
|
2
|
+
require 'cocoapods-core'
|
3
|
+
require_relative '../git/http_download'
|
4
|
+
require_relative '../git/git_download'
|
5
|
+
|
6
|
+
module LgPodPlugin
|
7
|
+
|
8
|
+
class LDownloader
|
9
|
+
attr_accessor :request
|
10
|
+
|
11
|
+
def initialize(pod)
|
12
|
+
self.request = LRequest.new(pod)
|
13
|
+
end
|
14
|
+
|
15
|
+
# 预下载处理
|
16
|
+
def pre_download_pod
|
17
|
+
name = self.request.name
|
18
|
+
if self.request.lg_spec
|
19
|
+
podspec = self.request.lg_spec.spec
|
20
|
+
else
|
21
|
+
podspec = nil
|
22
|
+
end
|
23
|
+
checkout_options = Hash.new.merge!(self.request.checkout_options)
|
24
|
+
http = checkout_options[:http]
|
25
|
+
git = checkout_options[:git]
|
26
|
+
tag = checkout_options[:tag]
|
27
|
+
branch = checkout_options[:branch]
|
28
|
+
checkout_options[:name] = name if name
|
29
|
+
checkout_options[:spec] = self.request.lg_spec if podspec
|
30
|
+
unless branch
|
31
|
+
branch = self.request.params[:branch] if self.request.params[:branch]
|
32
|
+
checkout_options[:branch] = branch if branch
|
33
|
+
end
|
34
|
+
commit = checkout_options[:commit]
|
35
|
+
unless commit
|
36
|
+
commit = self.request.params[:commit] if self.request.params[:commit]
|
37
|
+
checkout_options[:commit] = commit if commit
|
38
|
+
end
|
39
|
+
if branch
|
40
|
+
LgPodPlugin.log_green "Using `#{name}` (#{branch})"
|
41
|
+
elsif tag
|
42
|
+
LgPodPlugin.log_green "Using `#{name}` (#{tag})"
|
43
|
+
elsif commit
|
44
|
+
LgPodPlugin.log_green "Using `#{name}` (#{commit})"
|
45
|
+
elsif http
|
46
|
+
version = checkout_options[:version]
|
47
|
+
LgPodPlugin.log_green "Using `#{name}` (#{version})"
|
48
|
+
else
|
49
|
+
LgPodPlugin.log_green "Using `#{name}`"
|
50
|
+
end
|
51
|
+
hash_map = self.request.get_cache_key_params
|
52
|
+
# 发现本地有缓存, 不需要更新缓存
|
53
|
+
if self.request.single_git
|
54
|
+
pod_is_exist, destination, cache_pod_spec = LCache.new.pod_cache_exist(name, hash_map, podspec, self.request.released_pod)
|
55
|
+
else
|
56
|
+
pod_is_exist, destination, cache_pod_spec = LCache.new.pod_cache_exist(name, hash_map, podspec, self.request.released_pod)
|
57
|
+
end
|
58
|
+
if pod_is_exist
|
59
|
+
is_delete = self.request.params["is_delete"] ||= false
|
60
|
+
LProject.shared.need_update_pods.delete(name) if is_delete
|
61
|
+
self.request.checkout_options.delete(:branch) if commit
|
62
|
+
self.request.checkout_options[:commit] = commit if commit
|
63
|
+
LgPodPlugin.log_green "find the cache of `#{name}`, you can use it now."
|
64
|
+
nil
|
65
|
+
else
|
66
|
+
LgPodPlugin.log_green "find the new commit of `#{name}`, Git downloading now."
|
67
|
+
# 本地 git 下载 pod 目录
|
68
|
+
download_params = self.pre_download_git_repository(checkout_options)
|
69
|
+
if download_params && download_params.is_a?(Hash)
|
70
|
+
download_params["destination"] = destination
|
71
|
+
download_params["cache_pod_spec_path"] = cache_pod_spec
|
72
|
+
podspec = download_params["podspec"]
|
73
|
+
podspec_content = download_params["podspec_content"]
|
74
|
+
if podspec
|
75
|
+
podspec_json = podspec.to_pretty_json
|
76
|
+
download_params["podspec_json"] = podspec_json if podspec
|
77
|
+
download_params["prepare_command"] = podspec.prepare_command if podspec
|
78
|
+
download_params.delete("podspec")
|
79
|
+
unless self.request.lg_spec
|
80
|
+
self.request.lg_spec = podspec
|
81
|
+
end
|
82
|
+
elsif podspec_content
|
83
|
+
path = download_params["path"]
|
84
|
+
podspec_path = path + "/#{name}.podspec"
|
85
|
+
begin
|
86
|
+
File.open(podspec_path,"w+") do|f|
|
87
|
+
f.write podspec_content
|
88
|
+
end
|
89
|
+
end
|
90
|
+
if File.exist?(podspec_path)
|
91
|
+
lg_spec = LgPodPlugin::PodSpec.form_file podspec_path
|
92
|
+
if lg_spec
|
93
|
+
self.request.lg_spec = lg_spec
|
94
|
+
download_params["podspec_json"] = lg_spec.to_pretty_json
|
95
|
+
download_params["source_files"] = lg_spec.source_files.keys
|
96
|
+
download_params["prepare_command"] = lg_spec.prepare_command if lg_spec.prepare_command
|
97
|
+
download_params.delete("podspec_content")
|
98
|
+
else
|
99
|
+
download_params["source_files"] = ["All"]
|
100
|
+
download_params["prepare_command"] = nil
|
101
|
+
download_params["podspec_json"] = podspec_content
|
102
|
+
download_params.delete("podspec_content")
|
103
|
+
end
|
104
|
+
end
|
105
|
+
FileUtils.rm_rf podspec_path
|
106
|
+
end
|
107
|
+
return download_params
|
108
|
+
elsif File.exist?(download_params.to_s) && download_params
|
109
|
+
FileUtils.chdir download_params
|
110
|
+
LgPodPlugin::LCache.cache_pod(name, download_params.to_path, { :git => git }, podspec, self.request.released_pod) if self.request.single_git
|
111
|
+
LgPodPlugin::LCache.cache_pod(name, download_params.to_path, self.request.get_cache_key_params,podspec, self.request.released_pod)
|
112
|
+
FileUtils.chdir(LFileManager.download_director)
|
113
|
+
FileUtils.rm_rf(download_params)
|
114
|
+
self.request.checkout_options.delete(:branch) if commit
|
115
|
+
self.request.checkout_options[:commit] = commit if commit
|
116
|
+
end
|
117
|
+
nil
|
118
|
+
end
|
119
|
+
|
120
|
+
end
|
121
|
+
|
122
|
+
def pre_download_git_repository(checkout_options = {})
|
123
|
+
lg_pod_path = LFileManager.cache_workspace(LProject.shared.workspace)
|
124
|
+
lg_pod_path.mkdir(0700) unless lg_pod_path.exist?
|
125
|
+
download_repository_strategy(lg_pod_path, checkout_options)
|
126
|
+
end
|
127
|
+
|
128
|
+
# 根据不同 git 源 选择下载策略
|
129
|
+
def download_repository_strategy(path, checkout_options = {})
|
130
|
+
FileUtils.chdir(path)
|
131
|
+
git = checkout_options[:git]
|
132
|
+
http = checkout_options[:http]
|
133
|
+
if http
|
134
|
+
begin
|
135
|
+
checkout_options[:path] = path
|
136
|
+
http_download = LgPodPlugin::HTTPDownloader.new(checkout_options)
|
137
|
+
http_download.download
|
138
|
+
rescue => exception
|
139
|
+
LgPodPlugin.log_red "异常信息: #{$!}"
|
140
|
+
LgPodPlugin.log_yellow " 异常位置: #{$@}"
|
141
|
+
return nil
|
142
|
+
end
|
143
|
+
elsif git
|
144
|
+
checkout_options[:path] = path
|
145
|
+
checkout_options[:config] = self.request.config if self.request.config
|
146
|
+
git_download = LgPodPlugin::GitDownloader.new(checkout_options)
|
147
|
+
return git_download.download
|
148
|
+
else
|
149
|
+
return nil
|
150
|
+
end
|
151
|
+
|
152
|
+
end
|
153
|
+
|
154
|
+
end
|
155
|
+
|
156
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'git'
|
1
|
+
# require 'git'
|
2
2
|
require 'cocoapods/downloader'
|
3
3
|
require 'cocoapods/downloader/cache'
|
4
4
|
require 'cocoapods/downloader/response'
|
@@ -7,25 +7,32 @@ require 'cocoapods/downloader/request'
|
|
7
7
|
module LgPodPlugin
|
8
8
|
|
9
9
|
class LCache
|
10
|
-
REQUIRED_ATTRS ||= %i[workspace cache_root].freeze
|
11
|
-
attr_accessor(*REQUIRED_ATTRS)
|
12
10
|
|
13
|
-
def initialize
|
14
|
-
|
15
|
-
|
11
|
+
def initialize
|
12
|
+
end
|
13
|
+
|
14
|
+
public
|
15
|
+
def pod_cache_exist(name, options, spec = nil, released_pod = false)
|
16
|
+
destination, cache_pod_spec = self.find_pod_cache name, options, spec, released_pod
|
17
|
+
target = LProject.shared.workspace.join("Pods").join(name)
|
18
|
+
if (File.exist?(destination) && !destination.children.empty?) && File.exist?(target) && !target.children.empty?
|
19
|
+
[true, destination, cache_pod_spec]
|
20
|
+
else
|
21
|
+
[false, destination, cache_pod_spec]
|
22
|
+
end
|
16
23
|
end
|
17
24
|
|
18
25
|
#判断缓存是否存在且有效命中缓存
|
19
|
-
|
26
|
+
public
|
27
|
+
def find_pod_cache(name, options, spec = nil, released_pod = false)
|
20
28
|
hash_map = Hash.new.merge!(options)
|
21
|
-
|
29
|
+
if hash_map.has_key?(:version)
|
30
|
+
hash_map.delete(:version)
|
31
|
+
end
|
32
|
+
request = LCache.download_request(name, hash_map, spec, released_pod)
|
22
33
|
destination = LCache.path_for_pod(request, {})
|
23
34
|
cache_pod_spec = LCache.path_for_spec(request, {})
|
24
|
-
|
25
|
-
false
|
26
|
-
else
|
27
|
-
true
|
28
|
-
end
|
35
|
+
[destination, cache_pod_spec]
|
29
36
|
end
|
30
37
|
|
31
38
|
def self.root_path
|
@@ -33,8 +40,12 @@ module LgPodPlugin
|
|
33
40
|
Pathname(path)
|
34
41
|
end
|
35
42
|
|
36
|
-
def self.download_request(name, params)
|
37
|
-
|
43
|
+
def self.download_request(name, params, spec = nil, released_pod = false)
|
44
|
+
if released_pod
|
45
|
+
Pod::Downloader::Request.new(spec: spec, released: true , name: name, params: params)
|
46
|
+
else
|
47
|
+
Pod::Downloader::Request.new(spec: nil, released: false , name: name, params: params)
|
48
|
+
end
|
38
49
|
end
|
39
50
|
|
40
51
|
def self.path_for_pod(request, slug_opts = {})
|
@@ -98,6 +109,14 @@ module LgPodPlugin
|
|
98
109
|
end
|
99
110
|
end
|
100
111
|
|
112
|
+
def self.clean_pod_unused_files(destination, spec)
|
113
|
+
specs_by_platform = group_sub_specs_by_platform(spec)
|
114
|
+
self.write_lock(destination) do
|
115
|
+
Pod::Installer::PodSourcePreparer.new(spec, destination).prepare!
|
116
|
+
Pod::Sandbox::PodDirCleaner.new(destination, specs_by_platform).clean!
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
101
120
|
def self.write_lock(location, &block)
|
102
121
|
self.lock(location, File::LOCK_EX, &block)
|
103
122
|
end
|
@@ -131,6 +150,7 @@ module LgPodPlugin
|
|
131
150
|
false
|
132
151
|
end
|
133
152
|
|
153
|
+
public
|
134
154
|
def self.write_spec(spec, path)
|
135
155
|
path.dirname.mkpath
|
136
156
|
Pod::Downloader::Cache.write_lock(path) do
|
@@ -141,28 +161,23 @@ module LgPodPlugin
|
|
141
161
|
end
|
142
162
|
|
143
163
|
# 拷贝 pod 缓存文件到 sandbox
|
144
|
-
|
145
|
-
|
164
|
+
public
|
165
|
+
def self.cache_pod(name, target, options = {}, spec = nil, released_pod = false)
|
166
|
+
checkout_options = Hash.new.deep_merge(options).reject do |key, val|
|
146
167
|
!key || !val
|
147
168
|
end
|
148
|
-
request = LCache.download_request(name,
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
destination = path_for_pod(request, :name => name, :params => hash_map)
|
154
|
-
unless File.exist?(destination)
|
169
|
+
request = LCache.download_request(name, checkout_options, spec, released_pod)
|
170
|
+
_, pods_pecs = get_local_spec(request, target)
|
171
|
+
pods_pecs.each do |_, s_spec|
|
172
|
+
destination = path_for_pod(request, :name => name, :params => checkout_options)
|
173
|
+
if !File.exist?(destination) || destination.children.empty?
|
155
174
|
LgPodPlugin.log_green "Copying #{name} from `#{target}` to `#{destination}` "
|
156
175
|
copy_and_clean(target, destination, s_spec)
|
157
176
|
end
|
158
|
-
cache_pod_spec = path_for_spec(request, :name => name, :params =>
|
177
|
+
cache_pod_spec = path_for_spec(request, :name => name, :params => checkout_options)
|
159
178
|
unless File.exist?(cache_pod_spec)
|
160
179
|
write_spec(s_spec, cache_pod_spec)
|
161
180
|
end
|
162
|
-
if request.name == s_name
|
163
|
-
result.location = destination
|
164
|
-
end
|
165
|
-
|
166
181
|
end
|
167
182
|
|
168
183
|
end
|
@@ -0,0 +1,233 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
# require 'singleton'
|
3
|
+
require 'cocoapods-core'
|
4
|
+
|
5
|
+
module LgPodPlugin
|
6
|
+
|
7
|
+
class LRequest
|
8
|
+
attr_reader :target
|
9
|
+
attr_reader :name
|
10
|
+
attr_accessor :lg_spec
|
11
|
+
attr_reader :released_pod
|
12
|
+
attr_accessor :single_git
|
13
|
+
attr_accessor :config
|
14
|
+
attr_accessor :net_ping
|
15
|
+
attr_accessor :params
|
16
|
+
attr_accessor :lockfile
|
17
|
+
attr_accessor :checkout_options
|
18
|
+
def initialize(pod)
|
19
|
+
@name = pod.name
|
20
|
+
@target = pod.target
|
21
|
+
@released_pod = pod.released_pod
|
22
|
+
@checkout_options = pod.checkout_options
|
23
|
+
if pod.spec
|
24
|
+
@lg_spec = pod.spec
|
25
|
+
end
|
26
|
+
self.preprocess_request
|
27
|
+
end
|
28
|
+
|
29
|
+
def preprocess_request
|
30
|
+
http = self.checkout_options[:http]
|
31
|
+
if http
|
32
|
+
self.config = nil
|
33
|
+
self.net_ping = nil
|
34
|
+
self.single_git = false
|
35
|
+
self.params = Hash.new
|
36
|
+
else
|
37
|
+
tag = self.checkout_options[:tag]
|
38
|
+
git = self.checkout_options[:git]
|
39
|
+
commit = self.checkout_options[:commit]
|
40
|
+
branch = self.checkout_options[:branch]
|
41
|
+
if (git && branch) || (git && commit) || (git && tag)
|
42
|
+
self.single_git = false
|
43
|
+
else
|
44
|
+
self.single_git = true
|
45
|
+
end
|
46
|
+
self.net_ping = Ping.new(git)
|
47
|
+
self.config = LConfig.get_config(git, self.net_ping.uri)
|
48
|
+
self.params = self.get_request_params
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
public
|
53
|
+
def get_lockfile
|
54
|
+
self.lockfile = LgPodPlugin::LockfileModel.from_file
|
55
|
+
end
|
56
|
+
|
57
|
+
# 获取缓存用的hash_map
|
58
|
+
public
|
59
|
+
def get_cache_key_params
|
60
|
+
options = Hash.new.merge!(self.checkout_options)
|
61
|
+
hash_map = Hash.new
|
62
|
+
http = options[:http]
|
63
|
+
if http
|
64
|
+
hash_map[:http] = http
|
65
|
+
return hash_map
|
66
|
+
end
|
67
|
+
git = options[:git] ||= self.params[:git]
|
68
|
+
tag = options[:tag] ||= self.params[:tag]
|
69
|
+
branch = options[:branch] ||= self.params[:branch]
|
70
|
+
commit = options[:commit] ||= self.params[:commit]
|
71
|
+
return hash_map unless git
|
72
|
+
hash_map[:git] = git
|
73
|
+
if git && commit
|
74
|
+
hash_map[:commit] = commit
|
75
|
+
elsif git && tag
|
76
|
+
hash_map[:tag] = tag
|
77
|
+
elsif git && branch && commit
|
78
|
+
hash_map[:commit] = commit
|
79
|
+
end
|
80
|
+
hash_map
|
81
|
+
end
|
82
|
+
|
83
|
+
public
|
84
|
+
def get_lock_params
|
85
|
+
begin
|
86
|
+
_release_pods = self.lockfile.release_pods ||= []
|
87
|
+
_external_source = (self.lockfile.external_sources_data[self.name])
|
88
|
+
_external_source = {} unless _external_source
|
89
|
+
_checkout_options = self.lockfile.checkout_options_for_pod_named(self.name)
|
90
|
+
rescue
|
91
|
+
_release_pods = {}
|
92
|
+
_external_source = {}
|
93
|
+
_checkout_options = {}
|
94
|
+
end
|
95
|
+
|
96
|
+
git = self.checkout_options[:git]
|
97
|
+
tag = self.checkout_options[:tag]
|
98
|
+
commit = self.checkout_options[:commit]
|
99
|
+
branch = self.checkout_options[:branch]
|
100
|
+
|
101
|
+
lock_git = _external_source[:git] ||= _checkout_options[:git]
|
102
|
+
lock_tag = _external_source[:tag] ||= _release_pods[self.name]
|
103
|
+
lock_branch = _external_source[:branch] ||= ""
|
104
|
+
lock_commit = _checkout_options[:commit] ||= ""
|
105
|
+
|
106
|
+
hash_map = Hash.new
|
107
|
+
hash_map[:git] = git if git
|
108
|
+
if git && tag
|
109
|
+
hash_map[:tag] = tag
|
110
|
+
if tag != lock_tag
|
111
|
+
hash_map["is_delete"] = false
|
112
|
+
else
|
113
|
+
hash_map["is_delete"] = true
|
114
|
+
end
|
115
|
+
return hash_map
|
116
|
+
elsif git && branch
|
117
|
+
hash_map[:branch] = branch
|
118
|
+
if lock_commit && !lock_commit.empty? && !LProject.shared.update
|
119
|
+
pod_info = LSqliteDb.shared.query_branch_with_sha(self.name, git, lock_commit)
|
120
|
+
lock_branch = pod_info[:branch] if lock_branch.empty?
|
121
|
+
new_commit = pod_info[:sha] ||= ""
|
122
|
+
if lock_branch == branch && new_commit == lock_commit
|
123
|
+
hash_map[:commit] = lock_commit
|
124
|
+
hash_map["is_delete"] = true
|
125
|
+
return hash_map
|
126
|
+
end
|
127
|
+
end
|
128
|
+
_, new_commit = git_ls_remote_refs(self.name, git, branch)
|
129
|
+
if new_commit && !new_commit.empty?
|
130
|
+
hash_map[:commit] = new_commit
|
131
|
+
elsif lock_commit && !lock_commit.empty?
|
132
|
+
hash_map[:commit] = lock_commit
|
133
|
+
end
|
134
|
+
if !new_commit || !lock_commit || new_commit.empty? || lock_commit.empty?
|
135
|
+
hash_map["is_delete"] = false
|
136
|
+
elsif new_commit != lock_commit
|
137
|
+
hash_map["is_delete"] = false
|
138
|
+
else
|
139
|
+
hash_map["is_delete"] = true
|
140
|
+
end
|
141
|
+
elsif git && commit
|
142
|
+
if commit != lock_commit
|
143
|
+
hash_map["is_delete"] = false
|
144
|
+
else
|
145
|
+
hash_map["is_delete"] = true
|
146
|
+
end
|
147
|
+
hash_map[:commit] = commit
|
148
|
+
return hash_map
|
149
|
+
else
|
150
|
+
if lock_git && !LProject.shared.update
|
151
|
+
id = LPodLatestRefs.get_pod_id(self.name, git)
|
152
|
+
pod_info = LSqliteDb.shared.query_pod_refs(id)
|
153
|
+
if pod_info&.commit
|
154
|
+
if pod_info
|
155
|
+
new_commit = pod_info.commit
|
156
|
+
else
|
157
|
+
new_commit = nil
|
158
|
+
end
|
159
|
+
if pod_info
|
160
|
+
new_branch = pod_info.branch
|
161
|
+
else
|
162
|
+
new_branch = nil
|
163
|
+
end
|
164
|
+
if new_commit
|
165
|
+
hash_map[:commit] = new_commit
|
166
|
+
end
|
167
|
+
if new_branch
|
168
|
+
hash_map[:branch] = new_branch
|
169
|
+
end
|
170
|
+
hash_map["is_delete"] = true
|
171
|
+
return hash_map
|
172
|
+
end
|
173
|
+
end
|
174
|
+
new_branch, new_commit = git_ls_remote_refs(self.name, git, nil)
|
175
|
+
hash_map[:branch] = new_branch if new_branch
|
176
|
+
if new_commit && !new_commit.empty?
|
177
|
+
hash_map[:commit] = new_commit
|
178
|
+
end
|
179
|
+
if !new_commit || new_commit.empty?
|
180
|
+
hash_map["is_delete"] = true
|
181
|
+
else
|
182
|
+
hash_map["is_delete"] = false
|
183
|
+
end
|
184
|
+
end
|
185
|
+
hash_map
|
186
|
+
end
|
187
|
+
|
188
|
+
public
|
189
|
+
|
190
|
+
#获取下载参数
|
191
|
+
def get_request_params
|
192
|
+
unless self.lockfile
|
193
|
+
self.lockfile = self.get_lockfile
|
194
|
+
end
|
195
|
+
Hash.new.merge!(self.get_lock_params)
|
196
|
+
end
|
197
|
+
|
198
|
+
# 获取最新的一条 commit 信息
|
199
|
+
def git_ls_remote_refs(name, git, branch)
|
200
|
+
ip = self.net_ping.ip
|
201
|
+
network_ok = self.net_ping.network_ok
|
202
|
+
return [nil, nil] unless (ip && network_ok)
|
203
|
+
if branch
|
204
|
+
new_commit, _ = GitLabAPI.request_github_refs_heads git, branch, self.net_ping.uri
|
205
|
+
unless new_commit
|
206
|
+
id = LPodLatestRefs.get_pod_id(name, git)
|
207
|
+
pod_info = LSqliteDb.shared.query_pod_refs(id)
|
208
|
+
new_commit = pod_info ? pod_info.commit : nil
|
209
|
+
return [branch, new_commit]
|
210
|
+
end
|
211
|
+
if new_commit
|
212
|
+
LSqliteDb.shared.insert_pod_refs(name, git, branch, nil, new_commit)
|
213
|
+
end
|
214
|
+
[branch, new_commit]
|
215
|
+
else
|
216
|
+
new_commit, new_branch = GitLabAPI.request_github_refs_heads git, nil, self.net_ping.uri
|
217
|
+
unless new_commit
|
218
|
+
id = LPodLatestRefs.get_pod_id(name, git)
|
219
|
+
pod_info = LSqliteDb.shared.query_pod_refs(id)
|
220
|
+
new_commit = pod_info ? pod_info.commit : nil
|
221
|
+
new_branch = pod_info ? pod_info.branch : nil
|
222
|
+
return [new_branch, new_commit]
|
223
|
+
end
|
224
|
+
if new_commit
|
225
|
+
LSqliteDb.shared.insert_pod_refs(name, git, new_branch, nil, new_commit)
|
226
|
+
end
|
227
|
+
[new_branch, new_commit]
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|
231
|
+
end
|
232
|
+
|
233
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
require 'uri'
|
2
|
+
require_relative '../utils/l_util'
|
3
|
+
|
4
|
+
module LgPodPlugin
|
5
|
+
|
6
|
+
class GitRepository
|
7
|
+
private
|
8
|
+
attr_reader :checkout_options
|
9
|
+
public
|
10
|
+
REQUIRED_ATTRS ||= %i[git tag name commit branch config path].freeze
|
11
|
+
attr_accessor(*REQUIRED_ATTRS)
|
12
|
+
def initialize(checkout_options = {})
|
13
|
+
self.git = checkout_options[:git]
|
14
|
+
self.tag = checkout_options[:tag]
|
15
|
+
self.name = checkout_options[:name]
|
16
|
+
self.path = checkout_options[:path]
|
17
|
+
self.config = checkout_options[:config]
|
18
|
+
self.commit = checkout_options[:commit]
|
19
|
+
self.branch = checkout_options[:branch]
|
20
|
+
@checkout_options = checkout_options
|
21
|
+
end
|
22
|
+
|
23
|
+
def download
|
24
|
+
if self.git && self.tag
|
25
|
+
self.git_clone_by_tag(self.path, "lg_temp_pod")
|
26
|
+
elsif self.git && self.branch
|
27
|
+
self.git_clone_by_branch self.path, "lg_temp_pod", self.branch
|
28
|
+
elsif self.git && self.commit
|
29
|
+
self.git_clone_by_commit self.path, "lg_temp_pod"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def git_clone_by_branch(path, temp_name, branch = nil)
|
34
|
+
new_branch = branch ? branch : nil
|
35
|
+
download_temp_path = path.join(temp_name)
|
36
|
+
if self.git && new_branch
|
37
|
+
git_download_command(temp_name, self.git, new_branch, nil)
|
38
|
+
else
|
39
|
+
git_download_command(temp_name, self.git, nil, nil)
|
40
|
+
if File.exist?(temp_name)
|
41
|
+
system("git -C #{download_temp_path.to_path} rev-parse HEAD")
|
42
|
+
end
|
43
|
+
end
|
44
|
+
download_temp_path
|
45
|
+
end
|
46
|
+
|
47
|
+
def git_clone_by_tag(path, temp_name)
|
48
|
+
git_download_command(temp_name, self.git, nil, self.tag)
|
49
|
+
path.join(temp_name)
|
50
|
+
end
|
51
|
+
|
52
|
+
# git clone commit
|
53
|
+
def git_clone_by_commit(path, temp_name)
|
54
|
+
Git.init(temp_name)
|
55
|
+
FileUtils.chdir(temp_name)
|
56
|
+
LgPodPlugin.log_blue "git clone #{self.git}"
|
57
|
+
system("git remote add origin #{self.git}")
|
58
|
+
system("git fetch origin #{self.commit}")
|
59
|
+
system("git reset --hard FETCH_HEAD")
|
60
|
+
path.join(temp_name)
|
61
|
+
end
|
62
|
+
|
63
|
+
# 封装 git clone命令
|
64
|
+
def git_download_command(temp_name, git, branch, tag)
|
65
|
+
cmds = ['git']
|
66
|
+
cmds << "clone"
|
67
|
+
cmds << "#{git}"
|
68
|
+
cmds << "#{temp_name} "
|
69
|
+
cmds << "--template="
|
70
|
+
cmds << "--single-branch --depth 1"
|
71
|
+
if branch
|
72
|
+
cmds << "--branch"
|
73
|
+
cmds << branch
|
74
|
+
elsif tag
|
75
|
+
cmds << "--branch"
|
76
|
+
cmds << tag
|
77
|
+
end
|
78
|
+
cmds_to_s = cmds.join(" ")
|
79
|
+
LgPodPlugin.log_blue cmds_to_s
|
80
|
+
system(cmds_to_s)
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require_relative 'git_clone'
|
2
|
+
require_relative 'gitlab_api'
|
3
|
+
require_relative 'gitlab_archive'
|
4
|
+
require_relative 'github_archive'
|
5
|
+
require_relative '../config/l_config'
|
6
|
+
require_relative '../downloader/request'
|
7
|
+
|
8
|
+
module LgPodPlugin
|
9
|
+
class GitDownloader
|
10
|
+
attr_accessor :git
|
11
|
+
attr_accessor :config
|
12
|
+
attr_accessor :checkout_options
|
13
|
+
def initialize(checkout_options = {})
|
14
|
+
self.git = checkout_options[:git]
|
15
|
+
self.config = checkout_options[:config]
|
16
|
+
self.checkout_options = checkout_options
|
17
|
+
end
|
18
|
+
|
19
|
+
#开始下载
|
20
|
+
public
|
21
|
+
def download
|
22
|
+
begin
|
23
|
+
if self.is_use_gitlab_archive_file(self.git)
|
24
|
+
git_archive = GitLabArchive.new(self.checkout_options)
|
25
|
+
return git_archive.download
|
26
|
+
elsif self.git.include?("https://github.com")
|
27
|
+
github_archive = GitHubArchive.new(self.checkout_options)
|
28
|
+
return github_archive.download
|
29
|
+
else
|
30
|
+
git_clone = GitRepository.new(checkout_options)
|
31
|
+
return git_clone.download
|
32
|
+
end
|
33
|
+
rescue
|
34
|
+
LgPodPlugin.log_red "异常信息: #{$!}"
|
35
|
+
LgPodPlugin.log_yellow " 异常位置: #{$@}"
|
36
|
+
git_clone = GitRepository.new(checkout_options)
|
37
|
+
return git_clone.download
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
# 是否能够使用 gitlab 下载 zip 文件
|
42
|
+
public
|
43
|
+
def is_use_gitlab_archive_file(git)
|
44
|
+
return false unless self.config&.access_token
|
45
|
+
return true if self.config.project
|
46
|
+
project_name = LUtils.get_git_project_name(git)
|
47
|
+
self.config.project = GitLabAPI.request_project_info(config.host, project_name, config.access_token, git)
|
48
|
+
(self.config.project != nil)
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
end
|
53
|
+
end
|