diff --git a/bundler/lib/dependabot/bundler/language.rb b/bundler/lib/dependabot/bundler/language.rb index 5d3f71821f..ab2887358b 100644 --- a/bundler/lib/dependabot/bundler/language.rb +++ b/bundler/lib/dependabot/bundler/language.rb @@ -14,7 +14,10 @@ class Language < Dependabot::Ecosystem::VersionManager sig { params(raw_version: String, requirement: T.nilable(Requirement)).void } def initialize(raw_version, requirement = nil) - super(LANGUAGE, Version.new(raw_version), [], [], requirement) + super( + name: LANGUAGE, + version: Version.new(raw_version), + requirement: requirement) end end end diff --git a/bundler/lib/dependabot/bundler/package_manager.rb b/bundler/lib/dependabot/bundler/package_manager.rb index 3cc4f1a49f..8385d6e4db 100644 --- a/bundler/lib/dependabot/bundler/package_manager.rb +++ b/bundler/lib/dependabot/bundler/package_manager.rb @@ -31,11 +31,11 @@ class PackageManager < Dependabot::Ecosystem::VersionManager end def initialize(raw_version, requirement = nil) super( - PACKAGE_MANAGER, - Version.new(raw_version), - DEPRECATED_BUNDLER_VERSIONS, - SUPPORTED_BUNDLER_VERSIONS, - requirement, + name: PACKAGE_MANAGER, + version: Version.new(raw_version), + deprecated_versions: DEPRECATED_BUNDLER_VERSIONS, + supported_versions: SUPPORTED_BUNDLER_VERSIONS, + requirement: requirement, ) end end diff --git a/cargo/lib/dependabot/cargo/language.rb b/cargo/lib/dependabot/cargo/language.rb index 9262d86e99..330c7f66ca 100644 --- a/cargo/lib/dependabot/cargo/language.rb +++ b/cargo/lib/dependabot/cargo/language.rb @@ -15,8 +15,8 @@ class Language < Dependabot::Ecosystem::VersionManager sig { params(raw_version: String).void } def initialize(raw_version) super( - LANGUAGE, - Version.new(raw_version) + name: LANGUAGE, + version: Version.new(raw_version) ) end end diff --git a/cargo/lib/dependabot/cargo/package_manager.rb b/cargo/lib/dependabot/cargo/package_manager.rb index 3617b5afd0..8ad2307634 100644 --- a/cargo/lib/dependabot/cargo/package_manager.rb +++ b/cargo/lib/dependabot/cargo/package_manager.rb @@ -20,10 +20,10 @@ class PackageManager < Dependabot::Ecosystem::VersionManager sig { params(raw_version: String).void } def initialize(raw_version) super( - PACKAGE_MANAGER, - Version.new(raw_version), - DEPRECATED_CARGO_VERSIONS, - SUPPORTED_CARGO_VERSIONS + name: PACKAGE_MANAGER, + version: Version.new(raw_version), + deprecated_versions: DEPRECATED_CARGO_VERSIONS, + supported_versions: SUPPORTED_CARGO_VERSIONS ) end diff --git a/common/lib/dependabot/ecosystem.rb b/common/lib/dependabot/ecosystem.rb index b4d7c55129..8842382e50 100644 --- a/common/lib/dependabot/ecosystem.rb +++ b/common/lib/dependabot/ecosystem.rb @@ -17,30 +17,38 @@ class VersionManager abstract! # Initialize version information for a package manager or language. # @param name [String] the name of the package manager or language (e.g., "bundler", "ruby"). - # @param version [Dependabot::Version] the parsed current version. + # @param detected_version [Dependabot::Version] the detected version of the package manager or language. + # @param version [Dependabot::Version] the version dependabots run on. # @param deprecated_versions [Array] an array of deprecated versions. # @param supported_versions [Array] an array of supported versions. # @param requirement [Dependabot::Requirement] an array of requirements. # @example - # VersionManager.new("bundler", "2.1.4", nil) + # VersionManager.new( + # name: "bundler", + # version: Version.new("2.1.4"), + # requirement: nil + # ) sig do params( name: String, - version: Dependabot::Version, + detected_version: T.nilable(Dependabot::Version), + version: T.nilable(Dependabot::Version), deprecated_versions: T::Array[Dependabot::Version], supported_versions: T::Array[Dependabot::Version], requirement: T.nilable(Dependabot::Requirement) ).void end def initialize( - name, - version, - deprecated_versions = [], - supported_versions = [], - requirement = nil + name:, + detected_version: nil, + version: nil, + deprecated_versions: [], + supported_versions: [], + requirement: nil ) @name = T.let(name, String) - @version = T.let(version, Dependabot::Version) + @detected_version = T.let(detected_version || version, T.nilable(Dependabot::Version)) + @version = T.let(version, T.nilable(Dependabot::Version)) @deprecated_versions = T.let(deprecated_versions, T::Array[Dependabot::Version]) @supported_versions = T.let(supported_versions, T::Array[Dependabot::Version]) @requirement = T.let(requirement, T.nilable(Dependabot::Requirement)) @@ -52,10 +60,16 @@ def initialize( sig { returns(String) } attr_reader :name + # The current version of the package manager or language. + # @example + # detected_version #=> Dependabot::Version.new("2") + sig { returns(T.nilable(Dependabot::Version)) } + attr_reader :detected_version + # The current version of the package manager or language. # @example # version #=> Dependabot::Version.new("2.1.4") - sig { returns(Dependabot::Version) } + sig { returns(T.nilable(Dependabot::Version)) } attr_reader :version # Returns an array of deprecated versions of the package manager. @@ -82,10 +96,12 @@ def initialize( # deprecated? #=> true sig { returns(T::Boolean) } def deprecated? + return false unless detected_version + # If the version is unsupported, the unsupported error is getting raised separately. return false if unsupported? - deprecated_versions.include?(version) + deprecated_versions.include?(detected_version) end # Checks if the current version is unsupported. @@ -93,16 +109,20 @@ def deprecated? # unsupported? #=> false sig { returns(T::Boolean) } def unsupported? + return false unless detected_version + return false if supported_versions.empty? # Check if the version is not supported - supported_versions.all? { |supported| supported > version } + supported_versions.all? { |supported| supported > detected_version } end # Raises an error if the current package manager or language version is unsupported. # If the version is unsupported, it raises a ToolVersionNotSupported error. sig { void } def raise_if_unsupported! + return unless detected_version + return unless unsupported? # Example: v2.*, v3.* @@ -110,7 +130,7 @@ def raise_if_unsupported! raise ToolVersionNotSupported.new( name, - version.to_s, + detected_version.to_s, supported_versions_message ) end diff --git a/common/lib/dependabot/notices.rb b/common/lib/dependabot/notices.rb index 35e2f3a0ac..cfecdbefee 100644 --- a/common/lib/dependabot/notices.rb +++ b/common/lib/dependabot/notices.rb @@ -120,7 +120,7 @@ def self.generate_deprecation_notice(version_manager, version_manager_type = :pa ) notice_type = "#{version_manager.name}_deprecated_warn" title = version_manager_type == :language ? "Language deprecation notice" : "Package manager deprecation notice" - description = "Dependabot will stop supporting `#{version_manager.name} v#{version_manager.version}`!" + description = "Dependabot will stop supporting `#{version_manager.name} v#{version_manager.detected_version}`!" ## Add the supported versions to the description description += "\n\n#{supported_versions_description}\n" unless supported_versions_description.empty? diff --git a/common/spec/dependabot/ecosystem_spec.rb b/common/spec/dependabot/ecosystem_spec.rb index df4f9e1156..224ff0377a 100644 --- a/common/spec/dependabot/ecosystem_spec.rb +++ b/common/spec/dependabot/ecosystem_spec.rb @@ -13,35 +13,44 @@ let(:deprecated_versions) { [Dependabot::Version.new("1")] } let(:requirement) { TestRequirement.new(">= 1.0") } + let(:package_manager_detected_version) { "1.0.0" } let(:package_manager_raw_version) { "1.0.0" } + let(:language_detected_version) { "3.0.0" } let(:language_raw_version) { "3.0.0" } let(:package_manager) do Class.new(Dependabot::Ecosystem::VersionManager) do - def initialize(raw_version, deprecated_versions, supported_versions, requirement) + def initialize(detected_version, raw_version, deprecated_versions, supported_versions, requirement) super( - "bundler", # name - Dependabot::Version.new(raw_version), # version - deprecated_versions, # deprecated_versions - supported_versions, # supported_versions - requirement # requirement + name: "bundler", # name + detected_version: Dependabot::Version.new(detected_version), # version + version: Dependabot::Version.new(raw_version), # version + deprecated_versions: deprecated_versions, # deprecated_versions + supported_versions: supported_versions, # supported_versions + requirement: requirement # requirement ) end - end.new(package_manager_raw_version, deprecated_versions, supported_versions, requirement) + end.new( + package_manager_detected_version, + package_manager_raw_version, + deprecated_versions, + supported_versions, + requirement + ) end let(:language) do Class.new(Dependabot::Ecosystem::VersionManager) do - def initialize(raw_version) + def initialize(detected_version, raw_version) super( - "ruby", # name - Dependabot::Version.new(raw_version), # version - [], # deprecated_versions - [], # supported_versions - nil # requirement + name: "ruby", # name + detected_version: Dependabot::Version.new(detected_version), # version + version: Dependabot::Version.new(raw_version), # version + deprecated_versions: [], # deprecated_versions + supported_versions: [], # supported_versions ) end - end.new(language_raw_version) + end.new(language_detected_version, language_raw_version) end describe "#initialize" do @@ -56,6 +65,7 @@ def initialize(raw_version) describe "#deprecated?" do context "when the package manager version is deprecated" do + let(:package_manager_detected_version) { "1" } let(:package_manager_raw_version) { "1" } it "returns true" do @@ -65,6 +75,7 @@ def initialize(raw_version) end context "when the package manager version is not deprecated" do + let(:package_manager_detected_version) { "2.0.0" } let(:package_manager_raw_version) { "2.0.0" } it "returns false" do @@ -76,6 +87,7 @@ def initialize(raw_version) describe "#unsupported?" do context "when the package manager version is unsupported" do + let(:package_manager_detected_version) { "0.8.0" } let(:package_manager_raw_version) { "0.8.0" } it "returns true" do @@ -85,6 +97,7 @@ def initialize(raw_version) end context "when the package manager version is supported" do + let(:package_manager_detected_version) { "2.0.0" } let(:package_manager_raw_version) { "2.0.0" } it "returns false" do @@ -96,6 +109,7 @@ def initialize(raw_version) describe "#raise_if_unsupported!" do context "when the package manager version is unsupported" do + let(:package_manager_detected_version) { "0.8.0" } let(:package_manager_raw_version) { "0.8.0" } it "raises a ToolVersionNotSupported error" do @@ -105,6 +119,7 @@ def initialize(raw_version) end context "when the package manager version is supported" do + let(:package_manager_detected_version) { "2.0.0" } let(:package_manager_raw_version) { "2.0.0" } it "does not raise an error" do diff --git a/common/spec/dependabot/file_parsers/base_spec.rb b/common/spec/dependabot/file_parsers/base_spec.rb index 76105e5427..460269fa84 100644 --- a/common/spec/dependabot/file_parsers/base_spec.rb +++ b/common/spec/dependabot/file_parsers/base_spec.rb @@ -50,10 +50,10 @@ def initialize raw_version = "1.0.0" super( - "bundler", # name - Dependabot::Version.new(raw_version), # version - [Dependabot::Version.new("1.0.0")], # deprecated_versions - [Dependabot::Version.new("1.1.0"), Dependabot::Version.new("2.0.0")] # supported_versions + name: "bundler", # name + version: Dependabot::Version.new(raw_version), # version + deprecated_versions: [Dependabot::Version.new("1.0.0")], # deprecated_versions + supported_versions: [Dependabot::Version.new("1.1.0"), Dependabot::Version.new("2.0.0")] # supported_versions ) end diff --git a/common/spec/dependabot/notices_spec.rb b/common/spec/dependabot/notices_spec.rb index 644479adf9..817a4c1873 100644 --- a/common/spec/dependabot/notices_spec.rb +++ b/common/spec/dependabot/notices_spec.rb @@ -9,14 +9,15 @@ # A stub package manager for testing purposes. class StubVersionManager < Dependabot::Ecosystem::VersionManager - def initialize(name:, version:, deprecated_versions: [], supported_versions: [], + def initialize(name:, detected_version:, raw_version:, deprecated_versions: [], supported_versions: [], support_later_versions: false) @support_later_versions = support_later_versions super( - name, - Dependabot::Version.new(version), - deprecated_versions, - supported_versions + name: name, + detected_version: Dependabot::Version.new(detected_version), + version: Dependabot::Version.new(raw_version), + deprecated_versions: deprecated_versions, + supported_versions: supported_versions ) end @@ -126,7 +127,8 @@ def support_later_versions? let(:package_manager) do StubVersionManager.new( name: "bundler", - version: Dependabot::Version.new("1"), + detected_version: Dependabot::Version.new("1"), + raw_version: Dependabot::Version.new("1"), deprecated_versions: [Dependabot::Version.new("1")], supported_versions: [Dependabot::Version.new("2"), Dependabot::Version.new("3")] ) @@ -155,7 +157,8 @@ def support_later_versions? let(:language_manager) do StubVersionManager.new( name: "python", - version: Dependabot::Version.new("3.8"), + detected_version: Dependabot::Version.new("3.8"), + raw_version: Dependabot::Version.new("3.8"), deprecated_versions: [Dependabot::Version.new("3.8")], supported_versions: [Dependabot::Version.new("3.9")] ) diff --git a/common/spec/dependabot/version_manager_spec.rb b/common/spec/dependabot/version_manager_spec.rb index d8f8d53375..d12d2ede3a 100644 --- a/common/spec/dependabot/version_manager_spec.rb +++ b/common/spec/dependabot/version_manager_spec.rb @@ -8,12 +8,14 @@ let(:concrete_class) do Class.new(Dependabot::Ecosystem::VersionManager) do def initialize + detected_version = "1.0.0" raw_version = "1.0.0" super( - "bundler", # name - Dependabot::Version.new(raw_version), # version - [Dependabot::Version.new("1")], # deprecated_versions - [Dependabot::Version.new("1"), Dependabot::Version.new("2")] # supported_versions + name: "bundler", # name + detected_version: Dependabot::Version.new(detected_version), # version + version: Dependabot::Version.new(raw_version), # version + deprecated_versions: [Dependabot::Version.new("1")], # deprecated_versions + supported_versions: [Dependabot::Version.new("1"), Dependabot::Version.new("2")] # supported_versions ) end @@ -26,10 +28,12 @@ def support_later_versions? let(:default_concrete_class) do Class.new(Dependabot::Ecosystem::VersionManager) do def initialize + detected_version = "1.0.0" raw_version = "1.0.0" super( - "bundler", # name - Dependabot::Version.new(raw_version) + name: "bundler", # name + detected_version: Dependabot::Version.new(detected_version), + version: Dependabot::Version.new(raw_version) ) end end @@ -90,10 +94,12 @@ def initialize end context "when version is unsupported" do - let(:version) { Dependabot::Version.new("0.9.0") } + let(:detected_version) { Dependabot::Version.new("0.9") } + let(:raw_version) { Dependabot::Version.new("0.9.0") } it "returns false as unsupported takes precedence" do - package_manager.instance_variable_set(:@version, version) + package_manager.instance_variable_set(:@detected_version, detected_version) + package_manager.instance_variable_set(:@version, raw_version) package_manager.instance_variable_set(:@supported_versions, [Dependabot::Version.new("1"), Dependabot::Version.new("2")]) expect(package_manager.deprecated?).to be false @@ -103,10 +109,12 @@ def initialize describe "#unsupported?" do context "when version is unsupported" do - let(:version) { Dependabot::Version.new("0.9.0") } + let(:detected_version) { Dependabot::Version.new("0.9") } + let(:raw_version) { Dependabot::Version.new("0.9.0") } it "returns true" do - package_manager.instance_variable_set(:@version, version) + package_manager.instance_variable_set(:@detected_version, detected_version) + package_manager.instance_variable_set(:@version, raw_version) package_manager.instance_variable_set(:@supported_versions, [Dependabot::Version.new("1"), Dependabot::Version.new("2")]) expect(package_manager.unsupported?).to be true diff --git a/composer/lib/dependabot/composer/language.rb b/composer/lib/dependabot/composer/language.rb index 17696fe07a..e91c2812ff 100644 --- a/composer/lib/dependabot/composer/language.rb +++ b/composer/lib/dependabot/composer/language.rb @@ -16,11 +16,9 @@ class Language < Dependabot::Ecosystem::VersionManager sig { params(raw_version: String, requirement: T.nilable(Requirement)).void } def initialize(raw_version, requirement: nil) super( - NAME, - Version.new(raw_version), - [], - [], - requirement + name: NAME, + version: Version.new(raw_version), + requirement: requirement ) end diff --git a/composer/lib/dependabot/composer/package_manager.rb b/composer/lib/dependabot/composer/package_manager.rb index 0339ff701b..9a7ed230bf 100644 --- a/composer/lib/dependabot/composer/package_manager.rb +++ b/composer/lib/dependabot/composer/package_manager.rb @@ -36,10 +36,10 @@ class PackageManager < Dependabot::Ecosystem::VersionManager sig { params(raw_version: String).void } def initialize(raw_version) super( - NAME, - Version.new(raw_version), - DEPRECATED_COMPOSER_VERSIONS, - SUPPORTED_COMPOSER_VERSIONS, + name: NAME, + version: Version.new(raw_version), + deprecated_versions: DEPRECATED_COMPOSER_VERSIONS, + supported_versions: SUPPORTED_COMPOSER_VERSIONS, ) end end diff --git a/devcontainers/lib/dependabot/devcontainers/language.rb b/devcontainers/lib/dependabot/devcontainers/language.rb index 0d75a1838b..4be268d01a 100644 --- a/devcontainers/lib/dependabot/devcontainers/language.rb +++ b/devcontainers/lib/dependabot/devcontainers/language.rb @@ -14,7 +14,9 @@ class Language < Dependabot::Ecosystem::VersionManager sig { params(raw_version: String).void } def initialize(raw_version) - super(LANGUAGE, Version.new(raw_version)) + super( + name: LANGUAGE, + version: Version.new(raw_version)) end end end diff --git a/devcontainers/lib/dependabot/devcontainers/package_manager.rb b/devcontainers/lib/dependabot/devcontainers/package_manager.rb index 60b8557c5c..a42ef5825a 100644 --- a/devcontainers/lib/dependabot/devcontainers/package_manager.rb +++ b/devcontainers/lib/dependabot/devcontainers/package_manager.rb @@ -20,10 +20,10 @@ class PackageManager < Dependabot::Ecosystem::VersionManager sig { params(raw_version: String).void } def initialize(raw_version) super( - PACKAGE_MANAGER, - Version.new(raw_version), - DEPRECATED_DEVCONTAINER_VERSIONS, - SUPPORTED_DEVCONTAINER_VERSIONS + name: PACKAGE_MANAGER, + version: Version.new(raw_version), + deprecated_versions: DEPRECATED_DEVCONTAINER_VERSIONS, + supported_versions: SUPPORTED_DEVCONTAINER_VERSIONS ) end diff --git a/elm/lib/dependabot/elm/language.rb b/elm/lib/dependabot/elm/language.rb index 56e23daa3f..7a36cb1243 100644 --- a/elm/lib/dependabot/elm/language.rb +++ b/elm/lib/dependabot/elm/language.rb @@ -14,7 +14,11 @@ class Language < Dependabot::Ecosystem::VersionManager sig { params(raw_version: String, requirement: T.nilable(Requirement)).void } def initialize(raw_version, requirement = nil) - super(LANGUAGE, Version.new(raw_version), [], [], requirement) + super( + name: LANGUAGE, + version: Version.new(raw_version), + requirement: requirement + ) end sig { returns(T::Boolean) } diff --git a/elm/lib/dependabot/elm/package_manager.rb b/elm/lib/dependabot/elm/package_manager.rb index 784c0523dd..6fbafd8e31 100644 --- a/elm/lib/dependabot/elm/package_manager.rb +++ b/elm/lib/dependabot/elm/package_manager.rb @@ -34,11 +34,11 @@ class PackageManager < Dependabot::Ecosystem::VersionManager end def initialize(raw_version, requirement = nil) super( - PACKAGE_MANAGER, - Version.new(raw_version), - DEPRECATED_ELM_VERSIONS, - SUPPORTED_ELM_VERSIONS, - requirement, + name: PACKAGE_MANAGER, + version: Version.new(raw_version), + deprecated_versions: DEPRECATED_ELM_VERSIONS, + supported_versions: SUPPORTED_ELM_VERSIONS, + requirement: requirement, ) end diff --git a/git_submodules/lib/dependabot/git_submodules/package_manager.rb b/git_submodules/lib/dependabot/git_submodules/package_manager.rb index 7eb2a167cd..86432c0c2f 100644 --- a/git_submodules/lib/dependabot/git_submodules/package_manager.rb +++ b/git_submodules/lib/dependabot/git_submodules/package_manager.rb @@ -20,10 +20,10 @@ class PackageManager < Dependabot::Ecosystem::VersionManager sig { params(raw_version: String).void } def initialize(raw_version) super( - PACKAGE_MANAGER, - Version.new(raw_version), - DEPRECATED_GIT_VERSIONS, - SUPPORTED_GIT_VERSIONS + name: PACKAGE_MANAGER, + version: Version.new(raw_version), + deprecated_versions: DEPRECATED_GIT_VERSIONS, + supported_versions: SUPPORTED_GIT_VERSIONS ) end diff --git a/go_modules/lib/dependabot/go_modules/language.rb b/go_modules/lib/dependabot/go_modules/language.rb index 46c92f60a7..fc5be09701 100644 --- a/go_modules/lib/dependabot/go_modules/language.rb +++ b/go_modules/lib/dependabot/go_modules/language.rb @@ -16,8 +16,8 @@ class Language < Dependabot::Ecosystem::VersionManager sig { params(raw_version: String).void } def initialize(raw_version) super( - LANGUAGE, - Version.new(raw_version) + name: LANGUAGE, + version: Version.new(raw_version) ) end end diff --git a/go_modules/lib/dependabot/go_modules/package_manager.rb b/go_modules/lib/dependabot/go_modules/package_manager.rb index 201bd1cdab..291106c0c7 100644 --- a/go_modules/lib/dependabot/go_modules/package_manager.rb +++ b/go_modules/lib/dependabot/go_modules/package_manager.rb @@ -21,10 +21,10 @@ class PackageManager < Dependabot::Ecosystem::VersionManager sig { params(raw_version: String).void } def initialize(raw_version) super( - PACKAGE_MANAGER, - Version.new(raw_version), - DEPRECATED_GO_VERSIONS, - SUPPORTED_GO_VERSIONS + name: PACKAGE_MANAGER, + version: Version.new(raw_version), + deprecated_versions: DEPRECATED_GO_VERSIONS, + supported_versions: SUPPORTED_GO_VERSIONS ) end diff --git a/gradle/lib/dependabot/gradle/language.rb b/gradle/lib/dependabot/gradle/language.rb index da35e0d758..d8c66ce51f 100644 --- a/gradle/lib/dependabot/gradle/language.rb +++ b/gradle/lib/dependabot/gradle/language.rb @@ -15,8 +15,8 @@ class Language < Dependabot::Ecosystem::VersionManager sig { params(raw_version: String).void } def initialize(raw_version) super( - LANGUAGE, - Version.new(raw_version) + name: LANGUAGE, + version: Version.new(raw_version) ) end end diff --git a/gradle/lib/dependabot/gradle/package_manager.rb b/gradle/lib/dependabot/gradle/package_manager.rb index 41960de056..551862013c 100644 --- a/gradle/lib/dependabot/gradle/package_manager.rb +++ b/gradle/lib/dependabot/gradle/package_manager.rb @@ -20,10 +20,10 @@ class PackageManager < Dependabot::Ecosystem::VersionManager sig { params(raw_version: String).void } def initialize(raw_version) super( - PACKAGE_MANAGER, - Version.new(raw_version), - DEPRECATED_GRADLE_VERSIONS, - SUPPORTED_GRADLE_VERSIONS + name: PACKAGE_MANAGER, + version: Version.new(raw_version), + deprecated_versions: DEPRECATED_GRADLE_VERSIONS, + supported_versions: SUPPORTED_GRADLE_VERSIONS ) end diff --git a/hex/lib/dependabot/hex/language.rb b/hex/lib/dependabot/hex/language.rb index b315e6ab61..7e905dcb85 100644 --- a/hex/lib/dependabot/hex/language.rb +++ b/hex/lib/dependabot/hex/language.rb @@ -14,7 +14,10 @@ class Language < Dependabot::Ecosystem::VersionManager sig { params(raw_version: String).void } def initialize(raw_version) - super(LANGUAGE, Version.new(raw_version)) + super( + name: LANGUAGE, + version: Version.new(raw_version) + ) end end end diff --git a/hex/lib/dependabot/hex/package_manager.rb b/hex/lib/dependabot/hex/package_manager.rb index f973be7d12..9a9d60ac04 100644 --- a/hex/lib/dependabot/hex/package_manager.rb +++ b/hex/lib/dependabot/hex/package_manager.rb @@ -20,10 +20,10 @@ class PackageManager < Dependabot::Ecosystem::VersionManager sig { params(raw_version: String).void } def initialize(raw_version) super( - PACKAGE_MANAGER, - Version.new(raw_version), - DEPRECATED_HEX_VERSIONS, - SUPPORTED_HEX_VERSIONS + name: PACKAGE_MANAGER, + version: Version.new(raw_version), + deprecated_versions: DEPRECATED_HEX_VERSIONS, + supported_versions: SUPPORTED_HEX_VERSIONS ) end diff --git a/maven/lib/dependabot/maven/language.rb b/maven/lib/dependabot/maven/language.rb index 3978ff1b76..9643ef1b2a 100644 --- a/maven/lib/dependabot/maven/language.rb +++ b/maven/lib/dependabot/maven/language.rb @@ -16,8 +16,8 @@ class Language < Dependabot::Ecosystem::VersionManager sig { params(raw_version: String).void } def initialize(raw_version) super( - LANGUAGE, - Version.new(raw_version) + name: LANGUAGE, + version: Version.new(raw_version) ) end end diff --git a/maven/lib/dependabot/maven/package_manager.rb b/maven/lib/dependabot/maven/package_manager.rb index 6a79199937..47f81f1058 100644 --- a/maven/lib/dependabot/maven/package_manager.rb +++ b/maven/lib/dependabot/maven/package_manager.rb @@ -28,11 +28,11 @@ class PackageManager < Dependabot::Ecosystem::VersionManager end def initialize(raw_version, requirement = nil) super( - PACKAGE_MANAGER, - Version.new(raw_version), - DEPRECATED_MAVEN_VERSIONS, - SUPPORTED_MAVEN_VERSIONS, - requirement, + name: PACKAGE_MANAGER, + version: Version.new(raw_version), + deprecated_versions: DEPRECATED_MAVEN_VERSIONS, + supported_versions: SUPPORTED_MAVEN_VERSIONS, + requirement: requirement, ) end diff --git a/npm_and_yarn/lib/dependabot/npm_and_yarn/package_manager.rb b/npm_and_yarn/lib/dependabot/npm_and_yarn/package_manager.rb index 9984583a1d..98f5555ea1 100644 --- a/npm_and_yarn/lib/dependabot/npm_and_yarn/package_manager.rb +++ b/npm_and_yarn/lib/dependabot/npm_and_yarn/package_manager.rb @@ -78,11 +78,11 @@ class NpmPackageManager < Ecosystem::VersionManager end def initialize(raw_version, requirement: nil) super( - NAME, - Version.new(raw_version), - DEPRECATED_VERSIONS, - SUPPORTED_VERSIONS, - requirement + name: NAME, + version: Version.new(raw_version), + deprecated_versions: DEPRECATED_VERSIONS, + supported_versions: SUPPORTED_VERSIONS, + requirement: requirement ) end @@ -129,11 +129,11 @@ class YarnPackageManager < Ecosystem::VersionManager end def initialize(raw_version, requirement: nil) super( - NAME, - Version.new(raw_version), - DEPRECATED_VERSIONS, - SUPPORTED_VERSIONS, - requirement + name: NAME, + version: Version.new(raw_version), + deprecated_versions: DEPRECATED_VERSIONS, + supported_versions: SUPPORTED_VERSIONS, + requirement: requirement ) end @@ -174,11 +174,11 @@ class PNPMPackageManager < Ecosystem::VersionManager end def initialize(raw_version, requirement: nil) super( - NAME, - Version.new(raw_version), - DEPRECATED_VERSIONS, - SUPPORTED_VERSIONS, - requirement + name: NAME, + version: Version.new(raw_version), + deprecated_versions: DEPRECATED_VERSIONS, + supported_versions: SUPPORTED_VERSIONS, + requirement: requirement ) end @@ -290,11 +290,11 @@ class Language < Ecosystem::VersionManager end def initialize(raw_version, requirement: nil) super( - NAME, - Version.new(raw_version), - DEPRECATED_VERSIONS, - SUPPORTED_VERSIONS, - requirement + name: NAME, + version: Version.new(raw_version), + deprecated_versions: DEPRECATED_VERSIONS, + supported_versions: SUPPORTED_VERSIONS, + requirement: requirement ) end diff --git a/nuget/lib/dependabot/nuget/language.rb b/nuget/lib/dependabot/nuget/language.rb index 2fe6841d83..7d602641de 100644 --- a/nuget/lib/dependabot/nuget/language.rb +++ b/nuget/lib/dependabot/nuget/language.rb @@ -12,7 +12,11 @@ class Language < Dependabot::Ecosystem::VersionManager sig { params(language: String, raw_version: String, requirement: T.nilable(Requirement)).void } def initialize(language, raw_version, requirement = nil) - super(language, Version.new(raw_version), [], [], requirement) + super( + name: language, + version: Version.new(raw_version), + requirement: requirement, + ) end end @@ -28,7 +32,10 @@ class CSharpLanguage < Dependabot::Ecosystem::VersionManager sig { params(language: String, requirement: T.nilable(Requirement)).void } def initialize(language, requirement = nil) - super(language, Version.new(nil), [], [], requirement) + super( + name: language, + requirement: requirement, + ) end end @@ -44,7 +51,10 @@ class VBLanguage < Dependabot::Ecosystem::VersionManager sig { params(language: String, requirement: T.nilable(Requirement)).void } def initialize(language, requirement = nil) - super(language, Version.new(nil), [], [], requirement) + super( + name: language, + requirement: requirement, + ) end end @@ -60,7 +70,10 @@ class FSharpLanguage < Dependabot::Ecosystem::VersionManager sig { params(language: String, requirement: T.nilable(Requirement)).void } def initialize(language, requirement = nil) - super(language, Version.new(nil), [], [], requirement) + super( + name: language, + requirement: requirement, + ) end end @@ -75,7 +88,10 @@ class DotNet < Dependabot::Ecosystem::VersionManager sig { params(language: String, requirement: T.nilable(Requirement)).void } def initialize(language, requirement = nil) - super(language, Version.new(nil), [], [], requirement) + super( + name: language, + requirement: requirement, + ) end end end diff --git a/nuget/lib/dependabot/nuget/package_manager.rb b/nuget/lib/dependabot/nuget/package_manager.rb index 1966e1d96c..546c3b4a79 100644 --- a/nuget/lib/dependabot/nuget/package_manager.rb +++ b/nuget/lib/dependabot/nuget/package_manager.rb @@ -30,10 +30,10 @@ class NugetPackageManager < Dependabot::Ecosystem::VersionManager end def initialize(raw_version) super( - NAME, - Version.new(raw_version), - SUPPORTED_VERSIONS, - DEPRECATED_VERSIONS + name: NAME, + version: Version.new(raw_version), + deprecated_versions: DEPRECATED_VERSIONS, + supported_versions: SUPPORTED_VERSIONS ) end diff --git a/pub/lib/dependabot/pub/language.rb b/pub/lib/dependabot/pub/language.rb index a62a03826e..34d89d37f2 100644 --- a/pub/lib/dependabot/pub/language.rb +++ b/pub/lib/dependabot/pub/language.rb @@ -14,7 +14,10 @@ class Language < Dependabot::Ecosystem::VersionManager sig { params(raw_version: String).void } def initialize(raw_version) - super(LANGUAGE, Version.new(raw_version)) + super( + name: LANGUAGE, + version: Version.new(raw_version) + ) end end end diff --git a/pub/lib/dependabot/pub/package_manager.rb b/pub/lib/dependabot/pub/package_manager.rb index 7488d26634..d66bea04ab 100644 --- a/pub/lib/dependabot/pub/package_manager.rb +++ b/pub/lib/dependabot/pub/package_manager.rb @@ -31,10 +31,10 @@ class PubPackageManager < Dependabot::Ecosystem::VersionManager end def initialize(raw_version) super( - NAME, - Version.new(raw_version), - SUPPORTED_VERSIONS, - DEPRECATED_VERSIONS + name: NAME, + version: Version.new(raw_version), + deprecated_versions: DEPRECATED_VERSIONS, + supported_versions: SUPPORTED_VERSIONS ) end diff --git a/python/lib/dependabot/python/language.rb b/python/lib/dependabot/python/language.rb index 7fe6294b0e..66317ba831 100644 --- a/python/lib/dependabot/python/language.rb +++ b/python/lib/dependabot/python/language.rb @@ -32,7 +32,13 @@ class Language < Dependabot::Ecosystem::VersionManager sig { params(raw_version: String, requirement: T.nilable(Requirement)).void } def initialize(raw_version, requirement = nil) - super(LANGUAGE, Version.new(raw_version), DEPRECATED_VERSIONS, SUPPORTED_VERSIONS, requirement) + super( + name: LANGUAGE, + version: Version.new(raw_version), + deprecated_versions: DEPRECATED_VERSIONS, + supported_versions: SUPPORTED_VERSIONS, + requirement: requirement, + ) end sig { override.returns(T::Boolean) } diff --git a/python/lib/dependabot/python/package_manager.rb b/python/lib/dependabot/python/package_manager.rb index effe79d873..724e3a1ad4 100644 --- a/python/lib/dependabot/python/package_manager.rb +++ b/python/lib/dependabot/python/package_manager.rb @@ -31,11 +31,11 @@ class PipPackageManager < Dependabot::Ecosystem::VersionManager end def initialize(raw_version, requirement = nil) super( - NAME, - Version.new(raw_version), - SUPPORTED_VERSIONS, - DEPRECATED_VERSIONS, - requirement, + name: NAME, + version: Version.new(raw_version), + deprecated_versions: DEPRECATED_VERSIONS, + supported_versions: SUPPORTED_VERSIONS, + requirement: requirement, ) end @@ -69,11 +69,11 @@ class PoetryPackageManager < Dependabot::Ecosystem::VersionManager end def initialize(raw_version, requirement = nil) super( - NAME, - Version.new(raw_version), - SUPPORTED_VERSIONS, - DEPRECATED_VERSIONS, - requirement, + name: NAME, + version: Version.new(raw_version), + deprecated_versions: DEPRECATED_VERSIONS, + supported_versions: SUPPORTED_VERSIONS, + requirement: requirement, ) end @@ -106,11 +106,11 @@ class PipCompilePackageManager < Dependabot::Ecosystem::VersionManager end def initialize(raw_version, requirement = nil) super( - NAME, - Version.new(raw_version), - SUPPORTED_VERSIONS, - DEPRECATED_VERSIONS, - requirement, + name: NAME, + version: Version.new(raw_version), + deprecated_versions: DEPRECATED_VERSIONS, + supported_versions: SUPPORTED_VERSIONS, + requirement: requirement, ) end @@ -145,11 +145,11 @@ class PipenvPackageManager < Dependabot::Ecosystem::VersionManager end def initialize(raw_version, requirement = nil) super( - NAME, - Version.new(raw_version), - SUPPORTED_VERSIONS, - DEPRECATED_VERSIONS, - requirement, + name: NAME, + version: Version.new(raw_version), + deprecated_versions: DEPRECATED_VERSIONS, + supported_versions: SUPPORTED_VERSIONS, + requirement: requirement, ) end diff --git a/silent/lib/dependabot/silent/package_manager.rb b/silent/lib/dependabot/silent/package_manager.rb index c26e364645..542e301d0c 100644 --- a/silent/lib/dependabot/silent/package_manager.rb +++ b/silent/lib/dependabot/silent/package_manager.rb @@ -19,10 +19,10 @@ class PackageManager < Ecosystem::VersionManager sig { params(version: T.any(String, Dependabot::Version)).void } def initialize(version) super( - PACKAGE_MANAGER, - Version.new(version), - DEPRECATED_SILENT_VERSIONS, - SUPPORTED_SILENT_VERSIONS, + name: PACKAGE_MANAGER, + version: Version.new(version), + deprecated_versions: DEPRECATED_SILENT_VERSIONS, + supported_versions: SUPPORTED_SILENT_VERSIONS, ) end end diff --git a/swift/lib/dependabot/swift/language.rb b/swift/lib/dependabot/swift/language.rb index 9bedfc7386..976fc4095e 100644 --- a/swift/lib/dependabot/swift/language.rb +++ b/swift/lib/dependabot/swift/language.rb @@ -15,8 +15,8 @@ class Language < Dependabot::Ecosystem::VersionManager sig { params(raw_version: String).void } def initialize(raw_version) super( - LANGUAGE, - Version.new(raw_version) + name: LANGUAGE, + version: Version.new(raw_version) ) end end diff --git a/swift/lib/dependabot/swift/package_manager.rb b/swift/lib/dependabot/swift/package_manager.rb index 40bdb93fd4..c2e6e0cfcc 100644 --- a/swift/lib/dependabot/swift/package_manager.rb +++ b/swift/lib/dependabot/swift/package_manager.rb @@ -20,10 +20,10 @@ class PackageManager < Dependabot::Ecosystem::VersionManager sig { params(raw_version: String).void } def initialize(raw_version) super( - PACKAGE_MANAGER, - Version.new(raw_version), - DEPRECATED_SWIFT_VERSIONS, - SUPPORTED_SWIFT_VERSIONS + name: PACKAGE_MANAGER, + version: Version.new(raw_version), + deprecated_versions: DEPRECATED_SWIFT_VERSIONS, + supported_versions: SUPPORTED_SWIFT_VERSIONS ) end diff --git a/terraform/lib/dependabot/terraform/package_manager.rb b/terraform/lib/dependabot/terraform/package_manager.rb index cbfe8ef09b..987811a3f8 100644 --- a/terraform/lib/dependabot/terraform/package_manager.rb +++ b/terraform/lib/dependabot/terraform/package_manager.rb @@ -20,10 +20,10 @@ class PackageManager < Dependabot::Ecosystem::VersionManager sig { params(raw_version: String).void } def initialize(raw_version) super( - PACKAGE_MANAGER, - Version.new(raw_version), - DEPRECATED_TERRAFORM_VERSIONS, - SUPPORTED_TERRAFORM_VERSIONS + name: PACKAGE_MANAGER, + version: Version.new(raw_version), + deprecated_versions: DEPRECATED_TERRAFORM_VERSIONS, + supported_versions: SUPPORTED_TERRAFORM_VERSIONS ) end diff --git a/updater/lib/dependabot/api_client.rb b/updater/lib/dependabot/api_client.rb index c0ebe9be9a..7896b00d2f 100644 --- a/updater/lib/dependabot/api_client.rb +++ b/updater/lib/dependabot/api_client.rb @@ -330,10 +330,13 @@ def record_ecosystem_meta(ecosystem) def version_manager_json(version_manager) return nil unless version_manager + raw_version = version_manager.version&.to_semver.to_s + version = version_manager.version&.to_semver.to_s + { name: version_manager.name, - raw_version: version_manager.version.to_semver.to_s, - version: version_manager.version.to_s, + raw_version: raw_version.empty? ? "N/A" : raw_version, + version: version.empty? ? "N/A" : version, requirement: version_manager_requirement_json(version_manager) } end diff --git a/updater/spec/dependabot/notices_helpers_spec.rb b/updater/spec/dependabot/notices_helpers_spec.rb index 35898414e2..05d85e251f 100644 --- a/updater/spec/dependabot/notices_helpers_spec.rb +++ b/updater/spec/dependabot/notices_helpers_spec.rb @@ -25,12 +25,14 @@ def initialize let(:package_manager) do Class.new(Dependabot::Ecosystem::VersionManager) do def initialize + detected_version = "1" raw_version = "1" super( - "bundler", # name - Dependabot::Version.new(raw_version), # version - [Dependabot::Version.new("1")], # deprecated_versions - [Dependabot::Version.new("2"), Dependabot::Version.new("3")] # supported_versions + name: "bundler", # name + detected_version: Dependabot::Version.new(detected_version), # detected_version + version: Dependabot::Version.new(raw_version), # version + deprecated_versions: [Dependabot::Version.new("1")], # deprecated_versions + supported_versions: [Dependabot::Version.new("2"), Dependabot::Version.new("3")] # supported_versions ) end end.new @@ -81,12 +83,14 @@ def initialize let(:package_manager) do Class.new(Dependabot::Ecosystem::VersionManager) do def initialize + detected_version = "2" raw_version = "2" super( - "bundler", # name - Dependabot::Version.new(raw_version), # version - [Dependabot::Version.new("1")], # deprecated_versions - [Dependabot::Version.new("2"), Dependabot::Version.new("3")] # supported_versions + name: "bundler", # name + detected_version: Dependabot::Version.new(detected_version), + version: Dependabot::Version.new(raw_version), # version + deprecated_versions: [Dependabot::Version.new("1")], # deprecated_versions + supported_versions: [Dependabot::Version.new("2"), Dependabot::Version.new("3")] # supported_versions ) end end.new @@ -105,10 +109,11 @@ def initialize Class.new(Dependabot::Ecosystem::VersionManager) do def initialize super( - "python", # name - Dependabot::Version.new("3.8"), # version - [Dependabot::Version.new("3.8")], # deprecated_versions - [Dependabot::Version.new("3.9"), Dependabot::Version.new("3.10")] # supported_versions + name: "python", # name + detected_version: Dependabot::Version.new("3.8"), # version + version: Dependabot::Version.new("3.8"), # version + deprecated_versions: [Dependabot::Version.new("3.8")], # deprecated_versions + supported_versions: [Dependabot::Version.new("3.9"), Dependabot::Version.new("3.10")] # supported_versions ) end end.new diff --git a/updater/spec/support/dummy_pkg_helpers.rb b/updater/spec/support/dummy_pkg_helpers.rb index 2ff6b3aeb8..aa5ae583d9 100644 --- a/updater/spec/support/dummy_pkg_helpers.rb +++ b/updater/spec/support/dummy_pkg_helpers.rb @@ -67,10 +67,11 @@ def updated_bundler_files_hash(fixture: "bundler") class StubPackageManager < Dependabot::Ecosystem::VersionManager def initialize(name:, version:, deprecated_versions: [], supported_versions: []) super( - name, - Dependabot::Version.new(version), - deprecated_versions, - supported_versions + name: name, + detected_version: Dependabot::Version.new(version), + version: Dependabot::Version.new(version), + deprecated_versions: deprecated_versions, + supported_versions: supported_versions ) end