getv 1.5.1 → 1.7.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '089dcf7c1b77a594ef0d7362f8d64f9f1df0ac6a8642947c3448299bc21e6680'
4
- data.tar.gz: f890fce6a6fe69416ddfee40cda03a1cf28ee4c70c88c04352712f8d9d373422
3
+ metadata.gz: 02f4118cffd6bd28b8c54d987599cab98c37f8143ded1478979d7ff98833aa16
4
+ data.tar.gz: 92f7af5c1c92e2d4d30441f365b5310f9af314b9986e0b3a00f6f8552e158c6a
5
5
  SHA512:
6
- metadata.gz: 4d282b8cf6471125466a80e024e47b4346d2a2be3dc80a7c0ff7e31e60fc25f0efbfc32d2068ed58dabb2f3da862ede4519217b83f2603eb78bedd7367bb4f51
7
- data.tar.gz: 1dc7d16a64011dca99f288001ff787c99efe82ee4b096955fd5f44913b6a5c669817bceab5e001acf94bacdaea19db356f36ec9536232a19dd2d053c9ca3134f
6
+ metadata.gz: 67a3261c969c484cd75f4cab1390842534188868124de028034c435c6647f939a0524f8f8063fc5b7a6dd8eeb95e83eaac91b6e150e645cac0bcbcdb5bc6a0fb
7
+ data.tar.gz: 0fa62737d1e826d3544fa13fc4410dcc824b593105177481d50673edfb68dc26a196ba8e54642862bc0243a88fc5a0a196aa85320d586681a642f5b064e3e3a6
data/README.md CHANGED
@@ -39,15 +39,16 @@ SYNOPSIS
39
39
 
40
40
 
41
41
  VERSION
42
- 1.5.0
42
+ 1.7.0
43
43
 
44
44
 
45
45
 
46
46
  GLOBAL OPTIONS
47
- --help - Show this message
48
- -j, --json - Output in json
49
- -l, --latest - Latest version
50
- --version - Display the program version
47
+ --help - Show this message
48
+ -j, --json - Output in json
49
+ -l, --latest - Latest version
50
+ -p, --proxy=arg - Web proxy (default: none)
51
+ --version - Display the program version
51
52
 
52
53
 
53
54
 
@@ -58,6 +59,7 @@ COMMANDS
58
59
  github_commit - Get package versions from GitHub commits
59
60
  github_release - Get package versions from GitHub releases
60
61
  github_tag - Get package versions from GitHub tags
62
+ helm - Get package versions from a Helm chart repository
61
63
  help - Shows a list of commands or help for one command
62
64
  index - Get package versions from web page of links
63
65
  npm - Get package versions from npm at registry.npmjs.org
@@ -70,7 +72,7 @@ Show the latest available version of the `getv` gem:
70
72
 
71
73
  ```console
72
74
  $ getv --latest gem getv
73
- 1.5.0
75
+ 1.7.0
74
76
  ```
75
77
 
76
78
  Show all `dep` GitHub release versions in JSON:
data/exe/getv CHANGED
@@ -38,7 +38,7 @@ class App # rubocop:disable Metrics/ClassLength
38
38
 
39
39
  desc 'Get package versions from a Docker or OCI container image registry'
40
40
  arg_name 'package_name'
41
- command :docker do |c|
41
+ command :docker do |c| # rubocop:disable Metrics/BlockLength
42
42
  defaults = (Getv::Package.new 'name', type: c.name.to_s).opts
43
43
  c.flag %i[select_search], desc: 'Regex version selection search', default_value: defaults[:select_search]
44
44
  c.flag %i[select_replace], desc: 'Regex version selection replace', default_value: defaults[:select_replace]
@@ -47,10 +47,11 @@ class App # rubocop:disable Metrics/ClassLength
47
47
  c.flag %i[semantic_select], desc: 'Semantic version selection (comma delimited)',
48
48
  default_value: defaults[:semantic_select]
49
49
  c.flag %i[owner], desc: 'Repository owner',
50
- default_value: "'<owner>' if package_name is in format '<owner>/<repo>', otherwise just package_name" # rubocop:disable Layout/LineLength
50
+ default_value: "'<owner>' if package_name is in format '<registry>/<owner>/<repo>' or '<owner>/<repo>', otherwise just package_name" # rubocop:disable Layout/LineLength
51
51
  c.flag %i[repo], desc: 'Repository name',
52
- default_value: "'<repo>' if package_name is in format '<owner>/<repo>', otherwise just package_name" # rubocop:disable Layout/LineLength
53
- c.flag %i[url], desc: 'URL', default_value: defaults[:url]
52
+ default_value: "'<repo>' if package_name is in format '<registry>/<owner>/<repo>' or <owner>/<repo>, otherwise just package_name" # rubocop:disable Layout/LineLength
53
+ c.flag %i[url], desc: 'URL',
54
+ default_value: "'https://<registry>' if package_name is in format '<registry>/<owner>/<repo>', otherwise #{defaults[:url]}" # rubocop:disable Layout/LineLength
54
55
  c.flag %i[user], desc: 'Username', default_value: defaults[:user]
55
56
  c.flag %i[password], desc: 'Password', default_value: defaults[:password]
56
57
  c.action do |global_options, options, args|
@@ -195,6 +196,34 @@ class App # rubocop:disable Metrics/ClassLength
195
196
  end
196
197
  end
197
198
 
199
+ desc 'Get package versions from a Helm chart repository'
200
+ arg_name 'package_name'
201
+ command :helm do |c|
202
+ defaults = (Getv::Package.new 'name', type: c.name.to_s).opts
203
+ c.flag %i[select_search], desc: 'Regex version selection search', default_value: defaults[:select_search]
204
+ c.flag %i[select_replace], desc: 'Regex version selection replace', default_value: defaults[:select_replace]
205
+ c.flag %i[reject], desc: 'Regex version rejection', default_value: defaults[:reject]
206
+ c.switch %i[invalid_versions], desc: 'Include invalid semantic versions', negatable: false, default_value: false
207
+ c.flag %i[semantic_select], desc: 'Semantic version selection (comma delimited)',
208
+ default_value: defaults[:semantic_select]
209
+ c.flag %i[chart], desc: 'Chart name', default_value: 'package_name'
210
+ c.flag %i[url], desc: 'URL', default_value: defaults[:url]
211
+ c.flag %i[user], desc: 'Username', default_value: defaults[:user]
212
+ c.flag %i[password], desc: 'Password', default_value: defaults[:password]
213
+ c.action do |global_options, options, args|
214
+ help_now! unless args.size == 1
215
+
216
+ opts = global_options.merge(options)
217
+ opts = opts.slice :select_search, :select_replace, :reject, :semantic_only, :semantic_select, :chart, :url,
218
+ :user, :password, :proxy
219
+ opts = opts.delete_if { |k, v| v.nil? || v == c.flags[k].default_value }
220
+ opts[:semantic_only] = !options[:invalid_versions]
221
+ opts[:semantic_select] = opts[:semantic_select].split(',') unless opts.fetch(:semantic_select, nil).nil?
222
+ package = Getv::Package.new args[0], { type: c.name.to_s }.merge(opts)
223
+ Getv::Cli.output(package, latest: global_options[:latest], json: global_options[:json])
224
+ end
225
+ end
226
+
198
227
  desc 'Get package versions from web page of links'
199
228
  arg_name 'package_name'
200
229
  command :index do |c|
data/lib/getv/package.rb CHANGED
@@ -33,17 +33,31 @@ module Getv
33
33
  versions: nil,
34
34
  latest_version: nil
35
35
  }.merge(opts)
36
- if (opts[:type] == 'docker' || opts[:type] =~ /github.*/) && (name.count('/') == 1)
37
- opts = { owner: name.split('/')[0], repo: name.split('/')[1] }.merge(opts)
38
- end
39
36
  case opts[:type]
40
37
  when 'docker'
41
- opts = { owner: 'library', repo: name, url: 'https://registry.hub.docker.com', user: nil,
42
- password: nil }.merge(opts)
38
+ opts = { user: nil, password: nil }.merge(opts)
39
+ opts = case name.count('/')
40
+ when 0
41
+ { owner: 'library', repo: name, url: 'https://registry.hub.docker.com' }.merge(opts)
42
+ when 1
43
+ { owner: name.split('/')[0], repo: name.split('/')[1],
44
+ url: 'https://registry.hub.docker.com' }.merge(opts)
45
+ else
46
+ { owner: name.split('/')[1], repo: name.split('/')[2..-1].join('/'),
47
+ url: "https://#{name.split('/')[0]}" }.merge(opts)
48
+ end
43
49
  when 'gem'
44
50
  opts = { gem: name[/rubygem-(.*)/, 1] || name }.merge(opts)
45
51
  when /github.*/
46
- opts = { owner: name, repo: name, token: nil }.merge(opts)
52
+ opts = { token: nil }.merge(opts)
53
+ opts = case name.count('/')
54
+ when 1
55
+ { owner: name.split('/')[0], repo: name.split('/')[1] }.merge(opts)
56
+ else
57
+ { owner: name, repo: name }.merge(opts)
58
+ end
59
+ when 'helm'
60
+ opts = { chart: name, url: nil, user: nil, password: nil }.merge(opts)
47
61
  when 'index'
48
62
  opts = { link: 'content' }.merge(opts)
49
63
  when 'npm'
@@ -91,12 +105,17 @@ module Getv
91
105
 
92
106
  private
93
107
 
94
- def get(url)
108
+ def get(url) # rubocop:disable Metrics/AbcSize
95
109
  require 'rest-client'
96
- RestClient::Request.execute(method: :get, url: url, proxy: opts[:proxy]).body
110
+ if opts[:user] && opts[:password]
111
+ RestClient::Request.execute(method: :get, url: url, proxy: opts[:proxy], user: opts[:user],
112
+ password: opts[:password]).body
113
+ else
114
+ RestClient::Request.execute(method: :get, url: url, proxy: opts[:proxy]).body
115
+ end
97
116
  end
98
117
 
99
- def versions_using_docker # rubocop:disable Metrics/AbcSize
118
+ def versions_using_docker # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
100
119
  require 'docker_registry2'
101
120
  docker_opts = {}
102
121
  docker_opts[:http_options] = { proxy: opts[:proxy] } unless opts[:proxy].nil?
@@ -106,6 +125,8 @@ module Getv
106
125
  end
107
126
  docker = DockerRegistry2.connect(opts[:url], docker_opts)
108
127
  docker.tags("#{opts[:owner]}/#{opts[:repo]}")['tags']
128
+ rescue DockerRegistry2::NotFound
129
+ []
109
130
  end
110
131
 
111
132
  def versions_using_gem
@@ -146,6 +167,11 @@ module Getv
146
167
  end
147
168
  end
148
169
 
170
+ def versions_using_helm
171
+ require 'yaml'
172
+ YAML.safe_load(get("#{opts[:url]}/index.yaml")).fetch('entries', {}).fetch(opts[:chart], []).map { |e| e['version'] }
173
+ end
174
+
149
175
  def versions_using_index
150
176
  require 'nokogiri'
151
177
  Nokogiri::HTML(get(opts[:url])).css('a').map do |a|
data/lib/getv/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Getv
4
- VERSION = '1.5.1'
4
+ VERSION = '1.7.1'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: getv
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.1
4
+ version: 1.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - harbottle
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-01-30 00:00:00.000000000 Z
11
+ date: 2022-02-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gli
@@ -151,7 +151,7 @@ metadata:
151
151
  homepage_uri: https://github.com/liger1978/getv
152
152
  source_code_uri: https://github.com/liger1978/getv
153
153
  changelog_uri: https://github.com/liger1978/getv
154
- post_install_message:
154
+ post_install_message:
155
155
  rdoc_options: []
156
156
  require_paths:
157
157
  - lib
@@ -166,8 +166,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
166
166
  - !ruby/object:Gem::Version
167
167
  version: '0'
168
168
  requirements: []
169
- rubygems_version: 3.2.22
170
- signing_key:
169
+ rubygems_version: 3.1.2
170
+ signing_key:
171
171
  specification_version: 4
172
172
  summary: Pull package version numbers from the web in various ways.
173
173
  test_files: []