Skip to content

Commit

Permalink
Revert verbose command output upon verify failure
Browse files Browse the repository at this point in the history
A previous PR had tried to make the command that was output when the
`--verify` step failed to be more surgical so that users can run a
command that would potentially be faster.

However, the constants that we collect as Tapioca is generating DSL RBI
files do not necessarily map to real constants inside the application.
Some of the constants are synthetic, for example
`GeneratedUrlHelpersModule`, and would not work if supplied on a
`tapioca dsl` command line. Thus, the verbose output ends up doing more
harm than good.
  • Loading branch information
paracycle committed Apr 14, 2021
1 parent 03582cc commit 86b4e82
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
13 changes: 4 additions & 9 deletions lib/tapioca/generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,6 @@ def build_dsl(requested_constants, should_verify: false, quiet: false)
}
)

constant_lookup = {}

compiler.run do |constant, contents|
constant_name = Module.instance_method(:name).bind(constant).call

Expand All @@ -159,13 +157,12 @@ def build_dsl(requested_constants, should_verify: false, quiet: false)

if filename
rbi_files_to_purge.delete(filename)
constant_lookup[filename.relative_path_from(outpath)] = constant_name
end
end
say("")

if should_verify
perform_dsl_verification(outpath, constant_lookup)
perform_dsl_verification(outpath)
else
purge_stale_dsl_rbi_files(rbi_files_to_purge)

Expand Down Expand Up @@ -596,17 +593,15 @@ def rbi_files_in(path)
end.sort
end

sig { params(dir: Pathname, constant_lookup: T::Hash[String, String]).void }
def perform_dsl_verification(dir, constant_lookup)
sig { params(dir: Pathname).void }
def perform_dsl_verification(dir)
diff = verify_dsl_rbi(tmp_dir: dir)

if diff.empty?
say("Nothing to do, all RBIs are up-to-date.")
else
constants = T.unsafe(constant_lookup).values_at(*diff.keys).join(" ")

say("RBI files are out-of-date, please run:")
say(" `#{Config::DEFAULT_COMMAND} dsl #{constants}`")
say(" `#{Config::DEFAULT_COMMAND} dsl`")

say("")

Expand Down
4 changes: 2 additions & 2 deletions spec/tapioca/cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ class Image
RBI files are out-of-date, please run:
`bin/tapioca dsl Image`
`bin/tapioca dsl`
Reason:
File(s) added:
Expand Down Expand Up @@ -694,7 +694,7 @@ class Image
RBI files are out-of-date, please run:
`bin/tapioca dsl Image`
`bin/tapioca dsl`
Reason:
File(s) changed:
Expand Down

0 comments on commit 86b4e82

Please sign in to comment.