getv 1.0.1 → 1.3.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 +129 -34
- data/exe/getv +314 -0
- data/lib/getv/package.rb +5 -2
- data/lib/getv/version.rb +1 -1
- metadata +25 -11
- data/.bundle/config +0 -4
- data/.gitignore +0 -15
- data/.rspec +0 -3
- data/.rubocop.yml +0 -10
- data/.travis.yml +0 -6
- data/Gemfile +0 -17
- data/Rakefile +0 -6
- data/getv.gemspec +0 -33
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d3f1afae07aeb895e7cac0ef722a2a0c12008681ee09bfa724cdfc692accba75
|
4
|
+
data.tar.gz: 67ea05289cee910c2c53db2fa337cc6a20bc2459d407bf5bf995d01b5cea41a5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e33576d51b5d6a32d39f54421e87d458542b3ce38a52f2e8b5182d4c38d54257b5e4a75469f96d15df8ab34c0546e03a153e7133138dd5d2dd9b63258d0eaa02
|
7
|
+
data.tar.gz: da5ed58b41e029f1979147c6d3d614bdc9841f267fc56e37f9b4775b7f7c8dc1836141f57e477156876b03b2daa9ac518445364386f4e85802728e0981a7577e
|
data/README.md
CHANGED
@@ -1,10 +1,18 @@
|
|
1
|
-
#
|
1
|
+
# getv
|
2
2
|
|
3
|
-
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/getv.svg)](https://rubygems.org/gems/getv)
|
4
|
+
|
5
|
+
The goal of `getv` is to make it easy and quick to pull software package version numbers from various sources on the web. The application is packaged as a [gem](https://rubygems.org/gems/getv) and provides both a Ruby library and an executable command line tool, `getv`.
|
4
6
|
|
5
7
|
## Installation
|
6
8
|
|
7
|
-
|
9
|
+
Install `getv` with:
|
10
|
+
|
11
|
+
```
|
12
|
+
gem install getv
|
13
|
+
```
|
14
|
+
|
15
|
+
Or add this line to your application's Gemfile:
|
8
16
|
|
9
17
|
```ruby
|
10
18
|
gem 'getv'
|
@@ -12,50 +20,137 @@ gem 'getv'
|
|
12
20
|
|
13
21
|
And then execute:
|
14
22
|
|
15
|
-
|
23
|
+
```sh
|
24
|
+
bundle install
|
25
|
+
```
|
26
|
+
|
27
|
+
## CLI
|
28
|
+
|
29
|
+
An executable command tool, `getv` is bundled with this gem:
|
30
|
+
|
31
|
+
```console
|
32
|
+
$ getv
|
33
|
+
NAME
|
34
|
+
getv - Get package version numbers from the web in various ways
|
35
|
+
|
36
|
+
|
37
|
+
SYNOPSIS
|
38
|
+
getv [global options] command [command options] [arguments...]
|
39
|
+
|
40
|
+
|
41
|
+
VERSION
|
42
|
+
1.3.0
|
43
|
+
|
44
|
+
|
45
|
+
|
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
|
51
|
+
|
52
|
+
|
53
|
+
|
54
|
+
COMMANDS
|
55
|
+
docker - Get package versions from a Docker or OCI container image registry
|
56
|
+
gem - Get package versions from RubyGems.org
|
57
|
+
get - Get package versions from text file URL
|
58
|
+
github_commit - Get package versions from GitHub commits. Set environment variable $GITHUB_TOKEN to avoid GitHub API limit.
|
59
|
+
github_release - Get package versions from GitHub releases. Set environment variable $GITHUB_TOKEN to avoid GitHub API limit.
|
60
|
+
github_tag - Get package versions from GitHub tags. Set environment variable $GITHUB_TOKEN to avoid GitHub API limit.
|
61
|
+
help - Shows a list of commands or help for one command
|
62
|
+
index - Get package versions from web page of links
|
63
|
+
npm - Get package versions from npm at registry.npmjs.org
|
64
|
+
pypi - Get package versions from the Python Package Index at pypi.org
|
65
|
+
```
|
66
|
+
|
67
|
+
### CLI examples
|
68
|
+
|
69
|
+
Show the latest available version of the `getv` gem:
|
70
|
+
|
71
|
+
```console
|
72
|
+
$ getv --latest gem getv
|
73
|
+
1.3.0
|
74
|
+
```
|
75
|
+
|
76
|
+
Show all `dep` GitHub release versions in JSON:
|
77
|
+
|
78
|
+
```console
|
79
|
+
$ getv --json github_release golang/dep
|
80
|
+
{"name":"golang/dep","versions":["0.2.0","0.2.1","0.3.0","0.3.1","0.3.2","0.4.0","0.4.1","0.5.0","0.5.1","0.5.2","0.5.3","0.5.4"]}
|
81
|
+
```
|
82
|
+
|
83
|
+
Show all AtomicParsley Github release versions:
|
84
|
+
|
85
|
+
```console
|
86
|
+
$ getv github_release --invalid_versions wez/atomicparsley
|
87
|
+
20200701.154658.b0d6223
|
88
|
+
20201231.092811.cbecfb1
|
89
|
+
20210114.184825.1dbe1be
|
90
|
+
20210124.204813.840499f
|
91
|
+
20210617.200601.1ac7c08
|
92
|
+
20210715.151551.e7ad03a
|
93
|
+
```
|
16
94
|
|
17
|
-
|
95
|
+
Show the latest stable version of Kubernetes using the release text file URL:
|
18
96
|
|
19
|
-
|
97
|
+
```console
|
98
|
+
$ getv -l get --url=https://storage.googleapis.com/kubernetes-release/release/stable.txt kubernetes
|
99
|
+
1.23.2
|
100
|
+
```
|
20
101
|
|
21
|
-
|
102
|
+
Show selected semantic versions of the `apache/superset` Docker image in JSON:
|
22
103
|
|
104
|
+
```console
|
105
|
+
$ getv --json docker --reject '-' --semantic_select '~>1.3.0,!=1.3.1' apache/superset
|
106
|
+
{"name":"apache/superset","versions":["1.3.0","1.3.2"]}
|
23
107
|
```
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
108
|
+
|
109
|
+
Show all versions of `libnetfilter_acct` using selected link values on an indexed web page:
|
110
|
+
|
111
|
+
```console
|
112
|
+
$ getv --select_search='^.*libnetfilter_acct-([\d\.]*)\.tar\.bz2$' index --url=https://netfilter.org/projects/libnetfilter_acct/files --link_value libnetfilter_acct
|
113
|
+
1.0.0
|
114
|
+
1.0.1
|
115
|
+
1.0.2
|
116
|
+
1.0.3
|
117
|
+
```
|
118
|
+
|
119
|
+
Show the latest GitHub commit to the `main` branch of the `getv` project in a useful versioning format:
|
120
|
+
|
121
|
+
```console
|
122
|
+
# By default the \2 capture group contains the date and \5 contains the short commit hash
|
123
|
+
$ getv -l github_commit --select_replace '\2git\5' --branch main liger1978/getv
|
124
|
+
20220123git9ed86f0
|
125
|
+
```
|
126
|
+
|
127
|
+
## Ruby library
|
128
|
+
|
129
|
+
Example:
|
130
|
+
|
131
|
+
```ruby
|
132
|
+
require 'getv'
|
133
|
+
|
134
|
+
superset = Getv::Package.new 'superset', type: 'docker', owner: 'apache', reject: '-'
|
135
|
+
puts superset.versions
|
136
|
+
puts superset.latest_version
|
47
137
|
```
|
48
138
|
|
49
139
|
## Development
|
50
140
|
|
51
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
141
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bundle exec rake spec` to run the tests. Run `bundle exec rubocop` to run the linter. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
52
142
|
|
53
|
-
|
143
|
+
Note that by default, Bundler will attempt to install gems to the system, e.g. `/usr/bin`, `/usr/share`, which requires elevated access and can interfere with files that are managed by the system's package manager. This behaviour can be overridden by creating the file `.bundle/config` and adding the following line:
|
144
|
+
```
|
145
|
+
BUNDLE_PATH: "./.bundle"
|
146
|
+
```
|
147
|
+
When you run `bin/setup` or `bundle install`, all gems will be installed inside the .bundle directory of this project.
|
54
148
|
|
55
|
-
|
149
|
+
To make this behaviour a default for all gem projects, the above line can be added to the user's bundle config file in their home directory (`~/.bundle/config`)
|
56
150
|
|
57
|
-
|
151
|
+
## Contributing
|
58
152
|
|
153
|
+
Bug reports and pull requests are welcome on [GitHub](https://github.com/liger1978/getv).
|
59
154
|
|
60
155
|
## License
|
61
156
|
|
data/exe/getv
ADDED
@@ -0,0 +1,314 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'getv'
|
5
|
+
require 'gli'
|
6
|
+
|
7
|
+
module Getv
|
8
|
+
# cli class
|
9
|
+
class Cli
|
10
|
+
def self.output(package, latest: false, json: false) # rubocop:disable Metrics/MethodLength
|
11
|
+
if latest
|
12
|
+
if json
|
13
|
+
require 'json'
|
14
|
+
puts({
|
15
|
+
'name' => package.name,
|
16
|
+
'latest_version' => package.latest_version
|
17
|
+
}.to_json)
|
18
|
+
else
|
19
|
+
puts package.latest_version
|
20
|
+
end
|
21
|
+
elsif json
|
22
|
+
require 'json'
|
23
|
+
puts({
|
24
|
+
'name' => package.name,
|
25
|
+
'versions' => package.versions
|
26
|
+
}.to_json)
|
27
|
+
else
|
28
|
+
puts package.versions
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# app class
|
35
|
+
class App # rubocop:disable Metrics/ClassLength
|
36
|
+
extend GLI::App
|
37
|
+
|
38
|
+
program_desc 'Get package version numbers from the web in various ways'
|
39
|
+
|
40
|
+
version Getv::VERSION
|
41
|
+
|
42
|
+
subcommand_option_handling :normal
|
43
|
+
arguments :strict
|
44
|
+
|
45
|
+
switch %i[l latest], desc: 'Latest version', negatable: false
|
46
|
+
switch %i[j json], desc: 'Output in json', negatable: false
|
47
|
+
|
48
|
+
desc 'Get package versions from a Docker or OCI container image registry'
|
49
|
+
arg_name 'package_name'
|
50
|
+
command :docker do |c| # rubocop:disable Metrics/BlockLength
|
51
|
+
defaults = (Getv::Package.new 'name', type: c.name.to_s).opts
|
52
|
+
c.flag %i[select_search], desc: 'Regex version selection search', default_value: defaults[:select_search]
|
53
|
+
c.flag %i[select_replace], desc: 'Regex version selection replace', default_value: defaults[:select_replace]
|
54
|
+
c.flag %i[reject], desc: 'Regex version rejection', default_value: defaults[:reject]
|
55
|
+
c.switch %i[invalid_versions], desc: 'Include invalid semantic versions', negatable: false, default_value: false
|
56
|
+
c.flag %i[semantic_select], desc: 'Semantic version selection (comma delimited)',
|
57
|
+
default_value: defaults[:semantic_select]
|
58
|
+
c.flag %i[owner], desc: 'Repository owner',
|
59
|
+
default_value: "'<owner>' if package_name is in format '<owner>/<repo>', otherwise just package_name" # rubocop:disable Layout/LineLength
|
60
|
+
c.flag %i[repo], desc: 'Repository name',
|
61
|
+
default_value: "'<repo>' if package_name is in format '<owner>/<repo>', otherwise just package_name" # rubocop:disable Layout/LineLength
|
62
|
+
c.flag %i[url], desc: 'URL', default_value: defaults[:url]
|
63
|
+
c.action do |global_options, options, args|
|
64
|
+
if args.size == 1
|
65
|
+
opts = global_options.merge(options)
|
66
|
+
opts = opts.slice :select_search, :select_replace, :reject, :semantic_only, :semantic_select, :owner, :repo,
|
67
|
+
:url
|
68
|
+
opts = opts.delete_if { |k, v| v.nil? || v == c.flags[k].default_value }
|
69
|
+
opts[:semantic_only] = !options[:invalid_versions]
|
70
|
+
opts[:semantic_select] = opts[:semantic_select].split(',') unless opts.fetch(:semantic_select, nil).nil?
|
71
|
+
package = Getv::Package.new args[0], { type: c.name.to_s }.merge(opts)
|
72
|
+
Getv::Cli.output(package, latest: global_options[:latest], json: global_options[:json])
|
73
|
+
else
|
74
|
+
help_now!
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
desc 'Get package versions from RubyGems.org'
|
80
|
+
arg_name 'package_name'
|
81
|
+
command :gem do |c|
|
82
|
+
defaults = (Getv::Package.new 'name', type: c.name.to_s).opts
|
83
|
+
c.flag %i[select_search], desc: 'Regex version selection search', default_value: defaults[:select_search]
|
84
|
+
c.flag %i[select_replace], desc: 'Regex version selection replace', default_value: defaults[:select_replace]
|
85
|
+
c.flag %i[reject], desc: 'Regex version rejection', default_value: defaults[:reject]
|
86
|
+
c.switch %i[invalid_versions], desc: 'Include invalid semantic versions', negatable: false, default_value: false
|
87
|
+
c.flag %i[semantic_select], desc: 'Semantic version selection (comma delimited)',
|
88
|
+
default_value: defaults[:semantic_select]
|
89
|
+
c.action do |global_options, options, args|
|
90
|
+
if args.size == 1
|
91
|
+
opts = global_options.merge(options)
|
92
|
+
opts = opts.slice :select_search, :select_replace, :reject, :semantic_only, :semantic_select
|
93
|
+
opts = opts.delete_if { |k, v| v.nil? || v == c.flags[k].default_value }
|
94
|
+
opts[:semantic_only] = !options[:invalid_versions]
|
95
|
+
opts[:semantic_select] = opts[:semantic_select].split(',') unless opts.fetch(:semantic_select, nil).nil?
|
96
|
+
package = Getv::Package.new args[0], { type: c.name.to_s }.merge(opts)
|
97
|
+
Getv::Cli.output(package, latest: global_options[:latest], json: global_options[:json])
|
98
|
+
else
|
99
|
+
help_now!
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
desc 'Get package versions from text file URL'
|
105
|
+
arg_name 'package_name'
|
106
|
+
command :get do |c|
|
107
|
+
defaults = (Getv::Package.new 'name', type: c.name.to_s).opts
|
108
|
+
c.flag %i[select_search], desc: 'Regex version selection search', default_value: defaults[:select_search]
|
109
|
+
c.flag %i[select_replace], desc: 'Regex version selection replace', default_value: defaults[:select_replace]
|
110
|
+
c.flag %i[reject], desc: 'Regex version rejection', default_value: defaults[:reject]
|
111
|
+
c.switch %i[invalid_versions], desc: 'Include invalid semantic versions', negatable: false, default_value: false
|
112
|
+
c.flag %i[semantic_select], desc: 'Semantic version selection (comma delimited)',
|
113
|
+
default_value: defaults[:semantic_select]
|
114
|
+
c.flag %i[url], desc: 'URL', default_value: defaults[:url]
|
115
|
+
c.action do |global_options, options, args|
|
116
|
+
if args.size == 1
|
117
|
+
opts = global_options.merge(options)
|
118
|
+
opts = opts.slice :select_search, :select_replace, :reject, :semantic_only, :semantic_select, :url
|
119
|
+
opts = opts.delete_if { |k, v| v.nil? || v == c.flags[k].default_value }
|
120
|
+
opts[:semantic_only] = !options[:invalid_versions]
|
121
|
+
opts[:semantic_select] = opts[:semantic_select].split(',') unless opts.fetch(:semantic_select, nil).nil?
|
122
|
+
package = Getv::Package.new args[0], { type: c.name.to_s }.merge(opts)
|
123
|
+
Getv::Cli.output(package, latest: global_options[:latest], json: global_options[:json])
|
124
|
+
else
|
125
|
+
help_now!
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
desc 'Get package versions from GitHub commits. Set environment variable $GITHUB_TOKEN to avoid GitHub API limit.'
|
131
|
+
arg_name 'package_name'
|
132
|
+
command :github_commit do |c|
|
133
|
+
defaults = (Getv::Package.new 'name', type: c.name.to_s).opts
|
134
|
+
c.flag %i[select_search], desc: 'Regex version selection search', default_value: defaults[:select_search]
|
135
|
+
c.flag %i[select_replace], desc: 'Regex version selection replace', default_value: defaults[:select_replace]
|
136
|
+
c.flag %i[reject], desc: 'Regex version rejection', default_value: defaults[:reject]
|
137
|
+
c.flag %i[owner], desc: 'Repository owner',
|
138
|
+
default_value: "'<owner>' if package_name is in format '<owner>/<repo>', otherwise just package_name" # rubocop:disable Layout/LineLength
|
139
|
+
c.flag %i[repo], desc: 'Repository name',
|
140
|
+
default_value: "'<repo>' if package_name is in format '<owner>/<repo>', otherwise just package_name" # rubocop:disable Layout/LineLength
|
141
|
+
c.flag %i[branch], desc: 'Repository branch', default_value: defaults[:branch]
|
142
|
+
c.action do |global_options, options, args|
|
143
|
+
if args.size == 1
|
144
|
+
opts = global_options.merge(options)
|
145
|
+
opts = opts.slice :select_search, :select_replace, :reject, :owner, :repo, :branch
|
146
|
+
opts = opts.delete_if { |k, v| v.nil? || v == c.flags[k].default_value }
|
147
|
+
package = Getv::Package.new args[0], { type: c.name.to_s }.merge(opts)
|
148
|
+
Getv::Cli.output(package, latest: global_options[:latest], json: global_options[:json])
|
149
|
+
else
|
150
|
+
help_now!
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
desc 'Get package versions from GitHub releases. Set environment variable $GITHUB_TOKEN to avoid GitHub API limit.'
|
156
|
+
arg_name 'package_name'
|
157
|
+
command :github_release do |c|
|
158
|
+
defaults = (Getv::Package.new 'name', type: c.name.to_s).opts
|
159
|
+
c.flag %i[select_search], desc: 'Regex version selection search', default_value: defaults[:select_search]
|
160
|
+
c.flag %i[select_replace], desc: 'Regex version selection replace', default_value: defaults[:select_replace]
|
161
|
+
c.flag %i[reject], desc: 'Regex version rejection', default_value: defaults[:reject]
|
162
|
+
c.switch %i[invalid_versions], desc: 'Include invalid semantic versions', negatable: false, default_value: false
|
163
|
+
c.flag %i[semantic_select], desc: 'Semantic version selection (comma delimited)',
|
164
|
+
default_value: defaults[:semantic_select]
|
165
|
+
c.flag %i[owner], desc: 'Repository owner',
|
166
|
+
default_value: "'<owner>' if package_name is in format '<owner>/<repo>', otherwise just package_name" # rubocop:disable Layout/LineLength
|
167
|
+
c.flag %i[repo], desc: 'Repository name',
|
168
|
+
default_value: "'<repo>' if package_name is in format '<owner>/<repo>', otherwise just package_name" # rubocop:disable Layout/LineLength
|
169
|
+
c.action do |global_options, options, args|
|
170
|
+
if args.size == 1
|
171
|
+
opts = global_options.merge(options)
|
172
|
+
opts = opts.slice :select_search, :select_replace, :reject, :semantic_only, :semantic_select, :owner, :repo
|
173
|
+
opts = opts.delete_if { |k, v| v.nil? || v == c.flags[k].default_value }
|
174
|
+
opts[:semantic_only] = !options[:invalid_versions]
|
175
|
+
opts[:semantic_select] = opts[:semantic_select].split(',') unless opts.fetch(:semantic_select, nil).nil?
|
176
|
+
package = Getv::Package.new args[0], { type: c.name.to_s }.merge(opts)
|
177
|
+
Getv::Cli.output(package, latest: global_options[:latest], json: global_options[:json])
|
178
|
+
else
|
179
|
+
help_now!
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
desc 'Get package versions from GitHub tags. Set environment variable $GITHUB_TOKEN to avoid GitHub API limit.'
|
185
|
+
arg_name 'package_name'
|
186
|
+
command :github_tag do |c|
|
187
|
+
defaults = (Getv::Package.new 'name', type: c.name.to_s).opts
|
188
|
+
c.flag %i[select_search], desc: 'Regex version selection search', default_value: defaults[:select_search]
|
189
|
+
c.flag %i[select_replace], desc: 'Regex version selection replace', default_value: defaults[:select_replace]
|
190
|
+
c.flag %i[reject], desc: 'Regex version rejection', default_value: defaults[:reject]
|
191
|
+
c.switch %i[invalid_versions], desc: 'Include invalid semantic versions', negatable: false, default_value: false
|
192
|
+
c.flag %i[semantic_select], desc: 'Semantic version selection (comma delimited)',
|
193
|
+
default_value: defaults[:semantic_select]
|
194
|
+
c.flag %i[owner], desc: 'Repository owner',
|
195
|
+
default_value: "'<owner>' if package_name is in format '<owner>/<repo>', otherwise just package_name" # rubocop:disable Layout/LineLength
|
196
|
+
c.flag %i[repo], desc: 'Repository name',
|
197
|
+
default_value: "'<repo>' if package_name is in format '<owner>/<repo>', otherwise just package_name" # rubocop:disable Layout/LineLength
|
198
|
+
c.action do |global_options, options, args|
|
199
|
+
if args.size == 1
|
200
|
+
opts = global_options.merge(options)
|
201
|
+
opts = opts.slice :select_search, :select_replace, :reject, :semantic_only, :semantic_select, :owner, :repo
|
202
|
+
opts = opts.delete_if { |k, v| v.nil? || v == c.flags[k].default_value }
|
203
|
+
opts[:semantic_only] = !options[:invalid_versions]
|
204
|
+
opts[:semantic_select] = opts[:semantic_select].split(',') unless opts.fetch(:semantic_select, nil).nil?
|
205
|
+
package = Getv::Package.new args[0], { type: c.name.to_s }.merge(opts)
|
206
|
+
Getv::Cli.output(package, latest: global_options[:latest], json: global_options[:json])
|
207
|
+
else
|
208
|
+
help_now!
|
209
|
+
end
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
213
|
+
desc 'Get package versions from web page of links'
|
214
|
+
arg_name 'package_name'
|
215
|
+
command :index do |c|
|
216
|
+
defaults = (Getv::Package.new 'name', type: c.name.to_s).opts
|
217
|
+
c.flag %i[select_search], desc: 'Regex version selection search', default_value: defaults[:select_search]
|
218
|
+
c.flag %i[select_replace], desc: 'Regex version selection replace', default_value: defaults[:select_replace]
|
219
|
+
c.flag %i[reject], desc: 'Regex version rejection', default_value: defaults[:reject]
|
220
|
+
c.switch %i[invalid_versions], desc: 'Include invalid semantic versions', negatable: false, default_value: false
|
221
|
+
c.flag %i[semantic_select], desc: 'Semantic version selection (comma delimited)',
|
222
|
+
default_value: defaults[:semantic_select]
|
223
|
+
c.flag %i[url], desc: 'URL', default_value: defaults[:url]
|
224
|
+
c.switch %i[link_value], desc: 'Use the value (target) of links rather than the content (display text)',
|
225
|
+
negatable: false, default_value: false
|
226
|
+
c.action do |global_options, options, args|
|
227
|
+
if args.size == 1
|
228
|
+
opts = global_options.merge(options)
|
229
|
+
opts = opts.slice :select_search, :select_replace, :reject, :semantic_only, :semantic_select, :url
|
230
|
+
opts = opts.delete_if { |k, v| v.nil? || v == c.flags[k].default_value }
|
231
|
+
opts[:link] == 'value' if options[:link_value]
|
232
|
+
opts[:semantic_only] = !options[:invalid_versions]
|
233
|
+
opts[:semantic_select] = opts[:semantic_select].split(',') unless opts.fetch(:semantic_select, nil).nil?
|
234
|
+
package = Getv::Package.new args[0], { type: c.name.to_s }.merge(opts)
|
235
|
+
Getv::Cli.output(package, latest: global_options[:latest], json: global_options[:json])
|
236
|
+
else
|
237
|
+
help_now!
|
238
|
+
end
|
239
|
+
end
|
240
|
+
end
|
241
|
+
|
242
|
+
desc 'Get package versions from npm at registry.npmjs.org'
|
243
|
+
arg_name 'package_name'
|
244
|
+
command :npm do |c|
|
245
|
+
defaults = (Getv::Package.new 'name', type: c.name.to_s).opts
|
246
|
+
c.flag %i[select_search], desc: 'Regex version selection search', default_value: defaults[:select_search]
|
247
|
+
c.flag %i[select_replace], desc: 'Regex version selection replace', default_value: defaults[:select_replace]
|
248
|
+
c.flag %i[reject], desc: 'Regex version rejection', default_value: defaults[:reject]
|
249
|
+
c.switch %i[invalid_versions], desc: 'Include invalid semantic versions', negatable: false, default_value: false
|
250
|
+
c.flag %i[semantic_select], desc: 'Semantic version selection (comma delimited)',
|
251
|
+
default_value: defaults[:semantic_select]
|
252
|
+
c.action do |global_options, options, args|
|
253
|
+
if args.size == 1
|
254
|
+
opts = global_options.merge(options)
|
255
|
+
opts = opts.slice :select_search, :select_replace, :reject, :semantic_only, :semantic_select
|
256
|
+
opts = opts.delete_if { |k, v| v.nil? || v == c.flags[k].default_value }
|
257
|
+
opts[:semantic_only] = !options[:invalid_versions]
|
258
|
+
opts[:semantic_select] = opts[:semantic_select].split(',') unless opts.fetch(:semantic_select, nil).nil?
|
259
|
+
package = Getv::Package.new args[0], { type: c.name.to_s }.merge(opts)
|
260
|
+
Getv::Cli.output(package, latest: global_options[:latest], json: global_options[:json])
|
261
|
+
else
|
262
|
+
help_now!
|
263
|
+
end
|
264
|
+
end
|
265
|
+
end
|
266
|
+
|
267
|
+
desc 'Get package versions from the Python Package Index at pypi.org'
|
268
|
+
arg_name 'package_name'
|
269
|
+
command :pypi do |c|
|
270
|
+
defaults = (Getv::Package.new 'name', type: c.name.to_s).opts
|
271
|
+
c.flag %i[select_search], desc: 'Regex version selection search', default_value: defaults[:select_search]
|
272
|
+
c.flag %i[select_replace], desc: 'Regex version selection replace', default_value: defaults[:select_replace]
|
273
|
+
c.flag %i[reject], desc: 'Regex version rejection', default_value: defaults[:reject]
|
274
|
+
c.switch %i[invalid_versions], desc: 'Include invalid semantic versions', negatable: false, default_value: false
|
275
|
+
c.flag %i[semantic_select], desc: 'Semantic version selection (comma delimited)',
|
276
|
+
default_value: defaults[:semantic_select]
|
277
|
+
c.action do |global_options, options, args|
|
278
|
+
if args.size == 1
|
279
|
+
opts = global_options.merge(options)
|
280
|
+
opts = opts.slice :select_search, :select_replace, :reject, :semantic_only, :semantic_select
|
281
|
+
opts = opts.delete_if { |k, v| v.nil? || v == c.flags[k].default_value }
|
282
|
+
opts[:semantic_only] = !options[:invalid_versions]
|
283
|
+
opts[:semantic_select] = opts[:semantic_select].split(',') unless opts.fetch(:semantic_select, nil).nil?
|
284
|
+
package = Getv::Package.new args[0], { type: c.name.to_s }.merge(opts)
|
285
|
+
Getv::Cli.output(package, latest: global_options[:latest], json: global_options[:json])
|
286
|
+
else
|
287
|
+
help_now!
|
288
|
+
end
|
289
|
+
end
|
290
|
+
end
|
291
|
+
|
292
|
+
pre do |_global, _command, _options, _args|
|
293
|
+
# Pre logic here
|
294
|
+
# Return true to proceed; false to abort and not call the
|
295
|
+
# chosen command
|
296
|
+
# Use skips_pre before a command to skip this block
|
297
|
+
# on that command only
|
298
|
+
true
|
299
|
+
end
|
300
|
+
|
301
|
+
post do |global, command, options, args|
|
302
|
+
# Post logic here
|
303
|
+
# Use skips_post before a command to skip this
|
304
|
+
# block on that command only
|
305
|
+
end
|
306
|
+
|
307
|
+
on_error do |_exception|
|
308
|
+
# Error logic here
|
309
|
+
# return false to skip default error handling
|
310
|
+
true
|
311
|
+
end
|
312
|
+
end
|
313
|
+
|
314
|
+
exit App.run(ARGV)
|
data/lib/getv/package.rb
CHANGED
@@ -5,7 +5,7 @@ module Getv
|
|
5
5
|
class Package # rubocop:disable Metrics/ClassLength
|
6
6
|
attr_accessor :name, :opts
|
7
7
|
|
8
|
-
def initialize(name, opts = {}) # rubocop:disable Metrics/MethodLength,Metrics/CyclomaticComplexity,Metrics/AbcSize
|
8
|
+
def initialize(name, opts = {}) # rubocop:disable Metrics/MethodLength,Metrics/CyclomaticComplexity,Metrics/AbcSize,Metrics/PerceivedComplexity
|
9
9
|
@name = name
|
10
10
|
case name
|
11
11
|
when /rubygem-.*/
|
@@ -24,7 +24,7 @@ module Getv
|
|
24
24
|
end
|
25
25
|
opts = {
|
26
26
|
type: 'github_release',
|
27
|
-
select_search: '^\s*v?(
|
27
|
+
select_search: '^\s*v?(.*)\s*$',
|
28
28
|
select_replace: '\1',
|
29
29
|
reject: nil,
|
30
30
|
semantic_only: true,
|
@@ -32,6 +32,9 @@ module Getv
|
|
32
32
|
versions: nil,
|
33
33
|
latest_version: nil
|
34
34
|
}.merge(opts)
|
35
|
+
if (opts[:type] == 'docker' || opts[:type] =~ /github.*/) && (name.count('/') == 1)
|
36
|
+
opts = { owner: name.split('/')[0], repo: name.split('/')[1] }.merge(opts)
|
37
|
+
end
|
35
38
|
case opts[:type]
|
36
39
|
when 'docker'
|
37
40
|
opts = { owner: 'library', repo: name, url: 'https://registry.hub.docker.com' }.merge(opts)
|
data/lib/getv/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,35 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: getv
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.3.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-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: gli
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 2.20.1
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 3.0.0
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 2.20.1
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 3.0.0
|
13
33
|
- !ruby/object:Gem::Dependency
|
14
34
|
name: docker_registry2
|
15
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -93,20 +113,14 @@ dependencies:
|
|
93
113
|
description: Pull package version numbers from the web in various ways.
|
94
114
|
email:
|
95
115
|
- harbottle@room3d3.com
|
96
|
-
executables:
|
116
|
+
executables:
|
117
|
+
- getv
|
97
118
|
extensions: []
|
98
119
|
extra_rdoc_files: []
|
99
120
|
files:
|
100
|
-
- ".bundle/config"
|
101
|
-
- ".gitignore"
|
102
|
-
- ".rspec"
|
103
|
-
- ".rubocop.yml"
|
104
|
-
- ".travis.yml"
|
105
|
-
- Gemfile
|
106
121
|
- LICENSE.txt
|
107
122
|
- README.md
|
108
|
-
-
|
109
|
-
- getv.gemspec
|
123
|
+
- exe/getv
|
110
124
|
- lib/getv.rb
|
111
125
|
- lib/getv/package.rb
|
112
126
|
- lib/getv/version.rb
|
data/.bundle/config
DELETED
data/.gitignore
DELETED
data/.rspec
DELETED
data/.rubocop.yml
DELETED
data/.travis.yml
DELETED
data/Gemfile
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
source 'https://rubygems.org'
|
4
|
-
|
5
|
-
# Specify your gem's dependencies in getv.gemspec
|
6
|
-
gemspec
|
7
|
-
|
8
|
-
gem 'docker_registry2', '~> 1.10'
|
9
|
-
gem 'irb', '~> 1.4'
|
10
|
-
gem 'nokogiri', '~> 1.13'
|
11
|
-
gem 'octokit', '~> 4.21'
|
12
|
-
gem 'rake', '~> 12.0'
|
13
|
-
gem 'rdoc', '~> 6.4'
|
14
|
-
gem 'rspec', '~> 3.0'
|
15
|
-
gem 'semantic', '~> 1.6'
|
16
|
-
gem 'vcr', '~> 6.0'
|
17
|
-
gem 'webmock', '~> 3.0'
|
data/Rakefile
DELETED
data/getv.gemspec
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'lib/getv/version'
|
4
|
-
|
5
|
-
Gem::Specification.new do |spec|
|
6
|
-
spec.name = 'getv'
|
7
|
-
spec.version = Getv::VERSION
|
8
|
-
spec.authors = ['harbottle']
|
9
|
-
spec.email = ['harbottle@room3d3.com']
|
10
|
-
|
11
|
-
spec.summary = 'Pull package version numbers from the web in various ways.'
|
12
|
-
spec.description = 'Pull package version numbers from the web in various ways.'
|
13
|
-
spec.homepage = 'https://github.com/liger1978/getv'
|
14
|
-
spec.license = 'MIT'
|
15
|
-
|
16
|
-
spec.metadata['homepage_uri'] = spec.homepage
|
17
|
-
spec.metadata['source_code_uri'] = 'https://github.com/liger1978/getv'
|
18
|
-
spec.metadata['changelog_uri'] = 'https://github.com/liger1978/getv'
|
19
|
-
|
20
|
-
# Specify which files should be added to the gem when it is released.
|
21
|
-
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
22
|
-
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
23
|
-
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
24
|
-
end
|
25
|
-
spec.bindir = 'exe'
|
26
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
27
|
-
spec.require_paths = ['lib']
|
28
|
-
|
29
|
-
spec.add_dependency('docker_registry2', '>= 1.0.0', '< 2.0.0')
|
30
|
-
spec.add_dependency('nokogiri', '>= 1.0.0', '< 2.0.0')
|
31
|
-
spec.add_dependency('octokit', '>= 3.0.0', '< 5.0.0')
|
32
|
-
spec.add_dependency('semantic', '>= 1.0.0', '< 2.0.0')
|
33
|
-
end
|