cocoapods-soul-component-plugin 0.0.9 → 0.0.13
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: e24028ddd6eaf2842b42ec156eaa176c8e25979b027fe0bfc78b9de2d6b13aff
|
4
|
+
data.tar.gz: 9ce54967f87d00a17b6697ec228027fc3e0af35442981ade92f9a801cdead879
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a02b79d7921ede221a8cf9784f333ad29c5cf757c289a059457b2f21576aa9783fe6a9e81f6950ef90a9d0e24a4067900428b875b9302b59e21a7925fa81c006
|
7
|
+
data.tar.gz: 23d77f22305b4513bf2bc77fe0843d827aa0ec1b06c5dd8868d4327b86eb4a1531ccedbbd7c513590720ed5a19a8c04b56df193d3adce68d7be8fd9f49ad5d06
|
@@ -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
|
@@ -85,7 +115,8 @@ module CocoapodsSoulComponentPlugin
|
|
85
115
|
group = project.main_group
|
86
116
|
group.set_source_tree('SOURCE_ROOT')
|
87
117
|
# 向group中添加 文件引用
|
88
|
-
file_ref = group.new_reference(
|
118
|
+
file_ref = group.new_reference(component_file_path)
|
119
|
+
file_user_ref = group.new_reference(component_user_file_path)
|
89
120
|
# podfile_local排序
|
90
121
|
podfile_local_group = group.children.last
|
91
122
|
group.children.pop
|
@@ -93,37 +124,83 @@ module CocoapodsSoulComponentPlugin
|
|
93
124
|
project.save
|
94
125
|
end
|
95
126
|
|
96
|
-
def self.
|
97
|
-
|
98
|
-
json = File.read(
|
127
|
+
def self.generateComponents
|
128
|
+
components = []
|
129
|
+
json = File.read(component_file_path)
|
99
130
|
obj = JSON.parse(json)
|
100
|
-
dependencies = obj['dependencies']
|
101
131
|
|
132
|
+
dependencies_user = nil
|
133
|
+
if File.exist?(component_user_file_path)
|
134
|
+
json_user = File.read(component_user_file_path)
|
135
|
+
obj_user = JSON.parse(json_user)
|
136
|
+
dependencies_user = obj_user['dependencies']
|
137
|
+
end
|
138
|
+
|
139
|
+
dependencies = obj['dependencies']
|
102
140
|
dependencies.each do |each|
|
103
|
-
|
141
|
+
component = Soul_Component.new(each[0], each[1]['local'], each[1]['submodule'], each[1]['version'], each[1]['git'],
|
142
|
+
each[1]['branch'], each[1]['path'], each[1]['commit'])
|
143
|
+
if dependencies_user && dependencies_user[component.name]
|
144
|
+
component.local = dependencies_user[component.name]['local'] if dependencies_user[component.name]['local']
|
145
|
+
component.submodule = dependencies_user[component.name]['submodule'] if dependencies_user[component.name]['submodule']
|
146
|
+
component.version = dependencies_user[component.name]['version']
|
147
|
+
component.git = dependencies_user[component.name]['git'] if dependencies_user[component.name]['git']
|
148
|
+
component.branch = dependencies_user[component.name]['branch']
|
149
|
+
component.path = dependencies_user[component.name]['path']
|
150
|
+
component.commit = dependencies_user[component.name]['commit']
|
151
|
+
Pod::UI.puts "使用用户配置覆盖。参数:#{component.to_hash}".green
|
152
|
+
end
|
153
|
+
if @@use_source
|
154
|
+
component.local = true
|
155
|
+
if Pod::Downloader::Git.check_if_has_auth_clone(component.git) == false
|
156
|
+
component.local = false
|
157
|
+
Pod::UI.puts "本地依赖 #{component.name} 切换失败,使用 binary 。参数:#{component.to_hash}".red
|
158
|
+
end
|
159
|
+
end
|
160
|
+
components.push(component)
|
161
|
+
end
|
162
|
+
components
|
163
|
+
end
|
164
|
+
|
165
|
+
def self.checkValidComponents
|
166
|
+
isValid = true
|
167
|
+
@@components.each do |each|
|
168
|
+
if each.name.nil? || each.git.nil? || each.local.nil? || each.submodule.nil?
|
169
|
+
Pod::UI.puts "缺少必要参数,name/git/local/submodule为必要参数:#{each.to_hash}".red
|
170
|
+
isValid = false
|
171
|
+
end
|
104
172
|
end
|
173
|
+
isValid
|
174
|
+
end
|
105
175
|
|
106
|
-
|
107
|
-
|
176
|
+
def self.pre_run
|
177
|
+
@@components = generateComponents
|
178
|
+
if checkValidComponents == false
|
179
|
+
Pod::UI.puts '参数异常,退出'.red
|
180
|
+
exit(1)
|
181
|
+
end
|
182
|
+
|
183
|
+
@@components.each do |each|
|
184
|
+
if each.path.nil?
|
108
185
|
if each.submodule == false
|
109
186
|
if each.local == true
|
110
187
|
local_path = each.name
|
111
188
|
|
112
|
-
if each.commit
|
189
|
+
if !each.commit.nil?
|
113
190
|
local_path += '-'
|
114
191
|
local_path += each.commit.to_s
|
115
|
-
elsif each.branch
|
192
|
+
elsif !each.branch.nil?
|
116
193
|
local_path += '-'
|
117
194
|
local_path += each.branch.to_s
|
118
|
-
elsif each.version
|
195
|
+
elsif !each.version.nil?
|
119
196
|
local_path += '-'
|
120
197
|
local_path += each.version.to_s
|
121
198
|
end
|
122
|
-
target_path = "#{root_path}/LocalPods/#{local_path}
|
199
|
+
target_path = "#{root_path}/LocalPods/#{local_path}"
|
123
200
|
each.path = target_path
|
124
201
|
|
125
202
|
if File.exist?(target_path) == false
|
126
|
-
options = { git: each.git, commit: each.commit, tag: each.version, branch:each.branch }
|
203
|
+
options = { git: each.git, commit: each.commit, tag: each.version, branch: each.branch }
|
127
204
|
options = Pod::Downloader.preprocess_options(options)
|
128
205
|
downloader = Pod::Downloader.for_target(target_path, options)
|
129
206
|
Pod::UI.puts "本地依赖 #{each.name} 不存在,即将进行下载 。参数:#{options}".green
|
@@ -132,10 +209,8 @@ module CocoapodsSoulComponentPlugin
|
|
132
209
|
Pod::UI.puts "本地依赖 #{each.name} 已存在,不进行变更,如需更新请删除重新 install。位置:#{target_path}".yellow
|
133
210
|
end
|
134
211
|
end
|
135
|
-
|
136
|
-
|
137
|
-
each.path = "SOPods/#{each.name}"
|
138
|
-
end
|
212
|
+
elsif each.local == true
|
213
|
+
each.path = "SOPods/#{each.name}"
|
139
214
|
end
|
140
215
|
end
|
141
216
|
end
|
@@ -146,8 +221,21 @@ end
|
|
146
221
|
module Pod
|
147
222
|
class Command
|
148
223
|
class Install < Command
|
224
|
+
def self.options
|
225
|
+
[
|
226
|
+
['--source', 'Use source']
|
227
|
+
].concat(super)
|
228
|
+
end
|
229
|
+
|
230
|
+
def initialize(argv)
|
231
|
+
CocoapodsSoulComponentPlugin.use_source = argv.flag?('source')
|
232
|
+
super
|
233
|
+
end
|
234
|
+
|
149
235
|
alias old_run run
|
236
|
+
|
150
237
|
def run
|
238
|
+
Pod::UI.puts "当前版本:#{CocoapodsSoulComponentPlugin::VERSION}".green
|
151
239
|
CocoapodsSoulComponentPlugin.pre_run if CocoapodsSoulComponentPlugin.use_components
|
152
240
|
old_run
|
153
241
|
CocoapodsSoulComponentPlugin.post_run if CocoapodsSoulComponentPlugin.use_components
|
@@ -159,7 +247,7 @@ module Pod
|
|
159
247
|
alias old_initialize initialize
|
160
248
|
|
161
249
|
def initialize(name = nil, *requirements)
|
162
|
-
if requirements
|
250
|
+
if requirements.nil?
|
163
251
|
old_initialize(name)
|
164
252
|
return
|
165
253
|
end
|
@@ -168,14 +256,14 @@ module Pod
|
|
168
256
|
# puts name, requirements
|
169
257
|
# end
|
170
258
|
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
259
|
+
CocoapodsSoulComponentPlugin.components.each do |each|
|
260
|
+
next unless each.name == name
|
261
|
+
|
262
|
+
requirements = if each.local == true
|
263
|
+
[{ name: each.name, path: each.path }]
|
264
|
+
else
|
265
|
+
[each.version]
|
266
|
+
end
|
179
267
|
end
|
180
268
|
|
181
269
|
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.13
|
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
|