cocoapods-dist 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: c767924cd3e18cf87c96793b0ae13e5704705b60a209774969dee552616355c4
4
+ data.tar.gz: d7cc7b815165cd54a8ccd2db8ffa80b0fb25b973fc2c09327cc9263ecbb185e0
5
+ SHA512:
6
+ metadata.gz: c78f3ce502ee21c08c8e00edf4de66d42aa150c1c5fc306d0ea9eb315c34e7a723901a167a28c8b582c8b8c5d933810d8f92195233601e9ac23a5e517fbbf0e5
7
+ data.tar.gz: 2084843afa12e197aac2b989b576dc4918195523cba93331f04cbc6aa96e2e594a0a887d266dd8e76b315a5bfd75d6c2f13d94c537210d93977f2b9e169a74cf
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-dist.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) 2023 youhui <youhui@babybus.com>
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,14 @@
1
+ # cocoapods-dist
2
+
3
+
4
+
5
+ ## Installation
6
+
7
+ $ gem install cocoapods-dist
8
+
9
+ ## Usage
10
+
11
+ $ pod spec dist POD_NAME [--tag|--commit]
12
+
13
+
14
+
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,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'cocoapods-dist/gem_version.rb'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'cocoapods-dist'
8
+ spec.version = CocoapodsDist::VERSION
9
+ spec.authors = ['youhui']
10
+ spec.email = ['developer_yh@163.com']
11
+ spec.description = %q{a cocoapods plugin to display particular component outdated information In a xcode project.}
12
+ spec.summary = %q{--tag: show tags only; --commit: show all addtion commits.}
13
+ spec.homepage = 'https://github.com/ymoyao/cocoapods-dist'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_development_dependency 'bundler', '~> 1.3'
22
+ spec.add_development_dependency 'rake'
23
+ end
@@ -0,0 +1,171 @@
1
+ module Pod
2
+ class Command
3
+ class Dist < Command
4
+ include RepoUpdate
5
+ include ProjectDirectory
6
+ require 'cocoapods/command/spec'
7
+ require 'cocoapods/command/outdated.rb'
8
+ require 'cocoapods/executable.rb'
9
+
10
+ require 'cocoapods-dist/command/spec-dist.rb'
11
+ require 'cocoapods-dist/command/outdated-dist.rb'
12
+
13
+ extend Executable
14
+ executable :git
15
+
16
+ self.summary = 'a cocoapods plugin to display particular component outdated information In a xcode project.'
17
+
18
+ self.description = <<-DESC
19
+ --tag: show tags only
20
+ --commit: show all addtion commits
21
+ DESC
22
+
23
+ def self.options
24
+ [
25
+ ['--tag', 'Force running `pod repo update` before install'],
26
+ ['--commit', 'Disallow any changes to the Podfile or the Podfile.lock during installation'],
27
+ ].concat(super)
28
+ end
29
+
30
+ def initialize(argv)
31
+ @tag = argv.flag?('tag', true)
32
+ @commit = argv.flag?('commit', false)
33
+ @name = argv.shift_argument
34
+ super
35
+ end
36
+
37
+ def validate!
38
+ super
39
+ help! 'A Pod name is required.' unless @name
40
+ end
41
+
42
+ def run
43
+
44
+ validate!
45
+
46
+ #first clone module to cache dir
47
+ cloneToCache
48
+
49
+ #second
50
+ outdated = Pod::Command::Outdated.parse([])
51
+ updates = outdated.public_updates
52
+ updates = updates.select {|subArr| subArr[0] == @name} unless updates.empty?
53
+
54
+ if updates.empty?
55
+ UI.puts 'No pod updates are available.'.yellow
56
+ else
57
+ UI.section 'The color indicates what happens when you run `pod update`' do
58
+ UI.puts "#{'<green>'.green}\t - Will be updated to the newest version"
59
+ UI.puts "#{'<blue>'.blue}\t - Will be updated, but not to the newest version because of specified version in Podfile"
60
+ UI.puts "#{'<red>'.red}\t - Will not be updated because of specified version in Podfile"
61
+ UI.puts ''
62
+ end if ansi_output?
63
+ UI.section "The following pod update #{@name} are available:" do
64
+ updates.each do |(name, from_version, matching_version, to_version)|
65
+ color = :blue
66
+ if matching_version == to_version
67
+ color = :green
68
+ elsif from_version == matching_version
69
+ color = :red
70
+ end
71
+ UI.puts "- #{name} #{from_version.to_s.send(color)} -> #{matching_version.to_s.send(color)} " \
72
+ "(latest version #{to_version.to_s})" # rubocop:disable Lint/StringConversionInInterpolation
73
+
74
+ unless matching_version.version.empty? || from_version.version.empty?
75
+ if @commit
76
+ commit_sha_start = git('rev-parse',from_version).chomp
77
+ commit_sha_end = git('rev-parse',matching_version).chomp
78
+ log = git('log','--pretty=format:"%h %s"',"#{commit_sha_start}...#{commit_sha_end}").chomp
79
+ UI.puts "#{log}"
80
+ else
81
+ Dir.chdir(env_git) {
82
+ tags = (git! ['tag']).split("\n")
83
+ tags.each do |tag|
84
+ if versionGreat(tag.to_s,from_version.to_s) && versionGreatOrEqual(matching_version.to_s,tag.to_s)
85
+ commit_sha = git('rev-parse',tag).chomp
86
+ log = git('log','--pretty=format:"%s"','-n 1',commit_sha).chomp
87
+ # log = git('show','--quiet','--pretty=format:"%s"',commit_sha)
88
+ UI.puts "[#{tag}]: ".send(color) + "#{log}"
89
+ end
90
+ end
91
+ }
92
+ end
93
+ end
94
+
95
+ end
96
+ end
97
+ end
98
+ end
99
+
100
+ private
101
+
102
+ # git command
103
+ def git(*args)
104
+ Dir.chdir(env_git) { return git! args }
105
+ end
106
+
107
+ # env
108
+ def source_pod
109
+ cat = Pod::Command::Spec::Cat.parse([@name])
110
+ spec = cat.pubulic_spec_and_source_from_spce(@name,false)
111
+ source = spec.attributes_hash['source']['git']
112
+ end
113
+
114
+ def env_cache
115
+ File.join(File.expand_path('~/.cache'), 'cocoapods-dist')
116
+ end
117
+
118
+ def env_git
119
+ File.join(File.expand_path(env_cache), @name)
120
+ end
121
+
122
+ # clone
123
+ def cloneToCache
124
+ unless Dir.exist?(env_git)
125
+ repo_clone(source_pod,env_cache)
126
+ end
127
+ end
128
+
129
+ def repo_clone(source, path)
130
+ unless Dir.exist?(path)
131
+ Dir.mkdir(path)
132
+ end
133
+ UI.section("Cloning `#{source}` into `#{path}`.") do
134
+ Dir.chdir(path) { git! ['clone', source] }
135
+ end
136
+ end
137
+
138
+ # compare tags (>=)
139
+ def versionGreatOrEqual(tag1, tag2)
140
+ tags1 = tag1.split(".")
141
+ tags2 = tag2.split(".")
142
+
143
+ # Fill in the missing bits so that both tags have the same number of bits
144
+ max_length = [tags1.length, tags2.length].max
145
+ tags1 += ["0"] * (max_length - tags1.length)
146
+ tags2 += ["0"] * (max_length - tags2.length)
147
+
148
+ # Compare labels one by one from high to low
149
+ (0...max_length).each do |i|
150
+ if tags1[i].to_i > tags2[i].to_i
151
+ return true
152
+ elsif tags1[i].to_i < tags2[i].to_i
153
+ return false
154
+ end
155
+ end
156
+
157
+ # If all digits are equal, the labels are considered equal
158
+ return true
159
+ end
160
+
161
+ # compare tags (>)
162
+ def versionGreat(tag1, tag2)
163
+ result = versionGreatOrEqual(tag1,tag2)
164
+ if result == true && tag1 == tag2
165
+ return false
166
+ end
167
+ return result
168
+ end
169
+ end
170
+ end
171
+ end
@@ -0,0 +1,9 @@
1
+ module Pod
2
+ class Command
3
+ class Outdated < Command
4
+ def public_updates
5
+ updates
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,21 @@
1
+ module Pod
2
+ class Command
3
+ class Spec < Command
4
+ def pubulic_spec_and_source_from_spce(spec, version_filter = false)
5
+ sets = config.sources_manager.search_by_name(spec)
6
+
7
+ if sets.count == 1
8
+ set = sets.first
9
+ elsif sets.map(&:name).include?(spec)
10
+ set = sets.find { |s| s.name == spec }
11
+ else
12
+ names = sets.map(&:name) * ', '
13
+ raise Informative, "More than one spec found for '#{spec}':\n#{names}"
14
+ end
15
+
16
+ best_spec, spec_source = spec_and_source_from_set(set)
17
+ best_spec
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1 @@
1
+ require 'cocoapods-dist/command/dist'
@@ -0,0 +1,3 @@
1
+ module CocoapodsDist
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1 @@
1
+ require 'cocoapods-dist/gem_version'
@@ -0,0 +1 @@
1
+ require 'cocoapods-dist/command'
@@ -0,0 +1,12 @@
1
+ require File.expand_path('../../spec_helper', __FILE__)
2
+
3
+ module Pod
4
+ describe Command::Dist do
5
+ describe 'CLAide' do
6
+ it 'registers it self' do
7
+ Command.parse(%w{ dist }).should.be.instance_of Command::Dist
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,89 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cocoapods-dist
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - youhui
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2023-06-16 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 cocoapods plugin to display particular component outdated information
42
+ In a xcode project.
43
+ email:
44
+ - developer_yh@163.com
45
+ executables: []
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - ".gitignore"
50
+ - Gemfile
51
+ - LICENSE.txt
52
+ - README.md
53
+ - Rakefile
54
+ - cocoapods-dist.gemspec
55
+ - lib/cocoapods-dist.rb
56
+ - lib/cocoapods-dist/command.rb
57
+ - lib/cocoapods-dist/command/dist.rb
58
+ - lib/cocoapods-dist/command/outdated-dist.rb
59
+ - lib/cocoapods-dist/command/spec-dist.rb
60
+ - lib/cocoapods-dist/gem_version.rb
61
+ - lib/cocoapods_plugin.rb
62
+ - spec/command/dist_spec.rb
63
+ - spec/spec_helper.rb
64
+ homepage: https://github.com/ymoyao/cocoapods-dist
65
+ licenses:
66
+ - MIT
67
+ metadata: {}
68
+ post_install_message:
69
+ rdoc_options: []
70
+ require_paths:
71
+ - lib
72
+ required_ruby_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ required_rubygems_version: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ requirements: []
83
+ rubygems_version: 3.1.2
84
+ signing_key:
85
+ specification_version: 4
86
+ summary: "--tag: show tags only; --commit: show all addtion commits."
87
+ test_files:
88
+ - spec/command/dist_spec.rb
89
+ - spec/spec_helper.rb