mirror of
https://github.com/pnpm/pnpm.git
synced 2026-04-02 14:33:18 -04:00
feat: show available workspace versions on mismatch (#10466)
This commit is contained in:
committed by
Zoltan Kochan
parent
d75628a612
commit
1df570b468
@@ -216,6 +216,7 @@
|
||||
"proxied",
|
||||
"pwsh",
|
||||
"quux",
|
||||
"rcompare",
|
||||
"redownload",
|
||||
"refclone",
|
||||
"reflattened",
|
||||
|
||||
@@ -561,9 +561,16 @@ function tryResolveFromWorkspacePackages (
|
||||
opts.update ? { name: spec.name, fetchSpec: '*', type: 'range' } : spec
|
||||
)
|
||||
if (!localVersion) {
|
||||
const availableVersions = Array.from(workspacePkgsMatchingName.keys()).sort((a, b) => semver.rcompare(a, b))
|
||||
throw new PnpmError(
|
||||
'NO_MATCHING_VERSION_INSIDE_WORKSPACE',
|
||||
`In ${path.relative(process.cwd(), opts.projectDir)}: No matching version found for ${opts.wantedDependency.alias ?? ''}@${opts.wantedDependency.bareSpecifier ?? ''} inside the workspace`
|
||||
`In ${path.relative(process.cwd(), opts.projectDir)}: No matching version found for ${opts.wantedDependency.alias ?? ''}@${opts.wantedDependency.bareSpecifier ?? ''} inside the workspace` +
|
||||
(availableVersions.length ? `. Available versions: ${availableVersions.join(', ')}` : ''),
|
||||
availableVersions.length
|
||||
? {
|
||||
hint: `Available workspace versions for "${spec.name}": ${availableVersions.join(', ')}`,
|
||||
}
|
||||
: undefined
|
||||
)
|
||||
}
|
||||
return resolveFromLocalPackage(workspacePkgsMatchingName.get(localVersion)!, spec, opts)
|
||||
|
||||
@@ -1702,7 +1702,7 @@ test('workspace protocol: resolution fails if there is no matching local package
|
||||
|
||||
expect(err).toBeTruthy()
|
||||
expect(err.code).toBe('ERR_PNPM_NO_MATCHING_VERSION_INSIDE_WORKSPACE')
|
||||
expect(err.message).toBe(`In ${path.relative(process.cwd(), projectDir)}: No matching version found for is-positive@workspace:^3.0.0 inside the workspace`)
|
||||
expect(err.message).toBe(`In ${path.relative(process.cwd(), projectDir)}: No matching version found for is-positive@workspace:^3.0.0 inside the workspace. Available versions: 2.0.0`)
|
||||
})
|
||||
|
||||
test('workspace protocol: resolution fails if there are no local packages', async () => {
|
||||
|
||||
Reference in New Issue
Block a user