cocoapods-hipac 0.0.1 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6f269935ce593da1dafc4fafb74856901770cc26
4
- data.tar.gz: 992de1c2dfac9159693762eefc388dfdf803693c
3
+ metadata.gz: 3dc8a84d1a80fd4659c28c7b0653fed9cca0493e
4
+ data.tar.gz: 971cb916671c86020e0d31ae1dac97bc2188d341
5
5
  SHA512:
6
- metadata.gz: d4eb0ae2586846ffd812003734c1fe13223c9fafdd9b0b7122a5ab594e6d6b6e7325e5687af638ba3be0efa749b8e3e81fbde9d0c0db69df3b7db0b5d42da2c0
7
- data.tar.gz: 500dc66f069554caa5ff15d47ecee418787ab124bbfc56e16a8bace75c45f87611b3f4ff10108e410d80cde5d2a7c6a3d20d539fd4a514d0edafa7fa9d82e0b9
6
+ metadata.gz: 265c8333d5f688daf69575aef7ee5ccca8db10def324ae4990cf33d71b005a60875980bf96145a067c9ea4ae9752ef2fd7a99c0962938b36f87655f53fd903bf
7
+ data.tar.gz: 5464b26a0057bd4ae3d51b0b9cd05991a93f1a4221710a161b15ae94fbf478b50e256e2f24b92bf8de67ce3fbd67fd309ddb59baea9db996f1b88edb2915a261
data/README.md CHANGED
@@ -1,4 +1,11 @@
1
- hipac cocoapods-plugin
1
+ # hipac cocoapods-plugin
2
2
  为 pod 提供二级命令 hipac
3
+ ## install
4
+ `gem install cocoapods-hipac`
3
5
  ## usage
4
- `pod hipac sort` 根据 podFile 分析依赖
6
+ * `pod hipac depsort` 根据 podFile 分析依赖
7
+ * `pod hipac pull` 根据 podFile 将开发状态 pod 批量更新至本地
8
+ 所有 pod 会 pull 至 podFile 所在目录的上一级
9
+ 本地没有该 pod 仓库 执行git clone -b
10
+ 本地有该 pod 仓库,且分支一致,执行 git stash & git pull
11
+ 本地有该 pod 仓库,但分支不一致,执行 git stash & git checkout branch & git pull
@@ -15,5 +15,15 @@ module Pod
15
15
  dev_dependency_list
16
16
 
17
17
  end
18
+
19
+ def all_dependency_list
20
+ main_target_definition_list = target_definition_list.reject do |target_definition|
21
+ target_definition.name.end_with?('Tests') || target_definition.name.end_with?('Widget')
22
+ end
23
+
24
+ all_dependency_list = main_target_definition_list.flat_map(&:dependencies).uniq
25
+
26
+ all_dependency_list
27
+ end
18
28
  end
19
29
  end
@@ -10,11 +10,17 @@ module Pod
10
10
  end
11
11
 
12
12
  def direct_dependencies
13
- @direct_dependencies ||= begin
13
+ @direct_dependencies ||= begin
14
14
  direct_value('dependencies')
15
15
  end
16
16
  end
17
17
 
18
+
19
+
20
+ def recursive_tree(specs)
21
+ resolve_recursive_tree(specs)
22
+ end
23
+
18
24
  protected
19
25
  def direct_value(name, platform = :ios)
20
26
  subspec_consumers = recursive_subspecs.select { |s| s.supported_on_platform?(platform) }
@@ -26,14 +32,28 @@ module Pod
26
32
 
27
33
  def resolve_recursive_dependencies(specs)
28
34
  direct_dependencies.map do |dep|
29
- spec = specs.find { |s| s.name == dep.name }
35
+ spec = specs.find { |s| s.name.eql?(dep.name) }
30
36
  next dep if spec.nil? || spec.direct_dependencies.empty?
31
-
37
+
32
38
  (Array(dep) + spec.resolve_recursive_dependencies(specs)).flatten
39
+
33
40
  end.compact.flatten.uniq
34
41
  end
42
+
43
+ def resolve_recursive_tree(specs, line='-')
44
+ direct_dependencies.each do |dep|
45
+ spec = specs.find { |s| s.name.eql?(dep.name)}
46
+ next dep if spec.nil?
47
+ UI.puts line + ' ' + spec.name
48
+
49
+ if !spec.direct_dependencies.empty?
50
+ spec.resolve_recursive_tree(specs, '-'+line)
51
+ end
52
+
53
+ end
54
+ end
35
55
  end
36
56
 
37
57
  include Pod::Specification::RecursiveDependency
38
58
  end
39
- end
59
+ end
@@ -0,0 +1,18 @@
1
+ require 'cocoapods'
2
+
3
+ def reference_spec_list
4
+ analyzer = Pod::Installer::Analyzer.new(@config.sandbox, @config.podfile, @config.lockfile)
5
+ podfile_specs = @config.with_changes(skip_repo_update: true) do
6
+ # allow fetch ,初次install时,或者新增external source 时,由于Pods/Local Podspecs 是空,会抛出找不到specification异常
7
+ begin
8
+ analyzer.analyze(false).specs_by_target.values.flatten(1)
9
+ rescue
10
+ analyzer.analyze(true).specs_by_target.values.flatten(1)
11
+ end
12
+ end
13
+
14
+ podfile_specs
15
+ rescue
16
+ puts 'Can`t fetch specs from project directory, fetch from private source cache'.yellow
17
+ @config.sources_manager.default_source.last_specs
18
+ end
@@ -1,7 +1,8 @@
1
1
  require 'cocoapods-hipac/command/cocoapods/podfile'
2
2
  require 'cocoapods-hipac/command/cocoapods/source'
3
3
  require 'cocoapods-hipac/command/cocoapods/specification'
4
- require 'cocoapods-hipac/command/depsort/pod_item'
4
+ require 'cocoapods-hipac/command/cocoapods/pod_item'
5
+ require 'cocoapods-hipac/command/cocoapods/tool'
5
6
 
6
7
 
7
8
  module Pod
@@ -11,11 +12,18 @@ module Pod
11
12
  self.summary = '根据 Podfile 文件对 pod 依赖分析'
12
13
 
13
14
  self.description = <<-DESC
14
- 根据 Podfile 文件对 pod 依赖分析
15
+ 根据 Podfile 文件对 pod 依赖分析,默认只对处于开发状态的 pod 排序
15
16
  DESC
16
17
 
18
+ def self.options
19
+ [
20
+ ['--all', '所有依赖'],
21
+ ].concat(Pod::Command::Lib::Lint.options).concat(super).uniq
22
+ end
23
+
17
24
  def initialize(argv)
18
25
  @config = Pod::Config.instance
26
+ @all = argv.flag?('all')
19
27
  help! 'No `Podfile` found in the project directory.' if Pathname.glob('Podfile').empty?
20
28
  super
21
29
  end
@@ -27,7 +35,7 @@ module Pod
27
35
  def run
28
36
  UI.puts "pod hipac depsort"
29
37
 
30
- group_pods_dep(dev_dependency_list(), reference_spec_list())
38
+ group_pods_dep(dependency_list(), reference_spec_list())
31
39
 
32
40
  if @grouped_pods
33
41
 
@@ -56,25 +64,16 @@ module Pod
56
64
  end
57
65
  end
58
66
 
59
- def dev_dependency_list
60
- @config.podfile.dev_dependency_list
61
- end
67
+ def dependency_list
68
+ list = []
69
+
70
+ if @all
71
+ list = @config.podfile.all_dependency_list
72
+ else
73
+ list = @config.podfile.dev_dependency_list
74
+ end
62
75
 
63
- def reference_spec_list
64
- analyzer = Pod::Installer::Analyzer.new(@config.sandbox, @config.podfile, @config.lockfile)
65
- podfile_specs = @config.with_changes(skip_repo_update: true) do
66
- # allow fetch ,初次install时,或者新增external source 时,由于Pods/Local Podspecs 是空,会抛出找不到specification异常
67
- begin
68
- analyzer.analyze(false).specs_by_target.values.flatten(1)
69
- rescue
70
- analyzer.analyze(true).specs_by_target.values.flatten(1)
71
- end
72
- end
73
-
74
- podfile_specs
75
- rescue
76
- puts 'Can`t fetch specs from project directory, fetch from private source cache'.yellow
77
- @config.sources_manager.default_source.last_specs
76
+ list
78
77
  end
79
78
 
80
79
  def group_pods_dep(dev_dependency_list, reference_spec_list)
@@ -1,5 +1,6 @@
1
1
  require 'cocoapods-hipac/command/depsort'
2
2
  require 'cocoapods-hipac/command/pull'
3
+ require 'cocoapods-hipac/command/tree'
3
4
 
4
5
 
5
6
  module Pod
@@ -0,0 +1,55 @@
1
+ require 'cocoapods-hipac/command/cocoapods/podfile'
2
+ require 'cocoapods-hipac/command/cocoapods/source'
3
+ require 'cocoapods-hipac/command/cocoapods/specification'
4
+ require 'cocoapods-hipac/command/cocoapods/pod_item'
5
+ require 'cocoapods-hipac/command/cocoapods/tool'
6
+
7
+
8
+ module Pod
9
+ class Command
10
+ class Hipac < Command
11
+ class Tree < Hipac
12
+ self.summary = '根据 Podfile 文件对 pod 依赖分析'
13
+
14
+ self.description = <<-DESC
15
+ 根据 Podfile 文件对 pod 依赖分析
16
+ DESC
17
+
18
+ def initialize(argv)
19
+ @config = Pod::Config.instance
20
+ help! 'No `Podfile` found in the project directory.' if Pathname.glob('Podfile').empty?
21
+ super
22
+ end
23
+
24
+ def validate!
25
+ super
26
+ end
27
+
28
+ def run
29
+ all_dependency_name_list = all_dependency_list().map(&:name)
30
+
31
+ all_spec_list = reference_spec_list()
32
+
33
+ private_dependency_list = all_spec_list.select do |spec|
34
+ all_dependency_name_list.include?(spec.name)
35
+ end
36
+
37
+ UI.puts 'tree start'
38
+ private_dependency_list.each do |spec|
39
+ UI.puts spec.name
40
+ spec.recursive_tree(all_spec_list)
41
+ UI.puts "\n"
42
+ end
43
+ UI.puts 'tree end'
44
+
45
+ end
46
+
47
+ def all_dependency_list
48
+ @config.podfile.all_dependency_list
49
+ end
50
+
51
+
52
+ end
53
+ end
54
+ end
55
+ end
@@ -1,3 +1,3 @@
1
1
  module CocoapodsHipac
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-hipac
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - QiYa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-01 00:00:00.000000000 Z
11
+ date: 2019-03-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -53,13 +53,15 @@ files:
53
53
  - cocoapods-hipac.gemspec
54
54
  - lib/cocoapods-hipac.rb
55
55
  - lib/cocoapods-hipac/command.rb
56
+ - lib/cocoapods-hipac/command/cocoapods/pod_item.rb
56
57
  - lib/cocoapods-hipac/command/cocoapods/podfile.rb
57
58
  - lib/cocoapods-hipac/command/cocoapods/source.rb
58
59
  - lib/cocoapods-hipac/command/cocoapods/specification.rb
60
+ - lib/cocoapods-hipac/command/cocoapods/tool.rb
59
61
  - lib/cocoapods-hipac/command/depsort.rb
60
- - lib/cocoapods-hipac/command/depsort/pod_item.rb
61
62
  - lib/cocoapods-hipac/command/hipac.rb
62
63
  - lib/cocoapods-hipac/command/pull.rb
64
+ - lib/cocoapods-hipac/command/tree.rb
63
65
  - lib/cocoapods-hipac/gem_version.rb
64
66
  - lib/cocoapods_plugin.rb
65
67
  - spec/command/hipac_spec.rb