Skip to content

"projectsAffectedByDependencyUpdates": "auto" does not work with pnpm catalogs #29986

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 of 4 tasks
laneysmith opened this issue Feb 11, 2025 · 4 comments · Fixed by #31091
Closed
1 of 4 tasks

"projectsAffectedByDependencyUpdates": "auto" does not work with pnpm catalogs #29986

laneysmith opened this issue Feb 11, 2025 · 4 comments · Fixed by #31091

Comments

@laneysmith
Copy link
Contributor

Current Behavior

To help enforce a single version policy within our monorepo, we use pnpm catalogs for all dependencies that are used in multiple projects. When "projectsAffectedByDependencyUpdates" is set to "auto", updates to pnpm-workspace.yaml catalog versions result in 0 projects being marked as affected.

Expected Behavior

When a default or named catalog version is updated in pnpm-workspace.yaml, all projects that reference that catalog as a dependency in their package.json should be marked as affected.

GitHub Repo

No response

Steps to Reproduce

In any Nx workspace project that uses catalogs,

  1. set "projectsAffectedByDependencyUpdates" to "auto" & commit change
  2. update a version for a catalog dependency
  3. run pnpm i
  4. run nx show projects --affected --uncommitted

Nx Report

NX   Report complete - copy this into the issue template

Node           : 20.17.0
OS             : darwin-arm64
Native Target  : aarch64-macos
pnpm           : 9.11.0

nx                     : 20.3.2
@nx/js                 : 20.3.2
@nx/jest               : 20.3.2
@nx/eslint             : 20.3.2
@nx/workspace          : 20.3.2
@nx/cypress            : 20.3.2
@nx/devkit             : 20.3.2
@nx/eslint-plugin      : 20.3.2
@nx/module-federation  : 20.3.2
@nx/plugin             : 20.3.2
@nx/react              : 20.3.2
@nx/storybook          : 20.3.2
@nx/vite               : 20.3.2
@nx/web                : 20.3.2
typescript             : 5.5.4
---------------------------------------
Registered Plugins:
@nx/vite/plugin
@nx/storybook/plugin
@nx/js/typescript

Failure Logs

Package Manager Version

9.11.0

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

Related to the following issues that stem from lack of support for pnpm catalogs

@ryanbas21
Copy link
Contributor

#29923 Does this help? Let me know if i'm missing something

@laneysmith
Copy link
Contributor Author

#29923 Does this help? Let me know if i'm missing something

@ryanbas21 In this case I think we'd need to update the affected logic to check for changes to catalog versions in pnpm-workspace.yaml (or pnpm-lock.yaml), then determine which projects reference the changed catalogs as dependencies and mark them as affected.

@laneysmith
Copy link
Contributor Author

I looked into this a bit more and see there's an open issue in pnpm for updating pnpm ls --filter "[<since>]" to detect which packages are impacted by a catalog version change: pnpm/pnpm#8718. Until that is resolved, it doesn't appear we can just leverage pnpm to determine projects affected by catalog changes.

@or-orchid
Copy link

I am facing the same issue with pnpm-lock.yaml without using pnpm-workspace.yaml, I assume it's also relevant to monorepos without pnpm workspaces

laneysmith added a commit to laneysmith/nx that referenced this issue May 6, 2025
…jects were changed from pnpm lock file diff

Closes nrwl#29986
laneysmith added a commit to laneysmith/nx that referenced this issue May 7, 2025
…jects were changed from pnpm lock file diff

Closes nrwl#29986
laneysmith added a commit to laneysmith/nx that referenced this issue May 7, 2025
…jects were changed from pnpm lock file diff

Closes nrwl#29986
laneysmith added a commit to laneysmith/nx that referenced this issue May 7, 2025
…jects were changed from pnpm lock file diff

Closes nrwl#29986
laneysmith added a commit to laneysmith/nx that referenced this issue May 7, 2025
…jects were changed from pnpm lock file diff

Closes nrwl#29986
jaysoo pushed a commit to laneysmith/nx that referenced this issue May 16, 2025
jaysoo added a commit that referenced this issue May 16, 2025
…jects were changed from pnpm lock file diff (#31091)

…jects were changed from pnpm lock file diff

Closes #29986

## Current Behavior

Nx projects that use pnpm catalogs cannot take advantage of the
`projectsAffectedByDependencyUpdates` `“auto”` setting because updating
catalog versions does not touch project files.

## Expected Behavior

When `projectsAffectedByDependencyUpdates` is set to `“auto”`, updating
a catalog dependency version should result in all projects that use it
getting marked as affected.

A catalog version update and the affected projects can be detected from
a changed pnpm lock file. This PR updates the
`getTouchedProjectsFromLockFile` logic to check the lock file for pnpm
monorepos.

Example pnpm lock file diff after catalog dependency update:

```diff
# pnpm-lock.yaml

# ...

catalogs:
  default:
    '@aws-sdk/client-s3':
-      specifier: ^3.535.0
-      version: 3.535.0
+      specifier: ^3.797.0
+      version: 3.797.0

importers:

  apps/app1:
    dependencies:
      '@aws-sdk/client-s3':
        specifier: 'catalog:'
-        version: 3.535.0
+        version: 3.797.0

# ...
```

## Related Issue(s)

#29986

Fixes #29986

---------

Co-authored-by: Jack Hsu <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants