Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bump corepack to fix freezes #11126

Merged
merged 8 commits into from
Dec 20, 2024
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
2 changes: 1 addition & 1 deletion npm_and_yarn/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
18 changes: 17 additions & 1 deletion npm_and_yarn/lib/dependabot/npm_and_yarn/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,31 @@ 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?("+")

super(T.must(version))
end

sig { params(version: VersionParameter).returns(VersionParameter) }
def clean_version(version)
Copy link
Contributor

@kbukum1 kbukum1 Dec 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Tip:
Corepack's newer versions, when installing dependencies locally, may attempt to add the packageManager field to the package.json. Instead of returning the expected version, Corepack sometimes outputs a warning message that includes the version, leading to a malformed version string. This method cleans the version string by extracting the correct semantic version (x.y.z) from the warning or input, ensuring compatibility with Dependabot and related processes.

# 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)
Expand Down
Loading