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
data/lib/tapioca/gem_info.rb
CHANGED
data/lib/tapioca/gemfile.rb
CHANGED
@@ -14,34 +14,34 @@ module Tapioca
|
|
14
14
|
)
|
15
15
|
end
|
16
16
|
|
17
|
-
|
17
|
+
#: Bundler::Definition
|
18
18
|
attr_reader(:definition)
|
19
19
|
|
20
|
-
|
20
|
+
#: Array[GemSpec]
|
21
21
|
attr_reader(:dependencies)
|
22
22
|
|
23
|
-
|
23
|
+
#: Array[String]
|
24
24
|
attr_reader(:missing_specs)
|
25
25
|
|
26
|
-
|
26
|
+
#: (Array[String] excluded_gems) -> void
|
27
27
|
def initialize(excluded_gems)
|
28
|
-
@gemfile =
|
29
|
-
@lockfile =
|
30
|
-
@definition =
|
28
|
+
@gemfile = File.new(Bundler.default_gemfile) #: File
|
29
|
+
@lockfile = File.new(Bundler.default_lockfile) #: File
|
30
|
+
@definition = Bundler::Dsl.evaluate(gemfile, lockfile, {}) #: Bundler::Definition
|
31
31
|
@excluded_gems = excluded_gems
|
32
32
|
|
33
33
|
dependencies, missing_specs = load_dependencies
|
34
34
|
|
35
|
-
@dependencies =
|
36
|
-
@missing_specs =
|
35
|
+
@dependencies = dependencies #: Array[GemSpec]
|
36
|
+
@missing_specs = missing_specs #: Array[String]
|
37
37
|
end
|
38
38
|
|
39
|
-
|
39
|
+
#: (String gem_name) -> GemSpec?
|
40
40
|
def gem(gem_name)
|
41
41
|
dependencies.detect { |dep| dep.name == gem_name }
|
42
42
|
end
|
43
43
|
|
44
|
-
|
44
|
+
#: -> void
|
45
45
|
def require_bundle
|
46
46
|
BundlerExt::AutoRequireHook.override_require_false(exclude: @excluded_gems) do
|
47
47
|
T.unsafe(runtime).require(*groups)
|
@@ -50,10 +50,10 @@ module Tapioca
|
|
50
50
|
|
51
51
|
private
|
52
52
|
|
53
|
-
|
53
|
+
#: File
|
54
54
|
attr_reader(:gemfile, :lockfile)
|
55
55
|
|
56
|
-
|
56
|
+
#: -> [Array[GemSpec], Array[String]]
|
57
57
|
def load_dependencies
|
58
58
|
materialized_dependencies, missing_specs = materialize_deps
|
59
59
|
dependencies = materialized_dependencies
|
@@ -64,7 +64,7 @@ module Tapioca
|
|
64
64
|
[dependencies, missing_specs]
|
65
65
|
end
|
66
66
|
|
67
|
-
|
67
|
+
#: -> [T::Enumerable[Spec], Array[String]]
|
68
68
|
def materialize_deps
|
69
69
|
deps = definition.locked_gems.dependencies.except(*@excluded_gems).values
|
70
70
|
resolve = definition.resolve
|
@@ -87,17 +87,17 @@ module Tapioca
|
|
87
87
|
[materialized_dependencies, missing_specs]
|
88
88
|
end
|
89
89
|
|
90
|
-
|
90
|
+
#: -> Bundler::Runtime
|
91
91
|
def runtime
|
92
92
|
Bundler::Runtime.new(File.dirname(gemfile.path), definition)
|
93
93
|
end
|
94
94
|
|
95
|
-
|
95
|
+
#: -> Array[Symbol]
|
96
96
|
def groups
|
97
97
|
definition.groups
|
98
98
|
end
|
99
99
|
|
100
|
-
|
100
|
+
#: -> String
|
101
101
|
def dir
|
102
102
|
File.expand_path(gemfile.path + "/..")
|
103
103
|
end
|
@@ -109,74 +109,68 @@ module Tapioca
|
|
109
109
|
class << self
|
110
110
|
extend T::Sig
|
111
111
|
|
112
|
-
|
112
|
+
#: -> Hash[String, Gemfile::GemSpec]
|
113
113
|
def spec_lookup_by_file_path
|
114
|
-
@lookup ||=
|
115
|
-
|
116
|
-
|
117
|
-
.
|
118
|
-
|
119
|
-
end.to_h,
|
120
|
-
T.nilable(T::Hash[String, Gemfile::GemSpec]),
|
121
|
-
)
|
114
|
+
@lookup ||= [*::Gem::Specification.default_stubs, *::Gem::Specification.stubs]
|
115
|
+
.map! { |spec| new(spec.to_spec) }
|
116
|
+
.flat_map do |spec|
|
117
|
+
spec.files.filter_map { |file| [file.realpath.to_s, spec] if file.exist? }
|
118
|
+
end.to_h #: Hash[String, Gemfile::GemSpec]?
|
122
119
|
end
|
123
120
|
end
|
124
121
|
|
125
|
-
IGNORED_GEMS =
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
)
|
137
|
-
|
138
|
-
sig { returns(String) }
|
122
|
+
IGNORED_GEMS = [
|
123
|
+
"sorbet",
|
124
|
+
"sorbet-static",
|
125
|
+
"sorbet-runtime",
|
126
|
+
"sorbet-static-and-runtime",
|
127
|
+
"debug",
|
128
|
+
"irb",
|
129
|
+
"fakefs",
|
130
|
+
].freeze #: Array[String]
|
131
|
+
|
132
|
+
#: String
|
139
133
|
attr_reader :full_gem_path, :version
|
140
134
|
|
141
|
-
|
135
|
+
#: Array[Pathname]
|
142
136
|
attr_reader :files
|
143
137
|
|
144
|
-
|
138
|
+
#: (Spec spec) -> void
|
145
139
|
def initialize(spec)
|
146
|
-
@spec =
|
140
|
+
@spec = spec #: Tapioca::Gemfile::Spec
|
147
141
|
real_gem_path = to_realpath(@spec.full_gem_path)
|
148
|
-
@full_gem_path =
|
149
|
-
@version =
|
150
|
-
@exported_rbi_files =
|
151
|
-
@files =
|
142
|
+
@full_gem_path = real_gem_path #: String
|
143
|
+
@version = version_string #: String
|
144
|
+
@exported_rbi_files = nil #: Array[String]?
|
145
|
+
@files = collect_files #: Array[Pathname]
|
152
146
|
end
|
153
147
|
|
154
|
-
|
148
|
+
#: (BasicObject other) -> bool
|
155
149
|
def ==(other)
|
156
150
|
GemSpec === other && other.name == name && other.version == version
|
157
151
|
end
|
158
152
|
|
159
|
-
|
153
|
+
#: (String gemfile_dir) -> bool
|
160
154
|
def ignore?(gemfile_dir)
|
161
155
|
gem_ignored? || gem_in_app_dir?(gemfile_dir, full_gem_path)
|
162
156
|
end
|
163
157
|
|
164
|
-
|
158
|
+
#: -> String
|
165
159
|
def name
|
166
160
|
@spec.name
|
167
161
|
end
|
168
162
|
|
169
|
-
|
163
|
+
#: -> Array[::Gem::Dependency]
|
170
164
|
def dependencies
|
171
165
|
@spec.dependencies
|
172
166
|
end
|
173
167
|
|
174
|
-
|
168
|
+
#: -> String
|
175
169
|
def rbi_file_name
|
176
170
|
"#{name}@#{version}.rbi"
|
177
171
|
end
|
178
172
|
|
179
|
-
|
173
|
+
#: (String path) -> bool
|
180
174
|
def contains_path?(path)
|
181
175
|
if default_gem?
|
182
176
|
files.any? { |file| file.to_s == to_realpath(path) }
|
@@ -185,7 +179,7 @@ module Tapioca
|
|
185
179
|
end
|
186
180
|
end
|
187
181
|
|
188
|
-
|
182
|
+
#: -> void
|
189
183
|
def parse_yard_docs
|
190
184
|
files.each do |path|
|
191
185
|
YARD.parse(path.to_s, [], Logger::Severity::FATAL)
|
@@ -201,17 +195,17 @@ module Tapioca
|
|
201
195
|
end
|
202
196
|
end
|
203
197
|
|
204
|
-
|
198
|
+
#: -> Array[String]
|
205
199
|
def exported_rbi_files
|
206
200
|
@exported_rbi_files ||= Dir.glob("#{full_gem_path}/rbi/**/*.rbi").sort
|
207
201
|
end
|
208
202
|
|
209
|
-
|
203
|
+
#: -> bool
|
210
204
|
def export_rbi_files?
|
211
205
|
exported_rbi_files.any?
|
212
206
|
end
|
213
207
|
|
214
|
-
|
208
|
+
#: -> RBI::MergeTree
|
215
209
|
def exported_rbi_tree
|
216
210
|
rewriter = RBI::Rewriters::Merge.new(keep: RBI::Rewriters::Merge::Keep::NONE)
|
217
211
|
|
@@ -223,7 +217,7 @@ module Tapioca
|
|
223
217
|
rewriter.tree
|
224
218
|
end
|
225
219
|
|
226
|
-
|
220
|
+
#: (Pathname file) -> Pathname
|
227
221
|
def relative_path_for(file)
|
228
222
|
if default_gem?
|
229
223
|
file.realpath.relative_path_from(RbConfig::CONFIG["rubylibdir"])
|
@@ -234,7 +228,7 @@ module Tapioca
|
|
234
228
|
|
235
229
|
private
|
236
230
|
|
237
|
-
|
231
|
+
#: -> Array[Pathname]
|
238
232
|
def collect_files
|
239
233
|
if default_gem?
|
240
234
|
# `Bundler::RemoteSpecification` delegates missing methods to
|
@@ -249,24 +243,21 @@ module Tapioca
|
|
249
243
|
end
|
250
244
|
end
|
251
245
|
|
252
|
-
|
246
|
+
#: -> bool?
|
253
247
|
def default_gem?
|
254
248
|
@spec.respond_to?(:default_gem?) && @spec.default_gem?
|
255
249
|
end
|
256
250
|
|
257
|
-
|
251
|
+
#: -> Regexp
|
258
252
|
def require_paths_prefix_matcher
|
259
|
-
@require_paths_prefix_matcher ||=
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
end,
|
265
|
-
T.nilable(Regexp),
|
266
|
-
)
|
253
|
+
@require_paths_prefix_matcher ||= begin
|
254
|
+
require_paths = T.unsafe(@spec).require_paths
|
255
|
+
prefix_matchers = require_paths.map { |rp| Regexp.new("^#{rp}/") }
|
256
|
+
Regexp.union(prefix_matchers)
|
257
|
+
end #: Regexp?
|
267
258
|
end
|
268
259
|
|
269
|
-
|
260
|
+
#: (String file) -> Pathname
|
270
261
|
def resolve_to_ruby_lib_dir(file)
|
271
262
|
# We want to match require prefixes but fallback to an empty match
|
272
263
|
# if none of the require prefixes actually match. This is so that
|
@@ -280,14 +271,14 @@ module Tapioca
|
|
280
271
|
Pathname.new(file).expand_path
|
281
272
|
end
|
282
273
|
|
283
|
-
|
274
|
+
#: -> String
|
284
275
|
def version_string
|
285
276
|
version = @spec.version.to_s
|
286
277
|
version += "-#{@spec.source.revision}" if Bundler::Source::Git === @spec.source
|
287
278
|
version
|
288
279
|
end
|
289
280
|
|
290
|
-
|
281
|
+
#: (String path) -> bool
|
291
282
|
def has_parent_gemspec?(path)
|
292
283
|
# For some Git installed gems the location of the loaded file can
|
293
284
|
# be different from the gem path as indicated by the spec file
|
@@ -308,7 +299,7 @@ module Tapioca
|
|
308
299
|
false
|
309
300
|
end
|
310
301
|
|
311
|
-
|
302
|
+
#: -> bool
|
312
303
|
def gem_ignored?
|
313
304
|
IGNORED_GEMS.include?(name)
|
314
305
|
end
|
@@ -8,7 +8,7 @@ module Tapioca
|
|
8
8
|
|
9
9
|
requires_ancestor { Thor::Shell }
|
10
10
|
|
11
|
-
|
11
|
+
#: (?String message, *(Symbol | Array[Symbol]) color) -> void
|
12
12
|
def say_error(message = "", *color)
|
13
13
|
# Thor has its own `say_error` now, but it has two problems:
|
14
14
|
# 1. it adds the padding around all the messages, even if they continue on
|
@@ -22,14 +22,14 @@ module Tapioca
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
|
25
|
+
#: (Hash[Symbol, untyped] options) -> RBIFormatter
|
26
26
|
def rbi_formatter(options)
|
27
27
|
rbi_formatter = DEFAULT_RBI_FORMATTER
|
28
28
|
rbi_formatter.max_line_length = options[:rbi_max_line_length]
|
29
29
|
rbi_formatter
|
30
30
|
end
|
31
31
|
|
32
|
-
|
32
|
+
#: (Hash[Symbol, untyped] options) -> String?
|
33
33
|
def netrc_file(options)
|
34
34
|
return if options[:auth]
|
35
35
|
return unless options[:netrc]
|
@@ -8,20 +8,20 @@ module Tapioca
|
|
8
8
|
|
9
9
|
requires_ancestor { Thor }
|
10
10
|
|
11
|
-
|
11
|
+
#: String
|
12
12
|
attr_reader :command_name
|
13
13
|
|
14
|
-
|
14
|
+
#: Thor::CoreExt::HashWithIndifferentAccess
|
15
15
|
attr_reader :defaults
|
16
16
|
|
17
|
-
|
17
|
+
#: (?untyped args, ?untyped local_options, ?untyped config) -> void
|
18
18
|
def initialize(args = [], local_options = {}, config = {})
|
19
19
|
# Store current command
|
20
20
|
command = config[:current_command]
|
21
21
|
command_options = config[:command_options]
|
22
|
-
@command_name =
|
23
|
-
@merged_options =
|
24
|
-
@defaults =
|
22
|
+
@command_name = command.name #: String
|
23
|
+
@merged_options = nil #: Thor::CoreExt::HashWithIndifferentAccess?
|
24
|
+
@defaults = Thor::CoreExt::HashWithIndifferentAccess.new #: Thor::CoreExt::HashWithIndifferentAccess
|
25
25
|
|
26
26
|
# Filter command options unless we are handling the help command.
|
27
27
|
# This is so that the defaults are printed
|
@@ -30,7 +30,7 @@ module Tapioca
|
|
30
30
|
super
|
31
31
|
end
|
32
32
|
|
33
|
-
|
33
|
+
#: -> Thor::CoreExt::HashWithIndifferentAccess
|
34
34
|
def options
|
35
35
|
@merged_options ||= begin
|
36
36
|
original_options = super
|
@@ -42,7 +42,7 @@ module Tapioca
|
|
42
42
|
|
43
43
|
private
|
44
44
|
|
45
|
-
|
45
|
+
#: (Hash[Symbol, Thor::Option] options) -> void
|
46
46
|
def filter_defaults(options)
|
47
47
|
options.each do |key, option|
|
48
48
|
# Store the value of the current default in our defaults hash
|
@@ -52,7 +52,7 @@ module Tapioca
|
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
|
-
|
55
|
+
#: (Thor::CoreExt::HashWithIndifferentAccess options) -> Thor::CoreExt::HashWithIndifferentAccess
|
56
56
|
def config_options(options)
|
57
57
|
config_file = options[:config]
|
58
58
|
config = {}
|
@@ -66,12 +66,12 @@ module Tapioca
|
|
66
66
|
Thor::CoreExt::HashWithIndifferentAccess.new(config[command_name] || {})
|
67
67
|
end
|
68
68
|
|
69
|
-
|
69
|
+
#: (String config_file, Hash[untyped, untyped] config) -> void
|
70
70
|
def validate_config!(config_file, config)
|
71
71
|
# To ensure that this is not re-entered, we mark during validation
|
72
72
|
return if @validating_config
|
73
73
|
|
74
|
-
@validating_config =
|
74
|
+
@validating_config = true #: bool?
|
75
75
|
|
76
76
|
commands = T.cast(self, Thor).class.commands
|
77
77
|
|
@@ -92,13 +92,7 @@ module Tapioca
|
|
92
92
|
@validating_config = false
|
93
93
|
end
|
94
94
|
|
95
|
-
|
96
|
-
params(
|
97
|
-
command_options: T::Hash[Symbol, Thor::Option],
|
98
|
-
config_key: String,
|
99
|
-
config_options: T::Hash[T.untyped, T.untyped],
|
100
|
-
).returns(T::Array[ConfigError])
|
101
|
-
end
|
95
|
+
#: (Hash[Symbol, Thor::Option] command_options, String config_key, Hash[untyped, untyped] config_options) -> Array[ConfigError]
|
102
96
|
def validate_config_options(command_options, config_key, config_options)
|
103
97
|
config_options.filter_map do |config_option_key, config_option_value|
|
104
98
|
command_option = command_options[config_option_key.to_sym]
|
@@ -149,7 +143,7 @@ module Tapioca
|
|
149
143
|
const :message_parts, T::Array[ConfigErrorMessagePart]
|
150
144
|
end
|
151
145
|
|
152
|
-
|
146
|
+
#: (String msg) -> ConfigError
|
153
147
|
def build_error(msg)
|
154
148
|
parts = msg.split(/(`[^`]+` ?)/)
|
155
149
|
|
@@ -174,7 +168,7 @@ module Tapioca
|
|
174
168
|
)
|
175
169
|
end
|
176
170
|
|
177
|
-
|
171
|
+
#: (String config_file, Array[ConfigError] errors) -> String
|
178
172
|
def build_error_message(config_file, errors)
|
179
173
|
error_messages = errors.map do |error|
|
180
174
|
"- " + error.message_parts.map do |part|
|
@@ -189,10 +183,7 @@ module Tapioca
|
|
189
183
|
ERROR
|
190
184
|
end
|
191
185
|
|
192
|
-
|
193
|
-
params(options: T.nilable(Thor::CoreExt::HashWithIndifferentAccess))
|
194
|
-
.returns(Thor::CoreExt::HashWithIndifferentAccess)
|
195
|
-
end
|
186
|
+
#: (*Thor::CoreExt::HashWithIndifferentAccess? options) -> Thor::CoreExt::HashWithIndifferentAccess
|
196
187
|
def merge_options(*options)
|
197
188
|
merged = options.each_with_object({}) do |option, result|
|
198
189
|
result.merge!(option || {}) do |_, this_val, other_val|
|
@@ -8,7 +8,7 @@ module Tapioca
|
|
8
8
|
|
9
9
|
requires_ancestor { Thor }
|
10
10
|
|
11
|
-
|
11
|
+
#: (Hash[Symbol, untyped] options) -> void
|
12
12
|
def set_environment(options) # rubocop:disable Naming/AccessorMethodName
|
13
13
|
ENV["RAILS_ENV"] = ENV["RACK_ENV"] = options[:environment]
|
14
14
|
ENV["RUBY_DEBUG_LAZY"] = "1"
|
@@ -5,7 +5,7 @@ module Tapioca
|
|
5
5
|
module GemHelper
|
6
6
|
extend T::Sig
|
7
7
|
|
8
|
-
|
8
|
+
#: ((String | Pathname) app_dir, String full_gem_path) -> bool
|
9
9
|
def gem_in_app_dir?(app_dir, full_gem_path)
|
10
10
|
app_dir = to_realpath(app_dir)
|
11
11
|
full_gem_path = to_realpath(full_gem_path)
|
@@ -13,17 +13,17 @@ module Tapioca
|
|
13
13
|
!gem_in_bundle_path?(full_gem_path) && !gem_in_ruby_path?(full_gem_path) && path_in_dir?(full_gem_path, app_dir)
|
14
14
|
end
|
15
15
|
|
16
|
-
|
16
|
+
#: (String full_gem_path) -> bool
|
17
17
|
def gem_in_bundle_path?(full_gem_path)
|
18
18
|
path_in_dir?(full_gem_path, Bundler.bundle_path) || path_in_dir?(full_gem_path, Bundler.app_cache)
|
19
19
|
end
|
20
20
|
|
21
|
-
|
21
|
+
#: (String full_gem_path) -> bool
|
22
22
|
def gem_in_ruby_path?(full_gem_path)
|
23
23
|
path_in_dir?(full_gem_path, RbConfig::CONFIG["rubylibprefix"])
|
24
24
|
end
|
25
25
|
|
26
|
-
|
26
|
+
#: ((String | Pathname) path) -> String
|
27
27
|
def to_realpath(path)
|
28
28
|
path_string = path.to_s
|
29
29
|
path_string = File.realpath(path_string) if File.exist?(path_string)
|
@@ -32,7 +32,7 @@ module Tapioca
|
|
32
32
|
|
33
33
|
private
|
34
34
|
|
35
|
-
|
35
|
+
#: ((Pathname | String) path, (Pathname | String) dir) -> bool
|
36
36
|
def path_in_dir?(path, dir)
|
37
37
|
dir = Pathname.new(dir)
|
38
38
|
path = Pathname.new(path)
|
@@ -5,14 +5,14 @@ class GitAttributes
|
|
5
5
|
class << self
|
6
6
|
extend T::Sig
|
7
7
|
|
8
|
-
|
8
|
+
#: (Pathname path) -> void
|
9
9
|
def create_generated_attribute_file(path)
|
10
10
|
create_gitattributes_file(path, <<~CONTENT)
|
11
11
|
**/*.rbi linguist-generated=true
|
12
12
|
CONTENT
|
13
13
|
end
|
14
14
|
|
15
|
-
|
15
|
+
#: (Pathname path) -> void
|
16
16
|
def create_vendored_attribute_file(path)
|
17
17
|
create_gitattributes_file(path, <<~CONTENT)
|
18
18
|
**/*.rbi linguist-vendored=true
|
@@ -21,7 +21,7 @@ class GitAttributes
|
|
21
21
|
|
22
22
|
private
|
23
23
|
|
24
|
-
|
24
|
+
#: (Pathname path, String content) -> void
|
25
25
|
def create_gitattributes_file(path, content)
|
26
26
|
# We don't want to start creating folders, just to write
|
27
27
|
# the `.gitattributes` file. So, if the folder doesn't
|