lg_pod_plugin 1.1.8.1 → 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: 64cfe9f5818b1ad35a426e047a1639889db338c028923af2e2cbc9c4e31556da
4
- data.tar.gz: ce53c502a2bbbeb261dfe3dc048a8e423848f7f29633956447c0abe1b474712d
3
+ metadata.gz: 4d24b5f9bdfaba6416cf330a12dedd8ea1188bbb88ac3c833282662f2aea34fe
4
+ data.tar.gz: 5a5de669f9e3db6867afa241bdf6fb80f00703e7359f860cec24cea5ef58a5e8
5
5
  SHA512:
6
- metadata.gz: 6a6f5bc095f471f44cb2effd225be4bcf1c10622374adbe7f00d2b7953f0be3b09f763307ba167456169ba862e629e0cdf3e5596228f093461ee98fb35c3b21d
7
- data.tar.gz: e081fa09f5ba85d7a9a581b30a8fabf9e83ce89c200bd020b3a9bdc0a8b6b955cf61b01fd1c0279ea2dbec406f77b6b790fd42397a2989632a3eb8fa918c5f28
6
+ metadata.gz: c597e21e3e7b4d7717a43e189bf8100af12c0a519fd61a7101c4c621ed0f14a314a4c4e85d99e6ac4c9762aa5a402da1fe7a116b754ba728144d2a15061430cc
7
+ data.tar.gz: 0c0ae53f0b22bae3b8e0c008d237cdebc7415f963cf1b56d1640488a3e68ddaca324875b45750b2fb3717eb724dbe33c99da55f5e14ab158213c1f82dccbd5ad
data/lib/command/init.rb CHANGED
@@ -38,7 +38,7 @@ module LgPodPlugin
38
38
  refresh_token = ""
39
39
  expires_in = 7879680
40
40
  created_at = Time.now.to_i
41
- encrypt_access_token = LUtils.encrypt(self.token, "AZMpxzVxzbo3sFDLRZMpxzVxzbo3sFDZ")
41
+ encrypt_access_token = self.token
42
42
  hash = {"access_token": encrypt_access_token}
43
43
  hash["token_type"] = "Bearer"
44
44
  hash["expires_in"] = expires_in
@@ -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,41 +87,44 @@ module LgPodPlugin
94
87
  return Pathname.new(path.to_path + '.podspec.json')
95
88
  end
96
89
 
97
- def self.get_local_spec(request, target)
98
- result = Pod::Downloader::Response.new
99
- result.location = target
100
- if request.released_pod?
101
- result.spec = request.spec
102
- local_specs = { request.name => request.spec }
103
- return [request, local_specs]
104
- else
105
- local_specs = {}
106
- pods_pecs = Pod::Sandbox::PodspecFinder.new(target).podspecs
107
- pods_pecs[request.name] = request.spec if request.spec
108
- pods_pecs.each do |name, spec|
109
- if request.name == name
110
- result.spec = spec
111
- local_specs[request.name] = spec
112
- end
90
+ def self.group_subspecs_by_platform(spec)
91
+ specs_by_platform = {}
92
+ [spec, *spec.recursive_subspecs].each do |ss|
93
+ ss.available_platforms.each do |platform|
94
+ specs_by_platform[platform] ||= []
95
+ specs_by_platform[platform] << ss
113
96
  end
114
97
  end
115
- [result, local_specs]
98
+ specs_by_platform
116
99
  end
117
100
 
118
101
  def self.copy_and_clean(source, destination, spec)
119
- return self.root_cache.copy_and_clean(source, destination, spec)
102
+ attributes_hash = spec.send(:attributes_hash) || {}
103
+ name = attributes_hash["name"] ||= ""
104
+ specs_by_platform = self.group_subspecs_by_platform(spec)
105
+ destination.parent.mkpath
106
+ should_copy = source && source.exist? && !source.children.empty?
107
+ Pod::Downloader::Cache.write_lock(destination) do
108
+ if should_copy
109
+ FileUtils.rm_rf(destination)
110
+ FileUtils.cp_r(source, destination)
111
+ LgPodPlugin.log_green "-> Copy #{name} from #{source} to #{destination}"
112
+ end
113
+ Pod::Installer::PodSourcePreparer.new(spec, destination).prepare!
114
+ Pod::Sandbox::PodDirCleaner.new(destination, specs_by_platform).clean!
115
+ end
120
116
  end
121
117
 
122
118
  public
123
-
124
119
  def self.write_spec(spec, path)
125
- self.root_cache.write_spec(spec, path)
120
+ path.dirname.mkpath
121
+ Pod::Downloader::Cache.write_lock(path) do
122
+ path.open('w') { |f| f.write spec.to_pretty_json }
123
+ end
126
124
  end
127
125
 
128
126
  # 拷贝 pod 缓存文件到 sandbox
129
-
130
127
  public
131
-
132
128
  def self.cache_pod(name, target, options = {}, spec = nil, released_pod = false)
133
129
  checkout_options = Hash.new.deep_merge(options).reject do |key, val|
134
130
  !key || !val
@@ -12,7 +12,6 @@ module LgPodPlugin
12
12
  attr_accessor :config
13
13
  attr_accessor :net_ping
14
14
  attr_accessor :params
15
- # attr_accessor :lockfile
16
15
  attr_accessor :checkout_options
17
16
  def initialize(pod)
18
17
  @name = pod.name
@@ -39,6 +39,7 @@ module LgPodPlugin
39
39
  project_name = LUtils.get_git_project_name self.git
40
40
  download_urls = self.download_archive_zip(project_name)
41
41
  download_params = Hash.new
42
+ download_params["token"] = ""
42
43
  download_params["name"] = self.name
43
44
  download_params["type"] = "github-tag"
44
45
  download_params["path"] = root_path.to_path
@@ -51,6 +52,7 @@ module LgPodPlugin
51
52
  download_urls = self.download_archive_zip(project_name)
52
53
  download_params = Hash.new
53
54
  download_params["name"] = self.name
55
+ download_params["token"] = ""
54
56
  download_params["type"] = "github-branch"
55
57
  download_params["path"] = root_path.to_path
56
58
  download_params = download_params.merge(download_urls)
@@ -61,6 +63,7 @@ module LgPodPlugin
61
63
  project_name = LUtils.get_git_project_name self.git
62
64
  download_urls = self.download_archive_zip(project_name)
63
65
  download_params = Hash.new
66
+ download_params["token"] = ""
64
67
  download_params["name"] = self.name
65
68
  download_params["type"] = "github-commit"
66
69
  download_params["path"] = root_path.to_path
@@ -9,158 +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
- 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
12
+ access_token = "TAun4FNUjCdtwsUrwsLG"
25
13
  user_id = LUserAuthInfo.get_user_id(uri.hostname)
26
14
  now_time = Time.now.to_i
27
- refresh_token = json["refresh_token"]
28
- expires_in = json["expires_in"] ||= 7879680
29
- created_at = json["created_at"] ||= now_time
15
+ refresh_token = access_token
16
+ expires_in = 7879680
17
+ created_at = now_time
30
18
  user_model = LUserAuthInfo.new(user_id, "", "", uri.hostname, access_token, refresh_token, (created_at + expires_in), now_time, 1)
31
19
  LSqliteDb.shared.insert_user_info(user_model)
32
20
  LgPodPlugin.log_green "请求成功: `access_token` => #{access_token}, expires_in => #{expires_in}"
33
21
  return user_model
34
22
  end
35
23
 
36
- # 通过输入用户名和密码 获取 access_token
37
- def self.get_gitlab_access_token_input(uri, user_id, username = nil, password = nil)
38
- unless username && password
39
- LgPodPlugin.log_yellow "请输入 `#{uri.to_s}` 的用户名"
40
- username = STDIN.gets.chomp
41
- LgPodPlugin.log_yellow "请输入 `#{uri.to_s}` 的密码"
42
- password = STDIN.noecho(&:gets).chomp
43
- end
44
- GitLabAPI.request_gitlab_access_token(uri.hostname, username, password)
45
- user_info = LSqliteDb.shared.query_user_info(user_id)
46
- return user_info
47
- end
48
24
  # 检查 token 是否在有效期内
49
- def self.check_gitlab_access_token_valid(uri, user_info)
50
- time_now = Time.now.to_i
51
- refresh_token = user_info.refresh_token
52
- if user_info.type == 1
53
- if user_info.expires_in <= time_now
54
- project_name = LUtils.get_git_project_name(uri.to_s)
55
- token_valid = GitLabAPI.request_user_emails(uri.hostname, user_info.access_token)
56
- if token_valid == "success"
57
- new_user_info = LUserAuthInfo.new(user_info.id, "", "", uri.hostname, user_info.access_token, nil, (time_now + 7879680), time_now, 1)
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
- return user_info
67
- end
68
- else
69
- # 判断 token 是否失效
70
- if user_info.expires_in <= time_now
71
- return refresh_user_token uri, refresh_token, user_info.id, user_info.username, user_info.password
72
- else
73
- update_time = user_info.update_time.to_i
74
- if time_now - update_time > 1800
75
- user_info = refresh_user_token uri, refresh_token, user_info.id, user_info.username, user_info.password
76
- return user_info
77
- else
78
- return user_info
79
- end
80
- end
81
- end
82
- end
83
-
84
- def self.refresh_user_token(uri, refresh_token, user_id, username, password)
85
- # 刷新 token 失败时, 通过已经保存的用户名密码来刷新 token
86
- new_user_info = GitLabAPI.refresh_gitlab_access_token uri.hostname, refresh_token
87
- unless new_user_info
88
- return GitLabAPI.get_gitlab_access_token_input(uri, user_id, username, password)
89
- end
90
- return new_user_info
91
- end
92
-
93
- public
94
- # 获取 GitLab access_token
95
- def self.request_gitlab_access_token(host, username, password)
96
- user_id = LUserAuthInfo.get_user_id(host)
97
- begin
98
- uri = URI("#{host}/oauth/token")
99
- hash_map = { "grant_type" => "password", "username" => username, "password" => password }
100
- LgPodPlugin.log_green "开始请求 access_token, url => #{uri.to_s} "
101
- req = Net::HTTP.post_form(uri, hash_map)
102
- json = JSON.parse(req.body)
103
- error = json["error"]
104
- if error != nil
105
- if error == "invalid_grant"
106
- LSqliteDb.shared.delete_user_info(user_id)
107
- LgPodPlugin.log_yellow "LSqliteDb.shared.delete_user_info(#{user_id}"
108
- end
109
- raise json["error_description"]
110
- end
111
- access_token = json["access_token"]
112
- refresh_token = json["refresh_token"]
113
- expires_in = json["expires_in"] ||= 7200
114
- created_at = json["created_at"] ||= Time.now.to_i
115
- time_now = Time.now.to_i
116
- user_model = LUserAuthInfo.new(user_id, username, password, host, access_token, refresh_token, (created_at + expires_in), time_now, 0)
117
- LSqliteDb.shared.insert_user_info(user_model)
118
- LgPodPlugin.log_green "请求成功: `access_token` => #{access_token}, expires_in => #{expires_in}"
119
- rescue => exception
120
- LgPodPlugin.log_red "获取 `access_token` 失败, error => #{exception.to_s}"
121
- end
122
- end
123
-
124
- # 刷新gitlab_token
125
- def self.refresh_gitlab_access_token(host, refresh_token)
126
- begin
127
- hash_map = Hash.new
128
- hash_map["scope"] = "api"
129
- hash_map["grant_type"] = "refresh_token"
130
- hash_map["refresh_token"] = refresh_token
131
- uri = URI("#{host}/oauth/token")
132
- res = Net::HTTP.post_form(uri, hash_map)
133
- if res.body
134
- json = JSON.parse(res.body)
135
- else
136
- json = nil
137
- end
138
- return nil unless json.is_a?(Hash)
139
- error = json["error"]
140
- if error != nil
141
- error_description = json["error_description"]
142
- raise error_description
143
- end
144
- time_now = Time.now.to_i
145
- access_token = json["access_token"]
146
- refresh_token = json["refresh_token"]
147
- expires_in = json["expires_in"] ||= 7200
148
- created_at = json["created_at"] ||= time_now
149
- user_id = LUserAuthInfo.get_user_id(host)
150
- user_model = LSqliteDb.shared.query_user_info(user_id)
151
- user_model.expires_in = (created_at + expires_in)
152
- user_model.access_token = access_token
153
- user_model.refresh_token = refresh_token
154
- user_model.update_time = time_now
155
- user_model.type = 0
156
- LSqliteDb.shared.insert_user_info(user_model)
157
- LgPodPlugin.log_green "刷新token成功: `refresh_token` => #{refresh_token}, expires_in => #{expires_in}"
158
- return user_model
159
- rescue => exception
160
- LgPodPlugin.log_yellow "刷新 `access_token` 失败, error => #{exception.to_s}"
161
- return nil
162
- end
163
- 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
164
35
 
165
36
  # 通过名称搜索项目信息
166
37
  def self.request_project_info(host, project_name, access_token, git = nil)
@@ -264,47 +135,6 @@ module LgPodPlugin
264
135
  end
265
136
  end
266
137
 
267
- # public
268
- # def self.get_podspec_file_content(host, token, project_id, sha, filepath)
269
- # begin
270
- # hash_map = Hash.new
271
- # hash_map["ref"] = sha
272
- # hash_map["access_token"] = token
273
- # uri = URI("#{host}/api/v4/projects/#{project_id}/repository/files/#{filepath}")
274
- # uri.query = URI.encode_www_form(hash_map)
275
- # res = Net::HTTP.get_response(uri)
276
- # case res
277
- # when Net::HTTPSuccess, Net::HTTPRedirection
278
- # json = JSON.parse(res.body)
279
- # else
280
- # body = JSON.parse(res.body)
281
- # message = body["message"]
282
- # if message == "404 Project Not Found"
283
- # LSqliteDb.shared.delete_project_by_id(project_id)
284
- # end
285
- # json = nil
286
- # end
287
- # return nil unless json && json.is_a?(Hash)
288
- # content = json["content"]
289
- # return nil unless content && LUtils.is_a_string?(content)
290
- # encoding = json["encoding"] ||= "base64"
291
- # if encoding == "base64"
292
- # require 'base64'
293
- # content = Base64.decode64(content)
294
- # if content.respond_to?(:encoding) && content.encoding.name != 'UTF-8'
295
- # text = content.force_encoding("gb2312").force_encoding("utf-8")
296
- # return text
297
- # else
298
- # return content
299
- # end
300
- # else
301
- # return nil
302
- # end
303
- # rescue
304
- # return nil
305
- # end
306
- # end
307
-
308
138
  # 通过名称搜索项目信息
309
139
  public
310
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
 
@@ -1,5 +1,4 @@
1
1
  require 'pp'
2
- # require 'git'
3
2
  require 'cgi'
4
3
  require 'cocoapods'
5
4
  require 'cocoapods-core'
@@ -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.1"
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.1
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-02-29 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,59 +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
- public
33
- def copy_and_clean(source, destination, spec)
34
- attributes_hash = spec.send(:attributes_hash) || {}
35
- name = attributes_hash["name"] ||= ""
36
- specs_by_platform = group_subspecs_by_platform(spec)
37
- destination.parent.mkpath
38
- Pod::Downloader::Cache.write_lock(destination) do
39
- if source && source.exist? && !source.children.empty?
40
- FileUtils.rm_rf(destination)
41
- FileUtils.cp_r(source, destination)
42
- end
43
- LgPodPlugin.log_green "-> Copy #{name} from #{source} to #{destination}"
44
- Pod::Installer::PodSourcePreparer.new(spec, destination).prepare!
45
- Pod::Sandbox::PodDirCleaner.new(destination, specs_by_platform).clean!
46
- end
47
- end
48
-
49
- public
50
- def write_spec(spec, path)
51
- path.dirname.mkpath
52
- Pod::Downloader::Cache.write_lock(path) do
53
- path.open('w') { |f| f.write spec.to_pretty_json }
54
- end
55
- end
56
-
57
- end
58
- end
59
- end