cocoapods-dev-env 2.0.2 → 2.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -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.0.2
4
+ version: 2.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - 吴锡苗
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-10-27 00:00:00.000000000 Z
11
+ date: 2022-04-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: luna-binary-uploader
@@ -68,11 +68,16 @@ files:
68
68
  - Rakefile
69
69
  - bin/console
70
70
  - bin/setup
71
+ - cocoapods-dev-env.code-workspace
71
72
  - cocoapods-dev-env.gemspec
72
73
  - lib/cocoapods/dev/env.rb
73
74
  - lib/cocoapods/dev/env/version.rb
74
75
  - lib/cocoapods_plugin.rb
76
+ - lib/dev_env_entry.rb
77
+ - lib/dev_env_utils.rb
75
78
  - lib/file_processer.rb
79
+ - lib/resolver_binary.rb
80
+ - lib/resolver_universal_dependency.rb
76
81
  homepage: https://github.com/YoudaoMobile/cocoapods-dev-env
77
82
  licenses:
78
83
  - MIT
@@ -95,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
95
100
  - !ruby/object:Gem::Version
96
101
  version: '0'
97
102
  requirements: []
98
- rubygems_version: 3.0.3
103
+ rubygems_version: 3.2.5
99
104
  signing_key:
100
105
  specification_version: 4
101
106
  summary: a cocoapod plugin for dev in mutipods