lib/tapioca/generator.rb in tapioca-0.3.1 vs lib/tapioca/generator.rb in tapioca-0.4.0
- old
+ new
@@ -43,9 +43,41 @@
say("All operations performed in working directory.", [:green, :bold])
say("Please review changes and commit them.", [:green, :bold])
end
sig { void }
+ def build_todos
+ todos_path = config.todos_path
+ compiler = Compilers::TodosCompiler.new
+ name = set_color(todos_path, :yellow, :bold)
+ say("Compiling #{name}, this may take a few seconds... ")
+
+ # Clean all existing unresolved constants before regenerating the list
+ # so Sorbet won't grab them as already resolved.
+ File.delete(todos_path) if File.exist?(todos_path)
+
+ rbi_string = compiler.compile
+ if rbi_string.empty?
+ say("Nothing to do", :green)
+ return
+ end
+
+ content = String.new
+ content << rbi_header(config.generate_command, "false")
+ content << rbi_string
+ content << "\n"
+
+ outdir = File.dirname(todos_path)
+ FileUtils.mkdir_p(outdir)
+ File.write(todos_path, content)
+
+ say("Done", :green)
+
+ say("All unresolved constants have been written to #{name}.", [:green, :bold])
+ say("Please review changes and commit them.", [:green, :bold])
+ end
+
+ sig { void }
def sync_rbis_with_gemfile
anything_done = [
perform_removals,
perform_additions,
].any?