cocoapods-modularization 0.0.2
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 +7 -0
- data/lib/cocoapods-modularization/command/install.rb +98 -0
- data/lib/cocoapods-modularization/command/mod/add.rb +97 -0
- data/lib/cocoapods-modularization/command/mod/base.rb +35 -0
- data/lib/cocoapods-modularization/command/mod/binary.rb +82 -0
- data/lib/cocoapods-modularization/command/mod/config.rb +51 -0
- data/lib/cocoapods-modularization/command/mod/create.rb +34 -0
- data/lib/cocoapods-modularization/command/mod/inspect.rb +26 -0
- data/lib/cocoapods-modularization/command/mod/source.rb +81 -0
- data/lib/cocoapods-modularization/command/mod/sync.rb +29 -0
- data/lib/cocoapods-modularization/command/mod/update.rb +64 -0
- data/lib/cocoapods-modularization/command/mod.rb +28 -0
- data/lib/cocoapods-modularization/command.rb +2 -0
- data/lib/cocoapods-modularization/gem_version.rb +3 -0
- data/lib/cocoapods-modularization/generate/configuration.rb +364 -0
- data/lib/cocoapods-modularization/generate/installer.rb +388 -0
- data/lib/cocoapods-modularization/generate/podfile_generator.rb +398 -0
- data/lib/cocoapods-modularization/generate.rb +7 -0
- data/lib/cocoapods-modularization/meta/meta_accessor.rb +134 -0
- data/lib/cocoapods-modularization/meta/meta_constants.rb +135 -0
- data/lib/cocoapods-modularization/meta/meta_reference.rb +255 -0
- data/lib/cocoapods-modularization/meta.rb +7 -0
- data/lib/cocoapods-modularization/private/private_cache.rb +277 -0
- data/lib/cocoapods-modularization/private.rb +5 -0
- data/lib/cocoapods-modularization.rb +1 -0
- data/lib/cocoapods_plugin.rb +1 -0
- metadata +96 -0
@@ -0,0 +1,255 @@
|
|
1
|
+
module Pod
|
2
|
+
module Meta
|
3
|
+
module MetaReference
|
4
|
+
class << self
|
5
|
+
require 'cocoapods-modularization/private'
|
6
|
+
require 'json'
|
7
|
+
require 'fileutils'
|
8
|
+
require 'yaml'
|
9
|
+
|
10
|
+
# podfile => meta & data
|
11
|
+
def decode_podfile(config)
|
12
|
+
# check podfile
|
13
|
+
podfile = Podfile.from_file(podfile_path_in_dir(installation_root))
|
14
|
+
|
15
|
+
unless File.directory?(MetaConstants.pods_scripts_path)
|
16
|
+
FileUtils.mkdir_p(MetaConstants.pods_scripts_path)
|
17
|
+
end
|
18
|
+
|
19
|
+
unless File.directory?(MetaConstants.pods_generator_path)
|
20
|
+
FileUtils.mkdir_p(MetaConstants.pods_generator_path)
|
21
|
+
end
|
22
|
+
|
23
|
+
UI.puts "podfile to meta"
|
24
|
+
podfile_to_meta(podfile)
|
25
|
+
|
26
|
+
UI.puts "podfile to data"
|
27
|
+
podfile_to_data(podfile, config)
|
28
|
+
end
|
29
|
+
|
30
|
+
# podfile <= meta & data
|
31
|
+
def encode_podfile(enable_branch = false)
|
32
|
+
meta = MetaConstants.generate_yml_to_hash(MetaConstants.meta_path)
|
33
|
+
data = MetaConstants.read_data(enable_branch)
|
34
|
+
|
35
|
+
target_definitions = meta['target_definitions']
|
36
|
+
cached_branch_hash = enable_branch ? Private::PrivateCache.cached_branch_hash : nil
|
37
|
+
target_definitions.each do |target_definition|
|
38
|
+
next unless target_definition.kind_of?(Hash)
|
39
|
+
meta_dependency_from_data(target_definition, data, enable_branch)
|
40
|
+
end
|
41
|
+
|
42
|
+
File::open('CocoaPods.podfile.yaml', "w") { |io| io.puts meta.to_yaml }
|
43
|
+
end
|
44
|
+
|
45
|
+
def installation_root
|
46
|
+
@installation_root ||= begin
|
47
|
+
current_dir = Pathname.new(Dir.pwd.unicode_normalize(:nfkc))
|
48
|
+
current_path = current_dir
|
49
|
+
until current_path.root?
|
50
|
+
if podfile_path_in_dir(current_path)
|
51
|
+
installation_root = current_path
|
52
|
+
unless current_path == current_dir
|
53
|
+
UI.puts("[in #{current_path}]")
|
54
|
+
end
|
55
|
+
break
|
56
|
+
else
|
57
|
+
current_path = current_path.parent
|
58
|
+
end
|
59
|
+
end
|
60
|
+
installation_root || current_dir
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def podfile_path_in_dir(dir)
|
65
|
+
PODFILE_NAMES.each do |filename|
|
66
|
+
candidate = dir + filename
|
67
|
+
if candidate.file?
|
68
|
+
return candidate
|
69
|
+
end
|
70
|
+
end
|
71
|
+
nil
|
72
|
+
end
|
73
|
+
|
74
|
+
PODFILE_NAMES = [
|
75
|
+
'CocoaPods.podfile.yaml',
|
76
|
+
'CocoaPods.podfile',
|
77
|
+
'Podfile',
|
78
|
+
'Podfile.rb',
|
79
|
+
].freeze
|
80
|
+
|
81
|
+
private
|
82
|
+
def meta_dependency_from_data(meta, data, enable_branch)
|
83
|
+
dependencies = meta['dependencies'] if data.kind_of?(Hash)
|
84
|
+
meta['dependencies'] = dependencies.map { |e| hash_from(e, data, enable_branch) } if dependencies.kind_of?(Array)
|
85
|
+
childrens = meta['children']
|
86
|
+
childrens.each { |c| meta_dependency_from_data(c, data, enable_branch) } if childrens.kind_of?(Array)
|
87
|
+
end
|
88
|
+
|
89
|
+
def hash_from(e, data, enable_branch)
|
90
|
+
dependency_data = data[e]
|
91
|
+
|
92
|
+
git_branch_hash = try_git_branch(e, dependency_data) if enable_branch
|
93
|
+
return git_branch_hash if git_branch_hash.kind_of?(Hash)
|
94
|
+
|
95
|
+
local = dependency_data[MetaConstants.local_key]
|
96
|
+
local_path = dependency_data[MetaConstants.local_path_key]
|
97
|
+
|
98
|
+
if local && local_path.kind_of?(String)
|
99
|
+
return Hash[e => [Hash[:path => local_path]]]
|
100
|
+
else
|
101
|
+
return try_source(e, dependency_data)
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
def try_git_branch(e, dependency_data)
|
106
|
+
value = Private::PrivateCache.cached_branch_hash[e] if Private::PrivateCache.cached_branch_hash.kind_of?(Hash)
|
107
|
+
return nil unless value.kind_of?(Hash)
|
108
|
+
|
109
|
+
git = value[MetaConstants.git_key] if value.kind_of?(Hash)
|
110
|
+
branch = value[MetaConstants.branch_key] if value.kind_of?(Hash)
|
111
|
+
|
112
|
+
return nil unless git.kind_of?(String) && branch.kind_of?(String)
|
113
|
+
|
114
|
+
Hash[e => [Hash[:git => git, :branch => branch]]]
|
115
|
+
end
|
116
|
+
|
117
|
+
def try_source(e, dependency_data)
|
118
|
+
binary = dependency_data[MetaConstants.binary_key]
|
119
|
+
source_url = dependency_data[MetaConstants.source_key]
|
120
|
+
if binary
|
121
|
+
source_url ||= Private::PrivateCache.binary_repo_url
|
122
|
+
else
|
123
|
+
source_url ||= Private::PrivateCache.source_repo_url
|
124
|
+
end
|
125
|
+
Hash[e => [dependency_data[MetaConstants.version_key], Hash[:source => source_url]]]
|
126
|
+
end
|
127
|
+
|
128
|
+
def podfile_to_meta(podfile)
|
129
|
+
podfile_hash = podfile.to_hash
|
130
|
+
generate_dependency(podfile_hash)
|
131
|
+
File::open(MetaConstants.meta_path, "w") { |io| io.puts "#{podfile_hash.to_yaml}" }
|
132
|
+
end
|
133
|
+
|
134
|
+
def podfile_to_data(podfile, config)
|
135
|
+
data = generate_data(podfile, config)
|
136
|
+
File::open(MetaConstants.data_path, "w") { |io| io.puts "#{data.to_yaml}" }
|
137
|
+
|
138
|
+
local_data = generate_local_data(podfile)
|
139
|
+
File::open(MetaConstants.podfile_local_path, "w") { |io| io.puts "#{local_data.to_yaml}" }
|
140
|
+
end
|
141
|
+
|
142
|
+
def generate_local_data(podfile)
|
143
|
+
data = Hash.new
|
144
|
+
|
145
|
+
podfile.dependencies.select do |dependency|
|
146
|
+
if dependency.local?
|
147
|
+
podspec = File.directory?(dependency.local?) ? Pod::Specification.from_file("#{dependency.local?}/#{dependency.name.to_s}.podspec") : Pod::Specification.from_file(dependency.local?)
|
148
|
+
next podspec.name.to_s == dependency.name.to_s
|
149
|
+
end
|
150
|
+
if [Private::PrivateCache.source_repo_url, Private::PrivateCache.binary_repo_url].include?(dependency.podspec_repo)
|
151
|
+
next true
|
152
|
+
end
|
153
|
+
next false
|
154
|
+
end.each do |dependency|
|
155
|
+
data_element = Hash.new
|
156
|
+
|
157
|
+
if dependency.local?
|
158
|
+
data_element[MetaConstants.local_key] = true
|
159
|
+
data_element[MetaConstants.local_path_key] = dependency.local?
|
160
|
+
else
|
161
|
+
data_element[MetaConstants.local_key] = false
|
162
|
+
data_element[MetaConstants.local_path_key] = Private::PrivateCache.read_local_path(dependency.name)
|
163
|
+
end
|
164
|
+
|
165
|
+
data_element[MetaConstants.binary_key] = dependency.podspec_repo == Private::PrivateCache.binary_repo_url
|
166
|
+
|
167
|
+
data[dependency.name.to_s] = data_element
|
168
|
+
end
|
169
|
+
|
170
|
+
data
|
171
|
+
end
|
172
|
+
|
173
|
+
def generate_data(podfile, config)
|
174
|
+
data = Hash.new
|
175
|
+
|
176
|
+
podfile.dependencies.each do |dependency|
|
177
|
+
data_element = Hash.new
|
178
|
+
|
179
|
+
data_element[MetaConstants.version_key] = generate_version(dependency)
|
180
|
+
|
181
|
+
if dependency.podspec_repo.kind_of?(String)
|
182
|
+
if [Private::PrivateCache.source_repo_url, Private::PrivateCache.binary_repo_url].include?(dependency.podspec_repo)
|
183
|
+
data_element[MetaConstants.binary_key] = dependency.podspec_repo == Private::PrivateCache.binary_repo_url
|
184
|
+
else
|
185
|
+
data_element[MetaConstants.source_key] = dependency.podspec_repo
|
186
|
+
end
|
187
|
+
else
|
188
|
+
if File.exists?("#{podfile.defined_in_file.parent.parent}/Binary/#{dependency.name.to_s}.podspec")
|
189
|
+
data_element[MetaConstants.binary_key] = false
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
data[dependency.name.to_s] = data_element
|
194
|
+
end
|
195
|
+
|
196
|
+
data
|
197
|
+
end
|
198
|
+
|
199
|
+
def generate_version(dependency)
|
200
|
+
if dependency.local?.kind_of?(String)
|
201
|
+
podspec_path = dependency.local?
|
202
|
+
if File.directory?(podspec_path)
|
203
|
+
"= #{Pod::Specification.from_file("#{podspec_path}/#{dependency.name.to_s}.podspec").version.to_s}"
|
204
|
+
elsif File.file?(podspec_path)
|
205
|
+
"= #{Pod::Specification.from_file(podspec_path).version.to_s}"
|
206
|
+
else
|
207
|
+
raise "#{dependency.name} unrecognized local path"
|
208
|
+
end
|
209
|
+
else
|
210
|
+
dependency.requirement.to_s
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
214
|
+
def generate_dependency(podfile_hash)
|
215
|
+
target_definitions = podfile_hash["target_definitions"]
|
216
|
+
return unless target_definitions.kind_of?(Array)
|
217
|
+
|
218
|
+
target_definitions.each { |target| internal_generate_dependency(target) }
|
219
|
+
end
|
220
|
+
|
221
|
+
def internal_generate_dependency(target)
|
222
|
+
children = target['children']
|
223
|
+
children.each { |c| internal_generate_dependency(c) } if children.kind_of?(Array)
|
224
|
+
|
225
|
+
dependencies = target['dependencies']
|
226
|
+
return unless dependencies.kind_of?(Array)
|
227
|
+
|
228
|
+
dependencies = dependencies.map do |dependency|
|
229
|
+
key = dependency.kind_of?(Hash) ? dependency.keys.first : dependency
|
230
|
+
generated_name = key
|
231
|
+
generated_name
|
232
|
+
end
|
233
|
+
|
234
|
+
target['dependencies'] = dependencies
|
235
|
+
end
|
236
|
+
|
237
|
+
def prompt(message, default)
|
238
|
+
print "#{message} (or press enter to use: #{default}) > "
|
239
|
+
input = STDIN.gets.chomp
|
240
|
+
input = nil if input.strip.empty?
|
241
|
+
input
|
242
|
+
end
|
243
|
+
|
244
|
+
def validate_version(tag)
|
245
|
+
if tag.index(/[0-9]{1,2}.[0-9]{1,2}.[0-9]{1,2}/)
|
246
|
+
return true
|
247
|
+
else
|
248
|
+
UI.puts("Illegal tag: #{tag}")
|
249
|
+
return false
|
250
|
+
end
|
251
|
+
end
|
252
|
+
end
|
253
|
+
end
|
254
|
+
end
|
255
|
+
end
|
@@ -0,0 +1,277 @@
|
|
1
|
+
module Pod
|
2
|
+
module Private
|
3
|
+
module PrivateCache
|
4
|
+
class BranchCache
|
5
|
+
def initialize(key, path)
|
6
|
+
@key = key
|
7
|
+
@path = path
|
8
|
+
end
|
9
|
+
|
10
|
+
def key
|
11
|
+
@key
|
12
|
+
end
|
13
|
+
|
14
|
+
def git
|
15
|
+
git = `git -C #{@path} remote get-url origin`.lines.to_a.first
|
16
|
+
git.strip if git
|
17
|
+
end
|
18
|
+
|
19
|
+
def branch
|
20
|
+
branch = `git -C #{@path} rev-parse --abbrev-ref HEAD`.lines.to_a.first
|
21
|
+
branch.strip if branch
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
class << self
|
26
|
+
require 'pathname'
|
27
|
+
require 'fileutils'
|
28
|
+
require 'json'
|
29
|
+
|
30
|
+
@@root_path = Pathname.new(File.expand_path('~')) + 'Projects/Pods'
|
31
|
+
@@path_map = '.path_map.json'
|
32
|
+
@@repo_map = '.repo_map.json'
|
33
|
+
@@path_map_path = @@root_path + @@path_map
|
34
|
+
@@repo_map_path = @@root_path + @@repo_map
|
35
|
+
|
36
|
+
@@binary_repo_key = 'binary'
|
37
|
+
@@source_repo_key = 'source'
|
38
|
+
|
39
|
+
def cache_repo(repo_name, repo_url, is_binary)
|
40
|
+
make_workspace
|
41
|
+
repo_map = cached_repo_map
|
42
|
+
|
43
|
+
if is_binary
|
44
|
+
repo_map[@@binary_repo_key] = Hash[repo_name => repo_url]
|
45
|
+
else
|
46
|
+
repo_map[@@source_repo_key] = Hash[repo_name => repo_url]
|
47
|
+
end
|
48
|
+
|
49
|
+
File.open(@@repo_map_path, 'w') { |io| io << repo_map.to_json }
|
50
|
+
end
|
51
|
+
|
52
|
+
def binary_repo_name
|
53
|
+
repo_map = cached_repo_map
|
54
|
+
binary_map = repo_map[@@binary_repo_key]
|
55
|
+
return nil unless binary_map.kind_of?(Hash)
|
56
|
+
binary_map.keys.first
|
57
|
+
end
|
58
|
+
|
59
|
+
def source_repo_name
|
60
|
+
repo_map = cached_repo_map
|
61
|
+
source_map = repo_map[@@source_repo_key]
|
62
|
+
return nil unless source_map.kind_of?(Hash)
|
63
|
+
source_map.keys.first
|
64
|
+
end
|
65
|
+
|
66
|
+
def binary_repo_url
|
67
|
+
repo_map = cached_repo_map
|
68
|
+
binary_map = repo_map[@@binary_repo_key]
|
69
|
+
return nil unless binary_map.kind_of?(Hash)
|
70
|
+
binary_map.values.first
|
71
|
+
end
|
72
|
+
|
73
|
+
def source_repo_url
|
74
|
+
repo_map = cached_repo_map
|
75
|
+
source_map = repo_map[@@source_repo_key]
|
76
|
+
return nil unless source_map.kind_of?(Hash)
|
77
|
+
source_map.values.first
|
78
|
+
end
|
79
|
+
|
80
|
+
def cache_branch(branch_caches)
|
81
|
+
make_branch_cache_workspace_if_needed
|
82
|
+
branch_hash = Hash.new
|
83
|
+
|
84
|
+
branch_caches.each do |e|
|
85
|
+
branch_hash[e.key] = {Meta::MetaConstants.branch_key => e.branch, Meta::MetaConstants.git_key => e.git}
|
86
|
+
end
|
87
|
+
|
88
|
+
File.open(Meta::MetaConstants.branch_cache_path, "w") { |io| io << branch_hash.to_yaml }
|
89
|
+
end
|
90
|
+
|
91
|
+
def cached_branch_hash
|
92
|
+
unless File.exists?(Meta::MetaConstants.branch_cache_path)
|
93
|
+
return Hash.new
|
94
|
+
end
|
95
|
+
|
96
|
+
yaml = YAML.load_file(Meta::MetaConstants.branch_cache_path)
|
97
|
+
yaml
|
98
|
+
end
|
99
|
+
|
100
|
+
def set_search_path(search_path)
|
101
|
+
make_workspace()
|
102
|
+
content = File.open(@@path_map_path)
|
103
|
+
json = JSON.load(content)
|
104
|
+
|
105
|
+
map = Hash.new
|
106
|
+
if json.kind_of?(JSON)
|
107
|
+
map = json.to_hash
|
108
|
+
end
|
109
|
+
map['search_path'] = search_path
|
110
|
+
|
111
|
+
File.open(@@path_map_path, "w") { |io| io.puts map.to_json }
|
112
|
+
end
|
113
|
+
|
114
|
+
def start(repo_name)
|
115
|
+
current_pwd = Dir.pwd
|
116
|
+
|
117
|
+
# 1.检查repo_name合法性, 是否在repos中存在
|
118
|
+
repos_path = locate_repos_path
|
119
|
+
raise "#{repo_name} not found in configured source, run 'pod mod config' or 'pod repo uppdate' at first" unless repos_path
|
120
|
+
|
121
|
+
# 2.读取@@path_map缓存,是否有repo_name对应的pod的path存在
|
122
|
+
make_workspace()
|
123
|
+
# 2.1 如果repo_name对应的path存在, 返回他
|
124
|
+
local_path = read_local_path(repo_name)
|
125
|
+
return local_path if local_path.kind_of?(String)
|
126
|
+
|
127
|
+
## 2.3 使用repos的地址clone到@@root中并在@@path_map中写入缓存地址
|
128
|
+
version = Meta::MetaAccessor.version(repo_name)
|
129
|
+
version_path = Pathname.new(repos_path) + repo_name
|
130
|
+
raise "#{version}不存在, run `pod repo update #{File.basename(repos_path)}`" unless Dir.entries(version_path).include?(version)
|
131
|
+
|
132
|
+
repo_spec_path = version_path + "#{version}/#{repo_name}.podspec"
|
133
|
+
raise "#{repo_spec_path} 不存在, 不是一个合法的podspec" unless File.exists?(repo_spec_path)
|
134
|
+
|
135
|
+
## 切换workspace
|
136
|
+
FileUtils.cd(@@root_path)
|
137
|
+
## 判断repo_name是否存在,如果存在,删除他,可能是一些临时文件
|
138
|
+
if File.exists?(repo_name)
|
139
|
+
UI.puts '清空workspace'
|
140
|
+
FileUtils.rm_rf(repo_name)
|
141
|
+
end
|
142
|
+
|
143
|
+
git_clone_command = package_clone_command(repo_spec_path, repo_name)
|
144
|
+
UI.puts "clone #{repo_name} into #{@@root_path}"
|
145
|
+
system_build(git_clone_command)
|
146
|
+
|
147
|
+
## 下载完成之后,把路径写入缓存
|
148
|
+
local_path = "#{@@root_path}/#{repo_name}"
|
149
|
+
write_path_into_cache(repo_name, path)
|
150
|
+
|
151
|
+
## 结束后,重置pwd
|
152
|
+
FileUtils.cd(current_pwd)
|
153
|
+
|
154
|
+
return local_path
|
155
|
+
end
|
156
|
+
|
157
|
+
def write_path_into_cache(repo_name, path)
|
158
|
+
content = File.open(@@path_map_path)
|
159
|
+
json = JSON.load(content)
|
160
|
+
|
161
|
+
map = Hash.new
|
162
|
+
if json.kind_of?(JSON)
|
163
|
+
map = json.to_hash
|
164
|
+
end
|
165
|
+
map[repo_name] = path
|
166
|
+
|
167
|
+
# path的上一级作为search_path
|
168
|
+
map['search_path'] = Pathname.new(path).parent
|
169
|
+
|
170
|
+
File.open(@@path_map_path, "w") { |io| io.puts map.to_json }
|
171
|
+
end
|
172
|
+
|
173
|
+
def read_local_path(repo_name)
|
174
|
+
return "" unless File.exists?(@@path_map_path)
|
175
|
+
content = File.open(@@path_map_path)
|
176
|
+
json = JSON.load(content)
|
177
|
+
local_path = json[repo_name] if json.kind_of?(Hash)
|
178
|
+
return local_path if local_path.kind_of?(String)
|
179
|
+
|
180
|
+
# 如果不存在, 先在search_path中寻找
|
181
|
+
local_path = locate_spec_in_search_path(repo_name)
|
182
|
+
if local_path.kind_of?(String)
|
183
|
+
write_path_into_cache(repo_name, local_path)
|
184
|
+
return local_path
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
private
|
189
|
+
def cached_repo_map
|
190
|
+
repo_map = Hash.new
|
191
|
+
if File.exists?(@@repo_map_path)
|
192
|
+
content = File.read(@@repo_map_path)
|
193
|
+
_repo_map = JSON.load(content).to_hash
|
194
|
+
repo_map = _repo_map if _repo_map.kind_of?(Hash)
|
195
|
+
end
|
196
|
+
repo_map
|
197
|
+
end
|
198
|
+
|
199
|
+
def make_branch_cache_workspace_if_needed
|
200
|
+
unless File.directory?(Meta::MetaConstants.pods_generator_path)
|
201
|
+
raise "#{Meta::MetaConstants.pods_generator_path} not found"
|
202
|
+
end
|
203
|
+
|
204
|
+
unless File.exists?(Meta::MetaConstants.branch_cache_path)
|
205
|
+
FileUtils.touch(Meta::MetaConstants.branch_cache_path)
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
## 查询repos的路径
|
210
|
+
def locate_repos_path
|
211
|
+
repos_path = Pathname.new(File.expand_path('~')) + '.cocoapods/repos'
|
212
|
+
|
213
|
+
path = Dir.glob("#{repos_path}/*").select { |f| File.directory? f }.detect do |p|
|
214
|
+
ssh = `/usr/bin/env -u GIT_CONFIG git -C #{p} config --get remote.origin.url`.lines.to_a.first.to_s
|
215
|
+
ssh = ssh.strip if ssh.kind_of?(String)
|
216
|
+
ssh.kind_of?(String) and [source_repo_url, binary_repo_url].include?(ssh)
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
220
|
+
def locate_spec_in_search_path(repo_name)
|
221
|
+
return Dir.glob("#{search_path}/#{repo_name}").first
|
222
|
+
end
|
223
|
+
|
224
|
+
## 检查yrepos下是否包含repo_name
|
225
|
+
def is_repos_include(repo_path, repo_name)
|
226
|
+
Dir.entries(frepo_path).select { |entry| File.directory? File.join(repo_path, entry) and !(entry =='.' || entry == '..') }.include?(repo_name)
|
227
|
+
end
|
228
|
+
|
229
|
+
def package_clone_command(repo_spec_path, repo_name)
|
230
|
+
spec = Pod::Specification.from_file(repo_spec_path)
|
231
|
+
source_map = spec.source.to_hash
|
232
|
+
git = source_map[:git]
|
233
|
+
return unless git.kind_of?(String)
|
234
|
+
|
235
|
+
command = "git clone #{git}"
|
236
|
+
branch = source_map[:branch]
|
237
|
+
if branch.kind_of?(String)
|
238
|
+
command = command + " --branch #{branch} --depth 1 --single-branch #{@@root_path}/#{repo_name}"
|
239
|
+
end
|
240
|
+
|
241
|
+
command
|
242
|
+
end
|
243
|
+
|
244
|
+
def system_build(command)
|
245
|
+
output = `#{command}`.lines.to_a
|
246
|
+
|
247
|
+
if $?.exitstatus != 0
|
248
|
+
UI::BuildFailedReport.report(command, output)
|
249
|
+
Process.exit
|
250
|
+
end
|
251
|
+
end
|
252
|
+
|
253
|
+
def make_workspace
|
254
|
+
unless File.exists?(@@path_map_path)
|
255
|
+
# 如果root_path不存在,新建一个文件
|
256
|
+
unless Dir.exists?(@@root_path)
|
257
|
+
FileUtils.mkdir_p(@@root_path)
|
258
|
+
UI.puts "mkdir: #{@@root_path}"
|
259
|
+
end
|
260
|
+
|
261
|
+
# 如果ux_path_map不存在,创建一个文件
|
262
|
+
FileUtils.cd(@@root_path)
|
263
|
+
FileUtils.touch(@@path_map)
|
264
|
+
|
265
|
+
UI.puts "touch: #{@@path_map}"
|
266
|
+
end
|
267
|
+
end
|
268
|
+
|
269
|
+
def search_path
|
270
|
+
content = File.open(@@path_map_path)
|
271
|
+
json = JSON.load(content)
|
272
|
+
return json['search_path'] if json.kind_of?(Hash)
|
273
|
+
end
|
274
|
+
end
|
275
|
+
end
|
276
|
+
end
|
277
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'cocoapods-modularization/gem_version'
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'cocoapods-modularization/command'
|
metadata
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cocoapods-modularization
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- lazy
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-11-26 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.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: A short description of cocoapods-modularization.
|
42
|
+
email:
|
43
|
+
- 515310192@qq.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- lib/cocoapods-modularization.rb
|
49
|
+
- lib/cocoapods-modularization/command.rb
|
50
|
+
- lib/cocoapods-modularization/command/install.rb
|
51
|
+
- lib/cocoapods-modularization/command/mod.rb
|
52
|
+
- lib/cocoapods-modularization/command/mod/add.rb
|
53
|
+
- lib/cocoapods-modularization/command/mod/base.rb
|
54
|
+
- lib/cocoapods-modularization/command/mod/binary.rb
|
55
|
+
- lib/cocoapods-modularization/command/mod/config.rb
|
56
|
+
- lib/cocoapods-modularization/command/mod/create.rb
|
57
|
+
- lib/cocoapods-modularization/command/mod/inspect.rb
|
58
|
+
- lib/cocoapods-modularization/command/mod/source.rb
|
59
|
+
- lib/cocoapods-modularization/command/mod/sync.rb
|
60
|
+
- lib/cocoapods-modularization/command/mod/update.rb
|
61
|
+
- lib/cocoapods-modularization/gem_version.rb
|
62
|
+
- lib/cocoapods-modularization/generate.rb
|
63
|
+
- lib/cocoapods-modularization/generate/configuration.rb
|
64
|
+
- lib/cocoapods-modularization/generate/installer.rb
|
65
|
+
- lib/cocoapods-modularization/generate/podfile_generator.rb
|
66
|
+
- lib/cocoapods-modularization/meta.rb
|
67
|
+
- lib/cocoapods-modularization/meta/meta_accessor.rb
|
68
|
+
- lib/cocoapods-modularization/meta/meta_constants.rb
|
69
|
+
- lib/cocoapods-modularization/meta/meta_reference.rb
|
70
|
+
- lib/cocoapods-modularization/private.rb
|
71
|
+
- lib/cocoapods-modularization/private/private_cache.rb
|
72
|
+
- lib/cocoapods_plugin.rb
|
73
|
+
homepage: https://github.com/EXAMPLE/cocoapods-modularization
|
74
|
+
licenses:
|
75
|
+
- MIT
|
76
|
+
metadata: {}
|
77
|
+
post_install_message:
|
78
|
+
rdoc_options: []
|
79
|
+
require_paths:
|
80
|
+
- lib
|
81
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
requirements: []
|
92
|
+
rubygems_version: 3.0.3
|
93
|
+
signing_key:
|
94
|
+
specification_version: 4
|
95
|
+
summary: A longer description of cocoapods-modularization.
|
96
|
+
test_files: []
|