Module: CocoapodsSoulComponentPlugin
- Defined in:
- lib/cocoapods-soul-component-plugin/gem_version.rb,
lib/cocoapods-soul-component-plugin/command/soul-component-plugin.rb
Defined Under Namespace
Classes: Soul_Component
Constant Summary collapse
- VERSION =
'0.0.25'
- @@components =
[]
- @@use_source =
false
- @@import_dependency =
''
Class Method Summary collapse
- .add_refrence(file_path) ⇒ Object
- .checkValidComponents ⇒ Object
- .component_file_path ⇒ Object
- .component_user_file_path ⇒ Object
- .components ⇒ Object
- .generateComponents ⇒ Object
- .import_dependency ⇒ Object
- .import_dependency=(t_import_dependency) ⇒ Object
- .podfile_path ⇒ Object
- .post_run ⇒ Object
- .pre_run ⇒ Object
- .root_path ⇒ Object
- .use_components ⇒ Object
- .use_source ⇒ Object
- .use_source=(t_use_source) ⇒ Object
Class Method Details
.add_refrence(file_path) ⇒ Object
175 176 177 178 179 180 181 182 183 184 185 186 187 |
# File 'lib/cocoapods-soul-component-plugin/command/soul-component-plugin.rb', line 175 def self.add_refrence(file_path) project = Xcodeproj::Project.open(Pod::Config.instance.sandbox.project_path) # 获取主group group = project.main_group group.set_source_tree('SOURCE_ROOT') # 向group中添加 文件引用 file_ref = group.new_reference(file_path) # podfile_local排序 podfile_local_group = group.children.last group.children.pop group.children.unshift(podfile_local_group) project.save end |
.checkValidComponents ⇒ Object
227 228 229 230 231 232 233 234 235 236 |
# File 'lib/cocoapods-soul-component-plugin/command/soul-component-plugin.rb', line 227 def self.checkValidComponents isValid = true @@components.each do |each| if each.name.nil? || each.git.nil? || each.local.nil? || each.submodule.nil? Pod::UI.puts "缺少必要参数,name/git/local/submodule为必要参数:#{each.to_hash}".red isValid = false end end isValid end |
.component_file_path ⇒ Object
149 150 151 |
# File 'lib/cocoapods-soul-component-plugin/command/soul-component-plugin.rb', line 149 def self.component_file_path "#{root_path}/devops/component.json" end |
.component_user_file_path ⇒ Object
153 154 155 |
# File 'lib/cocoapods-soul-component-plugin/command/soul-component-plugin.rb', line 153 def self.component_user_file_path "#{root_path}/devops/component_user.json" end |
.components ⇒ Object
112 113 114 |
# File 'lib/cocoapods-soul-component-plugin/command/soul-component-plugin.rb', line 112 def self.components @@components end |
.generateComponents ⇒ Object
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 |
# File 'lib/cocoapods-soul-component-plugin/command/soul-component-plugin.rb', line 190 def self.generateComponents components = [] json = File.read(component_file_path) obj = JSON.parse(json) dependency_user = nil dependency_import = nil if File.exist?(component_user_file_path) json_user = File.read(component_user_file_path) obj_user = JSON.parse(json_user) obj = obj.deep_merge!(obj_user) puts "混入用户配置,结果为:#{obj}" end if @@import_dependency.length.positive? import_json = JSON.parse(self.import_dependency) obj = obj.deep_merge!(import_json) puts "混入导入配置,结果为:#{obj}" end dependencies = obj['dependencies'] dependencies.each do |each| component = Soul_Component.new(each[0], each[1]['local'], each[1]['submodule'], each[1]['version'], each[1]['git'], each[1]['branch'], each[1]['path'], each[1]['commit']) if @@use_source component.local = true if Pod::Downloader::Git.check_if_has_auth_clone(component.git) == false component.local = false Pod::UI.puts "本地依赖 #{component.name} 切换失败,使用 binary 。参数:#{component.to_hash}".red end end components.push(component) end components end |
.import_dependency ⇒ Object
108 109 110 |
# File 'lib/cocoapods-soul-component-plugin/command/soul-component-plugin.rb', line 108 def self.import_dependency @@import_dependency end |
.import_dependency=(t_import_dependency) ⇒ Object
104 105 106 |
# File 'lib/cocoapods-soul-component-plugin/command/soul-component-plugin.rb', line 104 def self.import_dependency=(t_import_dependency) @@import_dependency = t_import_dependency end |
.podfile_path ⇒ Object
145 146 147 |
# File 'lib/cocoapods-soul-component-plugin/command/soul-component-plugin.rb', line 145 def self.podfile_path "#{root_path}/Podfile" end |
.post_run ⇒ Object
167 168 169 170 171 172 173 |
# File 'lib/cocoapods-soul-component-plugin/command/soul-component-plugin.rb', line 167 def self.post_run Pod::UI.puts '添加component.json文件引用' if File.exist?(component_user_file_path) add_refrence(component_user_file_path) end add_refrence(component_file_path) end |
.pre_run ⇒ Object
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 |
# File 'lib/cocoapods-soul-component-plugin/command/soul-component-plugin.rb', line 238 def self.pre_run @@components = generateComponents if checkValidComponents == false Pod::UI.puts '参数异常,退出'.red exit(1) end @@components.each do |each| if each.path.nil? if each.local == true local_path = each.name if !each.commit.nil? local_path += '-' local_path += each.commit.to_s elsif !each.branch.nil? local_path += '-' local_path += each.branch.to_s.gsub('/','-') elsif !each.version.nil? local_path += '-' local_path += each.version.to_s.gsub('/','-') end target_path = "#{root_path}/LocalPods/#{local_path}" each.path = target_path if File.exist?(target_path) == false # 使用优先顺序 commit>branch>tag c = each.commit b = each.branch v = each.version if (c != nil) v = nil b = nil end if (b != nil) v = nil end = { git: each.git, commit: c, tag: v, branch: b } # 这行代码会自动清空branch并且设置commit # options = Pod::Downloader.preprocess_options(options) downloader = Pod::Downloader.for_target(target_path, ) Pod::UI.puts "本地依赖 #{each.name} 不存在,即将进行下载 。参数:#{}".green downloader.download_deep else Pod::UI.puts "本地依赖 #{each.name} 已存在,不进行变更,如需更新请删除重新 install。位置:#{target_path}".yellow end end end end end |
.root_path ⇒ Object
141 142 143 |
# File 'lib/cocoapods-soul-component-plugin/command/soul-component-plugin.rb', line 141 def self.root_path Pod::Config.instance.installation_root.to_s end |
.use_components ⇒ Object
137 138 139 |
# File 'lib/cocoapods-soul-component-plugin/command/soul-component-plugin.rb', line 137 def self.use_components File.exist?(component_file_path) end |
.use_source ⇒ Object
100 101 102 |
# File 'lib/cocoapods-soul-component-plugin/command/soul-component-plugin.rb', line 100 def self.use_source @@use_source end |
.use_source=(t_use_source) ⇒ Object
96 97 98 |
# File 'lib/cocoapods-soul-component-plugin/command/soul-component-plugin.rb', line 96 def self.use_source=(t_use_source) @@use_source = t_use_source end |