-
Notifications
You must be signed in to change notification settings - Fork 0
Fix large lockfile fallback and align scope docs #2
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| package analysis | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "gh-dep-risk/internal/npm" | ||
| ) | ||
|
|
||
| func TestCollectRegistryTargetsSkipsLocalWorkspacePackages(t *testing.T) { | ||
| input := Input{ | ||
| Target: AnalysisTarget{ | ||
| DisplayName: "apps/web", | ||
| ManifestPath: "apps/web/package.json", | ||
| LockfilePath: "yarn.lock", | ||
| Kind: TargetKindWorkspace, | ||
| PackageManager: "yarn", | ||
| OwningDirectory: "apps/web", | ||
| }, | ||
| BaseManifest: manifest(nil, nil, nil), | ||
| HeadManifest: manifest(map[string]string{ | ||
| "local-lib": "file:../local-lib", | ||
| }, nil, nil), | ||
| BaseLockfile: &npm.Lockfile{ | ||
| Manager: "yarn", | ||
| Packages: map[string]npm.LockPackage{}, | ||
| Importers: map[string]npm.LockImporter{}, | ||
| }, | ||
| HeadLockfile: &npm.Lockfile{ | ||
| Manager: "yarn", | ||
| Packages: map[string]npm.LockPackage{ | ||
| "node_modules/local-lib": { | ||
| Path: "node_modules/local-lib", | ||
| Name: "local-lib", | ||
| Version: "1.0.0", | ||
| Resolved: "file:../local-lib", | ||
| WorkspaceLocal: true, | ||
| Dependencies: map[string]string{}, | ||
| }, | ||
| }, | ||
| Importers: map[string]npm.LockImporter{}, | ||
| }, | ||
| } | ||
|
|
||
| targets := CollectRegistryTargets(input) | ||
| if len(targets) != 0 { | ||
| t.Fatalf("expected no registry targets for local workspace package, got %#v", targets) | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -148,6 +148,9 @@ func (l *Lockfile) CollectTargetPackages(targetDir string, directNames []string) | |
| continue | ||
| } | ||
| result.All[pkg.Path] = pkg | ||
| if pkg.WorkspaceLocal { | ||
| continue | ||
| } | ||
|
Comment on lines
+151
to
+153
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Skipping queue traversal for Useful? React with 👍 / 👎. |
||
| queue = append(queue, pkg) | ||
| } | ||
|
|
||
|
|
@@ -166,6 +169,9 @@ func (l *Lockfile) CollectTargetPackages(targetDir string, directNames []string) | |
| continue | ||
| } | ||
| result.All[dep.Path] = dep | ||
| if dep.WorkspaceLocal { | ||
| continue | ||
| } | ||
| queue = append(queue, dep) | ||
| } | ||
| } | ||
|
|
||
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.
The BFS now correctly avoids enqueueing
WorkspaceLocalpackages, but the later nested-package sweep (that adds any package whose path is under an already-included package) will still pull in.../node_modules/...dependencies under a workspace-local package path. That can re-introduce external packages as transitive even though traversal was intentionally skipped. Consider teaching that sweep to ignore workspace-local parents (e.g., only add nested packages when the parentresult.All[existingPath]is notWorkspaceLocal).