fix(validatePeerDependencies): allow combinations (#8946)

This commit is contained in:
Khải
2025-01-08 17:31:37 +07:00
committed by GitHub
parent c27856e789
commit ea58bfdc47
3 changed files with 9 additions and 1 deletions

View File

@@ -0,0 +1,6 @@
---
"@pnpm/resolve-dependencies": patch
"pnpm": patch
---
Allow `workspace:` and `catalog:` to be part of wider version range in `peerDependencies`.

View File

@@ -25,5 +25,6 @@ export function validatePeerDependencies (project: ProjectToValidate): void {
} }
function isValidPeerVersion (version: string): boolean { function isValidPeerVersion (version: string): boolean {
return typeof validRange(version) === 'string' || version.startsWith('workspace:') || version.startsWith('catalog:') // we use `includes` instead of `startsWith` because `workspace:*` and `catalog:*` could be a part of a wider version range expression
return typeof validRange(version) === 'string' || version.includes('workspace:') || version.includes('catalog:')
} }

View File

@@ -8,6 +8,7 @@ test('accepts valid specifications that make sense for peerDependencies', () =>
'semver-range': '>=1.2.3 || ^3.2.1', 'semver-range': '>=1.2.3 || ^3.2.1',
'workspace-scheme': 'workspace:^', 'workspace-scheme': 'workspace:^',
'catalog-scheme': 'catalog:', 'catalog-scheme': 'catalog:',
'combine-all': '>=1.2.3 || ^3.2.1 || workspace:^ || catalog:',
}, },
}, },
}) })