cocoapods-amicable 0.1.2 → 0.2.0

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: 6e660036bec0a4fa8dbff088a4040f46a08f7aee2b0f42ac70280f9599e4f8f9
4
- data.tar.gz: 647c6738de1bdad2fe6eff05402673c7f20e81ecaf0e5833c46109ad3dbcc18d
3
+ metadata.gz: 7206583281f3373c1c53205ea9294ba0528b20b7f12c749ed1b5847e7540f657
4
+ data.tar.gz: 88025c9a7c09a7d07b70d10751486773436c8bdec654ea9b73069e0f9d4cddaa
5
5
  SHA512:
6
- metadata.gz: 5ae8d92127d8e141627149aafea415399525bcb8d052deac8c375f7515f7cec3dc9f8fc19d112ea5e65b71e6d6e30ab572482ab85a4ac65da6a8e6bce38b3f97
7
- data.tar.gz: 806ffe80b279f8476c217afde01bf2f824dcf3a6cec5fc70befeac5c2ad06b4add967f8827e7a63099579452ba740652c5d10890d4815b18db7f36c7ca3560d5
6
+ metadata.gz: 2f3ec86cea08e8eb518d178389a0420bdba5e927a2fa97afbc4655deb97f5c59f64c226533fc3196741866c6c6e8a5d2cece7788990c411ed9fe3ae0c326d18e
7
+ data.tar.gz: dc9a85f45341ce0d9f08634993179c27ef40b1e6aba0e22615fa68de89a03ff562108008d4556d62177a683af6a0573feb31f1798ffa313edf3da052e1594387
@@ -1,81 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
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
4
+ module TargetIntegratorMixin
5
+ def add_check_manifest_lock_script_phase
6
+ podfile = target.target_definition.podfile
7
+ return super unless podfile.plugins.key?('cocoapods-amicable')
61
8
 
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
9
+ phase_name = Pod::Installer::UserProjectIntegrator::TargetIntegrator::CHECK_MANIFEST_PHASE_NAME
10
+ native_targets.each do |native_target|
11
+ phase = Pod::Installer::UserProjectIntegrator::TargetIntegrator.create_or_update_build_phase(native_target, Pod::Installer::UserProjectIntegrator::TargetIntegrator::BUILD_PHASE_PREFIX + phase_name)
12
+ native_target.build_phases.unshift(phase).uniq! unless native_target.build_phases.first == phase
76
13
 
77
- def update_check_manifest_script_phase(build_phase)
78
- build_phase.shell_script = <<-SH
14
+ phase.shell_script = <<-SH
79
15
  set -e
80
16
  set -u
81
17
  set -o pipefail
@@ -94,16 +30,58 @@ fi
94
30
 
95
31
  # This output is used by Xcode 'outputs' to avoid re-running this script phase.
96
32
  echo "SUCCESS" > "${SCRIPT_OUTPUT_FILE_0}"
97
- SH
33
+ SH
34
+
35
+ phase.input_paths = %w[
36
+ ${PODS_PODFILE_DIR_PATH}/Podfile.lock
37
+ ${PODS_ROOT}/Manifest.lock
38
+ ${PODS_ROOT}/Podfile.sha1
39
+ ]
40
+ if name = podfile.defined_in_file && podfile.defined_in_file.basename
41
+ phase.input_paths << "${PODS_PODFILE_DIR_PATH}/#{name}"
42
+ end
43
+ phase.output_paths = [target.check_manifest_lock_script_output_file_path]
44
+ end
45
+ end
46
+ end
47
+
48
+ module InstallerMixin
49
+ def write_lockfiles
50
+ super
51
+ return unless podfile.plugins.key?('cocoapods-amicable')
52
+ return unless checksum = podfile.checksum
53
+ return unless podfile_path = podfile.defined_in_file
54
+ checksum_path = sandbox.root + 'Podfile.sha1'
98
55
 
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}"
56
+ Pod::UI.message "- Writing Podfile checksum in #{Pod::UI.path checksum_path}" do
57
+ checksum_path.open('w') { |f| f << checksum << ' ' << podfile_path.basename.to_s << "\n" }
106
58
  end
107
59
  end
108
60
  end
61
+
62
+ module LockfileMixin
63
+ def generate(podfile, *)
64
+ lockfile = super
65
+ lockfile.internal_data.delete('PODFILE CHECKSUM') if podfile.plugins.key?('cocoapods-amicable')
66
+ lockfile
67
+ end
68
+ end
69
+ end
70
+
71
+ module Pod
72
+ class Installer
73
+ prepend ::CocoaPodsAmicable::InstallerMixin
74
+
75
+ class UserProjectIntegrator
76
+ class TargetIntegrator
77
+ prepend ::CocoaPodsAmicable::TargetIntegratorMixin
78
+ end
79
+ end
80
+ end
81
+
82
+ class Lockfile
83
+ class << self
84
+ prepend ::CocoaPodsAmicable::LockfileMixin
85
+ end
86
+ end
109
87
  end
@@ -1,7 +1,3 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'cocoapods_amicable'
4
-
5
- Pod::HooksManager.register 'cocoapods-amicable', :post_install do |post_install_context|
6
- CocoaPodsAmicable::PodfileChecksumFixer.new(post_install_context).fix!
7
- end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-amicable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Giddins
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-16 00:00:00.000000000 Z
11
+ date: 2018-04-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -67,7 +67,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
67
67
  version: '0'
68
68
  requirements: []
69
69
  rubyforge_project:
70
- rubygems_version: 2.7.4
70
+ rubygems_version: 2.7.3
71
71
  signing_key:
72
72
  specification_version: 4
73
73
  summary: A CocoaPods plugin that moves the Podfile checksum to a file in the Sandbox,