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

Npm: Fix querying of package details from private / scoped registries #5162

Merged
merged 6 commits into from
Mar 18, 2022

Conversation

sschuberth
Copy link
Member

Please have a look at the individual commit messages for the details.

@sschuberth sschuberth requested a review from a team as a code owner March 18, 2022 08:21
@sschuberth sschuberth force-pushed the npm-cli branch 2 times, most recently from 3aacc33 to a5a8a40 Compare March 18, 2022 08:53
MarcelBochtler
MarcelBochtler previously approved these changes Mar 18, 2022
@mnonnenmacher mnonnenmacher changed the title Npm: Fix quering of package details from private / scoped registries Npm: Fix querying of package details from private / scoped registries Mar 18, 2022
To avoid unnecessary remote queries, only do so if existing data is
incomplete.

Signed-off-by: Sebastian Schuberth <sebastian.schuberth@bosch.io>
To be on the safe side, do this in any case in common code.

Signed-off-by: Sebastian Schuberth <sebastian.schuberth@bosch.io>
MarcelBochtler
MarcelBochtler previously approved these changes Mar 18, 2022
analyzer/src/main/kotlin/managers/Npm.kt Outdated Show resolved Hide resolved
analyzer/src/main/kotlin/managers/Npm.kt Show resolved Hide resolved
analyzer/src/main/kotlin/managers/Npm.kt Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Mar 18, 2022

Codecov Report

Merging #5162 (2f7512e) into main (c087e6f) will decrease coverage by 0.04%.
The diff coverage is 64.28%.

❗ Current head 2f7512e differs from pull request most recent head cc9fd23. Consider uploading reports for the commit cc9fd23 to get more accurate results

@@             Coverage Diff              @@
##               main    #5162      +/-   ##
============================================
- Coverage     72.25%   72.21%   -0.05%     
+ Complexity     1929     1924       -5     
============================================
  Files           255      255              
  Lines         13684    13647      -37     
  Branches       1919     1918       -1     
============================================
- Hits           9888     9855      -33     
+ Misses         2791     2788       -3     
+ Partials       1005     1004       -1     
Impacted Files Coverage Δ
...yzer/src/main/kotlin/managers/utils/NodeSupport.kt 80.51% <ø> (+0.92%) ⬆️
analyzer/src/main/kotlin/managers/Npm.kt 81.88% <59.09%> (-1.34%) ⬇️
analyzer/src/main/kotlin/managers/Yarn.kt 91.66% <75.00%> (+0.75%) ⬆️
...main/kotlin/managers/utils/NpmDependencyHandler.kt 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c087e6f...cc9fd23. Read the comment docs.

Do not unconditionally overwrite existing package data, but only if it
is empty.

Signed-off-by: Sebastian Schuberth <sebastian.schuberth@bosch.io>
This is a preparation for an upcoming change that needs to run the `npm`
command line tool from a static context.

As a side effect when running `ort requirements`, `NpmCli` and `YarnCli`
are now listed in the "Other tool" section instead of the "PackageManager"
section.

Signed-off-by: Sebastian Schuberth <sebastian.schuberth@bosch.io>
@sschuberth sschuberth force-pushed the npm-cli branch 2 times, most recently from c8a4f2f to 7c6bd44 Compare March 18, 2022 13:35
mnonnenmacher
mnonnenmacher previously approved these changes Mar 18, 2022
@sschuberth sschuberth enabled auto-merge (rebase) March 18, 2022 17:22
Bump the NPM version requirement from 5.7.* to 6.* in order to be able
to use the `npm view` command to query details about a package from
remote registries. This lifts two severe restrictions:

- The original code was only able to query package details from the
  public NPM registry [1]. Private registries were not supported at all.

- Custom registries defined for different NPM scopes were not supported.

As a bonus, `npm view` seems to return more details than querying the
registry API directly even for the public NPM registry.

The downside is that performance is worse now, using `npm view` seems to
be roughly 4 times slower (on Linux); the command unfortunately does not
support batching. However, correctness should be more important than
performance here, and a future improvement could parallelize the
`parsePackage()` calls in general.

[1]: https://registry.npmjs.org

Signed-off-by: Sebastian Schuberth <sebastian.schuberth@bosch.io>
Signed-off-by: Sebastian Schuberth <sebastian.schuberth@bosch.io>
@sschuberth sschuberth disabled auto-merge March 18, 2022 19:55
@sschuberth
Copy link
Member Author

Merging despite the unrelated ConanFunTest failure.

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.

3 participants