Skip to content

Commit

Permalink
fix: skip over cataloged deps on pnpm update --latest
Browse files Browse the repository at this point in the history
  • Loading branch information
gluxon committed Jul 7, 2024
1 parent 450d5ed commit 9ea504b
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
47 changes: 47 additions & 0 deletions pkg-manager/core/test/catalogs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -593,4 +593,51 @@ describe('update', () => {
packages: { '[email protected]': expect.objectContaining({}) },
}))
})

test('update latest does modify catalog: protocol', async () => {
const { options, projects, readLockfile } = preparePackagesAndReturnObjects([{
name: 'project1',
dependencies: {
'is-positive': 'catalog:',
},
}])

const catalogs = {
default: { 'is-positive': '1.0.0' },
}

const mutateOpts = {
...options,
lockfileOnly: true,
catalogs,
}

await mutateModules(installProjects(projects), mutateOpts)

// Sanity check that the is-positive dependency is installed on the older
// requested version.
expect(readLockfile().catalogs.default).toEqual({
'is-positive': { specifier: '1.0.0', version: '1.0.0' },
})

const updatedManifest = await addDependenciesToPackage(
projects['project1' as ProjectId],
['is-positive'],
{
...mutateOpts,
allowNew: false,
update: true,
updateToLatest: true,
})

// Expecting the manifest to remain unchanged.
expect(updatedManifest).toEqual({
name: 'project1',
dependencies: {
'is-positive': 'catalog:',
},
})

expect(Object.keys(readLockfile().snapshots)).toEqual(['[email protected]'])
})
})
4 changes: 4 additions & 0 deletions pkg-manager/resolve-dependencies/src/resolveDependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,10 @@ async function resolveDependenciesOfImporterDependency (
...importer.options,
parentPkgAliases: importer.parentPkgAliases,
pickLowestVersion: pickLowestVersion && !importer.updatePackageManifest,
// Cataloged dependencies cannot be upgraded yet since they require
// updating the pnpm-workspace.yaml file. This will be handled in a future
// version of pnpm.
updateToLatest: catalogLookup === null && importer.options.updateToLatest,
},
extendedWantedDep
)
Expand Down

0 comments on commit 9ea504b

Please sign in to comment.