22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
# File 'lib/tapioca/helpers/rbi_helper.rb', line 22
def validate_rbi_files(command:, gem_dir:, dsl_dir:, auto_strictness:, gems: [], compilers: [])
error_url_base = Spoom::Sorbet::Errors::DEFAULT_ERROR_URL_BASE
say("Checking generated RBI files... ")
res = sorbet(
"--no-config",
"--error-url-base=#{error_url_base}",
"--stop-after namer",
dsl_dir,
gem_dir
)
say(" Done", :green)
errors = Spoom::Sorbet::Errors::Parser.parse_string(res.err)
if errors.empty?
say(" No errors found\n\n", [:green, :bold])
return
end
parse_errors = errors.select { |error| error.code < 4000 }
if parse_errors.any?
say_error(<<~ERR, :red)
##### INTERNAL ERROR #####
There are parse errors in the generated RBI files.
This seems related to a bug in Tapioca.
Please open an issue at https://github.com/Shopify/tapioca/issues/new with the following information:
Tapioca v#{Tapioca::VERSION}
Command:
#{command}
ERR
say_error(<<~ERR, :red) if gems.any?
Gems:
#{gems.map { |gem| " #{gem.name} (#{gem.version})" }.join("\n")}
ERR
say_error(<<~ERR, :red) if compilers.any?
Compilers:
#{compilers.map { |compiler| " #{compiler.name}" }.join("\n")}
ERR
say_error(<<~ERR, :red)
Errors:
#{parse_errors.map { |error| " #{error}" }.join("\n")}
##########################
ERR
end
if auto_strictness
redef_errors = errors.select { |error| error.code == 4010 }
update_gem_rbis_strictnesses(redef_errors, gem_dir)
end
Kernel.exit(1) if parse_errors.any?
end
|