cocoapods-dev-env 2.1.8 → 2.2.3

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.
@@ -0,0 +1,116 @@
1
+ require 'cocoapods'
2
+
3
+ # 在这里处理二进制返回不指定源时系统不切换回原来的源的问题,效率相对比较高,不会反复进入
4
+ module Pod
5
+ class Lockfile
6
+ old_dependencies_to_lock_pod_named = instance_method(:dependencies_to_lock_pod_named)
7
+ define_method(:dependencies_to_lock_pod_named) do |name|
8
+ locked_pod_dependency = old_dependencies_to_lock_pod_named.bind(self).call(name)
9
+ repoUrl = spec_repo(name)
10
+ if (repoUrl != nil &&
11
+ repoUrl.downcase == 'git@gitlab.corp.youdao.com:luna-ios-framework/ios-framework-spec-repo.git')
12
+ locked_pod_dependency[0].external_source = repoUrl
13
+ end
14
+ locked_pod_dependency
15
+ end
16
+ end
17
+ end
18
+
19
+ module Pod
20
+ class Resolver
21
+ old_resolver_specs_by_target = instance_method(:resolver_specs_by_target)
22
+ define_method(:resolver_specs_by_target) do
23
+ specs_by_target = old_resolver_specs_by_target.bind(self).call
24
+
25
+ sources_manager = Config.instance.sources_manager
26
+ use_source_pods = podfile.use_source_pods
27
+
28
+ missing_binary_specs = []
29
+ specs_by_target.each do |target, rspecs|
30
+ # use_binaries 并且 use_source_pods 不包含 本地可过滤
31
+ use_binary_rspecs = ["SDWebImage"]
32
+
33
+ # # Parallel.map(rspecs, in_threads: 8) do |rspec|
34
+ # specs_by_target[target] = rspecs.map do |rspec|
35
+ # # 采用二进制依赖并且不为开发组件
36
+ # use_binary = use_binary_rspecs.include?(rspec)
37
+ # source = use_binary ? sources_manager.binary_source : sources_manager.code_source
38
+
39
+ # spec_version = rspec.spec.version
40
+ # UI.message 'cocoapods-imy-bin 插件'
41
+ # UI.message "- 开始处理 #{rspec.spec.name} #{spec_version} 组件."
42
+
43
+ # begin
44
+ # # 从新 source 中获取 spec,在bin archive中会异常,因为找不到
45
+ # specification = source.specification(rspec.root.name, spec_version)
46
+ # UI.message "#{rspec.root.name} #{spec_version} \r\n specification =#{specification} "
47
+ # # 组件是 subspec
48
+ # if rspec.spec.subspec?
49
+ # specification = specification.subspec_by_name(rspec.name, false, true)
50
+ # end
51
+ # # 这里可能出现分析依赖的 source 和切换后的 source 对应 specification 的 subspec 对应不上
52
+ # # 造成 subspec_by_name 返回 nil,这个是正常现象
53
+ # next unless specification
54
+
55
+ # used_by_only = if Pod.match_version?('~> 1.7')
56
+ # rspec.used_by_non_library_targets_only
57
+ # else
58
+ # rspec.used_by_tests_only
59
+ # end
60
+ # # used_by_only = rspec.respond_to?(:used_by_tests_only) ? rspec.used_by_tests_only : rspec.used_by_non_library_targets_only
61
+ # # 组装新的 rspec ,替换原 rspec
62
+ # if use_binary
63
+ # rspec = if Pod.match_version?('~> 1.4.0')
64
+ # ResolverSpecification.new(specification, used_by_only)
65
+ # else
66
+ # ResolverSpecification.new(specification, used_by_only, source)
67
+ # end
68
+ # UI.message "组装新的 rspec ,替换原 rspec #{rspec.root.name} #{spec_version} \r\n specification =#{specification} \r\n #{rspec} "
69
+
70
+ # end
71
+
72
+ # rescue Pod::StandardError => e
73
+ # # 没有从新的 source 找到对应版本组件,直接返回原 rspec
74
+
75
+ # # missing_binary_specs << rspec.spec if use_binary
76
+ # missing_binary_specs << rspec.spec
77
+ # rspec
78
+ # end
79
+
80
+ # rspec
81
+ # end.compact
82
+ end
83
+
84
+ # if missing_binary_specs.any?
85
+ # missing_binary_specs.uniq.each do |spec|
86
+ # UI.message "【#{spec.name} | #{spec.version}】组件无对应二进制版本 , 将采用源码依赖."
87
+ # end
88
+ # Pod::Command::Bin::Archive.missing_binary_specs(missing_binary_specs)
89
+
90
+ # #缓存没有二进制组件到spec文件,local_psec_dir 目录
91
+ # sources_sepc = []
92
+ # des_dir = CBin::Config::Builder.instance.local_psec_dir
93
+ # FileUtils.rm_f(des_dir) if File.exist?des_dir
94
+ # Dir.mkdir des_dir unless File.exist?des_dir
95
+ # missing_binary_specs.uniq.each do |spec|
96
+ # next if spec.name.include?('/')
97
+
98
+ # spec_git_res = false
99
+ # CBin::Config::Builder.instance.ignore_git_list.each do |ignore_git|
100
+ # spec_git_res = spec.source[:git] && spec.source[:git].include?(ignore_git)
101
+ # break if spec_git_res
102
+ # end
103
+ # next if spec_git_res
104
+
105
+ # #获取没有制作二进制版本的spec集合
106
+ # sources_sepc << spec
107
+ # unless spec.defined_in_file.nil?
108
+ # FileUtils.cp("#{spec.defined_in_file}", "#{des_dir}")
109
+ # end
110
+ # end
111
+ # end
112
+
113
+ specs_by_target
114
+ end
115
+ end
116
+ end
@@ -0,0 +1,127 @@
1
+ require 'cocoapods'
2
+ require 'dev_env_entry'
3
+
4
+ $parentPodlockDependencyHash = Hash.new
5
+ $processedParentPods = Hash.new # 从父项目里读出来的pod当次已经下载或者加载过了就不需要再做一遍
6
+
7
+ module Pod
8
+ # Dependency扩展,通过setRequirement接口暴露内部变量的set方法
9
+ class Dependency
10
+ def setRequirement(requirement)
11
+ @requirement = requirement
12
+ end
13
+ end
14
+ end
15
+
16
+ module Pod
17
+
18
+ # 在这个里将父Podfile的依赖信息同步到子库里
19
+ class Resolver
20
+
21
+ def search_for(dependency)
22
+ UI.message "fake search_for" + dependency.inspect
23
+ if $podFileContentPodNameHash.has_key?(dependency.root_name)
24
+ # 双重保证已经存在在pofile里的不再重复下载覆盖成父项目的配置
25
+ UI.message "parrent extenal source has downloaded"
26
+ else
27
+ parentPodInfo = $parentPodlockDependencyHash[dependency.root_name]
28
+ if parentPodInfo != nil
29
+ dependency.external_source = parentPodInfo.external_source
30
+ dependency.setRequirement(parentPodInfo.requirement)
31
+ #dependency.external_source = Hash[:path => '../../ZYSDK']
32
+ # dependency.external_source = Hash.new
33
+ UI.message "fake create_set_from_sources, changeexternal:" + dependency.inspect
34
+ dep = dependency
35
+ if !$processedParentPods.has_key?(dependency.root_name) && dependency.external_source != nil
36
+ $processedParentPods[dependency.root_name] = true
37
+ # 这里有缺陷: 已经下载过的不需要再下载了,但是不下载又进不到系统里,导致最后没有使用指定的依赖
38
+ # 这个没用 podfile.pod(dependency.root_name, dependency.external_source)
39
+ # if sandbox.specification_path(dep.root_name).nil? ||
40
+ # !dep.external_source[:path].nil? ||
41
+ # !sandbox.pod_dir(dep.root_name).directory? ||
42
+ # checkout_requires_update?(dep)
43
+ # # 已经存在就不再下载
44
+ source = ExternalSources.from_dependency(dependency, podfile.defined_in_file, true)
45
+ source.fetch(sandbox)
46
+ # end
47
+ end
48
+ end
49
+ end
50
+
51
+ @search[dependency] ||= begin
52
+ additional_requirements = if locked_requirement = requirement_for_locked_pod_named(dependency.name)
53
+ [locked_requirement]
54
+ else
55
+ Array(@podfile_requirements_by_root_name[dependency.root_name])
56
+ end
57
+
58
+ specifications_for_dependency(dependency, additional_requirements).freeze
59
+ end
60
+ end
61
+ end
62
+
63
+ class Podfile
64
+ # 第一次读取在结尾的位置,因为需要先定义函数才能调用
65
+ module DSL
66
+ # 在这里根据用户配置*重新*读取父Podfile里的信息
67
+ def use_parent_lock_info!(option = true)
68
+ case option
69
+ when true, false
70
+ if !option
71
+ $parrentPath = ''
72
+ Podfile.cleanParrentLockFile()
73
+ end
74
+ when Hash
75
+ $parrentPath = option.fetch(:path)
76
+ Podfile.readParrentLockFile()
77
+ else
78
+ raise ArgumentError, "Got `#{option.inspect}`, should be a boolean or hash."
79
+ end
80
+ end
81
+ end
82
+
83
+ def self.cleanParrentLockFile()
84
+ $parentPodlockDependencyHash = Hash.new
85
+ end
86
+
87
+ # 类方法
88
+ def self.readParrentLockFile()
89
+ # 获取路径(之后外边直接配置)
90
+ localPath = Pathname.new(Dir.pwd + "/" + $parrentPath)
91
+ lockPath ||= localPath + "Podfile.lock"
92
+ # 读取lockfile
93
+ _lockfile = Lockfile.from_file(lockPath)
94
+ if _lockfile == nil
95
+ UI.message "dev_env, 读取父库的lockfile找不到对应路径的lock文件:" + lockPath.inspect
96
+ return
97
+ end
98
+ # 读取lockfile中的依赖信息,用于之后提取使用,其中数据为 Pod::Dependency类型
99
+ localPodsMaps = Hash.new()
100
+ localpods = _lockfile.dependencies
101
+ localpods.each do |dep|
102
+ # 数据为 Pod::Dependency类型
103
+ if (dep.external_source == nil && dep.requirement == nil) || localPodsMaps.has_key?(dep.root_name)
104
+ next
105
+ end
106
+ if dep.external_source == nil && dep.requirement.to_s == '>= 0'
107
+ # dependence里可能没有版本信息(很奇怪,从version里单独取一下,写死版本限制)
108
+ version = _lockfile.version(dep.root_name)
109
+ dep.setRequirement(Requirement.new(version))
110
+ dep.podspec_repo = _lockfile.spec_repo(dep.root_name)
111
+ end
112
+ if dep.local?
113
+ dep.external_source[:path] = $parrentPath + dep.external_source[:path]
114
+ end
115
+ # 测试代码 UI.puts "测试获取父项目podlock里的pod依赖列表: " + dep.inspect
116
+ localPodsMaps[dep.root_name] = dep
117
+ end
118
+ $parentPodlockDependencyHash = localPodsMaps
119
+ # 读取 示例: ydASRInfo = localPodsMaps['YDASR']
120
+ # UI.puts ydASRInfo.inspect
121
+ # UI.puts "YDASR path:\n" + ydASRInfo.external_source[:path]
122
+ end
123
+
124
+ # 在这里根据默认路径读取父Podfile里的信息
125
+ Podfile.readParrentLockFile()
126
+ end
127
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-dev-env
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.8
4
+ version: 2.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - 吴锡苗
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-02-18 00:00:00.000000000 Z
11
+ date: 2022-07-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: luna-binary-uploader
@@ -73,7 +73,11 @@ files:
73
73
  - lib/cocoapods/dev/env.rb
74
74
  - lib/cocoapods/dev/env/version.rb
75
75
  - lib/cocoapods_plugin.rb
76
+ - lib/dev_env_entry.rb
77
+ - lib/dev_env_utils.rb
76
78
  - lib/file_processer.rb
79
+ - lib/resolver_binary.rb
80
+ - lib/resolver_universal_dependency.rb
77
81
  homepage: https://github.com/YoudaoMobile/cocoapods-dev-env
78
82
  licenses:
79
83
  - MIT