rails-diff 0.4.1 → 0.5.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 +16 -0
- data/README.md +34 -1
- data/lib/rails/diff/version.rb +1 -1
- data/lib/rails/diff.rb +23 -10
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 38eec723e013294fcf65e9e7ca0d87bbb5a47247d1ac981e5636919c8ec23ab3
|
4
|
+
data.tar.gz: a94ae7dfea382c293363a14bea0e26170527d8c09aa6d152fd14c3fb207a267d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff731b2ca714546421d437c6b9c2dd43560e3db9f3ca4eeaba846547e2f50763786d0e466cb0a44dec9fd40f7631c888117b3c8f6f5ae0500b08243231164a40
|
7
|
+
data.tar.gz: 1459938e4540dcbbce30cfa9214386d092c1081425419c9224f14e9a426556df62c0d09a46a206ab6f3c6c2900a2f0a8309ec6b8c07faee5694c496b95ecc26f
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,20 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [0.4.2] - 2025-03-10
|
4
|
+
|
5
|
+
- Don't abort process on bundle check failure.
|
6
|
+
- Add optional debug logs.
|
7
|
+
|
8
|
+
```sh
|
9
|
+
rails-diff file Gemfile --debug
|
10
|
+
```
|
11
|
+
|
12
|
+
or
|
13
|
+
|
14
|
+
```sh
|
15
|
+
DEBUG=1 rails-diff file Gemfile
|
16
|
+
```
|
17
|
+
|
3
18
|
## [0.4.1] - 2025-03-05
|
4
19
|
|
5
20
|
- Bump `rack` and `uri` minor versions.
|
@@ -49,6 +64,7 @@ M## [0.1.1] - 2025-02-21
|
|
49
64
|
|
50
65
|
- Initial release
|
51
66
|
|
67
|
+
[0.4.1]: https://github.com/matheusrich/rails-diff/releases/tag/v0.4.1
|
52
68
|
[0.4.0]: https://github.com/matheusrich/rails-diff/releases/tag/v0.4.0
|
53
69
|
[0.3.0]: https://github.com/matheusrich/rails-diff/releases/tag/v0.3.0
|
54
70
|
[0.2.1]: https://github.com/matheusrich/rails-diff/releases/tag/v0.2.1
|
data/README.md
CHANGED
@@ -88,6 +88,36 @@ Example:
|
|
88
88
|
rails-diff file Dockerfile --new-app-options="--database=postgresql"
|
89
89
|
```
|
90
90
|
|
91
|
+
#### --skip <files/directories>
|
92
|
+
|
93
|
+
Skip specific files or directories during the diff.
|
94
|
+
|
95
|
+
```bash
|
96
|
+
rails-diff generated scaffold Post --skip app/views app/helpers
|
97
|
+
```
|
98
|
+
|
99
|
+
#### --clear-cache/--no-cache
|
100
|
+
|
101
|
+
Clear the cache directory to force cloning Rails and regenerating the Rails template app.
|
102
|
+
|
103
|
+
```bash
|
104
|
+
rails-diff file Dockerfile --clear-cache
|
105
|
+
```
|
106
|
+
|
107
|
+
#### --debug
|
108
|
+
|
109
|
+
Print debug information.
|
110
|
+
|
111
|
+
```sh
|
112
|
+
rails-diff file Gemfile --debug
|
113
|
+
```
|
114
|
+
|
115
|
+
or with an environment variable:
|
116
|
+
|
117
|
+
```sh
|
118
|
+
DEBUG=1 rails-diff file Gemfile
|
119
|
+
```
|
120
|
+
|
91
121
|
## How it works
|
92
122
|
|
93
123
|
When you run the diff, it will:
|
@@ -100,7 +130,10 @@ When you run the diff, it will:
|
|
100
130
|
|
101
131
|
The gem caches the generated Rails application to avoid regenerating it on every run. The cache is automatically invalidated when:
|
102
132
|
- Rails has new commits on main
|
103
|
-
- The cache directory doesn't exist
|
133
|
+
- The cache directory doesn't exist (or is cleared with the `--clear-cache` option)
|
134
|
+
- You use `--new-app-options` with different options
|
135
|
+
- You change your `~/.railsrc` file
|
136
|
+
- You use `--commit` with a different commit
|
104
137
|
|
105
138
|
You can also force clear the cache by using the `--no-cache` option (or its alias `--clear-cache`) with any command.
|
106
139
|
|
data/lib/rails/diff/version.rb
CHANGED
data/lib/rails/diff.rb
CHANGED
@@ -35,19 +35,29 @@ module Rails
|
|
35
35
|
|
36
36
|
private
|
37
37
|
|
38
|
-
def system!(*cmd)
|
38
|
+
def system!(*cmd, abort: true)
|
39
39
|
_, stderr, status = Open3.capture3(*cmd)
|
40
40
|
|
41
|
-
|
42
|
-
|
41
|
+
debug cmd.join(" ")
|
42
|
+
|
43
|
+
if status.success?
|
44
|
+
true
|
45
|
+
elsif abort
|
46
|
+
$stderr.puts "\e[1;31mCommand failed:\e[0m #{cmd.join(' ')}"
|
43
47
|
abort stderr
|
48
|
+
else
|
49
|
+
false
|
44
50
|
end
|
45
|
-
|
46
|
-
true
|
47
51
|
end
|
48
52
|
|
49
53
|
def info(message)
|
50
|
-
puts "\e[1;34minfo:\e[0m
|
54
|
+
puts "\e[1;34minfo:\e[0m\t#{message}"
|
55
|
+
end
|
56
|
+
|
57
|
+
def debug(message)
|
58
|
+
return unless ENV["DEBUG"]
|
59
|
+
|
60
|
+
puts "\e[1;33mdebug:\e[0m\t#{message}"
|
51
61
|
end
|
52
62
|
|
53
63
|
def clear_cache
|
@@ -124,7 +134,7 @@ module Rails
|
|
124
134
|
|
125
135
|
def install_app_dependencies
|
126
136
|
Dir.chdir(template_app_path) do
|
127
|
-
unless system!("bundle check")
|
137
|
+
unless system!("bundle check", abort: false)
|
128
138
|
info "Installing application dependencies"
|
129
139
|
system!("bundle install")
|
130
140
|
end
|
@@ -176,16 +186,16 @@ module Rails
|
|
176
186
|
|
177
187
|
def generate_app
|
178
188
|
Dir.chdir("railties") do
|
179
|
-
unless system!("bundle check")
|
189
|
+
unless system!("bundle check", abort: false)
|
180
190
|
info "Installing Rails dependencies"
|
181
191
|
system!("bundle install")
|
182
192
|
end
|
183
193
|
|
184
194
|
if railsrc_options
|
185
|
-
info "Using default options from #{RAILSRC_PATH}:\n > #{railsrc_options.join(' ')}"
|
195
|
+
info "Using default options from #{RAILSRC_PATH}:\n\t > #{railsrc_options.join(' ')}"
|
186
196
|
end
|
187
197
|
|
188
|
-
info "Generating new Rails application\n > #{rails_new_command.join(' ')}"
|
198
|
+
info "Generating new Rails application\n\t > #{rails_new_command.join(' ')}"
|
189
199
|
system!(*rails_new_command)
|
190
200
|
end
|
191
201
|
end
|
@@ -228,12 +238,14 @@ module Rails
|
|
228
238
|
class_option :fail_on_diff, type: :boolean, desc: "Fail if there are differences"
|
229
239
|
class_option :commit, type: :string, desc: "Compare against a specific commit"
|
230
240
|
class_option :new_app_options, type: :string, desc: "Options to pass to the rails new command"
|
241
|
+
class_option :debug, type: :boolean, desc: "Print debug information", aliases: ["-d"]
|
231
242
|
|
232
243
|
def self.exit_on_failure? = true
|
233
244
|
|
234
245
|
desc "file FILE [FILE ...]", "Compare one or more files from your repository with Rails' generated version"
|
235
246
|
def file(*files)
|
236
247
|
abort "Please provide at least one file to compare" if files.empty?
|
248
|
+
ENV["DEBUG"] = "true" if options[:debug]
|
237
249
|
|
238
250
|
diff = Rails::Diff.file(*files, no_cache: options[:no_cache], commit: options[:commit], new_app_options: options[:new_app_options])
|
239
251
|
return if diff.empty?
|
@@ -244,6 +256,7 @@ module Rails
|
|
244
256
|
desc "generated GENERATOR [args]", "Compare files that would be created by a Rails generator"
|
245
257
|
option :skip, type: :array, desc: "Skip specific files or directories", aliases: ["-s"], default: []
|
246
258
|
def generated(generator_name, *args)
|
259
|
+
ENV["DEBUG"] = "true" if options[:debug]
|
247
260
|
diff = Rails::Diff.generated(generator_name, *args, no_cache: options[:no_cache], skip: options[:skip], commit: options[:commit], new_app_options: options[:new_app_options])
|
248
261
|
return if diff.empty?
|
249
262
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-diff
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matheus Richard
|
8
8
|
bindir: exe
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-03-
|
10
|
+
date: 2025-03-10 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: rails
|