cocoapods-amicable 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/cocoapods_amicable.rb +109 -0
- data/lib/cocoapods_plugin.rb +7 -0
- metadata +75 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: cf1fafa880240e0edcb2ef1da4205bbc1608bcf8262db9a6b6fa6e9b563fb025
|
4
|
+
data.tar.gz: d6b2910671ecd58e3969997024d958efae2824757f6b28df6b1b690df9d7ec99
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 634ec21252d8f2d3e8b960f1561e684d62cb6636e3bb0685764608541ff03c77ae2a86e419ddabf1547b990e7226a6c4fa79ee92dbedd8c358aff1bb699c1bf7
|
7
|
+
data.tar.gz: c991e87bf3199494b9278f4ec0b36414b5bf0807a40322fb156e0ef6427a8e179fb4848a6fa277552a93a934cd01d0b6eefe08726a068a572217abdabca8237d
|
@@ -0,0 +1,109 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CocoaPodsAmicable
|
4
|
+
class PodfileChecksumFixer
|
5
|
+
def initialize(post_install_context)
|
6
|
+
@post_install_context = post_install_context
|
7
|
+
end
|
8
|
+
|
9
|
+
def fix!
|
10
|
+
Pod::UI.titled_section 'Moving the Podfile checksum from the lockfile' do
|
11
|
+
@checksum = remove_checksum_from_lockfiles
|
12
|
+
write_sha1_file
|
13
|
+
update_check_manifest_script_phases
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
attr_reader :checksum
|
20
|
+
|
21
|
+
def sandbox
|
22
|
+
@post_install_context.sandbox
|
23
|
+
end
|
24
|
+
|
25
|
+
def lockfiles
|
26
|
+
[Pod::Config.instance.lockfile_path, sandbox.manifest_path].map do |lockfile_path|
|
27
|
+
Pod::Lockfile.from_file(lockfile_path)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def remove_checksum_from_lockfiles
|
32
|
+
checksums = lockfiles.map do |lockfile|
|
33
|
+
checksum = lockfile.internal_data.delete('PODFILE CHECKSUM')
|
34
|
+
lockfile.write_to_disk(lockfile.defined_in_file)
|
35
|
+
checksum
|
36
|
+
end.uniq
|
37
|
+
case checksums.size
|
38
|
+
when 1
|
39
|
+
checksums.first
|
40
|
+
else
|
41
|
+
raise 'Multiple (different) podfiles checksums found'
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def sha1_file_path
|
46
|
+
sandbox.root + 'Podfile.sha1'
|
47
|
+
end
|
48
|
+
|
49
|
+
def podfile_basename
|
50
|
+
File.basename(Pod::Config.instance.podfile.defined_in_file)
|
51
|
+
end
|
52
|
+
|
53
|
+
def write_sha1_file
|
54
|
+
return unless name = podfile_basename
|
55
|
+
sha1_file_path.open('w') do |f|
|
56
|
+
f.write <<~EOS
|
57
|
+
#{checksum} #{name}
|
58
|
+
EOS
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def update_check_manifest_script_phases
|
63
|
+
user_projects = []
|
64
|
+
@post_install_context.umbrella_targets.each do |umbrella_target|
|
65
|
+
user_projects << umbrella_target.user_project
|
66
|
+
umbrella_target.user_targets.each do |user_target|
|
67
|
+
build_phase = user_target.build_phases.find do |bp|
|
68
|
+
bp.name.end_with? Pod::Installer::UserProjectIntegrator::TargetIntegrator::CHECK_MANIFEST_PHASE_NAME
|
69
|
+
end
|
70
|
+
update_check_manifest_script_phase(build_phase)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
user_projects.uniq.each(&:save)
|
75
|
+
end
|
76
|
+
|
77
|
+
def update_check_manifest_script_phase(build_phase)
|
78
|
+
build_phase.shell_script = <<~SH
|
79
|
+
set -e
|
80
|
+
set -u
|
81
|
+
set -o pipefail
|
82
|
+
|
83
|
+
fail() {
|
84
|
+
# print error to STDERR
|
85
|
+
echo "error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation." $@ >&2
|
86
|
+
exit 1
|
87
|
+
}
|
88
|
+
|
89
|
+
diff -q "${PODS_PODFILE_DIR_PATH}/Podfile.lock" "${PODS_ROOT}/Manifest.lock" > /dev/null || fail "The manifest in the sandbox differs from your lockfile."
|
90
|
+
|
91
|
+
if [ -f "${PODS_ROOT}/Podfile.sha1" ]; then
|
92
|
+
(cd "${PODS_PODFILE_DIR_PATH}" && shasum --algorithm 1 --status --check "${PODS_ROOT}/Podfile.sha1") || fail "Your Podfile has been changed since the last time you ran 'pod install'."
|
93
|
+
fi
|
94
|
+
|
95
|
+
# This output is used by Xcode 'outputs' to avoid re-running this script phase.
|
96
|
+
echo "SUCCESS" > "${SCRIPT_OUTPUT_FILE_0}"
|
97
|
+
SH
|
98
|
+
|
99
|
+
build_phase.input_paths = %w[
|
100
|
+
${PODS_PODFILE_DIR_PATH}/Podfile.lock
|
101
|
+
${PODS_ROOT}/Manifest.lock
|
102
|
+
${PODS_ROOT}/Podfile.sha1
|
103
|
+
]
|
104
|
+
if name = podfile_basename
|
105
|
+
build_phase.input_paths << "${PODS_PODFILE_DIR_PATH}/#{name}"
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
metadata
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cocoapods-amicable
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Samuel Giddins
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-02-14 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.16'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.16'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '12.3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '12.3'
|
41
|
+
description:
|
42
|
+
email:
|
43
|
+
- segiddins@segiddins.me
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- lib/cocoapods_amicable.rb
|
49
|
+
- lib/cocoapods_plugin.rb
|
50
|
+
homepage: https://github.com/segiddins/cocoapods-amicable
|
51
|
+
licenses:
|
52
|
+
- MIT
|
53
|
+
metadata: {}
|
54
|
+
post_install_message:
|
55
|
+
rdoc_options: []
|
56
|
+
require_paths:
|
57
|
+
- lib
|
58
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
requirements: []
|
69
|
+
rubyforge_project:
|
70
|
+
rubygems_version: 2.7.4
|
71
|
+
signing_key:
|
72
|
+
specification_version: 4
|
73
|
+
summary: A CocoaPods plugin that moves the Podfile checksum to a file in the Sandbox,
|
74
|
+
reducing merge conflicts for teams that don't commit their Pods directory.
|
75
|
+
test_files: []
|