cocoapods-soul-component-plugin 0.0.10 → 0.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '086cfd8e90765ff78ef8b39dc1d1d0fd0e8df174410e0fac71360946eb62acda'
|
4
|
+
data.tar.gz: 6657b4e8d4ef34e00843a6ba56e32c71239e844f2f9f07c7d10caacb1aafcd54
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 52780e0b5c959db595b9d3e1d8914cd2383243f1184ff1d6b9528dffed5b353ad0775c57e6c294da5c819d5a50bd4f02cba681ac929dae73b441adafa6fd22e5
|
7
|
+
data.tar.gz: 5b5ecb2dc862f56aee5ead37711e8901c985ba8d934caf3ef56e7566669ed5e2a6c41e25a0689375cd032d6fb18841f3d96f0742a29c84dfeb1080d515167292
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'cocoapods'
|
2
4
|
require 'fileutils'
|
3
5
|
require 'json'
|
@@ -10,9 +12,15 @@ module Pod
|
|
10
12
|
module Downloader
|
11
13
|
class Git < Base
|
12
14
|
def download_deep
|
13
|
-
clone(false,false
|
15
|
+
clone(false, false)
|
14
16
|
checkout_commit if options[:commit]
|
15
17
|
end
|
18
|
+
|
19
|
+
def self.check_if_has_auth_clone(url)
|
20
|
+
cmd = "git ls-remote #{url} --exit-code"
|
21
|
+
stdout, stderr, status = Open3.capture3(cmd)
|
22
|
+
status.success?
|
23
|
+
end
|
16
24
|
end
|
17
25
|
end
|
18
26
|
|
@@ -24,7 +32,6 @@ module Pod
|
|
24
32
|
self.description = <<-DESC
|
25
33
|
Install components through devops/components.json
|
26
34
|
DESC
|
27
|
-
self.arguments = []
|
28
35
|
|
29
36
|
def run
|
30
37
|
# do nothing
|
@@ -35,7 +42,20 @@ module Pod
|
|
35
42
|
end
|
36
43
|
|
37
44
|
module CocoapodsSoulComponentPlugin
|
38
|
-
|
45
|
+
@@components = []
|
46
|
+
@@use_source = false
|
47
|
+
|
48
|
+
def self.use_source=(t_use_source)
|
49
|
+
@@use_source = t_use_source
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.use_source
|
53
|
+
@@use_source
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.components
|
57
|
+
@@components
|
58
|
+
end
|
39
59
|
|
40
60
|
class Soul_Component
|
41
61
|
attr_accessor :name, :local, :submodule, :version, :git, :branch, :path, :commit
|
@@ -50,6 +70,12 @@ module CocoapodsSoulComponentPlugin
|
|
50
70
|
@path = path
|
51
71
|
@commit = commit
|
52
72
|
end
|
73
|
+
|
74
|
+
def to_hash
|
75
|
+
instance_variables.map do |var|
|
76
|
+
[var[1..-1].to_sym, instance_variable_get(var)]
|
77
|
+
end.to_h
|
78
|
+
end
|
53
79
|
end
|
54
80
|
|
55
81
|
def self.use_components
|
@@ -68,6 +94,10 @@ module CocoapodsSoulComponentPlugin
|
|
68
94
|
"#{root_path}/devops/component.json"
|
69
95
|
end
|
70
96
|
|
97
|
+
def self.component_user_file_path
|
98
|
+
"#{root_path}/devops/component_user.json"
|
99
|
+
end
|
100
|
+
|
71
101
|
Pod::HooksManager.register('cocoapods-soul-component-plugin', :pre_install) do |_context|
|
72
102
|
Pod::UI.puts '插件 pre_install'
|
73
103
|
end
|
@@ -80,12 +110,19 @@ module CocoapodsSoulComponentPlugin
|
|
80
110
|
|
81
111
|
def self.post_run
|
82
112
|
Pod::UI.puts '添加component.json文件引用'
|
113
|
+
if File.exist?(component_user_file_path)
|
114
|
+
add_refrence(component_user_file_path)
|
115
|
+
end
|
116
|
+
add_refrence(component_file_path)
|
117
|
+
end
|
118
|
+
|
119
|
+
def self.add_refrence(file_path)
|
83
120
|
project = Xcodeproj::Project.open(Pod::Config.instance.sandbox.project_path)
|
84
121
|
# 获取主group
|
85
122
|
group = project.main_group
|
86
123
|
group.set_source_tree('SOURCE_ROOT')
|
87
124
|
# 向group中添加 文件引用
|
88
|
-
file_ref = group.new_reference(
|
125
|
+
file_ref = group.new_reference(file_path)
|
89
126
|
# podfile_local排序
|
90
127
|
podfile_local_group = group.children.last
|
91
128
|
group.children.pop
|
@@ -93,29 +130,75 @@ module CocoapodsSoulComponentPlugin
|
|
93
130
|
project.save
|
94
131
|
end
|
95
132
|
|
96
|
-
def self.
|
97
|
-
|
98
|
-
json = File.read(
|
133
|
+
def self.generateComponents
|
134
|
+
components = []
|
135
|
+
json = File.read(component_file_path)
|
99
136
|
obj = JSON.parse(json)
|
100
|
-
dependencies = obj['dependencies']
|
101
137
|
|
138
|
+
dependencies_user = nil
|
139
|
+
if File.exist?(component_user_file_path)
|
140
|
+
json_user = File.read(component_user_file_path)
|
141
|
+
obj_user = JSON.parse(json_user)
|
142
|
+
dependencies_user = obj_user['dependencies']
|
143
|
+
end
|
144
|
+
|
145
|
+
dependencies = obj['dependencies']
|
102
146
|
dependencies.each do |each|
|
103
|
-
|
147
|
+
component = Soul_Component.new(each[0], each[1]['local'], each[1]['submodule'], each[1]['version'], each[1]['git'],
|
148
|
+
each[1]['branch'], each[1]['path'], each[1]['commit'])
|
149
|
+
if dependencies_user && dependencies_user[component.name]
|
150
|
+
component.local = dependencies_user[component.name]['local'] if dependencies_user[component.name]['local']
|
151
|
+
component.submodule = dependencies_user[component.name]['submodule'] if dependencies_user[component.name]['submodule']
|
152
|
+
component.version = dependencies_user[component.name]['version']
|
153
|
+
component.git = dependencies_user[component.name]['git'] if dependencies_user[component.name]['git']
|
154
|
+
component.branch = dependencies_user[component.name]['branch']
|
155
|
+
component.path = dependencies_user[component.name]['path']
|
156
|
+
component.commit = dependencies_user[component.name]['commit']
|
157
|
+
Pod::UI.puts "使用用户配置覆盖。参数:#{component.to_hash}".green
|
158
|
+
end
|
159
|
+
if @@use_source
|
160
|
+
component.local = true
|
161
|
+
if Pod::Downloader::Git.check_if_has_auth_clone(component.git) == false
|
162
|
+
component.local = false
|
163
|
+
Pod::UI.puts "本地依赖 #{component.name} 切换失败,使用 binary 。参数:#{component.to_hash}".red
|
164
|
+
end
|
165
|
+
end
|
166
|
+
components.push(component)
|
104
167
|
end
|
168
|
+
components
|
169
|
+
end
|
105
170
|
|
106
|
-
|
107
|
-
|
171
|
+
def self.checkValidComponents
|
172
|
+
isValid = true
|
173
|
+
@@components.each do |each|
|
174
|
+
if each.name.nil? || each.git.nil? || each.local.nil? || each.submodule.nil?
|
175
|
+
Pod::UI.puts "缺少必要参数,name/git/local/submodule为必要参数:#{each.to_hash}".red
|
176
|
+
isValid = false
|
177
|
+
end
|
178
|
+
end
|
179
|
+
isValid
|
180
|
+
end
|
181
|
+
|
182
|
+
def self.pre_run
|
183
|
+
@@components = generateComponents
|
184
|
+
if checkValidComponents == false
|
185
|
+
Pod::UI.puts '参数异常,退出'.red
|
186
|
+
exit(1)
|
187
|
+
end
|
188
|
+
|
189
|
+
@@components.each do |each|
|
190
|
+
if each.path.nil?
|
108
191
|
if each.submodule == false
|
109
192
|
if each.local == true
|
110
193
|
local_path = each.name
|
111
194
|
|
112
|
-
if each.commit
|
195
|
+
if !each.commit.nil?
|
113
196
|
local_path += '-'
|
114
197
|
local_path += each.commit.to_s
|
115
|
-
elsif each.branch
|
198
|
+
elsif !each.branch.nil?
|
116
199
|
local_path += '-'
|
117
200
|
local_path += each.branch.to_s
|
118
|
-
elsif each.version
|
201
|
+
elsif !each.version.nil?
|
119
202
|
local_path += '-'
|
120
203
|
local_path += each.version.to_s
|
121
204
|
end
|
@@ -123,7 +206,7 @@ module CocoapodsSoulComponentPlugin
|
|
123
206
|
each.path = target_path
|
124
207
|
|
125
208
|
if File.exist?(target_path) == false
|
126
|
-
options = { git: each.git, commit: each.commit, tag: each.version, branch:each.branch }
|
209
|
+
options = { git: each.git, commit: each.commit, tag: each.version, branch: each.branch }
|
127
210
|
options = Pod::Downloader.preprocess_options(options)
|
128
211
|
downloader = Pod::Downloader.for_target(target_path, options)
|
129
212
|
Pod::UI.puts "本地依赖 #{each.name} 不存在,即将进行下载 。参数:#{options}".green
|
@@ -132,10 +215,8 @@ module CocoapodsSoulComponentPlugin
|
|
132
215
|
Pod::UI.puts "本地依赖 #{each.name} 已存在,不进行变更,如需更新请删除重新 install。位置:#{target_path}".yellow
|
133
216
|
end
|
134
217
|
end
|
135
|
-
|
136
|
-
|
137
|
-
each.path = "SOPods/#{each.name}"
|
138
|
-
end
|
218
|
+
elsif each.local == true
|
219
|
+
each.path = "SOPods/#{each.name}"
|
139
220
|
end
|
140
221
|
end
|
141
222
|
end
|
@@ -146,8 +227,21 @@ end
|
|
146
227
|
module Pod
|
147
228
|
class Command
|
148
229
|
class Install < Command
|
230
|
+
def self.options
|
231
|
+
[
|
232
|
+
['--source', 'Use source']
|
233
|
+
].concat(super)
|
234
|
+
end
|
235
|
+
|
236
|
+
def initialize(argv)
|
237
|
+
CocoapodsSoulComponentPlugin.use_source = argv.flag?('source')
|
238
|
+
super
|
239
|
+
end
|
240
|
+
|
149
241
|
alias old_run run
|
242
|
+
|
150
243
|
def run
|
244
|
+
Pod::UI.puts "当前版本:#{CocoapodsSoulComponentPlugin::VERSION}".green
|
151
245
|
CocoapodsSoulComponentPlugin.pre_run if CocoapodsSoulComponentPlugin.use_components
|
152
246
|
old_run
|
153
247
|
CocoapodsSoulComponentPlugin.post_run if CocoapodsSoulComponentPlugin.use_components
|
@@ -159,7 +253,7 @@ module Pod
|
|
159
253
|
alias old_initialize initialize
|
160
254
|
|
161
255
|
def initialize(name = nil, *requirements)
|
162
|
-
if requirements
|
256
|
+
if requirements.nil?
|
163
257
|
old_initialize(name)
|
164
258
|
return
|
165
259
|
end
|
@@ -168,14 +262,14 @@ module Pod
|
|
168
262
|
# puts name, requirements
|
169
263
|
# end
|
170
264
|
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
265
|
+
CocoapodsSoulComponentPlugin.components.each do |each|
|
266
|
+
next unless each.name == name
|
267
|
+
|
268
|
+
requirements = if each.local == true
|
269
|
+
[{ name: each.name, path: each.path }]
|
270
|
+
else
|
271
|
+
[each.version]
|
272
|
+
end
|
179
273
|
end
|
180
274
|
|
181
275
|
old_initialize(name, *requirements)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cocoapods-soul-component-plugin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- fang
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-12-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|