Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 29 additions & 3 deletions lib/rbs/collection/config/lockfile_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,17 @@ module RBS
module Collection
class Config
class LockfileGenerator
ALUMNI_STDLIBS = { "mutex_m" => ">= 0.3.0" }
ALUMNI_STDLIBS = {
"mutex_m" => ">= 0.3.0",
"abbrev" => nil,
"base64" => nil,
"bigdecimal" => nil,
"csv" => nil,
"minitest" => nil,
"net-smtp" => nil,
"nkf" => nil,
"observer" => nil,
}

class GemfileLockMismatchError < StandardError
def initialize(expected:, actual:)
Expand Down Expand Up @@ -161,12 +171,24 @@ def generate
return if lockfile.gems.key?(name)

case name
when 'bigdecimal-math'
# The `bigdecimal-math` is never released as a gem.
# Therefore, `assign_gem` should not be called.
RBS.logger.info {
from = from_gem || "rbs_collection.yaml"
"`#{name}` is included in the RBS dependencies of `#{from}`, but the type definition as a stdlib in rbs-gem is deprecated. Delete `#{name}` from the RBS dependencies of `#{from}`."
}
source = find_source(name: name)
if source&.is_a?(Sources::Stdlib)
lockfile.gems[name] = { name: name, version: "0", source: source }
end
return
when *ALUMNI_STDLIBS.keys
version = ALUMNI_STDLIBS.fetch(name)
if from_gem
# From `dependencies:` of a `manifest.yaml` of a gem
source = find_source(name: name) or raise
if source.is_a?(Sources::Stdlib)
if source.is_a?(Sources::Stdlib) && version
RBS.logger.warn {
"`#{name}` is included in the RBS dependencies of `#{from_gem}`, but the type definition as a stdlib in rbs-gem is deprecated. Add `#{name}` (#{version}) to the dependency of your Ruby program to use the gem-bundled type definition."
}
Expand All @@ -180,7 +202,11 @@ def generate
else
# From `gems:` of a `rbs_collection.yaml`
RBS.logger.warn {
"`#{name}` as a stdlib in rbs-gem is deprecated. Add `#{name}` (#{version}) to the dependency of your Ruby program to use the gem-bundled type definition."
if version
"`#{name}` as a stdlib in rbs-gem is deprecated. Add `#{name}` (#{version}) to the dependency of your Ruby program to use the gem-bundled type definition."
else
"`#{name}` as a stdlib in rbs-gem is deprecated. Delete `#{name}` from the RBS dependencies in your rbs_collection.yaml."
end
}
end
end
Expand Down
2 changes: 1 addition & 1 deletion sig/collection/config/lockfile_generator.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module RBS
class LockfileGenerator
# Name of stdlibs that was rbs-bundled stdlib but is now a gem.
#
ALUMNI_STDLIBS: Hash[String, String]
ALUMNI_STDLIBS: Hash[String, String?]

class GemfileLockMismatchError < StandardError
@expected: Pathname
Expand Down