next_rails 1.2.1 → 1.2.2

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: 822e7ed8bda705fc5a9ff1a0f8ccbba91901e01dd279760e7787a7ef1df3f38f
4
- data.tar.gz: fd6e3bb66afd86c54fba7e5352245ada2f3ec0520cd88063d11a938d908a4d90
3
+ metadata.gz: ceb25dba1847fdd6aa7b71ea2dacac03a90e16cf855e59d6a92cb6855c9124f6
4
+ data.tar.gz: 48c1a8bc8a02a2d717bb0da75c5145881ec96c0da6953309867238299d8f76b6
5
5
  SHA512:
6
- metadata.gz: 2da9a58d3922e7d266bc9769a5cfdfee57e1e5d21c2d31be9ff5f3b6b8c109e08b94dfb34eb894d516906921edcddafb5a26b42aab82f3c2f16344820877d133
7
- data.tar.gz: e8886320ac2047e9d83d4c6fd67aaccf14b9aa735102dc4eb2755e78cb2dbe359f221ae768ab5c9e2eba44731ba91222e370ff4bea4bee5cbad966e0b5ac2678
6
+ metadata.gz: afe58b7bc957ceed1c2c1ead4fe64059e4657dcbab249ecd35138f90d3e335987ea6759590679009dee64b9eb8178a28ee030ad13a744ae082348e19f82cc0ff
7
+ data.tar.gz: 00c6a32d28b7cb6836ee99246d6a92829d6a450753ad379ecf493015d809888790204e85ba55ac9c0c22c6ce30531422bbf646f7b5bea695c4193e47544c9c07
@@ -6,46 +6,32 @@ labels: bug
6
6
  assignees: ""
7
7
  ---
8
8
 
9
- **IMPORTANT: please make sure you ask yourself all intro questions and fill all sections of the template.**
9
+ <!--- Before creating a bug report, please, answer the following questions -->
10
+ <!--- Did you check the documentation for answers? -->
11
+ <!--- Did you make sure that this bug has not already been reported? -->
10
12
 
11
- **Before we start...:**
13
+ ## Expected Behavior
14
+ <!--- Tell us what should happen -->
15
+ <!--- For example: When I [do X], it should [produce Y] -->
12
16
 
13
- - [ ] I checked the documentation and found no answer
14
- - [ ] I checked to make sure that this issue has not already been filed
15
- - [ ] I'm reporting the issue to the correct repository (for multi-repository projects)
17
+ ## Actual Behavior
18
+ <!--- Tell us what happens instead -->
19
+ <!--- For example: When I [did X], it [produced Y] -->
16
20
 
17
- **Version, Branch, or Commit:**
21
+ ## Possible Fix
22
+ <!--- Optionally suggest a fix or work around -->
18
23
 
19
- What branch/commit/version of "next_rails" you are using?
24
+ ## To Reproduce
25
+ <!--- Optionally provide a link to a live example -->
20
26
 
21
- **Expected behavior:**
27
+ <!--- Otherwise, please provide a set of reproduction steps -->
28
+ 1.
29
+ 2.
30
+ 3.
31
+ 4.
22
32
 
23
- Please include a detailed description of the behavior you were expecting when you encountered this issue.
24
-
25
- **Actual behavior:**
26
-
27
- Please include a detailed description of the actual behavior of the application.
28
-
29
- **Steps to reproduce:**
30
-
31
- How do I achieve this behavior? Use the following format to provide a step-by-step guide:
32
-
33
- 1. Step 1: ...
34
- 2. Step 2: ...
35
-
36
- **Context and environment:**
37
-
38
- Provide any relevant information about your setup (Customize the list accordingly based on what info is relevant to this project)
39
-
40
- 1. Version of the software the issue is being opened for.
41
- 2. Operating System
42
- 3. Operating System version
43
- 4. Ruby version
44
-
45
- _Delete any information that is not relevant._
46
-
47
- **Logs**
48
-
49
- Include relevant log snippets or files here.
33
+ ## Additional Information
34
+ <!--- Include any relevant details about your environment (branch, browser, OS) -->
35
+ <!--- and the bug (screenshots, logs, etc) -->
50
36
 
51
37
  **I will abide by the [code of conduct](https://github.com/fastruby/next_rails/blob/main/CODE_OF_CONDUCT.md)**
@@ -6,35 +6,18 @@ labels: enhancement
6
6
  assignees: ""
7
7
  ---
8
8
 
9
- **IMPORTANT: please make sure you ask yourself all intro questions and fill all sections of the template.**
9
+ <!--- Before creating a feature request, please, answer the following questions -->
10
+ <!--- Did you check the documentation for this feature? -->
11
+ <!--- Did you make sure that this feature has not already been requested? -->
10
12
 
11
- **Before we start...:**
13
+ ## Description
14
+ <!--- Provide a description of the change or addition you are proposing -->
12
15
 
13
- - [ ] I checked the documentation and didn't find this feature
14
- - [ ] I checked to make sure that this feature has not already been requested
16
+ ## Possible Implementation
17
+ <!--- Optionally suggest an idea to implement or a workaround to fix the issue -->
15
18
 
16
- **Branch/Commit:**
17
-
18
- Inform what branch/commit/version of "next_rails" you are using.
19
-
20
- **Describe the feature:**
21
-
22
- Please include a detailed description of the feature you are requesting and any detail on it’s expected behavior.
23
-
24
- > **As a \<role name\>** > **I do \<something\>** > **And then I do \<another action\>** > **And I see \<some result\>**
25
-
26
- **Problem:**
27
-
28
- Please include a detailed description of the problem this feature would solve.
29
-
30
- > **As a \<role name\>** > **I want to \<do something\>** > **So that I can achieve a \<goal\>**
31
-
32
- **Mockups:**
33
-
34
- Include any mockup idea related to the requested feature if it applies.
35
-
36
- **Resources:**
37
-
38
- If you have resources related to the implementation or research for this feature, add them here.
19
+ ## Resources:
20
+ <!--- If you have resources related to the implementation or research for this feature, add them here. -->
21
+ <!--- If possible, include any mockup ideas related to the requested feature. -->
39
22
 
40
23
  **I will abide by the [code of conduct](https://github.com/fastruby/next_rails/blob/main/CODE_OF_CONDUCT.md)**
data/CHANGELOG.md CHANGED
@@ -1,4 +1,9 @@
1
- # main [(unreleased)](https://github.com/fastruby/next_rails/compare/v1.2.1...main)
1
+ # main [(unreleased)](https://github.com/fastruby/next_rails/compare/v1.2.2...main)
2
+ * Your changes/patches go here.
3
+ # v1.2.2 / 2023-03-03 [(commits)](https://github.com/fastruby/next_rails/compare/v1.2.1...v1.2.2)
4
+ * [BUGFIX: Fixed `KernelWarnTracker#warn signature to match `Kernel#warn` for ruby 2.5+](https://github.com/fastruby/next_rails/pull/82)
5
+ * [CHORE: Added updated templates for bug fixes, feature requests and pull requests](https://github.com/fastruby/next_rails/pull/64) as per [this RFC](https://github.com/fastruby/RFCs/blob/main/2021-10-13-github-templates.md)
6
+ * [FEATURE: Turn BundleReport into a module](https://github.com/fastruby/next_rails/pull/63)
2
7
 
3
8
  # v1.2.1 / 2022-09-26 [(commits)](https://github.com/fastruby/next_rails/compare/v1.2.0...v1.2.1)
4
9
 
@@ -8,6 +13,8 @@
8
13
 
9
14
  - [BUGFIX: bundle_report outdated was giving an exception due to missing method latest_version](https://github.com/fastruby/next_rails/pull/62)
10
15
 
16
+ - [FEATURE: `bundle_report outdated` outputs in JSON format when passed optional argument](https://github.com/fastruby/next_rails/pull/61)
17
+
11
18
  # v1.2.0 / 2022-08-12 [(commits)](https://github.com/fastruby/next_rails/compare/v1.1.0...v1.2.0)
12
19
 
13
20
  - [FEATURE: Support Ruby versions as old as Ruby 2.0](https://github.com/fastruby/next_rails/pull/54)
data/README.md CHANGED
@@ -29,10 +29,17 @@ Learn about your Gemfile and see what needs updating.
29
29
  ```bash
30
30
  # Show all out-of-date gems
31
31
  bundle_report outdated
32
+
32
33
  # Show five oldest, out-of-date gems
33
34
  bundle_report outdated | head -n 5
35
+
36
+ # Show all out-of-date gems in machine readable JSON format
37
+ bundle_report outdated --json
38
+
34
39
  # Show gems that don't work with Rails 5.2.0
35
40
  bundle_report compatibility --rails-version=5.2.0
41
+
42
+ # Show the usual help message
36
43
  bundle_report --help
37
44
  # Find minimum compatible ruby version with Rails 7.0.0
38
45
  bundle_report ruby_check --rails-version=7.0.0
@@ -91,7 +98,7 @@ deprecations run
91
98
  deprecations --help # For more options and examples
92
99
  ```
93
100
 
94
- Right now, the path to the shitlist is hardcoded so make sure you store yours at `spec/support/deprecations.shitlist.json`.
101
+ Right now, the path to the shitlist is hardcoded so make sure you store yours at `spec/support/deprecation_warning.shitlist.json`.
95
102
 
96
103
  #### `next_rails` command
97
104
 
@@ -115,7 +122,9 @@ next rails s # Start server using Gemfile.next
115
122
 
116
123
  ## Installation
117
124
 
118
- Add this line to your application's Gemfile:
125
+ Add this line to your application's Gemfile
126
+
127
+ > NOTE: If you add this gem to a group, make sure it is the test env group
119
128
 
120
129
  ```ruby
121
130
  gem 'next_rails'
data/exe/bundle_report CHANGED
@@ -17,6 +17,7 @@ at_exit do
17
17
  Examples:
18
18
  #{$0} compatibility --rails-version 5.0
19
19
  #{$0} outdated
20
+ #{$0} outdated --json
20
21
 
21
22
  ruby_check To find a compatible ruby version for the target rails version
22
23
 
@@ -36,6 +37,10 @@ at_exit do
36
37
  options[:include_rails_gems] = true
37
38
  end
38
39
 
40
+ opts.on("--json", "Output JSON in outdated report (defaults to false)") do
41
+ options[:format] = 'json'
42
+ end
43
+
39
44
  opts.on_tail("-h", "--help", "Show this message") do
40
45
  puts opts
41
46
  exit
@@ -54,7 +59,7 @@ at_exit do
54
59
 
55
60
  case report_type
56
61
  when "ruby_check" then NextRails::BundleReport.compatible_ruby_version(rails_version: options.fetch(:rails_version))
57
- when "outdated" then NextRails::BundleReport.outdated
62
+ when "outdated" then NextRails::BundleReport.outdated(options.fetch(:format, nil))
58
63
  else
59
64
  NextRails::BundleReport.compatibility(rails_version: options.fetch(:rails_version, "5.0"), include_rails_gems: options.fetch(:include_rails_gems, false))
60
65
  end
@@ -18,12 +18,16 @@ class DeprecationTracker
18
18
  @callbacks ||= []
19
19
  end
20
20
 
21
- def warn(*messages)
21
+ def warn(*messages, uplevel: nil)
22
22
  KernelWarnTracker.callbacks.each do |callback|
23
23
  messages.each { |message| callback.(message) }
24
24
  end
25
25
 
26
- super
26
+ if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.5.0")
27
+ super *messages
28
+ else
29
+ super
30
+ end
27
31
  end
28
32
  end
29
33
 
@@ -5,8 +5,10 @@ require "json"
5
5
  require "net/http"
6
6
 
7
7
  module NextRails
8
- class BundleReport
9
- def self.compatibility(rails_version: nil, include_rails_gems: nil)
8
+ module BundleReport
9
+ extend self
10
+
11
+ def compatibility(rails_version: nil, include_rails_gems: nil)
10
12
  incompatible_gems = NextRails::GemInfo.all.reject do |gem|
11
13
  gem.compatible_with_rails?(rails_version: rails_version) || (!include_rails_gems && gem.from_rails?)
12
14
  end.sort_by { |gem| gem.name }
@@ -50,13 +52,13 @@ module NextRails
50
52
  puts ERB.new(template, nil, "-").result(binding)
51
53
  end
52
54
 
53
- def self.gem_header(_gem)
55
+ def gem_header(_gem)
54
56
  header = "#{_gem.name} #{_gem.version}".bold
55
57
  header << " (loaded from git)".magenta if _gem.sourced_from_git?
56
58
  header
57
59
  end
58
60
 
59
- def self.compatible_ruby_version(rails_version)
61
+ def compatible_ruby_version(rails_version)
60
62
  # find all the versions of rails gem
61
63
  uri = URI('https://rubygems.org/api/v1/versions/rails.json')
62
64
  res = Net::HTTP.get_response(uri)
@@ -95,25 +97,62 @@ module NextRails
95
97
  end
96
98
  end
97
99
 
98
- def self.outdated
100
+ def outdated(format = nil)
99
101
  gems = NextRails::GemInfo.all
100
102
  out_of_date_gems = gems.reject(&:up_to_date?).sort_by(&:created_at)
101
- percentage_out_of_date = ((out_of_date_gems.count / gems.count.to_f) * 100).round
102
103
  sourced_from_git = gems.select(&:sourced_from_git?)
103
104
 
104
- out_of_date_gems.each do |_gem|
105
- header = "#{_gem.name} #{_gem.version}"
105
+ if format == 'json'
106
+ output_to_json(out_of_date_gems, gems.count, sourced_from_git.count)
107
+ else
108
+ output_to_stdout(out_of_date_gems, gems.count, sourced_from_git.count)
109
+ end
110
+ end
111
+
112
+ def output_to_json(out_of_date_gems, total_gem_count, sourced_from_git_count)
113
+ obj = build_json(out_of_date_gems, total_gem_count, sourced_from_git_count)
114
+ puts JSON.pretty_generate(obj)
115
+ end
116
+
117
+ def build_json(out_of_date_gems, total_gem_count, sourced_from_git_count)
118
+ output = Hash.new { [] }
119
+ out_of_date_gems.each do |gem|
120
+ output[:outdated_gems] += [
121
+ {
122
+ name: gem.name,
123
+ installed_version: gem.version,
124
+ installed_age: gem.age,
125
+ latest_version: gem.latest_version.version,
126
+ latest_age: gem.latest_version.age
127
+ }
128
+ ]
129
+ end
130
+
131
+ output.merge(
132
+ {
133
+ sourced_from_git_count: sourced_from_git_count,
134
+ total_gem_count: total_gem_count
135
+ }
136
+ )
137
+ end
138
+
139
+ def output_to_stdout(out_of_date_gems, total_gem_count, sourced_from_git_count)
140
+ out_of_date_gems.each do |gem|
141
+ header = "#{gem.name} #{gem.version}"
106
142
 
107
143
  puts <<-MESSAGE
108
- #{header.bold.white}: released #{_gem.age} (latest version, #{_gem.latest_version.version}, released #{_gem.latest_version.age})
144
+ #{header.bold.white}: released #{gem.age} (latest version, #{gem.latest_version.version}, released #{gem.latest_version.age})
109
145
  MESSAGE
110
146
  end
111
147
 
112
- puts ""
113
- puts <<-MESSAGE
114
- #{"#{sourced_from_git.count}".yellow} gems are sourced from git
115
- #{"#{out_of_date_gems.length}".red} of the #{gems.count} gems are out-of-date (#{percentage_out_of_date}%)
148
+ percentage_out_of_date = ((out_of_date_gems.count / total_gem_count.to_f) * 100).round
149
+ footer = <<-MESSAGE
150
+ #{sourced_from_git_count.to_s.yellow} gems are sourced from git
151
+ #{out_of_date_gems.count.to_s.red} of the #{total_gem_count} gems are out-of-date (#{percentage_out_of_date}%)
116
152
  MESSAGE
153
+
154
+ puts ''
155
+ puts footer
117
156
  end
118
157
  end
119
- end
158
+ end
@@ -79,7 +79,7 @@ module NextRails
79
79
  def state(rails_version)
80
80
  if compatible_with_rails?(rails_version: rails_version)
81
81
  :compatible
82
- elsif latest_compatible_version.version == "NOT FOUND"
82
+ elsif latest_compatible_version && latest_compatible_version.version == "NOT FOUND"
83
83
  :no_new_version
84
84
  elsif latest_compatible_version
85
85
  :found_compatible
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module NextRails
2
- VERSION = "1.2.1"
4
+ VERSION = "1.2.2"
3
5
  end
@@ -1,9 +1,15 @@
1
- **IMPORTANT**: Please read the README before submitting pull requests for this project. Additionally, if your PR closes any open GitHub issues, make sure you include Closes #XXXX in your comment or use the option on the PR's sidebar to add related issues to auto-close the issue that your PR fixes.
1
+ ## Description
2
+ <!--- Describe your changes in detail -->
2
3
 
3
- - [ ] Add an entry to `CHANGELOG.md` that links to this PR under the "main (unreleased)" heading.
4
+ ## Motivation and Context
5
+ <!--- Why is this change required? What problem does it solve? -->
6
+ <!--- If it fixes an open issue, please link to the issue here. -->
4
7
 
5
- Description:
8
+ ## How Has This Been Tested?
9
+ <!--- Include any relevant details about your testing environment and the steps you followed -->
10
+ <!--- For example: I am using [Safari|Firefox|Chrome] then I visit [the users path] -->
6
11
 
7
- Please include a summary of the change and which issue is fixed or which feature is introduced. If changes to the behavior are made, clearly describe what changes.
12
+ ## Screenshots:
13
+ <!-- Add screenshots (applicable to any UI changes) -->
8
14
 
9
- I will abide by the [code of conduct](https://github.com/fastruby/next_rails/blob/main/CODE_OF_CONDUCT.md).
15
+ **I will abide by the [code of conduct](https://github.com/fastruby/next_rails/blob/main/CODE_OF_CONDUCT.md)**
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: next_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ernesto Tagwerker
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2022-09-26 00:00:00.000000000 Z
12
+ date: 2023-03-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: colorize
@@ -194,7 +194,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
194
194
  - !ruby/object:Gem::Version
195
195
  version: '0'
196
196
  requirements: []
197
- rubygems_version: 3.1.6
197
+ rubygems_version: 3.0.9
198
198
  signing_key:
199
199
  specification_version: 4
200
200
  summary: A toolkit to upgrade your next Rails application