Add basic npm overrides parsing to package.json - #4130
Open
divizbansal wants to merge 2 commits into
Open
Conversation
Signed-off-by: Diviz Bansal <bansalkrrish36@gmail.com>
Signed-off-by: Diviz Bansal <bansalkrrish36@gmail.com>
AyanSinhaMahapatra
requested changes
Apr 4, 2025
AyanSinhaMahapatra
left a comment
Member
There was a problem hiding this comment.
@divizbansal Thanks++ for the PR. See comments for improvements
| key: bash-exception-gpl | ||
| short_name: Bash exception to GPL | ||
| name: Bash exception to GPL | ||
| category: Copyleft |
Member
There was a problem hiding this comment.
These changes are not related to the issue, please remove these. Probably caused by your IDE settings
| { | ||
| "name": "my-override-example", | ||
| "version": "1.0.0", | ||
| "overrides": { |
Member
There was a problem hiding this comment.
Can you add real examples seen in the wild?
See https://github.com/search?q=path%3A*%2Fpackage.json+overrides&type=code
| @@ -543,6 +543,24 @@ def test_npm_scan_with_private_package_json_and_yarn_lock(self): | |||
| expected_file, result_file, remove_uuid=True, regen=REGEN_TEST_FIXTURES | |||
| ) | |||
|
|
|||
| def test_parse_npm_package_json_with_overrides(self): | |||
Member
There was a problem hiding this comment.
Tests will look like this:
|
|
||
| overrides = json_data.get('overrides') | ||
| if overrides: | ||
| extra_data['overrides'] = overrides |
Member
There was a problem hiding this comment.
This is okay as a start but we need to do a bit more here.
See the go replace directives PR and reviews which is a similar issue: #3693 (comment)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4122
This PR adds a minimal approach to parse and store overrides in package.json into extra_data, plus tests.
Tasks
Run tests locally to check for errors.