cocoapods-patch 0.0.2 → 0.0.7

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b39b7df9e697a31cdcee1ce05641aecbce2536510730edbf4ebd309b83d90bef
4
- data.tar.gz: 45a5256704d13fee7002291fd3dec27d7d46005613786d30be017f05fdcf2ea2
3
+ metadata.gz: 2626728359e198af7ecc119c2bc846520c233f725cea13857a12a936bfacb527
4
+ data.tar.gz: ef94a39a36598ce2274b099f34af86953a21086d52b135dff893f6e21cf5aebf
5
5
  SHA512:
6
- metadata.gz: 3fdb4edae64ad26734cbd980cdb7502a4a3ea4ad956f2c7a4b2ceb604abdf00264b8e7ca5e3ff675ce998b707be504008cfce7e946c9148993255c119fd9ee0c
7
- data.tar.gz: e23fc9606eb1d50a8e1ef0397da6947afd3af47929543f9b1226de9700c6bc1404d84c2eac27b2a2f5294b83b124d7f0663764edb68e55092df5280bc69ed440
6
+ metadata.gz: 230e132b95a6bcadeb9e442fa5576ec5b57c36cefc543fae0feed769569fbadf4ac0e0f8e7799939e938a3bdede73d15517e150a3e6daf042471d2321fc9584b
7
+ data.tar.gz: d335a0613d53c0931caacd4e2938e8083d7b32cdbb843dd406b91e5714a77e8b678537577fa8d05cef2d2f2a4accfc39a80f210db17f074f3d22012d82e4b5a8
@@ -30,15 +30,24 @@ end
30
30
 
31
31
  # also used from the post-install hook
32
32
  def apply_patch(patch_file)
33
- check_cmd = "git apply --check #{patch_file} --directory=Pods -p2 2> /dev/null"
34
- can_apply = system(check_cmd)
35
- if can_apply
36
- apply_cmd = check_cmd.gsub('--check ', '')
37
- did_apply = system(apply_cmd)
38
- if did_apply
39
- Pod::UI.puts "Successfully applied #{patch_file}"
40
- else
41
- Pod::UI.warn "Failed to apply #{patch_file}"
33
+ working_dir = Dir.pwd
34
+ repo_root = `git rev-parse --show-toplevel`.strip
35
+ ios_project_path = Pathname.new(working_dir).relative_path_from(Pathname.new(repo_root))
36
+
37
+ directory_arg = (ios_project_path.to_s.eql? ".") ? "Pods" : File.join(ios_project_path, 'Pods')
38
+
39
+ Dir.chdir(repo_root) {
40
+ check_cmd = "git apply --check #{patch_file} --directory=#{directory_arg} -p2 2> /dev/null"
41
+
42
+ can_apply = system(check_cmd)
43
+ if can_apply
44
+ apply_cmd = check_cmd.gsub('--check ', '')
45
+ did_apply = system(apply_cmd)
46
+ if did_apply
47
+ Pod::UI.puts "Successfully applied #{patch_file}"
48
+ else
49
+ Pod::UI.warn "Failed to apply #{patch_file}"
50
+ end
42
51
  end
43
- end
52
+ }
44
53
  end
@@ -25,6 +25,7 @@ module Pod
25
25
  end
26
26
 
27
27
  def run
28
+ FileUtils.mkdir_p('patches')
28
29
  Dir.mktmpdir('cocoapods-patch-', config.project_root) do |work_dir|
29
30
  sandbox = Pod::Sandbox.new(work_dir)
30
31
  installer = Pod::Installer.new(sandbox, config.podfile)
@@ -1,3 +1,3 @@
1
1
  module CocoapodsPatch
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.7"
3
3
  end
@@ -2,11 +2,24 @@ require 'cocoapods'
2
2
  require 'pathname'
3
3
  require_relative 'command/patch/apply'
4
4
 
5
- module CocoapodsPatch
6
- module Hooks
7
- Pod::HooksManager.register('cocoapods-patch', :post_install) do |context|
8
- Pod::UI.puts 'Applying patches if necessary'
9
- patches_dir = Pathname.new(context.sandbox_root) + '..' + 'patches'
5
+ class Pod::Installer
6
+ # Because our patches may also delete files, we need to apply them before the pod project is generated
7
+ # The project is generated in the `integrate` method, so we override it
8
+ # We first run our patch action and then the original implementation of the method
9
+ # Reference: https://github.com/CocoaPods/CocoaPods/blob/760828a07f8fcfbff03bce13f56a1789b6f5a95d/lib/cocoapods/installer.rb#L178
10
+ alias_method :integrate_old, :integrate
11
+
12
+ def integrate
13
+ # apply our patches
14
+ apply_patches
15
+ # run the original implementation
16
+ integrate_old
17
+ end
18
+
19
+ def apply_patches
20
+ Pod::UI.puts 'Applying patches if necessary'
21
+ patches_dir = Pathname.new(Dir.pwd) + 'patches'
22
+ if patches_dir.directory?
10
23
  patches = patches_dir.each_child.select { |c| c.to_s.end_with?('.diff') }
11
24
  patches.each { |p| apply_patch(p) }
12
25
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-patch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Double Symmetry
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-29 00:00:00.000000000 Z
11
+ date: 2021-01-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler