diff --git a/npm_and_yarn/Dockerfile b/npm_and_yarn/Dockerfile index 41a16f11f3..ecffafa80c 100644 --- a/npm_and_yarn/Dockerfile +++ b/npm_and_yarn/Dockerfile @@ -1,7 +1,7 @@ FROM ghcr.io/dependabot/dependabot-updater-core # Check for updates at https://github.com/nodejs/corepack/releases -ARG COREPACK_VERSION=0.24.0 +ARG COREPACK_VERSION=0.30.0 # Check for updates at https://github.com/pnpm/pnpm/releases ARG PNPM_VERSION=9.15.0 diff --git a/npm_and_yarn/lib/dependabot/npm_and_yarn/version.rb b/npm_and_yarn/lib/dependabot/npm_and_yarn/version.rb index d144a66ee6..7470120b79 100644 --- a/npm_and_yarn/lib/dependabot/npm_and_yarn/version.rb +++ b/npm_and_yarn/lib/dependabot/npm_and_yarn/version.rb @@ -62,8 +62,10 @@ def self.semver_for(version) sig { override.params(version: VersionParameter).void } def initialize(version) + version = clean_version(version) + @version_string = T.let(version.to_s, String) - version = version.gsub(/^v/, "") if version.is_a?(String) + @build_info = T.let(nil, T.nilable(String)) version, @build_info = version.to_s.split("+") if version.to_s.include?("+") @@ -71,6 +73,20 @@ def initialize(version) super(T.must(version)) end + sig { params(version: VersionParameter).returns(VersionParameter) } + def clean_version(version) + # Check if version is a string before attempting to match + if version.is_a?(String) + # Matches @ followed by x.y.z (digits separated by dots) + if (match = version.match(/@(\d+\.\d+\.\d+)/)) + version = match[1] # Just "4.5.3" + end + version = version&.gsub(/^v/, "") + end + + version + end + sig { override.params(version: VersionParameter).returns(Dependabot::NpmAndYarn::Version) } def self.new(version) T.cast(super, Dependabot::NpmAndYarn::Version)