cocoapods-hipac 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6f269935ce593da1dafc4fafb74856901770cc26
4
+ data.tar.gz: 992de1c2dfac9159693762eefc388dfdf803693c
5
+ SHA512:
6
+ metadata.gz: d4eb0ae2586846ffd812003734c1fe13223c9fafdd9b0b7122a5ab594e6d6b6e7325e5687af638ba3be0efa749b8e3e81fbde9d0c0db69df3b7db0b5d42da2c0
7
+ data.tar.gz: 500dc66f069554caa5ff15d47ecee418787ab124bbfc56e16a8bace75c45f87611b3f4ff10108e410d80cde5d2a7c6a3d20d539fd4a514d0edafa7fa9d82e0b9
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ .DS_Store
2
+ pkg
3
+ .idea/
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in cocoapods-hipac.gemspec
4
+ gemspec
5
+
6
+ group :development do
7
+ gem 'cocoapods'
8
+
9
+ gem 'mocha'
10
+ gem 'bacon'
11
+ gem 'mocha-on-bacon'
12
+ gem 'prettybacon'
13
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2019 Demo <DEMO@JL.Local>
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,4 @@
1
+ hipac cocoapods-plugin
2
+ 为 pod 提供二级命令 hipac
3
+ ## usage
4
+ `pod hipac sort` 根据 podFile 分析依赖
data/Rakefile ADDED
@@ -0,0 +1,13 @@
1
+ require 'bundler/gem_tasks'
2
+
3
+ def specs(dir)
4
+ FileList["spec/#{dir}/*_spec.rb"].shuffle.join(' ')
5
+ end
6
+
7
+ desc 'Runs all the specs'
8
+ task :specs do
9
+ sh "bundle exec bacon #{specs('**')}"
10
+ end
11
+
12
+ task :default => :specs
13
+
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'cocoapods-hipac/gem_version.rb'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'cocoapods-hipac'
8
+ spec.version = CocoapodsHipac::VERSION
9
+ spec.authors = ['QiYa']
10
+ spec.email = ['jl.0130@hotmail.com']
11
+ spec.description = %q{A short description of cocoapods-hipac.}
12
+ spec.summary = %q{A longer description of cocoapods-hipac.}
13
+ spec.homepage = 'https://github.com/EXAMPLE/cocoapods-hipac'
14
+ spec.license = 'MIT'
15
+
16
+ # spec.files = Dir['lib/**/*']
17
+ spec.files = `git ls-files`.split($/)
18
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
+ spec.require_paths = ['lib']
21
+
22
+ spec.add_development_dependency 'bundler', '~> 1.3'
23
+ spec.add_development_dependency 'rake'
24
+ end
@@ -0,0 +1,19 @@
1
+ require 'cocoapods'
2
+
3
+ module Pod
4
+ class Podfile
5
+ def dev_dependency_list
6
+
7
+ main_target_definition_list = target_definition_list.reject do |target_definition|
8
+ target_definition.name.end_with?('Tests') || target_definition.name.end_with?('Widget')
9
+ end
10
+
11
+ dev_dependency_list = main_target_definition_list.flat_map(&:dependencies).uniq.select do |dependency|
12
+ dependency.external? && dependency.external_source[:tag].nil?
13
+ end
14
+
15
+ dev_dependency_list
16
+
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,28 @@
1
+ require 'cocoapods'
2
+
3
+ module Pod
4
+ class Source
5
+ def last_specs
6
+ pods.map do |pod|
7
+ versions = versions(pod)
8
+ if versions
9
+ version = versions.sort.last
10
+ spec = specification(pod, version)
11
+ end
12
+ end.compact
13
+ end
14
+
15
+ class Manager
16
+ HIPAC_SOURCE_URL = 'git@git.hipac.cn:Wireless/iOS/HipacSpecs.git'.freeze
17
+
18
+ def last_specs_with_source_name_or_url(name_or_url)
19
+ source = source_with_name_or_url(name_or_url)
20
+ source.last_specs if source
21
+ end
22
+
23
+ def default_source
24
+ source_with_name_or_url(HIPAC_SOURCE_URL)
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,39 @@
1
+ require 'cocoapods'
2
+
3
+ module Pod
4
+ class Specification
5
+ module RecursiveDependency
6
+ def recursive_dependencies(all_specs)
7
+ @recursive_dependencies ||= begin
8
+ resolve_recursive_dependencies(all_specs)
9
+ end
10
+ end
11
+
12
+ def direct_dependencies
13
+ @direct_dependencies ||= begin
14
+ direct_value('dependencies')
15
+ end
16
+ end
17
+
18
+ protected
19
+ def direct_value(name, platform = :ios)
20
+ subspec_consumers = recursive_subspecs.select { |s| s.supported_on_platform?(platform) }
21
+ .map { |s| s.consumer(platform) }
22
+ .uniq
23
+ value = (Array(consumer(platform)) + subspec_consumers).map { |c| c.send(name) }.flatten.uniq
24
+ value
25
+ end
26
+
27
+ def resolve_recursive_dependencies(specs)
28
+ direct_dependencies.map do |dep|
29
+ spec = specs.find { |s| s.name == dep.name }
30
+ next dep if spec.nil? || spec.direct_dependencies.empty?
31
+
32
+ (Array(dep) + spec.resolve_recursive_dependencies(specs)).flatten
33
+ end.compact.flatten.uniq
34
+ end
35
+ end
36
+
37
+ include Pod::Specification::RecursiveDependency
38
+ end
39
+ end
@@ -0,0 +1,18 @@
1
+ class PodItem
2
+ attr_accessor :name
3
+ attr_accessor :external_dependency_names
4
+ attr_accessor :dependency
5
+ attr_accessor :spec
6
+
7
+ def initialize(name)
8
+ @name = name
9
+ end
10
+
11
+ def to_s
12
+ name
13
+ end
14
+
15
+ def inspect
16
+ name
17
+ end
18
+ end
@@ -0,0 +1,118 @@
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/depsort/pod_item'
5
+
6
+
7
+ module Pod
8
+ class Command
9
+ class Hipac < Command
10
+ class Depsort < Hipac
11
+ self.summary = '根据 Podfile 文件对 pod 依赖分析'
12
+
13
+ self.description = <<-DESC
14
+ 根据 Podfile 文件对 pod 依赖分析
15
+ DESC
16
+
17
+ def initialize(argv)
18
+ @config = Pod::Config.instance
19
+ help! 'No `Podfile` found in the project directory.' if Pathname.glob('Podfile').empty?
20
+ super
21
+ end
22
+
23
+ def validate!
24
+ super
25
+ end
26
+
27
+ def run
28
+ UI.puts "pod hipac depsort"
29
+
30
+ group_pods_dep(dev_dependency_list(), reference_spec_list())
31
+
32
+ if @grouped_pods
33
+
34
+ sort_pods = []
35
+ @grouped_pods.each do |group|
36
+ group.each do |pod|
37
+ display = pod.name.dup
38
+ if pod.external_dependency_names.any?
39
+ pod.external_dependency_names.each do |name|
40
+ display << "\n- #{name}"
41
+ end
42
+ end
43
+ display << "\n\n"
44
+ puts display
45
+ sort_pods << pod
46
+ end
47
+ end
48
+
49
+ sort_pods.sort_by! do |pod|
50
+ pod.external_dependency_names.length
51
+ end
52
+
53
+ UI.puts sort_pods
54
+ else
55
+ puts '没有未依赖正式版本组件.'
56
+ end
57
+ end
58
+
59
+ def dev_dependency_list
60
+ @config.podfile.dev_dependency_list
61
+ end
62
+
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
78
+ end
79
+
80
+ def group_pods_dep(dev_dependency_list, reference_spec_list)
81
+ result = []
82
+
83
+ dev_dependency_name_list = dev_dependency_list.map(&:name)
84
+
85
+ dev_specs = reference_spec_list.select do |spec|
86
+ dev_dependency_name_list.include?(spec.name)
87
+ end
88
+
89
+ while dev_specs.length > 0
90
+ pods = []
91
+ dev_specs.each do |spec|
92
+ dependency_names = spec.recursive_dependencies(reference_spec_list).map { |dep| dep.name }
93
+ dev_name = spec.name
94
+
95
+ if dev_specs.select { |spec| dependency_names.include?(spec.name) }.empty?
96
+ pod = PodItem.new(dev_name)
97
+ pod.spec = reference_spec_list.find { |spec| spec.name == dev_name }
98
+ pod.dependency = dev_dependency_list.find { |dep| dep.name == dev_name }
99
+ pod.external_dependency_names = dependency_names.select { |name| dev_dependency_name_list.include?(name) }
100
+ pods << pod
101
+ end
102
+ end
103
+ dev_specs = dev_specs.reject do |spec|
104
+ pods.select { |pod| pod.name == spec.name }.any?
105
+ end
106
+ result << pods
107
+ end
108
+
109
+ @grouped_pods = result
110
+ @grouped_pods
111
+
112
+ end
113
+
114
+ end
115
+
116
+ end
117
+ end
118
+ end
@@ -0,0 +1,35 @@
1
+ require 'cocoapods-hipac/command/depsort'
2
+ require 'cocoapods-hipac/command/pull'
3
+
4
+
5
+ module Pod
6
+ class Command
7
+ # This is an example of a cocoapods plugin adding a top-level subcommand
8
+ # to the 'pod' command.
9
+ #
10
+ # You can also create subcommands of existing or new commands. Say you
11
+ # wanted to add a subcommand to `list` to show newly deprecated pods,
12
+ # (e.g. `pod list deprecated`), there are a few things that would need
13
+ # to change.
14
+ #
15
+ # - move this file to `lib/pod/command/list/deprecated.rb` and update
16
+ # the class to exist in the the Pod::Command::List namespace
17
+ # - change this class to extend from `List` instead of `Command`. This
18
+ # tells the plugin system that it is a subcommand of `list`.
19
+ # - edit `lib/cocoapods_plugins.rb` to require this file
20
+ #
21
+ # @todo Create a PR to add your plugin to CocoaPods/cocoapods.org
22
+ # in the `plugins.json` file, once your plugin is released.
23
+ #
24
+ class Hipac < Command
25
+ self.summary = 'Short description of cocoapods-hipac.'
26
+
27
+ self.description = <<-DESC
28
+ Longer description of cocoapods-hipac.
29
+ DESC
30
+
31
+ self.abstract_command = true
32
+
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,77 @@
1
+ require 'cocoapods-hipac/command/cocoapods/podfile'
2
+ require 'cocoapods-hipac/command/cocoapods/source'
3
+ require 'fileutils'
4
+
5
+ module Pod
6
+ class Command
7
+ class Hipac < Command
8
+ class Pull < Hipac
9
+ self.summary = '根据 Podfile 更新本地 pod'
10
+
11
+ self.description = <<-DESC
12
+ 根据 Podfile 更新本地 pod
13
+ DESC
14
+
15
+ # 运行路径
16
+ ROOT_DIR = Dir::pwd
17
+ # 执行拉取 根路径
18
+ PULL_ROOT_DIR = ROOT_DIR + '/../'
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 pull"
32
+ dev_dependency_list().each do | pod |
33
+ Dir::chdir(PULL_ROOT_DIR)
34
+ pod_dir = PULL_ROOT_DIR+pod.name
35
+
36
+ UI.puts pod_dir
37
+
38
+ if Dir::glob(pod_dir).length == 0
39
+ clone_command = "git clone -b #{pod.external_source[:branch]} #{pod.external_source[:git]}"
40
+ UI.puts clone_command
41
+ system clone_command
42
+ else
43
+ Dir::chdir(pod_dir)
44
+ system 'git remote update'
45
+
46
+ local_branch = `git rev-parse --abbrev-ref HEAD`
47
+ local_branch = local_branch.lstrip.rstrip
48
+
49
+ `git stash`
50
+
51
+ pull_command = "git pull origin #{pod.external_source[:branch]}"
52
+
53
+ if local_branch.eql?(pod.external_source[:branch])
54
+ UI.puts pull_command
55
+ system pull_command
56
+ else
57
+ checkout_command = "git checkout #{pod.external_source[:branch]}"
58
+ UI.puts checkout_command
59
+ system checkout_command
60
+ system pull_command
61
+ end
62
+
63
+ end
64
+ end
65
+
66
+
67
+ end
68
+
69
+ def dev_dependency_list
70
+ @config.podfile.dev_dependency_list
71
+ end
72
+
73
+ end
74
+
75
+ end
76
+ end
77
+ end
@@ -0,0 +1 @@
1
+ require 'cocoapods-hipac/command/hipac'
@@ -0,0 +1,3 @@
1
+ module CocoapodsHipac
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1 @@
1
+ require 'cocoapods-hipac/gem_version'
@@ -0,0 +1 @@
1
+ require 'cocoapods-hipac/command'
@@ -0,0 +1,12 @@
1
+ require File.expand_path('../../spec_helper', __FILE__)
2
+
3
+ module Pod
4
+ describe Command::Hipac do
5
+ describe 'CLAide' do
6
+ it 'registers it self' do
7
+ Command.parse(%w{ hipac }).should.be.instance_of Command::Hipac
8
+ end
9
+ end
10
+ end
11
+ end
12
+
@@ -0,0 +1,50 @@
1
+ require 'pathname'
2
+ ROOT = Pathname.new(File.expand_path('../../', __FILE__))
3
+ $:.unshift((ROOT + 'lib').to_s)
4
+ $:.unshift((ROOT + 'spec').to_s)
5
+
6
+ require 'bundler/setup'
7
+ require 'bacon'
8
+ require 'mocha-on-bacon'
9
+ require 'pretty_bacon'
10
+ require 'pathname'
11
+ require 'cocoapods'
12
+
13
+ Mocha::Configuration.prevent(:stubbing_non_existent_method)
14
+
15
+ require 'cocoapods_plugin'
16
+
17
+ #-----------------------------------------------------------------------------#
18
+
19
+ module Pod
20
+
21
+ # Disable the wrapping so the output is deterministic in the tests.
22
+ #
23
+ UI.disable_wrap = true
24
+
25
+ # Redirects the messages to an internal store.
26
+ #
27
+ module UI
28
+ @output = ''
29
+ @warnings = ''
30
+
31
+ class << self
32
+ attr_accessor :output
33
+ attr_accessor :warnings
34
+
35
+ def puts(message = '')
36
+ @output << "#{message}\n"
37
+ end
38
+
39
+ def warn(message = '', actions = [])
40
+ @warnings << "#{message}\n"
41
+ end
42
+
43
+ def print(message)
44
+ @output << message
45
+ end
46
+ end
47
+ end
48
+ end
49
+
50
+ #-----------------------------------------------------------------------------#
metadata ADDED
@@ -0,0 +1,93 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cocoapods-hipac
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - QiYa
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-03-01 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-hipac.
42
+ email:
43
+ - jl.0130@hotmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - Gemfile
50
+ - LICENSE.txt
51
+ - README.md
52
+ - Rakefile
53
+ - cocoapods-hipac.gemspec
54
+ - lib/cocoapods-hipac.rb
55
+ - lib/cocoapods-hipac/command.rb
56
+ - lib/cocoapods-hipac/command/cocoapods/podfile.rb
57
+ - lib/cocoapods-hipac/command/cocoapods/source.rb
58
+ - lib/cocoapods-hipac/command/cocoapods/specification.rb
59
+ - lib/cocoapods-hipac/command/depsort.rb
60
+ - lib/cocoapods-hipac/command/depsort/pod_item.rb
61
+ - lib/cocoapods-hipac/command/hipac.rb
62
+ - lib/cocoapods-hipac/command/pull.rb
63
+ - lib/cocoapods-hipac/gem_version.rb
64
+ - lib/cocoapods_plugin.rb
65
+ - spec/command/hipac_spec.rb
66
+ - spec/spec_helper.rb
67
+ homepage: https://github.com/EXAMPLE/cocoapods-hipac
68
+ licenses:
69
+ - MIT
70
+ metadata: {}
71
+ post_install_message:
72
+ rdoc_options: []
73
+ require_paths:
74
+ - lib
75
+ required_ruby_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ requirements: []
86
+ rubyforge_project:
87
+ rubygems_version: 2.6.13
88
+ signing_key:
89
+ specification_version: 4
90
+ summary: A longer description of cocoapods-hipac.
91
+ test_files:
92
+ - spec/command/hipac_spec.rb
93
+ - spec/spec_helper.rb