-
-
Notifications
You must be signed in to change notification settings - Fork 595
Add basic npm overrides parsing to package.json #4130
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
base: develop
Are you sure you want to change the base?
Add basic npm overrides parsing to package.json #4130
Conversation
Signed-off-by: Diviz Bansal <bansalkrrish36@gmail.com>
Signed-off-by: Diviz Bansal <bansalkrrish36@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests will look like this:
def test_parse_from_urls_dict_legacy_is_ignored(self): |
@@ -578,6 +578,10 @@ def _parse(cls, json_data, package_only=False): | |||
if value: | |||
extra_data[extra_data_field] = value | |||
|
|||
overrides = json_data.get('overrides') | |||
if overrides: | |||
extra_data['overrides'] = overrides |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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)
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.