getv 1.5.0 → 1.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -6
- data/exe/getv +33 -4
- data/lib/getv/package.rb +39 -13
- data/lib/getv/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d49b33dd0cac92da670d6e87cd932f4fbd60b6cb5d1db7f9ea2448a295f1f9b5
|
4
|
+
data.tar.gz: c8d460259782dbd03a353f79e7be1cee0d1e1f65124f06e04084931bcd880fad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef3b8cdbf5e974ff3c1663f3ec46eabc8b894aaea5e5f082ac5aa4c6d82d4c7e2ff3134cbc4e56f0da4fafe7eafb483eb0241d611b8d6b65370e50e8a66a86c8
|
7
|
+
data.tar.gz: b641600ab4ba600a5b337b06036c7779c9d89520cd11a5c4a38c1665073d082b7cd056120e417c8acf597ba2bb773798f8cd53c230635191208e89133f0d674d
|
data/README.md
CHANGED
@@ -39,15 +39,16 @@ SYNOPSIS
|
|
39
39
|
|
40
40
|
|
41
41
|
VERSION
|
42
|
-
1.
|
42
|
+
1.7.0
|
43
43
|
|
44
44
|
|
45
45
|
|
46
46
|
GLOBAL OPTIONS
|
47
|
-
--help
|
48
|
-
-j, --json
|
49
|
-
-l, --latest
|
50
|
-
--
|
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.
|
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>'
|
53
|
-
c.flag %i[url], desc: '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
@@ -9,11 +9,11 @@ module Getv
|
|
9
9
|
@name = name
|
10
10
|
case name
|
11
11
|
when /rubygem-.*/
|
12
|
-
opts = {
|
12
|
+
opts = { type: 'gem' }.merge(opts)
|
13
13
|
when /nodejs-.*/
|
14
|
-
opts = {
|
14
|
+
opts = { type: 'npm' }.merge(opts)
|
15
15
|
when /python.*-.*/
|
16
|
-
opts = {
|
16
|
+
opts = { type: 'pypi' }.merge(opts)
|
17
17
|
end
|
18
18
|
if opts[:type] == 'github_commit'
|
19
19
|
opts = {
|
@@ -33,23 +33,37 @@ 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 = {
|
42
|
-
|
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 = {
|
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'
|
50
64
|
opts = { npm: name[/nodejs-(.*)/, 1] || name }.merge(opts)
|
51
65
|
when 'pypi'
|
52
|
-
opts = {
|
66
|
+
opts = { pypi: name[/python.*-(.*)/, 1] || name }.merge(opts)
|
53
67
|
end
|
54
68
|
@opts = opts
|
55
69
|
end
|
@@ -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
|
-
|
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(name, []).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
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.
|
4
|
+
version: 1.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- harbottle
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-02-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gli
|
@@ -166,7 +166,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
166
166
|
- !ruby/object:Gem::Version
|
167
167
|
version: '0'
|
168
168
|
requirements: []
|
169
|
-
rubygems_version: 3.
|
169
|
+
rubygems_version: 3.1.2
|
170
170
|
signing_key:
|
171
171
|
specification_version: 4
|
172
172
|
summary: Pull package version numbers from the web in various ways.
|