Module: Pod::Podfile::DSL
- Defined in:
- lib/cocoapods-mPaaS/dsl.rb
Constant Summary collapse
- VERSION_REMOVE =
这里标记模块可选依赖的 magic word
"mPaaS_remove"
Instance Method Summary collapse
- #aliAccountExist? ⇒ Boolean
-
#fix_AMap3DMap_10_1_32! ⇒ Object
一些特殊定制的,修复冲突用的先写这里吧.
- #fix_AMap3DMap_10_1_60! ⇒ Object
- #fix_pod(name, version) ⇒ Object
- #lbsExist? ⇒ Boolean
- #moduleExist?(moduleName) ⇒ Boolean
- #mPaaS_baseline(baseline) ⇒ Object
- #mPaaS_igenore_headers(*headers) ⇒ Object
- #mPaaS_local_component_json(path) ⇒ Object
- #mPaaS_local_content_json(path, fallback = false) ⇒ Object
-
#mPaaS_pod(name, *version) ⇒ Object
Podfile 中 DSL 用.
- #mPaaS_repo_url(url) ⇒ Object
- #mpaas_target_ignore_headers(*headers) ⇒ Object
- #mPaaS_used(use) ⇒ Object
-
#mPaaS_version_code(*version_code) ⇒ Object
只是记录展示用.
- #origin_pod ⇒ Object
-
#pod(name = nil, *requirements) ⇒ Object
self.is_pod_support_mPaaS = true.
- #remove_pod(name) ⇒ Object
- #tinyAppExist? ⇒ Boolean
- #use_mPaaS_online! ⇒ Object
-
#use_pod_for_mPaaS! ⇒ Object
方法的嵌套 ? 最大程度的减少对原有逻辑的侵入性.
- #use_tinyApp! ⇒ Object
Instance Method Details
#aliAccountExist? ⇒ Boolean
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/cocoapods-mPaaS/dsl.rb', line 90 def aliAccountExist? project_dir = Dir::pwd podfile_path = File.join(project_dir, "Podfile") mPaaSPodfile = MPaaSPodfile.new mPaaSPodfile.run(podfile_path) # puts("___________________#{mPaaSPodfile.mPaaSBaseline}\n_____#{mPaaSPodfile.mPaaSPodVersion}\n_____#{mPaaSPodfile.mPaaSVersionCode}\n_____#{mPaaSPodfile.mPaaSPodNames}\n_____") mPaaSPodfile.mPaaSPodNames.each do |name| if name == "mPaaS_AliAccount" return true end end return false end |
#fix_AMap3DMap_10_1_32! ⇒ Object
一些特殊定制的,修复冲突用的先写这里吧
484 485 486 487 488 |
# File 'lib/cocoapods-mPaaS/dsl.rb', line 484 def fix_AMap3DMap_10_1_32! fix_pod "APMobileLBS", "1.0.1.190225153620.1" fix_pod "AMapFoundationKit", "" fix_pod "MAMapKit", "" end |
#fix_AMap3DMap_10_1_60! ⇒ Object
490 491 492 493 494 |
# File 'lib/cocoapods-mPaaS/dsl.rb', line 490 def fix_AMap3DMap_10_1_60! fix_pod "APMobileLBS", "1.0.1.190807105749.1" fix_pod "AMapFoundationKit", "" fix_pod "MAMapKit", "" end |
#fix_pod(name, version) ⇒ Object
124 125 126 127 128 129 130 |
# File 'lib/cocoapods-mPaaS/dsl.rb', line 124 def fix_pod(name, version) unless self.fix_pods self.fix_pods = {} end self.fix_pods[name] = version end |
#lbsExist? ⇒ Boolean
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/cocoapods-mPaaS/dsl.rb', line 73 def lbsExist? project_dir = Dir::pwd podfile_path = File.join(project_dir, "Podfile") mPaaSPodfile = MPaaSPodfile.new mPaaSPodfile.run(podfile_path) #puts("___________________#{mPaaSPodfile.mPaaSBaseline}\n_____#{mPaaSPodfile.mPaaSPodVersion}\n_____#{mPaaSPodfile.mPaaSVersionCode}\n_____#{mPaaSPodfile.mPaaSPodNames}\n_____") mPaaSPodfile.mPaaSPodNames.each do |name| if name == "mPaaS_LBS" return true end end return false end |
#moduleExist?(moduleName) ⇒ Boolean
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/cocoapods-mPaaS/dsl.rb', line 107 def moduleExist?(moduleName) project_dir = Dir::pwd podfile_path = File.join(project_dir, "Podfile") mPaaSPodfile = MPaaSPodfile.new mPaaSPodfile.run(podfile_path) # puts("___________________#{mPaaSPodfile.mPaaSBaseline}\n_____#{mPaaSPodfile.mPaaSPodVersion}\n_____#{mPaaSPodfile.mPaaSVersionCode}\n_____#{mPaaSPodfile.mPaaSPodNames}\n_____") mPaaSPodfile.mPaaSPodNames.each do |name| if name == moduleName return true end end return false end |
#mPaaS_baseline(baseline) ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/cocoapods-mPaaS/dsl.rb', line 21 def mPaaS_baseline(baseline) # 增加初始化的校验 if baseline == 'x.x.x' info = Pod::MPAAS::Localization.t('mpaas.dsl.replace_baseline_version_note') raise Pod::Informative, info end self.default_baseline = BaselineTools.filterVerison(baseline) end |
#mPaaS_igenore_headers(*headers) ⇒ Object
155 156 157 158 159 160 161 |
# File 'lib/cocoapods-mPaaS/dsl.rb', line 155 def mPaaS_igenore_headers(*headers) headers.each do |item| if item.is_a?(String) MPaaSCocoapodShare.instance.igenore_headers.add(item) end end end |
#mPaaS_local_component_json(path) ⇒ Object
39 40 41 |
# File 'lib/cocoapods-mPaaS/dsl.rb', line 39 def mPaaS_local_component_json(path) self.local_component_json_path = path end |
#mPaaS_local_content_json(path, fallback = false) ⇒ Object
43 44 45 46 |
# File 'lib/cocoapods-mPaaS/dsl.rb', line 43 def mPaaS_local_content_json(path, fallback = false) self.local_content_json_path = path self.local_content_json_fallback = fallback end |
#mPaaS_pod(name, *version) ⇒ Object
Podfile 中 DSL 用
179 180 181 182 183 184 185 186 187 188 189 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 226 227 228 229 230 231 232 233 234 235 236 237 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 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 |
# File 'lib/cocoapods-mPaaS/dsl.rb', line 179 def mPaaS_pod(name, *version) begin unless current_target_definition.abstract? MPaaSCocoapodShare.instance.usedMpaasTarget.add(current_target_definition.name.to_s) end rescue => e LogTools.p_red "cocoapods get current target name error:#{e.}" end current_verison = "" if version && !version.empty? # 先保留一段时间的继续取值 current_verison = BaselineTools.filterVerison(version[0]) LogTools.p_yellow "--------------------------------Warning-----------------------------------------------" LogTools.p_red Pod::MPAAS::Localization.t('mpaas.dsl.mpaas_pod_deprecated_warning', name: name, version: version[0]) LogTools.p_red "" LogTools.p_red Pod::MPAAS::Localization.t('mpaas.dsl.specify_global_default_baseline_warning') else if self.default_baseline current_verison = self.default_baseline else info = Pod::MPAAS::Localization.t('mpaas.dsl.version_not_found_for_pod', name: name, current_version: current_verison) raise Pod::Informative, info end end baseline_hash = BaselineTools.getBaselineByVersion(current_verison, true) dependencies_hash = baseline_hash[name] if dependencies_hash LogTools.v_green "mPaaS_pod : #{name}(#{current_verison}) <> #{dependencies_hash}\n" dependencies_hash.each do |pod_name, pod_version| if pod_name == "MPNebulaSDKPlugins" if self.is_use_tinyApp || tinyAppExist? LogTools.v_red "No need to pod MPNebulaSDKPlugins ..." next end end # 10.1.60 恶心兼容处理 1 if name == "mPaaS_Nebula" && pod_name == "NebulaBiz" && (tinyAppExist?) # || lbsExist? LogTools.p_yellow "skip NebulaBiz in mPaaS_Nebula..." next end # 10.1.60 恶心兼容处理 1a 20200413 # 如果 lbs 和 nebula 共存,用 nebula 的版本 if name == "mPaaS_LBS" && pod_name == "NebulaBiz" && moduleExist?('mPaaS_Nebula') && !tinyAppExist?# || lbsExist? LogTools.p_yellow "skip NebulaBiz in mPaaS_LBS...(use mPaaS_LBS & mPaaS_Nebula)" next end if name == "mPaaS_LBS" && pod_name == "TinyAppCommon" && moduleExist?('mPaaS_Nebula') && !tinyAppExist?# || lbsExist? LogTools.p_yellow "skip TinyAppCommon in mPaaS_LBS...(use mPaaS_LBS & mPaaS_Nebula)" next end # 10.1.60 恶心兼容处理 2 if name == "mPaaS_Nebula" && pod_name == "TinyAppCommon" && (tinyAppExist?) # || lbsExist? LogTools.p_yellow "skip TinyAppCommon in mPaaS_Nebula..." next end # 10.1.60 恶心兼容处理 3 if name == "mPaaS_TinyApp" && pod_name == "Nebula" && aliAccountExist? LogTools.p_yellow "skip Nebula in mPaaS_TinyApp..." next end # 10.1.60 恶心兼容处理 3a if name == "mPaaS_Nebula" && pod_name == "Nebula" && aliAccountExist? LogTools.p_yellow "skip Nebula in mPaaS_Nebula..." next end # 10.1.60 恶心兼容处理 4 if name == "mPaaS_LBS" && pod_name == "Nebula" && aliAccountExist? LogTools.p_yellow "skip Nebula in mPaaS_LBS..." next end # 10.2.3 恶心兼容处理 5 if name == "mPaaS_CDP" && (pod_name == "NebulaBiz" || pod_name == "TinyAppCommon" || pod_name == "Nebula") && moduleExist?('mPaaS_Nebula') LogTools.p_yellow "skip #{pod_name} in mPaaS_CDP... use mPaaS_Nebula" next end # 10.2.3 恶心兼容处理 5a if name == "mPaaS_CDP" && (pod_name == "NebulaBiz" || pod_name == "TinyAppCommon" || pod_name == "Nebula") && tinyAppExist? LogTools.p_yellow "skip #{pod_name} in mPaaS_CDP... use mPaaS_TinyApp" next end if self.fix_pods && self.fix_pods.has_key?(pod_name) # 版本号取 fix_pods 中的 LogTools.v_red "fix_pod #{pod_name}, #{self.fix_pods[pod_name]}" fix_pod_verison = self.fix_pods[pod_name] if fix_pod_verison && !fix_pod_verison.empty? && fix_pod_verison != VERSION_REMOVE pod pod_name, fix_pod_verison elsif fix_pod_verison == VERSION_REMOVE # 查询当前父模块的可选依赖,判断 pod_name 是否允许被移除 unless @_remove_pod_options @_remove_pod_options = BaselineTools.getOptionsInLocalByBaseline(self.default_baseline) || {} content_hash_for_opt = BaselineTools.getContentFileByVersion(self.default_baseline) @_remove_pod_opt_fw = content_hash_for_opt["optional_frameworks"] end opt_module_names = @_remove_pod_options[name] || [] if opt_module_names.empty? pod pod_name, pod_version LogTools.p_yellow "[Warning] remove_pod '#{pod_name}' 未生效:'#{name}' 没有声明可选依赖(options)" else # 收集当前父模块所有可选子模块的直接 frameworks removable_frameworks = [] opt_module_names.each do |opt_name| if @_remove_pod_opt_fw removable_frameworks = removable_frameworks | (@_remove_pod_opt_fw[opt_name] || []) else # 兼容老 content.json,没有 optional_frameworks,用 baseline_hash 的 keys removable_frameworks = removable_frameworks | (baseline_hash[opt_name] ? baseline_hash[opt_name].keys : []) end end if removable_frameworks.include?(pod_name) LogTools.p_yellow "remove_pod #{pod_name} in #{name}" else pod pod_name, pod_version LogTools.p_yellow "[Warning] remove_pod '#{pod_name}' 未生效:'#{pod_name}' 不在 '#{name}' 的可选依赖 frameworks 中" end end else # 如果没设版本号,就认为是去除处理 LogTools.v_red "fix_pod(remove) #{pod_name}" end next end if self.is_use_mPaaS_online pod_version_online = BaselineTools.getPodVersionOnlineByName(pod_name, current_verison) if pod_version != pod_version_online LogTools.p_green "#{pod_name} changed to #{pod_version_online} from #{pod_version}" end pod pod_name, pod_version_online else if pod_version.nil? || pod_version.empty? info = Pod::MPAAS::Localization.t('mpaas.dsl.sorry_version_not_found', pod_name: pod_name) raise Pod::Informative, info end pod pod_name, pod_version end end else info = "No #{name} : #{current_verison} found !!! Check name & version in Podfile" raise Pod::Informative, info end end |
#mPaaS_repo_url(url) ⇒ Object
48 49 50 |
# File 'lib/cocoapods-mPaaS/dsl.rb', line 48 def mPaaS_repo_url(url) self.mpaas_repo_url = url end |
#mpaas_target_ignore_headers(*headers) ⇒ Object
163 164 165 166 167 168 169 170 171 172 173 174 175 176 |
# File 'lib/cocoapods-mPaaS/dsl.rb', line 163 def mpaas_target_ignore_headers(*headers) return if current_target_definition.abstract? # 获取当前的 target 名称作为 Hash 的 Key target_name = current_target_definition.name headers.each do |item| if item.is_a?(String) MPaaSCocoapodShare.instance.targetmap_igenore_headers[target_name] << item end end rescue => e LogTools.p_red "CocoaPods get current target name error: #{e.}" end |
#mPaaS_used(use) ⇒ Object
342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 |
# File 'lib/cocoapods-mPaaS/dsl.rb', line 342 def mPaaS_used(use) begin unless current_target_definition.abstract? if use MPaaSCocoapodShare.instance.usedMpaasTarget.add(current_target_definition.name.to_s) else MPaaSCocoapodShare.instance.usedMpaasTarget.delete(current_target_definition.name.to_s) MPaaSCocoapodShare.instance.unuseMpaasTarget.add(current_target_definition.name.to_s) end end rescue => e LogTools.p_red "cocoapods get current target name error:#{e.}" end end |
#mPaaS_version_code(*version_code) ⇒ Object
只是记录展示用
53 54 |
# File 'lib/cocoapods-mPaaS/dsl.rb', line 53 def mPaaS_version_code(*version_code) end |
#origin_pod ⇒ Object
358 |
# File 'lib/cocoapods-mPaaS/dsl.rb', line 358 alias_method :origin_pod, :pod |
#pod(name = nil, *requirements) ⇒ Object
self.is_pod_support_mPaaS = true
364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 |
# File 'lib/cocoapods-mPaaS/dsl.rb', line 364 def pod(name = nil, *requirements) current_verison = "" if requirements && !requirements.empty? current_verison = requirements[0] # baseline_hash = BaselineTools.getBaselineByVersion(requirements[0]) # dependencies_hash = baseline_hash[name] # if dependencies_hash # LogTools.v_green "pod (origin) : #{name} <> #{dependencies_hash}" # dependencies_hash.each do |pod_name, pod_version| # origin_pod(pod_name, pod_version) # end # else # #todo 测试走这里 # origin_pod(name, *requirements) # end else if self.default_baseline current_verison = self.default_baseline else # 这个地不能抛异常,原生pod其他第三方有可能会走到这 # info = "当前 #{name} : #{current_verison} 找不到版本 ! 请在 mPaaS_pod 后指定版本,或者使用全局默认标识 mPaaS_baseline" # raise Pod::Informative, info end # 如果未显式声明版本号,这里取下 default_baseline # baseline_hash = BaselineTools.getBaselineByVersion(self.default_baseline) # dependencies_hash = baseline_hash[name] # if dependencies_hash # LogTools.v_green "pod (origin) : #{name} <> #{dependencies_hash}" # dependencies_hash.each do |pod_name, pod_version| # origin_pod(pod_name, pod_version) # end # else # #todo 测试走这里 # origin_pod(name, *requirements) # end end baseline_hash = BaselineTools.getBaselineByVersion(current_verison, true) dependencies_hash = baseline_hash[name] if dependencies_hash LogTools.v_green "pod (origin) : #{name} <> #{dependencies_hash}\n" dependencies_hash.each do |pod_name, pod_version| if pod_name == "MPNebulaSDKPlugins" if self.is_use_tinyApp || tinyAppExist? LogTools.v_red "No need to pod MPNebulaSDKPlugins ..." next end end origin_pod(pod_name, pod_version) end else #todo 测试走这里 origin_pod(name, *requirements) # LogTools.p_red name end end |
#remove_pod(name) ⇒ Object
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
# File 'lib/cocoapods-mPaaS/dsl.rb', line 132 def remove_pod(name) unless self.default_baseline info = Pod::MPAAS::Localization.t('mpaas.dsl.use_global_default_baseline') raise Pod::Informative, info end content_hash = BaselineTools.getContentFileByVersion(self.default_baseline) opt_fw = content_hash["optional_frameworks"] if opt_fw && opt_fw[name] # 新 content.json:只标记可选模块的直接 frameworks opt_fw[name].each do |pod_name| fix_pod pod_name, VERSION_REMOVE end else # 兼容老 content.json 或未在 optional_frameworks 中的模块:标记全部 baseline_hash = BaselineTools.getBaselineByVersion(self.default_baseline) dependencies_hash = baseline_hash[name] dependencies_hash && dependencies_hash.each do |pod_name, pod_version| fix_pod pod_name, VERSION_REMOVE end end end |
#tinyAppExist? ⇒ Boolean
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/cocoapods-mPaaS/dsl.rb', line 56 def tinyAppExist? project_dir = Dir::pwd podfile_path = File.join(project_dir, "Podfile") mPaaSPodfile = MPaaSPodfile.new mPaaSPodfile.run(podfile_path) # puts("___________________#{mPaaSPodfile.mPaaSBaseline}\n_____#{mPaaSPodfile.mPaaSPodVersion}\n_____#{mPaaSPodfile.mPaaSVersionCode}\n_____#{mPaaSPodfile.mPaaSPodNames}\n_____") mPaaSPodfile.mPaaSPodNames.each do |name| if name == "mPaaS_TinyApp" || name == "mPaaS_TinyApp_without_BLE" return true end end return false end |
#use_mPaaS_online! ⇒ Object
35 36 37 |
# File 'lib/cocoapods-mPaaS/dsl.rb', line 35 def use_mPaaS_online! self.is_use_mPaaS_online = true end |
#use_pod_for_mPaaS! ⇒ Object
方法的嵌套 ? 最大程度的减少对原有逻辑的侵入性
361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 |
# File 'lib/cocoapods-mPaaS/dsl.rb', line 361 def use_pod_for_mPaaS! # self.is_pod_support_mPaaS = true def pod(name = nil, *requirements) current_verison = "" if requirements && !requirements.empty? current_verison = requirements[0] # baseline_hash = BaselineTools.getBaselineByVersion(requirements[0]) # dependencies_hash = baseline_hash[name] # if dependencies_hash # LogTools.v_green "pod (origin) : #{name} <> #{dependencies_hash}" # dependencies_hash.each do |pod_name, pod_version| # origin_pod(pod_name, pod_version) # end # else # #todo 测试走这里 # origin_pod(name, *requirements) # end else if self.default_baseline current_verison = self.default_baseline else # 这个地不能抛异常,原生pod其他第三方有可能会走到这 # info = "当前 #{name} : #{current_verison} 找不到版本 ! 请在 mPaaS_pod 后指定版本,或者使用全局默认标识 mPaaS_baseline" # raise Pod::Informative, info end # 如果未显式声明版本号,这里取下 default_baseline # baseline_hash = BaselineTools.getBaselineByVersion(self.default_baseline) # dependencies_hash = baseline_hash[name] # if dependencies_hash # LogTools.v_green "pod (origin) : #{name} <> #{dependencies_hash}" # dependencies_hash.each do |pod_name, pod_version| # origin_pod(pod_name, pod_version) # end # else # #todo 测试走这里 # origin_pod(name, *requirements) # end end baseline_hash = BaselineTools.getBaselineByVersion(current_verison, true) dependencies_hash = baseline_hash[name] if dependencies_hash LogTools.v_green "pod (origin) : #{name} <> #{dependencies_hash}\n" dependencies_hash.each do |pod_name, pod_version| if pod_name == "MPNebulaSDKPlugins" if self.is_use_tinyApp || tinyAppExist? LogTools.v_red "No need to pod MPNebulaSDKPlugins ..." next end end origin_pod(pod_name, pod_version) end else #todo 测试走这里 origin_pod(name, *requirements) # LogTools.p_red name end end end |
#use_tinyApp! ⇒ Object
31 32 33 |
# File 'lib/cocoapods-mPaaS/dsl.rb', line 31 def use_tinyApp! self.is_use_tinyApp = true end |