lg_pod_plugin 1.1.6.6 → 1.1.7.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/command.rb +1 -0
- data/lib/command/doctor.rb +31 -0
- data/lib/command/init.rb +36 -8
- data/lib/command/install.rb +1 -1
- data/lib/command/update.rb +1 -1
- data/lib/lg_pod_plugin/config/l_config.rb +6 -19
- data/lib/lg_pod_plugin/db/database.rb +116 -110
- data/lib/lg_pod_plugin/downloader/downloader.rb +7 -6
- data/lib/lg_pod_plugin/downloader/l_cache.rb +11 -2
- data/lib/lg_pod_plugin/downloader/overload_cache.rb +329 -0
- data/lib/lg_pod_plugin/downloader/request.rb +32 -32
- data/lib/lg_pod_plugin/git/gitlab_api.rb +102 -5
- data/lib/lg_pod_plugin/installer/PodDownload +0 -0
- data/lib/lg_pod_plugin/installer/install.rb +1 -4
- data/lib/lg_pod_plugin/installer/main.rb +0 -1
- data/lib/lg_pod_plugin/installer/project.rb +2 -7
- data/lib/lg_pod_plugin/net/l_uri.rb +0 -7
- data/lib/lg_pod_plugin/pod/release-pod.rb +11 -42
- data/lib/lg_pod_plugin/utils/l_util.rb +9 -9
- data/lib/lg_pod_plugin/version.rb +1 -1
- data/lib/lg_pod_plugin.rb +1 -0
- metadata +29 -119
- data/lib/sqlite3-1.5.3-arm64-darwin/API_CHANGES.md +0 -49
- data/lib/sqlite3-1.5.3-arm64-darwin/CHANGELOG.md +0 -462
- data/lib/sqlite3-1.5.3-arm64-darwin/CONTRIBUTING.md +0 -24
- data/lib/sqlite3-1.5.3-arm64-darwin/ChangeLog.cvs +0 -88
- data/lib/sqlite3-1.5.3-arm64-darwin/README.md +0 -235
- data/lib/sqlite3-1.5.3-arm64-darwin/dependencies.yml +0 -14
- data/lib/sqlite3-1.5.3-arm64-darwin/ext/sqlite3/aggregator.c +0 -274
- data/lib/sqlite3-1.5.3-arm64-darwin/ext/sqlite3/aggregator.h +0 -12
- data/lib/sqlite3-1.5.3-arm64-darwin/ext/sqlite3/backup.c +0 -168
- data/lib/sqlite3-1.5.3-arm64-darwin/ext/sqlite3/backup.h +0 -15
- data/lib/sqlite3-1.5.3-arm64-darwin/ext/sqlite3/database.c +0 -853
- data/lib/sqlite3-1.5.3-arm64-darwin/ext/sqlite3/database.h +0 -17
- data/lib/sqlite3-1.5.3-arm64-darwin/ext/sqlite3/exception.c +0 -98
- data/lib/sqlite3-1.5.3-arm64-darwin/ext/sqlite3/exception.h +0 -8
- data/lib/sqlite3-1.5.3-arm64-darwin/ext/sqlite3/extconf.rb +0 -251
- data/lib/sqlite3-1.5.3-arm64-darwin/ext/sqlite3/sqlite3.c +0 -163
- data/lib/sqlite3-1.5.3-arm64-darwin/ext/sqlite3/sqlite3_ruby.h +0 -48
- data/lib/sqlite3-1.5.3-arm64-darwin/ext/sqlite3/statement.c +0 -442
- data/lib/sqlite3-1.5.3-arm64-darwin/ext/sqlite3/statement.h +0 -16
- data/lib/sqlite3-1.5.3-arm64-darwin/faq/faq.md +0 -431
- data/lib/sqlite3-1.5.3-arm64-darwin/faq/faq.rb +0 -145
- data/lib/sqlite3-1.5.3-arm64-darwin/faq/faq.yml +0 -426
- 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/3.2/sqlite3_native.bundle +0 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/constants.rb +0 -50
- data/lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/database.rb +0 -741
- data/lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/errors.rb +0 -35
- data/lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/pragmas.rb +0 -595
- data/lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/resultset.rb +0 -187
- data/lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/statement.rb +0 -145
- data/lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/translator.rb +0 -118
- data/lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/value.rb +0 -57
- data/lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/version.rb +0 -23
- data/lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3.rb +0 -15
- data/lib/sqlite3-1.5.3-arm64-darwin/test/helper.rb +0 -27
- data/lib/sqlite3-1.5.3-arm64-darwin/test/test_backup.rb +0 -33
- data/lib/sqlite3-1.5.3-arm64-darwin/test/test_collation.rb +0 -82
- data/lib/sqlite3-1.5.3-arm64-darwin/test/test_database.rb +0 -545
- data/lib/sqlite3-1.5.3-arm64-darwin/test/test_database_flags.rb +0 -95
- data/lib/sqlite3-1.5.3-arm64-darwin/test/test_database_readonly.rb +0 -36
- data/lib/sqlite3-1.5.3-arm64-darwin/test/test_database_readwrite.rb +0 -41
- data/lib/sqlite3-1.5.3-arm64-darwin/test/test_deprecated.rb +0 -44
- data/lib/sqlite3-1.5.3-arm64-darwin/test/test_encoding.rb +0 -155
- data/lib/sqlite3-1.5.3-arm64-darwin/test/test_integration.rb +0 -507
- data/lib/sqlite3-1.5.3-arm64-darwin/test/test_integration_aggregate.rb +0 -336
- data/lib/sqlite3-1.5.3-arm64-darwin/test/test_integration_open_close.rb +0 -30
- data/lib/sqlite3-1.5.3-arm64-darwin/test/test_integration_pending.rb +0 -115
- data/lib/sqlite3-1.5.3-arm64-darwin/test/test_integration_resultset.rb +0 -142
- data/lib/sqlite3-1.5.3-arm64-darwin/test/test_integration_statement.rb +0 -194
- data/lib/sqlite3-1.5.3-arm64-darwin/test/test_result_set.rb +0 -37
- data/lib/sqlite3-1.5.3-arm64-darwin/test/test_sqlite3.rb +0 -30
- data/lib/sqlite3-1.5.3-arm64-darwin/test/test_statement.rb +0 -263
- data/lib/sqlite3-1.5.3-arm64-darwin/test/test_statement_execute.rb +0 -35
- data/lib/sqlite3-1.5.3-x86_64-darwin/API_CHANGES.md +0 -49
- data/lib/sqlite3-1.5.3-x86_64-darwin/CHANGELOG.md +0 -462
- data/lib/sqlite3-1.5.3-x86_64-darwin/CONTRIBUTING.md +0 -24
- data/lib/sqlite3-1.5.3-x86_64-darwin/ChangeLog.cvs +0 -88
- data/lib/sqlite3-1.5.3-x86_64-darwin/README.md +0 -235
- data/lib/sqlite3-1.5.3-x86_64-darwin/dependencies.yml +0 -14
- data/lib/sqlite3-1.5.3-x86_64-darwin/ext/sqlite3/aggregator.c +0 -274
- data/lib/sqlite3-1.5.3-x86_64-darwin/ext/sqlite3/aggregator.h +0 -12
- data/lib/sqlite3-1.5.3-x86_64-darwin/ext/sqlite3/backup.c +0 -168
- data/lib/sqlite3-1.5.3-x86_64-darwin/ext/sqlite3/backup.h +0 -15
- data/lib/sqlite3-1.5.3-x86_64-darwin/ext/sqlite3/database.c +0 -853
- data/lib/sqlite3-1.5.3-x86_64-darwin/ext/sqlite3/database.h +0 -17
- data/lib/sqlite3-1.5.3-x86_64-darwin/ext/sqlite3/exception.c +0 -98
- data/lib/sqlite3-1.5.3-x86_64-darwin/ext/sqlite3/exception.h +0 -8
- data/lib/sqlite3-1.5.3-x86_64-darwin/ext/sqlite3/extconf.rb +0 -251
- data/lib/sqlite3-1.5.3-x86_64-darwin/ext/sqlite3/sqlite3.c +0 -163
- data/lib/sqlite3-1.5.3-x86_64-darwin/ext/sqlite3/sqlite3_ruby.h +0 -48
- data/lib/sqlite3-1.5.3-x86_64-darwin/ext/sqlite3/statement.c +0 -442
- data/lib/sqlite3-1.5.3-x86_64-darwin/ext/sqlite3/statement.h +0 -16
- data/lib/sqlite3-1.5.3-x86_64-darwin/faq/faq.md +0 -431
- data/lib/sqlite3-1.5.3-x86_64-darwin/faq/faq.rb +0 -145
- data/lib/sqlite3-1.5.3-x86_64-darwin/faq/faq.yml +0 -426
- 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/3.2/sqlite3_native.bundle +0 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3/constants.rb +0 -50
- data/lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3/database.rb +0 -741
- data/lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3/errors.rb +0 -35
- data/lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3/pragmas.rb +0 -595
- data/lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3/resultset.rb +0 -187
- data/lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3/statement.rb +0 -145
- data/lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3/translator.rb +0 -118
- data/lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3/value.rb +0 -57
- data/lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3/version.rb +0 -23
- data/lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3.rb +0 -15
- data/lib/sqlite3-1.5.3-x86_64-darwin/test/helper.rb +0 -27
- data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_backup.rb +0 -33
- data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_collation.rb +0 -82
- data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_database.rb +0 -545
- data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_database_flags.rb +0 -95
- data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_database_readonly.rb +0 -36
- data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_database_readwrite.rb +0 -41
- data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_deprecated.rb +0 -44
- data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_encoding.rb +0 -155
- data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_integration.rb +0 -507
- data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_integration_aggregate.rb +0 -336
- data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_integration_open_close.rb +0 -30
- data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_integration_pending.rb +0 -115
- data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_integration_resultset.rb +0 -142
- data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_integration_statement.rb +0 -194
- data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_result_set.rb +0 -37
- data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_sqlite3.rb +0 -30
- data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_statement.rb +0 -263
- data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_statement_execute.rb +0 -35
@@ -0,0 +1,329 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'cocoapods'
|
4
|
+
require 'fileutils'
|
5
|
+
require 'tmpdir'
|
6
|
+
|
7
|
+
module Pod
|
8
|
+
module Downloader
|
9
|
+
# The class responsible for managing Pod downloads, transparently caching
|
10
|
+
# them in a cache directory.
|
11
|
+
#
|
12
|
+
class Cache
|
13
|
+
# @return [Pathname] The root directory where this cache store its
|
14
|
+
# downloads.
|
15
|
+
#
|
16
|
+
attr_reader :root
|
17
|
+
|
18
|
+
# Initialize a new instance
|
19
|
+
#
|
20
|
+
# @param [Pathname,String] root
|
21
|
+
# see {#root}
|
22
|
+
#
|
23
|
+
def initialize(root)
|
24
|
+
@root = Pathname(root)
|
25
|
+
ensure_matching_version
|
26
|
+
end
|
27
|
+
|
28
|
+
# Downloads the Pod from the given `request`
|
29
|
+
#
|
30
|
+
# @param [Request] request
|
31
|
+
# the request to be downloaded.
|
32
|
+
#
|
33
|
+
# @return [Response] the response from downloading `request`
|
34
|
+
#
|
35
|
+
def download_pod(request)
|
36
|
+
cached_pod(request) || uncached_pod(request)
|
37
|
+
rescue Informative
|
38
|
+
raise
|
39
|
+
rescue
|
40
|
+
UI.puts("\n[!] Error installing #{request.name}".red)
|
41
|
+
raise
|
42
|
+
end
|
43
|
+
|
44
|
+
# @return [Hash<String, Hash<Symbol, String>>]
|
45
|
+
# A hash whose keys are the pod name
|
46
|
+
# And values are a hash with the following keys:
|
47
|
+
# :spec_file : path to the spec file
|
48
|
+
# :name : name of the pod
|
49
|
+
# :version : pod version
|
50
|
+
# :release : boolean to tell if that's a release pod
|
51
|
+
# :slug : the slug path where the pod cache is located
|
52
|
+
#
|
53
|
+
def cache_descriptors_per_pod
|
54
|
+
specs_dir = root + 'Specs'
|
55
|
+
release_specs_dir = specs_dir + 'Release'
|
56
|
+
return {} unless specs_dir.exist?
|
57
|
+
|
58
|
+
spec_paths = specs_dir.find.select { |f| f.fnmatch('*.podspec.json') }
|
59
|
+
spec_paths.reduce({}) do |hash, spec_path|
|
60
|
+
spec = Specification.from_file(spec_path)
|
61
|
+
hash[spec.name] ||= []
|
62
|
+
is_release = spec_path.to_s.start_with?(release_specs_dir.to_s)
|
63
|
+
request = Downloader::Request.new(:spec => spec, :released => is_release)
|
64
|
+
hash[spec.name] << {
|
65
|
+
:spec_file => spec_path,
|
66
|
+
:name => spec.name,
|
67
|
+
:version => spec.version,
|
68
|
+
:release => is_release,
|
69
|
+
:slug => root + request.slug,
|
70
|
+
}
|
71
|
+
hash
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
# Convenience method for acquiring a shared lock to safely read from the
|
76
|
+
# cache. See `Cache.lock` for more details.
|
77
|
+
#
|
78
|
+
# @param [Pathname] location
|
79
|
+
# the path to require a lock for.
|
80
|
+
#
|
81
|
+
# @param [block] &block
|
82
|
+
# the block to execute inside the lock.
|
83
|
+
#
|
84
|
+
# @return [void]
|
85
|
+
#
|
86
|
+
def self.read_lock(location, &block)
|
87
|
+
Cache.lock(location, File::LOCK_SH, &block)
|
88
|
+
end
|
89
|
+
|
90
|
+
# Convenience method for acquiring an exclusive lock to safely write to
|
91
|
+
# the cache. See `Cache.lock` for more details.
|
92
|
+
#
|
93
|
+
# @param [Pathname] location
|
94
|
+
# the path to require a lock for.
|
95
|
+
#
|
96
|
+
# @param [block] &block
|
97
|
+
# the block to execute inside the lock.
|
98
|
+
#
|
99
|
+
# @return [void]
|
100
|
+
#
|
101
|
+
def self.write_lock(location, &block)
|
102
|
+
Cache.lock(location, File::LOCK_EX, &block)
|
103
|
+
end
|
104
|
+
|
105
|
+
# Creates a .lock file at `location`, aquires a lock of type
|
106
|
+
# `lock_type`, checks that it is valid, and executes passed block while
|
107
|
+
# holding on to that lock. Afterwards, the .lock file is deleted, which is
|
108
|
+
# why validation of the lock is necessary, as you might have a lock on a
|
109
|
+
# file that doesn't exist on the filesystem anymore.
|
110
|
+
#
|
111
|
+
# @param [Pathname] location
|
112
|
+
# the path to require a lock for.
|
113
|
+
#
|
114
|
+
# @param [locking_constant] lock_type
|
115
|
+
# the type of lock, either exclusive (File::LOCK_EX) or shared
|
116
|
+
# (File::LOCK_SH).
|
117
|
+
#
|
118
|
+
# @return [void]
|
119
|
+
#
|
120
|
+
def self.lock(location, lock_type)
|
121
|
+
raise ArgumentError, 'no block given' unless block_given?
|
122
|
+
lockfile = "#{location}.lock"
|
123
|
+
f = nil
|
124
|
+
loop do
|
125
|
+
f.close if f
|
126
|
+
f = File.open(lockfile, File::CREAT, 0o644)
|
127
|
+
f.flock(lock_type)
|
128
|
+
break if Cache.valid_lock?(f, lockfile)
|
129
|
+
end
|
130
|
+
begin
|
131
|
+
yield location
|
132
|
+
ensure
|
133
|
+
if lock_type == File::LOCK_SH
|
134
|
+
f.flock(File::LOCK_EX)
|
135
|
+
File.delete(lockfile) if Cache.valid_lock?(f, lockfile)
|
136
|
+
else
|
137
|
+
File.delete(lockfile)
|
138
|
+
end
|
139
|
+
f.close
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
# Checks that the lock is on a file that still exists on the filesystem.
|
144
|
+
#
|
145
|
+
# @param [File] file
|
146
|
+
# the actual file that we have a lock for.
|
147
|
+
#
|
148
|
+
# @param [String] filename
|
149
|
+
# the filename of the file that we have a lock for.
|
150
|
+
#
|
151
|
+
# @return [Boolean]
|
152
|
+
# true if `filename` still exists and is the same file as `file`
|
153
|
+
#
|
154
|
+
def self.valid_lock?(file, filename)
|
155
|
+
file.stat.ino == File.stat(filename).ino
|
156
|
+
rescue Errno::ENOENT
|
157
|
+
false
|
158
|
+
end
|
159
|
+
|
160
|
+
private
|
161
|
+
|
162
|
+
# Ensures the cache on disk was created with the same CocoaPods version as
|
163
|
+
# is currently running.
|
164
|
+
#
|
165
|
+
# @return [Void]
|
166
|
+
#
|
167
|
+
def ensure_matching_version
|
168
|
+
version_file = root + 'VERSION'
|
169
|
+
if version_file.file?
|
170
|
+
version = version_file.read.strip
|
171
|
+
else
|
172
|
+
version = Pod::VERSION
|
173
|
+
end
|
174
|
+
pod_version = %x(bundle exec pod --version).split("\n").first
|
175
|
+
if version != pod_version
|
176
|
+
version = pod_version
|
177
|
+
version_file.open('w') { |f| f << version }
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
# @param [Request] request
|
182
|
+
# the request to be downloaded.
|
183
|
+
#
|
184
|
+
# @param [Hash<Symbol,String>] slug_opts
|
185
|
+
# the download options that should be used in constructing the
|
186
|
+
# cache slug for this request.
|
187
|
+
#
|
188
|
+
# @return [Pathname] The path for the Pod downloaded from the given
|
189
|
+
# `request`.
|
190
|
+
#
|
191
|
+
def path_for_pod(request, slug_opts = {})
|
192
|
+
root + request.slug(**slug_opts)
|
193
|
+
end
|
194
|
+
|
195
|
+
# @param [Request] request
|
196
|
+
# the request to be downloaded.
|
197
|
+
#
|
198
|
+
# @param [Hash<Symbol,String>] slug_opts
|
199
|
+
# the download options that should be used in constructing the
|
200
|
+
# cache slug for this request.
|
201
|
+
#
|
202
|
+
# @return [Pathname] The path for the podspec downloaded from the given
|
203
|
+
# `request`.
|
204
|
+
#
|
205
|
+
def path_for_spec(request, slug_opts = {})
|
206
|
+
path = root + 'Specs' + request.slug(**slug_opts)
|
207
|
+
Pathname.new(path.to_path + '.podspec.json')
|
208
|
+
end
|
209
|
+
|
210
|
+
# @param [Request] request
|
211
|
+
# the request to be downloaded.
|
212
|
+
#
|
213
|
+
# @return [Response] The download response for the given `request` that
|
214
|
+
# was found in the download cache.
|
215
|
+
#
|
216
|
+
def cached_pod(request)
|
217
|
+
cached_spec = cached_spec(request)
|
218
|
+
path = path_for_pod(request)
|
219
|
+
|
220
|
+
return unless cached_spec && path.directory?
|
221
|
+
spec = request.spec || cached_spec
|
222
|
+
Response.new(path, spec, request.params)
|
223
|
+
end
|
224
|
+
|
225
|
+
# @param [Request] request
|
226
|
+
# the request to be downloaded.
|
227
|
+
#
|
228
|
+
# @return [Specification] The cached specification for the given
|
229
|
+
# `request`.
|
230
|
+
#
|
231
|
+
def cached_spec(request)
|
232
|
+
path = path_for_spec(request)
|
233
|
+
path.file? && Specification.from_file(path)
|
234
|
+
rescue JSON::ParserError
|
235
|
+
nil
|
236
|
+
end
|
237
|
+
|
238
|
+
# @param [Request] request
|
239
|
+
# the request to be downloaded.
|
240
|
+
#
|
241
|
+
# @return [Response] The download response for the given `request` that
|
242
|
+
# was not found in the download cache.
|
243
|
+
#
|
244
|
+
def uncached_pod(request)
|
245
|
+
in_tmpdir do |target|
|
246
|
+
result, podspecs = download(request, target)
|
247
|
+
result.location = nil
|
248
|
+
|
249
|
+
podspecs.each do |name, spec|
|
250
|
+
destination = path_for_pod(request, :name => name, :params => result.checkout_options)
|
251
|
+
copy_and_clean(target, destination, spec)
|
252
|
+
write_spec(spec, path_for_spec(request, :name => name, :params => result.checkout_options))
|
253
|
+
if request.name == name
|
254
|
+
result.location = destination
|
255
|
+
end
|
256
|
+
end
|
257
|
+
|
258
|
+
result
|
259
|
+
end
|
260
|
+
end
|
261
|
+
|
262
|
+
def download(request, target)
|
263
|
+
Downloader.download_request(request, target)
|
264
|
+
end
|
265
|
+
|
266
|
+
# Performs the given block inside a temporary directory,
|
267
|
+
# which is removed at the end of the block's scope.
|
268
|
+
#
|
269
|
+
# @return [Object] The return value of the given block
|
270
|
+
#
|
271
|
+
def in_tmpdir(&blk)
|
272
|
+
tmpdir = Pathname(Dir.mktmpdir)
|
273
|
+
blk.call(tmpdir)
|
274
|
+
ensure
|
275
|
+
FileUtils.remove_entry(tmpdir, :force => true) if tmpdir && tmpdir.exist?
|
276
|
+
end
|
277
|
+
|
278
|
+
# Copies the `source` directory to `destination`, cleaning the directory
|
279
|
+
# of any files unused by `spec`.
|
280
|
+
#
|
281
|
+
# @param [Pathname] source
|
282
|
+
#
|
283
|
+
# @param [Pathname] destination
|
284
|
+
#
|
285
|
+
# @param [Specification] spec
|
286
|
+
#
|
287
|
+
# @return [Void]
|
288
|
+
#
|
289
|
+
def copy_and_clean(source, destination, spec)
|
290
|
+
specs_by_platform = group_subspecs_by_platform(spec)
|
291
|
+
destination.parent.mkpath
|
292
|
+
Cache.write_lock(destination) do
|
293
|
+
FileUtils.rm_rf(destination)
|
294
|
+
FileUtils.cp_r(source, destination)
|
295
|
+
Pod::Installer::PodSourcePreparer.new(spec, destination).prepare!
|
296
|
+
Sandbox::PodDirCleaner.new(destination, specs_by_platform).clean!
|
297
|
+
end
|
298
|
+
end
|
299
|
+
|
300
|
+
def group_subspecs_by_platform(spec)
|
301
|
+
specs_by_platform = {}
|
302
|
+
[spec, *spec.recursive_subspecs].each do |ss|
|
303
|
+
ss.available_platforms.each do |platform|
|
304
|
+
specs_by_platform[platform] ||= []
|
305
|
+
specs_by_platform[platform] << ss
|
306
|
+
end
|
307
|
+
end
|
308
|
+
specs_by_platform
|
309
|
+
end
|
310
|
+
|
311
|
+
# Writes the given `spec` to the given `path`.
|
312
|
+
#
|
313
|
+
# @param [Specification] spec
|
314
|
+
# the specification to be written.
|
315
|
+
#
|
316
|
+
# @param [Pathname] path
|
317
|
+
# the path the specification is to be written to.
|
318
|
+
#
|
319
|
+
# @return [Void]
|
320
|
+
#
|
321
|
+
def write_spec(spec, path)
|
322
|
+
path.dirname.mkpath
|
323
|
+
Cache.write_lock(path) do
|
324
|
+
path.open('w') { |f| f.write spec.to_pretty_json }
|
325
|
+
end
|
326
|
+
end
|
327
|
+
end
|
328
|
+
end
|
329
|
+
end
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'net/http'
|
2
|
-
# require 'singleton'
|
3
2
|
require 'cocoapods-core'
|
4
3
|
|
5
4
|
module LgPodPlugin
|
@@ -13,7 +12,7 @@ module LgPodPlugin
|
|
13
12
|
attr_accessor :config
|
14
13
|
attr_accessor :net_ping
|
15
14
|
attr_accessor :params
|
16
|
-
attr_accessor :lockfile
|
15
|
+
# attr_accessor :lockfile
|
17
16
|
attr_accessor :checkout_options
|
18
17
|
def initialize(pod)
|
19
18
|
@name = pod.name
|
@@ -50,9 +49,9 @@ module LgPodPlugin
|
|
50
49
|
end
|
51
50
|
|
52
51
|
public
|
53
|
-
def get_lockfile
|
54
|
-
self.lockfile = LgPodPlugin::LockfileModel.from_file
|
55
|
-
end
|
52
|
+
# def get_lockfile
|
53
|
+
# self.lockfile = LgPodPlugin::LockfileModel.from_file
|
54
|
+
# end
|
56
55
|
|
57
56
|
# 获取缓存用的hash_map
|
58
57
|
public
|
@@ -68,16 +67,17 @@ module LgPodPlugin
|
|
68
67
|
tag = options[:tag] ||= self.params[:tag]
|
69
68
|
branch = options[:branch] ||= self.params[:branch]
|
70
69
|
commit = options[:commit] ||= self.params[:commit]
|
71
|
-
return
|
70
|
+
return nil unless git
|
72
71
|
hash_map[:git] = git
|
73
|
-
if git &&
|
72
|
+
if git && commit
|
74
73
|
hash_map[:commit] = commit
|
74
|
+
return hash_map
|
75
75
|
elsif git && tag
|
76
76
|
hash_map[:tag] = tag
|
77
|
-
|
78
|
-
|
77
|
+
return hash_map
|
78
|
+
else
|
79
|
+
return {:git => git}
|
79
80
|
end
|
80
|
-
hash_map
|
81
81
|
end
|
82
82
|
|
83
83
|
public
|
@@ -111,9 +111,9 @@ module LgPodPlugin
|
|
111
111
|
|
112
112
|
#获取下载参数
|
113
113
|
def get_request_params
|
114
|
-
unless self.lockfile
|
115
|
-
|
116
|
-
end
|
114
|
+
# unless self.lockfile
|
115
|
+
# self.lockfile = self.get_lockfile
|
116
|
+
# end
|
117
117
|
Hash.new.merge!(self.get_lock_params)
|
118
118
|
end
|
119
119
|
|
@@ -124,28 +124,28 @@ module LgPodPlugin
|
|
124
124
|
return [nil, nil] unless (ip && network_ok)
|
125
125
|
if branch
|
126
126
|
new_commit, _ = GitLabAPI.request_github_refs_heads git, branch, self.net_ping.uri
|
127
|
-
unless new_commit
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
end
|
133
|
-
if new_commit
|
134
|
-
|
135
|
-
end
|
127
|
+
# unless new_commit
|
128
|
+
# id = LPodLatestRefs.get_pod_id(name, git, branch)
|
129
|
+
# pod_info = LSqliteDb.shared.query_pod_refs(id)
|
130
|
+
# new_commit = pod_info ? pod_info.commit : nil
|
131
|
+
# return [branch, new_commit]
|
132
|
+
# end
|
133
|
+
# if new_commit
|
134
|
+
# LSqliteDb.shared.insert_pod_refs(name, git, branch, nil, new_commit)
|
135
|
+
# end
|
136
136
|
[branch, new_commit]
|
137
137
|
else
|
138
138
|
new_commit, new_branch = GitLabAPI.request_github_refs_heads git, nil, self.net_ping.uri
|
139
|
-
unless new_commit
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
end
|
146
|
-
if new_commit
|
147
|
-
|
148
|
-
end
|
139
|
+
# unless new_commit
|
140
|
+
# id = LPodLatestRefs.get_pod_id(name, git, "HEAD")
|
141
|
+
# pod_info = LSqliteDb.shared.query_pod_refs(id)
|
142
|
+
# new_commit = pod_info ? pod_info.commit : nil
|
143
|
+
# new_branch = pod_info ? pod_info.branch : nil
|
144
|
+
# return [new_branch, new_commit]
|
145
|
+
# end
|
146
|
+
# if new_commit
|
147
|
+
# LSqliteDb.shared.insert_pod_refs(name, git, "HEAD", nil, new_commit)
|
148
|
+
# end
|
149
149
|
[new_branch, new_commit]
|
150
150
|
end
|
151
151
|
end
|
@@ -7,6 +7,32 @@ module LgPodPlugin
|
|
7
7
|
|
8
8
|
class GitLabAPI
|
9
9
|
|
10
|
+
# 通过读取本地文件获取 access_token
|
11
|
+
def self.get_gitlab_access_token(uri, user_id)
|
12
|
+
db_path = LFileManager.download_director.join("database")
|
13
|
+
db_path.mkdir unless db_path.exist?
|
14
|
+
token_file = db_path.join("access_token.json")
|
15
|
+
return self.get_gitlab_access_token_input(uri, user_id, nil, nil) unless token_file.exist?
|
16
|
+
json = JSON.parse(File.read("#{token_file.to_path}"))
|
17
|
+
encrypt_access_token = json["access_token"]
|
18
|
+
return self.get_gitlab_access_token_input(uri, user_id, nil, nil) if encrypt_access_token.nil?
|
19
|
+
access_token = LUtils.decrypt(encrypt_access_token, "AZMpxzVxzbo3sFDLRZMpxzVxzbo3sFDZ")
|
20
|
+
token_vaild = GitLabAPI.request_user_emails(uri.hostname, access_token)
|
21
|
+
if token_vaild == "invalid token"
|
22
|
+
FileUtils.rm_rf token_file
|
23
|
+
return self.get_gitlab_access_token_input(uri, user_id, nil, nil) if encrypt_access_token.nil?
|
24
|
+
end
|
25
|
+
user_id = LUserAuthInfo.get_user_id(uri.hostname)
|
26
|
+
refresh_token = json["refresh_token"]
|
27
|
+
expires_in = json["expires_in"] ||= 7879680
|
28
|
+
created_at = json["created_at"] ||= Time.now.to_i
|
29
|
+
user_model = LUserAuthInfo.new(user_id, "", "", uri.hostname, access_token, refresh_token, (created_at + expires_in))
|
30
|
+
LSqliteDb.shared.insert_user_info(user_model)
|
31
|
+
LgPodPlugin.log_green "请求成功: `access_token` => #{access_token}, expires_in => #{expires_in}"
|
32
|
+
return user_model
|
33
|
+
end
|
34
|
+
|
35
|
+
# 通过输入用户名和密码 获取 access_token
|
10
36
|
def self.get_gitlab_access_token_input(uri, user_id, username = nil, password = nil)
|
11
37
|
unless username && password
|
12
38
|
LgPodPlugin.log_yellow "请输入 `#{uri.to_s}` 的用户名"
|
@@ -18,6 +44,47 @@ module LgPodPlugin
|
|
18
44
|
user_info = LSqliteDb.shared.query_user_info(user_id)
|
19
45
|
return user_info
|
20
46
|
end
|
47
|
+
# 检查 token 是否在有效期内
|
48
|
+
def self.check_gitlab_access_token_valid(uri, user_info)
|
49
|
+
time_now = Time.now.to_i
|
50
|
+
refresh_token = user_info.refresh_token
|
51
|
+
# 判断 token 是否失效
|
52
|
+
if user_info.expires_in <= time_now
|
53
|
+
if refresh_token.nil? || refresh_token == "" # 使用本地令牌访问
|
54
|
+
project_name = LUtils.get_git_project_name(uri.to_s)
|
55
|
+
token_vaild = GitLabAPI.request_user_emails(uri.hostname, user_info.access_token)
|
56
|
+
if token_vaild == "success"
|
57
|
+
new_user_info = LUserAuthInfo.new(user_info.id, "", "", uri.hostname, user_info.access_token, nil, (time_now + 7879680))
|
58
|
+
LSqliteDb.shared.insert_user_info(user_info)
|
59
|
+
return new_user_info
|
60
|
+
else
|
61
|
+
token_file = LFileManager.download_director.join("database").join("access_token.json")
|
62
|
+
FileUtils.rm_rf token_file if token_file.exist?
|
63
|
+
return self.get_gitlab_access_token_input(uri, user_info.id, nil, nil)
|
64
|
+
end
|
65
|
+
else
|
66
|
+
# 刷新 token 失败时, 通过已经保存的用户名密码来刷新 token
|
67
|
+
return refreshUserToken uri, refresh_token, user_info.id, user_info.username, user_info.password
|
68
|
+
end
|
69
|
+
else
|
70
|
+
update_time = user_info.update_time.to_i
|
71
|
+
if time_now - update_time > 1800
|
72
|
+
user_info = refreshUserToken uri, refresh_token, user_info.id, user_info.username, user_info.password
|
73
|
+
return user_info
|
74
|
+
else
|
75
|
+
return user_info
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def self.refreshUserToken(uri, refresh_token, user_id, username, password)
|
81
|
+
# 刷新 token 失败时, 通过已经保存的用户名密码来刷新 token
|
82
|
+
new_user_info = GitLabAPI.refresh_gitlab_access_token uri.hostname, refresh_token
|
83
|
+
unless new_user_info
|
84
|
+
return GitLabAPI.get_gitlab_access_token_input(uri, user_id, username, password)
|
85
|
+
end
|
86
|
+
return new_user_info
|
87
|
+
end
|
21
88
|
|
22
89
|
public
|
23
90
|
# 获取 GitLab access_token
|
@@ -33,6 +100,7 @@ module LgPodPlugin
|
|
33
100
|
if error != nil
|
34
101
|
if error == "invalid_grant"
|
35
102
|
LSqliteDb.shared.delete_user_info(user_id)
|
103
|
+
LgPodPlugin.log_yellow "LSqliteDb.shared.delete_user_info(#{user_id}"
|
36
104
|
end
|
37
105
|
raise json["error_description"]
|
38
106
|
end
|
@@ -40,7 +108,8 @@ module LgPodPlugin
|
|
40
108
|
refresh_token = json["refresh_token"]
|
41
109
|
expires_in = json["expires_in"] ||= 7200
|
42
110
|
created_at = json["created_at"] ||= Time.now.to_i
|
43
|
-
|
111
|
+
time_now = Time.now.to_i
|
112
|
+
user_model = LUserAuthInfo.new(user_id, username, password, host, access_token, refresh_token, (created_at + expires_in), time_now)
|
44
113
|
LSqliteDb.shared.insert_user_info(user_model)
|
45
114
|
LgPodPlugin.log_green "请求成功: `access_token` => #{access_token}, expires_in => #{expires_in}"
|
46
115
|
rescue => exception
|
@@ -60,7 +129,7 @@ module LgPodPlugin
|
|
60
129
|
if res.body
|
61
130
|
json = JSON.parse(res.body)
|
62
131
|
else
|
63
|
-
|
132
|
+
json = nil
|
64
133
|
end
|
65
134
|
return nil unless json.is_a?(Hash)
|
66
135
|
error = json["error"]
|
@@ -68,16 +137,19 @@ module LgPodPlugin
|
|
68
137
|
error_description = json["error_description"]
|
69
138
|
raise error_description
|
70
139
|
end
|
140
|
+
time_now = Time.now.to_i
|
71
141
|
access_token = json["access_token"]
|
72
142
|
refresh_token = json["refresh_token"]
|
73
143
|
expires_in = json["expires_in"] ||= 7200
|
74
|
-
created_at = json["created_at"] ||=
|
144
|
+
created_at = json["created_at"] ||= time_now
|
75
145
|
user_id = LUserAuthInfo.get_user_id(host)
|
76
146
|
user_model = LSqliteDb.shared.query_user_info(user_id)
|
77
147
|
user_model.expires_in = (created_at + expires_in)
|
78
148
|
user_model.access_token = access_token
|
79
149
|
user_model.refresh_token = refresh_token
|
150
|
+
user_model.update_time = time_now
|
80
151
|
LSqliteDb.shared.insert_user_info(user_model)
|
152
|
+
LgPodPlugin.log_green "刷新token成功: `refresh_token` => #{refresh_token}, expires_in => #{expires_in}"
|
81
153
|
return user_model
|
82
154
|
rescue => exception
|
83
155
|
LgPodPlugin.log_yellow "刷新 `access_token` 失败, error => #{exception.to_s}"
|
@@ -105,7 +177,7 @@ module LgPodPlugin
|
|
105
177
|
path = json["path"] ||= ""
|
106
178
|
path_with_namespace = json["path_with_namespace"] ||= ""
|
107
179
|
name_with_namespace = (json["name_with_namespace"] ||= "").gsub(/[ ]/, '')
|
108
|
-
if git.include?(path_with_namespace)
|
180
|
+
if git.include?(path_with_namespace) || git.downcase.include?(name_with_namespace.downcase)
|
109
181
|
id = json["id"]
|
110
182
|
web_url = json["web_url"]
|
111
183
|
description = json["description"]
|
@@ -172,7 +244,7 @@ module LgPodPlugin
|
|
172
244
|
# 通过github api 获取 git 最新commit
|
173
245
|
def self.request_github_refs_heads(git, branch, uri = nil)
|
174
246
|
return [nil, nil] unless git
|
175
|
-
unless git.include?("
|
247
|
+
unless git.include?("github.com/") || git.include?("git@github.com:")
|
176
248
|
if LgPodPlugin::LUtils.is_gitlab_uri(git, "")
|
177
249
|
return self.request_gitlab_refs_heads(git, branch, uri)
|
178
250
|
end
|
@@ -228,6 +300,31 @@ module LgPodPlugin
|
|
228
300
|
end
|
229
301
|
end
|
230
302
|
|
303
|
+
# 通过名称搜索项目信息
|
304
|
+
public
|
305
|
+
def self.request_user_emails(host, access_token)
|
306
|
+
begin
|
307
|
+
hash_map = {"access_token": access_token}
|
308
|
+
uri = URI("#{host}/api/v4/user/emails")
|
309
|
+
uri.query = URI.encode_www_form(hash_map)
|
310
|
+
res = Net::HTTP.get_response(uri)
|
311
|
+
if res.body
|
312
|
+
array = JSON.parse(res.body)
|
313
|
+
else
|
314
|
+
array = []
|
315
|
+
end
|
316
|
+
if array.is_a?(Array)
|
317
|
+
return "success"
|
318
|
+
elsif array.is_a?(Hash)
|
319
|
+
return "invalid token"
|
320
|
+
else
|
321
|
+
return "invalid token"
|
322
|
+
end
|
323
|
+
rescue
|
324
|
+
return "invalid token"
|
325
|
+
end
|
326
|
+
end
|
327
|
+
|
231
328
|
end
|
232
329
|
|
233
330
|
end
|
Binary file
|
@@ -21,10 +21,7 @@ module LgPodPlugin
|
|
21
21
|
def install(pod)
|
22
22
|
hash = pod.checkout_options
|
23
23
|
path = hash[:path]
|
24
|
-
unless path.nil?
|
25
|
-
LProject.shared.need_update_pods[pod.name] = "1"
|
26
|
-
return nil
|
27
|
-
end
|
24
|
+
return nil unless path.nil?
|
28
25
|
@downloader = LDownloader.new(pod)
|
29
26
|
self.download_params = @downloader.pre_download_pod
|
30
27
|
return self.download_params
|
@@ -8,22 +8,18 @@ module LgPodPlugin
|
|
8
8
|
include Singleton
|
9
9
|
|
10
10
|
attr_reader :podfile
|
11
|
-
attr_reader :lockfile
|
12
11
|
attr_reader :update
|
13
12
|
attr_reader :targets
|
14
13
|
attr_reader :workspace
|
15
14
|
attr_reader :repo_update
|
16
15
|
attr_reader :external_pods
|
17
|
-
attr_reader :need_update_pods
|
18
16
|
attr_accessor :cache_specs
|
19
|
-
|
17
|
+
attr_accessor :refreshToken
|
20
18
|
def setup(workspace,podfile_path, update, repo_update)
|
21
19
|
@podfile = Pod::Podfile.from_file(podfile_path)
|
22
20
|
@update = update
|
23
21
|
@workspace = workspace
|
24
22
|
@repo_update = repo_update
|
25
|
-
lockfile_path = workspace.join("Podfile.lock")
|
26
|
-
@lockfile = Pod::Lockfile.from_file(lockfile_path) if lockfile_path.exist?
|
27
23
|
target = @podfile.send(:current_target_definition)
|
28
24
|
children = target.children
|
29
25
|
@targets = Array.new
|
@@ -35,8 +31,7 @@ module LgPodPlugin
|
|
35
31
|
end
|
36
32
|
@cache_specs = Hash.new
|
37
33
|
@external_pods = Hash.new.merge!(external_pods)
|
38
|
-
@
|
39
|
-
# @redirect_url_hash = Hash.new
|
34
|
+
@refreshToken = nil
|
40
35
|
return self
|
41
36
|
end
|
42
37
|
|
@@ -30,13 +30,6 @@ module LgPodPlugin
|
|
30
30
|
end
|
31
31
|
return if origin_uri.nil?
|
32
32
|
@uri = origin_uri
|
33
|
-
# redirect_url = LProject.shared.redirect_url_hash[origin_uri.host]
|
34
|
-
# if redirect_url
|
35
|
-
# @uri = redirect_url
|
36
|
-
# else
|
37
|
-
# @uri = URI(get_redirect_url(origin_uri.scheme + "://" + origin_uri.host))
|
38
|
-
# LProject.shared.redirect_url_hash[origin_uri.host] = @uri
|
39
|
-
# end
|
40
33
|
@host = @uri.host
|
41
34
|
@scheme = @uri.scheme ||= "https"
|
42
35
|
@hostname = @scheme + "://" + @host
|