cocoapods-patch 0.0.1 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1906c058ad8d231b40db3b069f987234f90d5e8fff70f61196ed785f18787c46
4
- data.tar.gz: 1a59dd3429f39519559aa6d7807c3cc94db9178551e492422844bd86a7ebdaea
3
+ metadata.gz: 5f1fc48aa0350d562d1ad476ab439624105cee81c22bab3b604a73131e1dd6eb
4
+ data.tar.gz: b03c8bf4611c20f40536936fa02c2b43f833588b63038d083fe834be9a368a0c
5
5
  SHA512:
6
- metadata.gz: 1b20fefdce67bafc583858bce2a4f5fa8f6f8996b587ac27b359917422f5d7d8edb2cec2af0a5c16735777015a37c23380af3c78f4017e89ce2943d94f4c91ef
7
- data.tar.gz: d578b7a256154fe8f0cafea6f4c9eb7845a8d8a98868f43e15448e025acb4b3836d5f3d47d94a3933d16bdf405601ed89b203fa7b81f514527b6789310c6bfad
6
+ metadata.gz: c96592ef2a7c17cbc4916afc582a0af9219bf2ecf351dbc6f21ab10a6660cb4de8e5a8fcd69c3cada1d5d69c6c29c53e654143f426193e23a0e4bf757acb4d78
7
+ data.tar.gz: c7c7d93705236d902f9ddd02d4102ae800c9280bc1f8549d31b600a7fc4a1c5b6616b2029a0e2468fa58678fabc3dc5d5a9d09ddcba34f83ad414251a7added1
@@ -1,3 +1,5 @@
1
+ require 'cocoapods'
2
+
1
3
  module Pod
2
4
  class Command
3
5
  class Patch < Command
@@ -28,15 +30,25 @@ end
28
30
 
29
31
  # also used from the post-install hook
30
32
  def apply_patch(patch_file)
31
- check_cmd = "git apply --check #{patch_file} --directory=Pods -p2 2> /dev/null"
32
- can_apply = system(check_cmd)
33
- if can_apply
34
- apply_cmd = check_cmd.gsub('--check ', '')
35
- did_apply = system(apply_cmd)
36
- if did_apply
37
- UI.puts "Successfully applied #{patch_file}"
38
- else
39
- 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
+ Pod::UI.puts "YOOOOO #{patch_file} - #{directory_arg}"
41
+ check_cmd = "git apply --check #{patch_file} --directory=#{directory_arg} -p2 2> /dev/null"
42
+
43
+ can_apply = system(check_cmd)
44
+ if can_apply
45
+ apply_cmd = check_cmd.gsub('--check ', '')
46
+ did_apply = system(apply_cmd)
47
+ if did_apply
48
+ Pod::UI.puts "Successfully applied #{patch_file}"
49
+ else
50
+ Pod::UI.warn "Failed to apply #{patch_file}"
51
+ end
40
52
  end
41
- end
53
+ }
42
54
  end
@@ -1,4 +1,3 @@
1
1
  module CocoapodsPatch
2
- VERSION = "0.0.1"
3
- NAME = 'cocoapods-patch'
2
+ VERSION = "0.0.6"
4
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.1
4
+ version: 0.0.6
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-25 00:00:00.000000000 Z
11
+ date: 2021-01-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler