Skip to content

feat(core): update getTouchedProjectsFromLockFile to detect which projects were changed from pnpm lock file diff#31091

Merged
jaysoo merged 3 commits intonrwl:masterfrom
laneysmith:laney/detect-project-updates-from-pnpm-lock-file
May 16, 2025
Merged

feat(core): update getTouchedProjectsFromLockFile to detect which projects were changed from pnpm lock file diff#31091
jaysoo merged 3 commits intonrwl:masterfrom
laneysmith:laney/detect-project-updates-from-pnpm-lock-file

Conversation

@laneysmith
Copy link
Copy Markdown
Contributor

@laneysmith laneysmith commented May 6, 2025

…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:

# 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

@vercel
Copy link
Copy Markdown

vercel Bot commented May 6, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Updated (UTC)
nx-dev ⬜️ Ignored (Inspect) Visit Preview May 16, 2025 3:49pm

@nx-cloud
Copy link
Copy Markdown
Contributor

nx-cloud Bot commented May 6, 2025

View your CI Pipeline Execution ↗ for commit eb190a4.

Command Status Duration Result
nx affected --targets=lint,test,build,e2e,e2e-c... ✅ Succeeded 38m 55s View ↗
nx run-many -t check-imports check-commit check... ✅ Succeeded 17s View ↗
nx-cloud record -- nx-cloud conformance:check ✅ Succeeded 2s View ↗
nx-cloud record -- nx format:check ✅ Succeeded 5s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded 4s View ↗
nx documentation ✅ Succeeded 3m 6s View ↗

☁️ Nx Cloud last updated this comment at 2025-05-16 16:41:17 UTC

@laneysmith laneysmith force-pushed the laney/detect-project-updates-from-pnpm-lock-file branch 4 times, most recently from 62a4ad4 to 74f9831 Compare May 7, 2025 22:17
@laneysmith laneysmith marked this pull request as ready for review May 7, 2025 23:29
@laneysmith laneysmith requested a review from a team as a code owner May 7, 2025 23:29
@laneysmith laneysmith requested a review from Cammisuli May 7, 2025 23:29
@FrozenPandaz FrozenPandaz added the priority: medium Medium Priority (not high, not low priority) label May 9, 2025
@FrozenPandaz FrozenPandaz assigned jaysoo and unassigned AgentEnder May 9, 2025
@FrozenPandaz FrozenPandaz added priority: high High Priority (important issues which affect many people severely) and removed priority: medium Medium Priority (not high, not low priority) labels May 9, 2025
Comment thread packages/nx/src/plugins/js/project-graph/affected/lock-file-changes.spec.ts Outdated
@jaysoo jaysoo changed the title feat(core): update getTouchedProjectsFromLockFile to detect which pro… feat(core): update getTouchedProjectsFromLockFile to detect which projects were changed from pnpm lock file diff May 16, 2025
@jaysoo jaysoo force-pushed the laney/detect-project-updates-from-pnpm-lock-file branch from 74f9831 to eb190a4 Compare May 16, 2025 15:44
@jaysoo
Copy link
Copy Markdown
Member

jaysoo commented May 16, 2025

The YAML file is not treated as JSON changes. I pushed an update to packages/nx/src/project-graph/file-utils.ts to parse it as such, or else your logic would not run.

I've verified that this works locally. Thanks for your contribution!

@jaysoo jaysoo merged commit a5ccd13 into nrwl:master May 16, 2025
6 checks passed
@github-actions
Copy link
Copy Markdown
Contributor

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators May 22, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

priority: high High Priority (important issues which affect many people severely)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

4 participants