tapioca 0.14.4 → 0.15.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/tapioca/commands/annotations.rb +26 -14
- data/lib/tapioca/dsl/compilers/active_record_relations.rb +1 -1
- data/lib/tapioca/dsl/compilers/identity_cache.rb +1 -1
- data/lib/tapioca/gem_info.rb +18 -0
- data/lib/tapioca/internal.rb +1 -0
- data/lib/tapioca/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f93b130a7096e0712ccd91b8406d92ce537287afafc8aad7586e7f670d88a131
|
4
|
+
data.tar.gz: b2cc1e6d2658002600c1edd9c5c88b22704e3f4170ff19aff93bb9fc21df688e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa10ff7ffd4768cea802b63dc68273fa0abf7f69b61a83b1325669e97d706cb8afcc704093c93596a830662fe04b01ad2ded3c166abd69a5c69097bd28f586c9
|
7
|
+
data.tar.gz: 63499428de9374990372beb46ece3f98d0f446ba28ef02bfa181179113e37e587ff9867bbe0d729d67c03ddb2813943f6f04d14f2065589a603a766a06ce8096
|
@@ -46,22 +46,22 @@ module Tapioca
|
|
46
46
|
GitAttributes.create_vendored_attribute_file(@outpath)
|
47
47
|
end
|
48
48
|
|
49
|
-
sig { returns(T::Array[
|
49
|
+
sig { returns(T::Array[GemInfo]) }
|
50
50
|
def list_gemfile_gems
|
51
51
|
say("Listing gems from Gemfile.lock... ", [:blue, :bold])
|
52
52
|
gemfile = Bundler.read_file("Gemfile.lock")
|
53
53
|
parser = Bundler::LockfileParser.new(gemfile)
|
54
|
-
|
54
|
+
gem_info = parser.specs.map { |spec| GemInfo.from_spec(spec) }
|
55
55
|
say("Done", :green)
|
56
|
-
|
56
|
+
gem_info
|
57
57
|
end
|
58
58
|
|
59
|
-
sig { params(project_gems: T::Array[
|
59
|
+
sig { params(project_gems: T::Array[GemInfo]).void }
|
60
60
|
def remove_expired_annotations(project_gems)
|
61
61
|
say("Removing annotations for gems that have been removed... ", [:blue, :bold])
|
62
62
|
|
63
63
|
annotations = Pathname.glob(@outpath.join("*.rbi")).map { |f| f.basename(".*").to_s }
|
64
|
-
expired = annotations - project_gems
|
64
|
+
expired = annotations - project_gems.map(&:name)
|
65
65
|
|
66
66
|
if expired.empty?
|
67
67
|
say(" Nothing to do")
|
@@ -109,14 +109,14 @@ module Tapioca
|
|
109
109
|
index
|
110
110
|
end
|
111
111
|
|
112
|
-
sig { params(
|
113
|
-
def fetch_annotations(
|
112
|
+
sig { params(project_gems: T::Array[GemInfo]).returns(T::Array[String]) }
|
113
|
+
def fetch_annotations(project_gems)
|
114
114
|
say("Fetching gem annotations from central repository... ", [:blue, :bold])
|
115
|
-
fetchable_gems = T.let(Hash.new { |h, k| h[k] = [] }, T::Hash[
|
115
|
+
fetchable_gems = T.let(Hash.new { |h, k| h[k] = [] }, T::Hash[GemInfo, T::Array[String]])
|
116
116
|
|
117
|
-
|
117
|
+
project_gems.each_with_object(fetchable_gems) do |gem_info, hash|
|
118
118
|
@indexes.each do |uri, index|
|
119
|
-
T.must(hash[
|
119
|
+
T.must(hash[gem_info]) << uri if index.has_gem?(gem_info.name)
|
120
120
|
end
|
121
121
|
end
|
122
122
|
|
@@ -127,13 +127,16 @@ module Tapioca
|
|
127
127
|
end
|
128
128
|
|
129
129
|
say("\n")
|
130
|
-
fetched_gems = fetchable_gems.select { |
|
130
|
+
fetched_gems = fetchable_gems.select { |gem_info, repo_uris| fetch_annotation(repo_uris, gem_info) }
|
131
131
|
say("\nDone", :green)
|
132
|
-
fetched_gems.keys.sort
|
132
|
+
fetched_gems.keys.map(&:name).sort
|
133
133
|
end
|
134
134
|
|
135
|
-
sig { params(repo_uris: T::Array[String],
|
136
|
-
def fetch_annotation(repo_uris,
|
135
|
+
sig { params(repo_uris: T::Array[String], gem_info: GemInfo).void }
|
136
|
+
def fetch_annotation(repo_uris, gem_info)
|
137
|
+
gem_name = gem_info.name
|
138
|
+
gem_version = gem_info.version
|
139
|
+
|
137
140
|
contents = repo_uris.map do |repo_uri|
|
138
141
|
fetch_file(repo_uri, "#{CENTRAL_REPO_ANNOTATIONS_DIR}/#{gem_name}.rbi")
|
139
142
|
end
|
@@ -142,6 +145,7 @@ module Tapioca
|
|
142
145
|
return unless content
|
143
146
|
|
144
147
|
content = apply_typed_override(gem_name, content)
|
148
|
+
content = filter_versions(gem_version, content)
|
145
149
|
content = add_header(gem_name, content)
|
146
150
|
|
147
151
|
say("\n Fetched #{set_color(gem_name, :yellow, :bold)}", :green)
|
@@ -221,6 +225,14 @@ module Tapioca
|
|
221
225
|
Spoom::Sorbet::Sigils.update_sigil(content, strictness)
|
222
226
|
end
|
223
227
|
|
228
|
+
sig { params(gem_version: ::Gem::Version, content: String).returns(String) }
|
229
|
+
def filter_versions(gem_version, content)
|
230
|
+
rbi = RBI::Parser.parse_string(content)
|
231
|
+
rbi.filter_versions!(gem_version)
|
232
|
+
|
233
|
+
rbi.string
|
234
|
+
end
|
235
|
+
|
224
236
|
sig { params(gem_name: String, contents: T::Array[String]).returns(T.nilable(String)) }
|
225
237
|
def merge_files(gem_name, contents)
|
226
238
|
return if contents.empty?
|
@@ -190,7 +190,7 @@ module Tapioca
|
|
190
190
|
# Grab all Spawn methods
|
191
191
|
query_methods |= ActiveRecord::SpawnMethods.instance_methods(false)
|
192
192
|
# Remove the ones we know are private API
|
193
|
-
query_methods -= [:arel, :build_subquery, :construct_join_dependency, :extensions, :spawn]
|
193
|
+
query_methods -= [:all, :arel, :build_subquery, :construct_join_dependency, :extensions, :spawn]
|
194
194
|
# Remove "group" which needs a custom return type for GroupChains
|
195
195
|
query_methods -= [:group]
|
196
196
|
# Remove "where" which needs a custom return type for WhereChains
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# typed: strict
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module Tapioca
|
5
|
+
class GemInfo < T::Struct
|
6
|
+
const :name, String
|
7
|
+
const :version, ::Gem::Version
|
8
|
+
|
9
|
+
class << self
|
10
|
+
extend(T::Sig)
|
11
|
+
|
12
|
+
sig { params(spec: Bundler::LazySpecification).returns(GemInfo) }
|
13
|
+
def from_spec(spec)
|
14
|
+
new(name: spec.name, version: spec.version)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/tapioca/internal.rb
CHANGED
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.
|
4
|
+
version: 0.15.0
|
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: 2024-06-
|
14
|
+
date: 2024-06-27 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: bundler
|
@@ -228,6 +228,7 @@ files:
|
|
228
228
|
- lib/tapioca/gem/listeners/subconstants.rb
|
229
229
|
- lib/tapioca/gem/listeners/yard_doc.rb
|
230
230
|
- lib/tapioca/gem/pipeline.rb
|
231
|
+
- lib/tapioca/gem_info.rb
|
231
232
|
- lib/tapioca/gemfile.rb
|
232
233
|
- lib/tapioca/helpers/cli_helper.rb
|
233
234
|
- lib/tapioca/helpers/config_helper.rb
|