cocoapods-hipac 0.0.6 → 0.0.7

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: 2a5c664edb2ea879aae6778421a668cce9f9a50222d157b24f9ccbaf57c09ff7
4
- data.tar.gz: 504833ea4a2c763f8eaa424485d39c675253151960e2973e618b3ea516249aa6
3
+ metadata.gz: 81ff72826cd7d52e3a0cb2fedfed993b7c7f65613084534e6e6187a534946a38
4
+ data.tar.gz: 6ed9a856ba2c5789e23efcdb41fe4a9c75d218c0b24b4f5a9120a77a3cd8e89a
5
5
  SHA512:
6
- metadata.gz: 034f8ff775104d602d45e153e895d0c4f6a9a75ad3a478ce1f93e9fd4f3a6b3bd341014758b37e0a0d6296fde8753778efd87b2e14b6e9d5f523ab9a1862c313
7
- data.tar.gz: 47b144deb6a1dba2017ec284450d62808a3d9c524f749d536615d7c79e2f5a1d3bec5961d3af475d76a16374cafbd599305a640f0bb2b1acdbc2efd5199ccbf3
6
+ metadata.gz: 355861741757bd1f80aa59e89169dfcc9565c31c2550a173764280c15718aa61f24d0553260d9370383dceaede268a44487eccc0848e3b631bcda1fad93b925f
7
+ data.tar.gz: de46607c333fefdbfa8b254c03dad4a75329db05501deefd29970dbb6b039df9e62b4b09109e961db08595f3981c517d104aaea05ead70e0b786e8ed9446c89a
@@ -0,0 +1,237 @@
1
+ ---
2
+ title: Cocoapods Plugin
3
+ date: 2019-06-03 01:44:34
4
+ tags:
5
+ - iOS
6
+ - Ruby
7
+ - Cocoapods
8
+ description: <center> 讲一讲 Cocoapods Plugin 那些事</center>
9
+ ---
10
+
11
+ # cocoapods-hipac
12
+ ## WHAT
13
+ cocoapods-hipac 是一个 cocoapods 的插件 gem 工具 [cocoapods-hipac | RubyGems.org | Ruby 社区 Gem 托管](https://rubygems.org/gems/cocoapods-hipac)
14
+
15
+ ### Load
16
+
17
+ cocoapods 底层基于 CLAide命令行接口框架[GitHub - CocoaPods/CLAide: A small command-line interface framework.](https://github.com/CocoaPods/CLAide),一个简单的命令行选项、命令解析器,同时提供 API,可以快速创建一个功能丰富的命令行接口
18
+
19
+ `Command::PluginManager` ,在 `claide/command/plugin_manager` 文件内
20
+
21
+ ```ruby
22
+ # @return [Array<Gem::Specification>] Loads plugins via RubyGems looking
23
+ # for files named after the `PLUGIN_PREFIX_plugin` and returns the
24
+ # specifications of the gems loaded successfully.
25
+ # Plugins are required safely.
26
+ #
27
+ def self.load_plugins(plugin_prefix)
28
+ loaded_plugins[plugin_prefix] ||=
29
+ plugin_gems_for_prefix(plugin_prefix).map do |spec, paths|
30
+ spec if safe_activate_and_require(spec, paths)
31
+ end.compact
32
+ end
33
+
34
+ # @group Helper Methods
35
+
36
+ # @return [Array<[Gem::Specification, Array<String>]>]
37
+ # Returns an array of tuples containing the specifications and
38
+ # plugin files to require for a given plugin prefix.
39
+ #
40
+ def self.plugin_gems_for_prefix(prefix)
41
+ glob = "#{prefix}_plugin#{Gem.suffix_pattern}"
42
+ Gem::Specification.latest_specs(true).map do |spec|
43
+ matches = spec.matches_for_glob(glob)
44
+ [spec, matches] unless matches.empty?
45
+ end.compact
46
+ end
47
+
48
+ # Activates the given spec and requires the given paths.
49
+ # If any exception occurs it is caught and an
50
+ # informative message is printed.
51
+ #
52
+ # @param [Gem::Specification] spec
53
+ # The spec to be activated.
54
+ #
55
+ # @param [String] paths
56
+ # The paths to require.
57
+ #
58
+ # @return [Bool] Whether activation and requiring succeeded.
59
+ #
60
+ def self.safe_activate_and_require(spec, paths)
61
+ spec.activate
62
+ paths.each { |path| require(path) }
63
+ true
64
+ rescue Exception => exception # rubocop:disable RescueException
65
+ message = "\n---------------------------------------------"
66
+ message << "\nError loading the plugin `#{spec.full_name}`.\n"
67
+ message << "\n#{exception.class} - #{exception.message}"
68
+ message << "\n#{exception.backtrace.join("\n")}"
69
+ message << "\n---------------------------------------------\n"
70
+ warn message.ansi.yellow
71
+ false
72
+ end
73
+ ```
74
+
75
+ ```ruby
76
+ # 获取最新 spec 集合
77
+ # Return the latest specs, optionally including prerelease specs if prerelease is true.
78
+ latest_specs(prerelease = false)
79
+
80
+ # 获取 gem 中匹配的文件路径
81
+ # Return all files in this gem that match for glob.
82
+ matches_for_glob(glob)
83
+
84
+ # 激活 spec,注册并将其 lib 路径添加到 $LOAD_PATH ($LOAD_PATH 环境变量存储 require 文件时查找的路径)
85
+ # Activate this spec, registering it as a loaded spec and adding it's lib paths to $LOAD_PATH. Returns true if the spec was activated, false if it was previously activated. Freaks out if there are conflicts upon activation.
86
+ activate()
87
+ ```
88
+
89
+ `loaded_plugins[plugin_prefix]`为空时,执行`plugin_gems_for_prefix` 方法,通过`latest_specs` 获取了最新的 spec ,并通过 spec 的`matches_for_glob`方法对文件进行匹配,当 spec 存在匹配`#{prefix}_plugin#{Gem.suffix_pattern}`格式的文件,则视其为 CocoaPods 插件。在拿到插件及其匹配文件后,
90
+ `safe_activate_and_require` 方法将文件加入 `$LOAD_PATH` 中并 `require` 之。
91
+
92
+
93
+ `CLAide::Command` 类会在`run` 类方法中加载所有插件
94
+ ```ruby
95
+ # @param [Array, ARGV] argv
96
+ # A list of (remaining) parameters.
97
+ #
98
+ # @return [Command] An instance of the command class that was matched by
99
+ # going through the arguments in the parameters and drilling down
100
+ # command classes.
101
+ #
102
+ def self.run(argv = [])
103
+ plugin_prefixes.each do |plugin_prefix|
104
+ PluginManager.load_plugins(plugin_prefix)
105
+ end
106
+
107
+ argv = ARGV.coerce(argv)
108
+ command = parse(argv)
109
+ ANSI.disabled = !command.ansi_output?
110
+ unless command.handle_root_options(argv)
111
+ command.validate!
112
+ command.run
113
+ end
114
+ rescue Object => exception
115
+ handle_exception(command, exception)
116
+ end
117
+ ```
118
+
119
+ ## WHY
120
+ * 简化 pod 日常的命令使用
121
+ ```shell
122
+ env t=source pod lib lint --allow-warnings --use-libraries --use-modular-headers --swift-version=5.0 --sources=git@ytgit.hipac.cn:Wireless/iOS/HipacSpecs.git,git@ytgit.hipac.cn:Wireless/ios/framework/hipacspecsfork.git --verbose
123
+ ```
124
+
125
+ ```shell
126
+ pod hipac lint
127
+ ```
128
+
129
+ * 丰富 pod 的功能、定制 Podfile DSL
130
+
131
+ ## INSTALL
132
+ `gem install cocoapods-hipac`
133
+
134
+ ## USAGE
135
+ * `pod hipac deplist` 根据 Podfile 文件对 pod 依赖分析,列出 pod 的所有依赖
136
+ * `pod hipac deptree` 根据 Podfile 文件对 pod 依赖分析,输出 podfile.lock 格式的带层级依赖
137
+ * `pod hipac depsort` 根据 Podfile 文件对 pod 依赖分析并排序,默认只对处于开发状态的 pod 排序
138
+ * `pod hipac pull` 根据 podFile 将开发状态 pod 批量更新至本地
139
+ 所有 pod 会 pull 至 podFile 所在目录的上一级
140
+ 本地没有该 pod 仓库 ,执行git clone -b
141
+ 本地有该 pod 仓库,且分支一致,执行 git stash -> git pull
142
+ 本地有该 pod 仓库,但分支不一致,执行 git stash -> git checkout branch -> git pull
143
+
144
+ ## CORE
145
+ 本插件核心是一个递归遍历 dependency 的功能,看源码的时候到了
146
+ ```ruby
147
+ def resolve_recursive_dependencies(specs)
148
+ direct_dependencies.map do |dep|
149
+ spec = specs.find { |s| s.name.eql?(dep.name) }
150
+ next dep if spec.nil? || spec.direct_dependencies.empty?
151
+
152
+ (Array(dep) + spec.resolve_recursive_dependencies(specs)).flatten
153
+
154
+ end.compact.flatten.uniq
155
+ end
156
+ ```
157
+
158
+ ## HOW
159
+ gem 工具开发很简单,通过 gemspec 文件,配置工具包的各种信息。
160
+ 由于站在 cocapods 这个巨人的肩膀上,只要用一个命令就可以初始化一个 plugin 工程。
161
+
162
+ ### dev
163
+
164
+ `pod plugins create my-plugin` 得到一份标准gem工程模板
165
+
166
+ ```
167
+ .
168
+ ├── Gemfile
169
+ ├── LICENSE.txt
170
+ ├── Podfile
171
+ ├── Pods
172
+ ├── README.md
173
+ ├── Rakefile
174
+ ├── cocoapods-hipac-0.0.6.gem
175
+ ├── cocoapods-hipac.gemspec
176
+ ├── lib
177
+ │   ├── cocoapods-hipac
178
+ │   │   ├── command
179
+ │   │   │   ├── cocoapods
180
+ │   │   │   │   ├── pod_item.rb
181
+ │   │   │   │   ├── podfile.rb
182
+ │   │   │   │   ├── source.rb
183
+ │   │   │   │   ├── specification.rb
184
+ │   │   │   │   └── tool.rb
185
+ │   │   │   ├── deplist.rb
186
+ │   │   │   ├── depsort.rb
187
+ │   │   │   ├── deptree.rb
188
+ │   │   │   ├── hipac.rb
189
+ │   │   │   └── pull.rb
190
+ │   │   ├── command.rb
191
+ │   │   └── gem_version.rb
192
+ │   ├── cocoapods-hipac.rb
193
+ │   └── cocoapods_plugin.rb
194
+ └── spec
195
+ ├── command
196
+ │   └── hipac_spec.rb
197
+ └── spec_helper.rb
198
+ ```
199
+
200
+ 先将 source 指向本地,便于打包测试`spec.files = Dir['lib/**/*']`
201
+
202
+ ### build
203
+
204
+ `gem build my-plugin.gemspec`
205
+
206
+ ### install & exec
207
+
208
+ `gem install my-plugin-0.0.1.gem`
209
+
210
+ `pod XXX`
211
+
212
+ ### publish
213
+
214
+ `gem push squid-utils-0.1.0.gem`
215
+
216
+
217
+
218
+
219
+ ## More
220
+ `PodDepGraph` :基于`pod hipac deplist` 的结果,绘制 pod 依赖关系图,这里做了一个依赖关系优化,使依赖图没那么蜘蛛网
221
+ A -> B -> C 类似这种关系,A 和 C 之间的间接依赖会被优化
222
+
223
+ ### BTW
224
+ 钉钉消息
225
+ [钉钉开发文档 自定义机器人](https://open-doc.dingtalk.com/microapp/serverapi2/qf2nxq)
226
+ [钉钉开发文档 三方系统事件通知到钉钉聊天群](https://open-doc.dingtalk.com/microapp/serverapi2/qgx3dh#-2)
227
+
228
+
229
+
230
+
231
+
232
+ ## 引用致谢
233
+ > [Guides - RubyGems Guides](https://guides.rubygems.org)
234
+ > [CocoaPods plugin开发](https://ddrccw.github.io/2018/03/30/2018-03-30-develop-cocoapods-plugin/)
235
+ > [谈谈 DSL 以及 DSL 的应用(以 CocoaPods 为例) - 简书](https://www.jianshu.com/p/8173c0a42412)
236
+ > [Cocoapods源码解析](https://myseven.github.io/2018-04-25/Cocoapods源码解析)
237
+ > [Cocoapods命令行是怎么工作的?](https://myseven.github.io/2018-04-24/Cocoapods%E5%91%BD%E4%BB%A4%E8%A1%8C%E6%98%AF%E6%80%8E%E4%B9%88%E5%B7%A5%E4%BD%9C%E7%9A%84)
@@ -0,0 +1,97 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ cocoapods-hipac (0.0.7)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ CFPropertyList (3.0.0)
10
+ activesupport (4.2.11.1)
11
+ i18n (~> 0.7)
12
+ minitest (~> 5.1)
13
+ thread_safe (~> 0.3, >= 0.3.4)
14
+ tzinfo (~> 1.1)
15
+ atomos (0.1.3)
16
+ bacon (1.2.0)
17
+ claide (1.0.2)
18
+ cocoapods (1.7.0.beta.3)
19
+ activesupport (>= 4.0.2, < 5)
20
+ claide (>= 1.0.2, < 2.0)
21
+ cocoapods-core (= 1.7.0.beta.3)
22
+ cocoapods-deintegrate (>= 1.0.3, < 2.0)
23
+ cocoapods-downloader (>= 1.2.2, < 2.0)
24
+ cocoapods-plugins (>= 1.0.0, < 2.0)
25
+ cocoapods-search (>= 1.0.0, < 2.0)
26
+ cocoapods-stats (>= 1.0.0, < 2.0)
27
+ cocoapods-trunk (>= 1.3.1, < 2.0)
28
+ cocoapods-try (>= 1.1.0, < 2.0)
29
+ colored2 (~> 3.1)
30
+ escape (~> 0.0.4)
31
+ fourflusher (>= 2.2.0, < 3.0)
32
+ gh_inspector (~> 1.0)
33
+ molinillo (~> 0.6.6)
34
+ nap (~> 1.0)
35
+ ruby-macho (~> 1.4)
36
+ xcodeproj (>= 1.8.2, < 2.0)
37
+ cocoapods-core (1.7.0.beta.3)
38
+ activesupport (>= 4.0.2, < 6)
39
+ fuzzy_match (~> 2.0.4)
40
+ nap (~> 1.0)
41
+ cocoapods-deintegrate (1.0.4)
42
+ cocoapods-downloader (1.2.2)
43
+ cocoapods-plugins (1.0.0)
44
+ nap
45
+ cocoapods-search (1.0.0)
46
+ cocoapods-stats (1.1.0)
47
+ cocoapods-trunk (1.3.1)
48
+ nap (>= 0.8, < 2.0)
49
+ netrc (~> 0.11)
50
+ cocoapods-try (1.1.0)
51
+ colored2 (3.1.2)
52
+ concurrent-ruby (1.1.5)
53
+ escape (0.0.4)
54
+ fourflusher (2.2.0)
55
+ fuzzy_match (2.0.4)
56
+ gh_inspector (1.1.3)
57
+ i18n (0.9.5)
58
+ concurrent-ruby (~> 1.0)
59
+ metaclass (0.0.4)
60
+ minitest (5.11.3)
61
+ mocha (1.2.1)
62
+ metaclass (~> 0.0.1)
63
+ mocha-on-bacon (0.2.3)
64
+ mocha (>= 0.13.0)
65
+ molinillo (0.6.6)
66
+ nanaimo (0.2.6)
67
+ nap (1.1.0)
68
+ netrc (0.11.0)
69
+ prettybacon (0.0.2)
70
+ bacon (~> 1.2)
71
+ rake (10.5.0)
72
+ ruby-macho (1.4.0)
73
+ thread_safe (0.3.6)
74
+ tzinfo (1.2.5)
75
+ thread_safe (~> 0.1)
76
+ xcodeproj (1.9.0)
77
+ CFPropertyList (>= 2.3.3, < 4.0)
78
+ atomos (~> 0.1.3)
79
+ claide (>= 1.0.2, < 2.0)
80
+ colored2 (~> 3.1)
81
+ nanaimo (~> 0.2.6)
82
+
83
+ PLATFORMS
84
+ ruby
85
+
86
+ DEPENDENCIES
87
+ bacon
88
+ bundler (~> 2.0)
89
+ cocoapods
90
+ cocoapods-hipac!
91
+ mocha
92
+ mocha-on-bacon
93
+ prettybacon
94
+ rake
95
+
96
+ BUNDLED WITH
97
+ 2.0.1
@@ -19,6 +19,6 @@ Gem::Specification.new do |spec|
19
19
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
20
  spec.require_paths = ['lib']
21
21
 
22
- spec.add_development_dependency 'bundler', '~> 1.3'
22
+ spec.add_development_dependency 'bundler', '~> 2.0'
23
23
  spec.add_development_dependency 'rake'
24
24
  end
@@ -69,16 +69,16 @@ module Pod
69
69
  sort_pods.each { |pod|
70
70
  info = ''
71
71
  info << pod.name.lstrip.rstrip
72
- info << '|'
73
- dev = temp_dev_dep_list.find { |s| s.name.eql?(pod.name) }
74
- if dev.nil?
75
- info << '0'
76
- else
77
- info << '1'
78
- if dev.external_source[:branch]
79
- info << '|' + dev.external_source[:branch]
80
- end
81
- end
72
+ # info << '|'
73
+ # dev = temp_dev_dep_list.find { |s| s.name.eql?(pod.name) }
74
+ # if dev.nil?
75
+ # info << '0'
76
+ # else
77
+ # info << '1'
78
+ # if dev.external_source[:branch]
79
+ # info << '|' + dev.external_source[:branch]
80
+ # end
81
+ # end
82
82
  UI.puts info
83
83
  }
84
84
 
@@ -2,6 +2,7 @@ require 'cocoapods-hipac/command/depsort'
2
2
  require 'cocoapods-hipac/command/pull'
3
3
  require 'cocoapods-hipac/command/deptree'
4
4
  require 'cocoapods-hipac/command/deplist'
5
+ require 'cocoapods-hipac/command/status'
5
6
 
6
7
 
7
8
  module Pod
@@ -0,0 +1,100 @@
1
+
2
+ require 'cocoapods-hipac/command/cocoapods/podfile'
3
+ require 'cocoapods-hipac/command/cocoapods/source'
4
+ require 'cocoapods-hipac/command/cocoapods/specification'
5
+ require 'cocoapods-hipac/command/cocoapods/pod_item'
6
+ require 'cocoapods-hipac/command/cocoapods/tool'
7
+
8
+
9
+ module Pod
10
+ class Command
11
+ class Hipac < Command
12
+ class Status < Hipac
13
+ self.summary = '根据 Podfile 文件输出 pod 开发状态'
14
+
15
+ self.description = <<-DESC
16
+ 根据 Podfile 文件对 pod 依赖分析,默认只对处于开发状态的 pod 排序
17
+ DESC
18
+
19
+
20
+ def initialize(argv)
21
+ @config = Pod::Config.instance
22
+ help! 'No `Podfile` found in the project directory.' if Pathname.glob('Podfile').empty?
23
+ super
24
+ end
25
+
26
+ def validate!
27
+ super
28
+ end
29
+
30
+ def run
31
+ UI.puts "pod hipac status"
32
+
33
+
34
+
35
+ UI.puts "\n\npod_dep_status_result\n\n"
36
+ UI.puts "========="
37
+
38
+ # output_all_dep(dependency_list())
39
+
40
+ # UI.puts dependency_list()
41
+
42
+
43
+
44
+ dependency_list().each { |pod|
45
+ info = ''
46
+ info << pod.name
47
+ info << '|'
48
+
49
+ if pod.external? && pod.external_source[:branch]
50
+ info << '1'
51
+ info << '|'
52
+ info << pod.external_source[:branch]
53
+
54
+ else
55
+ info << '0'
56
+ end
57
+
58
+ UI.puts info
59
+ }
60
+ UI.puts "========="
61
+
62
+
63
+ end
64
+
65
+ def output_all_dep(sort_pods)
66
+ temp_dev_dep_list = @config.podfile.dev_dependency_list
67
+
68
+ sort_pods.each { |pod|
69
+ info = ''
70
+ info << pod.name.lstrip.rstrip
71
+ info << '|'
72
+ dev = temp_dev_dep_list.find { |s| s.name.eql?(pod.name) }
73
+
74
+ if dev.nil?
75
+ info << '0'
76
+ else
77
+ info << '1'
78
+ if dev.external_source[:branch]
79
+ info << '|' + dev.external_source[:branch]
80
+ end
81
+ end
82
+ UI.puts info
83
+ }
84
+
85
+ end
86
+
87
+
88
+ def dependency_list
89
+ list = []
90
+
91
+ list = @config.podfile.all_dependency_list
92
+
93
+ list
94
+ end
95
+
96
+ end
97
+
98
+ end
99
+ end
100
+ end
@@ -1,3 +1,3 @@
1
1
  module CocoapodsHipac
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
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.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - QiYa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-11 00:00:00.000000000 Z
11
+ date: 2019-06-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.3'
19
+ version: '2.0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.3'
26
+ version: '2.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -46,7 +46,9 @@ extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
48
  - ".gitignore"
49
+ - 2019-06-03-Cocoapods Plugin.md
49
50
  - Gemfile
51
+ - Gemfile.lock
50
52
  - LICENSE.txt
51
53
  - README.md
52
54
  - Rakefile
@@ -63,6 +65,7 @@ files:
63
65
  - lib/cocoapods-hipac/command/deptree.rb
64
66
  - lib/cocoapods-hipac/command/hipac.rb
65
67
  - lib/cocoapods-hipac/command/pull.rb
68
+ - lib/cocoapods-hipac/command/status.rb
66
69
  - lib/cocoapods-hipac/gem_version.rb
67
70
  - lib/cocoapods_plugin.rb
68
71
  - spec/command/hipac_spec.rb
@@ -86,8 +89,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
86
89
  - !ruby/object:Gem::Version
87
90
  version: '0'
88
91
  requirements: []
89
- rubyforge_project:
90
- rubygems_version: 2.7.7
92
+ rubygems_version: 3.0.3
91
93
  signing_key:
92
94
  specification_version: 4
93
95
  summary: A longer description of cocoapods-hipac.