end_of_life 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rspec +3 -0
- data/.standard.yml +1 -0
- data/.tool-versions +1 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile +12 -0
- data/Gemfile.lock +136 -0
- data/LICENSE.txt +21 -0
- data/README.md +73 -0
- data/Rakefile +8 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/end_of_life.gemspec +44 -0
- data/exe/end_of_life +7 -0
- data/exe/eol +1 -0
- data/lib/end_of_life/repository.rb +86 -0
- data/lib/end_of_life/ruby_version/parser.rb +88 -0
- data/lib/end_of_life/ruby_version.rb +37 -0
- data/lib/end_of_life/terminal_helper.rb +36 -0
- data/lib/end_of_life/version.rb +5 -0
- data/lib/end_of_life.json +13 -0
- data/lib/end_of_life.rb +65 -0
- metadata +154 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 66851fa78b32b4451ef40ef58f02c25386f6badd5d216a8bd360ed0dba84feed
|
4
|
+
data.tar.gz: 2f0c53b0a7d125b7ed0b408501a9a754c846b8d84e45821f70dd07ae1de13c1c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0cfee4bc90cae86ebb57baa7d48b1aa4cc4f9a521effffc4e0cbea29029fbcdfafd5a09b219639b30ae688792030102f91011b0960899d56a1e8e4aee4583f8d
|
7
|
+
data.tar.gz: b2a3556b924c0fbfb8968ef8ff2c64359b9b66f2659acef55442a3579d35a3877a8805ae4f62192be5d9f3a3d1ea5a91fa0413a9ebf96386d86d4564ec2c7df4
|
data/.rspec
ADDED
data/.standard.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby_version: 2.7.1
|
data/.tool-versions
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby 3.0.3
|
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
# Specify your gem's dependencies in end_of_life.gemspec
|
6
|
+
gemspec
|
7
|
+
|
8
|
+
gem "climate_control", "~> 1.0.1"
|
9
|
+
gem "rake", "~> 13.0"
|
10
|
+
gem "rspec", "~> 3.0"
|
11
|
+
gem "simplecov", "~> 0.21.2"
|
12
|
+
gem "standard", "~> 1.6"
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,136 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
end_of_life (0.1.0)
|
5
|
+
dry-monads (~> 1.3)
|
6
|
+
octokit (~> 4.0)
|
7
|
+
pastel (~> 0.8.0)
|
8
|
+
tty-spinner (~> 0.9.0)
|
9
|
+
tty-table (~> 0.12.0)
|
10
|
+
warning (~> 1.2.1)
|
11
|
+
|
12
|
+
GEM
|
13
|
+
remote: https://rubygems.org/
|
14
|
+
specs:
|
15
|
+
addressable (2.8.0)
|
16
|
+
public_suffix (>= 2.0.2, < 5.0)
|
17
|
+
ast (2.4.2)
|
18
|
+
climate_control (1.0.1)
|
19
|
+
concurrent-ruby (1.1.9)
|
20
|
+
diff-lcs (1.4.4)
|
21
|
+
docile (1.4.0)
|
22
|
+
dry-core (0.7.1)
|
23
|
+
concurrent-ruby (~> 1.0)
|
24
|
+
dry-monads (1.4.0)
|
25
|
+
concurrent-ruby (~> 1.0)
|
26
|
+
dry-core (~> 0.7)
|
27
|
+
faraday (1.9.3)
|
28
|
+
faraday-em_http (~> 1.0)
|
29
|
+
faraday-em_synchrony (~> 1.0)
|
30
|
+
faraday-excon (~> 1.1)
|
31
|
+
faraday-httpclient (~> 1.0)
|
32
|
+
faraday-multipart (~> 1.0)
|
33
|
+
faraday-net_http (~> 1.0)
|
34
|
+
faraday-net_http_persistent (~> 1.0)
|
35
|
+
faraday-patron (~> 1.0)
|
36
|
+
faraday-rack (~> 1.0)
|
37
|
+
faraday-retry (~> 1.0)
|
38
|
+
ruby2_keywords (>= 0.0.4)
|
39
|
+
faraday-em_http (1.0.0)
|
40
|
+
faraday-em_synchrony (1.0.0)
|
41
|
+
faraday-excon (1.1.0)
|
42
|
+
faraday-httpclient (1.0.1)
|
43
|
+
faraday-multipart (1.0.3)
|
44
|
+
multipart-post (>= 1.2, < 3)
|
45
|
+
faraday-net_http (1.0.1)
|
46
|
+
faraday-net_http_persistent (1.2.0)
|
47
|
+
faraday-patron (1.0.0)
|
48
|
+
faraday-rack (1.0.0)
|
49
|
+
faraday-retry (1.0.3)
|
50
|
+
multipart-post (2.1.1)
|
51
|
+
octokit (4.21.0)
|
52
|
+
faraday (>= 0.9)
|
53
|
+
sawyer (~> 0.8.0, >= 0.5.3)
|
54
|
+
parallel (1.21.0)
|
55
|
+
parser (3.1.0.0)
|
56
|
+
ast (~> 2.4.1)
|
57
|
+
pastel (0.8.0)
|
58
|
+
tty-color (~> 0.5)
|
59
|
+
public_suffix (4.0.6)
|
60
|
+
rainbow (3.0.0)
|
61
|
+
rake (13.0.6)
|
62
|
+
regexp_parser (2.2.0)
|
63
|
+
rexml (3.2.5)
|
64
|
+
rspec (3.10.0)
|
65
|
+
rspec-core (~> 3.10.0)
|
66
|
+
rspec-expectations (~> 3.10.0)
|
67
|
+
rspec-mocks (~> 3.10.0)
|
68
|
+
rspec-core (3.10.1)
|
69
|
+
rspec-support (~> 3.10.0)
|
70
|
+
rspec-expectations (3.10.1)
|
71
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
72
|
+
rspec-support (~> 3.10.0)
|
73
|
+
rspec-mocks (3.10.2)
|
74
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
75
|
+
rspec-support (~> 3.10.0)
|
76
|
+
rspec-support (3.10.2)
|
77
|
+
rubocop (1.24.1)
|
78
|
+
parallel (~> 1.10)
|
79
|
+
parser (>= 3.0.0.0)
|
80
|
+
rainbow (>= 2.2.2, < 4.0)
|
81
|
+
regexp_parser (>= 1.8, < 3.0)
|
82
|
+
rexml
|
83
|
+
rubocop-ast (>= 1.15.1, < 2.0)
|
84
|
+
ruby-progressbar (~> 1.7)
|
85
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
86
|
+
rubocop-ast (1.15.1)
|
87
|
+
parser (>= 3.0.1.1)
|
88
|
+
rubocop-performance (1.13.1)
|
89
|
+
rubocop (>= 1.7.0, < 2.0)
|
90
|
+
rubocop-ast (>= 0.4.0)
|
91
|
+
ruby-progressbar (1.11.0)
|
92
|
+
ruby2_keywords (0.0.5)
|
93
|
+
sawyer (0.8.2)
|
94
|
+
addressable (>= 2.3.5)
|
95
|
+
faraday (> 0.8, < 2.0)
|
96
|
+
simplecov (0.21.2)
|
97
|
+
docile (~> 1.1)
|
98
|
+
simplecov-html (~> 0.11)
|
99
|
+
simplecov_json_formatter (~> 0.1)
|
100
|
+
simplecov-html (0.12.3)
|
101
|
+
simplecov_json_formatter (0.1.3)
|
102
|
+
standard (1.6.0)
|
103
|
+
rubocop (= 1.24.1)
|
104
|
+
rubocop-performance (= 1.13.1)
|
105
|
+
strings (0.2.1)
|
106
|
+
strings-ansi (~> 0.2)
|
107
|
+
unicode-display_width (>= 1.5, < 3.0)
|
108
|
+
unicode_utils (~> 1.4)
|
109
|
+
strings-ansi (0.2.0)
|
110
|
+
tty-color (0.6.0)
|
111
|
+
tty-cursor (0.7.1)
|
112
|
+
tty-screen (0.8.1)
|
113
|
+
tty-spinner (0.9.3)
|
114
|
+
tty-cursor (~> 0.7)
|
115
|
+
tty-table (0.12.0)
|
116
|
+
pastel (~> 0.8)
|
117
|
+
strings (~> 0.2.0)
|
118
|
+
tty-screen (~> 0.8)
|
119
|
+
unicode-display_width (2.1.0)
|
120
|
+
unicode_utils (1.4.0)
|
121
|
+
warning (1.2.1)
|
122
|
+
|
123
|
+
PLATFORMS
|
124
|
+
x86_64-darwin-20
|
125
|
+
x86_64-linux
|
126
|
+
|
127
|
+
DEPENDENCIES
|
128
|
+
climate_control (~> 1.0.1)
|
129
|
+
end_of_life!
|
130
|
+
rake (~> 13.0)
|
131
|
+
rspec (~> 3.0)
|
132
|
+
simplecov (~> 0.21.2)
|
133
|
+
standard (~> 1.6)
|
134
|
+
|
135
|
+
BUNDLED WITH
|
136
|
+
2.3.4
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2022 Matheus Richard
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
# End Of Life
|
2
|
+
|
3
|
+
This gem lists GitHub repositories using end-of-life Ruby versions.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
```sh
|
8
|
+
gem install end_of_life
|
9
|
+
```
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
1. Set up a [GitHub access token];
|
14
|
+
|
15
|
+
[GitHub access token]: https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token#creating-a-token
|
16
|
+
|
17
|
+
2. Export the `GITHUB_TOKEN` environment variable or set it when calling `end_of_life`;
|
18
|
+
|
19
|
+
3. Use the `end_of_life` command to list the repositories:
|
20
|
+
```sh
|
21
|
+
$ GITHUB_TOKEN=something end_of_life # if your platform supports symlinks, you can use the `eol` command instead
|
22
|
+
[✔] Fetching repositories...
|
23
|
+
[✔] Searching for EOL Ruby in repositories...
|
24
|
+
|
25
|
+
Found 2 repositories using EOL Ruby (<= 2.5.9):
|
26
|
+
┌───┬──────────────────────────────────────────────┬──────────────┐
|
27
|
+
│ │ Repository │ Ruby version │
|
28
|
+
├───┼──────────────────────────────────────────────┼──────────────┤
|
29
|
+
│ 1 │ https://github.com/MatheusRich/my_rails_app │ 2.5.8 │
|
30
|
+
│ 2 │ https://github.com/MatheusRich/some_repo │ 2.5.0 │
|
31
|
+
└───┴──────────────────────────────────────────────┴──────────────┘
|
32
|
+
```
|
33
|
+
|
34
|
+
## How it works?
|
35
|
+
|
36
|
+
This gem fetches all your GitHub repositories that contain Ruby code, then
|
37
|
+
searches for files that may have a Ruby version. Currently, those files are:
|
38
|
+
`.ruby-version`, `Gemfile`, `Gemfile.lock`, and `.tool-version`. We parse these
|
39
|
+
files and extract the minimum Ruby version used in the repository.
|
40
|
+
|
41
|
+
The EOL Ruby version is defined statically in [this JSON file] provided by
|
42
|
+
https://endoflife.date/. We plan to fetch their API endpoint in the future.
|
43
|
+
|
44
|
+
> **IMPORTANT:** To parse Gemfiles, we need to execute the code inside it. **Be
|
45
|
+
> careful** because this may be a security risk. We plan to add a secure parser
|
46
|
+
> for Gemfiles in the future.
|
47
|
+
|
48
|
+
Some other limitations are listed on the [issues page].
|
49
|
+
|
50
|
+
[this json file]: ./lib/end_of_life.json
|
51
|
+
[issues page]: https://github.com/MatheusRich/end_of_life/issues
|
52
|
+
|
53
|
+
## Development
|
54
|
+
|
55
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run
|
56
|
+
`rake spec` to run the tests. You can also run `bin/console` for an interactive
|
57
|
+
prompt that will allow you to experiment.
|
58
|
+
|
59
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To
|
60
|
+
release a new version, update the version number in `version.rb`, and then run
|
61
|
+
`bundle exec rake release`, which will create a git tag for the version, push
|
62
|
+
git commits and the created tag, and push the `.gem` file to
|
63
|
+
[rubygems.org](https://rubygems.org).
|
64
|
+
|
65
|
+
## Contributing
|
66
|
+
|
67
|
+
Bug reports and pull requests are welcome on GitHub at
|
68
|
+
https://github.com/MatheusRich/end_of_life.
|
69
|
+
|
70
|
+
## License
|
71
|
+
|
72
|
+
The gem is available as open source under the terms of the [MIT
|
73
|
+
License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "bundler/setup"
|
5
|
+
require "end_of_life"
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require "irb"
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/end_of_life.gemspec
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/end_of_life/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "end_of_life"
|
7
|
+
spec.version = EndOfLife::VERSION
|
8
|
+
spec.authors = ["Matheus Richard"]
|
9
|
+
spec.email = ["matheusrichardt@gmail.com"]
|
10
|
+
|
11
|
+
spec.summary = "Lists repositories using end-of-life Ruby versions"
|
12
|
+
spec.description = "Searches your GitHub repositores and lists the ones using end-of-life, i.e. " \
|
13
|
+
"unmaintained, Ruby versions"
|
14
|
+
spec.homepage = "https://github.com/MatheusRich/end_of_life"
|
15
|
+
spec.license = "MIT"
|
16
|
+
spec.required_ruby_version = ">= 2.7.0"
|
17
|
+
|
18
|
+
# spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'"
|
19
|
+
|
20
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
21
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
22
|
+
spec.metadata["changelog_uri"] = "#{spec.homepage}/blob/main/CHANGELOG.md"
|
23
|
+
|
24
|
+
# Specify which files should be added to the gem when it is released.
|
25
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
26
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
27
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
28
|
+
(f == __FILE__) || f.match(%r{\A(?:(?:test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
|
29
|
+
end
|
30
|
+
end
|
31
|
+
spec.bindir = "exe"
|
32
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
33
|
+
spec.require_paths = ["lib"]
|
34
|
+
|
35
|
+
spec.add_dependency "octokit", "~> 4.0"
|
36
|
+
spec.add_dependency "pastel", "~> 0.8.0"
|
37
|
+
spec.add_dependency "dry-monads", "~> 1.3"
|
38
|
+
spec.add_dependency "tty-spinner", "~> 0.9.0"
|
39
|
+
spec.add_dependency "tty-table", "~> 0.12.0"
|
40
|
+
spec.add_dependency "warning", "~> 1.2.1"
|
41
|
+
|
42
|
+
# For more information and examples about making a new gem, check out our
|
43
|
+
# guide at: https://bundler.io/guides/creating_gem.html
|
44
|
+
end
|
data/exe/end_of_life
ADDED
data/exe/eol
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
end_of_life
|
@@ -0,0 +1,86 @@
|
|
1
|
+
require "dry-monads"
|
2
|
+
|
3
|
+
module EndOfLife
|
4
|
+
class Repository
|
5
|
+
class << self
|
6
|
+
include Dry::Monads[:result, :maybe]
|
7
|
+
|
8
|
+
def fetch(language:, user: nil)
|
9
|
+
github_client.fmap do |github|
|
10
|
+
user ||= github.user.login
|
11
|
+
response = github.search_repositories("user:#{user} language:#{language}", per_page: 100)
|
12
|
+
warn "Incomplete results: we only search 100 repos at a time" if response.incomplete_results
|
13
|
+
|
14
|
+
response.items.map do |repo|
|
15
|
+
Repository.new(
|
16
|
+
full_name: repo.full_name,
|
17
|
+
url: repo.html_url,
|
18
|
+
github_client: github
|
19
|
+
)
|
20
|
+
end
|
21
|
+
rescue => e
|
22
|
+
Failure("Unexpected error: #{e}")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def github_client
|
27
|
+
Maybe(ENV["GITHUB_TOKEN"])
|
28
|
+
.to_result
|
29
|
+
.fmap { |token| Octokit::Client.new(access_token: token) }
|
30
|
+
.or { Failure("Please set GITHUB_TOKEN environment variable") }
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
attr :full_name, :url
|
35
|
+
|
36
|
+
def initialize(full_name:, url:, github_client:)
|
37
|
+
@full_name = full_name
|
38
|
+
@url = url
|
39
|
+
@github_client = github_client
|
40
|
+
end
|
41
|
+
|
42
|
+
def eol_ruby?
|
43
|
+
ruby_version&.eol?
|
44
|
+
end
|
45
|
+
|
46
|
+
def ruby_version
|
47
|
+
return @ruby_version if defined?(@ruby_version)
|
48
|
+
|
49
|
+
@ruby_version = ruby_versions.min
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
def ruby_versions
|
55
|
+
return @ruby_versions if defined?(@ruby_versions)
|
56
|
+
|
57
|
+
@ruby_versions = begin
|
58
|
+
ruby_version_files = [
|
59
|
+
fetch_file(".ruby-version"),
|
60
|
+
fetch_file("Gemfile"),
|
61
|
+
fetch_file("Gemfile.lock"),
|
62
|
+
fetch_file(".tool-versions")
|
63
|
+
].compact
|
64
|
+
|
65
|
+
ruby_version_files.filter_map { |file| parse_version_file(file) }
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def fetch_file(file_path)
|
70
|
+
@github_client.contents(full_name, path: file_path)
|
71
|
+
rescue Octokit::NotFound
|
72
|
+
nil
|
73
|
+
end
|
74
|
+
|
75
|
+
def parse_version_file(file)
|
76
|
+
RubyVersion.from_file(file_name: file.name, content: decode_file(file))
|
77
|
+
end
|
78
|
+
|
79
|
+
def decode_file(file)
|
80
|
+
return file.content if file.encoding.nil?
|
81
|
+
return Base64.decode64(file.content) if file.encoding == "base64"
|
82
|
+
|
83
|
+
raise ArgumentError, "Unsupported encoding: #{file.encoding.inspect}"
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
require "bundler"
|
2
|
+
require "tempfile"
|
3
|
+
|
4
|
+
module EndOfLife
|
5
|
+
class RubyVersion
|
6
|
+
module Parser
|
7
|
+
extend self
|
8
|
+
|
9
|
+
def parse_file(file_name:, content:)
|
10
|
+
if file_name == ".ruby-version"
|
11
|
+
parse_ruby_version_file(content)
|
12
|
+
elsif file_name == "Gemfile.lock"
|
13
|
+
parse_gemfile_lock_file(content)
|
14
|
+
elsif file_name == "Gemfile"
|
15
|
+
parse_gemfile_file(content)
|
16
|
+
elsif file_name == ".tool-versions"
|
17
|
+
parse_tool_versions_file(content)
|
18
|
+
else
|
19
|
+
raise ArgumentError, "Unsupported file #{file_name}"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def parse_ruby_version_file(file_content)
|
26
|
+
string_version = file_content.strip.delete_prefix("ruby-")
|
27
|
+
|
28
|
+
RubyVersion.new(string_version)
|
29
|
+
end
|
30
|
+
|
31
|
+
def parse_gemfile_lock_file(file_content)
|
32
|
+
with_silent_bundler do
|
33
|
+
gemfile_lock_version = Bundler::LockfileParser.new(file_content).ruby_version
|
34
|
+
return if gemfile_lock_version.nil?
|
35
|
+
|
36
|
+
RubyVersion.new(gemfile_lock_version.delete_prefix("ruby "))
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def parse_gemfile_file(file_content)
|
41
|
+
return if file_content.empty?
|
42
|
+
|
43
|
+
with_temp_gemfile(file_content) do |temp_gemfile|
|
44
|
+
gemfile_version = temp_gemfile.ruby_version&.gem_version
|
45
|
+
return nil if gemfile_version.nil?
|
46
|
+
|
47
|
+
RubyVersion.new(gemfile_version)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def parse_tool_versions_file(file_content)
|
52
|
+
file_content
|
53
|
+
.split("\n")
|
54
|
+
.filter_map do |line|
|
55
|
+
tool, version = line.strip.split
|
56
|
+
|
57
|
+
tool == "ruby" && RubyVersion.new(version)
|
58
|
+
end
|
59
|
+
.first
|
60
|
+
end
|
61
|
+
|
62
|
+
def with_silent_bundler
|
63
|
+
previous_ui = Bundler.ui
|
64
|
+
Bundler.ui = Bundler::UI::Silent.new
|
65
|
+
|
66
|
+
yield
|
67
|
+
ensure
|
68
|
+
Bundler.ui = previous_ui
|
69
|
+
end
|
70
|
+
|
71
|
+
def with_temp_gemfile(contents)
|
72
|
+
# Bundler requires a file to parse, so we need to create a temporary file
|
73
|
+
Tempfile.create("tempGemfile") do |tempfile|
|
74
|
+
tempfile.write(contents)
|
75
|
+
tempfile.rewind
|
76
|
+
gemfile = with_silent_bundler do
|
77
|
+
# This is security problem, since it runs the code inside the file
|
78
|
+
Bundler::Definition.build(tempfile.path, nil, {})
|
79
|
+
end
|
80
|
+
|
81
|
+
yield(gemfile)
|
82
|
+
rescue Bundler::BundlerError
|
83
|
+
nil
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require_relative "ruby_version/parser"
|
2
|
+
|
3
|
+
module EndOfLife
|
4
|
+
class RubyVersion
|
5
|
+
include Comparable
|
6
|
+
|
7
|
+
EOL = File.read("lib/end_of_life.json")
|
8
|
+
.then { |json| JSON.parse(json, symbolize_names: true) }
|
9
|
+
.filter { |version| Date.parse(version[:eol]) <= Date.today }
|
10
|
+
.map { |version| Gem::Version.new(version[:latest]) }
|
11
|
+
.max
|
12
|
+
|
13
|
+
def self.from_file(file_name:, content:, parser: Parser)
|
14
|
+
parser.parse_file(file_name: file_name, content: content)
|
15
|
+
end
|
16
|
+
|
17
|
+
attr :version
|
18
|
+
|
19
|
+
def initialize(version_string)
|
20
|
+
@version = Gem::Version.new(version_string)
|
21
|
+
|
22
|
+
freeze
|
23
|
+
end
|
24
|
+
|
25
|
+
def eol?
|
26
|
+
@version <= EOL
|
27
|
+
end
|
28
|
+
|
29
|
+
def <=>(other)
|
30
|
+
@version <=> other.version
|
31
|
+
end
|
32
|
+
|
33
|
+
def to_s
|
34
|
+
@version.to_s
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require "pastel"
|
2
|
+
require "tty-spinner"
|
3
|
+
require "tty-table"
|
4
|
+
|
5
|
+
module EndOfLife
|
6
|
+
module TerminalHelper
|
7
|
+
def error_msg(message, label: "[ERROR]")
|
8
|
+
label = paint.red("#{label} ")
|
9
|
+
|
10
|
+
"#{label} #{message}"
|
11
|
+
end
|
12
|
+
|
13
|
+
def with_loading_spinner(message)
|
14
|
+
result = nil
|
15
|
+
|
16
|
+
new_spinner(message).run do |spinner|
|
17
|
+
result = yield(spinner)
|
18
|
+
spinner.success
|
19
|
+
end
|
20
|
+
|
21
|
+
result
|
22
|
+
end
|
23
|
+
|
24
|
+
def table(...)
|
25
|
+
TTY::Table.new(...).render(:unicode, padding: [0, 1])
|
26
|
+
end
|
27
|
+
|
28
|
+
def paint
|
29
|
+
@paint ||= Pastel.new
|
30
|
+
end
|
31
|
+
|
32
|
+
def new_spinner(message, options = {success_mark: paint.green("✔"), error_mark: paint.red("✖")})
|
33
|
+
TTY::Spinner.new("[:spinner] #{message}", options)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
[
|
2
|
+
{"cycle": "3.1", "release": "2021-12-25", "eol": "2025-12-25", "latest": "3.1.0"},
|
3
|
+
{"cycle": "3.0", "release": "2020-12-25", "eol": "2024-03-31", "latest": "3.0.3"},
|
4
|
+
{"cycle": "2.7", "release": "2019-12-25", "eol": "2023-03-31", "latest": "2.7.5"},
|
5
|
+
{"cycle": "2.6", "release": "2018-12-25", "eol": "2022-03-31", "latest": "2.6.9"},
|
6
|
+
{"cycle": "2.5", "release": "2017-12-25", "eol": "2021-03-31", "latest": "2.5.9"},
|
7
|
+
{"cycle": "2.4", "release": "2016-12-25", "eol": "2020-03-31", "latest": "2.4.10"},
|
8
|
+
{"cycle": "2.3", "release": "2015-12-25", "eol": "2019-03-31", "latest": "2.3.8"},
|
9
|
+
{"cycle": "2.2", "release": "2014-12-25", "eol": "2018-03-31", "latest": "2.2.10"},
|
10
|
+
{"cycle": "2.1", "release": "2013-12-25", "eol": "2017-03-31", "latest": "2.1.10"},
|
11
|
+
{"cycle": "2.0.0", "release": "2013-02-24", "eol": "2016-02-24", "latest": "2.0.0-p648"},
|
12
|
+
{"cycle": "1.9.3", "release": "2011-10-31", "eol": "2015-02-23", "latest": "1.9.3-p551"}
|
13
|
+
]
|
data/lib/end_of_life.rb
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "json"
|
4
|
+
require "octokit"
|
5
|
+
require "warning"
|
6
|
+
require_relative "end_of_life/repository"
|
7
|
+
require_relative "end_of_life/ruby_version"
|
8
|
+
require_relative "end_of_life/terminal_helper"
|
9
|
+
require_relative "end_of_life/version"
|
10
|
+
|
11
|
+
module EndOfLife
|
12
|
+
extend TerminalHelper
|
13
|
+
|
14
|
+
Warning.ignore(/Faraday::Connection#authorization/)
|
15
|
+
|
16
|
+
class CLI
|
17
|
+
include TerminalHelper
|
18
|
+
|
19
|
+
def call(argv)
|
20
|
+
fetch_repositories
|
21
|
+
.fmap { |repositories| filter_repositories_with_end_of_life(repositories) }
|
22
|
+
.fmap { |repositories| print_diagnose_for(repositories) }
|
23
|
+
.or { |error| puts "\n#{error_msg(error)}" }
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def fetch_repositories
|
29
|
+
with_loading_spinner("Fetching repositories...") do |spinner|
|
30
|
+
result = Repository.fetch(language: "ruby")
|
31
|
+
|
32
|
+
spinner.error if result.failure?
|
33
|
+
|
34
|
+
result
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def filter_repositories_with_end_of_life(repositories)
|
39
|
+
with_loading_spinner("Searching for EOL Ruby in repositories...") do
|
40
|
+
repositories.filter { |repo| repo.eol_ruby? }
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def print_diagnose_for(repositories)
|
45
|
+
puts
|
46
|
+
|
47
|
+
if repositories.empty?
|
48
|
+
puts "No repositories using EOL Ruby."
|
49
|
+
return
|
50
|
+
end
|
51
|
+
|
52
|
+
puts "Found #{repositories.size} repositories using EOL Ruby (<= #{RubyVersion::EOL}):"
|
53
|
+
puts end_of_life_table(repositories)
|
54
|
+
end
|
55
|
+
|
56
|
+
def end_of_life_table(repositories)
|
57
|
+
headers = ["", "Repository", "Ruby version"]
|
58
|
+
rows = repositories.map.with_index(1) do |repo, i|
|
59
|
+
[i, repo.url, repo.ruby_version]
|
60
|
+
end
|
61
|
+
|
62
|
+
table(headers, rows)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
metadata
ADDED
@@ -0,0 +1,154 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: end_of_life
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Matheus Richard
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-01-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: octokit
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '4.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '4.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: pastel
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.8.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.8.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: dry-monads
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.3'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.3'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: tty-spinner
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.9.0
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.9.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: tty-table
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.12.0
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.12.0
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: warning
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 1.2.1
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 1.2.1
|
97
|
+
description: Searches your GitHub repositores and lists the ones using end-of-life,
|
98
|
+
i.e. unmaintained, Ruby versions
|
99
|
+
email:
|
100
|
+
- matheusrichardt@gmail.com
|
101
|
+
executables:
|
102
|
+
- end_of_life
|
103
|
+
- eol
|
104
|
+
extensions: []
|
105
|
+
extra_rdoc_files: []
|
106
|
+
files:
|
107
|
+
- ".rspec"
|
108
|
+
- ".standard.yml"
|
109
|
+
- ".tool-versions"
|
110
|
+
- CHANGELOG.md
|
111
|
+
- Gemfile
|
112
|
+
- Gemfile.lock
|
113
|
+
- LICENSE.txt
|
114
|
+
- README.md
|
115
|
+
- Rakefile
|
116
|
+
- bin/console
|
117
|
+
- bin/setup
|
118
|
+
- end_of_life.gemspec
|
119
|
+
- exe/end_of_life
|
120
|
+
- exe/eol
|
121
|
+
- lib/end_of_life.json
|
122
|
+
- lib/end_of_life.rb
|
123
|
+
- lib/end_of_life/repository.rb
|
124
|
+
- lib/end_of_life/ruby_version.rb
|
125
|
+
- lib/end_of_life/ruby_version/parser.rb
|
126
|
+
- lib/end_of_life/terminal_helper.rb
|
127
|
+
- lib/end_of_life/version.rb
|
128
|
+
homepage: https://github.com/MatheusRich/end_of_life
|
129
|
+
licenses:
|
130
|
+
- MIT
|
131
|
+
metadata:
|
132
|
+
homepage_uri: https://github.com/MatheusRich/end_of_life
|
133
|
+
source_code_uri: https://github.com/MatheusRich/end_of_life
|
134
|
+
changelog_uri: https://github.com/MatheusRich/end_of_life/blob/main/CHANGELOG.md
|
135
|
+
post_install_message:
|
136
|
+
rdoc_options: []
|
137
|
+
require_paths:
|
138
|
+
- lib
|
139
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
140
|
+
requirements:
|
141
|
+
- - ">="
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
version: 2.7.0
|
144
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
145
|
+
requirements:
|
146
|
+
- - ">="
|
147
|
+
- !ruby/object:Gem::Version
|
148
|
+
version: '0'
|
149
|
+
requirements: []
|
150
|
+
rubygems_version: 3.2.32
|
151
|
+
signing_key:
|
152
|
+
specification_version: 4
|
153
|
+
summary: Lists repositories using end-of-life Ruby versions
|
154
|
+
test_files: []
|