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

fix: better support for pnpm aliases #4555

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 25 additions & 0 deletions cli/internal/lockfile/lockfile_test.go
@@ -0,0 +1,25 @@
package lockfile

import (
"sort"
"testing"

"gotest.tools/v3/assert"
)

func Test_ByKeySortIsStable(t *testing.T) {
packagesA := []Package{
{"/foo/1.2.3", "1.2.3", true},
{"/baz/1.0.9", "/baz/1.0.9", true},
{"/bar/1.2.3", "1.2.3", true},
{"/foo/1.2.3", "/foo/1.2.3", true},
{"/baz/1.0.9", "1.0.9", true},
}
packagesB := make([]Package, len(packagesA))
copy(packagesB, packagesA)

sort.Sort(ByKey(packagesA))
sort.Sort(ByKey(packagesB))

assert.DeepEqual(t, packagesA, packagesB)
}
4 changes: 3 additions & 1 deletion cli/internal/lockfile/pnpm_lockfile.go
Expand Up @@ -230,7 +230,9 @@ func (p *PnpmLockfile) ResolvePackage(workspacePath turbopath.AnchoredUnixPath,
if entry.Version != "" {
version = entry.Version
} else {
version = resolvedVersion
// If there isn't a version field in the entry then the version is
// encoded in the key and we can omit the name from the version.
version = p.extractVersion(resolvedVersion)
}
return Package{Key: resolvedVersion, Version: version, Found: true}, nil
}
Expand Down
5 changes: 2 additions & 3 deletions cli/internal/lockfile/pnpm_lockfile_test.go
Expand Up @@ -307,7 +307,7 @@ func Test_PnpmOverride(t *testing.T) {
assert.NilError(t, err, "failure to find package")
assert.Assert(t, pkg.Found)
assert.DeepEqual(t, pkg.Key, "/hardhat-deploy-ethers/0.3.0-beta.13_yab2ug5tvye2kp6e24l5x3z7uy")
assert.DeepEqual(t, pkg.Version, "/hardhat-deploy-ethers/0.3.0-beta.13_yab2ug5tvye2kp6e24l5x3z7uy")
assert.DeepEqual(t, pkg.Version, "0.3.0-beta.13_yab2ug5tvye2kp6e24l5x3z7uy")
}

func Test_DepPathParsing(t *testing.T) {
Expand Down Expand Up @@ -377,7 +377,7 @@ func Test_DepPathParsing(t *testing.T) {
}
}

func Test_MixedVersioning(t *testing.T) {
func Test_PnpmAliasesOverlap(t *testing.T) {
contents, err := getFixture(t, "pnpm-absolute.yaml")
assert.NilError(t, err)

Expand All @@ -398,7 +398,6 @@ func Test_MixedVersioning(t *testing.T) {
assert.DeepEqual(t, deps, []Package{
{"/@scope/child/1.0.0", "1.0.0", true},
{"/@scope/parent/1.0.0", "1.0.0", true},
{"/Special/1.2.3", "/Special/1.2.3", true},
{"/Special/1.2.3", "1.2.3", true},
{"/another/1.0.0", "1.0.0", true},
{"/foo/1.0.0", "1.0.0", true},
Expand Down