tapioca 0.8.3 → 0.9.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +5 -2
- data/README.md +188 -36
- data/lib/tapioca/cli.rb +130 -66
- data/lib/tapioca/commands/annotations.rb +167 -34
- data/lib/tapioca/commands/check_shims.rb +101 -0
- data/lib/tapioca/commands/{init.rb → configure.rb} +1 -1
- data/lib/tapioca/commands/dsl.rb +1 -1
- data/lib/tapioca/commands/gem.rb +15 -10
- data/lib/tapioca/commands.rb +2 -1
- data/lib/tapioca/dsl/compiler.rb +1 -13
- data/lib/tapioca/dsl/compilers/active_model_attributes.rb +1 -1
- data/lib/tapioca/dsl/compilers/active_record_relations.rb +17 -0
- data/lib/tapioca/dsl/compilers/active_record_typed_store.rb +5 -4
- data/lib/tapioca/dsl/compilers/frozen_record.rb +2 -2
- data/lib/tapioca/dsl/compilers/protobuf.rb +6 -0
- data/lib/tapioca/dsl/compilers.rb +0 -4
- data/lib/tapioca/dsl/helpers/active_record_column_type_helper.rb +21 -3
- data/lib/tapioca/dsl/pipeline.rb +0 -2
- data/lib/tapioca/dsl.rb +8 -0
- data/lib/tapioca/executor.rb +0 -3
- data/lib/tapioca/gem/events.rb +22 -3
- data/lib/tapioca/gem/listeners/base.rb +11 -0
- data/lib/tapioca/gem/listeners/dynamic_mixins.rb +5 -0
- data/lib/tapioca/gem/listeners/foreign_constants.rb +65 -0
- data/lib/tapioca/gem/listeners/methods.rb +7 -18
- data/lib/tapioca/gem/listeners/mixins.rb +31 -10
- data/lib/tapioca/gem/listeners/remove_empty_payload_scopes.rb +5 -0
- data/lib/tapioca/gem/listeners/sorbet_enums.rb +5 -0
- data/lib/tapioca/gem/listeners/sorbet_helpers.rb +5 -0
- data/lib/tapioca/gem/listeners/sorbet_props.rb +5 -0
- data/lib/tapioca/gem/listeners/sorbet_required_ancestors.rb +5 -0
- data/lib/tapioca/gem/listeners/sorbet_signatures.rb +6 -1
- data/lib/tapioca/gem/listeners/sorbet_type_variables.rb +5 -0
- data/lib/tapioca/gem/listeners/source_location.rb +67 -0
- data/lib/tapioca/gem/listeners/subconstants.rb +5 -0
- data/lib/tapioca/gem/listeners/yard_doc.rb +5 -0
- data/lib/tapioca/gem/listeners.rb +2 -0
- data/lib/tapioca/gem/pipeline.rb +64 -19
- data/lib/tapioca/gem.rb +6 -0
- data/lib/tapioca/gemfile.rb +7 -6
- data/lib/tapioca/helpers/cli_helper.rb +8 -2
- data/lib/tapioca/helpers/config_helper.rb +0 -2
- data/lib/tapioca/helpers/env_helper.rb +16 -0
- data/lib/tapioca/helpers/rbi_files_helper.rb +255 -0
- data/lib/tapioca/helpers/rbi_helper.rb +98 -94
- data/lib/tapioca/helpers/sorbet_helper.rb +2 -3
- data/lib/tapioca/helpers/test/content.rb +0 -2
- data/lib/tapioca/helpers/test/template.rb +0 -2
- data/lib/tapioca/internal.rb +36 -12
- data/lib/tapioca/rbi_ext/model.rb +2 -15
- data/lib/tapioca/runtime/dynamic_mixin_compiler.rb +18 -16
- data/lib/tapioca/runtime/reflection.rb +26 -0
- data/lib/tapioca/runtime/trackers/constant_definition.rb +44 -16
- data/lib/tapioca/runtime/trackers/mixin.rb +49 -14
- data/lib/tapioca/sorbet_ext/generic_name_patch.rb +1 -4
- data/lib/tapioca/sorbet_ext/name_patch.rb +15 -5
- data/lib/tapioca/sorbet_ext/proc_bind_patch.rb +40 -0
- data/lib/tapioca/static/requires_compiler.rb +0 -2
- data/lib/tapioca/static/symbol_loader.rb +26 -30
- data/lib/tapioca/static/symbol_table_parser.rb +0 -3
- data/lib/tapioca/version.rb +1 -1
- data/lib/tapioca.rb +3 -0
- metadata +24 -7
- data/lib/tapioca/dsl/helpers/param_helper.rb +0 -55
- data/lib/tapioca/helpers/shims_helper.rb +0 -115
- data/lib/tapioca/helpers/signatures_helper.rb +0 -17
- data/lib/tapioca/helpers/type_variable_helper.rb +0 -43
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c9cda50b7996366aafe00f6b8643f17385088e842c9626c23b922202702d8ee4
|
4
|
+
data.tar.gz: 040d9732ca74f020d475c3965392b63c2b9a525876cfd765b2c21fa0d031df54
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a7678c337e77326cedb49b06088ec1b24ae9b08f2047f02efc741134dc6a6efe851a702f45e02c571850c1762aca4de134067015aa8f2da06be9aa1cabb2050b
|
7
|
+
data.tar.gz: edd3d2148f8c4ee3c04bdc5025502e859f8d726bf38c741d4357a152770608ba639ad420070a8e071a261b4459bb20b7b637a390991877fd757e9d04a3d0d4b7
|
data/Gemfile
CHANGED
@@ -11,7 +11,6 @@ gem("pry-byebug")
|
|
11
11
|
gem("rubocop-shopify", require: false)
|
12
12
|
gem("rubocop-sorbet", ">= 0.4.1")
|
13
13
|
gem("rubocop-rspec", require: false)
|
14
|
-
gem("sorbet")
|
15
14
|
gem("ruby-lsp", require: false)
|
16
15
|
|
17
16
|
group(:deployment, :development) do
|
@@ -38,7 +37,7 @@ group(:development, :test) do
|
|
38
37
|
gem("shopify-money", require: false)
|
39
38
|
gem("sidekiq", require: false)
|
40
39
|
gem("nokogiri", require: false)
|
41
|
-
gem("config", require: false)
|
40
|
+
gem("config", github: "rubyconfig/config", branch: "master", require: false)
|
42
41
|
gem("aasm", require: false)
|
43
42
|
gem("bcrypt", require: false)
|
44
43
|
gem("xpath", require: false)
|
@@ -48,3 +47,7 @@ group(:development, :test) do
|
|
48
47
|
# https://github.com/rails/rails/blob/0919aa97260ab8240150278d3b07a1547489e3fd/Gemfile#L178-L191
|
49
48
|
gem("net-smtp", "0.3.1", require: false)
|
50
49
|
end
|
50
|
+
|
51
|
+
group :test do
|
52
|
+
gem("webmock")
|
53
|
+
end
|
data/README.md
CHANGED
@@ -42,15 +42,19 @@ end
|
|
42
42
|
|
43
43
|
Run `bundle install` and make sure Tapioca is properly installed:
|
44
44
|
|
45
|
-
|
46
|
-
|
45
|
+
<!-- START_HELP -->
|
46
|
+
```shell
|
47
|
+
$ tapioca help
|
48
|
+
|
47
49
|
Commands:
|
48
50
|
tapioca --version, -v # show version
|
49
|
-
tapioca
|
51
|
+
tapioca annotations # Pull gem RBI annotations from remote sources
|
52
|
+
tapioca check-shims # check duplicated definitions in shim RBIs
|
53
|
+
tapioca configure # initialize folder structure and type checking configuration
|
50
54
|
tapioca dsl [constant...] # generate RBIs for dynamic methods
|
51
55
|
tapioca gem [gem...] # generate RBIs from gems
|
52
56
|
tapioca help [COMMAND] # Describe available commands or one specific command
|
53
|
-
tapioca init #
|
57
|
+
tapioca init # get project ready for type checking
|
54
58
|
tapioca require # generate the list of files to be required by tapioca
|
55
59
|
tapioca todo # generate the list of unresolved constants
|
56
60
|
|
@@ -58,24 +62,27 @@ Options:
|
|
58
62
|
-c, [--config=<config file path>] # Path to the Tapioca configuration file
|
59
63
|
# Default: sorbet/tapioca/config.yml
|
60
64
|
-V, [--verbose], [--no-verbose] # Verbose output for debugging purposes
|
65
|
+
|
61
66
|
```
|
67
|
+
<!-- END_HELP -->
|
62
68
|
|
63
69
|
## Getting started
|
64
70
|
|
65
71
|
Execute this command to get started:
|
66
72
|
|
67
|
-
```
|
73
|
+
```shell
|
68
74
|
$ bundle exec tapioca init
|
69
|
-
create sorbet/config
|
70
|
-
create sorbet/tapioca/config.yml
|
71
|
-
create sorbet/tapioca/require.rb
|
72
|
-
create bin/tapioca
|
73
75
|
```
|
74
76
|
|
75
77
|
This will:
|
76
78
|
|
77
|
-
|
78
|
-
|
79
|
+
1. create the [configuration file for Sorbet](https://sorbet.org/docs/cli#config-file), the [configuration file for Tapioca](#Configuration) and the [require.rb file](#manually-requiring-parts-of-a-gem)
|
80
|
+
2. install the [binstub](https://bundler.io/man/bundle-binstubs.1.html#DESCRIPTION) for Tapioca in your app's `bin/` folder, so that you can use `bin/tapioca` to run commands in your app
|
81
|
+
3. pull the community RBI annotations from the [central repository](https://github.com/Shopify/rbi-central) matching your app's gems
|
82
|
+
4. generate the RBIs for your app's gems
|
83
|
+
5. generate the RBI file for missing constants
|
84
|
+
|
85
|
+
See the following sections for more details about each step.
|
79
86
|
|
80
87
|
<!-- START_HELP_COMMAND_INIT -->
|
81
88
|
```shell
|
@@ -89,7 +96,7 @@ Options:
|
|
89
96
|
# Default: sorbet/tapioca/config.yml
|
90
97
|
-V, [--verbose], [--no-verbose] # Verbose output for debugging purposes
|
91
98
|
|
92
|
-
|
99
|
+
get project ready for type checking
|
93
100
|
```
|
94
101
|
<!-- END_HELP_COMMAND_INIT -->
|
95
102
|
|
@@ -101,7 +108,7 @@ Sorbet does not read the code in your gem dependencies, so it does not know the
|
|
101
108
|
|
102
109
|
In order to generate the RBI files for the gems used in your application, run the following command:
|
103
110
|
|
104
|
-
```
|
111
|
+
```shell
|
105
112
|
$ bin/tapioca gems [gems...]
|
106
113
|
|
107
114
|
Removing RBI files of gems that have been removed:
|
@@ -145,6 +152,8 @@ Options:
|
|
145
152
|
[--verify], [--no-verify] # Verify RBIs are up-to-date
|
146
153
|
[--doc], [--no-doc] # Include YARD documentation from sources when generating RBIs. Warning: this might be slow
|
147
154
|
# Default: true
|
155
|
+
[--loc], [--no-loc] # Include comments with source location when generating RBIs
|
156
|
+
# Default: true
|
148
157
|
[--exported-gem-rbis], [--no-exported-gem-rbis] # Include RBIs found in the `rbi/` directory of the gem
|
149
158
|
# Default: true
|
150
159
|
-w, [--workers=N] # EXPERIMENTAL: Number of parallel workers to use when generating RBIs
|
@@ -155,6 +164,8 @@ Options:
|
|
155
164
|
# Default: sorbet/rbi/dsl
|
156
165
|
[--rbi-max-line-length=N] # Set the max line length of generated RBIs. Signatures longer than the max line length will be wrapped
|
157
166
|
# Default: 120
|
167
|
+
-e, [--environment=ENVIRONMENT] # The Rack/Rails environment to use when generating RBIs
|
168
|
+
# Default: development
|
158
169
|
-c, [--config=<config file path>] # Path to the Tapioca configuration file
|
159
170
|
# Default: sorbet/tapioca/config.yml
|
160
171
|
-V, [--verbose], [--no-verbose] # Verbose output for debugging purposes
|
@@ -163,11 +174,17 @@ generate RBIs from gems
|
|
163
174
|
```
|
164
175
|
<!-- END_HELP_COMMAND_GEM -->
|
165
176
|
|
177
|
+
By default, running `tapioca gem` will only generate the RBI files for gems that have been added to or removed from the project's `Gemfile` this means that Tapioca will not regenerate the RBI files for untouched gems. However, when changing Tapioca configuration or bumping its version, it may be useful to force the regeneration of the RBI files previsouly generated. This can be done with the `--all` option:
|
178
|
+
|
179
|
+
```shell
|
180
|
+
bin/tapioca gems --all
|
181
|
+
```
|
182
|
+
|
166
183
|
> Are you coming from `srb rbi`? [See how `tapioca gem` compares to `srb rbi`](https://github.com/Shopify/tapioca/wiki/How-does-tapioca-compare-to-%22srb-rbi-gems%22-%3F).
|
167
184
|
|
168
185
|
#### Manually requiring parts of a gem
|
169
186
|
|
170
|
-
It may happen that the RBI file generated for a gem listed inside your `Gemfile.lock` is missing some definitions
|
187
|
+
It may happen that the RBI file generated for a gem listed inside your `Gemfile.lock` is missing some definitions that you would expect it to be exporting.
|
171
188
|
|
172
189
|
For gems that have a normal default `require` and that load all of their constants through that, everything should work seamlessly. However, for gems that are marked as `require: false` in the `Gemfile`, or for gems that export constants optionally via different requires, where a single require does not load the whole gem code into memory, Tapioca will not be able to load some of the types into memory and, thus, won't be able to generate complete RBIs for them. For this reason, we need to keep a small external file named `sorbet/tapioca/require.rb` that is executed after all the gems in the `Gemfile` have been required and before generation of gem RBIs have started. This file is responsible for adding the requires for additional files from gems, which are not covered by the default require.
|
173
190
|
|
@@ -210,7 +227,7 @@ If you ever run into a case, where you add a gem or update the version of a gem
|
|
210
227
|
|
211
228
|
To help you get started, you can use the command `tapioca require` to auto-populate the contents of the `sorbet/tapioca/require.rb` file with all the requires found in your application:
|
212
229
|
|
213
|
-
```
|
230
|
+
```shell
|
214
231
|
$ bin/tapioca require
|
215
232
|
|
216
233
|
Compiling sorbet/tapioca/require.rb, this may take a few seconds... Done
|
@@ -223,11 +240,11 @@ Once the file is generated, you should review it, remove all unnecessary require
|
|
223
240
|
|
224
241
|
#### Excluding a gem from RBI generation
|
225
242
|
|
226
|
-
It may be useful to exclude some gems from the generation process. For example for gems that are in Bundle's debug group or gems of which the contents are dependent on the architecture they are loaded on.
|
243
|
+
It may be useful to exclude some gems from the generation process. For example for gems that are in Bundle's debug group or gems of which the contents are dependent on the architecture they are loaded on.
|
227
244
|
|
228
245
|
To do so you can pass the list of gems you want to exclude in the command line with the `--exclude` option:
|
229
246
|
|
230
|
-
```
|
247
|
+
```shell
|
231
248
|
$ bin/tapioca gems --exclude gemA gemB
|
232
249
|
```
|
233
250
|
|
@@ -240,13 +257,18 @@ gem:
|
|
240
257
|
- gemB
|
241
258
|
```
|
242
259
|
|
260
|
+
There are a few development/test environment gems that can cause RBI generation issues, so Tapioca skips them by default:
|
261
|
+
|
262
|
+
* `debug`
|
263
|
+
* `fakefs`
|
264
|
+
|
243
265
|
#### Changing the strictness level of the RBI for a gem
|
244
266
|
|
245
267
|
By default, all RBI files for gems are generated with the [strictness level](https://sorbet.org/docs/static#file-level-granularity-strictness-levels) `typed: true`. Sometimes, this strictness level can create type-checking errors when a gem contains definitions that conflict with [Sorbet internal definitions for Ruby core and standard library](https://sorbet.org/docs/faq#it-looks-like-sorbets-types-for-the-stdlib-are-wrong).
|
246
268
|
|
247
269
|
Tapioca comes with an automatic detection (option `--auto-strictness`, enabled by default) of such cases and will switch the strictness level to `typed: false` in RBI files containing conflicts with the core and standard library definitions. It is nonetheless possible to manually switch the strictness level for a gem using the `--typed-overrides` option:
|
248
270
|
|
249
|
-
```
|
271
|
+
```shell
|
250
272
|
$ bin/tapioca gems --typed-overrides gemA:false gemB:false
|
251
273
|
```
|
252
274
|
|
@@ -263,7 +285,7 @@ gem:
|
|
263
285
|
|
264
286
|
To ensure all RBI files for gems are up-to-date with the latest changes in your `Gemfile.lock`, Tapioca provides a `--verify` option:
|
265
287
|
|
266
|
-
```
|
288
|
+
```shell
|
267
289
|
$ bin/tapioca gems --verify
|
268
290
|
|
269
291
|
Checking for out-of-date RBIs...
|
@@ -273,6 +295,115 @@ Nothing to do, all RBIs are up-to-date.
|
|
273
295
|
|
274
296
|
This option can be used on CI to make sure the RBI files are always up-to-date and ensure accurate type checking. **Warning**: doing so will break your normal Dependabot workflow as every pull-request opened to bump a gem version will fail CI since the RBI will be out-of-date and will require you to manually run `bin/tapioca gems` to update them.
|
275
297
|
|
298
|
+
### Pulling RBI annotations from remote sources
|
299
|
+
|
300
|
+
Since Tapioca does not perform any type inference, the RBI files generated for the gems do not contain any type signatures. Instead, Tapioca relies on the community to provide high-quality, manually written RBI annotations for public gems.
|
301
|
+
|
302
|
+
To pull the annotations relevant to your project from the central repository, run the `annotations` command:
|
303
|
+
|
304
|
+
```shell
|
305
|
+
$ bin/tapioca annotations
|
306
|
+
|
307
|
+
Retrieving index from central repository... Done
|
308
|
+
Listing gems from Gemfile.lock... Done
|
309
|
+
Removing annotations for gems that have been removed... Nothing to do
|
310
|
+
Fetching gem annotations from central repository...
|
311
|
+
|
312
|
+
Fetched activesupport
|
313
|
+
created sorbet/rbi/annotations/activesupport.rbi
|
314
|
+
|
315
|
+
Done
|
316
|
+
```
|
317
|
+
|
318
|
+
<!-- START_HELP_COMMAND_ANNOTATIONS -->
|
319
|
+
```shell
|
320
|
+
$ tapioca help annotations
|
321
|
+
|
322
|
+
Usage:
|
323
|
+
tapioca annotations
|
324
|
+
|
325
|
+
Options:
|
326
|
+
[--sources=one two three] # URIs of the sources to pull gem RBI annotations from
|
327
|
+
# Default: ["https://raw.githubusercontent.com/Shopify/rbi-central/main"]
|
328
|
+
[--netrc], [--no-netrc] # Use .netrc to authenticate to private sources
|
329
|
+
# Default: true
|
330
|
+
[--netrc-file=NETRC_FILE] # Path to .netrc file
|
331
|
+
[--auth=AUTH] # HTTP authorization header for private sources
|
332
|
+
--typed, -t, [--typed-overrides=gem:level [gem:level ...]] # Override for typed sigils for pulled annotations
|
333
|
+
-c, [--config=<config file path>] # Path to the Tapioca configuration file
|
334
|
+
# Default: sorbet/tapioca/config.yml
|
335
|
+
-V, [--verbose], [--no-verbose] # Verbose output for debugging purposes
|
336
|
+
|
337
|
+
Pull gem RBI annotations from remote sources
|
338
|
+
```
|
339
|
+
<!-- END_HELP_COMMAND_ANNOTATIONS -->
|
340
|
+
|
341
|
+
By default, Tapioca will pull the annotations stored in the central repository located at https://github.com/Shopify/rbi-central. It is possible to use a custom repository by changing the value of the `--sources` options. For example if your repository is stored on Github:
|
342
|
+
|
343
|
+
```shell
|
344
|
+
$ bin/tapioca annotations --sources https://raw.githubusercontent.com/$USER/$REPO/$BRANCH
|
345
|
+
```
|
346
|
+
|
347
|
+
Tapioca also supports pulling annotations from multiple sources:
|
348
|
+
|
349
|
+
```shell
|
350
|
+
$ bin/tapioca annotations --sources https://raw.githubusercontent.com/$USER/$REPO1/$BRANCH https://raw.githubusercontent.com/$USER/$REPO2/$BRANCH
|
351
|
+
```
|
352
|
+
|
353
|
+
#### Basic authentication
|
354
|
+
|
355
|
+
Private repositories can be used as sources by passing the option `--auth` with an authentication string. For Github, this string is `token $TOKEN` where `$TOKEN` is a [personal access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token):
|
356
|
+
|
357
|
+
```shell
|
358
|
+
$ bin/tapioca annotations --sources https://raw.githubusercontent.com/$USER/$PRIVATE_REPO/$BRANCH --auth "token $TOKEN"
|
359
|
+
```
|
360
|
+
|
361
|
+
#### Using a .netrc file
|
362
|
+
|
363
|
+
Tapioca supports reading credentials from a [netrc](https://www.gnu.org/software/inetutils/manual/html_node/The-_002enetrc-file.html) file (defaulting to `~/.netrc`).
|
364
|
+
|
365
|
+
Given these lines in your netrc:
|
366
|
+
|
367
|
+
```netrc
|
368
|
+
machine raw.githubusercontent.com
|
369
|
+
login $USERNAME
|
370
|
+
password $TOKEN
|
371
|
+
```
|
372
|
+
|
373
|
+
where `$USERNAME` is your Github username and `$TOKEN` is a [personal access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token), then, if you run Tapioca with the `--netrc` option (enabled by default), your annotation requests should be authenticated properly.
|
374
|
+
|
375
|
+
The `--netrc-file` option can be specified to read from a file other than `~/.netrc`:
|
376
|
+
|
377
|
+
```shell
|
378
|
+
$ bin/tapioca annotations --netrc-file /path/to/my/netrc/file
|
379
|
+
```
|
380
|
+
|
381
|
+
Similar to `--netrc-file`, you can also specify an alternative netrc file by using the `TAPIOCA_NETRC_FILE` environment variable:
|
382
|
+
|
383
|
+
```shell
|
384
|
+
$ TAPIOCA_NETRC_FILE=/path/to/my/netrc/file bin/tapioca annotations
|
385
|
+
```
|
386
|
+
|
387
|
+
Tapioca will first try to find the netrc file as specified by the `--netrc-file` option. If that option is not supplied, it will try the `TAPIOCA_NETRC_FILE` environment variable value. If that value is not supplied either, it will fallback to `~/.netrc`.
|
388
|
+
|
389
|
+
#### Changing the typed strictness of annotations files
|
390
|
+
|
391
|
+
Sometimes the annotations files pulled by Tapioca will create type errors in your project because of incompatibilities.
|
392
|
+
It is possible to ignore such files by switching their strictness level `--typed-overrides` option:
|
393
|
+
|
394
|
+
```shell
|
395
|
+
$ bin/tapioca annotations --typed-overrides gemA:ignore gemB:false
|
396
|
+
```
|
397
|
+
|
398
|
+
Or through the configuration file:
|
399
|
+
|
400
|
+
```yaml
|
401
|
+
annotations:
|
402
|
+
typed_overrides:
|
403
|
+
gemA: "ignore"
|
404
|
+
gemB: "false"
|
405
|
+
```
|
406
|
+
|
276
407
|
### Generating RBI files for Rails and other DSLs
|
277
408
|
|
278
409
|
Sorbet by itself does not understand DSLs involving meta-programming, such as Rails. This means that Sorbet won't know about constants and methods generated by `ActiveRecord` or `ActiveSupport`.
|
@@ -280,7 +411,7 @@ To solve this, Tapioca can load your application and introspect it to find the c
|
|
280
411
|
|
281
412
|
To generate the RBI files for the DSLs used in your application, run the following command:
|
282
413
|
|
283
|
-
```
|
414
|
+
```shell
|
284
415
|
$ bin/tapioca dsl
|
285
416
|
|
286
417
|
Loading Rails application... Done
|
@@ -315,6 +446,8 @@ Options:
|
|
315
446
|
# Default: 1
|
316
447
|
[--rbi-max-line-length=N] # Set the max line length of generated RBIs. Signatures longer than the max line length will be wrapped
|
317
448
|
# Default: 120
|
449
|
+
-e, [--environment=ENVIRONMENT] # The Rack/Rails environment to use when generating RBIs
|
450
|
+
# Default: development
|
318
451
|
-c, [--config=<config file path>] # Path to the Tapioca configuration file
|
319
452
|
# Default: sorbet/tapioca/config.yml
|
320
453
|
-V, [--verbose], [--no-verbose] # Verbose output for debugging purposes
|
@@ -327,7 +460,7 @@ generate RBIs for dynamic methods
|
|
327
460
|
|
328
461
|
To ensure all RBI files for DSLs are up-to-date with the latest changes in your application or database, Tapioca provide a `--verify` option:
|
329
462
|
|
330
|
-
```
|
463
|
+
```shell
|
331
464
|
$ bin/tapioca dsl --verify
|
332
465
|
|
333
466
|
Loading Rails application... Done
|
@@ -517,7 +650,7 @@ To get you started quickly, Tapioca can create a RBI file containing a stub of a
|
|
517
650
|
|
518
651
|
To generate the RBI file for the missing constants used in your application run the following command:
|
519
652
|
|
520
|
-
```
|
653
|
+
```shell
|
521
654
|
$ bin/tapioca todo
|
522
655
|
|
523
656
|
Compiling sorbet/rbi/todo.rbi, this may take a few seconds... Done
|
@@ -566,13 +699,14 @@ end
|
|
566
699
|
|
567
700
|
As you migrate to newer versions of Sorbet or Tapioca, some shims may become useless as Sorbet's internal definitions for Ruby's core and standard library is enhanced or Tapioca is able to generate definitions for new DSLs. To avoid keeping outdated or useless definitions inside your application shims, Tapioca provides the `check-shims` command:
|
568
701
|
|
569
|
-
```
|
702
|
+
```shell
|
570
703
|
$ bin/tapioca check-shims
|
571
704
|
|
572
705
|
Loading Sorbet payload... Done
|
573
706
|
Loading shim RBIs from sorbet/rbi/shims... Done
|
574
707
|
Loading gem RBIs from sorbet/rbi/gems... Done
|
575
708
|
Loading gem RBIs from sorbet/rbi/dsl... Done
|
709
|
+
Loading annotation RBIs from sorbet/rbi/annotations... Done
|
576
710
|
Looking for duplicates... Done
|
577
711
|
|
578
712
|
Duplicated RBI for ::MyModel#title:
|
@@ -588,27 +722,35 @@ Please remove the duplicated definitions from the sorbet/rbi/shims directory.
|
|
588
722
|
|
589
723
|
This command can be used on CI to make sure the RBI shims are always up-to-date and non-redundant with generated files.
|
590
724
|
|
591
|
-
<!--
|
725
|
+
<!-- START_HELP_COMMAND_CHECK_SHIMS -->
|
592
726
|
```shell
|
593
|
-
$
|
727
|
+
$ tapioca help check_shims
|
594
728
|
|
595
729
|
Usage:
|
596
730
|
tapioca check-shims
|
597
731
|
|
598
732
|
Options:
|
599
|
-
[--gem-rbi-dir=GEM_RBI_DIR]
|
600
|
-
|
601
|
-
[--dsl-rbi-dir=DSL_RBI_DIR]
|
602
|
-
|
603
|
-
[--shim-rbi-dir=SHIM_RBI_DIR]
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
733
|
+
[--gem-rbi-dir=GEM_RBI_DIR] # Path to gem RBIs
|
734
|
+
# Default: sorbet/rbi/gems
|
735
|
+
[--dsl-rbi-dir=DSL_RBI_DIR] # Path to DSL RBIs
|
736
|
+
# Default: sorbet/rbi/dsl
|
737
|
+
[--shim-rbi-dir=SHIM_RBI_DIR] # Path to shim RBIs
|
738
|
+
# Default: sorbet/rbi/shims
|
739
|
+
[--annotations-rbi-dir=ANNOTATIONS_RBI_DIR] # Path to annotations RBIs
|
740
|
+
# Default: sorbet/rbi/annotations
|
741
|
+
[--todo-rbi-file=TODO_RBI_FILE] # Path to the generated todo RBI file
|
742
|
+
# Default: sorbet/rbi/todo.rbi
|
743
|
+
[--payload], [--no-payload] # Check shims against Sorbet's payload
|
744
|
+
# Default: true
|
745
|
+
-w, [--workers=N] # EXPERIMENTAL: Number of parallel workers
|
746
|
+
# Default: 1
|
747
|
+
-c, [--config=<config file path>] # Path to the Tapioca configuration file
|
748
|
+
# Default: sorbet/tapioca/config.yml
|
749
|
+
-V, [--verbose], [--no-verbose] # Verbose output for debugging purposes
|
608
750
|
|
609
751
|
check duplicated definitions in shim RBIs
|
610
752
|
```
|
611
|
-
<!--
|
753
|
+
<!-- END_HELP_COMMAND_CHECK_SHIMS -->
|
612
754
|
|
613
755
|
### Configuration
|
614
756
|
|
@@ -652,6 +794,7 @@ dsl:
|
|
652
794
|
quiet: false
|
653
795
|
workers: 1
|
654
796
|
rbi_max_line_length: 120
|
797
|
+
environment: development
|
655
798
|
gem:
|
656
799
|
outdir: sorbet/rbi/gems
|
657
800
|
file_header: true
|
@@ -663,18 +806,27 @@ gem:
|
|
663
806
|
activesupport: 'false'
|
664
807
|
verify: false
|
665
808
|
doc: true
|
809
|
+
loc: true
|
666
810
|
exported_gem_rbis: true
|
667
811
|
workers: 1
|
668
812
|
auto_strictness: true
|
669
813
|
dsl_dir: sorbet/rbi/dsl
|
670
814
|
rbi_max_line_length: 120
|
815
|
+
environment: development
|
671
816
|
check_shims:
|
672
817
|
gem_rbi_dir: sorbet/rbi/gems
|
673
818
|
dsl_rbi_dir: sorbet/rbi/dsl
|
674
819
|
shim_rbi_dir: sorbet/rbi/shims
|
820
|
+
annotations_rbi_dir: sorbet/rbi/annotations
|
821
|
+
todo_rbi_file: sorbet/rbi/todo.rbi
|
675
822
|
payload: true
|
823
|
+
workers: 1
|
676
824
|
annotations:
|
677
|
-
|
825
|
+
sources:
|
826
|
+
- https://raw.githubusercontent.com/Shopify/rbi-central/main
|
827
|
+
netrc: true
|
828
|
+
netrc_file: ''
|
829
|
+
typed_overrides: {}
|
678
830
|
```
|
679
831
|
<!-- END_CONFIG_TEMPLATE -->
|
680
832
|
|