35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
# File 'lib/cocoapods-fix-react-native/fix_with_context.rb', line 35
def pre_fix_with_context(context)
locked_dependencies = Molinillo::DependencyGraph.new
if context.lockfile
context.lockfile.dependencies.each do |dependency|
locked_dependencies.add_vertex(dependency.name, dependency, true)
end
else
Pod::UI.warn 'No Podfile.lock present. Continuing without locked dependencies.'
end
sources = context.podfile.sources.map do |source|
Pod::Config.instance.sources_manager.source_with_name_or_url(source)
end
react_spec = nil
begin
resolver = Pod::Resolver.new(context.sandbox, context.podfile, locked_dependencies, sources, true)
target_definitions = resolver.resolve
target_definitions.each do |(definition, dependencies)|
next if definition.name == 'Pods'
react = dependencies.find { |d| d.spec.name == 'React' || d.spec.name.start_with?('React/') }
next if react.nil?
react_spec = react.spec
end
rescue StandardError => e
Pod::UI.warn 'Failed to resolve dependencies, so pre-patch was not applied, ' +
'please try running `pod install` again to apply the patch.'
end
return if react_spec.nil?
version = react_spec.version.to_s
return unless patch_exist?(version)
path_to_fix = version_file(version, 'pre')
if File.exist? path_to_fix
Pod::UI.section "Patching React Native #{version}" do
require(path_to_fix)
end
end
end
|