getv 1.4.0 → 1.5.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 +5 -5
- data/exe/getv +21 -13
- data/lib/getv/package.rb +22 -25
- data/lib/getv/version.rb +1 -1
- metadata +22 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eecf3794e494d199c44abee7e7c1813bf4cdb1ba4a3df0b1e84de43933c4b769
|
4
|
+
data.tar.gz: df3ef755f0275ba9dea7b06181156391d82a3dd456677d27eb2bc7849f8e2d30
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3cfe705be77258d3ad2fcef502d32a788134fbd6ef574725d1a2b8154b179b2652e6b6db060503d4b568c0e1524c602f726afdc275cf948f7fa6ee10c3d5c023
|
7
|
+
data.tar.gz: 84f5e7c13dd5e875f32b84203e1cba6aaadb8caa2919fd5ed54e20ce413ffa9ca0a73971ed812d08096b03e64d24bea085c0319dab66216932333ef77f84c358
|
data/README.md
CHANGED
@@ -39,7 +39,7 @@ SYNOPSIS
|
|
39
39
|
|
40
40
|
|
41
41
|
VERSION
|
42
|
-
1.
|
42
|
+
1.5.0
|
43
43
|
|
44
44
|
|
45
45
|
|
@@ -55,9 +55,9 @@ COMMANDS
|
|
55
55
|
docker - Get package versions from a Docker or OCI container image registry
|
56
56
|
gem - Get package versions from RubyGems.org
|
57
57
|
get - Get package versions from text file URL
|
58
|
-
github_commit - Get package versions from GitHub commits
|
59
|
-
github_release - Get package versions from GitHub releases
|
60
|
-
github_tag - Get package versions from GitHub tags
|
58
|
+
github_commit - Get package versions from GitHub commits
|
59
|
+
github_release - Get package versions from GitHub releases
|
60
|
+
github_tag - Get package versions from GitHub tags
|
61
61
|
help - Shows a list of commands or help for one command
|
62
62
|
index - Get package versions from web page of links
|
63
63
|
npm - Get package versions from npm at registry.npmjs.org
|
@@ -70,7 +70,7 @@ Show the latest available version of the `getv` gem:
|
|
70
70
|
|
71
71
|
```console
|
72
72
|
$ getv --latest gem getv
|
73
|
-
1.
|
73
|
+
1.5.0
|
74
74
|
```
|
75
75
|
|
76
76
|
Show all `dep` GitHub release versions in JSON:
|
data/exe/getv
CHANGED
@@ -34,8 +34,9 @@ class App # rubocop:disable Metrics/ClassLength
|
|
34
34
|
|
35
35
|
switch %i[l latest], desc: 'Latest version', negatable: false
|
36
36
|
switch %i[j json], desc: 'Output in json', negatable: false
|
37
|
+
flag %i[p proxy], desc: 'Web proxy', default_value: nil
|
37
38
|
|
38
|
-
desc 'Get package versions from a Docker or OCI container image registry
|
39
|
+
desc 'Get package versions from a Docker or OCI container image registry'
|
39
40
|
arg_name 'package_name'
|
40
41
|
command :docker do |c|
|
41
42
|
defaults = (Getv::Package.new 'name', type: c.name.to_s).opts
|
@@ -50,12 +51,14 @@ class App # rubocop:disable Metrics/ClassLength
|
|
50
51
|
c.flag %i[repo], desc: 'Repository name',
|
51
52
|
default_value: "'<repo>' if package_name is in format '<owner>/<repo>', otherwise just package_name" # rubocop:disable Layout/LineLength
|
52
53
|
c.flag %i[url], desc: 'URL', default_value: defaults[:url]
|
54
|
+
c.flag %i[user], desc: 'Username', default_value: defaults[:user]
|
55
|
+
c.flag %i[password], desc: 'Password', default_value: defaults[:password]
|
53
56
|
c.action do |global_options, options, args|
|
54
57
|
help_now! unless args.size == 1
|
55
58
|
|
56
59
|
opts = global_options.merge(options)
|
57
60
|
opts = opts.slice :select_search, :select_replace, :reject, :semantic_only, :semantic_select, :owner, :repo,
|
58
|
-
:url
|
61
|
+
:url, :user, :password, :proxy
|
59
62
|
opts = opts.delete_if { |k, v| v.nil? || v == c.flags[k].default_value }
|
60
63
|
opts[:semantic_only] = !options[:invalid_versions]
|
61
64
|
opts[:semantic_select] = opts[:semantic_select].split(',') unless opts.fetch(:semantic_select, nil).nil?
|
@@ -78,7 +81,7 @@ class App # rubocop:disable Metrics/ClassLength
|
|
78
81
|
help_now! unless args.size == 1
|
79
82
|
|
80
83
|
opts = global_options.merge(options)
|
81
|
-
opts = opts.slice :select_search, :select_replace, :reject, :semantic_only, :semantic_select
|
84
|
+
opts = opts.slice :select_search, :select_replace, :reject, :semantic_only, :semantic_select, :proxy
|
82
85
|
opts = opts.delete_if { |k, v| v.nil? || v == c.flags[k].default_value }
|
83
86
|
opts[:semantic_only] = !options[:invalid_versions]
|
84
87
|
opts[:semantic_select] = opts[:semantic_select].split(',') unless opts.fetch(:semantic_select, nil).nil?
|
@@ -101,7 +104,7 @@ class App # rubocop:disable Metrics/ClassLength
|
|
101
104
|
c.action do |global_options, options, args|
|
102
105
|
help_now! unless args.size == 1
|
103
106
|
|
104
|
-
opts = opts.slice :select_search, :select_replace, :reject, :semantic_only, :semantic_select, :url
|
107
|
+
opts = opts.slice :select_search, :select_replace, :reject, :semantic_only, :semantic_select, :url, :proxy
|
105
108
|
opts = opts.delete_if { |k, v| v.nil? || v == c.flags[k].default_value }
|
106
109
|
opts[:semantic_only] = !options[:invalid_versions]
|
107
110
|
opts[:semantic_select] = opts[:semantic_select].split(',') unless opts.fetch(:semantic_select, nil).nil?
|
@@ -110,7 +113,7 @@ class App # rubocop:disable Metrics/ClassLength
|
|
110
113
|
end
|
111
114
|
end
|
112
115
|
|
113
|
-
desc 'Get package versions from GitHub commits
|
116
|
+
desc 'Get package versions from GitHub commits'
|
114
117
|
arg_name 'package_name'
|
115
118
|
command :github_commit do |c|
|
116
119
|
defaults = (Getv::Package.new 'name', type: c.name.to_s).opts
|
@@ -122,18 +125,19 @@ class App # rubocop:disable Metrics/ClassLength
|
|
122
125
|
c.flag %i[repo], desc: 'Repository name',
|
123
126
|
default_value: "'<repo>' if package_name is in format '<owner>/<repo>', otherwise just package_name" # rubocop:disable Layout/LineLength
|
124
127
|
c.flag %i[branch], desc: 'Repository branch', default_value: defaults[:branch]
|
128
|
+
c.flag %i[token], desc: 'Token', default_value: defaults[:token]
|
125
129
|
c.action do |global_options, options, args|
|
126
130
|
help_now! unless args.size == 1
|
127
131
|
|
128
132
|
opts = global_options.merge(options)
|
129
|
-
opts = opts.slice :select_search, :select_replace, :reject, :owner, :repo, :branch
|
133
|
+
opts = opts.slice :select_search, :select_replace, :reject, :owner, :repo, :branch, :token, :proxy
|
130
134
|
opts = opts.delete_if { |k, v| v.nil? || v == c.flags[k].default_value }
|
131
135
|
package = Getv::Package.new args[0], { type: c.name.to_s }.merge(opts)
|
132
136
|
Getv::Cli.output(package, latest: global_options[:latest], json: global_options[:json])
|
133
137
|
end
|
134
138
|
end
|
135
139
|
|
136
|
-
desc 'Get package versions from GitHub releases
|
140
|
+
desc 'Get package versions from GitHub releases'
|
137
141
|
arg_name 'package_name'
|
138
142
|
command :github_release do |c|
|
139
143
|
defaults = (Getv::Package.new 'name', type: c.name.to_s).opts
|
@@ -147,11 +151,13 @@ class App # rubocop:disable Metrics/ClassLength
|
|
147
151
|
default_value: "'<owner>' if package_name is in format '<owner>/<repo>', otherwise just package_name" # rubocop:disable Layout/LineLength
|
148
152
|
c.flag %i[repo], desc: 'Repository name',
|
149
153
|
default_value: "'<repo>' if package_name is in format '<owner>/<repo>', otherwise just package_name" # rubocop:disable Layout/LineLength
|
154
|
+
c.flag %i[token], desc: 'Token', default_value: defaults[:token]
|
150
155
|
c.action do |global_options, options, args|
|
151
156
|
help_now! unless args.size == 1
|
152
157
|
|
153
158
|
opts = global_options.merge(options)
|
154
|
-
opts = opts.slice :select_search, :select_replace, :reject, :semantic_only, :semantic_select, :owner, :repo
|
159
|
+
opts = opts.slice :select_search, :select_replace, :reject, :semantic_only, :semantic_select, :owner, :repo,
|
160
|
+
:token, :proxy
|
155
161
|
opts = opts.delete_if { |k, v| v.nil? || v == c.flags[k].default_value }
|
156
162
|
opts[:semantic_only] = !options[:invalid_versions]
|
157
163
|
opts[:semantic_select] = opts[:semantic_select].split(',') unless opts.fetch(:semantic_select, nil).nil?
|
@@ -160,7 +166,7 @@ class App # rubocop:disable Metrics/ClassLength
|
|
160
166
|
end
|
161
167
|
end
|
162
168
|
|
163
|
-
desc 'Get package versions from GitHub tags
|
169
|
+
desc 'Get package versions from GitHub tags'
|
164
170
|
arg_name 'package_name'
|
165
171
|
command :github_tag do |c|
|
166
172
|
defaults = (Getv::Package.new 'name', type: c.name.to_s).opts
|
@@ -174,11 +180,13 @@ class App # rubocop:disable Metrics/ClassLength
|
|
174
180
|
default_value: "'<owner>' if package_name is in format '<owner>/<repo>', otherwise just package_name" # rubocop:disable Layout/LineLength
|
175
181
|
c.flag %i[repo], desc: 'Repository name',
|
176
182
|
default_value: "'<repo>' if package_name is in format '<owner>/<repo>', otherwise just package_name" # rubocop:disable Layout/LineLength
|
183
|
+
c.flag %i[token], desc: 'Token', default_value: defaults[:token]
|
177
184
|
c.action do |global_options, options, args|
|
178
185
|
help_now! unless args.size == 1
|
179
186
|
|
180
187
|
opts = global_options.merge(options)
|
181
|
-
opts = opts.slice :select_search, :select_replace, :reject, :semantic_only, :semantic_select, :owner, :repo
|
188
|
+
opts = opts.slice :select_search, :select_replace, :reject, :semantic_only, :semantic_select, :owner, :repo,
|
189
|
+
:token, :proxy
|
182
190
|
opts = opts.delete_if { |k, v| v.nil? || v == c.flags[k].default_value }
|
183
191
|
opts[:semantic_only] = !options[:invalid_versions]
|
184
192
|
opts[:semantic_select] = opts[:semantic_select].split(',') unless opts.fetch(:semantic_select, nil).nil?
|
@@ -204,7 +212,7 @@ class App # rubocop:disable Metrics/ClassLength
|
|
204
212
|
help_now! unless args.size == 1
|
205
213
|
|
206
214
|
opts = global_options.merge(options)
|
207
|
-
opts = opts.slice :select_search, :select_replace, :reject, :semantic_only, :semantic_select, :url
|
215
|
+
opts = opts.slice :select_search, :select_replace, :reject, :semantic_only, :semantic_select, :url, :proxy
|
208
216
|
opts = opts.delete_if { |k, v| v.nil? || v == c.flags[k].default_value }
|
209
217
|
opts[:link] == 'value' if options[:link_value]
|
210
218
|
opts[:semantic_only] = !options[:invalid_versions]
|
@@ -228,7 +236,7 @@ class App # rubocop:disable Metrics/ClassLength
|
|
228
236
|
help_now! unless args.size == 1
|
229
237
|
|
230
238
|
opts = global_options.merge(options)
|
231
|
-
opts = opts.slice :select_search, :select_replace, :reject, :semantic_only, :semantic_select
|
239
|
+
opts = opts.slice :select_search, :select_replace, :reject, :semantic_only, :semantic_select, :proxy
|
232
240
|
opts = opts.delete_if { |k, v| v.nil? || v == c.flags[k].default_value }
|
233
241
|
opts[:semantic_only] = !options[:invalid_versions]
|
234
242
|
opts[:semantic_select] = opts[:semantic_select].split(',') unless opts.fetch(:semantic_select, nil).nil?
|
@@ -251,7 +259,7 @@ class App # rubocop:disable Metrics/ClassLength
|
|
251
259
|
help_now! unless args.size == 1
|
252
260
|
|
253
261
|
opts = global_options.merge(options)
|
254
|
-
opts = opts.slice :select_search, :select_replace, :reject, :semantic_only, :semantic_select
|
262
|
+
opts = opts.slice :select_search, :select_replace, :reject, :semantic_only, :semantic_select, :proxy
|
255
263
|
opts = opts.delete_if { |k, v| v.nil? || v == c.flags[k].default_value }
|
256
264
|
opts[:semantic_only] = !options[:invalid_versions]
|
257
265
|
opts[:semantic_select] = opts[:semantic_select].split(',') unless opts.fetch(:semantic_select, nil).nil?
|
data/lib/getv/package.rb
CHANGED
@@ -29,6 +29,7 @@ module Getv
|
|
29
29
|
reject: nil,
|
30
30
|
semantic_only: true,
|
31
31
|
semantic_select: ['*'],
|
32
|
+
proxy: nil,
|
32
33
|
versions: nil,
|
33
34
|
latest_version: nil
|
34
35
|
}.merge(opts)
|
@@ -37,11 +38,12 @@ module Getv
|
|
37
38
|
end
|
38
39
|
case opts[:type]
|
39
40
|
when 'docker'
|
40
|
-
opts = { owner: 'library', repo: name, url: 'https://registry.hub.docker.com'
|
41
|
+
opts = { owner: 'library', repo: name, url: 'https://registry.hub.docker.com', user: nil,
|
42
|
+
password: nil }.merge(opts)
|
41
43
|
when 'gem'
|
42
44
|
opts = { gem: name[/rubygem-(.*)/, 1] || name }.merge(opts)
|
43
45
|
when /github.*/
|
44
|
-
opts = { owner: name, repo: name }.merge(opts)
|
46
|
+
opts = { owner: name, repo: name, token: nil }.merge(opts)
|
45
47
|
when 'index'
|
46
48
|
opts = { link: 'content' }.merge(opts)
|
47
49
|
when 'npm'
|
@@ -89,13 +91,18 @@ module Getv
|
|
89
91
|
|
90
92
|
private
|
91
93
|
|
94
|
+
def get(url)
|
95
|
+
require 'rest-client'
|
96
|
+
RestClient::Request.execute(method: :get, url: url, proxy: opts[:proxy]).body
|
97
|
+
end
|
98
|
+
|
92
99
|
def versions_using_docker # rubocop:disable Metrics/AbcSize
|
93
100
|
require 'docker_registry2'
|
94
101
|
docker_opts = {}
|
95
|
-
docker_opts[:http_options] = { proxy:
|
96
|
-
if
|
97
|
-
docker_opts[:user] =
|
98
|
-
docker_opts[:password] =
|
102
|
+
docker_opts[:http_options] = { proxy: opts[:proxy] } unless opts[:proxy].nil?
|
103
|
+
if opts[:user] && opts[:password]
|
104
|
+
docker_opts[:user] = opts[:user]
|
105
|
+
docker_opts[:password] = opts[:password]
|
99
106
|
end
|
100
107
|
docker = DockerRegistry2.connect(opts[:url], docker_opts)
|
101
108
|
docker.tags("#{opts[:owner]}/#{opts[:repo]}")['tags']
|
@@ -103,29 +110,26 @@ module Getv
|
|
103
110
|
|
104
111
|
def versions_using_gem
|
105
112
|
require 'json'
|
106
|
-
|
107
|
-
require 'net/http'
|
108
|
-
JSON.parse(Net::HTTP.get(URI("https://rubygems.org/api/v1/versions/#{opts[:gem]}.json"))).map do |v|
|
113
|
+
JSON.parse(get("https://rubygems.org/api/v1/versions/#{opts[:gem]}.json")).map do |v|
|
109
114
|
v['number']
|
110
115
|
end
|
111
116
|
end
|
112
117
|
|
113
118
|
def versions_using_get
|
114
|
-
|
115
|
-
require 'net/http'
|
116
|
-
Net::HTTP.get(URI(opts[:url])).split("\n")
|
119
|
+
get(opts[:url]).split("\n")
|
117
120
|
end
|
118
121
|
|
119
|
-
def github
|
122
|
+
def github # rubocop:disable Metrics/MethodLength
|
120
123
|
require 'octokit'
|
121
|
-
if
|
122
|
-
github = Octokit::Client.new(access_token:
|
124
|
+
if opts[:token]
|
125
|
+
github = Octokit::Client.new(access_token: opts[:token])
|
123
126
|
user = github.user
|
124
127
|
user.login
|
125
128
|
else
|
126
129
|
github = Octokit::Client.new
|
127
130
|
end
|
128
131
|
github.auto_paginate = true
|
132
|
+
github.proxy = opts[:proxy]
|
129
133
|
github
|
130
134
|
end
|
131
135
|
|
@@ -143,11 +147,8 @@ module Getv
|
|
143
147
|
end
|
144
148
|
|
145
149
|
def versions_using_index
|
146
|
-
require 'open-uri'
|
147
|
-
require 'net/http'
|
148
150
|
require 'nokogiri'
|
149
|
-
|
150
|
-
Nokogiri::HTML(URI.open(opts[:url])).css('a').map do |a| # rubocop:disable Security/Open
|
151
|
+
Nokogiri::HTML(get(opts[:url])).css('a').map do |a|
|
151
152
|
if opts[:link] == 'value'
|
152
153
|
a.values[0]
|
153
154
|
else
|
@@ -158,16 +159,12 @@ module Getv
|
|
158
159
|
|
159
160
|
def versions_using_npm
|
160
161
|
require 'json'
|
161
|
-
|
162
|
-
require 'net/http'
|
163
|
-
JSON.parse(Net::HTTP.get(URI("https://registry.npmjs.org/#{opts[:npm]}")))['versions'].keys
|
162
|
+
JSON.parse(get("https://registry.npmjs.org/#{opts[:npm]}"))['versions'].keys
|
164
163
|
end
|
165
164
|
|
166
165
|
def versions_using_pypi
|
167
166
|
require 'json'
|
168
|
-
|
169
|
-
require 'net/http'
|
170
|
-
JSON.parse(Net::HTTP.get(URI("https://pypi.org/pypi/#{opts[:pypi]}/json")))['releases'].keys
|
167
|
+
JSON.parse(get("https://pypi.org/pypi/#{opts[:pypi]}/json"))['releases'].keys
|
171
168
|
end
|
172
169
|
end
|
173
170
|
end
|
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.5.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-01-
|
11
|
+
date: 2022-01-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gli
|
@@ -90,6 +90,26 @@ dependencies:
|
|
90
90
|
- - "<"
|
91
91
|
- !ruby/object:Gem::Version
|
92
92
|
version: 5.0.0
|
93
|
+
- !ruby/object:Gem::Dependency
|
94
|
+
name: rest-client
|
95
|
+
requirement: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: 2.1.0
|
100
|
+
- - "<"
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: 3.0.0
|
103
|
+
type: :runtime
|
104
|
+
prerelease: false
|
105
|
+
version_requirements: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: 2.1.0
|
110
|
+
- - "<"
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: 3.0.0
|
93
113
|
- !ruby/object:Gem::Dependency
|
94
114
|
name: semantic
|
95
115
|
requirement: !ruby/object:Gem::Requirement
|