mirror of
https://github.com/pnpm/pnpm.git
synced 2026-05-24 08:35:19 -04:00
fix: pkg deps don't ignore the workspace project without set version (#4112)
close #3933
This commit is contained in:
5
.changeset/dirty-cups-live.md
Normal file
5
.changeset/dirty-cups-live.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"pkgs-graph": patch
|
||||
---
|
||||
|
||||
fix: when set workspace protocol the pkgs in workspace without version not ignore
|
||||
5
.changeset/mean-lamps-march.md
Normal file
5
.changeset/mean-lamps-march.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"pnpm": patch
|
||||
---
|
||||
|
||||
When sorting workspace projects, don't ignore the manifests of those that don't have a version field [#3933](https://github.com/pnpm/pnpm/issues/3933).
|
||||
@@ -91,6 +91,10 @@ export default function <T> (pkgs: Array<Package & T>, opts?: {
|
||||
unmatched.push({ pkgName: depName, range: rawSpec })
|
||||
return ''
|
||||
}
|
||||
if (isWorkspaceSpec && versions.length === 0) {
|
||||
const matchedPkg = pkgs.find(pkg => pkg.manifest.name === depName)
|
||||
return matchedPkg!.dir
|
||||
}
|
||||
if (versions.includes(rawSpec)) {
|
||||
const matchedPkg = pkgs.find(pkg => pkg.manifest.name === depName && pkg.manifest.version === rawSpec)
|
||||
return matchedPkg!.dir
|
||||
|
||||
@@ -669,3 +669,51 @@ test('* matches prerelease versions', () => {
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
// fix: https://github.com/pnpm/pnpm/issues/3933
|
||||
test('successfully create a package graph even when a workspace package has no version', async () => {
|
||||
const result = createPkgGraph([
|
||||
{
|
||||
dir: BAR1_PATH,
|
||||
manifest: {
|
||||
dependencies: {
|
||||
foo: 'workspace:*',
|
||||
},
|
||||
name: 'bar',
|
||||
version: '1.0.0',
|
||||
},
|
||||
},
|
||||
{
|
||||
dir: FOO1_PATH,
|
||||
manifest: {
|
||||
name: 'foo',
|
||||
},
|
||||
},
|
||||
])
|
||||
|
||||
expect(result.unmatched).toStrictEqual([])
|
||||
expect(result.graph).toStrictEqual({
|
||||
[BAR1_PATH]: {
|
||||
dependencies: [FOO1_PATH],
|
||||
package: {
|
||||
dir: BAR1_PATH,
|
||||
manifest: {
|
||||
dependencies: {
|
||||
foo: 'workspace:*',
|
||||
},
|
||||
name: 'bar',
|
||||
version: '1.0.0',
|
||||
},
|
||||
},
|
||||
},
|
||||
[FOO1_PATH]: {
|
||||
dependencies: [],
|
||||
package: {
|
||||
dir: FOO1_PATH,
|
||||
manifest: {
|
||||
name: 'foo',
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user