-
Notifications
You must be signed in to change notification settings - Fork 313
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
node: Prepare for a larger Npm
refactoring
#9385
Conversation
7a0bd6c
to
0ede477
Compare
Prepare for re-writing large parts of `Npm` to no more rely on the file hierarchy of `node_modules` when constructing the dependency tree. While the same is planned for `Yarn` too, this change is just a refactoring step which allows to do `Npm` first. Signed-off-by: Frank Viernau <[email protected]>
As of the recent refactoring of `Pnpm`, the is no more override of this function in ORT. So, make the function private. Signed-off-by: Frank Viernau <[email protected]>
5497a72
to
f015cc1
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #9385 +/- ##
============================================
- Coverage 67.67% 66.72% -0.96%
- Complexity 1223 1236 +13
============================================
Files 244 247 +3
Lines 8626 8962 +336
Branches 911 974 +63
============================================
+ Hits 5838 5980 +142
- Misses 2413 2567 +154
- Partials 375 415 +40
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
f015cc1
to
d48900f
Compare
The functions `parseProject()` and `parsePackage()` are used by mutliple package managers. Move them to `NpmSupport` which contains common code to account for that. Signed-off-by: Frank Viernau <[email protected]>
Align with `pnpm` and `yarn2`. Signed-off-by: Frank Viernau <[email protected]>
Establish consistency and prepare for an upcoming refactoring of `Npm` which will add further classes under the `npm` directory. Signed-off-by: Frank Viernau <[email protected]>
Use an own logger instead of the one from `Npm`. Signed-off-by: Frank Viernau <[email protected]>
d48900f
to
92f0710
Compare
Merging despite the unrelated |
Oh, crap, sorry @oss-review-toolkit/core-devs, I was mixing this up with #9380 which I intended to merge! Let me do a retrospective review to see if I need to revert things, or if we can live with the accidental merge. Sorry again 😞 |
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.
I've added a few retrospective comments. I don't think we need to revert the accidental merge, but getting relies to my questions would be nice for the sake of documenting things.
@@ -22,68 +22,41 @@ | |||
package org.ossreviewtoolkit.plugins.packagemanagers.node | |||
|
|||
import java.io.File | |||
import java.util.concurrent.ConcurrentHashMap |
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.
Commit message:
While the same is planned for
Yarn
too, this change is just a refactoring step which allows to doNpm
first.
As this refactoring moves around so much code which is hard to review, it would have been nice to explain why Npm
is done first. Wouldn't it have been easier to do Yarn
first?
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.
Doing this for Npm
is way more straight forward than doing this for Yarn
.
I wanted to do the low hanging fruit first, which also allows to quickly add workspaces support for NPM.
How to best implement this in Yarn I'm not sure. I'm considering to ask Yarn community whether they are open to a contribution to the list
command, so that it outputs something which is less complex to process for our purpose.
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.
I'm considering to ask Yarn community whether they are open to a contribution to the
list
command
But then we would depend on (at least) that Yarn version, which is probably not feasible anyway.
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.
Hm, why would this be problematic? I do remember similar thing for go mod
.
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.
Because projects might depend on a lower version of Yarn (for whatever reason), similar to like some projects depend on a lower Version of Gradle.
@@ -26,32 +26,13 @@ import java.io.File | |||
import org.apache.logging.log4j.kotlin.logger | |||
|
|||
import org.ossreviewtoolkit.analyzer.AbstractPackageManagerFactory | |||
import org.ossreviewtoolkit.analyzer.PackageManager.Companion.getFallbackProjectName |
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.
Commit message:
- Typo in "mutliple".
@@ -94,7 +95,7 @@ class Npm( | |||
return runCatching { | |||
val process = run(workingDir, "info", "--json", packageName) | |||
|
|||
parsePackageJson(process.stdout) | |||
org.ossreviewtoolkit.plugins.packagemanagers.node.parsePackageJson(process.stdout) |
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.
Why is this a FQN now?
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.
Just a mistake. Haven't noticed it.
@@ -247,8 +247,10 @@ internal fun parsePackage( | |||
return module | |||
} | |||
|
|||
private val logger = loggerOf(MethodHandles.lookup().lookupClass()) |
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.
I'd move this to the top to make more clear that all functions could make use of it.
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.
Agree.
I've addressed your (@sschuberth) comments where possible with #9389. |
Prepare for re-writing large parts of
Npm
to solely rely on thenpm
command output to construct the dependency tree,which will remove the inheritance between
Yarn
andNpm
. To allow doing that, invert the inheritance betweenYarn
andNpm
as a "temporary" refactoring step.Also do further minor preparations.
Part of: #9261.