jmpod 0.1.8 → 0.1.9
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/lib/jmpod/command/analyze.rb +113 -0
- data/lib/jmpod/command.rb +1 -0
- data/lib/jmpod/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bc46c13c610ef39f98d07faf6b4cc3f05a11db52bca314cc2d728731fa699352
|
4
|
+
data.tar.gz: e4a611b89fc20239e45a6f81601c78d42247206112e9bc3a67621d2ff15863b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 21c22e7aabe9ca5ef8a9553db9bab0f96336d5139b7712eb2e0f93ca2b3f6086fd96b05bc57bb024b74b8d7f0d585f14806e4ac265491655160f11b8b8315455
|
7
|
+
data.tar.gz: c2c8c8a7b510a3fbd6b17b2a5724656ae8c016af901b690736de6fa19d51747f228b2671c8814855ad4ae4a0f68e6cfe7465e05daa95fd4a84f2a5c8d8868fdb
|
@@ -0,0 +1,113 @@
|
|
1
|
+
require 'cocoapods'
|
2
|
+
require 'pathname'
|
3
|
+
require 'pp'
|
4
|
+
|
5
|
+
module Jmpod
|
6
|
+
class Command
|
7
|
+
class Analyze < Command
|
8
|
+
self.abstract_command = true
|
9
|
+
self.summary = '分析podfile完整依赖链'
|
10
|
+
self.description = <<-DESC
|
11
|
+
分析podfile完整依赖链,并输出json文件.
|
12
|
+
DESC
|
13
|
+
|
14
|
+
def initialize(podfile_dir_path)
|
15
|
+
p 'podfile_dir_path === '
|
16
|
+
pp podfile_dir_path
|
17
|
+
path = Pathname.new(podfile_dir_path)
|
18
|
+
raise 'absolute path is needed' unless path.absolute?
|
19
|
+
|
20
|
+
Dir.chdir(podfile_dir_path) do
|
21
|
+
analyze_with_podfile(
|
22
|
+
path,
|
23
|
+
Pod::Podfile.from_file(path + 'Podfile'),
|
24
|
+
Pod::Lockfile.from_file(path + 'Podfile.lock')
|
25
|
+
)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
def podfile_dependencies(podfile)
|
31
|
+
res = []
|
32
|
+
podfile.root_target_definitions.each do |td|
|
33
|
+
children_definitions = td.recursive_children
|
34
|
+
children_definitions.each do |cd|
|
35
|
+
dependencies_hash_array = cd.send(:get_hash_value, 'dependencies')
|
36
|
+
next if dependencies_hash_array.nil? || dependencies_hash_array.count.zero?
|
37
|
+
|
38
|
+
dependencies_hash_array.each do |item|
|
39
|
+
next if item.class.name != 'Hash'
|
40
|
+
|
41
|
+
item.each do |name, _|
|
42
|
+
res.push name
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
res
|
48
|
+
end
|
49
|
+
|
50
|
+
def run
|
51
|
+
p 'config === '
|
52
|
+
pp config.podfile
|
53
|
+
analyze_with_podfile(nil, config.podfile)
|
54
|
+
end
|
55
|
+
|
56
|
+
def analyze_with_podfile(_podfile_dir_path, podfile, lockfile = nil)
|
57
|
+
if _podfile_dir_path
|
58
|
+
sandbox = Dir.mktmpdir
|
59
|
+
else
|
60
|
+
sandbox = Dir.pwd + '/Pods'
|
61
|
+
end
|
62
|
+
p 'sandbox === '
|
63
|
+
pp sandbox
|
64
|
+
analyzer = Pod::Installer::Analyzer.new(
|
65
|
+
Pod::Sandbox.new(sandbox),
|
66
|
+
podfile,
|
67
|
+
lockfile
|
68
|
+
)
|
69
|
+
|
70
|
+
specifications = analyzer.analyze.specifications.map(&:root).uniq
|
71
|
+
|
72
|
+
new_map = generate_pods_data(specifications)
|
73
|
+
p "new_map === "
|
74
|
+
pp new_map
|
75
|
+
new_map
|
76
|
+
end
|
77
|
+
|
78
|
+
def generate_pods_data(specs)
|
79
|
+
pods_and_deps_merged = specs.reduce({}) do |result, spec|
|
80
|
+
name = spec.to_s
|
81
|
+
result[name] ||= []
|
82
|
+
result[name].concat(spec.all_dependencies.map(&:to_s))
|
83
|
+
result
|
84
|
+
end
|
85
|
+
|
86
|
+
pod_and_deps = pods_and_deps_merged.map do |name, deps|
|
87
|
+
deps.empty? ? name : { name => YAMLHelper.sorted_array(deps.uniq) }
|
88
|
+
end
|
89
|
+
YAMLHelper.sorted_array(pod_and_deps)
|
90
|
+
end
|
91
|
+
|
92
|
+
def self.find_dependencies(name, map, res, dependencies_map, root_name)
|
93
|
+
return unless map[name]
|
94
|
+
|
95
|
+
map[name].each do |k|
|
96
|
+
find_dependencies(k.name, map, res, dependencies_map, root_name)
|
97
|
+
dependency = dependencies_map[k.name.split('/')[0]]
|
98
|
+
res.push dependency.name if dependency && dependency.name != root_name
|
99
|
+
end
|
100
|
+
res
|
101
|
+
end
|
102
|
+
|
103
|
+
def self.subspecs_with_name(spec, subspecs_short_names)
|
104
|
+
subspecs_short_names.map do |name|
|
105
|
+
spec.subspecs.find { |ss| ss.name.include? name }
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
data/lib/jmpod/command.rb
CHANGED
data/lib/jmpod/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jmpod
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jieming
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-04-
|
11
|
+
date: 2020-04-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -119,6 +119,7 @@ files:
|
|
119
119
|
- jmpod.gemspec
|
120
120
|
- lib/jmpod.rb
|
121
121
|
- lib/jmpod/command.rb
|
122
|
+
- lib/jmpod/command/analyze.rb
|
122
123
|
- lib/jmpod/command/config.rb
|
123
124
|
- lib/jmpod/command/config/get.rb
|
124
125
|
- lib/jmpod/command/config/set.rb
|