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 4 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
13 changes: 13 additions & 0 deletions npm_and_yarn/lib/dependabot/npm_and_yarn/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ 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)
Copy link
Member

Choose a reason for hiding this comment

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

line 67 is also cleaning a version string; can we consolidate?

Copy link
Contributor

Choose a reason for hiding this comment

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

it is also moved.

@build_info = T.let(nil, T.nilable(String))
Expand All @@ -71,6 +72,18 @@ def initialize(version)
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
# Matches @ followed by x.y.z (digits separated by dots)
if version.is_a?(String) && (match = version.match(/@(\d+\.\d+\.\d+)/))
return match[1] # Just "4.5.3"
end

# If version is not a string or no match found, return original version
version
end

sig { override.params(version: VersionParameter).returns(Dependabot::NpmAndYarn::Version) }
def self.new(version)
T.cast(super, Dependabot::NpmAndYarn::Version)
Expand Down
Loading