lg_pod_plugin 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +201 -0
- data/README.md +44 -0
- data/lib/lg_pod_plugin/cache.rb +199 -0
- data/lib/lg_pod_plugin/database.rb +104 -0
- data/lib/lg_pod_plugin/download.rb +132 -0
- data/lib/lg_pod_plugin/file_path.rb +26 -0
- data/lib/lg_pod_plugin/git_util.rb +138 -0
- data/lib/lg_pod_plugin/install.rb +115 -0
- data/lib/lg_pod_plugin/pod_spec.rb +66 -0
- data/lib/lg_pod_plugin/version.rb +3 -0
- data/lib/lg_pod_plugin.rb +23 -0
- metadata +152 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2b53208ed4fa32c2ca693aaa0b1d960ba2699e0a1b5e89c521123f489c35dc9b
|
4
|
+
data.tar.gz: da8650d3f68524a9b25667094edc57386509ef86c7ca90c1dacd350365efe8ea
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 42d727f09c1e37babdde7cc562af7c5301e11813b37768d138b57bb76f3fe28e40ad1e1fc3d81db341fa5c901275e2c894778814a285768240fbbff872368b84
|
7
|
+
data.tar.gz: 3ce6ae923d9c7c8af2a5a514d137935efeb111607b1bc52c49e4bd7c130c48153857816efd67c07b8b77e80110e5710c25da861316d70339993377fc866f3027
|
data/LICENSE
ADDED
@@ -0,0 +1,201 @@
|
|
1
|
+
Apache License
|
2
|
+
Version 2.0, January 2004
|
3
|
+
http://www.apache.org/licenses/
|
4
|
+
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
6
|
+
|
7
|
+
1. Definitions.
|
8
|
+
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
11
|
+
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
13
|
+
the copyright owner that is granting the License.
|
14
|
+
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
16
|
+
other entities that control, are controlled by, or are under common
|
17
|
+
control with that entity. For the purposes of this definition,
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
19
|
+
direction or management of such entity, whether by contract or
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
22
|
+
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
24
|
+
exercising permissions granted by this License.
|
25
|
+
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
27
|
+
including but not limited to software source code, documentation
|
28
|
+
source, and configuration files.
|
29
|
+
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
31
|
+
transformation or translation of a Source form, including but
|
32
|
+
not limited to compiled object code, generated documentation,
|
33
|
+
and conversions to other media types.
|
34
|
+
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
36
|
+
Object form, made available under the License, as indicated by a
|
37
|
+
copyright notice that is included in or attached to the work
|
38
|
+
(an example is provided in the Appendix below).
|
39
|
+
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
46
|
+
the Work and Derivative Works thereof.
|
47
|
+
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
49
|
+
the original version of the Work and any modifications or additions
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
61
|
+
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
64
|
+
subsequently incorporated within the Work.
|
65
|
+
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
72
|
+
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
78
|
+
where such license applies only to those patent claims licensable
|
79
|
+
by such Contributor that are necessarily infringed by their
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
82
|
+
institute patent litigation against any entity (including a
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
85
|
+
or contributory patent infringement, then any patent licenses
|
86
|
+
granted to You under this License for that Work shall terminate
|
87
|
+
as of the date such litigation is filed.
|
88
|
+
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
91
|
+
modifications, and in Source or Object form, provided that You
|
92
|
+
meet the following conditions:
|
93
|
+
|
94
|
+
(a) You must give any other recipients of the Work or
|
95
|
+
Derivative Works a copy of this License; and
|
96
|
+
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
98
|
+
stating that You changed the files; and
|
99
|
+
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
102
|
+
attribution notices from the Source form of the Work,
|
103
|
+
excluding those notices that do not pertain to any part of
|
104
|
+
the Derivative Works; and
|
105
|
+
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
108
|
+
include a readable copy of the attribution notices contained
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
111
|
+
of the following places: within a NOTICE text file distributed
|
112
|
+
as part of the Derivative Works; within the Source form or
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
114
|
+
within a display generated by the Derivative Works, if and
|
115
|
+
wherever such third-party notices normally appear. The contents
|
116
|
+
of the NOTICE file are for informational purposes only and
|
117
|
+
do not modify the License. You may add Your own attribution
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
120
|
+
that such additional attribution notices cannot be construed
|
121
|
+
as modifying the License.
|
122
|
+
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
124
|
+
may provide additional or different license terms and conditions
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
128
|
+
the conditions stated in this License.
|
129
|
+
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
133
|
+
this License, without any additional terms or conditions.
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
135
|
+
the terms of any separate license agreement you may have executed
|
136
|
+
with Licensor regarding such Contributions.
|
137
|
+
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
140
|
+
except as required for reasonable and customary use in describing the
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
142
|
+
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
152
|
+
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
158
|
+
incidental, or consequential damages of any character arising as a
|
159
|
+
result of this License or out of the use or inability to use the
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
162
|
+
other commercial damages or losses), even if such Contributor
|
163
|
+
has been advised of the possibility of such damages.
|
164
|
+
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
168
|
+
or other liability obligations and/or rights consistent with this
|
169
|
+
License. However, in accepting such obligations, You may act only
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
174
|
+
of your accepting any such warranty or additional liability.
|
175
|
+
|
176
|
+
END OF TERMS AND CONDITIONS
|
177
|
+
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
179
|
+
|
180
|
+
To apply the Apache License to your work, attach the following
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
182
|
+
replaced with your own identifying information. (Don't include
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
184
|
+
comment syntax for the file format. We also recommend that a
|
185
|
+
file or class name and description of purpose be included on the
|
186
|
+
same "printed page" as the copyright notice for easier
|
187
|
+
identification within third-party archives.
|
188
|
+
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
190
|
+
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
192
|
+
you may not use this file except in compliance with the License.
|
193
|
+
You may obtain a copy of the License at
|
194
|
+
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
196
|
+
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
200
|
+
See the License for the specific language governing permissions and
|
201
|
+
limitations under the License.
|
data/README.md
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# LgPodPlugin
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/lg_pod_plugin`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'lg_pod_plugin'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle install
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install lg_pod_plugin
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/lg_pod_plugin. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/lg_pod_plugin/blob/master/CODE_OF_CONDUCT.md).
|
36
|
+
|
37
|
+
|
38
|
+
## License
|
39
|
+
|
40
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
41
|
+
|
42
|
+
## Code of Conduct
|
43
|
+
|
44
|
+
Everyone interacting in the LgPodPlugin project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/lg_pod_plugin/blob/master/CODE_OF_CONDUCT.md).
|
@@ -0,0 +1,199 @@
|
|
1
|
+
require 'git'
|
2
|
+
require 'cocoapods/downloader.rb'
|
3
|
+
require 'cocoapods/downloader/cache.rb'
|
4
|
+
require 'cocoapods/downloader/response.rb'
|
5
|
+
require 'cocoapods/downloader/request.rb'
|
6
|
+
|
7
|
+
module LgPodPlugin
|
8
|
+
|
9
|
+
class CachePodInfo
|
10
|
+
attr_accessor :sha
|
11
|
+
attr_accessor :tag
|
12
|
+
attr_accessor :name
|
13
|
+
attr_accessor :path
|
14
|
+
attr_accessor :branch
|
15
|
+
attr_accessor :timestamp
|
16
|
+
def initialize
|
17
|
+
super
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
class Cache
|
23
|
+
|
24
|
+
def initialize
|
25
|
+
super
|
26
|
+
end
|
27
|
+
|
28
|
+
#判断缓存是否存在且有效命中缓存
|
29
|
+
def find_pod_cache(name ,git, branch, is_update)
|
30
|
+
last_commit = nil
|
31
|
+
|
32
|
+
if is_update
|
33
|
+
puts "git ls-remote #{git} #{branch}"
|
34
|
+
sha = %x(git ls-remote #{git} #{branch}).split(" ").first
|
35
|
+
if sha
|
36
|
+
last_commit = sha
|
37
|
+
else
|
38
|
+
ls = Git.ls_remote(git, :refs => true )
|
39
|
+
find_branch = ls["branches"][branch]
|
40
|
+
if find_branch
|
41
|
+
last_commit = find_branch[:sha]
|
42
|
+
end
|
43
|
+
end
|
44
|
+
else
|
45
|
+
local_pod_path = self.get_download_path(name, git, branch)
|
46
|
+
if Dir.exist?(local_pod_path)
|
47
|
+
local_git = Git.open(Pathname("#{local_pod_path}"))
|
48
|
+
last_commit = local_git.log(1).to_s
|
49
|
+
end
|
50
|
+
end
|
51
|
+
unless last_commit
|
52
|
+
return [true , nil]
|
53
|
+
end
|
54
|
+
request = Cache.download_request(name, {:git => git, :commit => last_commit})
|
55
|
+
destination = Cache.path_for_pod(request, {})
|
56
|
+
cache_pod_spec = Cache.path_for_spec(request, {})
|
57
|
+
if File.exist?(destination) && File.exist?(cache_pod_spec)
|
58
|
+
[false , last_commit]
|
59
|
+
else
|
60
|
+
[true , last_commit]
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def clean_old_cache(name, git, commit)
|
65
|
+
request = Cache.download_request(name, {:git => git, :commit => commit})
|
66
|
+
destination = Cache.path_for_pod(request, {})
|
67
|
+
cache_pod_spec = Cache.path_for_spec(request, {})
|
68
|
+
if File.exist?(destination)
|
69
|
+
FileUtils.rm_rf(destination)
|
70
|
+
end
|
71
|
+
if File.exist?(cache_pod_spec)
|
72
|
+
FileUtils.rm_rf(cache_pod_spec)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def self.root_path
|
77
|
+
path = File.join(Dir.home, "Library/Caches/CocoaPods/Pods")
|
78
|
+
Pathname(path)
|
79
|
+
end
|
80
|
+
|
81
|
+
def self.download_request(name, params)
|
82
|
+
Pod::Downloader::Request.new(spec: nil, released: false, name: name, params: params)
|
83
|
+
end
|
84
|
+
|
85
|
+
def self.path_for_pod(request, slug_opts = {})
|
86
|
+
root = self.root_path
|
87
|
+
root + request.slug(**slug_opts)
|
88
|
+
end
|
89
|
+
|
90
|
+
def self.path_for_spec(request, slug_opts = {})
|
91
|
+
root = self.root_path
|
92
|
+
path = root + 'Specs' + request.slug(**slug_opts)
|
93
|
+
Pathname.new(path.to_path + '.podspec.json')
|
94
|
+
end
|
95
|
+
|
96
|
+
def self.cached_spec(request)
|
97
|
+
path = path_for_spec(request)
|
98
|
+
path.file? && Specification.from_file(path)
|
99
|
+
rescue JSON::ParserError
|
100
|
+
nil
|
101
|
+
end
|
102
|
+
|
103
|
+
def self.get_local_spec(request, target)
|
104
|
+
result = Pod::Downloader::Response.new
|
105
|
+
result.location = target
|
106
|
+
if request.released_pod?
|
107
|
+
result.spec = request.spec
|
108
|
+
local_specs = { request.name => request.spec }
|
109
|
+
return [request, local_specs]
|
110
|
+
else
|
111
|
+
local_specs = {}
|
112
|
+
podspecs = Pod::Sandbox::PodspecFinder.new(target).podspecs
|
113
|
+
podspecs[request.name] = request.spec if request.spec
|
114
|
+
podspecs.each do |name, spec|
|
115
|
+
if request.name == name
|
116
|
+
result.spec = spec
|
117
|
+
local_specs[request.name] = spec
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
[result, local_specs]
|
123
|
+
end
|
124
|
+
|
125
|
+
def self.group_sub_specs_by_platform(spec)
|
126
|
+
specs_by_platform = {}
|
127
|
+
[spec, *spec.recursive_subspecs].each do |ss|
|
128
|
+
ss.available_platforms.each do |platform|
|
129
|
+
specs_by_platform[platform] ||= []
|
130
|
+
specs_by_platform[platform] << ss
|
131
|
+
end
|
132
|
+
end
|
133
|
+
specs_by_platform
|
134
|
+
end
|
135
|
+
|
136
|
+
def self.copy_and_clean(source, destination, spec)
|
137
|
+
specs_by_platform = group_sub_specs_by_platform(spec)
|
138
|
+
destination.parent.mkpath
|
139
|
+
Pod::Downloader::Cache.write_lock(destination) do
|
140
|
+
FileUtils.rm_rf(destination)
|
141
|
+
FileUtils.cp_r(source, destination)
|
142
|
+
Pod::Installer::PodSourcePreparer.new(spec, destination).prepare!
|
143
|
+
Pod::Sandbox::PodDirCleaner.new(destination, specs_by_platform).clean!
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
def self.write_spec(spec, path)
|
148
|
+
path.dirname.mkpath
|
149
|
+
Pod::Downloader::Cache.write_lock(path) do
|
150
|
+
path.open('w') { |f| f.write spec.to_pretty_json }
|
151
|
+
end
|
152
|
+
end
|
153
|
+
# 拷贝 pod 缓存文件到 sandbox
|
154
|
+
def self.cache_pod(name, target, is_update, options = {})
|
155
|
+
request = Cache.download_request(name, options)
|
156
|
+
result, pods_pecs = get_local_spec(request, target)
|
157
|
+
result.location = nil
|
158
|
+
pods_pecs.each do |s_name, s_spec|
|
159
|
+
destination = path_for_pod(request, {})
|
160
|
+
if !File.exist?(destination) || is_update
|
161
|
+
puts "Copying #{name} from `#{target}` to `#{destination}` "
|
162
|
+
copy_and_clean(target, destination, s_spec)
|
163
|
+
end
|
164
|
+
cache_pod_spec = path_for_spec(request, {})
|
165
|
+
if !File.exist?(cache_pod_spec) || is_update
|
166
|
+
write_spec(s_spec, cache_pod_spec)
|
167
|
+
end
|
168
|
+
if request.name == s_name
|
169
|
+
result.location = destination
|
170
|
+
end
|
171
|
+
|
172
|
+
end
|
173
|
+
|
174
|
+
end
|
175
|
+
|
176
|
+
# 根据下载参数生产缓存的路径
|
177
|
+
def get_download_path(name, git, branch)
|
178
|
+
request = Cache.download_request(name, {:git => git, :branch => branch})
|
179
|
+
self.slug(name, request.params, nil )
|
180
|
+
end
|
181
|
+
|
182
|
+
# 根据下载参数生产缓存目录
|
183
|
+
def slug(name, params, spec)
|
184
|
+
path = FileManager.download_pod_path(name).to_path
|
185
|
+
checksum = spec&.checksum && '-' << spec.checksum[0, 5]
|
186
|
+
opts = params.to_a.sort_by(&:first).map { |k, v| "#{k}=#{v}" }.join('-')
|
187
|
+
digest = Digest::MD5.hexdigest(opts)
|
188
|
+
if digest
|
189
|
+
path += "/#{digest}"
|
190
|
+
end
|
191
|
+
if checksum
|
192
|
+
path += "/#{checksum}"
|
193
|
+
end
|
194
|
+
path
|
195
|
+
end
|
196
|
+
|
197
|
+
end
|
198
|
+
|
199
|
+
end
|
@@ -0,0 +1,104 @@
|
|
1
|
+
require "sqlite3"
|
2
|
+
require 'singleton'
|
3
|
+
require_relative 'cache'
|
4
|
+
|
5
|
+
module LgPodPlugin
|
6
|
+
|
7
|
+
class SqliteDb
|
8
|
+
include Singleton
|
9
|
+
REQUIRED_ATTRS ||= %i[db table_name].freeze
|
10
|
+
attr_accessor(*REQUIRED_ATTRS)
|
11
|
+
# 初始化 db
|
12
|
+
def initialize
|
13
|
+
root_path = FileManager.download_director.join("database")
|
14
|
+
db_file_path = root_path.join("my.db")
|
15
|
+
if !root_path.exist? || !db_file_path.exist?
|
16
|
+
FileUtils.mkdir(root_path)
|
17
|
+
FileUtils.chdir(root_path)
|
18
|
+
FileUtils.touch("my.db")
|
19
|
+
end
|
20
|
+
# FileUtils.chdir(root_path)
|
21
|
+
self.db = SQLite3::Database.new(db_file_path.to_path)
|
22
|
+
#添加表
|
23
|
+
# sql = "create table IF NOT EXISTS LgPodTable (id integer primary key autoincrement not null, name varchar(100), branch varchar(100), commit varchar(100));"
|
24
|
+
sql = "create table if not exists lg_pod_table(
|
25
|
+
id integer primary key autoincrement not null,
|
26
|
+
name varchar(100),
|
27
|
+
branch varchar(100),
|
28
|
+
sha varchar(100),
|
29
|
+
tag varchar(100),
|
30
|
+
local_path varchar(150),
|
31
|
+
update_time TimeStamp NOT NULL DEFAULT CURRENT_TIMESTAMP)"
|
32
|
+
self.db.execute(sql)
|
33
|
+
self.table_name = "lg_pod_table"
|
34
|
+
super
|
35
|
+
end
|
36
|
+
|
37
|
+
def insert_table(name, branch, sha, tag, path)
|
38
|
+
timestamp = Time.now.to_i * 1000
|
39
|
+
pod_info = self.select_table(name, branch)
|
40
|
+
if pod_info.name
|
41
|
+
self.db.execute_batch(
|
42
|
+
"UPDATE #{table_name} SET sha = (:sha), tag = (:tag), local_path = (:local_path), update_time = (:update_time) where (name = :name) and (branch = :branch)", {"branch" => branch,"name" => name, "sha" => sha,"tag" => tag, :update_time => timestamp, :local_path => path.to_path}
|
43
|
+
)
|
44
|
+
else
|
45
|
+
self.db.execute("INSERT INTO #{table_name} (name, branch, sha, tag, local_path, update_time)
|
46
|
+
VALUES (?, ?, ?, ?,?,?)", [name, branch, sha, tag, path.to_path, timestamp])
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def should_clean_pod_info(name, branch)
|
51
|
+
current_pod = self.select_table(name, branch)
|
52
|
+
if current_pod&.path && !Dir.exist?(current_pod.path)
|
53
|
+
self.delete_table(current_pod.name, current_pod.branch)
|
54
|
+
end
|
55
|
+
array = self.select_tables(name, branch)
|
56
|
+
if array.count <= 1
|
57
|
+
return
|
58
|
+
end
|
59
|
+
|
60
|
+
#待删除的 pod 换成
|
61
|
+
pod_info = array.first
|
62
|
+
if pod_info&.path && Dir.exist?(pod_info.path)
|
63
|
+
FileUtils.rm_rf(pod_info.path)
|
64
|
+
self.delete_table(pod_info.name, pod_info.branch)
|
65
|
+
array.delete(pod_info)
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
|
70
|
+
def select_table(name, branch)
|
71
|
+
pod_info = CachePodInfo.new
|
72
|
+
self.db.execute( "select * from #{self.table_name} where name = '#{name}' and branch = '#{branch}'; ") do |row|
|
73
|
+
pod_info.name = row[1]
|
74
|
+
pod_info.branch = row[2]
|
75
|
+
pod_info.sha = row[3]
|
76
|
+
pod_info.tag = row[4]
|
77
|
+
pod_info.path = row[5]
|
78
|
+
pod_info.timestamp = row[6]
|
79
|
+
end
|
80
|
+
pod_info
|
81
|
+
end
|
82
|
+
|
83
|
+
def select_tables(name, branch)
|
84
|
+
array = []
|
85
|
+
self.db.execute( "select * from #{self.table_name} where name = '#{name}' and branch != '#{branch}' order by update_time;") do |row|
|
86
|
+
pod_info = CachePodInfo.new
|
87
|
+
pod_info.name = row[1]
|
88
|
+
pod_info.branch = row[2]
|
89
|
+
pod_info.sha = row[3]
|
90
|
+
pod_info.tag = row[4]
|
91
|
+
pod_info.path = row[5]
|
92
|
+
pod_info.timestamp = row[6]
|
93
|
+
array.append(pod_info)
|
94
|
+
end
|
95
|
+
array
|
96
|
+
end
|
97
|
+
|
98
|
+
def delete_table(name, branch)
|
99
|
+
self.db.execute("delete from #{self.table_name} where name = ? and branch = ? ;", [name, branch])
|
100
|
+
end
|
101
|
+
|
102
|
+
end
|
103
|
+
|
104
|
+
end
|
@@ -0,0 +1,132 @@
|
|
1
|
+
require 'git'
|
2
|
+
require_relative 'cache.rb'
|
3
|
+
require_relative 'database.rb'
|
4
|
+
require_relative 'file_path.rb'
|
5
|
+
|
6
|
+
module LgPodPlugin
|
7
|
+
|
8
|
+
class Downloader
|
9
|
+
attr_accessor :git_util
|
10
|
+
attr_accessor :db
|
11
|
+
attr_accessor :cache
|
12
|
+
REQUIRED_ATTRS ||= %i[git name commit branch tag options].freeze
|
13
|
+
attr_accessor(*REQUIRED_ATTRS)
|
14
|
+
def initialize
|
15
|
+
self.cache = Cache.new
|
16
|
+
self.db = SqliteDb.instance
|
17
|
+
super
|
18
|
+
end
|
19
|
+
def download_init(name, options = {})
|
20
|
+
self.name = name
|
21
|
+
self.options = options
|
22
|
+
self.git = options[:git]
|
23
|
+
self.tag = options[:tag]
|
24
|
+
self.branch = options[:branch]
|
25
|
+
self.commit = options[:commit]
|
26
|
+
end
|
27
|
+
|
28
|
+
def is_update_pod
|
29
|
+
cgi = CGI.new
|
30
|
+
command_keys = cgi.keys
|
31
|
+
unless command_keys.count > 0
|
32
|
+
return false
|
33
|
+
end
|
34
|
+
first_key = command_keys[0].to_s ||= ""
|
35
|
+
if first_key.include?("install")
|
36
|
+
false
|
37
|
+
elsif first_key.include?("update")
|
38
|
+
true
|
39
|
+
else
|
40
|
+
false
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def check_cache_valid(name, branch)
|
45
|
+
self.db.should_clean_pod_info(name, branch)
|
46
|
+
end
|
47
|
+
|
48
|
+
# 预下载处理
|
49
|
+
def pre_download_pod(git)
|
50
|
+
self.git_util = git
|
51
|
+
is_update = self.is_update_pod
|
52
|
+
self.git_util.git_init(self.name, self.options)
|
53
|
+
# if name == "LAddressComponents" || name == "LLogger" || name == "LUnityFramework" || name == "LUser"
|
54
|
+
# pp name
|
55
|
+
# end
|
56
|
+
# tag = options[:tag]
|
57
|
+
git_url = options[:git]
|
58
|
+
# commit = options[:commit]
|
59
|
+
branch = options[:branch]
|
60
|
+
puts "Pre-downloading: `#{name}` \n"
|
61
|
+
|
62
|
+
# 发现本地有缓存, 不需要更新缓存
|
63
|
+
need_download, new_commit = self.cache.find_pod_cache(name, git_url, branch, is_update)
|
64
|
+
unless need_download
|
65
|
+
puts "find the cache of `#{name}`, you can use it now."
|
66
|
+
return
|
67
|
+
end
|
68
|
+
|
69
|
+
# 检查是否要清空缓存
|
70
|
+
if is_update
|
71
|
+
check_cache_valid(name, branch)
|
72
|
+
end
|
73
|
+
|
74
|
+
# 本地 git 下载 pod 目录
|
75
|
+
pre_down_load_path = self.cache.get_download_path(name, git_url, branch)
|
76
|
+
real_pod_path = self.git_util.pre_download_git_remote(pre_down_load_path, branch)
|
77
|
+
# 本地clone代码失败跳出去
|
78
|
+
unless real_pod_path.exist?
|
79
|
+
return
|
80
|
+
end
|
81
|
+
# 切换到本地git仓库目录下
|
82
|
+
FileUtils.chdir(real_pod_path)
|
83
|
+
unless real_pod_path.glob("*.git")
|
84
|
+
return
|
85
|
+
end
|
86
|
+
# 使用branch克隆代码
|
87
|
+
git = Git.open(Pathname("./"))
|
88
|
+
current_branch = git.current_branch
|
89
|
+
if current_branch == branch # 要 clone 的分支正好等于当前分支
|
90
|
+
current_commit = git.log(1).to_s
|
91
|
+
if new_commit != current_commit && is_update
|
92
|
+
#删除旧的pod 缓存
|
93
|
+
self.cache.clean_old_cache(name, git_url, current_commit)
|
94
|
+
puts "git pull #{name} origin/#{current_branch}\n"
|
95
|
+
self.git_util.should_pull(git, current_branch, new_commit)
|
96
|
+
current_commit = new_commit
|
97
|
+
end
|
98
|
+
hash_map = {:git => git_url}
|
99
|
+
if current_commit
|
100
|
+
hash_map[:commit] = current_commit
|
101
|
+
end
|
102
|
+
SqliteDb.instance.insert_table(name, branch, current_commit, nil, real_pod_path)
|
103
|
+
LgPodPlugin::Cache.cache_pod(name,real_pod_path,is_update,hash_map)
|
104
|
+
else
|
105
|
+
branch_exist = git.branches.local.find {|e| e.to_s == branch}
|
106
|
+
if branch_exist
|
107
|
+
puts "git switch #{name} #{git_url} -b #{branch}\n"
|
108
|
+
self.git_util.git_switch(branch)
|
109
|
+
else
|
110
|
+
puts "git checkout #{name} #{git_url} -b #{branch}\n"
|
111
|
+
self.git_util.git_checkout(branch)
|
112
|
+
end
|
113
|
+
current_commit = git.log(1).to_s
|
114
|
+
if current_commit != new_commit
|
115
|
+
puts "git pull #{name} #{git_url} -b #{branch}\n"
|
116
|
+
self.git_util.should_pull(git, current_branch, new_commit)
|
117
|
+
current_commit = new_commit
|
118
|
+
end
|
119
|
+
hash_map = {:git => git_url}
|
120
|
+
if current_commit
|
121
|
+
hash_map[:commit] = current_commit
|
122
|
+
end
|
123
|
+
SqliteDb.instance.insert_table(name, branch, current_commit, nil, real_pod_path)
|
124
|
+
LgPodPlugin::Cache.cache_pod(name,real_pod_path,is_update,hash_map)
|
125
|
+
end
|
126
|
+
|
127
|
+
|
128
|
+
end
|
129
|
+
|
130
|
+
end
|
131
|
+
|
132
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
|
2
|
+
module LgPodPlugin
|
3
|
+
|
4
|
+
class FileManager
|
5
|
+
|
6
|
+
def self.cache_director
|
7
|
+
Pathname(File.join(Dir.home, "Library/Caches"))
|
8
|
+
end
|
9
|
+
|
10
|
+
# 本地下载路径 ~Library/Caches/LgPodPlugin
|
11
|
+
def self.download_director
|
12
|
+
cache_path = self.cache_director.join("LgPodPlugin")
|
13
|
+
unless cache_path.exist?
|
14
|
+
# pp "文件路径不存在"
|
15
|
+
cache_path.mkdir(0700)
|
16
|
+
end
|
17
|
+
cache_path
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.download_pod_path(name)
|
21
|
+
download_director.join(name)
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
@@ -0,0 +1,138 @@
|
|
1
|
+
require 'pp'
|
2
|
+
require 'git'
|
3
|
+
|
4
|
+
module LgPodPlugin
|
5
|
+
|
6
|
+
class GitUtil
|
7
|
+
attr_accessor :git
|
8
|
+
attr_accessor :tag
|
9
|
+
attr_accessor :path
|
10
|
+
attr_accessor :name
|
11
|
+
attr_accessor :commit
|
12
|
+
attr_accessor :branch
|
13
|
+
attr_accessor :temp_git_path
|
14
|
+
def initialize
|
15
|
+
super
|
16
|
+
end
|
17
|
+
|
18
|
+
def git_init(name, options = {})
|
19
|
+
self.name = name
|
20
|
+
self.git = options[:git]
|
21
|
+
self.tag = options[:tag]
|
22
|
+
self.path = options[:path]
|
23
|
+
self.branch = options[:branch]
|
24
|
+
self.commit = options[:commit]
|
25
|
+
end
|
26
|
+
|
27
|
+
def git_clone(path)
|
28
|
+
if self.branch
|
29
|
+
temp_git_path = path.join("l-temp-pod")
|
30
|
+
puts "git clone --template= --single-branch --depth 1 --branch #{self.branch} #{self.git}\n"
|
31
|
+
system("git clone --template= --single-branch --depth 1 --branch #{self.branch} #{self.git} #{temp_git_path}")
|
32
|
+
puts "\n"
|
33
|
+
temp_git_path
|
34
|
+
else
|
35
|
+
nil
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def git_checkout(branch)
|
40
|
+
system("git checkout -b #{branch}")
|
41
|
+
end
|
42
|
+
|
43
|
+
def git_switch(branch)
|
44
|
+
system("git switch #{branch}")
|
45
|
+
end
|
46
|
+
|
47
|
+
#noinspection RubyNilAnalysis
|
48
|
+
def pre_download_git_remote(path, branch)
|
49
|
+
lg_pod_path = Pathname(path)
|
50
|
+
root_path = FileManager.download_director
|
51
|
+
pod_info_db = SqliteDb.instance.select_table(self.name, branch)
|
52
|
+
if lg_pod_path.exist? && pod_info_db.branch
|
53
|
+
return lg_pod_path
|
54
|
+
end
|
55
|
+
|
56
|
+
FileUtils.chdir(root_path)
|
57
|
+
temp_path = root_path.join("tmp")
|
58
|
+
if temp_path.exist?
|
59
|
+
FileUtils.rm_r(temp_path)
|
60
|
+
end
|
61
|
+
temp_path.mkdir(0700)
|
62
|
+
FileUtils.chdir(temp_path)
|
63
|
+
#clone仓库
|
64
|
+
get_temp_folder = git_clone(temp_path)
|
65
|
+
#下载 git 仓库失败
|
66
|
+
unless get_temp_folder.exist?
|
67
|
+
return nil
|
68
|
+
end
|
69
|
+
pod_root_director = FileManager.download_pod_path(name)
|
70
|
+
unless pod_root_director.exist?
|
71
|
+
FileUtils.mkdir(pod_root_director)
|
72
|
+
end
|
73
|
+
FileUtils.mv(get_temp_folder, lg_pod_path)
|
74
|
+
temp_path.rmdir
|
75
|
+
lg_pod_path
|
76
|
+
end
|
77
|
+
|
78
|
+
# 本地pod库git操作
|
79
|
+
def git_local_pod_check
|
80
|
+
FileUtils.chdir(self.path)
|
81
|
+
git = Git.open(Pathname("./"))
|
82
|
+
current_branch = git.current_branch
|
83
|
+
last_stash_message = "#{current_branch}_pod_install_cache"
|
84
|
+
if self.branch == current_branch
|
85
|
+
# 是否恢复储藏内容到暂存区
|
86
|
+
self.should_pull(git ,current_branch)
|
87
|
+
else
|
88
|
+
# 存储上一个 branch 未暂存的内容
|
89
|
+
# 判断 git status 是否有要暂存的内容
|
90
|
+
have_changes = git.status.changed.map { |change|
|
91
|
+
change.to_s
|
92
|
+
}
|
93
|
+
# 如果有要暂存的内容, 就 git stash save
|
94
|
+
unless have_changes.empty?
|
95
|
+
# "当前#{current_branch}分支有未暂存的内容"
|
96
|
+
git.branch.stashes.save(last_stash_message)
|
97
|
+
end
|
98
|
+
# 这里 checkout到目标分支, 本地有git switch -b xxx, 本地没有 git checkout -b xxx
|
99
|
+
git.checkout(git.branch(branch))
|
100
|
+
current_branch = git.current_branch
|
101
|
+
self.should_pull(git ,current_branch)
|
102
|
+
# 是否恢复储藏内容到暂存区
|
103
|
+
self.should_pop_stash(git, current_branch)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
# 是否pull 代码
|
108
|
+
def should_pull(git, branch, new_commit = nil)
|
109
|
+
git_url = git.remote.url
|
110
|
+
if new_commit == nil
|
111
|
+
puts "git ls-remote #{git_url} #{branch}"
|
112
|
+
new_commit = %x(git ls-remote #{git_url} #{branch}).split(" ").first
|
113
|
+
end
|
114
|
+
local_commit = git.log(1).to_s #本地最后一条 commit hash 值
|
115
|
+
if local_commit != new_commit
|
116
|
+
system("git pull origin #{branch}")
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
def should_pop_stash(git, branch)
|
121
|
+
last_stash_message = "#{branch}_pod_install_cache"
|
122
|
+
# 查看下贮存的有没有代码
|
123
|
+
stashes = git.branch.stashes.all.flatten.select do |ss|
|
124
|
+
ss.is_a?(String)
|
125
|
+
end
|
126
|
+
unless stashes.include?(last_stash_message)
|
127
|
+
return
|
128
|
+
end
|
129
|
+
drop_index = stashes.index(last_stash_message)
|
130
|
+
# 恢复上次贮藏的代码
|
131
|
+
system("git stash apply stash@{#{drop_index}} ")
|
132
|
+
# pop 掉已恢复到暂缓区的代码
|
133
|
+
git_command = "git stash drop stash@{" + "#{drop_index}" + "}"
|
134
|
+
system(git_command)
|
135
|
+
end
|
136
|
+
|
137
|
+
end
|
138
|
+
end
|
@@ -0,0 +1,115 @@
|
|
1
|
+
require 'pp'
|
2
|
+
require 'git'
|
3
|
+
require 'cgi'
|
4
|
+
require 'sqlite3'
|
5
|
+
require 'cocoapods'
|
6
|
+
require_relative 'database'
|
7
|
+
require_relative 'download'
|
8
|
+
require_relative 'git_util'
|
9
|
+
require_relative 'pod_spec.rb'
|
10
|
+
|
11
|
+
module LgPodPlugin
|
12
|
+
class Installer
|
13
|
+
attr_accessor :downloader
|
14
|
+
attr_accessor :git_util
|
15
|
+
def initialize(defined_in_file = nil, profile, &block)
|
16
|
+
@defined_in_file = defined_in_file
|
17
|
+
@target = profile.send(:current_target_definition)
|
18
|
+
self.git_util = GitUtil.new
|
19
|
+
self.downloader = Downloader.new
|
20
|
+
if block
|
21
|
+
instance_eval(&block)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# @param [Object] name
|
26
|
+
# @param [Hash] options
|
27
|
+
# @return [Object] nil
|
28
|
+
def pod(name, options = {})
|
29
|
+
unless name
|
30
|
+
raise StandardError, 'A dependency requires a name.'
|
31
|
+
end
|
32
|
+
if options[0].is_a?(String)
|
33
|
+
version = options[0].to_s
|
34
|
+
@target.store_pod(name, version)
|
35
|
+
return
|
36
|
+
end
|
37
|
+
|
38
|
+
path = options[:path]
|
39
|
+
tag = options[:tag]
|
40
|
+
commit = options[:commit]
|
41
|
+
url = options[:git]
|
42
|
+
branch = options[:branch]
|
43
|
+
depth = options[:depth] ||= true
|
44
|
+
|
45
|
+
# 找到本地组件库 执行 git pull
|
46
|
+
if path && File.directory?(path)
|
47
|
+
self.install_local_pod(name, options)
|
48
|
+
return
|
49
|
+
end
|
50
|
+
|
51
|
+
# 根据tag, commit下载文件
|
52
|
+
hash_map = options
|
53
|
+
hash_map.delete(:path)
|
54
|
+
if tag || commit
|
55
|
+
hash_map.delete(:branch)
|
56
|
+
hash_map.delete(:depth)
|
57
|
+
@target.store_pod(name, hash_map)
|
58
|
+
return
|
59
|
+
end
|
60
|
+
|
61
|
+
# 根据 branch 下载代码
|
62
|
+
if url && branch && depth
|
63
|
+
hash_map.delete(:tag)
|
64
|
+
hash_map.delete(:commit)
|
65
|
+
hash_map.delete(:depth)
|
66
|
+
self.downloader.download_init(name, options)
|
67
|
+
self.downloader.pre_download_pod(self.git_util)
|
68
|
+
@target.store_pod(name, hash_map)
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
def install_form_specs(spec_path = nil)
|
74
|
+
spec_path ||= './Specs'
|
75
|
+
path = File.expand_path(spec_path, Dir.pwd)
|
76
|
+
file_objects = Dir.glob(File.expand_path("*.rb",path)).map do |file_path|
|
77
|
+
#读取 xxx.rb文件
|
78
|
+
Spec.form_file(file_path)
|
79
|
+
end
|
80
|
+
# 便利出每一个pod对安装信息
|
81
|
+
file_objects.each do |file|
|
82
|
+
if file.install
|
83
|
+
options = file.pod_requirements
|
84
|
+
self.pod(file.name, options)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
89
|
+
|
90
|
+
private
|
91
|
+
def install_local_pod(name, options = {})
|
92
|
+
hash_map = options
|
93
|
+
path = options[:path]
|
94
|
+
branch = options[:branch]
|
95
|
+
unless Dir.exist?(path)
|
96
|
+
puts "no such file or directory at path => `#{path}`"
|
97
|
+
return
|
98
|
+
end
|
99
|
+
local_path = Pathname(path)
|
100
|
+
unless local_path.glob("*.git").empty?
|
101
|
+
puts "path => `#{local_path}` 找不到.git目录"
|
102
|
+
end
|
103
|
+
self.git_util.git_init(name, :branch => branch, :path => local_path)
|
104
|
+
self.git_util.git_local_pod_check
|
105
|
+
hash_map.delete(:tag)
|
106
|
+
hash_map.delete(:git)
|
107
|
+
hash_map.delete(:depth)
|
108
|
+
hash_map.delete(:commit)
|
109
|
+
hash_map.delete(:branch)
|
110
|
+
# 安装本地私有组件库
|
111
|
+
@target.store_pod(name, hash_map)
|
112
|
+
end
|
113
|
+
|
114
|
+
end
|
115
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
module LgPodPlugin
|
2
|
+
|
3
|
+
class Spec
|
4
|
+
|
5
|
+
REQUIRED_ATTRS ||= %i[install name git commit tag path branch].freeze
|
6
|
+
attr_accessor(*REQUIRED_ATTRS)
|
7
|
+
OPTIONAL_ATTRS ||= %i[depth configurations modular_headers subspecs inhibit_warnings testspecs].freeze
|
8
|
+
attr_accessor(*OPTIONAL_ATTRS)
|
9
|
+
def initialize(defined_in_file = nil, &block)
|
10
|
+
if block
|
11
|
+
instance_eval(&block)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def inspect
|
16
|
+
"#{self.class}: #{object_id} name: #{name}, tag: #{tag}"
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.form_file(file_path)
|
20
|
+
contents = File.open(file_path, 'r:utf-8', &:read)
|
21
|
+
if contents.respond_to?(:encoding) && contents.encoding.name != 'UTF-8'
|
22
|
+
contents.encoding("UTF-8")
|
23
|
+
end
|
24
|
+
# 2 讲xx.rb转成 Spec 对象
|
25
|
+
l_spec = eval(contents, nil , file_path.to_s)
|
26
|
+
if l_spec.install == nil
|
27
|
+
l_spec.install = true
|
28
|
+
end
|
29
|
+
l_spec
|
30
|
+
end
|
31
|
+
|
32
|
+
# pod 必传参数
|
33
|
+
def pod_requirements
|
34
|
+
h = nil
|
35
|
+
unless install != false
|
36
|
+
return h
|
37
|
+
end
|
38
|
+
# 集成组件时, 【必选】参数, 必须互斥
|
39
|
+
if path
|
40
|
+
h = { path: path }
|
41
|
+
elsif git && commit
|
42
|
+
h = { git: git, commit: commit }
|
43
|
+
elsif git && tag
|
44
|
+
h = { git: git, tag: tag }
|
45
|
+
elsif git && branch
|
46
|
+
# branch is not supported for binary
|
47
|
+
h = { git: git, branch: branch, depth: depth }
|
48
|
+
else
|
49
|
+
puts("VirusFile is not valid, `#{name}` will not be required\n")
|
50
|
+
end
|
51
|
+
|
52
|
+
pod_optional(h)
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
def pod_optional(h)
|
57
|
+
OPTIONAL_ATTRS.each do |att|
|
58
|
+
value = send(att)
|
59
|
+
h[att] = value unless value.nil?
|
60
|
+
end
|
61
|
+
h
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'git'
|
2
|
+
require 'sqlite3'
|
3
|
+
require "lg_pod_plugin/version"
|
4
|
+
require_relative 'lg_pod_plugin/database'
|
5
|
+
require_relative 'lg_pod_plugin/download'
|
6
|
+
require_relative 'lg_pod_plugin/git_util'
|
7
|
+
require_relative 'lg_pod_plugin/pod_spec'
|
8
|
+
require_relative 'lg_pod_plugin/install'
|
9
|
+
|
10
|
+
module LgPodPlugin
|
11
|
+
|
12
|
+
class Error < StandardError; end
|
13
|
+
|
14
|
+
def self.install(defined_in_file = nil, profile, &block)
|
15
|
+
Installer.new(defined_in_file, profile, &block)
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.install_form_spec(profile, spec_path = nil)
|
19
|
+
return Installer.new(profile).install_form_specs(spec_path)
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
metadata
ADDED
@@ -0,0 +1,152 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: lg_pod_plugin
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- dongzb01
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-09-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: sqlite3
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.4.4
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.4.4
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bacon
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.1'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.1'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 13.0.6
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 13.0.6
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: git
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 1.12.0
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 1.12.0
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: cocoapods
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 1.11.3
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 1.11.3
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rspec
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '3.0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '3.0'
|
111
|
+
description: 拦截pod_install 方法, 并设置 pod 方法参数列表
|
112
|
+
email:
|
113
|
+
- 1060545231@qq.com
|
114
|
+
executables: []
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- LICENSE
|
119
|
+
- README.md
|
120
|
+
- lib/lg_pod_plugin.rb
|
121
|
+
- lib/lg_pod_plugin/cache.rb
|
122
|
+
- lib/lg_pod_plugin/database.rb
|
123
|
+
- lib/lg_pod_plugin/download.rb
|
124
|
+
- lib/lg_pod_plugin/file_path.rb
|
125
|
+
- lib/lg_pod_plugin/git_util.rb
|
126
|
+
- lib/lg_pod_plugin/install.rb
|
127
|
+
- lib/lg_pod_plugin/pod_spec.rb
|
128
|
+
- lib/lg_pod_plugin/version.rb
|
129
|
+
homepage: https://gitee.com/fmdb_beantech_admin/lg_pod_plugin
|
130
|
+
licenses:
|
131
|
+
- MIT
|
132
|
+
metadata: {}
|
133
|
+
post_install_message:
|
134
|
+
rdoc_options: []
|
135
|
+
require_paths:
|
136
|
+
- lib
|
137
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
138
|
+
requirements:
|
139
|
+
- - ">="
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: 2.3.0
|
142
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - ">="
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '0'
|
147
|
+
requirements: []
|
148
|
+
rubygems_version: 3.1.6
|
149
|
+
signing_key:
|
150
|
+
specification_version: 4
|
151
|
+
summary: 封装了自定义podfile 中pod 方法
|
152
|
+
test_files: []
|