cocoapods-patch 0.0.7 → 0.0.8
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 +4 -4
- data/README.md +38 -0
- data/lib/{cocoapods-patch/gem_version.rb → cocoapods_patch.rb} +1 -1
- data/lib/cocoapods_plugin.rb +2 -2
- data/lib/pod/command.rb +3 -0
- data/lib/{cocoapods-patch → pod}/command/patch.rb +7 -0
- data/lib/{cocoapods-patch → pod}/command/patch/apply.rb +2 -2
- data/lib/{cocoapods-patch → pod}/command/patch/create.rb +28 -3
- data/lib/{cocoapods-patch → pod}/hook.rb +16 -0
- metadata +43 -15
- data/lib/cocoapods-patch.rb +0 -1
- data/lib/cocoapods-patch/command.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 765a982a7881db3b57c31e3bbe5e54ec56f5d990a4918c81f1ff7dbf6e7d9cf7
|
4
|
+
data.tar.gz: b9ec1d2c051c580b5f9c79f34e6905b8931a5ca3abcde268d61ff03fbdb6e938
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 32860c686e91f67ee8d4939bb1507c852b34284c626086a74375e3c51a38d6c31e4b06e4f07e401f73724105824b55e3b3cc59001fbac875843e5e904046d970
|
7
|
+
data.tar.gz: 8702ff7065ed62bdca2455c145a7519bc9317db9f86a05639b8c2f08ae5dd9901e6566bfe6ea0dfd6b5501fa25d7a910af085ce3270996545a02d2117f701cfc
|
data/README.md
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
|
2
|
+
# cocoapods-patch
|
3
|
+
|
4
|
+
cocoapods-patch is a Cocoapods plugin that solves the problem of forking and maintaining a separate version of a Pod when only a small (often a one-liner), long-lived change in the original Pod is needed.
|
5
|
+
|
6
|
+
The idea behind the plugin is that patches should live inside the repo (in the `patches` directory) and be distributed together with the rest of your source code. This way, you can more easily code review and test the changes to a Pod and keep it synced across your team.
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
First, install the plugin
|
11
|
+
|
12
|
+
$ gem install cocoapods-patch
|
13
|
+
|
14
|
+
Next, add a `plugin 'cocoapods-patch'` line to your Podfile to use the plugin. This will enable [automatic apply](#automatically-applying-all-patches-on-install) so you don't have to worry about it again.
|
15
|
+
|
16
|
+
That's it, you're done.
|
17
|
+
|
18
|
+
## Usage
|
19
|
+
|
20
|
+
### Creating a patch
|
21
|
+
|
22
|
+
To create a patch, first, you need to modify the source code of the installed Pod. Do the desired changes to the Pod source code (under the `Pods/` directory). Once you're satisfied with the result, run:
|
23
|
+
|
24
|
+
pod patch create POD_NAME
|
25
|
+
|
26
|
+
This will create a `patches/POD_NAME.diff` file in your repository. The patch is a diff between the Pod version you have specified in your Podfile and your local changes to the Pod. You can now add and commit this patch.
|
27
|
+
|
28
|
+
### Automatically applying all patches on install
|
29
|
+
|
30
|
+
cocoapod-patch can be seamlessly integrated into the normal iOS development workflow. If you follow the installation instructions and add `plugin 'cocoapods-patch'` to your Podfile, every time you do a `pod install`, the plugin will go throught all the available patches and try to apply them. It will only warn you when the patch cannot be applied.
|
31
|
+
|
32
|
+
### Applying a patch manually
|
33
|
+
|
34
|
+
When you want to apply a patch to a pod, run
|
35
|
+
|
36
|
+
pod patch apply POD_NAME
|
37
|
+
|
38
|
+
This command will look for the appropriate patch in the `patches` directory and, if possibly, apply it to your local Pod. A patch can be applied only once.
|
data/lib/cocoapods_plugin.rb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
require '
|
2
|
-
require '
|
1
|
+
require 'pod/command'
|
2
|
+
require 'pod/hook'
|
data/lib/pod/command.rb
ADDED
@@ -1,3 +1,6 @@
|
|
1
|
+
require_relative 'patch/apply'
|
2
|
+
require_relative 'patch/create'
|
3
|
+
|
1
4
|
module Pod
|
2
5
|
class Command
|
3
6
|
class Patch < Command
|
@@ -7,6 +10,10 @@ module Pod
|
|
7
10
|
def patch_file
|
8
11
|
config.project_root + 'patches' + "#{@name}.diff"
|
9
12
|
end
|
13
|
+
|
14
|
+
def patches_path
|
15
|
+
config.project_root + 'patches'
|
16
|
+
end
|
10
17
|
end
|
11
18
|
end
|
12
19
|
end
|
@@ -44,9 +44,9 @@ def apply_patch(patch_file)
|
|
44
44
|
apply_cmd = check_cmd.gsub('--check ', '')
|
45
45
|
did_apply = system(apply_cmd)
|
46
46
|
if did_apply
|
47
|
-
Pod::UI.puts "Successfully applied #{patch_file}"
|
47
|
+
Pod::UI.puts "Successfully applied #{patch_file} 🎉"
|
48
48
|
else
|
49
|
-
Pod::UI.warn "
|
49
|
+
Pod::UI.warn "Error: failed to apply #{patch_file}"
|
50
50
|
end
|
51
51
|
end
|
52
52
|
}
|
@@ -24,8 +24,16 @@ module Pod
|
|
24
24
|
help! 'A Pod name is required.' unless @name
|
25
25
|
end
|
26
26
|
|
27
|
+
def clear_patches_folder_if_empty
|
28
|
+
if Dir.empty?(patches_path)
|
29
|
+
FileUtils.remove_dir(patches_path)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
27
33
|
def run
|
28
|
-
|
34
|
+
# create patches folder if it doesn't exist
|
35
|
+
FileUtils.mkdir_p(patches_path)
|
36
|
+
|
29
37
|
Dir.mktmpdir('cocoapods-patch-', config.project_root) do |work_dir|
|
30
38
|
sandbox = Pod::Sandbox.new(work_dir)
|
31
39
|
installer = Pod::Installer.new(sandbox, config.podfile)
|
@@ -34,18 +42,35 @@ module Pod
|
|
34
42
|
installer.prepare
|
35
43
|
installer.resolve_dependencies
|
36
44
|
|
45
|
+
UI.puts "Checking if pod exists in project..."
|
46
|
+
specs_by_platform = installer.send :specs_for_pod, @name
|
47
|
+
|
48
|
+
if specs_by_platform.empty?
|
49
|
+
clear_patches_folder_if_empty
|
50
|
+
help! "Given pod does not exist in project. Did you use incorrect pod name?"
|
51
|
+
|
52
|
+
return
|
53
|
+
end
|
54
|
+
|
37
55
|
pod_installer = installer.send :create_pod_installer, @name
|
38
56
|
pod_installer.install!
|
39
57
|
|
58
|
+
UI.puts "Creating patch"
|
40
59
|
theirs = Pathname.new(work_dir).join(@name).relative_path_from(config.project_root)
|
41
60
|
ours = config.project_pods_root.join(@name).relative_path_from(config.project_root)
|
42
61
|
gen_diff_cmd = "git diff --no-index #{theirs} #{ours} > #{patch_file}"
|
43
62
|
|
44
63
|
did_succeed = system(gen_diff_cmd)
|
45
64
|
if not did_succeed.nil?
|
46
|
-
|
65
|
+
if File.empty?(patch_file)
|
66
|
+
File.delete(patch_file)
|
67
|
+
clear_patches_folder_if_empty
|
68
|
+
UI.warn "Error: no changes detected between current pod and original"
|
69
|
+
else
|
70
|
+
UI.puts "Created patch #{patch_file} 🎉"
|
71
|
+
end
|
47
72
|
else
|
48
|
-
UI.warn "Error
|
73
|
+
UI.warn "Error: failed to create patch for #{@name}"
|
49
74
|
end
|
50
75
|
end
|
51
76
|
end
|
@@ -2,6 +2,22 @@ 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', :pre_install) do |context|
|
8
|
+
Pod::UI.puts 'Preparing patchable pods for clean patching'
|
9
|
+
patches_dir = Pathname.new(Dir.pwd) + 'patches'
|
10
|
+
if patches_dir.directory?
|
11
|
+
patches = patches_dir.each_child.select { |c| c.to_s.end_with?('.diff') }
|
12
|
+
patches.each do |p|
|
13
|
+
pod_name = File.basename(p, ".diff")
|
14
|
+
context.sandbox.clean_pod(pod_name)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
5
21
|
class Pod::Installer
|
6
22
|
# Because our patches may also delete files, we need to apply them before the pod project is generated
|
7
23
|
# The project is generated in the `integrate` method, so we override it
|
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.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Double Symmetry
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-03-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,28 +16,56 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '2.0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '2.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '13.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '13.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
32
46
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
47
|
+
version: '3.9'
|
34
48
|
type: :development
|
35
49
|
prerelease: false
|
36
50
|
version_requirements: !ruby/object:Gem::Requirement
|
37
51
|
requirements:
|
38
|
-
- - "
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.9'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: cocoapods
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
39
67
|
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
68
|
+
version: '1.0'
|
41
69
|
description: Create & apply patches to Pods
|
42
70
|
email:
|
43
71
|
- dev@doublesymmetry.com
|
@@ -45,14 +73,14 @@ executables: []
|
|
45
73
|
extensions: []
|
46
74
|
extra_rdoc_files: []
|
47
75
|
files:
|
48
|
-
-
|
49
|
-
- lib/
|
50
|
-
- lib/cocoapods-patch/command/patch.rb
|
51
|
-
- lib/cocoapods-patch/command/patch/apply.rb
|
52
|
-
- lib/cocoapods-patch/command/patch/create.rb
|
53
|
-
- lib/cocoapods-patch/gem_version.rb
|
54
|
-
- lib/cocoapods-patch/hook.rb
|
76
|
+
- README.md
|
77
|
+
- lib/cocoapods_patch.rb
|
55
78
|
- lib/cocoapods_plugin.rb
|
79
|
+
- lib/pod/command.rb
|
80
|
+
- lib/pod/command/patch.rb
|
81
|
+
- lib/pod/command/patch/apply.rb
|
82
|
+
- lib/pod/command/patch/create.rb
|
83
|
+
- lib/pod/hook.rb
|
56
84
|
homepage: https://github.com/DoubleSymmetry/cocoapods-patch
|
57
85
|
licenses:
|
58
86
|
- MIT
|
data/lib/cocoapods-patch.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
require 'cocoapods-patch/gem_version'
|