lg_pod_plugin 1.0.4 → 1.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (111) hide show
  1. checksums.yaml +4 -4
  2. data/lib/git/author.rb +14 -0
  3. data/lib/git/base/factory.rb +101 -0
  4. data/lib/git/base.rb +670 -0
  5. data/lib/git/branch.rb +126 -0
  6. data/lib/git/branches.rb +71 -0
  7. data/lib/git/config.rb +22 -0
  8. data/lib/git/diff.rb +155 -0
  9. data/lib/git/encoding_utils.rb +33 -0
  10. data/lib/git/escaped_path.rb +77 -0
  11. data/lib/git/index.rb +5 -0
  12. data/lib/git/lib.rb +1215 -0
  13. data/lib/git/log.rb +135 -0
  14. data/lib/git/object.rb +312 -0
  15. data/lib/git/path.rb +31 -0
  16. data/lib/git/remote.rb +36 -0
  17. data/lib/git/repository.rb +6 -0
  18. data/lib/git/stash.rb +27 -0
  19. data/lib/git/stashes.rb +55 -0
  20. data/lib/git/status.rb +199 -0
  21. data/lib/git/url.rb +127 -0
  22. data/lib/git/version.rb +5 -0
  23. data/lib/git/working_directory.rb +4 -0
  24. data/lib/git/worktree.rb +38 -0
  25. data/lib/git/worktrees.rb +47 -0
  26. data/lib/git.rb +326 -0
  27. data/lib/lg_pod_plugin/database.rb +104 -104
  28. data/lib/lg_pod_plugin/{download.rb → downloader.rb} +1 -1
  29. data/lib/lg_pod_plugin/file_path.rb +1 -1
  30. data/lib/lg_pod_plugin/git_util.rb +154 -50
  31. data/lib/lg_pod_plugin/install.rb +27 -21
  32. data/lib/lg_pod_plugin/l_cache.rb +13 -14
  33. data/lib/lg_pod_plugin/l_util.rb +39 -0
  34. data/lib/lg_pod_plugin/request.rb +9 -10
  35. data/lib/lg_pod_plugin/version.rb +1 -1
  36. data/lib/lg_pod_plugin.rb +1 -3
  37. data/lib/rchardet/big5freq.rb +927 -0
  38. data/lib/rchardet/big5prober.rb +42 -0
  39. data/lib/rchardet/chardistribution.rb +250 -0
  40. data/lib/rchardet/charsetgroupprober.rb +110 -0
  41. data/lib/rchardet/charsetprober.rb +70 -0
  42. data/lib/rchardet/codingstatemachine.rb +67 -0
  43. data/lib/rchardet/constants.rb +42 -0
  44. data/lib/rchardet/escprober.rb +90 -0
  45. data/lib/rchardet/escsm.rb +245 -0
  46. data/lib/rchardet/eucjpprober.rb +88 -0
  47. data/lib/rchardet/euckrfreq.rb +597 -0
  48. data/lib/rchardet/euckrprober.rb +42 -0
  49. data/lib/rchardet/euctwfreq.rb +431 -0
  50. data/lib/rchardet/euctwprober.rb +42 -0
  51. data/lib/rchardet/gb18030freq.rb +474 -0
  52. data/lib/rchardet/gb18030prober.rb +42 -0
  53. data/lib/rchardet/hebrewprober.rb +289 -0
  54. data/lib/rchardet/jisfreq.rb +571 -0
  55. data/lib/rchardet/jpcntx.rb +229 -0
  56. data/lib/rchardet/langbulgarianmodel.rb +229 -0
  57. data/lib/rchardet/langcyrillicmodel.rb +330 -0
  58. data/lib/rchardet/langgreekmodel.rb +227 -0
  59. data/lib/rchardet/langhebrewmodel.rb +202 -0
  60. data/lib/rchardet/langhungarianmodel.rb +226 -0
  61. data/lib/rchardet/langthaimodel.rb +201 -0
  62. data/lib/rchardet/latin1prober.rb +147 -0
  63. data/lib/rchardet/mbcharsetprober.rb +89 -0
  64. data/lib/rchardet/mbcsgroupprober.rb +47 -0
  65. data/lib/rchardet/mbcssm.rb +542 -0
  66. data/lib/rchardet/sbcharsetprober.rb +122 -0
  67. data/lib/rchardet/sbcsgroupprober.rb +58 -0
  68. data/lib/rchardet/sjisprober.rb +88 -0
  69. data/lib/rchardet/universaldetector.rb +179 -0
  70. data/lib/rchardet/utf8prober.rb +87 -0
  71. data/lib/rchardet/version.rb +3 -0
  72. data/lib/rchardet.rb +67 -0
  73. data/lib/zip/central_directory.rb +212 -0
  74. data/lib/zip/compressor.rb +9 -0
  75. data/lib/zip/constants.rb +115 -0
  76. data/lib/zip/crypto/decrypted_io.rb +40 -0
  77. data/lib/zip/crypto/encryption.rb +11 -0
  78. data/lib/zip/crypto/null_encryption.rb +43 -0
  79. data/lib/zip/crypto/traditional_encryption.rb +99 -0
  80. data/lib/zip/decompressor.rb +31 -0
  81. data/lib/zip/deflater.rb +34 -0
  82. data/lib/zip/dos_time.rb +53 -0
  83. data/lib/zip/entry.rb +719 -0
  84. data/lib/zip/entry_set.rb +88 -0
  85. data/lib/zip/errors.rb +19 -0
  86. data/lib/zip/extra_field/generic.rb +44 -0
  87. data/lib/zip/extra_field/ntfs.rb +94 -0
  88. data/lib/zip/extra_field/old_unix.rb +46 -0
  89. data/lib/zip/extra_field/universal_time.rb +77 -0
  90. data/lib/zip/extra_field/unix.rb +39 -0
  91. data/lib/zip/extra_field/zip64.rb +70 -0
  92. data/lib/zip/extra_field/zip64_placeholder.rb +15 -0
  93. data/lib/zip/extra_field.rb +103 -0
  94. data/lib/zip/file.rb +468 -0
  95. data/lib/zip/filesystem.rb +643 -0
  96. data/lib/zip/inflater.rb +54 -0
  97. data/lib/zip/input_stream.rb +180 -0
  98. data/lib/zip/ioextras/abstract_input_stream.rb +122 -0
  99. data/lib/zip/ioextras/abstract_output_stream.rb +43 -0
  100. data/lib/zip/ioextras.rb +36 -0
  101. data/lib/zip/null_compressor.rb +15 -0
  102. data/lib/zip/null_decompressor.rb +19 -0
  103. data/lib/zip/null_input_stream.rb +10 -0
  104. data/lib/zip/output_stream.rb +198 -0
  105. data/lib/zip/pass_thru_compressor.rb +23 -0
  106. data/lib/zip/pass_thru_decompressor.rb +31 -0
  107. data/lib/zip/streamable_directory.rb +15 -0
  108. data/lib/zip/streamable_stream.rb +52 -0
  109. data/lib/zip/version.rb +3 -0
  110. data/lib/zip.rb +72 -0
  111. metadata +103 -31
@@ -1,5 +1,6 @@
1
1
  require 'pp'
2
2
  require 'git'
3
+ require_relative 'l_util'
3
4
  require_relative 'request'
4
5
  require_relative 'l_cache'
5
6
 
@@ -19,24 +20,130 @@ module LgPodPlugin
19
20
  self.commit = options[:commit]
20
21
  end
21
22
 
23
+ # 根据branch 下载 zip 包
24
+ def git_download_branch_zip(path, temp_name)
25
+ token = ""
26
+ file_name = "#{temp_name}.zip"
27
+ base_url = self.git[0...self.git.length - 4]
28
+ project_name = base_url.split("/").last
29
+ unless project_name
30
+ return self.git_clone_by_branch(path, temp_name)
31
+ end
32
+ download_url = base_url + "/-/archive/" + self.branch + "/#{project_name}-#{self.branch}.zip"
33
+ LgPodPlugin.log_blue "开始下载 => #{download_url}"
34
+ system("curl --header PRIVATE-TOKEN:#{token} -o #{file_name} --connect-timeout 15 #{download_url}")
35
+ unless File.exist?(file_name)
36
+ LgPodPlugin.log_red("下载zip包失败, 尝试git clone #{self.git}")
37
+ return self.git_clone_by_branch(path, temp_name)
38
+ end
39
+ # 解压文件
40
+ result = LUtils.unzip_file(path.join(file_name).to_path, "./")
41
+ new_file_name = "#{project_name}-#{self.branch}"
42
+ unless result && File.exist?(new_file_name)
43
+ LgPodPlugin.log_red("解压文件失败, 尝试git clone #{self.git}")
44
+ return self.git_clone_by_branch(path, temp_name)
45
+ end
46
+ path.join(new_file_name)
47
+ end
48
+
49
+ # 通过tag下载zip包
50
+ def git_download_tag_zip(path, temp_name)
51
+ token = ""
52
+ base_url = self.git[0...self.git.length - 4]
53
+ project_name = base_url.split("/").last
54
+ unless project_name
55
+ return self.git_clone_by_tag(path, temp_name)
56
+ end
57
+ file_name = "#{temp_name}.zip"
58
+ download_url = base_url + "/-/archive/" + self.tag + "/#{project_name}-#{self.tag}.zip"
59
+ # 下载文件
60
+ LgPodPlugin.log_blue "开始下载 => #{download_url}"
61
+ system("curl -s --header PRIVATE-TOKEN:#{token} -o #{file_name} #{download_url}")
62
+ unless File.exist?(file_name)
63
+ LgPodPlugin.log_red("下载zip包失败, 尝试git clone #{self.git}")
64
+ return self.git_clone_by_tag(path, temp_name)
65
+ end
66
+ # 解压文件
67
+ result = LUtils.unzip_file(path.join(file_name).to_path, "./")
68
+ new_file_name = "#{project_name}-#{self.tag}"
69
+ unless result && File.exist?(new_file_name)
70
+ LgPodPlugin.log_red("解压文件失败, 尝试git clone #{self.git}")
71
+ return self.git_clone_by_tag(path, temp_name)
72
+ end
73
+ path.join(new_file_name)
74
+ end
75
+ # 通过 commit 下载zip包
76
+ def git_download_commit_zip(path, temp_name)
77
+ token = ""
78
+ base_url = self.git[0...self.git.length - 4]
79
+ project_name = base_url.split("/").last
80
+ unless project_name
81
+ return self.git_clone_by_commit(path, temp_name)
82
+ end
83
+ file_name = "#{temp_name}.zip"
84
+ download_url = base_url + "/-/archive/" + self.commit + "/#{project_name}-#{self.commit}.zip"
85
+ # 下载文件
86
+ LgPodPlugin.log_blue "开始下载 => #{download_url}"
87
+ system("curl -s --header PRIVATE-TOKEN:#{token} -o #{file_name} #{download_url}")
88
+ unless File.exist?(file_name)
89
+ LgPodPlugin.log_red("下载zip包失败, 尝试git clone #{self.git}")
90
+ return self.git_clone_by_commit(path, temp_name)
91
+ end
92
+ # 解压文件
93
+ result = LUtils.unzip_file(path.join(file_name).to_path, "./")
94
+ new_file_name = "#{project_name}-#{self.commit}"
95
+ unless result && File.exist?(new_file_name)
96
+ LgPodPlugin.log_red("解压文件失败, 尝试git clone #{self.git}")
97
+ return self.git_clone_by_commit(path, temp_name)
98
+ end
99
+ path.join(new_file_name)
100
+ end
101
+
102
+ def git_clone_by_branch(path, temp_name)
103
+ LgPodPlugin.log_blue "git clone --depth=1 --branch #{self.branch} #{self.git}"
104
+ system("git clone --depth=1 -b #{self.branch} #{self.git} #{temp_name}")
105
+ path.join(temp_name)
106
+ end
107
+
108
+ def git_clone_by_tag(path, temp_name)
109
+ LgPodPlugin.log_blue "git clone --tag #{self.tag} #{self.git}"
110
+ system("git clone --depth=1 -b #{self.tag} #{self.git} #{temp_name}")
111
+ path.join(temp_name)
112
+ end
113
+
114
+ def git_clone_by_commit(path, temp_name)
115
+ LgPodPlugin.log_blue "git clone #{self.git}"
116
+ Git.init(temp_name)
117
+ FileUtils.chdir(temp_name)
118
+ system("git remote add origin #{self.git}")
119
+ system("git fetch origin #{self.commit}")
120
+ system("git reset --hard FETCH_HEAD")
121
+ path.join(temp_name)
122
+ end
123
+
124
+ # clone 代码仓库
22
125
  def git_clone_repository(path)
23
126
  FileUtils.chdir(path)
24
127
  temp_name = "lg_temp_pod"
25
128
  if self.git && self.tag
26
- LgPodPlugin.log_blue "git clone --tag #{self.tag} #{self.git}"
27
- system("git clone --depth=1 -b #{self.tag} #{self.git} #{temp_name}")
129
+ if self.git.include?("xxx/capp/iOS")
130
+ return git_download_tag_zip(path, temp_name)
131
+ else
132
+ return self.git_clone_by_tag(path, temp_name)
133
+ end
28
134
  elsif self.git && self.branch
29
- LgPodPlugin.log_blue "git clone --depth=1 --branch #{self.branch} #{self.git}"
30
- system("git clone --depth=1 -b #{self.branch} #{self.git} #{temp_name}")
135
+ if self.git.include?("xxx/capp/iOS")
136
+ return self.git_download_branch_zip(path, temp_name)
137
+ else
138
+ return self.git_clone_by_branch(path, temp_name)
139
+ end
31
140
  elsif self.git && self.commit
32
- LgPodPlugin.log_blue "git clone #{self.git}"
33
- git = Git.init(temp_name)
34
- FileUtils.chdir(temp_name)
35
- system("git remote add origin #{self.git}")
36
- system("git fetch origin #{self.commit}")
37
- system("git reset --hard FETCH_HEAD")
38
- end
39
- return path.join(temp_name)
141
+ if self.git.include?("xxx/capp/iOS")
142
+ return self.git_download_commit_zip(path, temp_name)
143
+ else
144
+ return self.git_clone_by_commit(path, temp_name)
145
+ end
146
+ end
40
147
  end
41
148
 
42
149
  # def git_checkout(branch)
@@ -55,7 +162,7 @@ module LgPodPlugin
55
162
  else
56
163
  hash_map[:commit] = commit
57
164
  end
58
- return hash_map
165
+ hash_map
59
166
  end
60
167
 
61
168
  def pre_download_git_repository
@@ -76,36 +183,7 @@ module LgPodPlugin
76
183
  FileUtils.chdir(LFileManager.download_director)
77
184
  FileUtils.rm_rf(lg_pod_path)
78
185
  end
79
-
80
- # 本地pod库git操作
81
- def git_local_pod_check(path)
82
- FileUtils.chdir(path)
83
- git = Git.open(Pathname("./"))
84
- current_branch = git.current_branch
85
- last_stash_message = "#{current_branch}_pod_install_cache"
86
- if self.branch == current_branch || !self.branch
87
- # 是否恢复储藏内容到暂存区
88
- self.should_pull(git ,current_branch)
89
- else
90
- # 存储上一个 branch 未暂存的内容
91
- # 判断 git status 是否有要暂存的内容
92
- have_changes = git.status.changed.map { |change|
93
- change.to_s
94
- }
95
- # 如果有要暂存的内容, 就 git stash save
96
- unless have_changes.empty?
97
- # "当前#{current_branch}分支有未暂存的内容"
98
- git.branch.stashes.save(last_stash_message)
99
- end
100
- # 这里 checkout到目标分支, 本地有git switch -b xxx, 本地没有 git checkout -b xxx
101
- git.checkout(git.branch(branch))
102
- current_branch = git.current_branch
103
- self.should_pull(git ,current_branch)
104
- # 是否恢复储藏内容到暂存区
105
- self.should_pop_stash(git, current_branch)
106
- end
107
- end
108
-
186
+
109
187
  # 获取最新的一条 commit 信息
110
188
  def self.git_ls_remote_refs(git, branch, tag, commit)
111
189
  if branch
@@ -125,27 +203,53 @@ module LgPodPlugin
125
203
  new_commit = map[key][:sha]
126
204
  return [nil, new_commit]
127
205
  else
128
- new_commit = nil
129
- new_branch = nil
130
- find_commit = commit ||= ls["head"][:sha]
206
+ new_commit = new_branch = nil
207
+ find_commit = commit ? commit : ls["head"][:sha]
131
208
  ls["branches"].each do |key, value|
132
209
  sha = value[:sha]
133
210
  next if sha != find_commit
134
211
  new_branch = key
135
212
  new_commit = find_commit
136
213
  return [new_branch, new_commit]
137
- break
138
214
  end
139
215
  return [new_branch , new_commit]
140
216
  end
141
217
  end
142
-
218
+
219
+ # 本地pod库git操作
220
+ def git_local_pod_check(path)
221
+ FileUtils.chdir(path)
222
+ git = Git.open(Pathname("./"))
223
+ current_branch = git.current_branch
224
+ last_stash_message = "#{current_branch}_pod_install_cache"
225
+ if self.branch == current_branch || !self.branch
226
+ # 是否恢复储藏内容到暂存区
227
+ self.should_pull(git ,current_branch)
228
+ else
229
+ # 存储上一个 branch 未暂存的内容
230
+ # 判断 git status 是否有要暂存的内容
231
+ have_changes = git.status.changed.map { |change|
232
+ change.to_s
233
+ }
234
+ # 如果有要暂存的内容, 就 git stash save
235
+ unless have_changes.empty?
236
+ # "当前#{current_branch}分支有未暂存的内容"
237
+ git.branch.stashes.save(last_stash_message)
238
+ end
239
+ # 这里 checkout到目标分支, 本地有git switch -b xxx, 本地没有 git checkout -b xxx
240
+ git.checkout(git.branch(branch))
241
+ current_branch = git.current_branch
242
+ self.should_pull(git ,current_branch)
243
+ # 是否恢复储藏内容到暂存区
244
+ self.should_pop_stash(git, current_branch)
245
+ end
246
+ end
143
247
  # 是否pull 代码
144
248
  def should_pull(git, branch, new_commit = nil)
145
- new_barnch = branch ||= self.branch
249
+ new_branch = branch ||= self.branch
146
250
  git_url = git.remote.url ||= self.git
147
251
  if new_commit == nil
148
- new_branch, new_commit = LGitUtil.git_ls_remote_refs(git_url, new_barnch,nil, nil)
252
+ _, new_commit = LGitUtil.git_ls_remote_refs(git_url, new_branch,nil, nil)
149
253
  end
150
254
  local_commit = git.log(1).to_s #本地最后一条 commit hash 值
151
255
  if local_commit != new_commit
@@ -1,12 +1,11 @@
1
1
  require 'pp'
2
2
  require 'git'
3
3
  require 'cgi'
4
- require 'sqlite3'
5
4
  require 'cocoapods'
6
5
  require_relative 'request'
7
6
  require_relative 'database'
8
- require_relative 'download'
9
7
  require_relative 'git_util'
8
+ require_relative 'downloader.rb'
10
9
 
11
10
  module LgPodPlugin
12
11
 
@@ -70,16 +69,16 @@ module LgPodPlugin
70
69
  end
71
70
 
72
71
  # 根据pod name安装, pod 'AFNetworking'
73
- if !requirements
72
+ unless requirements
74
73
  self.target.store_pod(self.real_name)
75
74
  return
76
75
  end
77
- # 根据name, verison 安装, pod 'AFNetworking', "1.0.1"
76
+ # 根据name, version 安装, pod 'AFNetworking', "1.0.1"
78
77
  if self.version && !self.options
79
78
  self.target.store_pod(self.real_name, self.version)
80
79
  return
81
80
  end
82
- # 根据name, verison 安装, pod 'AFNetworking', "1.0.1", :configurations => ["Debug"]
81
+ # 根据name, version 安装, pod 'AFNetworking', "1.0.1", :configurations => ["Debug"]
83
82
  if self.version && self.options
84
83
  hash_map = self.options
85
84
  # hash_map.delete(:cache)
@@ -96,41 +95,48 @@ module LgPodPlugin
96
95
  path = hash_map[:path]
97
96
  if path
98
97
  self.install_local_pod(name, path, options)
99
- return
98
+ else
99
+ hash_map.delete(:path)
100
+ self.install_remote_pod(name, hash_map)
100
101
  end
101
- hash_map.delete(:path)
102
- git = hash_map[:git]
103
- # 根据git_url 下载远程仓库
102
+
103
+ end
104
+
105
+ public
106
+ def install_remote_pod(name, options = {})
107
+ git = options[:git]
104
108
  if git
105
109
  LRequest.shared.downloader.pre_download_pod
106
- # hash_map.delete(:cache)
107
- self.target.store_pod(self.real_name, hash_map)
110
+ self.target.store_pod(self.real_name, options)
108
111
  else
109
- #hash_map.delete(:cache)
110
- self.target.store_pod(self.real_name, hash_map)
112
+ LgPodPlugin.log_red "pod `#{name}` 的参数 path, git , tag , commit不正确"
111
113
  end
112
-
113
114
  end
114
115
 
115
116
  public
116
117
  #安装本地pod
117
118
  def install_local_pod(name, relative_path, options = {})
118
119
  hash_map = options
119
- branch = options[:branch]
120
120
  absolute_path = Pathname.new(relative_path).expand_path(self.workspace)
121
+
121
122
  unless absolute_path.exist?
122
- LgPodPlugin.log_red("pod `#{name}` at path => #{relative_path} 找不到")
123
+ hash_map.delete(:path)
124
+ self.install_remote_pod(name, hash_map)
123
125
  return
124
126
  end
125
- unless Dir.glob(File.expand_path(".git", absolute_path)).count > 0
126
- LgPodPlugin.log_red("pod `#{name}` at path => #{absolute_path} 找不到.git目录")
127
+
128
+ if Dir.glob(File.expand_path(".git", absolute_path)).empty?
129
+ hash_map.delete(:path)
130
+ self.install_remote_pod(name, hash_map)
127
131
  return
128
132
  end
129
- unless Dir.glob(File.expand_path("#{name}.podspec", absolute_path)).count > 0
130
- LgPodPlugin.log_red("pod `#{name}` at path => #{absolute_path} 找不到#{name}.podspec文件")
133
+
134
+ if Dir.glob(File.expand_path("#{name}.podspec", absolute_path)).empty?
135
+ hash_map.delete(:path)
136
+ self.install_remote_pod(name, hash_map)
131
137
  return
132
138
  end
133
- LRequest.shared.git_util.git_local_pod_check(absolute_path)
139
+ # LRequest.shared.git_util.git_local_pod_check(absolute_path)
134
140
  hash_map.delete(:tag)
135
141
  hash_map.delete(:git)
136
142
  # hash_map.delete(:cache)
@@ -26,7 +26,7 @@ module LgPodPlugin
26
26
  end
27
27
 
28
28
  #根据git branch commit 返回请求参数用来获取缓存 path
29
- def get_request_params(name, git, branch, tag, commit)
29
+ def get_request_params(git, branch, tag, commit)
30
30
  options = { :git => git }
31
31
  if git && tag
32
32
  options[:tag] = tag
@@ -41,30 +41,29 @@ module LgPodPlugin
41
41
  elsif git && commit
42
42
  options[:commit] = commit
43
43
  end
44
- return options
44
+ options
45
45
  end
46
46
  #判断缓存是否存在且有效命中缓存
47
47
  def find_pod_cache(name, git, branch, tag, commit, is_update)
48
- hash_map = nil
49
48
  if is_update
50
- hash_map = self.get_request_params(name, git, branch, tag, commit)
49
+ hash_map = self.get_request_params(git, branch, tag, commit)
51
50
  else
52
51
  if LRequest.shared.lock_params
53
52
  lock_tag = LRequest.shared.lock_params[:tag]
54
53
  lock_branch = LRequest.shared.lock_params[:branch]
55
54
  lock_commit = LRequest.shared.lock_params[:commit]
56
- hash_map = self.get_request_params(name, git, lock_branch, lock_tag, lock_commit)
55
+ hash_map = self.get_request_params(git, lock_branch, lock_tag, lock_commit)
57
56
  else
58
- hash_map = self.get_request_params(name, git, branch, tag, commit)
57
+ hash_map = self.get_request_params(git, branch, tag, commit)
59
58
  end
60
59
  end
61
60
  request = LCache.download_request(name, hash_map)
62
61
  destination = LCache.path_for_pod(request, {})
63
62
  cache_pod_spec = LCache.path_for_spec(request, {})
64
63
  if File.exist?(destination) && File.exist?(cache_pod_spec)
65
- return false
64
+ false
66
65
  else
67
- return true
66
+ true
68
67
  end
69
68
  end
70
69
 
@@ -104,9 +103,9 @@ module LgPodPlugin
104
103
  return [request, local_specs]
105
104
  else
106
105
  local_specs = {}
107
- podspecs = Pod::Sandbox::PodspecFinder.new(target).podspecs
108
- podspecs[request.name] = request.spec if request.spec
109
- podspecs.each do |name, spec|
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|
110
109
  if request.name == name
111
110
  result.spec = spec
112
111
  local_specs[request.name] = spec
@@ -186,12 +185,12 @@ module LgPodPlugin
186
185
  result.location = nil
187
186
  pods_pecs.each do |s_name, s_spec|
188
187
  destination = path_for_pod(request, {})
189
- if !File.exist?(destination)
188
+ unless File.exist?(destination)
190
189
  LgPodPlugin.log_green "Copying #{name} from `#{target}` to `#{destination}` "
191
190
  copy_and_clean(target, destination, s_spec)
192
191
  end
193
192
  cache_pod_spec = path_for_spec(request, {})
194
- if !File.exist?(cache_pod_spec)
193
+ unless File.exist?(cache_pod_spec)
195
194
  write_spec(s_spec, cache_pod_spec)
196
195
  end
197
196
  if request.name == s_name
@@ -218,7 +217,7 @@ module LgPodPlugin
218
217
  end
219
218
 
220
219
  # 根据下载参数生产缓存目录
221
- def slug(name, params, spec)
220
+ def slug(params, spec)
222
221
  path = ""
223
222
  checksum = spec&.checksum && '-' << spec.checksum[0, 5]
224
223
  opts = params.to_a.sort_by(&:first).map { |k, v| "#{k}=#{v}" }.join('-')
@@ -0,0 +1,39 @@
1
+ require 'zip'
2
+ module LgPodPlugin
3
+ class LUtils
4
+ def self.unzip_file (zip_file, dest_dir)
5
+ begin
6
+ Zip::File.open(zip_file) do |file|
7
+ file.each do |f|
8
+ file_path = File.join(dest_dir, f.name)
9
+ FileUtils.mkdir_p(File.dirname(file_path))
10
+ next if file_path.include?("Example")
11
+ # next if file_path.include?("LICENSE")
12
+ next if file_path.include?(".gitignore")
13
+ next if file_path.include?("node_modules")
14
+ next if file_path.include?("package.json")
15
+ next if file_path.include?(".swiftlint.yml")
16
+ next if file_path.include?("_Pods.xcodeproj")
17
+ next if file_path.include?("package-lock.json")
18
+ file.extract(f, file_path)
19
+ end
20
+ end
21
+ return true
22
+ rescue => err
23
+ puts err
24
+ return false
25
+ end
26
+
27
+ end
28
+
29
+ def self.aes_decrypt(key, data)
30
+ de_cipher = OpenSSL::Cipher::Cipher.new("AES-128-CBC")
31
+ de_cipher.decrypt
32
+ de_cipher.key = [key].pack('H*')
33
+ # de_cipher.iv = [iv].pack('H*');
34
+ puts de_cipher.update([data].pack('H*')) << de_cipher.final
35
+ end
36
+
37
+
38
+ end
39
+ end
@@ -2,7 +2,7 @@ require 'singleton'
2
2
  require 'yaml'
3
3
  require_relative 'l_cache'
4
4
  require_relative 'git_util'
5
- require_relative 'download'
5
+ require_relative 'downloader.rb'
6
6
  module LgPodPlugin
7
7
 
8
8
  class LRequest
@@ -30,10 +30,9 @@ module LgPodPlugin
30
30
  lock_file = self.workspace.join("Podfile.lock")
31
31
  if lock_file.exist?
32
32
  json = YAML.load_file(lock_file.to_path)
33
- external_sources = json["EXTERNAL SOURCES"]
34
- return external_sources
33
+ json["EXTERNAL SOURCES"]
35
34
  else
36
- return nil
35
+ nil
37
36
  end
38
37
  end
39
38
 
@@ -63,7 +62,7 @@ module LgPodPlugin
63
62
  elsif commit == lock_commit
64
63
  return { :git => git, :commit => lock_commit }
65
64
  else
66
- return nil
65
+ nil
67
66
  end
68
67
  end
69
68
 
@@ -88,11 +87,11 @@ module LgPodPlugin
88
87
  if lock_tag == tag && lock_commit
89
88
  hash_map[:commit] = lock_commit
90
89
  else
91
- new_branch, new_commit = LGitUtil.git_ls_remote_refs(git, branch, tag,commit)
90
+ _, new_commit = LGitUtil.git_ls_remote_refs(git, branch, tag, commit)
92
91
  hash_map[:commit] = new_commit
93
92
  end
94
93
  else
95
- new_branch, new_commit = LGitUtil.git_ls_remote_refs(git, branch, tag,commit)
94
+ _, new_commit = LGitUtil.git_ls_remote_refs(git, branch, tag,commit)
96
95
  hash_map[:commit] = new_commit
97
96
  end
98
97
  elsif git && commit
@@ -114,14 +113,14 @@ module LgPodPlugin
114
113
  if branch == lock_branch && lock_commit
115
114
  hash_map[:commit] = lock_commit
116
115
  else
117
- new_branch, new_commit = LGitUtil.git_ls_remote_refs(git, branch, tag, commit)
116
+ _, new_commit = LGitUtil.git_ls_remote_refs(git, branch, tag, commit)
118
117
  hash_map[:commit] = new_commit
119
118
  end
120
119
  else
121
- new_branch, new_commit = LGitUtil.git_ls_remote_refs(git, branch, tag, commit)
120
+ _, new_commit = LGitUtil.git_ls_remote_refs(git, branch, tag, commit)
122
121
  hash_map[:commit] = new_commit
123
122
  end
124
- else
123
+ elsif !path
125
124
  new_branch, new_commit = LGitUtil.git_ls_remote_refs(git, branch, tag, commit)
126
125
  hash_map[:commit] = new_commit
127
126
  hash_map[:branch] = new_branch
@@ -1,3 +1,3 @@
1
1
  module LgPodPlugin
2
- VERSION = "1.0.4"
2
+ VERSION = "1.0.6"
3
3
  end
data/lib/lg_pod_plugin.rb CHANGED
@@ -1,14 +1,12 @@
1
1
  require 'git'
2
- require 'sqlite3'
3
2
  require 'cocoapods-downloader'
4
3
  require 'cocoapods-core/podfile/target_definition'
5
-
6
4
  require "lg_pod_plugin/version"
7
5
  require_relative 'lg_pod_plugin/log'
8
6
  require_relative 'lg_pod_plugin/install'
9
7
  require_relative 'lg_pod_plugin/request'
10
8
  require_relative 'lg_pod_plugin/database'
11
- require_relative 'lg_pod_plugin/download'
9
+ require_relative 'lg_pod_plugin/downloader.rb'
12
10
  require_relative 'lg_pod_plugin/git_util'
13
11
 
14
12
  module LgPodPlugin