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

feat(npm): handle github dependencies with semver versions #28261

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

fehnomenal
Copy link

Changes

The npm manager supports extracting the correct version from strings like github:renovatebot/renovate#semver:37.280.0.

Context

NPM supports those dependencies but renovate not yet.

Documentation (please check one with an [x])

  • I have updated the documentation, or
  • No documentation update is required

How I've tested my work (please select one)

I have verified these changes via:

  • Code inspection only, or
  • Newly added/modified unit tests, or
  • No unit tests but ran on a real repository, or
  • Both unit tests + ran on a real repository

Copy link
Collaborator

@rarkins rarkins left a comment

Choose a reason for hiding this comment

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

Also needs a test added

} else if (
depRefPart.startsWith('semver:') &&
isVersion(depRefPart.slice('semver:'.length))
) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
) {
) {
// <protocol>://[<user>[:<password>]@]<hostname>[:<port>][:][/]<path>[#<commit-ish> | #semver:<semver>]
// https://docs.npmjs.com/cli/v10/configuring-npm/package-json#git-urls-as-dependencies

@@ -180,6 +180,16 @@ export function extractDependency(
dep.datasource = GithubTagsDatasource.id;
dep.versioning = npmVersioningId;
dep.packageName = githubOwnerRepo;
} else if (
depRefPart.startsWith('semver:') &&
isVersion(depRefPart.slice('semver:'.length))
Copy link
Member

Choose a reason for hiding this comment

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

use substring (perf)

isVersion(depRefPart.slice('semver:'.length))
) {
dep.currentRawValue = dep.currentValue;
dep.currentValue = depRefPart.slice('semver:'.length);
Copy link
Member

Choose a reason for hiding this comment

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

same

@rarkins rarkins marked this pull request as draft May 7, 2024 05:39
Copy link
Collaborator

@rarkins rarkins left a comment

Choose a reason for hiding this comment

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

Needs tests added

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants