lg_pod_plugin 1.1.7.3 → 1.1.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/command/init.rb +1 -1
- data/lib/lg_pod_plugin/db/database.rb +15 -51
- data/lib/lg_pod_plugin/downloader/downloader.rb +9 -48
- data/lib/lg_pod_plugin/downloader/l_cache.rb +58 -66
- data/lib/lg_pod_plugin/downloader/overload_cache.rb +14 -284
- data/lib/lg_pod_plugin/downloader/request.rb +2 -4
- data/lib/lg_pod_plugin/git/github_api.rb +2 -49
- data/lib/lg_pod_plugin/git/github_archive.rb +11 -32
- data/lib/lg_pod_plugin/git/gitlab_api.rb +62 -57
- data/lib/lg_pod_plugin/git/gitlab_archive.rb +7 -80
- data/lib/lg_pod_plugin/git/http_download.rb +3 -8
- data/lib/lg_pod_plugin/installer/PodDownload +0 -0
- data/lib/lg_pod_plugin/installer/install.rb +15 -12
- data/lib/lg_pod_plugin/installer/main.rb +5 -0
- data/lib/lg_pod_plugin/net/l_uri.rb +1 -34
- data/lib/lg_pod_plugin/pod/external_pod.rb +0 -1
- data/lib/lg_pod_plugin/pod/release-pod.rb +4 -4
- data/lib/lg_pod_plugin/utils/file_path.rb +5 -0
- data/lib/lg_pod_plugin/utils/l_util.rb +0 -24
- data/lib/lg_pod_plugin/version.rb +1 -1
- data/lib/lg_pod_plugin.rb +1 -1
- metadata +9 -12
- data/lib/lg_pod_plugin/config/lockfile_model.rb +0 -58
- data/lib/lg_pod_plugin/config/podspec.rb +0 -266
- data/lib/lg_pod_plugin/utils/aes-crypt.rb +0 -82
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 64cfe9f5818b1ad35a426e047a1639889db338c028923af2e2cbc9c4e31556da
|
4
|
+
data.tar.gz: ce53c502a2bbbeb261dfe3dc048a8e423848f7f29633956447c0abe1b474712d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a6f5bc095f471f44cb2effd225be4bcf1c10622374adbe7f00d2b7953f0be3b09f763307ba167456169ba862e629e0cdf3e5596228f093461ee98fb35c3b21d
|
7
|
+
data.tar.gz: e081fa09f5ba85d7a9a581b30a8fabf9e83ce89c200bd020b3a9bdc0a8b6b955cf61b01fd1c0279ea2dbec406f77b6b790fd42397a2989632a3eb8fa918c5f28
|
data/lib/command/init.rb
CHANGED
@@ -52,7 +52,7 @@ module LgPodPlugin
|
|
52
52
|
File.open(token_file.to_path, 'w+') { |f| f.write(str) }
|
53
53
|
LSqliteDb.shared.init_database
|
54
54
|
user_id = LUserAuthInfo.get_user_id(self.host)
|
55
|
-
user_model = LUserAuthInfo.new(user_id, "", "", self.host, self.token, "", (created_at + expires_in))
|
55
|
+
user_model = LUserAuthInfo.new(user_id, "", "", self.host, self.token, "", (created_at + expires_in), created_at, 1)
|
56
56
|
LSqliteDb.shared.insert_user_info(user_model)
|
57
57
|
LgPodPlugin.log_green "设置私人访问令牌成功"
|
58
58
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'singleton'
|
2
|
-
# arch = %x(ruby -v)
|
3
2
|
require 'sqlite3'
|
3
|
+
|
4
4
|
module LgPodPlugin
|
5
5
|
|
6
6
|
class ProjectModel
|
@@ -21,36 +21,13 @@ module LgPodPlugin
|
|
21
21
|
|
22
22
|
end
|
23
23
|
|
24
|
-
# class LPodLatestRefs
|
25
|
-
# attr_accessor :id
|
26
|
-
# attr_accessor :name
|
27
|
-
# attr_accessor :tag
|
28
|
-
# attr_accessor :git
|
29
|
-
# attr_accessor :branch
|
30
|
-
# attr_accessor :commit
|
31
|
-
#
|
32
|
-
# def initialize(id, name, git, branch, tag, commit)
|
33
|
-
# self.id = id
|
34
|
-
# self.git = git
|
35
|
-
# self.tag = tag
|
36
|
-
# self.name = name
|
37
|
-
# self.branch = branch
|
38
|
-
# self.commit = commit
|
39
|
-
# end
|
40
|
-
#
|
41
|
-
# def self.get_pod_id(name, git, branch)
|
42
|
-
# key = name + git + branch
|
43
|
-
# return Digest::MD5.hexdigest(key)
|
44
|
-
# end
|
45
|
-
#
|
46
|
-
# end
|
47
|
-
|
48
24
|
class LUserAuthInfo
|
49
|
-
REQUIRED_ATTRS ||= %i[id username password host access_token refresh_token expires_in update_time].freeze
|
25
|
+
REQUIRED_ATTRS ||= %i[id username password host access_token refresh_token expires_in update_time type].freeze
|
50
26
|
attr_accessor(*REQUIRED_ATTRS)
|
51
27
|
|
52
|
-
def initialize(id = nil, name = nil, pwd = nil, host = nil, token = nil, refresh_token = nil, time = nil, update_time = nil)
|
28
|
+
def initialize(id = nil, name = nil, pwd = nil, host = nil, token = nil, refresh_token = nil, time = nil, update_time = nil, type = 0)
|
53
29
|
self.id = id
|
30
|
+
self.type = type
|
54
31
|
self.host = host
|
55
32
|
self.password = pwd
|
56
33
|
self.username = name
|
@@ -114,6 +91,13 @@ module LgPodPlugin
|
|
114
91
|
self.db.execute(alter)
|
115
92
|
end
|
116
93
|
|
94
|
+
user_sel_sql2 = "select * from sqlite_master where name = '#{K_USER_TABLE}' and sql like '%type%'; "
|
95
|
+
resultSetPrincipal2 = self.db.execute(user_sel_sql2)
|
96
|
+
if resultSetPrincipal2.count == 0
|
97
|
+
alter = "ALTER TABLE #{K_USER_TABLE} ADD 'type' INT;"
|
98
|
+
self.db.execute(alter)
|
99
|
+
end
|
100
|
+
|
117
101
|
#添加项目表
|
118
102
|
sql2 = "create table if not exists #{K_USER_PROJECTS}(
|
119
103
|
id varchar(100) primary key not null,
|
@@ -128,27 +112,6 @@ module LgPodPlugin
|
|
128
112
|
);"
|
129
113
|
self.db.execute(sql2)
|
130
114
|
|
131
|
-
# #添加项目表
|
132
|
-
# sql3 = "create table if not exists #{K_POD_LATEST_REFS}(
|
133
|
-
# id varchar(100) primary key not null,
|
134
|
-
# name varchar(100),
|
135
|
-
# git varchar(100),
|
136
|
-
# branch varchar(100),
|
137
|
-
# tag varchar(100),
|
138
|
-
# sha varchar(100)
|
139
|
-
# );"
|
140
|
-
# self.db.execute(sql3)
|
141
|
-
#
|
142
|
-
# #添加项目表
|
143
|
-
# sql4 = "create table if not exists #{K_POD_SHA_BRANCH}(
|
144
|
-
# id varchar(100) primary key not null,
|
145
|
-
# name varchar(100),
|
146
|
-
# git varchar(100),
|
147
|
-
# branch varchar(100),
|
148
|
-
# sha varchar(100)
|
149
|
-
# );"
|
150
|
-
# self.db.execute(sql4)
|
151
|
-
|
152
115
|
end
|
153
116
|
|
154
117
|
public
|
@@ -156,11 +119,11 @@ module LgPodPlugin
|
|
156
119
|
# pp "user.id => #{user.id}"
|
157
120
|
if self.query_user_info(user.id) != nil
|
158
121
|
self.db.execute_batch(
|
159
|
-
"UPDATE #{K_USER_TABLE} SET username = (:username), password = (:password), host = (:host), access_token = (:access_token), expires_in = (:expires_in), refresh_token = (:refresh_token), update_time = (:update_time) where (id = :id)", { "username" => user.username, "password" => user.password, "host" => user.host, "access_token" => user.access_token, :expires_in => user.expires_in, :id => user.id, :refresh_token => user.refresh_token , :update_time => user.update_time}
|
122
|
+
"UPDATE #{K_USER_TABLE} SET username = (:username), password = (:password), host = (:host), access_token = (:access_token), expires_in = (:expires_in), refresh_token = (:refresh_token), update_time = (:update_time), type = (:type) where (id = :id)", { "username" => user.username, "password" => user.password, "host" => user.host, "access_token" => user.access_token, :expires_in => user.expires_in, :id => user.id, :refresh_token => user.refresh_token , :update_time => user.update_time, :type => user.type}
|
160
123
|
)
|
161
124
|
else
|
162
|
-
self.db.execute("INSERT INTO #{K_USER_TABLE} (id, username, password, host, access_token,refresh_token, expires_in, update_time)
|
163
|
-
VALUES (?, ?, ?, ?,?,?,?, ?)", [user.id, user.username, user.password, user.host, user.access_token, user.refresh_token, user.expires_in, user.update_time])
|
125
|
+
self.db.execute("INSERT INTO #{K_USER_TABLE} (id, username, password, host, access_token,refresh_token, expires_in, update_time, type)
|
126
|
+
VALUES (?, ?, ?, ?,?,?,?, ?, ?)", [user.id, user.username, user.password, user.host, user.access_token, user.refresh_token, user.expires_in, user.update_time, user.type])
|
164
127
|
end
|
165
128
|
|
166
129
|
end
|
@@ -179,6 +142,7 @@ module LgPodPlugin
|
|
179
142
|
user_info.refresh_token = row[5]
|
180
143
|
user_info.expires_in = row[6]
|
181
144
|
user_info.update_time = row[7]
|
145
|
+
user_info.type = row[8]
|
182
146
|
end
|
183
147
|
user_info
|
184
148
|
end
|
@@ -15,27 +15,18 @@ module LgPodPlugin
|
|
15
15
|
# 预下载处理
|
16
16
|
def pre_download_pod
|
17
17
|
name = self.request.name
|
18
|
-
|
19
|
-
podspec = self.request.lg_spec.spec
|
20
|
-
else
|
21
|
-
podspec = nil
|
22
|
-
end
|
18
|
+
podspec = self.request.podspec
|
23
19
|
checkout_options = Hash.new.merge!(self.request.checkout_options)
|
24
20
|
http = checkout_options[:http]
|
25
21
|
git = checkout_options[:git]
|
26
22
|
tag = checkout_options[:tag]
|
27
23
|
branch = checkout_options[:branch]
|
28
24
|
checkout_options[:name] = name if name
|
29
|
-
checkout_options[:spec] = self.request.lg_spec if podspec
|
30
25
|
unless branch
|
31
26
|
branch = self.request.params[:branch] if self.request.params[:branch]
|
32
27
|
checkout_options[:branch] = branch if branch
|
33
28
|
end
|
34
29
|
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
30
|
if branch
|
40
31
|
LgPodPlugin.log_green "Using `#{name}` (#{branch})"
|
41
32
|
elsif tag
|
@@ -49,10 +40,13 @@ module LgPodPlugin
|
|
49
40
|
LgPodPlugin.log_green "Using `#{name}`"
|
50
41
|
end
|
51
42
|
hash_map = self.request.get_cache_key_params
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
43
|
+
if request.single_git
|
44
|
+
commit = hash_map[:commit] unless commit
|
45
|
+
checkout_options[:commit] = commit if commit
|
46
|
+
pod_is_exist, destination, cache_pod_spec = LCache.new.pod_cache_exist(name, {:git => git}, podspec, self.request.released_pod)
|
47
|
+
else
|
48
|
+
pod_is_exist, destination, cache_pod_spec = LCache.new.pod_cache_exist(name, hash_map, podspec, self.request.released_pod)
|
49
|
+
end
|
56
50
|
if pod_is_exist
|
57
51
|
LgPodPlugin.log_green "find the cache of `#{name}`, you can use it now."
|
58
52
|
return nil
|
@@ -62,42 +56,9 @@ module LgPodPlugin
|
|
62
56
|
# 本地 git 下载 pod 目录
|
63
57
|
download_params = self.pre_download_git_repository(checkout_options)
|
64
58
|
if download_params && download_params.is_a?(Hash)
|
59
|
+
download_params["dirname"] = destination.dirname
|
65
60
|
download_params["destination"] = destination
|
66
61
|
download_params["cache_pod_spec_path"] = cache_pod_spec
|
67
|
-
podspec = download_params["podspec"]
|
68
|
-
podspec_content = download_params["podspec_content"]
|
69
|
-
if podspec
|
70
|
-
podspec_json = podspec.to_pretty_json
|
71
|
-
download_params["podspec_json"] = podspec_json if podspec
|
72
|
-
download_params["prepare_command"] = podspec.prepare_command if podspec
|
73
|
-
download_params.delete("podspec")
|
74
|
-
unless self.request.lg_spec
|
75
|
-
self.request.lg_spec = podspec
|
76
|
-
end
|
77
|
-
elsif podspec_content
|
78
|
-
path = download_params["path"]
|
79
|
-
podspec_path = path + "/#{name}.podspec"
|
80
|
-
begin
|
81
|
-
File.open(podspec_path,"w+") do|f|
|
82
|
-
f.write podspec_content
|
83
|
-
end
|
84
|
-
end
|
85
|
-
if File.exist?(podspec_path)
|
86
|
-
lg_spec = LgPodPlugin::PodSpec.form_file podspec_path
|
87
|
-
if lg_spec
|
88
|
-
self.request.lg_spec = lg_spec
|
89
|
-
download_params["podspec_json"] = lg_spec.to_pretty_json
|
90
|
-
download_params["source_files"] = lg_spec.source_files.keys
|
91
|
-
download_params["prepare_command"] = lg_spec.prepare_command if lg_spec.prepare_command
|
92
|
-
download_params.delete("podspec_content")
|
93
|
-
else
|
94
|
-
download_params["source_files"] = ["All"]
|
95
|
-
download_params["prepare_command"] = nil
|
96
|
-
download_params["podspec_json"] = podspec_content
|
97
|
-
download_params.delete("podspec_content")
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|
101
62
|
return download_params
|
102
63
|
elsif File.exist?(download_params.to_s) && download_params
|
103
64
|
FileUtils.chdir download_params
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
|
2
2
|
require 'cocoapods/downloader'
|
3
3
|
require 'cocoapods/downloader/cache'
|
4
4
|
require 'cocoapods/downloader/response'
|
@@ -12,32 +12,34 @@ module LgPodPlugin
|
|
12
12
|
end
|
13
13
|
|
14
14
|
public
|
15
|
+
|
15
16
|
def pod_cache_exist(name, options, spec = nil, released_pod = false)
|
16
17
|
# 参数为空不执行下载任务, 交给 cocoapods 处理下载
|
17
18
|
if options.nil?
|
18
|
-
return
|
19
|
+
return [true, nil, nil]
|
19
20
|
end
|
20
|
-
|
21
21
|
destination, cache_pod_spec = self.find_pod_cache name, options, spec, released_pod
|
22
|
-
lock_temp_file = destination.to_path+ ".lock"
|
22
|
+
lock_temp_file = destination.to_path + ".lock"
|
23
23
|
if File.exist?(lock_temp_file)
|
24
24
|
FileUtils.rm_rf lock_temp_file
|
25
25
|
end
|
26
|
-
if
|
26
|
+
if destination && destination.exist? && !destination.children.empty?
|
27
27
|
return [true, destination, cache_pod_spec]
|
28
28
|
else
|
29
29
|
return [false, destination, cache_pod_spec]
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
-
|
33
|
+
# 判断缓存是否存在且有效命中缓存
|
34
|
+
|
34
35
|
public
|
36
|
+
|
35
37
|
def find_pod_cache(name, options, spec = nil, released_pod = false)
|
36
38
|
hash_map = Hash.new.merge!(options)
|
37
39
|
if hash_map.has_key?(:version)
|
38
40
|
hash_map.delete(:version)
|
39
41
|
end
|
40
|
-
request = LCache.
|
42
|
+
request = LCache.create_download_request(name, hash_map, spec, released_pod)
|
41
43
|
destination = LCache.path_for_pod(request)
|
42
44
|
cache_pod_spec = LCache.path_for_spec(request)
|
43
45
|
[destination, cache_pod_spec]
|
@@ -48,32 +50,50 @@ module LgPodPlugin
|
|
48
50
|
Pathname(path)
|
49
51
|
end
|
50
52
|
|
51
|
-
def self.
|
53
|
+
def self.create_download_request(name, params, spec = nil, released_pod = false)
|
52
54
|
if released_pod
|
53
|
-
Pod::Downloader::Request.new(spec: spec, released: true
|
55
|
+
Pod::Downloader::Request.new(spec: spec, released: true, name: name, params: params)
|
56
|
+
else
|
57
|
+
Pod::Downloader::Request.new(spec: nil, released: false, name: name, params: params)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def self.create_downloader_manager(request, target)
|
62
|
+
result = Pod::Downloader::Response.new
|
63
|
+
result.checkout_options = request.params
|
64
|
+
result.location = target
|
65
|
+
|
66
|
+
if request.released_pod?
|
67
|
+
result.spec = request.spec
|
68
|
+
podspecs = { request.name => request.spec }
|
54
69
|
else
|
55
|
-
Pod::
|
70
|
+
podspecs = Pod::Sandbox::PodspecFinder.new(target).podspecs
|
71
|
+
podspecs[request.name] = request.spec if request.spec
|
72
|
+
podspecs.each do |name, spec|
|
73
|
+
if request.name == name
|
74
|
+
result.spec = spec
|
75
|
+
end
|
76
|
+
end
|
56
77
|
end
|
78
|
+
|
79
|
+
[result, podspecs]
|
57
80
|
end
|
58
|
-
|
81
|
+
|
82
|
+
def self.root_cache
|
83
|
+
cache_path = LFileManager.cache_root_path
|
84
|
+
return Pod::Downloader::Cache.new(cache_path)
|
85
|
+
end
|
86
|
+
|
87
|
+
# MARK - 缓存方法
|
59
88
|
def self.path_for_pod(request, slug_opts = {})
|
60
|
-
|
61
|
-
root + request.slug(**slug_opts)
|
89
|
+
root_path + request.slug(**slug_opts)
|
62
90
|
end
|
63
91
|
|
64
92
|
def self.path_for_spec(request, slug_opts = {})
|
65
|
-
|
66
|
-
path
|
67
|
-
Pathname.new(path.to_path + '.podspec.json')
|
93
|
+
path = root_path + 'Specs' + request.slug(**slug_opts)
|
94
|
+
return Pathname.new(path.to_path + '.podspec.json')
|
68
95
|
end
|
69
96
|
|
70
|
-
# def self.cached_spec(request)
|
71
|
-
# path = path_for_spec(request)
|
72
|
-
# path.file? && Specification.from_file(path)
|
73
|
-
# rescue JSON::ParserError
|
74
|
-
# nil
|
75
|
-
# end
|
76
|
-
|
77
97
|
def self.get_local_spec(request, target)
|
78
98
|
result = Pod::Downloader::Response.new
|
79
99
|
result.location = target
|
@@ -95,62 +115,29 @@ module LgPodPlugin
|
|
95
115
|
[result, local_specs]
|
96
116
|
end
|
97
117
|
|
98
|
-
def self.group_subspecs_by_platform(spec)
|
99
|
-
specs_by_platform = {}
|
100
|
-
[spec, *spec.recursive_subspecs].each do |ss|
|
101
|
-
ss.available_platforms.each do |platform|
|
102
|
-
specs_by_platform[platform] ||= []
|
103
|
-
specs_by_platform[platform] << ss
|
104
|
-
end
|
105
|
-
end
|
106
|
-
specs_by_platform
|
107
|
-
end
|
108
|
-
|
109
118
|
def self.copy_and_clean(source, destination, spec)
|
110
|
-
|
111
|
-
destination.parent.mkpath
|
112
|
-
self.write_lock(destination) do
|
113
|
-
FileUtils.rm_rf(destination)
|
114
|
-
FileUtils.cp_r(source, destination)
|
115
|
-
Pod::Installer::PodSourcePreparer.new(spec, destination).prepare!
|
116
|
-
Pod::Sandbox::PodDirCleaner.new(destination, specs_by_platform).clean!
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
def self.clean_pod_unused_files(destination, spec)
|
121
|
-
specs_by_platform = group_subspecs_by_platform(spec)
|
122
|
-
destination.parent.mkpath
|
123
|
-
self.write_lock(destination) do
|
124
|
-
Pod::Installer::PodSourcePreparer.new(spec, destination).prepare!
|
125
|
-
Pod::Sandbox::PodDirCleaner.new(destination, specs_by_platform).clean!
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
def self.write_lock(location, &block)
|
130
|
-
Pod::Downloader::Cache.lock(location, File::LOCK_SH, &block)
|
119
|
+
return self.root_cache.copy_and_clean(source, destination, spec)
|
131
120
|
end
|
132
121
|
|
133
122
|
public
|
123
|
+
|
134
124
|
def self.write_spec(spec, path)
|
135
|
-
|
136
|
-
Pod::Downloader::Cache.write_lock(path) do
|
137
|
-
path.open('w') { |f|
|
138
|
-
f.write spec.to_pretty_json
|
139
|
-
}
|
140
|
-
end
|
125
|
+
self.root_cache.write_spec(spec, path)
|
141
126
|
end
|
142
127
|
|
143
128
|
# 拷贝 pod 缓存文件到 sandbox
|
129
|
+
|
144
130
|
public
|
131
|
+
|
145
132
|
def self.cache_pod(name, target, options = {}, spec = nil, released_pod = false)
|
146
133
|
checkout_options = Hash.new.deep_merge(options).reject do |key, val|
|
147
134
|
!key || !val
|
148
135
|
end
|
149
|
-
request =
|
150
|
-
|
151
|
-
pods_pecs.each do |
|
152
|
-
destination = path_for_pod
|
153
|
-
if !
|
136
|
+
request = create_download_request(name, checkout_options, spec, released_pod)
|
137
|
+
result, pods_pecs = create_downloader_manager(request, target)
|
138
|
+
pods_pecs.each do |name, s_spec|
|
139
|
+
destination = path_for_pod request, { :name => name, :params => checkout_options }
|
140
|
+
if !destination.exist? || destination.children.empty?
|
154
141
|
LgPodPlugin.log_green "Copying #{name} from `#{target}` to `#{destination}` "
|
155
142
|
copy_and_clean(target, destination, s_spec)
|
156
143
|
end
|
@@ -158,8 +145,13 @@ module LgPodPlugin
|
|
158
145
|
unless File.exist?(cache_pod_spec)
|
159
146
|
write_spec(s_spec, cache_pod_spec)
|
160
147
|
end
|
148
|
+
if request.name == name
|
149
|
+
result.location = destination
|
150
|
+
end
|
161
151
|
end
|
162
152
|
|
153
|
+
result
|
154
|
+
|
163
155
|
end
|
164
156
|
|
165
157
|
end
|