tapioca 0.16.10 → 0.17.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/lib/ruby_lsp/tapioca/addon.rb +24 -20
- data/lib/ruby_lsp/tapioca/run_gem_rbi_check.rb +20 -20
- data/lib/tapioca/bundler_ext/auto_require_hook.rb +5 -10
- data/lib/tapioca/commands/abstract_dsl.rb +36 -62
- data/lib/tapioca/commands/abstract_gem.rb +23 -43
- data/lib/tapioca/commands/annotations.rb +27 -33
- data/lib/tapioca/commands/check_shims.rb +4 -13
- data/lib/tapioca/commands/command.rb +8 -20
- data/lib/tapioca/commands/command_without_tracker.rb +1 -1
- data/lib/tapioca/commands/configure.rb +11 -16
- data/lib/tapioca/commands/dsl_compiler_list.rb +2 -1
- data/lib/tapioca/commands/dsl_generate.rb +2 -1
- data/lib/tapioca/commands/dsl_verify.rb +2 -1
- data/lib/tapioca/commands/gem_generate.rb +4 -8
- data/lib/tapioca/commands/gem_sync.rb +2 -1
- data/lib/tapioca/commands/gem_verify.rb +3 -2
- data/lib/tapioca/commands/require.rb +3 -7
- data/lib/tapioca/commands/todo.rb +6 -10
- data/lib/tapioca/dsl/compiler.rb +28 -53
- data/lib/tapioca/dsl/compilers/aasm.rb +31 -41
- data/lib/tapioca/dsl/compilers/action_controller_helpers.rb +7 -5
- data/lib/tapioca/dsl/compilers/action_mailer.rb +5 -3
- data/lib/tapioca/dsl/compilers/action_text.rb +5 -3
- data/lib/tapioca/dsl/compilers/active_job.rb +5 -8
- data/lib/tapioca/dsl/compilers/active_model_attributes.rb +9 -7
- data/lib/tapioca/dsl/compilers/active_model_secure_password.rb +4 -2
- data/lib/tapioca/dsl/compilers/active_model_validations_confirmation.rb +4 -2
- data/lib/tapioca/dsl/compilers/active_record_associations.rb +16 -42
- data/lib/tapioca/dsl/compilers/active_record_columns.rb +19 -24
- data/lib/tapioca/dsl/compilers/active_record_delegated_types.rb +7 -5
- data/lib/tapioca/dsl/compilers/active_record_enum.rb +6 -4
- data/lib/tapioca/dsl/compilers/active_record_fixtures.rb +53 -61
- data/lib/tapioca/dsl/compilers/active_record_relations.rb +86 -119
- data/lib/tapioca/dsl/compilers/active_record_scope.rb +7 -11
- data/lib/tapioca/dsl/compilers/active_record_secure_token.rb +4 -2
- data/lib/tapioca/dsl/compilers/active_record_store.rb +4 -2
- data/lib/tapioca/dsl/compilers/active_record_typed_store.rb +18 -26
- data/lib/tapioca/dsl/compilers/active_resource.rb +18 -19
- data/lib/tapioca/dsl/compilers/active_storage.rb +5 -5
- data/lib/tapioca/dsl/compilers/active_support_concern.rb +8 -6
- data/lib/tapioca/dsl/compilers/active_support_current_attributes.rb +7 -5
- data/lib/tapioca/dsl/compilers/active_support_time_ext.rb +4 -2
- data/lib/tapioca/dsl/compilers/config.rb +4 -2
- data/lib/tapioca/dsl/compilers/frozen_record.rb +6 -9
- data/lib/tapioca/dsl/compilers/graphql_input_object.rb +8 -8
- data/lib/tapioca/dsl/compilers/graphql_mutation.rb +5 -8
- data/lib/tapioca/dsl/compilers/identity_cache.rb +10 -37
- data/lib/tapioca/dsl/compilers/json_api_client_resource.rb +8 -16
- data/lib/tapioca/dsl/compilers/kredis.rb +6 -4
- data/lib/tapioca/dsl/compilers/mixed_in_class_attributes.rb +4 -2
- data/lib/tapioca/dsl/compilers/protobuf.rb +12 -24
- data/lib/tapioca/dsl/compilers/rails_generators.rb +8 -9
- data/lib/tapioca/dsl/compilers/sidekiq_worker.rb +22 -11
- data/lib/tapioca/dsl/compilers/smart_properties.rb +11 -20
- data/lib/tapioca/dsl/compilers/state_machines.rb +14 -24
- data/lib/tapioca/dsl/compilers/url_helpers.rb +9 -7
- data/lib/tapioca/dsl/compilers.rb +4 -7
- data/lib/tapioca/dsl/helpers/active_model_type_helper.rb +13 -16
- data/lib/tapioca/dsl/helpers/active_record_column_type_helper.rb +13 -28
- data/lib/tapioca/dsl/helpers/active_record_constants_helper.rb +19 -15
- data/lib/tapioca/dsl/helpers/graphql_type_helper.rb +5 -24
- data/lib/tapioca/dsl/pipeline.rb +30 -58
- data/lib/tapioca/executor.rb +6 -12
- data/lib/tapioca/gem/events.rb +22 -28
- data/lib/tapioca/gem/listeners/base.rb +6 -6
- data/lib/tapioca/gem/listeners/dynamic_mixins.rb +4 -2
- data/lib/tapioca/gem/listeners/foreign_constants.rb +5 -7
- data/lib/tapioca/gem/listeners/methods.rb +15 -34
- data/lib/tapioca/gem/listeners/mixins.rb +6 -18
- data/lib/tapioca/gem/listeners/remove_empty_payload_scopes.rb +4 -2
- data/lib/tapioca/gem/listeners/sorbet_enums.rb +4 -2
- data/lib/tapioca/gem/listeners/sorbet_helpers.rb +4 -2
- data/lib/tapioca/gem/listeners/sorbet_props.rb +4 -2
- data/lib/tapioca/gem/listeners/sorbet_required_ancestors.rb +4 -2
- data/lib/tapioca/gem/listeners/sorbet_signatures.rb +7 -5
- data/lib/tapioca/gem/listeners/sorbet_type_variables.rb +6 -4
- data/lib/tapioca/gem/listeners/source_location.rb +7 -4
- data/lib/tapioca/gem/listeners/subconstants.rb +5 -4
- data/lib/tapioca/gem/listeners/yard_doc.rb +23 -22
- data/lib/tapioca/gem/pipeline.rb +57 -72
- data/lib/tapioca/gem_info.rb +1 -1
- data/lib/tapioca/gemfile.rb +64 -73
- data/lib/tapioca/helpers/cli_helper.rb +3 -3
- data/lib/tapioca/helpers/config_helper.rb +15 -24
- data/lib/tapioca/helpers/env_helper.rb +1 -1
- data/lib/tapioca/helpers/gem_helper.rb +5 -5
- data/lib/tapioca/helpers/git_attributes.rb +3 -3
- data/lib/tapioca/helpers/rbi_files_helper.rb +73 -67
- data/lib/tapioca/helpers/rbi_helper.rb +14 -22
- data/lib/tapioca/helpers/sorbet_helper.rb +9 -18
- data/lib/tapioca/helpers/source_uri.rb +15 -25
- data/lib/tapioca/helpers/test/content.rb +6 -6
- data/lib/tapioca/helpers/test/dsl_compiler.rb +19 -29
- data/lib/tapioca/helpers/test/isolation.rb +4 -4
- data/lib/tapioca/helpers/test/template.rb +5 -7
- data/lib/tapioca/internal.rb +5 -1
- data/lib/tapioca/loaders/dsl.rb +11 -19
- data/lib/tapioca/loaders/gem.rb +6 -21
- data/lib/tapioca/loaders/loader.rb +15 -27
- data/lib/tapioca/rbi_ext/model.rb +12 -37
- data/lib/tapioca/rbi_formatter.rb +10 -19
- data/lib/tapioca/rbs/rewriter.rb +55 -0
- data/lib/tapioca/repo_index.rb +7 -7
- data/lib/tapioca/runtime/attached_class_of_32.rb +1 -1
- data/lib/tapioca/runtime/attached_class_of_legacy.rb +1 -1
- data/lib/tapioca/runtime/dynamic_mixin_compiler.rb +23 -23
- data/lib/tapioca/runtime/generic_type_registry.rb +13 -23
- data/lib/tapioca/runtime/reflection.rb +48 -56
- data/lib/tapioca/runtime/trackers/autoload.rb +4 -8
- data/lib/tapioca/runtime/trackers/mixin.rb +6 -10
- data/lib/tapioca/runtime/trackers/required_ancestor.rb +3 -3
- data/lib/tapioca/runtime/trackers/tracker.rb +2 -2
- data/lib/tapioca/runtime/trackers.rb +4 -8
- data/lib/tapioca/sorbet_ext/generic_name_patch.rb +9 -15
- data/lib/tapioca/sorbet_ext/name_patch.rb +1 -1
- data/lib/tapioca/sorbet_ext/proc_bind_patch.rb +1 -1
- data/lib/tapioca/static/requires_compiler.rb +6 -6
- data/lib/tapioca/static/symbol_loader.rb +14 -16
- data/lib/tapioca/static/symbol_table_parser.rb +8 -8
- data/lib/tapioca/version.rb +1 -1
- data/lib/tapioca.rb +22 -29
- metadata +25 -10
@@ -9,27 +9,7 @@ module Tapioca
|
|
9
9
|
|
10
10
|
abstract!
|
11
11
|
|
12
|
-
|
13
|
-
params(
|
14
|
-
gem_names: T::Array[String],
|
15
|
-
exclude: T::Array[String],
|
16
|
-
include_dependencies: T::Boolean,
|
17
|
-
prerequire: T.nilable(String),
|
18
|
-
postrequire: String,
|
19
|
-
typed_overrides: T::Hash[String, String],
|
20
|
-
outpath: Pathname,
|
21
|
-
file_header: T::Boolean,
|
22
|
-
include_doc: T::Boolean,
|
23
|
-
include_loc: T::Boolean,
|
24
|
-
include_exported_rbis: T::Boolean,
|
25
|
-
number_of_workers: T.nilable(Integer),
|
26
|
-
auto_strictness: T::Boolean,
|
27
|
-
dsl_dir: String,
|
28
|
-
rbi_formatter: RBIFormatter,
|
29
|
-
halt_upon_load_error: T::Boolean,
|
30
|
-
lsp_addon: T.nilable(T::Boolean),
|
31
|
-
).void
|
32
|
-
end
|
12
|
+
#: (gem_names: Array[String], exclude: Array[String], include_dependencies: bool, prerequire: String?, postrequire: String, typed_overrides: Hash[String, String], outpath: Pathname, file_header: bool, include_doc: bool, include_loc: bool, include_exported_rbis: bool, ?number_of_workers: Integer?, ?auto_strictness: bool, ?dsl_dir: String, ?rbi_formatter: RBIFormatter, ?halt_upon_load_error: bool, ?lsp_addon: bool?) -> void
|
33
13
|
def initialize(
|
34
14
|
gem_names:,
|
35
15
|
exclude:,
|
@@ -65,18 +45,18 @@ module Tapioca
|
|
65
45
|
|
66
46
|
super()
|
67
47
|
|
68
|
-
@bundle =
|
69
|
-
@existing_rbis =
|
70
|
-
@expected_rbis =
|
71
|
-
@include_doc =
|
72
|
-
@include_loc =
|
48
|
+
@bundle = Gemfile.new(exclude) #: Gemfile
|
49
|
+
@existing_rbis = nil #: Hash[String, String]?
|
50
|
+
@expected_rbis = nil #: Hash[String, String]?
|
51
|
+
@include_doc = include_doc #: bool
|
52
|
+
@include_loc = include_loc #: bool
|
73
53
|
@include_exported_rbis = include_exported_rbis
|
74
54
|
@halt_upon_load_error = halt_upon_load_error
|
75
55
|
end
|
76
56
|
|
77
57
|
private
|
78
58
|
|
79
|
-
|
59
|
+
#: (Gemfile::GemSpec gem) -> void
|
80
60
|
def compile_gem_rbi(gem)
|
81
61
|
gem_name = set_color(gem.name, :yellow, :bold)
|
82
62
|
|
@@ -116,12 +96,12 @@ module Tapioca
|
|
116
96
|
end
|
117
97
|
end
|
118
98
|
|
119
|
-
|
99
|
+
#: -> void
|
120
100
|
def perform_removals
|
121
101
|
say("Removing RBI files of gems that have been removed:", [:blue, :bold])
|
122
102
|
puts
|
123
103
|
|
124
|
-
anything_done =
|
104
|
+
anything_done = false #: bool
|
125
105
|
|
126
106
|
gems = removed_rbis
|
127
107
|
|
@@ -143,12 +123,12 @@ module Tapioca
|
|
143
123
|
anything_done
|
144
124
|
end
|
145
125
|
|
146
|
-
|
126
|
+
#: -> void
|
147
127
|
def perform_additions
|
148
128
|
say("Generating RBI files of gems that are added or updated:", [:blue, :bold])
|
149
129
|
puts
|
150
130
|
|
151
|
-
anything_done =
|
131
|
+
anything_done = false #: bool
|
152
132
|
|
153
133
|
gems = added_rbis
|
154
134
|
|
@@ -186,34 +166,34 @@ module Tapioca
|
|
186
166
|
anything_done
|
187
167
|
end
|
188
168
|
|
189
|
-
|
169
|
+
#: -> Array[String]
|
190
170
|
def removed_rbis
|
191
171
|
(existing_rbis.keys - expected_rbis.keys).sort
|
192
172
|
end
|
193
173
|
|
194
|
-
|
174
|
+
#: (String gem_name) -> Pathname
|
195
175
|
def existing_rbi(gem_name)
|
196
176
|
gem_rbi_filename(gem_name, T.must(existing_rbis[gem_name]))
|
197
177
|
end
|
198
178
|
|
199
|
-
|
179
|
+
#: -> Array[String]
|
200
180
|
def added_rbis
|
201
181
|
expected_rbis.select do |name, value|
|
202
182
|
existing_rbis[name] != value
|
203
183
|
end.keys.sort
|
204
184
|
end
|
205
185
|
|
206
|
-
|
186
|
+
#: (String gem_name) -> Pathname
|
207
187
|
def expected_rbi(gem_name)
|
208
188
|
gem_rbi_filename(gem_name, T.must(expected_rbis[gem_name]))
|
209
189
|
end
|
210
190
|
|
211
|
-
|
191
|
+
#: (String gem_name) -> bool
|
212
192
|
def gem_rbi_exists?(gem_name)
|
213
193
|
existing_rbis.key?(gem_name)
|
214
194
|
end
|
215
195
|
|
216
|
-
|
196
|
+
#: (Hash[String, Symbol] diff, Symbol command) -> void
|
217
197
|
def report_diff_and_exit_if_out_of_date(diff, command)
|
218
198
|
if diff.empty?
|
219
199
|
say("Nothing to do, all RBIs are up-to-date.")
|
@@ -233,36 +213,36 @@ module Tapioca
|
|
233
213
|
end
|
234
214
|
end
|
235
215
|
|
236
|
-
|
216
|
+
#: (Pathname old_filename, Pathname new_filename) -> void
|
237
217
|
def move(old_filename, new_filename)
|
238
218
|
say("-> Moving: #{old_filename} to #{new_filename}")
|
239
219
|
old_filename.rename(new_filename.to_s)
|
240
220
|
end
|
241
221
|
|
242
|
-
|
222
|
+
#: -> Hash[String, String]
|
243
223
|
def existing_rbis
|
244
224
|
@existing_rbis ||= Pathname.glob((@outpath / "*@*.rbi").to_s)
|
245
225
|
.to_h { |f| T.cast(f.basename(".*").to_s.split("@", 2), [String, String]) }
|
246
226
|
end
|
247
227
|
|
248
|
-
|
228
|
+
#: -> Hash[String, String]
|
249
229
|
def expected_rbis
|
250
230
|
@expected_rbis ||= @bundle.dependencies
|
251
231
|
.reject { |gem| @exclude.include?(gem.name) }
|
252
232
|
.to_h { |gem| [gem.name, gem.version.to_s] }
|
253
233
|
end
|
254
234
|
|
255
|
-
|
235
|
+
#: (String gem_name, String version) -> Pathname
|
256
236
|
def gem_rbi_filename(gem_name, version)
|
257
237
|
@outpath / "#{gem_name}@#{version}.rbi"
|
258
238
|
end
|
259
239
|
|
260
|
-
|
240
|
+
#: (Symbol cause, Array[String] files) -> String
|
261
241
|
def build_error_for_files(cause, files)
|
262
242
|
" File(s) #{cause}:\n - #{files.join("\n - ")}"
|
263
243
|
end
|
264
244
|
|
265
|
-
|
245
|
+
#: (Gemfile::GemSpec gem, RBI::File file) -> void
|
266
246
|
def merge_with_exported_rbi(gem, file)
|
267
247
|
return file unless gem.export_rbi_files?
|
268
248
|
|
@@ -6,15 +6,7 @@ module Tapioca
|
|
6
6
|
class Annotations < CommandWithoutTracker
|
7
7
|
extend T::Sig
|
8
8
|
|
9
|
-
|
10
|
-
params(
|
11
|
-
central_repo_root_uris: T::Array[String],
|
12
|
-
auth: T.nilable(String),
|
13
|
-
netrc_file: T.nilable(String),
|
14
|
-
central_repo_index_path: String,
|
15
|
-
typed_overrides: T::Hash[String, String],
|
16
|
-
).void
|
17
|
-
end
|
9
|
+
#: (central_repo_root_uris: Array[String], ?auth: String?, ?netrc_file: String?, ?central_repo_index_path: String, ?typed_overrides: Hash[String, String]) -> void
|
18
10
|
def initialize(
|
19
11
|
central_repo_root_uris:,
|
20
12
|
auth: nil,
|
@@ -23,19 +15,20 @@ module Tapioca
|
|
23
15
|
typed_overrides: {}
|
24
16
|
)
|
25
17
|
super()
|
26
|
-
@outpath =
|
18
|
+
@outpath = Pathname.new(DEFAULT_ANNOTATIONS_DIR) #: Pathname
|
27
19
|
@central_repo_root_uris = central_repo_root_uris
|
28
20
|
@auth = auth
|
29
21
|
@netrc_file = netrc_file
|
30
|
-
@netrc_info =
|
31
|
-
@tokens =
|
32
|
-
@indexes =
|
22
|
+
@netrc_info = nil #: Netrc?
|
23
|
+
@tokens = repo_tokens #: Hash[String, String?]
|
24
|
+
@indexes = {} #: Hash[String, RepoIndex]
|
33
25
|
@typed_overrides = typed_overrides
|
34
26
|
end
|
35
27
|
|
36
28
|
private
|
37
29
|
|
38
|
-
|
30
|
+
# @override
|
31
|
+
#: -> void
|
39
32
|
def execute
|
40
33
|
@indexes = fetch_indexes
|
41
34
|
project_gems = list_gemfile_gems
|
@@ -46,7 +39,7 @@ module Tapioca
|
|
46
39
|
GitAttributes.create_vendored_attribute_file(@outpath)
|
47
40
|
end
|
48
41
|
|
49
|
-
|
42
|
+
#: -> Array[GemInfo]
|
50
43
|
def list_gemfile_gems
|
51
44
|
say("Listing gems from Gemfile.lock... ", [:blue, :bold])
|
52
45
|
gemfile = Bundler.read_file("Gemfile.lock")
|
@@ -56,7 +49,7 @@ module Tapioca
|
|
56
49
|
gem_info
|
57
50
|
end
|
58
51
|
|
59
|
-
|
52
|
+
#: (Array[GemInfo] project_gems) -> void
|
60
53
|
def remove_expired_annotations(project_gems)
|
61
54
|
say("Removing annotations for gems that have been removed... ", [:blue, :bold])
|
62
55
|
|
@@ -77,11 +70,11 @@ module Tapioca
|
|
77
70
|
say("\nDone\n\n", :green)
|
78
71
|
end
|
79
72
|
|
80
|
-
|
73
|
+
#: -> Hash[String, RepoIndex]
|
81
74
|
def fetch_indexes
|
82
75
|
multiple_repos = @central_repo_root_uris.size > 1
|
83
76
|
repo_number = 1
|
84
|
-
indexes =
|
77
|
+
indexes = {} #: Hash[String, RepoIndex]
|
85
78
|
|
86
79
|
@central_repo_root_uris.each do |uri|
|
87
80
|
index = fetch_index(uri, repo_number: multiple_repos ? repo_number : nil)
|
@@ -98,7 +91,7 @@ module Tapioca
|
|
98
91
|
indexes
|
99
92
|
end
|
100
93
|
|
101
|
-
|
94
|
+
#: (String repo_uri, repo_number: Integer?) -> RepoIndex?
|
102
95
|
def fetch_index(repo_uri, repo_number:)
|
103
96
|
say("Retrieving index from central repository#{repo_number ? " ##{repo_number}" : ""}... ", [:blue, :bold])
|
104
97
|
content = fetch_file(repo_uri, CENTRAL_REPO_INDEX_PATH)
|
@@ -109,10 +102,10 @@ module Tapioca
|
|
109
102
|
index
|
110
103
|
end
|
111
104
|
|
112
|
-
|
105
|
+
#: (Array[GemInfo] project_gems) -> Array[String]
|
113
106
|
def fetch_annotations(project_gems)
|
114
107
|
say("Fetching gem annotations from central repository... ", [:blue, :bold])
|
115
|
-
fetchable_gems =
|
108
|
+
fetchable_gems = Hash.new { |h, k| h[k] = [] } #: Hash[GemInfo, Array[String]]
|
116
109
|
|
117
110
|
project_gems.each_with_object(fetchable_gems) do |gem_info, hash|
|
118
111
|
@indexes.each do |uri, index|
|
@@ -132,7 +125,7 @@ module Tapioca
|
|
132
125
|
fetched_gems.keys.map(&:name).sort
|
133
126
|
end
|
134
127
|
|
135
|
-
sig { params(repo_uris: T::Array[String], gem_info: GemInfo).
|
128
|
+
sig { params(repo_uris: T::Array[String], gem_info: GemInfo).returns(T::Boolean) }
|
136
129
|
def fetch_annotation(repo_uris, gem_info)
|
137
130
|
gem_name = gem_info.name
|
138
131
|
gem_version = gem_info.version
|
@@ -142,7 +135,7 @@ module Tapioca
|
|
142
135
|
end
|
143
136
|
|
144
137
|
content = merge_files(gem_name, contents.compact)
|
145
|
-
return unless content
|
138
|
+
return false unless content
|
146
139
|
|
147
140
|
content = apply_typed_override(gem_name, content)
|
148
141
|
content = filter_versions(gem_version, content)
|
@@ -150,9 +143,10 @@ module Tapioca
|
|
150
143
|
|
151
144
|
say("\n Fetched #{set_color(gem_name, :yellow, :bold)}", :green)
|
152
145
|
create_file(@outpath.join("#{gem_name}.rbi"), content)
|
146
|
+
true
|
153
147
|
end
|
154
148
|
|
155
|
-
|
149
|
+
#: (String repo_uri, String path) -> String?
|
156
150
|
def fetch_file(repo_uri, path)
|
157
151
|
if repo_uri.start_with?(%r{https?://})
|
158
152
|
fetch_http_file(repo_uri, path)
|
@@ -161,7 +155,7 @@ module Tapioca
|
|
161
155
|
end
|
162
156
|
end
|
163
157
|
|
164
|
-
|
158
|
+
#: (String repo_uri, String path) -> String?
|
165
159
|
def fetch_local_file(repo_uri, path)
|
166
160
|
File.read("#{repo_uri}/#{path}")
|
167
161
|
rescue => e
|
@@ -169,7 +163,7 @@ module Tapioca
|
|
169
163
|
nil
|
170
164
|
end
|
171
165
|
|
172
|
-
|
166
|
+
#: (String repo_uri, String path) -> String?
|
173
167
|
def fetch_http_file(repo_uri, path)
|
174
168
|
auth = @tokens[repo_uri]
|
175
169
|
uri = URI("#{repo_uri}/#{path}")
|
@@ -193,7 +187,7 @@ module Tapioca
|
|
193
187
|
nil
|
194
188
|
end
|
195
189
|
|
196
|
-
|
190
|
+
#: (String name, String content) -> String
|
197
191
|
def add_header(name, content)
|
198
192
|
# WARNING: Changing this header could impact how GitHub determines if the file should be hidden:
|
199
193
|
# https://github.com/github/linguist/pull/6143
|
@@ -213,7 +207,7 @@ module Tapioca
|
|
213
207
|
end
|
214
208
|
end
|
215
209
|
|
216
|
-
|
210
|
+
#: (String name, String content) -> String
|
217
211
|
def apply_typed_override(name, content)
|
218
212
|
strictness = @typed_overrides[name]
|
219
213
|
return content unless strictness
|
@@ -225,7 +219,7 @@ module Tapioca
|
|
225
219
|
Spoom::Sorbet::Sigils.update_sigil(content, strictness)
|
226
220
|
end
|
227
221
|
|
228
|
-
|
222
|
+
#: (::Gem::Version gem_version, String content) -> String
|
229
223
|
def filter_versions(gem_version, content)
|
230
224
|
rbi = RBI::Parser.parse_string(content)
|
231
225
|
rbi.filter_versions!(gem_version)
|
@@ -233,7 +227,7 @@ module Tapioca
|
|
233
227
|
rbi.string
|
234
228
|
end
|
235
229
|
|
236
|
-
|
230
|
+
#: (String gem_name, Array[String] contents) -> String?
|
237
231
|
def merge_files(gem_name, contents)
|
238
232
|
return if contents.empty?
|
239
233
|
|
@@ -260,7 +254,7 @@ module Tapioca
|
|
260
254
|
nil
|
261
255
|
end
|
262
256
|
|
263
|
-
|
257
|
+
#: -> Hash[String, String?]
|
264
258
|
def repo_tokens
|
265
259
|
@netrc_info = Netrc.read(@netrc_file) if @netrc_file
|
266
260
|
@central_repo_root_uris.filter_map do |uri|
|
@@ -272,7 +266,7 @@ module Tapioca
|
|
272
266
|
end.to_h
|
273
267
|
end
|
274
268
|
|
275
|
-
|
269
|
+
#: (String repo_uri) -> String?
|
276
270
|
def token_for(repo_uri)
|
277
271
|
return unless @netrc_info
|
278
272
|
|
@@ -288,7 +282,7 @@ module Tapioca
|
|
288
282
|
"token #{token}"
|
289
283
|
end
|
290
284
|
|
291
|
-
|
285
|
+
#: (String path, String repo_uri, message: String) -> void
|
292
286
|
def say_http_error(path, repo_uri, message:)
|
293
287
|
say_error("\nCan't fetch file `#{path}` from #{repo_uri} (#{message})\n\n", :bold, :red)
|
294
288
|
say_error(<<~ERROR)
|
@@ -8,17 +8,7 @@ module Tapioca
|
|
8
8
|
include SorbetHelper
|
9
9
|
include RBIFilesHelper
|
10
10
|
|
11
|
-
|
12
|
-
params(
|
13
|
-
gem_rbi_dir: String,
|
14
|
-
dsl_rbi_dir: String,
|
15
|
-
annotations_rbi_dir: String,
|
16
|
-
shim_rbi_dir: String,
|
17
|
-
todo_rbi_file: String,
|
18
|
-
payload: T::Boolean,
|
19
|
-
number_of_workers: T.nilable(Integer),
|
20
|
-
).void
|
21
|
-
end
|
11
|
+
#: (gem_rbi_dir: String, dsl_rbi_dir: String, annotations_rbi_dir: String, shim_rbi_dir: String, todo_rbi_file: String, payload: bool, number_of_workers: Integer?) -> void
|
22
12
|
def initialize(
|
23
13
|
gem_rbi_dir:,
|
24
14
|
dsl_rbi_dir:,
|
@@ -40,7 +30,8 @@ module Tapioca
|
|
40
30
|
|
41
31
|
private
|
42
32
|
|
43
|
-
|
33
|
+
# @override
|
34
|
+
#: -> void
|
44
35
|
def execute
|
45
36
|
index = RBI::Index.new
|
46
37
|
|
@@ -50,7 +41,7 @@ module Tapioca
|
|
50
41
|
return
|
51
42
|
end
|
52
43
|
|
53
|
-
payload_path =
|
44
|
+
payload_path = nil #: String?
|
54
45
|
|
55
46
|
if @payload
|
56
47
|
Dir.mktmpdir do |dir|
|
@@ -16,12 +16,13 @@ module Tapioca
|
|
16
16
|
|
17
17
|
abstract!
|
18
18
|
|
19
|
-
|
19
|
+
#: -> void
|
20
20
|
def initialize
|
21
|
-
@file_writer =
|
21
|
+
@file_writer = FileWriter.new #: Thor::Actions
|
22
22
|
end
|
23
23
|
|
24
|
-
|
24
|
+
# @final
|
25
|
+
#: -> void
|
25
26
|
def run
|
26
27
|
Tapioca.silence_warnings do
|
27
28
|
execute
|
@@ -33,33 +34,20 @@ module Tapioca
|
|
33
34
|
sig { abstract.void }
|
34
35
|
def execute; end
|
35
36
|
|
36
|
-
|
37
|
+
#: (Symbol command, *String args) -> String
|
37
38
|
def default_command(command, *args)
|
38
39
|
[Tapioca::BINARY_FILE, command.to_s, *args].join(" ")
|
39
40
|
end
|
40
41
|
|
41
|
-
|
42
|
+
#: Thor::Actions
|
42
43
|
attr_reader :file_writer
|
43
44
|
|
44
|
-
|
45
|
-
params(
|
46
|
-
path: T.any(String, Pathname),
|
47
|
-
content: String,
|
48
|
-
force: T::Boolean,
|
49
|
-
skip: T::Boolean,
|
50
|
-
verbose: T::Boolean,
|
51
|
-
).void
|
52
|
-
end
|
45
|
+
#: ((String | Pathname) path, String content, ?force: bool, ?skip: bool, ?verbose: bool) -> void
|
53
46
|
def create_file(path, content, force: true, skip: false, verbose: true)
|
54
47
|
file_writer.create_file(path, force: force, skip: skip, verbose: verbose) { content }
|
55
48
|
end
|
56
49
|
|
57
|
-
|
58
|
-
params(
|
59
|
-
path: T.any(String, Pathname),
|
60
|
-
verbose: T::Boolean,
|
61
|
-
).void
|
62
|
-
end
|
50
|
+
#: ((String | Pathname) path, ?verbose: bool) -> void
|
63
51
|
def remove_file(path, verbose: true)
|
64
52
|
file_writer.remove_file(path, verbose: verbose)
|
65
53
|
end
|
@@ -4,13 +4,7 @@
|
|
4
4
|
module Tapioca
|
5
5
|
module Commands
|
6
6
|
class Configure < CommandWithoutTracker
|
7
|
-
|
8
|
-
params(
|
9
|
-
sorbet_config: String,
|
10
|
-
tapioca_config: String,
|
11
|
-
default_postrequire: String,
|
12
|
-
).void
|
13
|
-
end
|
7
|
+
#: (sorbet_config: String, tapioca_config: String, default_postrequire: String) -> void
|
14
8
|
def initialize(
|
15
9
|
sorbet_config:,
|
16
10
|
tapioca_config:,
|
@@ -22,13 +16,14 @@ module Tapioca
|
|
22
16
|
|
23
17
|
super()
|
24
18
|
|
25
|
-
@installer =
|
26
|
-
@spec =
|
19
|
+
@installer = nil #: Bundler::Installer?
|
20
|
+
@spec = nil #: Bundler::StubSpecification?
|
27
21
|
end
|
28
22
|
|
29
23
|
private
|
30
24
|
|
31
|
-
|
25
|
+
# @override
|
26
|
+
#: -> void
|
32
27
|
def execute
|
33
28
|
create_sorbet_config
|
34
29
|
create_tapioca_config
|
@@ -36,7 +31,7 @@ module Tapioca
|
|
36
31
|
create_binstub
|
37
32
|
end
|
38
33
|
|
39
|
-
|
34
|
+
#: -> void
|
40
35
|
def create_sorbet_config
|
41
36
|
create_file(@sorbet_config, <<~CONTENT, skip: true, force: false)
|
42
37
|
--dir
|
@@ -46,7 +41,7 @@ module Tapioca
|
|
46
41
|
CONTENT
|
47
42
|
end
|
48
43
|
|
49
|
-
|
44
|
+
#: -> void
|
50
45
|
def create_tapioca_config
|
51
46
|
create_file(@tapioca_config, <<~YAML, skip: true, force: false)
|
52
47
|
gem:
|
@@ -65,7 +60,7 @@ module Tapioca
|
|
65
60
|
YAML
|
66
61
|
end
|
67
62
|
|
68
|
-
|
63
|
+
#: -> void
|
69
64
|
def create_post_require
|
70
65
|
create_file(@default_postrequire, <<~CONTENT, skip: true, force: false)
|
71
66
|
# typed: true
|
@@ -75,7 +70,7 @@ module Tapioca
|
|
75
70
|
CONTENT
|
76
71
|
end
|
77
72
|
|
78
|
-
|
73
|
+
#: -> void
|
79
74
|
def create_binstub
|
80
75
|
force = File.exist?(Tapioca::BINARY_FILE)
|
81
76
|
|
@@ -88,12 +83,12 @@ module Tapioca
|
|
88
83
|
)
|
89
84
|
end
|
90
85
|
|
91
|
-
|
86
|
+
#: -> Bundler::Installer
|
92
87
|
def installer
|
93
88
|
@installer ||= Bundler::Installer.new(Bundler.root, Bundler.definition)
|
94
89
|
end
|
95
90
|
|
96
|
-
|
91
|
+
#: -> (Bundler::StubSpecification | ::Gem::Specification)
|
97
92
|
def spec
|
98
93
|
@spec ||= Bundler.definition.specs.find { |s| s.name == "tapioca" }
|
99
94
|
end
|
@@ -6,7 +6,8 @@ module Tapioca
|
|
6
6
|
class GemGenerate < AbstractGem
|
7
7
|
private
|
8
8
|
|
9
|
-
|
9
|
+
# @override
|
10
|
+
#: -> void
|
10
11
|
def execute
|
11
12
|
Loaders::Gem.load_application(
|
12
13
|
bundle: @bundle,
|
@@ -47,7 +48,7 @@ module Tapioca
|
|
47
48
|
GitAttributes.create_generated_attribute_file(@outpath)
|
48
49
|
end
|
49
50
|
|
50
|
-
|
51
|
+
#: (Array[String] gem_names) -> Array[Gemfile::GemSpec]
|
51
52
|
def gems_to_generate(gem_names)
|
52
53
|
return @bundle.dependencies if gem_names.empty?
|
53
54
|
|
@@ -65,12 +66,7 @@ module Tapioca
|
|
65
66
|
end
|
66
67
|
end
|
67
68
|
|
68
|
-
|
69
|
-
params(
|
70
|
-
gem: Gemfile::GemSpec,
|
71
|
-
dependencies: T::Array[Gemfile::GemSpec],
|
72
|
-
).returns(T::Array[Gemfile::GemSpec])
|
73
|
-
end
|
69
|
+
#: (Gemfile::GemSpec gem, ?Array[Gemfile::GemSpec] dependencies) -> Array[Gemfile::GemSpec]
|
74
70
|
def gem_dependencies(gem, dependencies = [])
|
75
71
|
direct_dependencies = gem.dependencies.filter_map { |dependency| @bundle.gem(dependency.name) }
|
76
72
|
gems = dependencies | direct_dependencies
|
@@ -6,14 +6,15 @@ module Tapioca
|
|
6
6
|
class GemVerify < AbstractGem
|
7
7
|
private
|
8
8
|
|
9
|
-
|
9
|
+
# @override
|
10
|
+
#: -> void
|
10
11
|
def execute
|
11
12
|
say("Checking for out-of-date RBIs...")
|
12
13
|
say("")
|
13
14
|
perform_sync_verification
|
14
15
|
end
|
15
16
|
|
16
|
-
|
17
|
+
#: -> void
|
17
18
|
def perform_sync_verification
|
18
19
|
diff = {}
|
19
20
|
|
@@ -4,12 +4,7 @@
|
|
4
4
|
module Tapioca
|
5
5
|
module Commands
|
6
6
|
class Require < CommandWithoutTracker
|
7
|
-
|
8
|
-
params(
|
9
|
-
requires_path: String,
|
10
|
-
sorbet_config_path: String,
|
11
|
-
).void
|
12
|
-
end
|
7
|
+
#: (requires_path: String, sorbet_config_path: String) -> void
|
13
8
|
def initialize(requires_path:, sorbet_config_path:)
|
14
9
|
@requires_path = requires_path
|
15
10
|
@sorbet_config_path = sorbet_config_path
|
@@ -19,7 +14,8 @@ module Tapioca
|
|
19
14
|
|
20
15
|
private
|
21
16
|
|
22
|
-
|
17
|
+
# @override
|
18
|
+
#: -> void
|
23
19
|
def execute
|
24
20
|
compiler = Static::RequiresCompiler.new(@sorbet_config_path)
|
25
21
|
name = set_color(@requires_path, :yellow, :bold)
|