lg_pod_plugin 1.1.8.2 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aafc9f0e84eb60f2f5a215573e20d4496446d31ad7fa4e8829c309872ad682cc
4
- data.tar.gz: a1d6ef6d263704e67e90de93cd4d756e52e67ad385eaebfb2907691c1f83db4e
3
+ metadata.gz: 4d24b5f9bdfaba6416cf330a12dedd8ea1188bbb88ac3c833282662f2aea34fe
4
+ data.tar.gz: 5a5de669f9e3db6867afa241bdf6fb80f00703e7359f860cec24cea5ef58a5e8
5
5
  SHA512:
6
- metadata.gz: 7a002fe8a446c71ebc2d82f2d95f860571a58a68dfecf5816b01258c550e3ba2dceaf4765227f6caed75af4829908a195da4c9efa1875c0fa24e11d9e309f48f
7
- data.tar.gz: f143f3a417584ef027c445d7ebaf6130187f4cce2b75d780fc3a4af1f8ac22f27e676bebacd85c5bac6efc805c2ab2d50129b4376b312d03c59a1ba348842ad9
6
+ metadata.gz: c597e21e3e7b4d7717a43e189bf8100af12c0a519fd61a7101c4c621ed0f14a314a4c4e85d99e6ac4c9762aa5a402da1fe7a116b754ba728144d2a15061430cc
7
+ data.tar.gz: 0c0ae53f0b22bae3b8e0c008d237cdebc7415f963cf1b56d1640488a3e68ddaca324875b45750b2fb3717eb724dbe33c99da55f5e14ab158213c1f82dccbd5ad
@@ -21,9 +21,7 @@ module LgPodPlugin
21
21
  return nil unless LUtils.is_gitlab_uri(git, uri.hostname)
22
22
  user_id = LUserAuthInfo.get_user_id(uri.hostname)
23
23
  user_info = LSqliteDb.shared.query_user_info(user_id)
24
- if user_info != nil
25
- user_info = GitLabAPI.check_gitlab_access_token_valid(uri, user_info)
26
- else
24
+ if user_info == nil
27
25
  user_info = GitLabAPI.get_gitlab_access_token(uri, user_id)
28
26
  end
29
27
  return nil unless user_info
@@ -31,9 +31,7 @@ module LgPodPlugin
31
31
  end
32
32
 
33
33
  # 判断缓存是否存在且有效命中缓存
34
-
35
34
  public
36
-
37
35
  def find_pod_cache(name, options, spec = nil, released_pod = false)
38
36
  hash_map = Hash.new.merge!(options)
39
37
  if hash_map.has_key?(:version)
@@ -79,11 +77,6 @@ module LgPodPlugin
79
77
  [result, podspecs]
80
78
  end
81
79
 
82
- # def self.root_cache
83
- # cache_path = LFileManager.cache_root_path
84
- # return Pod::Downloader::Cache.new(cache_path)
85
- # end
86
-
87
80
  # MARK - 缓存方法
88
81
  def self.path_for_pod(request, slug_opts = {})
89
82
  root_path + request.slug(**slug_opts)
@@ -94,28 +87,6 @@ module LgPodPlugin
94
87
  return Pathname.new(path.to_path + '.podspec.json')
95
88
  end
96
89
 
97
- #
98
- # def self.get_local_spec(request, target)
99
- # result = Pod::Downloader::Response.new
100
- # result.location = target
101
- # if request.released_pod?
102
- # result.spec = request.spec
103
- # local_specs = { request.name => request.spec }
104
- # return [request, local_specs]
105
- # else
106
- # local_specs = {}
107
- # pods_pecs = Pod::Sandbox::PodspecFinder.new(target).podspecs
108
- # pods_pecs[request.name] = request.spec if request.spec
109
- # pods_pecs.each do |name, spec|
110
- # if request.name == name
111
- # result.spec = spec
112
- # local_specs[request.name] = spec
113
- # end
114
- # end
115
- # end
116
- # [result, local_specs]
117
- # end
118
-
119
90
  def self.group_subspecs_by_platform(spec)
120
91
  specs_by_platform = {}
121
92
  [spec, *spec.recursive_subspecs].each do |ss|
@@ -9,157 +9,29 @@ module LgPodPlugin
9
9
 
10
10
  # 通过读取本地文件获取 access_token
11
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
- access_token = json["access_token"]
18
- return self.get_gitlab_access_token_input(uri, user_id, nil, nil) if access_token.nil?
19
- token_vaild = GitLabAPI.request_user_emails(uri.hostname, access_token)
20
- if token_vaild == "invalid token"
21
- FileUtils.rm_rf token_file
22
- return self.get_gitlab_access_token_input(uri, user_id, nil, nil)
23
- end
12
+ access_token = "TAun4FNUjCdtwsUrwsLG"
24
13
  user_id = LUserAuthInfo.get_user_id(uri.hostname)
25
14
  now_time = Time.now.to_i
26
- refresh_token = json["refresh_token"]
27
- expires_in = json["expires_in"] ||= 7879680
28
- created_at = json["created_at"] ||= now_time
15
+ refresh_token = access_token
16
+ expires_in = 7879680
17
+ created_at = now_time
29
18
  user_model = LUserAuthInfo.new(user_id, "", "", uri.hostname, access_token, refresh_token, (created_at + expires_in), now_time, 1)
30
19
  LSqliteDb.shared.insert_user_info(user_model)
31
20
  LgPodPlugin.log_green "请求成功: `access_token` => #{access_token}, expires_in => #{expires_in}"
32
21
  return user_model
33
22
  end
34
23
 
35
- # 通过输入用户名和密码 获取 access_token
36
- def self.get_gitlab_access_token_input(uri, user_id, username = nil, password = nil)
37
- unless username && password
38
- LgPodPlugin.log_yellow "请输入 `#{uri.to_s}` 的用户名"
39
- username = STDIN.gets.chomp
40
- LgPodPlugin.log_yellow "请输入 `#{uri.to_s}` 的密码"
41
- password = STDIN.noecho(&:gets).chomp
42
- end
43
- GitLabAPI.request_gitlab_access_token(uri.hostname, username, password)
44
- user_info = LSqliteDb.shared.query_user_info(user_id)
45
- return user_info
46
- end
47
24
  # 检查 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
- if user_info.type == 1
52
- if user_info.expires_in <= time_now
53
- project_name = LUtils.get_git_project_name(uri.to_s)
54
- token_valid = GitLabAPI.request_user_emails(uri.hostname, user_info.access_token)
55
- if token_valid == "success"
56
- new_user_info = LUserAuthInfo.new(user_info.id, "", "", uri.hostname, user_info.access_token, nil, (time_now + 7879680), time_now, 1)
57
- LSqliteDb.shared.insert_user_info(user_info)
58
- return new_user_info
59
- else
60
- token_file = LFileManager.download_director.join("database").join("access_token.json")
61
- FileUtils.rm_rf token_file if token_file.exist?
62
- return self.get_gitlab_access_token_input(uri, user_info.id, nil, nil)
63
- end
64
- else
65
- return user_info
66
- end
67
- else
68
- # 判断 token 是否失效
69
- if user_info.expires_in <= time_now
70
- return refresh_user_token uri, refresh_token, user_info.id, user_info.username, user_info.password
71
- else
72
- update_time = user_info.update_time.to_i
73
- if time_now - update_time > 1800
74
- user_info = refresh_user_token uri, refresh_token, user_info.id, user_info.username, user_info.password
75
- return user_info
76
- else
77
- return user_info
78
- end
79
- end
80
- end
81
- end
82
-
83
- def self.refresh_user_token(uri, refresh_token, user_id, username, password)
84
- # 刷新 token 失败时, 通过已经保存的用户名密码来刷新 token
85
- new_user_info = GitLabAPI.refresh_gitlab_access_token uri.hostname, refresh_token
86
- unless new_user_info
87
- return GitLabAPI.get_gitlab_access_token_input(uri, user_id, username, password)
88
- end
89
- return new_user_info
90
- end
91
-
92
- public
93
- # 获取 GitLab access_token
94
- def self.request_gitlab_access_token(host, username, password)
95
- user_id = LUserAuthInfo.get_user_id(host)
96
- begin
97
- uri = URI("#{host}/oauth/token")
98
- hash_map = { "grant_type" => "password", "username" => username, "password" => password }
99
- LgPodPlugin.log_green "开始请求 access_token, url => #{uri.to_s} "
100
- req = Net::HTTP.post_form(uri, hash_map)
101
- json = JSON.parse(req.body)
102
- error = json["error"]
103
- if error != nil
104
- if error == "invalid_grant"
105
- LSqliteDb.shared.delete_user_info(user_id)
106
- LgPodPlugin.log_yellow "LSqliteDb.shared.delete_user_info(#{user_id}"
107
- end
108
- raise json["error_description"]
109
- end
110
- access_token = json["access_token"]
111
- refresh_token = json["refresh_token"]
112
- expires_in = json["expires_in"] ||= 7200
113
- created_at = json["created_at"] ||= Time.now.to_i
114
- time_now = Time.now.to_i
115
- user_model = LUserAuthInfo.new(user_id, username, password, host, access_token, refresh_token, (created_at + expires_in), time_now, 0)
116
- LSqliteDb.shared.insert_user_info(user_model)
117
- LgPodPlugin.log_green "请求成功: `access_token` => #{access_token}, expires_in => #{expires_in}"
118
- rescue => exception
119
- LgPodPlugin.log_red "获取 `access_token` 失败, error => #{exception.to_s}"
120
- end
121
- end
122
-
123
- # 刷新gitlab_token
124
- def self.refresh_gitlab_access_token(host, refresh_token)
125
- begin
126
- hash_map = Hash.new
127
- hash_map["scope"] = "api"
128
- hash_map["grant_type"] = "refresh_token"
129
- hash_map["refresh_token"] = refresh_token
130
- uri = URI("#{host}/oauth/token")
131
- res = Net::HTTP.post_form(uri, hash_map)
132
- if res.body
133
- json = JSON.parse(res.body)
134
- else
135
- json = nil
136
- end
137
- return nil unless json.is_a?(Hash)
138
- error = json["error"]
139
- if error != nil
140
- error_description = json["error_description"]
141
- raise error_description
142
- end
143
- time_now = Time.now.to_i
144
- access_token = json["access_token"]
145
- refresh_token = json["refresh_token"]
146
- expires_in = json["expires_in"] ||= 7200
147
- created_at = json["created_at"] ||= time_now
148
- user_id = LUserAuthInfo.get_user_id(host)
149
- user_model = LSqliteDb.shared.query_user_info(user_id)
150
- user_model.expires_in = (created_at + expires_in)
151
- user_model.access_token = access_token
152
- user_model.refresh_token = refresh_token
153
- user_model.update_time = time_now
154
- user_model.type = 0
155
- LSqliteDb.shared.insert_user_info(user_model)
156
- LgPodPlugin.log_green "刷新token成功: `refresh_token` => #{refresh_token}, expires_in => #{expires_in}"
157
- return user_model
158
- rescue => exception
159
- LgPodPlugin.log_yellow "刷新 `access_token` 失败, error => #{exception.to_s}"
160
- return nil
161
- end
162
- end
25
+ # def self.check_gitlab_access_token_valid(uri, user_info)
26
+ # token_vaild = GitLabAPI.request_user_emails(uri.hostname, user_info.access_token)
27
+ # if token_vaild == "success"
28
+ # return user_info
29
+ # else
30
+ # LSqliteDb.shared.delete_user_info(user_info.id)
31
+ # LgPodPlugin.log_yellow "LSqliteDb.shared.delete_user_info(#{user_info.id}"
32
+ # return get_gitlab_access_token(uri, user_info.id)
33
+ # end
34
+ # end
163
35
 
164
36
  # 通过名称搜索项目信息
165
37
  def self.request_project_info(host, project_name, access_token, git = nil)
@@ -263,47 +135,6 @@ module LgPodPlugin
263
135
  end
264
136
  end
265
137
 
266
- # public
267
- # def self.get_podspec_file_content(host, token, project_id, sha, filepath)
268
- # begin
269
- # hash_map = Hash.new
270
- # hash_map["ref"] = sha
271
- # hash_map["access_token"] = token
272
- # uri = URI("#{host}/api/v4/projects/#{project_id}/repository/files/#{filepath}")
273
- # uri.query = URI.encode_www_form(hash_map)
274
- # res = Net::HTTP.get_response(uri)
275
- # case res
276
- # when Net::HTTPSuccess, Net::HTTPRedirection
277
- # json = JSON.parse(res.body)
278
- # else
279
- # body = JSON.parse(res.body)
280
- # message = body["message"]
281
- # if message == "404 Project Not Found"
282
- # LSqliteDb.shared.delete_project_by_id(project_id)
283
- # end
284
- # json = nil
285
- # end
286
- # return nil unless json && json.is_a?(Hash)
287
- # content = json["content"]
288
- # return nil unless content && LUtils.is_a_string?(content)
289
- # encoding = json["encoding"] ||= "base64"
290
- # if encoding == "base64"
291
- # require 'base64'
292
- # content = Base64.decode64(content)
293
- # if content.respond_to?(:encoding) && content.encoding.name != 'UTF-8'
294
- # text = content.force_encoding("gb2312").force_encoding("utf-8")
295
- # return text
296
- # else
297
- # return content
298
- # end
299
- # else
300
- # return nil
301
- # end
302
- # rescue
303
- # return nil
304
- # end
305
- # end
306
-
307
138
  # 通过名称搜索项目信息
308
139
  public
309
140
  def self.request_user_emails(host, access_token)
@@ -56,8 +56,8 @@ module LgPodPlugin
56
56
  else
57
57
  return nil
58
58
  end
59
- download_url = host + "/api/v4/projects/" + "#{project.id}" + "/repository/archive.tar.bz2\\?" + "sha\\=#{sha}"
60
- download_url += "\\&access_token\\=#{token}" if token
59
+ download_url = host + "/api/v4/projects/" + "#{project.id}" + "/repository/archive.tar.bz2?" + "sha=#{sha}"
60
+ download_url += "&access_token=#{token}" if token
61
61
  download_params = { "filename" => "#{self.name}.tar.bz2", "url" => download_url }
62
62
  end
63
63
 
@@ -16,14 +16,9 @@ module LgPodPlugin
16
16
  end
17
17
  end
18
18
 
19
- def self.ensure_matching_version
20
- cache = Pod::Downloader::Cache.new(LFileManager.cache_root_path)
21
- end
22
-
23
19
  public
24
20
  def self.run(command, options = {})
25
21
  clean_sandbox()
26
- ensure_matching_version()
27
22
  workspace = Pathname(Dir.pwd)
28
23
  update = (command == "update")
29
24
  LSqliteDb.shared.init_database
@@ -45,6 +40,8 @@ module LgPodPlugin
45
40
  all_installers = Hash.new
46
41
  project.targets.each do |target|
47
42
  target.dependencies.each do |_, pod|
43
+ checkout_options = pod.checkout_options
44
+ next unless checkout_options.has_key?(:git)
48
45
  installer = LPodInstaller.new
49
46
  download_params = installer.install(pod)
50
47
  if download_params
@@ -67,11 +67,10 @@ module LgPodPlugin
67
67
 
68
68
 
69
69
  def self.download_dependencies(installer)
70
- installer.send(:download_dependencies)
70
+ installer.download_dependencies
71
71
  installer.send(:validate_targets)
72
72
  installer.send(:clean_sandbox)
73
- installation_options = installer.send(:installation_options)
74
- skip_pods_project_generation = installation_options.send(:skip_pods_project_generation)
73
+ skip_pods_project_generation = installer.send(:installation_options).send(:skip_pods_project_generation)
75
74
  if skip_pods_project_generation
76
75
  installer.show_skip_pods_project_generation_message
77
76
  installer.send(:run_podfile_post_install_hooks)
@@ -1,3 +1,3 @@
1
1
  module LgPodPlugin
2
- VERSION = "1.1.8.2"
2
+ VERSION = "1.2.2"
3
3
  end
data/lib/lg_pod_plugin.rb CHANGED
@@ -26,7 +26,6 @@ require_relative 'lg_pod_plugin/git/gitlab_archive'
26
26
  require_relative 'lg_pod_plugin/downloader/downloader'
27
27
  require_relative 'lg_pod_plugin/git/git_download'
28
28
  require_relative 'lg_pod_plugin/git/git_clone'
29
- require_relative 'lg_pod_plugin/downloader/overload_cache'
30
29
 
31
30
  module LgPodPlugin
32
31
  autoload :Command, 'command/command'
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lg_pod_plugin
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.8.2
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - dongzb01
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-03-28 00:00:00.000000000 Z
11
+ date: 2024-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cocoapods
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 1.14.2
19
+ version: 1.15.2
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 1.14.2
26
+ version: 1.15.2
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: claide
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -58,20 +58,6 @@ dependencies:
58
58
  - - "~>"
59
59
  - !ruby/object:Gem::Version
60
60
  version: '1.1'
61
- - !ruby/object:Gem::Dependency
62
- name: bundler
63
- requirement: !ruby/object:Gem::Requirement
64
- requirements:
65
- - - "~>"
66
- - !ruby/object:Gem::Version
67
- version: 2.0.0
68
- type: :development
69
- prerelease: false
70
- version_requirements: !ruby/object:Gem::Requirement
71
- requirements:
72
- - - "~>"
73
- - !ruby/object:Gem::Version
74
- version: 2.0.0
75
61
  - !ruby/object:Gem::Dependency
76
62
  name: rake
77
63
  requirement: !ruby/object:Gem::Requirement
@@ -129,7 +115,6 @@ files:
129
115
  - lib/lg_pod_plugin/db/database.rb
130
116
  - lib/lg_pod_plugin/downloader/downloader.rb
131
117
  - lib/lg_pod_plugin/downloader/l_cache.rb
132
- - lib/lg_pod_plugin/downloader/overload_cache.rb
133
118
  - lib/lg_pod_plugin/downloader/request.rb
134
119
  - lib/lg_pod_plugin/git/git_clone.rb
135
120
  - lib/lg_pod_plugin/git/git_download.rb
@@ -171,7 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
171
156
  - !ruby/object:Gem::Version
172
157
  version: '0'
173
158
  requirements: []
174
- rubygems_version: 3.5.6
159
+ rubygems_version: 3.5.22
175
160
  signing_key:
176
161
  specification_version: 4
177
162
  summary: 封装了自定义podfile 中pod 方法
@@ -1,34 +0,0 @@
1
- require 'fileutils'
2
- require 'tmpdir'
3
-
4
- module Pod
5
- module Downloader
6
- # The class responsible for managing Pod downloads, transparently caching
7
- # them in a cache directory.
8
- #
9
- class Cache
10
-
11
-
12
- private
13
- # Ensures the cache on disk was created with the same CocoaPods version as
14
- # is currently running.
15
- #
16
- # @return [Void]
17
- #
18
- def ensure_matching_version
19
- version_file = root + 'VERSION'
20
- if version_file.file?
21
- version = version_file.read.strip
22
- else
23
- version = Pod::VERSION
24
- end
25
- pod_version = %x(bundle exec pod --version).split("\n").first
26
- if version != pod_version
27
- version = pod_version
28
- version_file.open('w') { |f| f << version }
29
- end
30
- end
31
-
32
- end
33
- end
34
- end