lg_pod_plugin 1.1.3 → 1.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (160) hide show
  1. checksums.yaml +4 -4
  2. data/bin/lg +2 -2
  3. data/lib/command/command.rb +1 -2
  4. data/lib/command/install.rb +7 -2
  5. data/lib/command/update.rb +4 -1
  6. data/lib/lg_pod_plugin/config/l_config.rb +59 -0
  7. data/lib/lg_pod_plugin/config/lockfile_model.rb +59 -0
  8. data/lib/lg_pod_plugin/config/podspec.rb +266 -0
  9. data/lib/lg_pod_plugin/config/target.rb +33 -0
  10. data/lib/lg_pod_plugin/{database.rb → db/database.rb} +76 -16
  11. data/lib/lg_pod_plugin/downloader/downloader.rb +156 -0
  12. data/lib/lg_pod_plugin/{l_cache.rb → downloader/l_cache.rb} +41 -22
  13. data/lib/lg_pod_plugin/downloader/request.rb +233 -0
  14. data/lib/lg_pod_plugin/git/git_clone.rb +85 -0
  15. data/lib/lg_pod_plugin/git/git_download.rb +53 -0
  16. data/lib/lg_pod_plugin/git/github_api.rb +137 -0
  17. data/lib/lg_pod_plugin/git/github_archive.rb +165 -0
  18. data/lib/lg_pod_plugin/git/gitlab_api.rb +265 -0
  19. data/lib/lg_pod_plugin/git/gitlab_archive.rb +177 -0
  20. data/lib/lg_pod_plugin/git/http_download.rb +39 -0
  21. data/lib/lg_pod_plugin/installer/PodDownload +0 -0
  22. data/lib/lg_pod_plugin/installer/concurrency.rb +21 -0
  23. data/lib/lg_pod_plugin/installer/install.rb +111 -0
  24. data/lib/lg_pod_plugin/installer/main.rb +63 -0
  25. data/lib/lg_pod_plugin/installer/project.rb +47 -0
  26. data/lib/lg_pod_plugin/net/l_uri.rb +88 -0
  27. data/lib/lg_pod_plugin/net/net-ping.rb +27 -0
  28. data/lib/lg_pod_plugin/pod/external_pod.rb +21 -0
  29. data/lib/lg_pod_plugin/pod/release-pod.rb +158 -0
  30. data/lib/lg_pod_plugin/utils/aes-crypt.rb +82 -0
  31. data/lib/lg_pod_plugin/{file_path.rb → utils/file_path.rb} +3 -5
  32. data/lib/lg_pod_plugin/utils/l_util.rb +133 -0
  33. data/lib/lg_pod_plugin/{log.rb → utils/log.rb} +1 -1
  34. data/lib/lg_pod_plugin/{string.rb → utils/string.rb} +0 -0
  35. data/lib/lg_pod_plugin/version.rb +1 -1
  36. data/lib/lg_pod_plugin.rb +24 -9
  37. data/lib/sqlite3-1.5.3-arm64-darwin/API_CHANGES.md +49 -0
  38. data/lib/sqlite3-1.5.3-arm64-darwin/CHANGELOG.md +462 -0
  39. data/lib/sqlite3-1.5.3-arm64-darwin/CONTRIBUTING.md +24 -0
  40. data/lib/sqlite3-1.5.3-arm64-darwin/ChangeLog.cvs +88 -0
  41. data/lib/sqlite3-1.5.3-arm64-darwin/README.md +235 -0
  42. data/lib/sqlite3-1.5.3-arm64-darwin/dependencies.yml +14 -0
  43. data/lib/sqlite3-1.5.3-arm64-darwin/ext/sqlite3/aggregator.c +274 -0
  44. data/lib/sqlite3-1.5.3-arm64-darwin/ext/sqlite3/aggregator.h +12 -0
  45. data/lib/sqlite3-1.5.3-arm64-darwin/ext/sqlite3/backup.c +168 -0
  46. data/lib/sqlite3-1.5.3-arm64-darwin/ext/sqlite3/backup.h +15 -0
  47. data/lib/sqlite3-1.5.3-arm64-darwin/ext/sqlite3/database.c +853 -0
  48. data/lib/sqlite3-1.5.3-arm64-darwin/ext/sqlite3/database.h +17 -0
  49. data/lib/sqlite3-1.5.3-arm64-darwin/ext/sqlite3/exception.c +98 -0
  50. data/lib/sqlite3-1.5.3-arm64-darwin/ext/sqlite3/exception.h +8 -0
  51. data/lib/sqlite3-1.5.3-arm64-darwin/ext/sqlite3/extconf.rb +251 -0
  52. data/lib/sqlite3-1.5.3-arm64-darwin/ext/sqlite3/sqlite3.c +163 -0
  53. data/lib/sqlite3-1.5.3-arm64-darwin/ext/sqlite3/sqlite3_ruby.h +48 -0
  54. data/lib/sqlite3-1.5.3-arm64-darwin/ext/sqlite3/statement.c +442 -0
  55. data/lib/sqlite3-1.5.3-arm64-darwin/ext/sqlite3/statement.h +16 -0
  56. data/lib/sqlite3-1.5.3-arm64-darwin/faq/faq.md +431 -0
  57. data/lib/sqlite3-1.5.3-arm64-darwin/faq/faq.rb +145 -0
  58. data/lib/sqlite3-1.5.3-arm64-darwin/faq/faq.yml +426 -0
  59. data/lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/2.6/sqlite3_native.bundle +0 -0
  60. data/lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/2.7/sqlite3_native.bundle +0 -0
  61. data/lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/3.0/sqlite3_native.bundle +0 -0
  62. data/lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/3.1/sqlite3_native.bundle +0 -0
  63. data/lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/constants.rb +50 -0
  64. data/lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/database.rb +741 -0
  65. data/lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/errors.rb +35 -0
  66. data/lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/pragmas.rb +595 -0
  67. data/lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/resultset.rb +187 -0
  68. data/lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/statement.rb +145 -0
  69. data/lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/translator.rb +118 -0
  70. data/lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/value.rb +57 -0
  71. data/lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/version.rb +23 -0
  72. data/lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3.rb +15 -0
  73. data/lib/sqlite3-1.5.3-arm64-darwin/test/helper.rb +27 -0
  74. data/lib/sqlite3-1.5.3-arm64-darwin/test/test_backup.rb +33 -0
  75. data/lib/sqlite3-1.5.3-arm64-darwin/test/test_collation.rb +82 -0
  76. data/lib/sqlite3-1.5.3-arm64-darwin/test/test_database.rb +545 -0
  77. data/lib/sqlite3-1.5.3-arm64-darwin/test/test_database_flags.rb +95 -0
  78. data/lib/sqlite3-1.5.3-arm64-darwin/test/test_database_readonly.rb +36 -0
  79. data/lib/sqlite3-1.5.3-arm64-darwin/test/test_database_readwrite.rb +41 -0
  80. data/lib/sqlite3-1.5.3-arm64-darwin/test/test_deprecated.rb +44 -0
  81. data/lib/sqlite3-1.5.3-arm64-darwin/test/test_encoding.rb +155 -0
  82. data/lib/sqlite3-1.5.3-arm64-darwin/test/test_integration.rb +507 -0
  83. data/lib/sqlite3-1.5.3-arm64-darwin/test/test_integration_aggregate.rb +336 -0
  84. data/lib/sqlite3-1.5.3-arm64-darwin/test/test_integration_open_close.rb +30 -0
  85. data/lib/sqlite3-1.5.3-arm64-darwin/test/test_integration_pending.rb +115 -0
  86. data/lib/sqlite3-1.5.3-arm64-darwin/test/test_integration_resultset.rb +142 -0
  87. data/lib/sqlite3-1.5.3-arm64-darwin/test/test_integration_statement.rb +194 -0
  88. data/lib/sqlite3-1.5.3-arm64-darwin/test/test_result_set.rb +37 -0
  89. data/lib/sqlite3-1.5.3-arm64-darwin/test/test_sqlite3.rb +30 -0
  90. data/lib/sqlite3-1.5.3-arm64-darwin/test/test_statement.rb +263 -0
  91. data/lib/sqlite3-1.5.3-arm64-darwin/test/test_statement_execute.rb +35 -0
  92. data/lib/sqlite3-1.5.3-x86_64-darwin/API_CHANGES.md +49 -0
  93. data/lib/sqlite3-1.5.3-x86_64-darwin/CHANGELOG.md +462 -0
  94. data/lib/sqlite3-1.5.3-x86_64-darwin/CONTRIBUTING.md +24 -0
  95. data/lib/sqlite3-1.5.3-x86_64-darwin/ChangeLog.cvs +88 -0
  96. data/lib/sqlite3-1.5.3-x86_64-darwin/README.md +235 -0
  97. data/lib/sqlite3-1.5.3-x86_64-darwin/dependencies.yml +14 -0
  98. data/lib/sqlite3-1.5.3-x86_64-darwin/ext/sqlite3/aggregator.c +274 -0
  99. data/lib/sqlite3-1.5.3-x86_64-darwin/ext/sqlite3/aggregator.h +12 -0
  100. data/lib/sqlite3-1.5.3-x86_64-darwin/ext/sqlite3/backup.c +168 -0
  101. data/lib/sqlite3-1.5.3-x86_64-darwin/ext/sqlite3/backup.h +15 -0
  102. data/lib/sqlite3-1.5.3-x86_64-darwin/ext/sqlite3/database.c +853 -0
  103. data/lib/sqlite3-1.5.3-x86_64-darwin/ext/sqlite3/database.h +17 -0
  104. data/lib/sqlite3-1.5.3-x86_64-darwin/ext/sqlite3/exception.c +98 -0
  105. data/lib/sqlite3-1.5.3-x86_64-darwin/ext/sqlite3/exception.h +8 -0
  106. data/lib/sqlite3-1.5.3-x86_64-darwin/ext/sqlite3/extconf.rb +251 -0
  107. data/lib/sqlite3-1.5.3-x86_64-darwin/ext/sqlite3/sqlite3.c +163 -0
  108. data/lib/sqlite3-1.5.3-x86_64-darwin/ext/sqlite3/sqlite3_ruby.h +48 -0
  109. data/lib/sqlite3-1.5.3-x86_64-darwin/ext/sqlite3/statement.c +442 -0
  110. data/lib/sqlite3-1.5.3-x86_64-darwin/ext/sqlite3/statement.h +16 -0
  111. data/lib/sqlite3-1.5.3-x86_64-darwin/faq/faq.md +431 -0
  112. data/lib/sqlite3-1.5.3-x86_64-darwin/faq/faq.rb +145 -0
  113. data/lib/sqlite3-1.5.3-x86_64-darwin/faq/faq.yml +426 -0
  114. data/lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3/2.6/sqlite3_native.bundle +0 -0
  115. data/lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3/2.7/sqlite3_native.bundle +0 -0
  116. data/lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3/3.0/sqlite3_native.bundle +0 -0
  117. data/lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3/3.1/sqlite3_native.bundle +0 -0
  118. data/lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3/constants.rb +50 -0
  119. data/lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3/database.rb +741 -0
  120. data/lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3/errors.rb +35 -0
  121. data/lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3/pragmas.rb +595 -0
  122. data/lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3/resultset.rb +187 -0
  123. data/lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3/statement.rb +145 -0
  124. data/lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3/translator.rb +118 -0
  125. data/lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3/value.rb +57 -0
  126. data/lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3/version.rb +23 -0
  127. data/lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3.rb +15 -0
  128. data/lib/sqlite3-1.5.3-x86_64-darwin/test/helper.rb +27 -0
  129. data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_backup.rb +33 -0
  130. data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_collation.rb +82 -0
  131. data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_database.rb +545 -0
  132. data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_database_flags.rb +95 -0
  133. data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_database_readonly.rb +36 -0
  134. data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_database_readwrite.rb +41 -0
  135. data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_deprecated.rb +44 -0
  136. data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_encoding.rb +155 -0
  137. data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_integration.rb +507 -0
  138. data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_integration_aggregate.rb +336 -0
  139. data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_integration_open_close.rb +30 -0
  140. data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_integration_pending.rb +115 -0
  141. data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_integration_resultset.rb +142 -0
  142. data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_integration_statement.rb +194 -0
  143. data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_result_set.rb +37 -0
  144. data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_sqlite3.rb +30 -0
  145. data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_statement.rb +263 -0
  146. data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_statement_execute.rb +35 -0
  147. metadata +146 -53
  148. data/lib/lg_pod_plugin/downloader.rb +0 -57
  149. data/lib/lg_pod_plugin/gitlab_api.rb +0 -147
  150. data/lib/lg_pod_plugin/gitlab_archive.rb +0 -352
  151. data/lib/lg_pod_plugin/gitlab_download.rb +0 -159
  152. data/lib/lg_pod_plugin/install.rb +0 -81
  153. data/lib/lg_pod_plugin/l_config.rb +0 -83
  154. data/lib/lg_pod_plugin/l_util.rb +0 -145
  155. data/lib/lg_pod_plugin/net-ping.rb +0 -41
  156. data/lib/lg_pod_plugin/podspec.rb +0 -156
  157. data/lib/lg_pod_plugin/release-pod.rb +0 -90
  158. data/lib/lg_pod_plugin/request.rb +0 -221
  159. data/lib/lg_pod_plugin/runner.rb +0 -114
  160. data/lib/lg_pod_plugin/specification.rb +0 -52
@@ -0,0 +1,177 @@
1
+ require 'uri'
2
+ require_relative 'git_download'
3
+ require_relative '../utils/l_util'
4
+
5
+ module LgPodPlugin
6
+
7
+ class GitLabArchive
8
+
9
+ private
10
+ attr_reader :source_files
11
+ attr_reader :podspec_content
12
+ attr_reader :checkout_options
13
+
14
+ public
15
+ REQUIRED_ATTRS ||= %i[git tag name commit branch config path spec].freeze
16
+ attr_accessor(*REQUIRED_ATTRS)
17
+
18
+ def initialize(checkout_options = {})
19
+ self.git = checkout_options[:git]
20
+ self.tag = checkout_options[:tag]
21
+ self.name = checkout_options[:name]
22
+ self.path = checkout_options[:path]
23
+ self.spec = checkout_options[:spec]
24
+ self.config = checkout_options[:config]
25
+ self.commit = checkout_options[:commit]
26
+ self.branch = checkout_options[:branch]
27
+ @checkout_options = checkout_options
28
+ end
29
+
30
+ def download
31
+ if self.git && self.tag
32
+ self.gitlab_download_tag_zip self.path
33
+ elsif self.git && self.branch
34
+ self.gitlab_download_branch_zip self.path
35
+ elsif self.git && self.commit
36
+ self.gitlab_download_commit_zip self.path
37
+ else
38
+ nil
39
+ end
40
+ end
41
+
42
+ # 下载某个文件zip格式
43
+ def download_archive_zip(sandbox_path)
44
+ host = self.config.host
45
+ project = self.config.project
46
+ token = self.config.access_token
47
+ unless host
48
+ http = Ping.new(project.web_url)
49
+ host = http.uri.scheme + "://" + http.uri.hostname
50
+ end
51
+ if self.git && self.tag
52
+ sha = self.tag
53
+ elsif self.git && self.branch
54
+ sha = self.branch
55
+ elsif self.git && self.commit
56
+ sha = self.commit
57
+ else
58
+ return nil
59
+ end
60
+
61
+ lg_spec = self.spec
62
+ unless lg_spec
63
+ podspec_filename = self.name + ".podspec"
64
+ podspec_content = GitLabAPI.get_podspec_file_content(host, token, project.id, sha, podspec_filename)
65
+ unless podspec_content && LUtils.is_a_string?(podspec_content)
66
+ download_url = host + "/api/v4/projects/" + "#{project.id}" + "/repository/archive.tar.bz2?" + "sha=#{sha}"
67
+ return [{ "filename" => "#{self.name}.tar.bz2", "url" => download_url }]
68
+ end
69
+ pod_spec_file_path = sandbox_path.join("#{podspec_filename}")
70
+ lg_spec = LgPodPlugin::PodSpec.form_string(podspec_content, pod_spec_file_path)
71
+ unless lg_spec
72
+ if podspec_content
73
+ begin
74
+ File.open(pod_spec_file_path, "w+") do |f|
75
+ f.write podspec_content
76
+ end
77
+ rescue => exception
78
+ LgPodPlugin.log_red "#{exception}"
79
+ end
80
+ @podspec_content = podspec_content
81
+ end
82
+ download_url = host + "/api/v4/projects/" + "#{project.id}" + "/repository/archive.tar.bz2?" + "sha=#{sha}"
83
+ return [{ "filename" => "#{self.name}.tar.bz2", "url" => download_url }]
84
+ end
85
+ self.spec = lg_spec
86
+ end
87
+ download_params = Array.new
88
+ @source_files = lg_spec.source_files.keys
89
+ lg_spec.source_files.each_key do |key|
90
+ next if key == "All" || key == "LICENSE" || key == "License"
91
+ path = LUtils.url_encode(key)
92
+ download_url = host + "/api/v4/projects/" + "#{project.id}" + "/repository/archive.tar.bz2#{"\\?"}" + "path#{"\\="}#{path}#{"\\&"}sha#{"\\="}#{sha}"
93
+ download_params.append({ "filename" => "#{key}.tar.bz2", "url" => download_url })
94
+ end
95
+ if download_params.empty?
96
+ download_url = host + "/api/v4/projects/" + "#{project.id}" + "/repository/archive.tar.bz2?" + "sha=#{sha}"
97
+ [{ "filename" => "#{self.name}.tar.bz2", "url" => download_url }]
98
+ else
99
+ download_params
100
+ end
101
+ end
102
+
103
+ # 根据branch 下载 zip 包
104
+ def gitlab_download_branch_zip(root_path)
105
+ token = self.config.access_token
106
+ download_urls = self.download_archive_zip(root_path)
107
+ return nil unless download_urls
108
+ download_params = Hash.new
109
+ download_params["token"] = token
110
+ download_params["name"] = self.name
111
+ download_params["type"] = "gitlab-branch"
112
+ if self.spec
113
+ download_params["podspec"] = self.spec
114
+ else
115
+ download_params["podspec_content"] = @podspec_content
116
+ end
117
+ download_params["path"] = root_path.to_path
118
+ if @source_files
119
+ download_params["source_files"] = @source_files
120
+ else
121
+ download_params["source_files"] = "All"
122
+ end
123
+ download_params["download_urls"] = download_urls
124
+ download_params
125
+ end
126
+
127
+ # 通过tag下载zip包
128
+ def gitlab_download_tag_zip(root_path)
129
+ token = self.config.access_token
130
+ download_urls = self.download_archive_zip(root_path)
131
+ return nil unless download_urls
132
+ download_params = Hash.new
133
+ download_params["token"] = token
134
+ download_params["name"] = self.name
135
+ download_params["type"] = "gitlab-tag"
136
+ if self.spec
137
+ download_params["podspec"] = self.spec
138
+ else
139
+ download_params["podspec_content"] = @podspec_content
140
+ end
141
+ download_params["path"] = root_path.to_path
142
+ if @source_files
143
+ download_params["source_files"] = @source_files
144
+ else
145
+ download_params["source_files"] = "All"
146
+ end
147
+ download_params["download_urls"] = download_urls
148
+ download_params
149
+ end
150
+
151
+ # 通过 commit 下载zip包
152
+ def gitlab_download_commit_zip(root_path)
153
+ token = self.config.access_token
154
+ download_urls = self.download_archive_zip(root_path)
155
+ return nil unless download_urls
156
+ download_params = Hash.new
157
+ download_params["token"] = token
158
+ download_params["name"] = self.name
159
+ if self.spec
160
+ download_params["podspec"] = self.spec
161
+ else
162
+ download_params["podspec_content"] = @podspec_content
163
+ end
164
+ download_params["type"] = "gitlab-commit"
165
+ download_params["path"] = root_path.to_path
166
+ if @source_files
167
+ download_params["source_files"] = @source_files
168
+ else
169
+ download_params["source_files"] = "All"
170
+ end
171
+ download_params["download_urls"] = download_urls
172
+ download_params
173
+ end
174
+
175
+ end
176
+
177
+ end
@@ -0,0 +1,39 @@
1
+ require 'uri'
2
+ require_relative 'git_download'
3
+ require_relative '../utils/l_util'
4
+ require_relative '../config/podspec'
5
+
6
+ module LgPodPlugin
7
+
8
+ class HTTPDownloader
9
+
10
+ private
11
+ attr_reader :checkout_options
12
+ public
13
+ REQUIRED_ATTRS ||= %i[http name path lg_spec].freeze
14
+ attr_accessor(*REQUIRED_ATTRS)
15
+ def initialize(checkout_options = {})
16
+ self.name = checkout_options[:name]
17
+ self.path = checkout_options[:path]
18
+ self.http = checkout_options[:http]
19
+ self.lg_spec = checkout_options[:spec]
20
+ @checkout_options = checkout_options
21
+ end
22
+
23
+ def download
24
+ download_params = Hash.new
25
+ new_filename = self.http.split("/").last ||= "lg_temp_pod.tar"
26
+ download_params["path"] = self.path.to_path
27
+ download_params["name"] = self.name
28
+ download_params["type"] = "http"
29
+ download_params["download_urls"] = [{ "filename" => (new_filename ? new_filename : filename), "url" => http }]
30
+ if self.lg_spec
31
+ download_params["podspec"] = self.lg_spec
32
+ download_params["source_files"] = self.lg_spec.source_files.keys
33
+ end
34
+ download_params
35
+ end
36
+
37
+ end
38
+
39
+ end
@@ -0,0 +1,21 @@
1
+ require 'json'
2
+ require 'aescrypt'
3
+
4
+ module LgPodPlugin
5
+
6
+ class Concurrency
7
+
8
+ public
9
+ def self.async_download_pods(installers)
10
+ return if installers.empty?
11
+ json_text = installers.map(&:download_params).uniq.to_json
12
+ arvg = LUtils.encrypt json_text, "AZMpxzVxzbo3sFDLRZMpxzVxzbo3sFDZ"
13
+ return unless arvg && !arvg.empty?
14
+ pwd = Pathname.new(File.dirname(__FILE__)).realpath
15
+ FileUtils.chdir pwd
16
+ system("./PodDownload #{arvg}")
17
+ installers.each(&:copy_file_to_caches)
18
+ end
19
+
20
+ end
21
+ end
@@ -0,0 +1,111 @@
1
+ require 'pp'
2
+ # require 'git'
3
+ require 'cgi'
4
+ require 'cocoapods'
5
+ require 'cocoapods-core'
6
+
7
+ module LgPodPlugin
8
+
9
+ class LPodInstaller
10
+ public
11
+ attr_accessor :download_params
12
+ private
13
+ attr_accessor :downloader
14
+
15
+ public
16
+ def initialize
17
+ end
18
+
19
+ #安装 pod
20
+ public
21
+ def install(pod)
22
+ hash = pod.checkout_options
23
+ path = hash[:path]
24
+ return nil if path
25
+ @downloader = LDownloader.new(pod)
26
+ self.download_params = @downloader.pre_download_pod
27
+ return self.download_params
28
+ end
29
+
30
+ public
31
+ def copy_file_to_caches
32
+ request = @downloader.send(:request)
33
+ name = request.send(:name)
34
+ params = Hash.new.merge!(request.params)
35
+ checkout_options = Hash.new.merge!(request.checkout_options)
36
+ commit = checkout_options[:commit] ||= params[:commit]
37
+ if request.lg_spec
38
+ cache_podspec = request.lg_spec.spec
39
+ else
40
+ cache_podspec = nil
41
+ end
42
+
43
+ unless cache_podspec
44
+ cache_podspec = LProject.shared.cache_specs[name]
45
+ request.lg_spec = LgPodPlugin::PodSpec.form_pod_spec cache_podspec if cache_podspec
46
+ end
47
+
48
+ if cache_podspec
49
+ destination = self.download_params["destination"]
50
+ if destination && File.exist?(destination) && !Pathname(destination).children.empty?
51
+ pod_is_exist = true
52
+ else
53
+ pod_is_exist = false
54
+ end
55
+ else
56
+ destination = self.download_params["destination"]
57
+ if destination && File.exist?(destination) && !Pathname(destination).children.empty?
58
+ pod_is_exist = true
59
+ else
60
+ pod_is_exist = false
61
+ end
62
+ cache_pod_spec_path = self.download_params["cache_pod_spec_path"]
63
+ local_spec_path = destination.glob("#{name}.podspec{,.json}").last
64
+ if local_spec_path && File.exist?(local_spec_path)
65
+ cache_podspec = Pod::Specification.from_file local_spec_path
66
+ if cache_podspec
67
+ LProject.shared.cache_specs[name] = cache_podspec
68
+ LCache.write_spec cache_podspec, cache_pod_spec_path
69
+ LCache.clean_pod_unused_files destination, cache_podspec
70
+ end
71
+ end
72
+ request.lg_spec = LgPodPlugin::PodSpec.form_pod_spec cache_podspec if cache_podspec
73
+ end
74
+ if pod_is_exist
75
+ is_delete = request.params["is_delete"] ||= false
76
+ LProject.shared.need_update_pods.delete(name) if is_delete
77
+ request.checkout_options.delete(:branch) if commit
78
+ request.checkout_options[:commit] = commit if commit
79
+ else
80
+ git = checkout_options[:git]
81
+ return unless git
82
+ cache_podspec = request.lg_spec.spec if request.lg_spec
83
+ branch = checkout_options[:branch]
84
+ checkout_options[:name] = name if name
85
+ unless branch
86
+ branch = self.request.params[:branch] if request.params[:branch]
87
+ checkout_options[:branch] = branch if branch
88
+ end
89
+ lg_pod_path = LFileManager.cache_workspace(LProject.shared.workspace)
90
+ lg_pod_path.mkdir(0700) unless lg_pod_path.exist?
91
+ checkout_options[:path] = lg_pod_path
92
+ FileUtils.chdir lg_pod_path
93
+ git_clone = GitRepository.new(checkout_options)
94
+ download_params = git_clone.download
95
+ return unless download_params && File.exist?(download_params)
96
+ FileUtils.chdir download_params
97
+ if request.single_git
98
+ LgPodPlugin::LCache.cache_pod(name, download_params, { :git => git }, cache_podspec, request.released_pod)
99
+ else
100
+ LgPodPlugin::LCache.cache_pod(name, download_params, request.get_cache_key_params, cache_podspec, request.released_pod)
101
+ end
102
+ FileUtils.chdir(LFileManager.download_director)
103
+ FileUtils.rm_rf(download_params)
104
+ request.checkout_options.delete(:branch) if commit
105
+ request.checkout_options[:commit] = commit if commit
106
+ end
107
+
108
+ end
109
+
110
+ end
111
+ end
@@ -0,0 +1,63 @@
1
+ require 'cocoapods'
2
+ require 'cocoapods-core'
3
+ require_relative '../installer/concurrency'
4
+
5
+ module LgPodPlugin
6
+
7
+ class Main
8
+
9
+ #删除旧的换成目录
10
+ def self.clean_sandbox
11
+ sand_box = LFileManager.download_director
12
+ sand_box.each_child do |f|
13
+ ftype = File::ftype(f)
14
+ next unless ftype == "directory"
15
+ next if f.to_path.include?("database")
16
+ FileUtils.rm_rf f.to_path
17
+ end
18
+ end
19
+
20
+ public
21
+ def self.run(command, options = {})
22
+ self.clean_sandbox
23
+ workspace = Pathname(Dir.pwd)
24
+ update = (command == "update")
25
+ LSqliteDb.shared.init_database
26
+ repo_update = options[:repo_update] ||= false
27
+ LgPodPlugin.log_blue "当前工作目录 #{workspace}"
28
+ podfile_path = check_podfile_exist?(workspace)
29
+ return unless podfile_path
30
+ project = LProject.shared.setup(workspace, podfile_path, update, repo_update)
31
+ self.install_external_pod(project)
32
+ # # 安装开发版本pod
33
+ verbose = options[:verbose] ||= false
34
+ ReleasePod.install_release_pod(update, repo_update, verbose)
35
+ end
36
+
37
+ def self.install_external_pod(project)
38
+ #下载 External pods
39
+ LgPodPlugin.log_blue "Pre-downloading External Pods" unless project.targets.empty?
40
+ all_installers = Hash.new
41
+ project.targets.each do |target|
42
+ target.dependencies.each do |_, pod|
43
+ installer = LPodInstaller.new
44
+ download_params = installer.install(pod)
45
+ if download_params
46
+ all_installers[download_params["name"]] = installer
47
+ end
48
+ end
49
+ end
50
+ # 通过 swift 可执行文件进行异步下载任务
51
+ LgPodPlugin::Concurrency.async_download_pods(all_installers.values)
52
+ end
53
+
54
+ def self.check_podfile_exist?(workspace)
55
+ podfile_path = workspace.join("Podfile")
56
+ return podfile_path if podfile_path.exist?
57
+ podfile_path = workspace.join("Podfile.rb")
58
+ return podfile_path if podfile_path.exist?
59
+ raise Informative, "No `Podfile' found in the project directory."
60
+ end
61
+
62
+ end
63
+ end
@@ -0,0 +1,47 @@
1
+ require 'singleton'
2
+ require 'cocoapods'
3
+ require 'cocoapods-core'
4
+
5
+ module LgPodPlugin
6
+
7
+ class LProject
8
+ include Singleton
9
+
10
+ attr_reader :podfile
11
+ attr_reader :lockfile
12
+ attr_reader :update
13
+ attr_reader :targets
14
+ attr_reader :workspace
15
+ attr_reader :repo_update
16
+ attr_reader :external_pods
17
+ attr_reader :need_update_pods
18
+ attr_accessor :cache_specs
19
+ def setup(workspace,podfile_path, update, repo_update)
20
+ @podfile = Pod::Podfile.from_file(podfile_path)
21
+ @update = update
22
+ @workspace = workspace
23
+ @repo_update = repo_update
24
+ lockfile_path = workspace.join("Podfile.lock")
25
+ @lockfile = Pod::Lockfile.from_file(lockfile_path) if lockfile_path.exist?
26
+ target = @podfile.send(:current_target_definition)
27
+ children = target.children
28
+ @targets = Array.new
29
+ external_pods = Hash.new
30
+ children.each do |s|
31
+ target = LPodTarget.new(s)
32
+ external_pods.merge!(target.dependencies)
33
+ @targets.append(target)
34
+ end
35
+ @cache_specs = Hash.new
36
+ @external_pods = Hash.new.merge!(external_pods)
37
+ @need_update_pods = Hash.new.merge!(external_pods)
38
+ self
39
+ end
40
+
41
+ def self.shared
42
+ return LProject.instance
43
+ end
44
+
45
+ end
46
+
47
+ end
@@ -0,0 +1,88 @@
1
+ require 'uri'
2
+ require 'resolv'
3
+
4
+ module LgPodPlugin
5
+
6
+ class LURI
7
+ public
8
+ attr_reader :ip
9
+ attr_reader :path
10
+ attr_reader :host
11
+ attr_reader :scheme
12
+ attr_reader :hostname
13
+ private
14
+ attr_reader :uri
15
+ public
16
+ def initialize(git)
17
+ begin
18
+ uri = URI(git)
19
+ rescue => exception
20
+ if git.include?("git@") && git.include?(":")
21
+ match = %r{(?<=git@).*?(?=:)}.match(git)
22
+ host = match ? match[0] : ""
23
+ base_url = LUtils.get_gitlab_base_url(git)
24
+ path = base_url.split(":").last
25
+ uri = URI("http://#{host}/#{path}")
26
+ else
27
+ LgPodPlugin.log_red exception
28
+ uri = nil
29
+ end
30
+ end
31
+ return unless uri
32
+ ip_address = getaddress(uri)
33
+ return unless ip_address
34
+ if git.include?("ssh") || git.include?("git@gitlab") || git.include?("git@")
35
+ @uri = URI("http://#{ip_address}#{uri.path}")
36
+ else
37
+ @uri = URI("#{uri.scheme}://#{ip_address}#{uri.path}")
38
+ end
39
+ @ip = ip_address
40
+ @host = @uri.host ||= ""
41
+ @path = @uri.path ||= ""
42
+ @scheme = @uri.scheme ||= ""
43
+ @hostname = @scheme + "://" + @host
44
+ end
45
+
46
+ private
47
+ #判断是否是 IP 地址
48
+ def is_address(host)
49
+ match = %r{^((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)$}.match(host)
50
+ !(match.nil?)
51
+ end
52
+
53
+ # 获取 ip 地址
54
+ private
55
+ def getaddress(uri)
56
+ begin
57
+ if self.is_address(uri.host)
58
+ ip = uri.host
59
+ return ip
60
+ else
61
+ ip_address = Resolv.getaddress uri.host
62
+ return ip_address
63
+ end
64
+ rescue
65
+ LgPodPlugin.log_yellow("time ping #{uri.host} -t 1")
66
+ result = %x(time ping #{uri.host} -t 1)
67
+ return if !result || result == "" || result.include?("timeout")
68
+ match = %r{\d+.\d+.\d+.\d+}.match(result)
69
+ return if match.nil?
70
+ ip_address = match ? match[0] : ""
71
+ begin
72
+ return ip_address if IPAddr.new(ip_address)
73
+ rescue => exception
74
+ LgPodPlugin.log_red exception
75
+ return nil
76
+ end
77
+ end
78
+ end
79
+
80
+ public def to_s
81
+ return "" unless @uri
82
+ @uri.to_s
83
+ end
84
+
85
+ end
86
+
87
+
88
+ end
@@ -0,0 +1,27 @@
1
+ require 'uri'
2
+ require 'resolv'
3
+ require "ipaddr"
4
+
5
+ module LgPodPlugin
6
+
7
+ class Ping
8
+ attr_accessor :ip
9
+ attr_accessor :network_ok
10
+ attr_accessor :uri
11
+ def initialize(url)
12
+ uri = LURI.new(url)
13
+ if uri.host
14
+ self.uri = uri
15
+ self.ip = uri.ip
16
+ self.network_ok = true
17
+ else
18
+ self.uri = nil
19
+ self.ip = nil
20
+ self.network_ok = false
21
+ end
22
+ end
23
+
24
+
25
+ end
26
+
27
+ end
@@ -0,0 +1,21 @@
1
+
2
+ require_relative '../config/podspec'
3
+
4
+ module LgPodPlugin
5
+
6
+ class ExternalPod
7
+ attr_reader :spec
8
+ attr_reader :target
9
+ attr_reader :name
10
+ attr_reader :released_pod
11
+ attr_reader :checkout_options
12
+ def initialize(target, name, hash)
13
+ @target = target
14
+ @released_pod = false
15
+ @checkout_options = hash
16
+ @name = LUtils.pod_real_name(name)
17
+ end
18
+
19
+ end
20
+
21
+ end