mirror of
https://github.com/pnpm/pnpm.git
synced 2026-04-28 02:53:15 -04:00
Fix add bug with overlapping workspace packages (#4575)
Co-authored-by: Zoltan Kochan <z@kochan.io>
This commit is contained in:
7
.changeset/strange-parents-drum.md
Normal file
7
.changeset/strange-parents-drum.md
Normal file
@@ -0,0 +1,7 @@
|
||||
---
|
||||
"@pnpm/resolve-dependencies": patch
|
||||
"pnpm": patch
|
||||
---
|
||||
|
||||
Don't update a direct dependency that has the same name as a dependency in the workspace, when adding a new dependency to a workspace project [#4575](https://github.com/pnpm/pnpm/pull/4575).
|
||||
|
||||
@@ -1316,3 +1316,72 @@ test('install the dependency that is already present in the workspace when addin
|
||||
expect(currentLockfile.importers['project-1'].dependencies?.['dep-of-pkg-with-1-dep']).toBe('100.0.0')
|
||||
expect(currentLockfile.importers['project-2'].dependencies?.['dep-of-pkg-with-1-dep']).toBe('100.0.0')
|
||||
})
|
||||
|
||||
test('do not update dependency that has the same name as a dependency in the workspace', async () => {
|
||||
await addDistTag({ package: 'dep-of-pkg-with-1-dep', version: '100.0.0', distTag: 'latest' })
|
||||
const manifest1: ProjectManifest = {
|
||||
name: 'project-1',
|
||||
version: '1.0.0',
|
||||
dependencies: {
|
||||
'dep-of-pkg-with-1-dep': '^100.0.0',
|
||||
},
|
||||
}
|
||||
const manifest2: ProjectManifest = { name: 'dep-of-pkg-with-1-dep', version: '100.1.0' }
|
||||
|
||||
preparePackages([
|
||||
{
|
||||
location: 'project-1',
|
||||
package: manifest1,
|
||||
},
|
||||
{
|
||||
location: 'project-2',
|
||||
package: manifest2,
|
||||
},
|
||||
])
|
||||
|
||||
const importers: MutatedProject[] = [
|
||||
{
|
||||
buildIndex: 0,
|
||||
manifest: manifest1,
|
||||
mutation: 'install',
|
||||
rootDir: path.resolve('project-1'),
|
||||
},
|
||||
{
|
||||
buildIndex: 0,
|
||||
manifest: manifest2,
|
||||
mutation: 'install',
|
||||
rootDir: path.resolve('project-2'),
|
||||
},
|
||||
]
|
||||
const workspacePackages = {
|
||||
'project-1': {
|
||||
'1.0.0': {
|
||||
dir: path.resolve('project-1'),
|
||||
manifest: manifest1,
|
||||
},
|
||||
},
|
||||
'dep-of-pkg-with-1-dep': {
|
||||
'100.1.0': {
|
||||
dir: path.resolve('project-2'),
|
||||
manifest: manifest2,
|
||||
},
|
||||
},
|
||||
}
|
||||
await mutateModules(importers, await testDefaults({ linkWorkspacePackagesDepth: -1, workspacePackages }))
|
||||
await addDistTag({ package: 'dep-of-pkg-with-1-dep', version: '100.1.0', distTag: 'latest' })
|
||||
await mutateModules([
|
||||
{
|
||||
...importers[0],
|
||||
dependencySelectors: ['is-negative@2.1.0'],
|
||||
mutation: 'installSome',
|
||||
},
|
||||
importers[1],
|
||||
], await testDefaults({ linkWorkspacePackagesDepth: -1, workspacePackages, preferredVersions: {} }))
|
||||
|
||||
const rootModules = assertProject(process.cwd())
|
||||
const currentLockfile = await rootModules.readCurrentLockfile()
|
||||
expect(Object.keys(currentLockfile.packages)).toStrictEqual([
|
||||
'/dep-of-pkg-with-1-dep/100.0.0',
|
||||
'/is-negative/2.1.0',
|
||||
])
|
||||
})
|
||||
|
||||
@@ -283,6 +283,7 @@ async function resolveDependenciesOfDependency (
|
||||
)
|
||||
) || Boolean(
|
||||
(options.workspacePackages != null) &&
|
||||
ctx.linkWorkspacePackagesDepth !== -1 &&
|
||||
wantedDepIsLocallyAvailable(
|
||||
options.workspacePackages,
|
||||
extendedWantedDep.wantedDependency,
|
||||
|
||||
@@ -10,8 +10,7 @@
|
||||
"bugs": {
|
||||
"url": "https://github.com/pnpm/eslint-config/issues"
|
||||
},
|
||||
"main": "lib/index.js",
|
||||
"types": "lib/index.d.ts",
|
||||
"main": "index.js",
|
||||
"directories": {
|
||||
"test": "test"
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user