Skip to content
New issue

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

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

Already on GitHub? # to your account

npm: support aliases in yarn lock v1 #3555

Merged
merged 2 commits into from
Oct 20, 2023

Conversation

schischi
Copy link
Contributor

ScanCode does not handle aliases in yarn.lock v1 file.
Aliases have the form: <alias-package>@npm:<package>
More info about aliases: https://classic.yarnpkg.com/lang/en/docs/cli/add/#toc-yarn-add-alias

The current code incorrectly parses aliases and end up throwing an exception, resulting in empty results.
A single alias in a yarn.lock file is gonna make the parser return 0 packages.

This patch adds the logic to handle them by simply dropping the alias part, and just keeping the package part.

Test plan: updated the unit tests.

Signed-off-by: Adrien Schildknecht adrs@fb.com

When parsing a `yarn.lock v1` file, ScanCode does not handle aliases properly.
Aliases have the form: `<alias-package>@npm:<package>`
More info about aliases: https://classic.yarnpkg.com/lang/en/docs/cli/add/#toc-yarn-add-alias

The current code incorrecly parse aliases and end up throwing an exception, resulting in empty results.
A single alias in a yarn.lock file is gonna make the parser return 0 packages.

This patch adds the logic to handle them by simply dropping the alias part, and just keeping the package part.

Test plan: updated the unit tests.

Signed-off-by: Adrien Schildknecht <adrs@fb.com>
An assert in the code was making aliases using `@` fail.

Signed-off-by: Adrien Schildknecht <adrs@fb.com>
Copy link
Member

@pombredanne pombredanne left a comment

Choose a reason for hiding this comment

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

Thank you ++... LGTM!

@pombredanne
Copy link
Member

@schischi do you know if these aliases also show up in yarn v2?

@pombredanne pombredanne merged commit b1a3620 into aboutcode-org:develop Oct 20, 2023
AyanSinhaMahapatra added a commit that referenced this pull request Apr 26, 2024
Reference: #3555
Signed-off-by: Ayan Sinha Mahapatra <ayansmahapatra@gmail.com>
@AyanSinhaMahapatra
Copy link
Member

@pombredanne it does not seem like we have this in yarn v2 as there is no mention of aliases in the doc for yarn v2 at https://yarnpkg.com/cli/add similar to https://classic.yarnpkg.com/lang/en/docs/cli/add/#toc-yarn-add-alias, which is the doc for yarn v1.

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

Successfully merging this pull request may close these issues.

3 participants