lg_pod_plugin 1.0.4 → 1.0.7

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 +163 -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 +37 -12
  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,139 @@ 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 = LRequest.shared.token
26
+ unless token
27
+ return self.git_clone_by_branch(path, temp_name)
28
+ end
29
+ file_name = "#{temp_name}.zip"
30
+ base_url = self.git[0...self.git.length - 4]
31
+ project_name = base_url.split("/").last
32
+ unless project_name
33
+ return self.git_clone_by_branch(path, temp_name)
34
+ end
35
+ download_url = base_url + "/-/archive/" + self.branch + "/#{project_name}-#{self.branch}.zip"
36
+ LgPodPlugin.log_blue "开始下载 => #{download_url}"
37
+ system("curl --header PRIVATE-TOKEN:#{token} -o #{file_name} --connect-timeout 15 #{download_url}")
38
+ unless File.exist?(file_name)
39
+ LgPodPlugin.log_red("下载zip包失败, 尝试git clone #{self.git}")
40
+ return self.git_clone_by_branch(path, temp_name)
41
+ end
42
+ # 解压文件
43
+ result = LUtils.unzip_file(path.join(file_name).to_path, "./")
44
+ new_file_name = "#{project_name}-#{self.branch}"
45
+ unless result && File.exist?(new_file_name)
46
+ LgPodPlugin.log_red("解压文件失败, 尝试git clone #{self.git}")
47
+ return self.git_clone_by_branch(path, temp_name)
48
+ end
49
+ path.join(new_file_name)
50
+ end
51
+
52
+ # 通过tag下载zip包
53
+ def git_download_tag_zip(path, temp_name)
54
+ token = LRequest.shared.token
55
+ unless token
56
+ return self.git_clone_by_tag(path, temp_name)
57
+ end
58
+ base_url = self.git[0...self.git.length - 4]
59
+ project_name = base_url.split("/").last
60
+ unless project_name
61
+ return self.git_clone_by_tag(path, temp_name)
62
+ end
63
+ file_name = "#{temp_name}.zip"
64
+ download_url = base_url + "/-/archive/" + self.tag + "/#{project_name}-#{self.tag}.zip"
65
+ # 下载文件
66
+ LgPodPlugin.log_blue "开始下载 => #{download_url}"
67
+ system("curl -s --header PRIVATE-TOKEN:#{token} -o #{file_name} #{download_url}")
68
+ unless File.exist?(file_name)
69
+ LgPodPlugin.log_red("下载zip包失败, 尝试git clone #{self.git}")
70
+ return self.git_clone_by_tag(path, temp_name)
71
+ end
72
+ # 解压文件
73
+ result = LUtils.unzip_file(path.join(file_name).to_path, "./")
74
+ new_file_name = "#{project_name}-#{self.tag}"
75
+ unless result && File.exist?(new_file_name)
76
+ LgPodPlugin.log_red("解压文件失败, 尝试git clone #{self.git}")
77
+ return self.git_clone_by_tag(path, temp_name)
78
+ end
79
+ path.join(new_file_name)
80
+ end
81
+ # 通过 commit 下载zip包
82
+ def git_download_commit_zip(path, temp_name)
83
+ token = LRequest.shared.token
84
+ unless token
85
+ return self.git_clone_by_commit(path, temp_name)
86
+ end
87
+ base_url = self.git[0...self.git.length - 4]
88
+ project_name = base_url.split("/").last
89
+ unless project_name
90
+ return self.git_clone_by_commit(path, temp_name)
91
+ end
92
+ file_name = "#{temp_name}.zip"
93
+ download_url = base_url + "/-/archive/" + self.commit + "/#{project_name}-#{self.commit}.zip"
94
+ # 下载文件
95
+ LgPodPlugin.log_blue "开始下载 => #{download_url}"
96
+ system("curl -s --header PRIVATE-TOKEN:#{token} -o #{file_name} #{download_url}")
97
+ unless File.exist?(file_name)
98
+ LgPodPlugin.log_red("下载zip包失败, 尝试git clone #{self.git}")
99
+ return self.git_clone_by_commit(path, temp_name)
100
+ end
101
+ # 解压文件
102
+ result = LUtils.unzip_file(path.join(file_name).to_path, "./")
103
+ new_file_name = "#{project_name}-#{self.commit}"
104
+ unless result && File.exist?(new_file_name)
105
+ LgPodPlugin.log_red("解压文件失败, 尝试git clone #{self.git}")
106
+ return self.git_clone_by_commit(path, temp_name)
107
+ end
108
+ path.join(new_file_name)
109
+ end
110
+
111
+ def git_clone_by_branch(path, temp_name)
112
+ LgPodPlugin.log_blue "git clone --depth=1 --branch #{self.branch} #{self.git}"
113
+ system("git clone --depth=1 -b #{self.branch} #{self.git} #{temp_name}")
114
+ path.join(temp_name)
115
+ end
116
+
117
+ def git_clone_by_tag(path, temp_name)
118
+ LgPodPlugin.log_blue "git clone --tag #{self.tag} #{self.git}"
119
+ system("git clone --depth=1 -b #{self.tag} #{self.git} #{temp_name}")
120
+ path.join(temp_name)
121
+ end
122
+
123
+ def git_clone_by_commit(path, temp_name)
124
+ LgPodPlugin.log_blue "git clone #{self.git}"
125
+ Git.init(temp_name)
126
+ FileUtils.chdir(temp_name)
127
+ system("git remote add origin #{self.git}")
128
+ system("git fetch origin #{self.commit}")
129
+ system("git reset --hard FETCH_HEAD")
130
+ path.join(temp_name)
131
+ end
132
+
133
+ # clone 代码仓库
22
134
  def git_clone_repository(path)
23
135
  FileUtils.chdir(path)
24
136
  temp_name = "lg_temp_pod"
25
137
  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}")
138
+ if self.git.include?("capp/iOS")
139
+ return git_download_tag_zip(path, temp_name)
140
+ else
141
+ return self.git_clone_by_tag(path, temp_name)
142
+ end
28
143
  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}")
144
+ if self.git.include?("capp/iOS")
145
+ return self.git_download_branch_zip(path, temp_name)
146
+ else
147
+ return self.git_clone_by_branch(path, temp_name)
148
+ end
31
149
  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)
150
+ if self.git.include?("capp/iOS")
151
+ return self.git_download_commit_zip(path, temp_name)
152
+ else
153
+ return self.git_clone_by_commit(path, temp_name)
154
+ end
155
+ end
40
156
  end
41
157
 
42
158
  # def git_checkout(branch)
@@ -55,7 +171,7 @@ module LgPodPlugin
55
171
  else
56
172
  hash_map[:commit] = commit
57
173
  end
58
- return hash_map
174
+ hash_map
59
175
  end
60
176
 
61
177
  def pre_download_git_repository
@@ -76,36 +192,7 @@ module LgPodPlugin
76
192
  FileUtils.chdir(LFileManager.download_director)
77
193
  FileUtils.rm_rf(lg_pod_path)
78
194
  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
-
195
+
109
196
  # 获取最新的一条 commit 信息
110
197
  def self.git_ls_remote_refs(git, branch, tag, commit)
111
198
  if branch
@@ -125,27 +212,53 @@ module LgPodPlugin
125
212
  new_commit = map[key][:sha]
126
213
  return [nil, new_commit]
127
214
  else
128
- new_commit = nil
129
- new_branch = nil
130
- find_commit = commit ||= ls["head"][:sha]
215
+ new_commit = new_branch = nil
216
+ find_commit = commit ? commit : ls["head"][:sha]
131
217
  ls["branches"].each do |key, value|
132
218
  sha = value[:sha]
133
219
  next if sha != find_commit
134
220
  new_branch = key
135
221
  new_commit = find_commit
136
222
  return [new_branch, new_commit]
137
- break
138
223
  end
139
224
  return [new_branch , new_commit]
140
225
  end
141
226
  end
142
-
227
+
228
+ # 本地pod库git操作
229
+ def git_local_pod_check(path)
230
+ FileUtils.chdir(path)
231
+ git = Git.open(Pathname("./"))
232
+ current_branch = git.current_branch
233
+ last_stash_message = "#{current_branch}_pod_install_cache"
234
+ if self.branch == current_branch || !self.branch
235
+ # 是否恢复储藏内容到暂存区
236
+ self.should_pull(git ,current_branch)
237
+ else
238
+ # 存储上一个 branch 未暂存的内容
239
+ # 判断 git status 是否有要暂存的内容
240
+ have_changes = git.status.changed.map { |change|
241
+ change.to_s
242
+ }
243
+ # 如果有要暂存的内容, 就 git stash save
244
+ unless have_changes.empty?
245
+ # "当前#{current_branch}分支有未暂存的内容"
246
+ git.branch.stashes.save(last_stash_message)
247
+ end
248
+ # 这里 checkout到目标分支, 本地有git switch -b xxx, 本地没有 git checkout -b xxx
249
+ git.checkout(git.branch(branch))
250
+ current_branch = git.current_branch
251
+ self.should_pull(git ,current_branch)
252
+ # 是否恢复储藏内容到暂存区
253
+ self.should_pop_stash(git, current_branch)
254
+ end
255
+ end
143
256
  # 是否pull 代码
144
257
  def should_pull(git, branch, new_commit = nil)
145
- new_barnch = branch ||= self.branch
258
+ new_branch = branch ||= self.branch
146
259
  git_url = git.remote.url ||= self.git
147
260
  if new_commit == nil
148
- new_branch, new_commit = LGitUtil.git_ls_remote_refs(git_url, new_barnch,nil, nil)
261
+ _, new_commit = LGitUtil.git_ls_remote_refs(git_url, new_branch,nil, nil)
149
262
  end
150
263
  local_commit = git.log(1).to_s #本地最后一条 commit hash 值
151
264
  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
@@ -1,13 +1,15 @@
1
- require 'singleton'
2
1
  require 'yaml'
2
+ require 'json'
3
+ require 'net/http'
4
+ require 'singleton'
3
5
  require_relative 'l_cache'
4
6
  require_relative 'git_util'
5
- require_relative 'download'
7
+ require_relative 'downloader.rb'
6
8
  module LgPodPlugin
7
9
 
8
10
  class LRequest
9
11
  include Singleton
10
- REQUIRED_ATTRS ||= %i[name options workspace cache downloader git_util lock_info lock_params is_update].freeze
12
+ REQUIRED_ATTRS ||= %i[name options workspace cache downloader git_util lock_info lock_params is_update token].freeze
11
13
  attr_accessor(*REQUIRED_ATTRS)
12
14
 
13
15
  def is_update_pod
@@ -30,10 +32,9 @@ module LgPodPlugin
30
32
  lock_file = self.workspace.join("Podfile.lock")
31
33
  if lock_file.exist?
32
34
  json = YAML.load_file(lock_file.to_path)
33
- external_sources = json["EXTERNAL SOURCES"]
34
- return external_sources
35
+ json["EXTERNAL SOURCES"]
35
36
  else
36
- return nil
37
+ nil
37
38
  end
38
39
  end
39
40
 
@@ -63,7 +64,7 @@ module LgPodPlugin
63
64
  elsif commit == lock_commit
64
65
  return { :git => git, :commit => lock_commit }
65
66
  else
66
- return nil
67
+ nil
67
68
  end
68
69
  end
69
70
 
@@ -88,11 +89,11 @@ module LgPodPlugin
88
89
  if lock_tag == tag && lock_commit
89
90
  hash_map[:commit] = lock_commit
90
91
  else
91
- new_branch, new_commit = LGitUtil.git_ls_remote_refs(git, branch, tag,commit)
92
+ _, new_commit = LGitUtil.git_ls_remote_refs(git, branch, tag, commit)
92
93
  hash_map[:commit] = new_commit
93
94
  end
94
95
  else
95
- new_branch, new_commit = LGitUtil.git_ls_remote_refs(git, branch, tag,commit)
96
+ _, new_commit = LGitUtil.git_ls_remote_refs(git, branch, tag,commit)
96
97
  hash_map[:commit] = new_commit
97
98
  end
98
99
  elsif git && commit
@@ -114,18 +115,21 @@ module LgPodPlugin
114
115
  if branch == lock_branch && lock_commit
115
116
  hash_map[:commit] = lock_commit
116
117
  else
117
- new_branch, new_commit = LGitUtil.git_ls_remote_refs(git, branch, tag, commit)
118
+ _, new_commit = LGitUtil.git_ls_remote_refs(git, branch, tag, commit)
118
119
  hash_map[:commit] = new_commit
119
120
  end
120
121
  else
121
- new_branch, new_commit = LGitUtil.git_ls_remote_refs(git, branch, tag, commit)
122
+ _, new_commit = LGitUtil.git_ls_remote_refs(git, branch, tag, commit)
122
123
  hash_map[:commit] = new_commit
123
124
  end
124
- else
125
+ elsif !path
125
126
  new_branch, new_commit = LGitUtil.git_ls_remote_refs(git, branch, tag, commit)
126
127
  hash_map[:commit] = new_commit
127
128
  hash_map[:branch] = new_branch
128
129
  end
130
+ if self.token == nil
131
+ self.token = self.request_gitlab_token(git)
132
+ end
129
133
  self.options = hash_map
130
134
  self.cache = LCache.new(self.workspace)
131
135
  self.git_util = LGitUtil.new(name, hash_map)
@@ -136,6 +140,27 @@ module LgPodPlugin
136
140
  return LRequest.instance
137
141
  end
138
142
 
143
+ def request_gitlab_token(git)
144
+ if git == nil
145
+ return nil
146
+ end
147
+ begin
148
+ #81.69.242.162
149
+ uri = URI('http://81.69.242.162:8080/v1/member/user/gitlab/token')
150
+ # uri = URI('http://127.0.0.1:8080/v1/member/user/gitlab/token')
151
+ params = {"url" => git}
152
+ res = Net::HTTP.post_form(uri, params)
153
+ json = JSON.parse(res.body)
154
+ rescue
155
+ return nil
156
+ end
157
+ unless json
158
+ return nil
159
+ end
160
+ token = json["data"]["token"]
161
+ return token
162
+ end
163
+
139
164
  end
140
165
 
141
166
  end
@@ -1,3 +1,3 @@
1
1
  module LgPodPlugin
2
- VERSION = "1.0.4"
2
+ VERSION = "1.0.7"
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