rails_preflight 0.1.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/README.md +15 -4
- data/database/deprecations.yml +3 -2
- data/lib/rails_preflight/config_analyzer.rb +58 -1
- data/lib/rails_preflight/deprecation_analyzer.rb +1 -1
- data/lib/rails_preflight/dual_boot_analyzer.rb +79 -0
- data/lib/rails_preflight/json_report.rb +1 -1
- data/lib/rails_preflight/markdown_report.rb +2 -1
- data/lib/rails_preflight/report_generator.rb +1 -0
- data/lib/rails_preflight/summary_calculator.rb +6 -1
- data/lib/rails_preflight/upgrade_analyzer.rb +2 -1
- data/lib/rails_preflight/version.rb +1 -1
- data/lib/rails_preflight.rb +1 -0
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5116d66e0950679bf5a2c02c21220a866955d6e309c611899e23413572e3139c
|
|
4
|
+
data.tar.gz: 5c55311682aaff5b5865fb81d7e461cf7a42713c782a3f3165c406a4d5f692b2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ec6b19914d2de83e4fcb6b96689612ab6365302a4e58a44ad406ee958c6045b6f8a96eb1b42c07ff1395e70f431d17c03ce7489cbcafaaf0f926d1c86acdd987
|
|
7
|
+
data.tar.gz: f5bf7047615dc677b4a4a1d454d0450e9114797476bc04e098b186a428968e7a2efc47d9ba6b88cefb89b96eb5bdcdae6c0c597f8c11093cbf12f9f34885ee6e
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.2.0 (2026-10-30)
|
|
4
|
+
|
|
5
|
+
- Each step links to its RailsDiff and reminds you to run `bin/rails app:update`; JSON steps carry the link as `railsdiff` (#29)
|
|
6
|
+
- Dual boot: a tip to set it up when there's none, and a tip to add a CI job when CI doesn't run it (#30)
|
|
7
|
+
- A warning when `.ruby-version`, the Dockerfile and CI config disagree on Ruby (#30)
|
|
8
|
+
- Secrets committed in config YAML are flagged by file and key, never the value, outside the development and test sections (#31)
|
|
9
|
+
- A production `secret_key_base` in `config/secrets.yml` is flagged, as a blocker when the target is Rails 7.2 or later, which stops reading that file; one read from `ENV["SECRET_KEY_BASE"]` isn't (#31)
|
|
10
|
+
- The `STATS_DIRECTORIES` message shows its replacement as one code span (#33)
|
|
11
|
+
|
|
3
12
|
## 0.1.2 (2026-10-13)
|
|
4
13
|
|
|
5
14
|
- Code inside Packwerk packs (`packs/<name>/app`, `lib`, `spec`, ...) is scanned like the app root, and rules scoped to `app/helpers` or `spec` apply inside packs too (#22, thanks @JuanVqz)
|
data/README.md
CHANGED
|
@@ -44,6 +44,8 @@ The audit analyzes your project for common Rails upgrade risk factors:
|
|
|
44
44
|
- Docker runtime risks (EOL base image, locale, tzdata, OpenSSL mismatch)
|
|
45
45
|
- Database schema risks (charset, integer IDs)
|
|
46
46
|
- Missing or outdated `config.load_defaults`
|
|
47
|
+
- Secrets committed in config YAML, by file and key, never the value; a production `secret_key_base` in `config/secrets.yml`, which Rails 7.2 stops reading
|
|
48
|
+
- Dual boot (`Gemfile.next`, `next?` in the Gemfile, bootboot) and whether CI runs it, and a Ruby version that `.ruby-version`, the Dockerfile and CI config disagree on
|
|
47
49
|
|
|
48
50
|
The output is a **single HTML report** designed to be:
|
|
49
51
|
|
|
@@ -103,7 +105,7 @@ The tool will analyze:
|
|
|
103
105
|
- `db/schema.rb` (if present; an app on `db/structure.sql` gets a note that the schema checks were skipped)
|
|
104
106
|
- `config/application.rb` and `config/**/*.yml`
|
|
105
107
|
- `.rb`, `.erb`, `.haml`, `.slim` and `.rake` files under `app/`, `config/`, `db/`, `lib/`, `test/` and `spec/`, at the root and in each Packwerk pack (`packs/<name>/app/`, ...)
|
|
106
|
-
- Scripts and CI config (`bin/`, `script/`, Procfiles, Makefiles, CI workflows) for removed rake tasks
|
|
108
|
+
- Scripts and CI config (`bin/`, `script/`, Procfiles, Makefiles, CI workflows) for removed rake tasks, and CI config for dual boot and its Ruby version
|
|
107
109
|
|
|
108
110
|
And generate:
|
|
109
111
|
|
|
@@ -165,7 +167,7 @@ It's a checklist per step, with `file:line` and the matched line under each find
|
|
|
165
167
|
```markdown
|
|
166
168
|
## Step 3: 6.1 to 7.0
|
|
167
169
|
|
|
168
|
-
Needs Ruby 2.7.0–3.2: 2.7.2 works.
|
|
170
|
+
Needs Ruby 2.7.0–3.2: 2.7.2 works. Run `bin/rails app:update` and compare with [RailsDiff](https://railsdiff.org/6.1.0/7.0.0).
|
|
169
171
|
|
|
170
172
|
- [ ] **Blocker:** annotate 3.1.1 requires activerecord >= 3.2, < 7.0, so it doesn't install on Rails 7.0. Upgrade it to a release that allows 7.0, or replace it.
|
|
171
173
|
- [ ] **Blocker:** `ActionMailer::DeliveryJob` and `ActionMailer::Parameterized::DeliveryJob` were removed in Rails 7.0. Mail is delivered by `ActionMailer::MailDeliveryJob`. ([source](https://guides.rubyonrails.org/7_0_release_notes.html#action-mailer-removals))
|
|
@@ -181,12 +183,13 @@ Needs Ruby 2.7.0–3.2: 2.7.2 works.
|
|
|
181
183
|
rails-preflight --format json --stdout 7.2 /path/to/your/app | jq '.counts'
|
|
182
184
|
```
|
|
183
185
|
|
|
184
|
-
The top level holds `schema`, `tool`, `app`, `current_rails`, `target_rails`, `ruby`, `offline`, `verdict` and `counts`, then the findings in `before` (before the first step), `steps` (each with `from`, `version`, its Ruby note and `findings`), `ahead` (keyed by the Rails version that removes them) and `cant_see`. There's no timestamp, so the same app gives the same output. Schema 1 may still change before 1.0; the number goes up when it does. A step from the same run, shortened ([full sample](docs/sample-report.json)):
|
|
186
|
+
The top level holds `schema`, `tool`, `app`, `current_rails`, `target_rails`, `ruby`, `offline`, `verdict` and `counts`, then the findings in `before` (before the first step), `steps` (each with `from`, `version`, its Ruby note, `railsdiff` and `findings`), `ahead` (keyed by the Rails version that removes them) and `cant_see`. There's no timestamp, so the same app gives the same output. Schema 1 may still change before 1.0; the number goes up when it does. A step from the same run, shortened ([full sample](docs/sample-report.json)):
|
|
185
187
|
|
|
186
188
|
```json
|
|
187
189
|
{
|
|
188
190
|
"from": "6.1",
|
|
189
191
|
"version": "7.0",
|
|
192
|
+
"railsdiff": "https://railsdiff.org/6.1.0/7.0.0",
|
|
190
193
|
"findings": [
|
|
191
194
|
{
|
|
192
195
|
"section": "Gem Compatibility",
|
|
@@ -227,7 +230,7 @@ rails-preflight --offline --format json --fail-on blockers 7.2
|
|
|
227
230
|
|
|
228
231
|
## Roadmap
|
|
229
232
|
|
|
230
|
-
|
|
233
|
+
What's planned is in [ROADMAP.md](ROADMAP.md).
|
|
231
234
|
|
|
232
235
|
## Philosophy
|
|
233
236
|
|
|
@@ -248,6 +251,14 @@ bundle exec rake
|
|
|
248
251
|
|
|
249
252
|
CI runs the suite on every Ruby from 2.7 to 4.0.
|
|
250
253
|
|
|
254
|
+
## Support the project ❤️
|
|
255
|
+
|
|
256
|
+
RailsPreFlight is independently developed and maintained. If it helps you assess an upgrade, identify risks, or save engineering time, consider [sponsoring its development](https://github.com/sponsors/aslam).
|
|
257
|
+
|
|
258
|
+
Sponsorship helps support ongoing maintenance, compatibility updates, and improvements.
|
|
259
|
+
|
|
260
|
+
Contributions, bug reports, and sharing the project are equally appreciated.
|
|
261
|
+
|
|
251
262
|
## License
|
|
252
263
|
|
|
253
264
|
MIT
|
data/database/deprecations.yml
CHANGED
|
@@ -103,7 +103,8 @@ deprecations:
|
|
|
103
103
|
recategorization: "Rails 7.1 -> 7.2"
|
|
104
104
|
fix_effort: low
|
|
105
105
|
- id: fixture_path_assignment
|
|
106
|
-
|
|
106
|
+
# Ruby reads a bare `fixture_path = x` as a local variable; the removed setter always has a receiver
|
|
107
|
+
pattern: "\\.fixture_path\\s*=(?!=)"
|
|
107
108
|
message: "'fixture_path' was removed in Rails 7.2. Assign 'fixture_paths' instead, which takes an array."
|
|
108
109
|
removed_in: "7.2"
|
|
109
110
|
severity: error
|
|
@@ -228,7 +229,7 @@ deprecations:
|
|
|
228
229
|
fix_effort: medium
|
|
229
230
|
- id: stats_directories
|
|
230
231
|
pattern: "\\bSTATS_DIRECTORIES\\b"
|
|
231
|
-
message: "'STATS_DIRECTORIES' was removed in Rails 8.1. Register extra directories with Rails::CodeStatistics.register_directory(
|
|
232
|
+
message: "'STATS_DIRECTORIES' was removed in Rails 8.1. Register extra directories with 'Rails::CodeStatistics.register_directory(\"Services\", \"app/services\")'."
|
|
232
233
|
removed_in: "8.1"
|
|
233
234
|
severity: error
|
|
234
235
|
confidence: "High"
|
|
@@ -1,10 +1,21 @@
|
|
|
1
1
|
# lib/rails_preflight/config_analyzer.rb
|
|
2
|
+
require_relative 'deprecation_analyzer'
|
|
3
|
+
|
|
2
4
|
module RailsPreflight
|
|
3
5
|
class ConfigAnalyzer
|
|
4
|
-
|
|
6
|
+
# `key: value` in YAML, key quoted or not, with the value up to a trailing comment.
|
|
7
|
+
YAML_PAIR = /^\s*-?\s*["']?([\w-]+)["']?\s*:\s*(.*?)\s*(?:\s#.*)?$/
|
|
8
|
+
# Values, unquoted, that hold nothing secret: ERB, aliases, anchors, flow collections, booleans, null, numbers.
|
|
9
|
+
NOT_LITERAL = /\A(?:<%|[*&{\[]|(?:true|false|yes|no|null|~|-?\d+(?:\.\d+)?)\z)/i
|
|
10
|
+
# Top-level sections whose values never reach production.
|
|
11
|
+
LOCAL_ENVS = %w[development test].freeze
|
|
12
|
+
SECRETS_REMOVED = "https://guides.rubyonrails.org/7_2_release_notes.html#railties-removals"
|
|
13
|
+
|
|
14
|
+
def initialize(root_path = Dir.pwd, current_rails = nil, target_rails: nil)
|
|
5
15
|
@root_path = root_path
|
|
6
16
|
# load_defaults takes a minor version ("7.1"), so compare at that level
|
|
7
17
|
@current_rails = Gem::Version.new(current_rails.to_s.split(".").first(2).join(".")) if current_rails
|
|
18
|
+
@target_rails = Gem::Version.new(target_rails) if target_rails && Gem::Version.correct?(target_rails)
|
|
8
19
|
end
|
|
9
20
|
|
|
10
21
|
def run
|
|
@@ -17,6 +28,9 @@ module RailsPreflight
|
|
|
17
28
|
result[:checks] << { message: "config/application.rb not found.", status: :warning, kind: :unknown }
|
|
18
29
|
end
|
|
19
30
|
|
|
31
|
+
check_committed_secrets(result[:checks])
|
|
32
|
+
check_secrets_secret_key_base(result[:checks])
|
|
33
|
+
|
|
20
34
|
if result[:checks].any?
|
|
21
35
|
result[:status] = :warning
|
|
22
36
|
else
|
|
@@ -42,5 +56,48 @@ module RailsPreflight
|
|
|
42
56
|
checks << { message: message, status: :warning, fix_effort: :medium }
|
|
43
57
|
end
|
|
44
58
|
end
|
|
59
|
+
|
|
60
|
+
# Secret-named keys with a literal value, outside the development and test sections. Shows the key, never the value.
|
|
61
|
+
def check_committed_secrets(checks)
|
|
62
|
+
hits = yaml_pairs(Dir.glob(File.join(@root_path, "config", "**", "*.{yml,yml.erb}")).reject { |file| file.include?("/locales/") })
|
|
63
|
+
.select { |_, _, section, key, value| key.match?(DeprecationAnalyzer::SECRET_NAME) && literal?(value) && !LOCAL_ENVS.include?(section) }
|
|
64
|
+
return if hits.empty?
|
|
65
|
+
|
|
66
|
+
them = hits.one? ? "it" : "them"
|
|
67
|
+
checks << { message: "#{hits.one? ? 'A secret is' : "#{hits.size} secrets are"} committed in config YAML, where anyone with the repository can read #{them}. Rotate #{them}, and read #{them} from credentials or ENV instead.",
|
|
68
|
+
status: :warning, fix_effort: :medium, files: hits.map { |file, line, _, key| { file: file, line: line, snippet: "#{key}: [hidden]" } } }
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# Rails 7.2 stops reading config/secrets.yml, so a production secret_key_base set there is lost; one read from
|
|
72
|
+
# ENV["SECRET_KEY_BASE"] still works, since 7.2 reads that variable itself.
|
|
73
|
+
def check_secrets_secret_key_base(checks)
|
|
74
|
+
return if @current_rails && @current_rails >= Gem::Version.new("7.2")
|
|
75
|
+
|
|
76
|
+
hit = yaml_pairs([File.join(@root_path, "config", "secrets.yml")]).find do |_, _, section, key, value|
|
|
77
|
+
%w[production shared].include?(section) && key == "secret_key_base" && !value.empty? && !value.match?(/ENV(?:\[|\.fetch\(\s*)["']SECRET_KEY_BASE["']/)
|
|
78
|
+
end
|
|
79
|
+
return unless hit
|
|
80
|
+
|
|
81
|
+
checks << { message: "'config/secrets.yml' sets 'secret_key_base' for production, and Rails 7.2 no longer reads 'config/secrets.yml'. Move the same value to credentials or 'SECRET_KEY_BASE' first: a new one invalidates sessions and signed cookies.",
|
|
82
|
+
status: @target_rails && @target_rails >= Gem::Version.new("7.2") ? :failed : :warning, removed_in: "7.2", fix_effort: :medium,
|
|
83
|
+
source: SECRETS_REMOVED, files: [{ file: hit[0], line: hit[1], snippet: "secret_key_base: [hidden]" }] }
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def literal?(value)
|
|
87
|
+
value = value.sub(/\A(["'])(.*)\1\z/, '\2')
|
|
88
|
+
!value.empty? && !value.match?(NOT_LITERAL)
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
# [file, line, top-level section, key, value] for each `key: value` line in the files that exist.
|
|
92
|
+
def yaml_pairs(files)
|
|
93
|
+
files.select { |file| File.file?(file) }.sort.flat_map do |file|
|
|
94
|
+
section = nil
|
|
95
|
+
File.foreach(file, encoding: "UTF-8").with_index(1).filter_map do |line, number|
|
|
96
|
+
section = $1 if line =~ /^([\w-]+):/
|
|
97
|
+
next unless (pair = line.match(YAML_PAIR))
|
|
98
|
+
[file.delete_prefix(File.join(@root_path, "")), number, section, pair[1], pair[2]]
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
end
|
|
45
102
|
end
|
|
46
103
|
end
|
|
@@ -71,7 +71,7 @@ module RailsPreflight
|
|
|
71
71
|
# Rubocop Advisory Check
|
|
72
72
|
if check_rubocop_rails
|
|
73
73
|
result[:checks] << {
|
|
74
|
-
message: "rubocop-rails is installed. Run
|
|
74
|
+
message: "rubocop-rails is installed. Run 'bundle exec rubocop -a' to auto-fix more deprecations.",
|
|
75
75
|
status: :passed
|
|
76
76
|
}
|
|
77
77
|
else
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# lib/rails_preflight/dual_boot_analyzer.rb
|
|
2
|
+
require_relative 'docker_analyzer'
|
|
3
|
+
|
|
4
|
+
module RailsPreflight
|
|
5
|
+
# Before the first step: can the app boot both Rails versions, does CI test both, and do the places
|
|
6
|
+
# that name a Ruby agree on it.
|
|
7
|
+
class DualBootAnalyzer
|
|
8
|
+
CI_GLOBS = %w[.github/workflows/*.{yml,yaml} .circleci/config.yml .gitlab-ci.yml .travis.yml].freeze
|
|
9
|
+
NEXT_RAILS = "https://github.com/fastruby/next_rails"
|
|
10
|
+
# next_rails runs the next boot with BUNDLE_GEMFILE=Gemfile.next; bootboot with DEPENDENCIES_NEXT=1.
|
|
11
|
+
CI_RUNS_NEXT = /Gemfile\.next|BUNDLE_GEMFILE|DEPENDENCIES_NEXT/
|
|
12
|
+
# setup-ruby's `ruby-version: 3.3`, and image tags such as `ruby:3.3` or `cimg/ruby:3.3.5`. A matrix
|
|
13
|
+
# (`ruby-version: ${{ matrix.ruby }}`) isn't resolved, so it's never compared.
|
|
14
|
+
CI_RUBY = /(?:ruby-version:\s*["']?|\bruby:)(\d+\.\d+(?:\.\d+)?)/
|
|
15
|
+
|
|
16
|
+
def initialize(root_path = Dir.pwd)
|
|
17
|
+
@root_path = root_path
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def run
|
|
21
|
+
result = { title: "Dual Boot", status: :passed, checks: [], confidence: :medium }
|
|
22
|
+
ci = Dir.glob(CI_GLOBS.map { |glob| File.join(@root_path, glob) }).sort.to_h { |file| [relative(file), File.read(file, encoding: "UTF-8")] }
|
|
23
|
+
|
|
24
|
+
if (setup = dual_boot)
|
|
25
|
+
if ci.any? && ci.values.none? { |content| content.match?(CI_RUNS_NEXT) }
|
|
26
|
+
result[:checks] << { message: "Dual boot is set up (#{setup}), but CI only runs the current Gemfile. Add a CI job with 'BUNDLE_GEMFILE=Gemfile.next', so each step is tested on the next Rails before it ships.",
|
|
27
|
+
status: :passed, kind: :tip, fix_effort: :low, source: NEXT_RAILS }
|
|
28
|
+
else
|
|
29
|
+
result[:checks] << { message: "Dual boot is set up (#{setup}).", status: :passed }
|
|
30
|
+
end
|
|
31
|
+
else
|
|
32
|
+
result[:checks] << { message: "No dual boot found (no 'Gemfile.next' or 'next?' in the Gemfile). Set it up first, e.g. with next_rails, so the app and its tests run on the current and the next Rails while each step is in progress.",
|
|
33
|
+
status: :passed, kind: :tip, fix_effort: :low, source: NEXT_RAILS }
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
check_ruby_versions(ci, result)
|
|
37
|
+
result
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
private
|
|
41
|
+
|
|
42
|
+
def dual_boot
|
|
43
|
+
gemfile = File.join(@root_path, "Gemfile")
|
|
44
|
+
if File.exist?(File.join(@root_path, "Gemfile.next")) then "'Gemfile.next'"
|
|
45
|
+
elsif File.exist?(File.join(@root_path, "Gemfile_next.lock")) then "'Gemfile_next.lock'"
|
|
46
|
+
elsif File.exist?(gemfile) && File.read(gemfile, encoding: "UTF-8").match?(/^\s*def\s+next\?/) then "'next?' in the Gemfile"
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# .ruby-version and the Dockerfile name the Ruby the app runs on, so they must agree. CI only has to test
|
|
51
|
+
# that Ruby somewhere: a matrix or a side workflow (docs, linting) on another Ruby is fine.
|
|
52
|
+
def check_ruby_versions(ci, result)
|
|
53
|
+
ruby_version_file = File.join(@root_path, ".ruby-version")
|
|
54
|
+
app = [[".ruby-version", File.exist?(ruby_version_file) && File.read(ruby_version_file)[/\d+\.\d+(?:\.\d+)?/]],
|
|
55
|
+
["Dockerfile", DockerAnalyzer.new(@root_path).detect_ruby_version]].select(&:last)
|
|
56
|
+
return if app.empty?
|
|
57
|
+
|
|
58
|
+
ci_rubies = ci.flat_map { |file, content| content.scan(CI_RUBY).flatten.uniq.map { |version| [file, version] } }
|
|
59
|
+
app_ruby = app.first.last
|
|
60
|
+
differ = app.map(&:last).any? { |version| !same?(version, app_ruby) } ||
|
|
61
|
+
(ci_rubies.any? && ci_rubies.none? { |_, version| same?(version, app_ruby) })
|
|
62
|
+
return unless differ
|
|
63
|
+
|
|
64
|
+
result[:status] = :warning
|
|
65
|
+
result[:checks] << { message: "The Ruby version differs between files: #{(app + ci_rubies).map { |source, version| "#{source} #{version}" }.join(', ')}. Make them match, so CI tests the Ruby that runs in production.",
|
|
66
|
+
status: :warning, fix_effort: :low }
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# 3.3 and 3.3.5 agree; 3.3 and 3.4 don't.
|
|
70
|
+
def same?(a, b)
|
|
71
|
+
a, b = [a, b].map { |version| version.split(".") }
|
|
72
|
+
a.first(b.size) == b.first(a.size)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def relative(file)
|
|
76
|
+
file.delete_prefix(File.join(@root_path, ""))
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
@@ -26,7 +26,7 @@ module RailsPreflight
|
|
|
26
26
|
counts: %i[broken blockers to_fix unknowns].to_h { |key| [key, @summary.fetch(key, []).size] },
|
|
27
27
|
before: @summary.fetch(:before, []).map { |entry| finding(entry) },
|
|
28
28
|
steps: @summary.fetch(:steps, []).map do |step|
|
|
29
|
-
step.slice(:from, :version, :ruby, :ruby_upgrade).merge(findings: step[:checks].map { |entry| finding(entry) })
|
|
29
|
+
step.slice(:from, :version, :ruby, :ruby_upgrade, :railsdiff).merge(findings: step[:checks].map { |entry| finding(entry) })
|
|
30
30
|
end,
|
|
31
31
|
ahead: @summary.fetch(:ahead, {}).transform_values { |entries| entries.map { |entry| finding(entry) } },
|
|
32
32
|
cant_see: @summary.fetch(:cant_see, []).map { |entry| finding(entry) }
|
|
@@ -22,7 +22,8 @@ module RailsPreflight
|
|
|
22
22
|
out << section("Before you start#{" (on Rails #{@data[:current_rails]})" if @data[:current_rails]}", before) if before.any?
|
|
23
23
|
@summary.fetch(:steps, []).each.with_index(1) do |step, i|
|
|
24
24
|
title = "Step #{i}: #{step[:from] ? "#{step[:from]} to #{step[:version]}" : "Rails #{step[:version]}"}"
|
|
25
|
-
|
|
25
|
+
note = ["#{step[:ruby]}.", ("Run `bin/rails app:update` and compare with [RailsDiff](#{step[:railsdiff]})." if step[:railsdiff])]
|
|
26
|
+
out << section(title, step[:checks], note.compact.join(" "))
|
|
26
27
|
end
|
|
27
28
|
@summary.fetch(:ahead, {}).each do |version, entries|
|
|
28
29
|
out << section("Ahead: removed in #{version}, not needed for #{@data[:target_rails]}", entries)
|
|
@@ -251,6 +251,7 @@ module RailsPreflight
|
|
|
251
251
|
<article class="step" id="<%= step_id(step[:version]) %>">
|
|
252
252
|
<div class="step-head"><h3><%= h(step[:from] ? "#{step[:from]} → #{step[:version]}" : "Rails #{step[:version]}") %></h3><span class="tag"><%= h(blocker_tag(step[:checks])) %></span></div>
|
|
253
253
|
<div class="rubynote"><span class="k">Ruby</span><span><%= h(step[:ruby]) %></span></div>
|
|
254
|
+
<% if step[:railsdiff] %><div class="rubynote"><span class="k">Config</span><span>Run <code>bin/rails app:update</code> and compare with <a href="<%= h(step[:railsdiff]) %>">RailsDiff</a></span></div><% end %>
|
|
254
255
|
<% if step[:checks].any? %>
|
|
255
256
|
<ul class="rows"><% step[:checks].each do |entry| %><%= row_html(entry) %><% end %></ul>
|
|
256
257
|
<% end %>
|
|
@@ -97,7 +97,7 @@ module RailsPreflight
|
|
|
97
97
|
max_now = @current_max_ruby
|
|
98
98
|
@hops.map do |hop|
|
|
99
99
|
note, upgraded = ruby_note(hop, ruby, max_now)
|
|
100
|
-
step = { version: hop[:version], from: from, ruby: note, ruby_upgrade: upgraded,
|
|
100
|
+
step = { version: hop[:version], from: from, ruby: note, ruby_upgrade: upgraded, railsdiff: railsdiff(from, hop[:version]),
|
|
101
101
|
checks: in_order(in_steps.select { |entry| step_for(entry) == hop[:version] }) }
|
|
102
102
|
ruby = upgraded || ruby
|
|
103
103
|
from = hop[:version]
|
|
@@ -106,6 +106,11 @@ module RailsPreflight
|
|
|
106
106
|
end
|
|
107
107
|
end
|
|
108
108
|
|
|
109
|
+
# The generated-app diff between the two minors, which is what `bin/rails app:update` brings in.
|
|
110
|
+
def railsdiff(from, to)
|
|
111
|
+
from && "https://railsdiff.org/#{from.split('.').first(2).join('.')}.0/#{to}.0"
|
|
112
|
+
end
|
|
113
|
+
|
|
109
114
|
# An API removed in one of the step versions is fixed as part of that step. A Ruby too old or too new for
|
|
110
115
|
# the target is checked against the target, so it sits in the last step, next to its Ruby note.
|
|
111
116
|
def step_for(entry)
|
|
@@ -55,11 +55,12 @@ module RailsPreflight
|
|
|
55
55
|
results << check_ruby_version
|
|
56
56
|
results << scan_gems
|
|
57
57
|
results << DockerAnalyzer.new(@project_path, checked_ruby: @eol_checked_ruby).run
|
|
58
|
+
results << DualBootAnalyzer.new(@project_path).run
|
|
58
59
|
results << GemAnalyzer.new(@project_path, lockfile_specs, hops: upgrade_hops.map { |hop| hop[:version] }, direct: lockfile&.dependencies&.keys || [],
|
|
59
60
|
last_releases: (@last_releases || {} unless @offline), target_released: target_rails_rules&.dig('released')).run
|
|
60
61
|
results << DeprecationAnalyzer.new(@project_path, target_rails: @target_rails, current_rails: current_rails&.to_s,
|
|
61
62
|
lockfile_path: @lockfile_path).run
|
|
62
|
-
results << ConfigAnalyzer.new(@project_path, current_rails).run
|
|
63
|
+
results << ConfigAnalyzer.new(@project_path, current_rails, target_rails: @target_rails).run
|
|
63
64
|
results << DatabaseAnalyzer.new(@project_path, database_rules).run
|
|
64
65
|
|
|
65
66
|
report_data = {
|
data/lib/rails_preflight.rb
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
require "rails_preflight/version"
|
|
2
2
|
require "rails_preflight/upgrade_analyzer"
|
|
3
3
|
require "rails_preflight/docker_analyzer"
|
|
4
|
+
require "rails_preflight/dual_boot_analyzer"
|
|
4
5
|
require "rails_preflight/deprecation_analyzer"
|
|
5
6
|
require "rails_preflight/gem_analyzer"
|
|
6
7
|
require "rails_preflight/config_analyzer"
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rails_preflight
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Syed Aslam
|
|
@@ -35,6 +35,7 @@ files:
|
|
|
35
35
|
- lib/rails_preflight/database_analyzer.rb
|
|
36
36
|
- lib/rails_preflight/deprecation_analyzer.rb
|
|
37
37
|
- lib/rails_preflight/docker_analyzer.rb
|
|
38
|
+
- lib/rails_preflight/dual_boot_analyzer.rb
|
|
38
39
|
- lib/rails_preflight/gem_analyzer.rb
|
|
39
40
|
- lib/rails_preflight/json_report.rb
|
|
40
41
|
- lib/rails_preflight/markdown_report.rb
|