jmpod 0.2.4 → 0.2.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 57395f5481cef82d1b55ca91626d91bc8ee89a0b6e081a9d4eb3821eec5f1715
4
- data.tar.gz: 35044c8dc835a21abda4c455df1ea58f0bb8ea76f973bc9cebad6cc46413a2c7
3
+ metadata.gz: 6459c9d7ddb429cda4c2d449c79f80e46151649a2863c6951a7b8e4c6d97dd73
4
+ data.tar.gz: c41b842e850b3df388afdd81cd63f8a6b37c0258ba0bf5abe79d96749390a8a4
5
5
  SHA512:
6
- metadata.gz: 5153a66ec8a46e5b4c482c851dbae3ed8fa37400e7b0207a2a1f5a6df6865b072364d11fb24cb53402f6bcd8b46506819366ff66c1384210eb8063d00fbbdbe4
7
- data.tar.gz: 80799554d9f43813f1b0bbae3b7aa821c5d4c2184192f9d559f6583bc37db7d177faf583b942171e4512ac33e1873a9280f02da53602ee5daea41cbff4dbf196
6
+ metadata.gz: 9a4ae079a3999310e502397af86968e9738b2f32fa0e0bf714745b41d4025bac88581a632e5665eaae2bd1a9bd4e8cf4f9e2340b90ad733501bb6737d2c72ec8
7
+ data.tar.gz: dcf57dbb0dd9ab6ce55ae1b4550b028b9cb222fde327ca7ec9d2f444bcd9928e6145cea0f092b8e11b489ec9250646646be9fc32e47c738da0209dd997985095
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- jmpod (0.2.3)
4
+ jmpod (0.2.5)
5
5
  claide (>= 1.0.2, < 2.0)
6
6
  cocoapods (>= 1.8.4)
7
7
  colored2 (~> 3.1)
data/bin/jmpod CHANGED
@@ -3,7 +3,6 @@
3
3
  require "bundler/setup"
4
4
  require "jmpod"
5
5
  require "cocoapods"
6
- require_relative '../lib/cocoapods/analyze'
7
6
 
8
7
  # You can add fixtures and/or initialization code here to make experimenting
9
8
  # with your gem easier. You can also use a different console, if you like.
@@ -3,106 +3,80 @@ require 'pathname'
3
3
  require 'tmpdir'
4
4
 
5
5
  module Jmpod
6
- class Command
7
- class Analyze < Command
8
- self.summary = '分析podfile完整依赖链'
9
- self.description = <<-DESC
10
- 分析podfile完整依赖链,并输出json文件.
11
- DESC
12
-
13
- def initialize(argv)
14
- puts 'analyze starting ......'.green
15
- @podfile_dir_path = argv.shift_argument
16
- super
17
- end
6
+ class Analyze
7
+ def podfile_dependencies(podfile)
8
+ res = []
9
+ podfile.root_target_definitions.each do |td|
10
+ children_definitions = td.recursive_children
11
+ children_definitions.each do |cd|
12
+ dependencies_hash_array = cd.send(:get_hash_value, 'dependencies')
13
+ next if dependencies_hash_array.nil? || dependencies_hash_array.count.zero?
18
14
 
15
+ dependencies_hash_array.each do |item|
16
+ next if item.class.name != 'Hash'
19
17
 
20
- def podfile_dependencies(podfile)
21
- res = []
22
- podfile.root_target_definitions.each do |td|
23
- children_definitions = td.recursive_children
24
- children_definitions.each do |cd|
25
- dependencies_hash_array = cd.send(:get_hash_value, 'dependencies')
26
- next if dependencies_hash_array.nil? || dependencies_hash_array.count.zero?
27
-
28
- dependencies_hash_array.each do |item|
29
- next if item.class.name != 'Hash'
30
-
31
- item.each do |name, _|
32
- res.push name
33
- end
18
+ item.each do |name, _|
19
+ res.push name
34
20
  end
35
21
  end
36
22
  end
37
- res
38
23
  end
24
+ res
25
+ end
39
26
 
40
- def self.options
41
- [].concat(super)
27
+ def analyze_with_podfile(_podfile_dir_path, podfile, lockfile = nil)
28
+ if _podfile_dir_path
29
+ sandbox = Dir.mktmpdir
30
+ else
31
+ sandbox = Dir.pwd + '/Pods'
42
32
  end
33
+ p 'sandbox === '
34
+ pp sandbox
35
+ an = Pod::Installer::Analyzer.new(Pod::Sandbox.new(sandbox), podfile)
36
+ pp an
37
+ # analyzer = Pod::Installer::Analyzer.new(
38
+ # Pod::Sandbox.new(sandbox),
39
+ # podfile,
40
+ # lockfile
41
+ # )
43
42
 
44
- def validate!
45
- super
46
- end
43
+ # specifications = analyzer.analyze.specifications.map(&:root).uniq
47
44
 
48
- def run
49
- puts 'config === '
50
- pp config.podfile
51
- analyze_with_podfile(nil, config.podfile)
45
+ # new_map = generate_pods_data(specifications)
46
+ # p "new_map === "
47
+ # pp new_map
48
+ # new_map
49
+ end
50
+
51
+ def generate_pods_data(specs)
52
+ pods_and_deps_merged = specs.reduce({}) do |result, spec|
53
+ name = spec.to_s
54
+ result[name] ||= []
55
+ result[name].concat(spec.all_dependencies.map(&:to_s))
56
+ result
52
57
  end
53
-
54
- def analyze_with_podfile(_podfile_dir_path, podfile, lockfile = nil)
55
- if _podfile_dir_path
56
- sandbox = Dir.mktmpdir
57
- else
58
- sandbox = Dir.pwd + '/Pods'
59
- end
60
- p 'sandbox === '
61
- pp sandbox
62
- analyzer = Pod::Installer::Analyzer.new(
63
- Pod::Sandbox.new(sandbox),
64
- podfile,
65
- lockfile
66
- )
67
-
68
- specifications = analyzer.analyze.specifications.map(&:root).uniq
69
-
70
- new_map = generate_pods_data(specifications)
71
- p "new_map === "
72
- pp new_map
73
- new_map
58
+
59
+ pod_and_deps = pods_and_deps_merged.map do |name, deps|
60
+ deps.empty? ? name : { name => YAMLHelper.sorted_array(deps.uniq) }
74
61
  end
62
+ YAMLHelper.sorted_array(pod_and_deps)
63
+ end
75
64
 
76
- def generate_pods_data(specs)
77
- pods_and_deps_merged = specs.reduce({}) do |result, spec|
78
- name = spec.to_s
79
- result[name] ||= []
80
- result[name].concat(spec.all_dependencies.map(&:to_s))
81
- result
82
- end
65
+ def self.find_dependencies(name, map, res, dependencies_map, root_name)
66
+ return unless map[name]
83
67
 
84
- pod_and_deps = pods_and_deps_merged.map do |name, deps|
85
- deps.empty? ? name : { name => YAMLHelper.sorted_array(deps.uniq) }
86
- end
87
- YAMLHelper.sorted_array(pod_and_deps)
88
- end
89
-
90
- def self.find_dependencies(name, map, res, dependencies_map, root_name)
91
- return unless map[name]
92
-
93
- map[name].each do |k|
94
- find_dependencies(k.name, map, res, dependencies_map, root_name)
95
- dependency = dependencies_map[k.name.split('/')[0]]
96
- res.push dependency.name if dependency && dependency.name != root_name
97
- end
98
- res
68
+ map[name].each do |k|
69
+ find_dependencies(k.name, map, res, dependencies_map, root_name)
70
+ dependency = dependencies_map[k.name.split('/')[0]]
71
+ res.push dependency.name if dependency && dependency.name != root_name
99
72
  end
100
-
101
- def self.subspecs_with_name(spec, subspecs_short_names)
102
- subspecs_short_names.map do |name|
103
- spec.subspecs.find { |ss| ss.name.include? name }
104
- end
105
- end
73
+ res
106
74
  end
75
+
76
+ def self.subspecs_with_name(spec, subspecs_short_names)
77
+ subspecs_short_names.map do |name|
78
+ spec.subspecs.find { |ss| ss.name.include? name }
79
+ end
80
+ end
107
81
  end
108
82
  end
@@ -0,0 +1,33 @@
1
+ require 'pp'
2
+ require 'tmpdir'
3
+ require 'jmpod/command/analyze'
4
+
5
+ module Pod
6
+ class Command
7
+ class Dependency < Command
8
+ self.summary = '分析podfile完整依赖链'
9
+ self.description = <<-DESC
10
+ 分析podfile完整依赖链,并输出json文件.
11
+ DESC
12
+
13
+ def initialize(argv)
14
+ super
15
+ end
16
+
17
+ def self.options
18
+ [
19
+ ].concat(super)
20
+ end
21
+
22
+ def validate!
23
+ super
24
+ verify_podfile_exists!
25
+ end
26
+
27
+ def run
28
+ analyze_result = Jmpod::Analyzer.analyze_with_podfile(nil, config.podfile)
29
+ pp analyze_result
30
+ end
31
+ end
32
+ end
33
+ end
data/lib/jmpod/command.rb CHANGED
@@ -17,7 +17,7 @@ module Jmpod
17
17
  require 'jmpod/command/create'
18
18
  require 'jmpod/command/init'
19
19
  require 'jmpod/command/config'
20
- require 'jmpod/command/analyze'
20
+ require 'jmpod/command/dependency'
21
21
 
22
22
  self.abstract_command = true
23
23
  self.command = 'jmpod'
data/lib/jmpod/version.rb CHANGED
@@ -2,5 +2,5 @@ module Jmpod
2
2
  # freeze 冻结对象,将对象变成一个常量
3
3
  # unless 右边的代码块成立,才会运行左边的代码块
4
4
  # defined? 是用来判断本地变量是否存在,也可用来判断是否存在方法
5
- VERSION = "0.2.4".freeze unless defined? Jmpod::VERSION
5
+ VERSION = "0.2.5".freeze unless defined? Jmpod::VERSION
6
6
  end
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.2.4
4
+ version: 0.2.5
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-26 00:00:00.000000000 Z
11
+ date: 2020-04-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -127,6 +127,7 @@ files:
127
127
  - lib/jmpod/command/create/oc.rb
128
128
  - lib/jmpod/command/create/swift.rb
129
129
  - lib/jmpod/command/create/third.rb
130
+ - lib/jmpod/command/dependency.rb
130
131
  - lib/jmpod/command/init.rb
131
132
  - lib/jmpod/command/init/ci.rb
132
133
  - lib/jmpod/command/init/unit.rb