cocoapods-modularization 0.3.1 → 0.4.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: 7ce2a7c7df77a07a8425e0a83ea6000715fae66d1d9b299b763da0d92eda63bd
4
- data.tar.gz: 93502239994e546320afdabdfb44abbd68e6fe4a91a6476f5bcafd66ba0d5058
3
+ metadata.gz: 42d014222c41482f1b2df08d7311a46239f4568f2e909543b846b60727b334b6
4
+ data.tar.gz: 18c9f07033eab5f6fa81c44f850b97dc66cb5fa87489a8d9cb444e354e856f07
5
5
  SHA512:
6
- metadata.gz: '08ebed102dd8fa4df5fb3818aac2a0cfbe0928c3e5ea2c7f093caf13976faae26de124a3562d019f63e9d2d98992525bd77e545fe8827fae14d488293f3b59f2'
7
- data.tar.gz: 5c7d1ada31906d351b2e40f2ecc7ebb1c461d7c79bdda254f8415edef3357af9c2c755c3764337fb5340b3c1aa82682d900ef3998e1391a092749ec5b3bae587
6
+ metadata.gz: 1a2e5f5b3c43a60595a8e5343768a5d4ba08e72b619a66345d80cf3d0bd94f5e5147885454c254bf2a6b7467da81b673f1c71f312fa39180e3f8e83600fda851
7
+ data.tar.gz: 025aacca5b1f552e251ca79adc5549779b2aeaa4e8e5c7c5f9a740929da6b0a6b1671a03d2775cb7f199509d9cfc374e765a010c5f7462935ec5c3deca6ddf88
@@ -1,5 +1,6 @@
1
1
  require 'cocoapods-modularization/meta'
2
2
  require 'fileutils'
3
+ require 'yaml'
3
4
 
4
5
  module Pod
5
6
  class Command
@@ -38,7 +39,8 @@ module Pod
38
39
  ['--clean-install', 'Ignore the contents of the project cache and force a full pod installation. This only ' \
39
40
  'applies to projects that have enabled incremental installation'],
40
41
  ['--enable-branch', 'Enable branch dependency'],
41
- ['--original', 'Run pod install ignore cocoapods-modularization']
42
+ ['--original', 'Run pod install ignore cocoapods-modularization'],
43
+ ['--sync', 'Run pod install and sync all local dependencies according with branch_cache.yml']
42
44
  ].concat(super).reject { |(name, _)| name == '--no-repo-update' }
43
45
  end
44
46
 
@@ -48,6 +50,7 @@ module Pod
48
50
  @clean_install = argv.flag?('clean-install', false)
49
51
  @enable_branch = argv.flag?('enable-branch', false)
50
52
  @original = argv.flag?('original', false)
53
+ @sync = argv.flag?('sync', false)
51
54
  end
52
55
 
53
56
  def run
@@ -56,6 +59,10 @@ module Pod
56
59
  FileUtils.rm_rf('Podfile.lock')
57
60
  end
58
61
 
62
+ if @sync
63
+ sync_local_dependencies
64
+ end
65
+
59
66
  unless @original
60
67
  begin
61
68
  Meta::MetaReference.encode_podfile(@enable_branch)
@@ -86,7 +93,7 @@ module Pod
86
93
  def add_modularization_into_xcode_reference
87
94
  project = Xcodeproj::Project.open('Pods/Pods.xcodeproj')
88
95
 
89
- [Meta::MetaConstants.podfile_local_path, Meta::MetaConstants.meta_path, Meta::MetaConstants.data_path].each do |file|
96
+ [Meta::MetaConstants.podfile_local_path, Meta::MetaConstants.meta_path, Meta::MetaConstants.data_path, Meta::MetaConstants.branch_cache_path].each do |file|
90
97
  next unless File.exists?(file)
91
98
  project.new_file("#{Dir.pwd}/#{file}", :project).tap do |podfile_ref|
92
99
  podfile_ref.xc_language_specification_identifier = 'xcode.lang.yaml'
@@ -104,6 +111,39 @@ module Pod
104
111
  end
105
112
  end
106
113
 
114
+ def sync_local_dependencies
115
+ return unless File.exist?(Meta::MetaConstants.branch_cache_path)
116
+ branch_cache_hash = YAML.load_file(Meta::MetaConstants.branch_cache_path)
117
+ return unless branch_cache_hash.kind_of?(Hash)
118
+
119
+ podfile_hash = YAML.load_file(Meta::MetaConstants.podfile_local_path)
120
+ return unless podfile_hash.kind_of?(Hash)
121
+
122
+ branch_cache_hash.each do |key, value|
123
+ local_data_hash = podfile_hash[key]
124
+ next unless local_data_hash.kind_of?(Hash)
125
+ git = value[Meta::MetaConstants.git_key]
126
+ next unless git.kind_of?(String)
127
+ branch = value[Meta::MetaConstants.branch_key]
128
+ next unless branch.kind_of?(String)
129
+ local_path = local_data_hash[Meta::MetaConstants.local_path_key]
130
+ next unless local_path.kind_of?(String)
131
+
132
+ puts "Start checkout #{key}, git: #{git}, branch: #{branch}, local_path: #{local_path}"
133
+ `git -C #{local_path} checkout #{branch}`
134
+ end
135
+
136
+ podfile_hash.each do |key, value|
137
+ local_path = value[Meta::MetaConstants.local_path_key]
138
+ next unless local_path.kind_of?(String)
139
+
140
+ if branch_cache_hash.has_key?(key)
141
+ Meta::MetaAccessor.set_local_path(key, local_path)
142
+ else
143
+ Meta::MetaAccessor.remove_local_path(key)
144
+ end
145
+ end
146
+ end
107
147
  end
108
148
  end
109
149
  end
@@ -1,3 +1,3 @@
1
1
  module CocoapodsModularization
2
- VERSION = "0.3.1"
2
+ VERSION = "0.4.0"
3
3
  end
@@ -12,12 +12,12 @@ module Pod
12
12
  end
13
13
 
14
14
  def git
15
- git = `git -C #{@path} remote get-url origin`.lines.to_a.first
15
+ git = `git -C #{@path} remote get-url origin`
16
16
  git.strip if git
17
17
  end
18
18
 
19
19
  def branch
20
- branch = `git -C #{@path} rev-parse --abbrev-ref HEAD`.lines.to_a.first
20
+ branch = `git -C #{@path} rev-parse --abbrev-ref HEAD`
21
21
  branch.strip if branch
22
22
  end
23
23
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-modularization
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - lazy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-06-12 00:00:00.000000000 Z
11
+ date: 2023-08-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler