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
chore: move lockfile ffi boundary #4629
Changes from 1 commit
8c99b57
8d93b1e
ab9f0b3
f9a460c
4f9c395
31ef289
1c6d663
92f0b58
2efd867
57be317
0ff9dbc
1931953
fbdeffd
8c6c647
b0f20e7
d1c52da
fada352
9049e5c
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 |
---|---|---|
|
@@ -17,7 +17,6 @@ import ( | |
"github.com/vercel/turbo/cli/internal/workspace" | ||
|
||
"github.com/Masterminds/semver" | ||
mapset "github.com/deckarep/golang-set" | ||
"github.com/pyr-sh/dag" | ||
"golang.org/x/sync/errgroup" | ||
) | ||
|
@@ -179,12 +178,6 @@ func BuildPackageGraph(repoRoot turbopath.AbsoluteSystemPath, rootPackageJSON *f | |
} | ||
c.PackageManager = packageManager | ||
|
||
if lockfile, err := c.PackageManager.ReadLockfile(repoRoot, rootPackageJSON); err != nil { | ||
warnings.append(err) | ||
} else { | ||
c.Lockfile = lockfile | ||
} | ||
|
||
if err := c.resolveWorkspaceRootDeps(rootPackageJSON, &warnings); err != nil { | ||
// TODO(Gaspar) was this the intended return error? | ||
return nil, fmt.Errorf("could not resolve workspaces: %w", err) | ||
|
@@ -231,6 +224,29 @@ func BuildPackageGraph(repoRoot turbopath.AbsoluteSystemPath, rootPackageJSON *f | |
} | ||
c.WorkspaceInfos.PackageJSONs[util.RootPkgName] = rootPackageJSON | ||
|
||
if lockFile, err := c.PackageManager.ReadLockfile(repoRoot, rootPackageJSON); err != nil { | ||
warnings.append(err) | ||
rootPackageJSON.TransitiveDeps = []lockfile.Package{} | ||
rootPackageJSON.ExternalDepsHash = "" | ||
} else { | ||
c.Lockfile = lockFile | ||
for _, pkg := range c.WorkspaceInfos.PackageJSONs { | ||
depSet, err := lockfile.TransitiveClosure( | ||
pkg.Dir.ToUnixPath(), | ||
pkg.UnresolvedExternalDeps, | ||
c.Lockfile, | ||
) | ||
if err != nil { | ||
warnings.append(err) | ||
continue | ||
chris-olszewski marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
if err := pkg.SetExternalDeps(depSet); err != nil { | ||
return nil, err | ||
} | ||
} | ||
|
||
} | ||
|
||
return c, warnings.errorOrNil() | ||
} | ||
|
||
|
@@ -246,25 +262,6 @@ func (c *Context) resolveWorkspaceRootDeps(rootPackageJSON *fs.PackageJSON, warn | |
for dep, version := range pkg.Dependencies { | ||
pkg.UnresolvedExternalDeps[dep] = version | ||
} | ||
if c.Lockfile != nil { | ||
depSet, err := lockfile.TransitiveClosure( | ||
pkg.Dir.ToUnixPath(), | ||
pkg.UnresolvedExternalDeps, | ||
c.Lockfile, | ||
) | ||
if err != nil { | ||
warnings.append(err) | ||
// Return early to skip using results of incomplete dep graph resolution | ||
return nil | ||
} | ||
if err := pkg.SetExternalDeps(depSet); err != nil { | ||
return err | ||
} | ||
} else { | ||
pkg.TransitiveDeps = []lockfile.Package{} | ||
pkg.ExternalDepsHash = "" | ||
} | ||
|
||
return nil | ||
} | ||
|
||
|
@@ -315,17 +312,6 @@ func (c *Context) populateWorkspaceGraphForPackageJSON(pkg *fs.PackageJSON, root | |
} | ||
} | ||
|
||
externalDeps, err := lockfile.TransitiveClosure( | ||
pkg.Dir.ToUnixPath(), | ||
pkg.UnresolvedExternalDeps, | ||
c.Lockfile, | ||
) | ||
if err != nil { | ||
warnings.append(err) | ||
// reset external deps to original state | ||
externalDeps = mapset.NewSet() | ||
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. What was this doing? 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. This was here instead of proper control flow, if the closure calculation errored we would override the return value with an empty set. This would then get translated to |
||
} | ||
|
||
// when there are no internal dependencies, we need to still add these leafs to the graph | ||
if internalDepsSet.Len() == 0 { | ||
c.WorkspaceGraph.Connect(dag.BasicEdge(pkg.Name, core.ROOT_NODE_NAME)) | ||
|
@@ -336,10 +322,6 @@ func (c *Context) populateWorkspaceGraphForPackageJSON(pkg *fs.PackageJSON, root | |
pkg.InternalDeps = append(pkg.InternalDeps, fmt.Sprintf("%v", v)) | ||
} | ||
|
||
if err := pkg.SetExternalDeps(externalDeps); err != nil { | ||
return err | ||
} | ||
|
||
sort.Strings(pkg.InternalDeps) | ||
|
||
return nil | ||
|
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.
Does this work as just
nil
?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.
Haven't done a full code trace, but it should. This was just copied from previous behavior.
Edit: Checked and
nil
works just fine here