tapioca 0.11.8 → 0.11.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +116 -49
- data/lib/tapioca/cli.rb +76 -67
- data/lib/tapioca/commands/{dsl.rb → abstract_dsl.rb} +32 -78
- data/lib/tapioca/commands/{gem.rb → abstract_gem.rb} +26 -93
- data/lib/tapioca/commands/annotations.rb +9 -7
- data/lib/tapioca/commands/check_shims.rb +2 -0
- data/lib/tapioca/commands/command.rb +9 -2
- data/lib/tapioca/commands/configure.rb +2 -2
- data/lib/tapioca/commands/dsl_compiler_list.rb +31 -0
- data/lib/tapioca/commands/dsl_generate.rb +40 -0
- data/lib/tapioca/commands/dsl_verify.rb +25 -0
- data/lib/tapioca/commands/gem_generate.rb +51 -0
- data/lib/tapioca/commands/gem_sync.rb +37 -0
- data/lib/tapioca/commands/gem_verify.rb +36 -0
- data/lib/tapioca/commands/require.rb +2 -0
- data/lib/tapioca/commands/todo.rb +21 -2
- data/lib/tapioca/commands.rb +8 -2
- data/lib/tapioca/dsl/compiler.rb +8 -4
- data/lib/tapioca/dsl/compilers/action_controller_helpers.rb +3 -1
- data/lib/tapioca/dsl/compilers/active_model_validations_confirmation.rb +94 -0
- data/lib/tapioca/dsl/compilers/active_record_columns.rb +19 -9
- data/lib/tapioca/dsl/compilers/active_record_fixtures.rb +11 -14
- data/lib/tapioca/dsl/compilers/active_record_store.rb +149 -0
- data/lib/tapioca/dsl/compilers/active_record_typed_store.rb +3 -2
- data/lib/tapioca/dsl/compilers/active_support_concern.rb +1 -1
- data/lib/tapioca/dsl/compilers/graphql_input_object.rb +1 -1
- data/lib/tapioca/dsl/compilers/graphql_mutation.rb +9 -2
- data/lib/tapioca/dsl/compilers/json_api_client_resource.rb +208 -0
- data/lib/tapioca/dsl/extensions/active_record.rb +9 -0
- data/lib/tapioca/dsl/helpers/active_record_column_type_helper.rb +23 -4
- data/lib/tapioca/dsl/helpers/active_record_constants_helper.rb +1 -0
- data/lib/tapioca/dsl/helpers/graphql_type_helper.rb +18 -3
- data/lib/tapioca/dsl/pipeline.rb +6 -4
- data/lib/tapioca/gem/pipeline.rb +103 -36
- data/lib/tapioca/gemfile.rb +13 -7
- data/lib/tapioca/helpers/git_attributes.rb +34 -0
- data/lib/tapioca/helpers/test/template.rb +4 -4
- data/lib/tapioca/internal.rb +1 -0
- data/lib/tapioca/loaders/dsl.rb +11 -1
- data/lib/tapioca/loaders/loader.rb +17 -2
- data/lib/tapioca/sorbet_ext/generic_name_patch.rb +0 -27
- data/lib/tapioca/static/symbol_loader.rb +10 -9
- data/lib/tapioca/version.rb +1 -1
- metadata +20 -10
data/lib/tapioca/internal.rb
CHANGED
@@ -28,6 +28,7 @@ require "yard-sorbet"
|
|
28
28
|
require "tapioca/runtime/dynamic_mixin_compiler"
|
29
29
|
require "tapioca/helpers/gem_helper"
|
30
30
|
|
31
|
+
require "tapioca/helpers/git_attributes"
|
31
32
|
require "tapioca/helpers/sorbet_helper"
|
32
33
|
require "tapioca/helpers/rbi_helper"
|
33
34
|
require "tapioca/sorbet_ext/backcompat_patches"
|
data/lib/tapioca/loaders/dsl.rb
CHANGED
@@ -46,7 +46,17 @@ module Tapioca
|
|
46
46
|
|
47
47
|
sig { void }
|
48
48
|
def load_dsl_extensions
|
49
|
-
|
49
|
+
say("Loading DSL extension classes... ")
|
50
|
+
|
51
|
+
Dir.glob(["#{@tapioca_path}/extensions/**/*.rb"]).each do |extension|
|
52
|
+
require File.expand_path(extension)
|
53
|
+
end
|
54
|
+
|
55
|
+
::Gem.find_files("tapioca/dsl/extensions/*.rb").each do |extension|
|
56
|
+
require File.expand_path(extension)
|
57
|
+
end
|
58
|
+
|
59
|
+
say("Done", :green)
|
50
60
|
end
|
51
61
|
|
52
62
|
sig { void }
|
@@ -80,6 +80,8 @@ module Tapioca
|
|
80
80
|
def load_rails_engines
|
81
81
|
return if engines.empty?
|
82
82
|
|
83
|
+
normalize_eager_load_paths_configuration!
|
84
|
+
|
83
85
|
with_rails_application do
|
84
86
|
run_initializers
|
85
87
|
|
@@ -110,7 +112,7 @@ module Tapioca
|
|
110
112
|
autoloader = Zeitwerk::Loader.new
|
111
113
|
|
112
114
|
engines.each do |engine|
|
113
|
-
engine.config.
|
115
|
+
engine.config.all_eager_load_paths.each do |path|
|
114
116
|
# Zeitwerk only accepts existing directories in `push_dir`.
|
115
117
|
next unless File.directory?(path)
|
116
118
|
# We should not add directories that are already managed by a Zeitwerk loader.
|
@@ -131,7 +133,7 @@ module Tapioca
|
|
131
133
|
# We can't use `Rails::Engine#eager_load!` directly because it will raise as soon as it encounters
|
132
134
|
# an error, which is not what we want. We want to try to load as much as we can.
|
133
135
|
engines.each do |engine|
|
134
|
-
engine.config.
|
136
|
+
engine.config.all_eager_load_paths.each do |load_path|
|
135
137
|
Dir.glob("#{load_path}/**/*.rb").sort.each do |file|
|
136
138
|
require_dependency file
|
137
139
|
end
|
@@ -179,6 +181,19 @@ module Tapioca
|
|
179
181
|
.reject { |engine| gem_in_app_dir?(project_path, engine.config.root.to_path) }
|
180
182
|
end
|
181
183
|
|
184
|
+
# Rails 7.2 renamed `eager_load_paths` to `all_eager_load_paths`, which maintains the same original functionality.
|
185
|
+
# The `eager_load_paths` method still exists, but doesn't return all paths anymore and causes Tapioca to miss some
|
186
|
+
# engine paths. The following commit is the change:
|
187
|
+
# https://github.com/rails/rails/commit/ebfca905db14020589c22e6937382e6f8f687664
|
188
|
+
#
|
189
|
+
# Here we make sure that the new `all_eager_load_paths` is always defined for every Rails version below 7.2, so
|
190
|
+
# that we can use it everywhere
|
191
|
+
def normalize_eager_load_paths_configuration!
|
192
|
+
return if Rails::VERSION::MAJOR >= 7 && Rails::VERSION::MINOR >= 2
|
193
|
+
|
194
|
+
engines.each { |e| e.config.all_eager_load_paths = e.config.eager_load_paths }
|
195
|
+
end
|
196
|
+
|
182
197
|
sig { params(path: String).void }
|
183
198
|
def safe_require(path)
|
184
199
|
require path
|
@@ -191,19 +191,6 @@ module Tapioca
|
|
191
191
|
sig { returns(T.nilable(String)) }
|
192
192
|
def name
|
193
193
|
constant_name = super
|
194
|
-
|
195
|
-
# This is a hack to work around modules under anonymous modules not having
|
196
|
-
# names in 2.7: https://bugs.ruby-lang.org/issues/14895
|
197
|
-
#
|
198
|
-
# This happens when a type variable is declared under `class << self`, for
|
199
|
-
# example.
|
200
|
-
#
|
201
|
-
# The workaround is to give the parent context a name, at which point, our
|
202
|
-
# module gets bound to a name under that name, as well.
|
203
|
-
unless constant_name
|
204
|
-
constant_name = with_bound_name_pre_3_0 { super }
|
205
|
-
end
|
206
|
-
|
207
194
|
constant_name&.split("::")&.last
|
208
195
|
end
|
209
196
|
|
@@ -247,20 +234,6 @@ module Tapioca
|
|
247
234
|
-> { bounds }
|
248
235
|
end
|
249
236
|
|
250
|
-
sig do
|
251
|
-
type_parameters(:Result)
|
252
|
-
.params(block: T.proc.returns(T.type_parameter(:Result)))
|
253
|
-
.returns(T.type_parameter(:Result))
|
254
|
-
end
|
255
|
-
def with_bound_name_pre_3_0(&block)
|
256
|
-
require "securerandom"
|
257
|
-
temp_name = "TYPE_VARIABLE_TRACKING_#{SecureRandom.hex}"
|
258
|
-
self.class.const_set(temp_name, @context)
|
259
|
-
block.call
|
260
|
-
ensure
|
261
|
-
self.class.send(:remove_const, temp_name) if temp_name
|
262
|
-
end
|
263
|
-
|
264
237
|
sig { returns(T::Hash[Symbol, T.untyped]) }
|
265
238
|
def bounds
|
266
239
|
@bounds ||= @bounds_proc.call
|
@@ -27,7 +27,7 @@ module Tapioca
|
|
27
27
|
|
28
28
|
return Set.new unless gem_engine
|
29
29
|
|
30
|
-
paths = gem_engine.config.
|
30
|
+
paths = gem_engine.config.all_eager_load_paths.flat_map do |load_path|
|
31
31
|
Pathname.glob("#{load_path}/**/*.rb")
|
32
32
|
end
|
33
33
|
|
@@ -59,14 +59,15 @@ module Tapioca
|
|
59
59
|
|
60
60
|
sig { returns(T::Array[T.class_of(Rails::Engine)]) }
|
61
61
|
def engines
|
62
|
-
@engines
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
62
|
+
@engines ||= T.let(
|
63
|
+
if Object.const_defined?("Rails::Engine")
|
64
|
+
descendants_of(Object.const_get("Rails::Engine"))
|
65
|
+
.reject(&:abstract_railtie?)
|
66
|
+
else
|
67
|
+
[]
|
68
|
+
end,
|
69
|
+
T.nilable(T::Array[T.class_of(Rails::Engine)]),
|
70
|
+
)
|
70
71
|
end
|
71
72
|
|
72
73
|
sig { params(input: String, table_type: String).returns(String) }
|
data/lib/tapioca/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tapioca
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.11.
|
4
|
+
version: 0.11.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ufuk Kayserilioglu
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: exe
|
13
13
|
cert_chain: []
|
14
|
-
date: 2023-
|
14
|
+
date: 2023-10-31 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: bundler
|
@@ -61,20 +61,20 @@ dependencies:
|
|
61
61
|
requirements:
|
62
62
|
- - "~>"
|
63
63
|
- !ruby/object:Gem::Version
|
64
|
-
version: 0.
|
64
|
+
version: 0.1.0
|
65
65
|
- - ">="
|
66
66
|
- !ruby/object:Gem::Version
|
67
|
-
version: 0.0
|
67
|
+
version: 0.1.0
|
68
68
|
type: :runtime
|
69
69
|
prerelease: false
|
70
70
|
version_requirements: !ruby/object:Gem::Requirement
|
71
71
|
requirements:
|
72
72
|
- - "~>"
|
73
73
|
- !ruby/object:Gem::Version
|
74
|
-
version: 0.
|
74
|
+
version: 0.1.0
|
75
75
|
- - ">="
|
76
76
|
- !ruby/object:Gem::Version
|
77
|
-
version: 0.0
|
77
|
+
version: 0.1.0
|
78
78
|
- !ruby/object:Gem::Dependency
|
79
79
|
name: sorbet-static-and-runtime
|
80
80
|
requirement: !ruby/object:Gem::Requirement
|
@@ -152,13 +152,19 @@ files:
|
|
152
152
|
- lib/tapioca/bundler_ext/auto_require_hook.rb
|
153
153
|
- lib/tapioca/cli.rb
|
154
154
|
- lib/tapioca/commands.rb
|
155
|
+
- lib/tapioca/commands/abstract_dsl.rb
|
156
|
+
- lib/tapioca/commands/abstract_gem.rb
|
155
157
|
- lib/tapioca/commands/annotations.rb
|
156
158
|
- lib/tapioca/commands/check_shims.rb
|
157
159
|
- lib/tapioca/commands/command.rb
|
158
160
|
- lib/tapioca/commands/command_without_tracker.rb
|
159
161
|
- lib/tapioca/commands/configure.rb
|
160
|
-
- lib/tapioca/commands/
|
161
|
-
- lib/tapioca/commands/
|
162
|
+
- lib/tapioca/commands/dsl_compiler_list.rb
|
163
|
+
- lib/tapioca/commands/dsl_generate.rb
|
164
|
+
- lib/tapioca/commands/dsl_verify.rb
|
165
|
+
- lib/tapioca/commands/gem_generate.rb
|
166
|
+
- lib/tapioca/commands/gem_sync.rb
|
167
|
+
- lib/tapioca/commands/gem_verify.rb
|
162
168
|
- lib/tapioca/commands/require.rb
|
163
169
|
- lib/tapioca/commands/todo.rb
|
164
170
|
- lib/tapioca/dsl.rb
|
@@ -170,6 +176,7 @@ files:
|
|
170
176
|
- lib/tapioca/dsl/compilers/active_job.rb
|
171
177
|
- lib/tapioca/dsl/compilers/active_model_attributes.rb
|
172
178
|
- lib/tapioca/dsl/compilers/active_model_secure_password.rb
|
179
|
+
- lib/tapioca/dsl/compilers/active_model_validations_confirmation.rb
|
173
180
|
- lib/tapioca/dsl/compilers/active_record_associations.rb
|
174
181
|
- lib/tapioca/dsl/compilers/active_record_columns.rb
|
175
182
|
- lib/tapioca/dsl/compilers/active_record_delegated_types.rb
|
@@ -178,6 +185,7 @@ files:
|
|
178
185
|
- lib/tapioca/dsl/compilers/active_record_relations.rb
|
179
186
|
- lib/tapioca/dsl/compilers/active_record_scope.rb
|
180
187
|
- lib/tapioca/dsl/compilers/active_record_secure_token.rb
|
188
|
+
- lib/tapioca/dsl/compilers/active_record_store.rb
|
181
189
|
- lib/tapioca/dsl/compilers/active_record_typed_store.rb
|
182
190
|
- lib/tapioca/dsl/compilers/active_resource.rb
|
183
191
|
- lib/tapioca/dsl/compilers/active_storage.rb
|
@@ -188,6 +196,7 @@ files:
|
|
188
196
|
- lib/tapioca/dsl/compilers/graphql_input_object.rb
|
189
197
|
- lib/tapioca/dsl/compilers/graphql_mutation.rb
|
190
198
|
- lib/tapioca/dsl/compilers/identity_cache.rb
|
199
|
+
- lib/tapioca/dsl/compilers/json_api_client_resource.rb
|
191
200
|
- lib/tapioca/dsl/compilers/kredis.rb
|
192
201
|
- lib/tapioca/dsl/compilers/mixed_in_class_attributes.rb
|
193
202
|
- lib/tapioca/dsl/compilers/protobuf.rb
|
@@ -228,6 +237,7 @@ files:
|
|
228
237
|
- lib/tapioca/helpers/config_helper.rb
|
229
238
|
- lib/tapioca/helpers/env_helper.rb
|
230
239
|
- lib/tapioca/helpers/gem_helper.rb
|
240
|
+
- lib/tapioca/helpers/git_attributes.rb
|
231
241
|
- lib/tapioca/helpers/rbi_files_helper.rb
|
232
242
|
- lib/tapioca/helpers/rbi_helper.rb
|
233
243
|
- lib/tapioca/helpers/sorbet_helper.rb
|
@@ -276,14 +286,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
276
286
|
requirements:
|
277
287
|
- - ">="
|
278
288
|
- !ruby/object:Gem::Version
|
279
|
-
version: '
|
289
|
+
version: '3.0'
|
280
290
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
281
291
|
requirements:
|
282
292
|
- - ">="
|
283
293
|
- !ruby/object:Gem::Version
|
284
294
|
version: '0'
|
285
295
|
requirements: []
|
286
|
-
rubygems_version: 3.4.
|
296
|
+
rubygems_version: 3.4.21
|
287
297
|
signing_key:
|
288
298
|
specification_version: 4
|
289
299
|
summary: A Ruby Interface file generator for gems, core types and the Ruby standard
|