Skip to content
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

fix: Disable updating peer dependencies when updatePeerDependencies is false. #2270

Merged

Conversation

kinyoklion
Copy link
Contributor

The "updatePeerDependencies" option currently operates as a "considerPeerDependencies" option. What this means is that if a package only has a peer dependency on another, then that will not be considered and no update will be made (as if there was no dependency). If a package has a peer dependency as well as another dependency, for instance a dev dependency, then the peer dependency is updated regardless.

This propagates the "updatePeerDependencies" option to the PackageJson updater so that it can omit updates to the peer dependencies.

It isn't completely clear what the intended behavior here is. This update behavior matches my current use-case, but it is possible it could be a problem for others. In which case there could be two different options (but the current name does seem like it would impact peer dependency updates.)

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • [na] Appropriate docs were updated (if necessary)

Fixes #2269
🦕

@kinyoklion kinyoklion requested review from a team as code owners April 16, 2024 01:35
@product-auto-label product-auto-label bot added the size: m Pull request size is medium. label Apr 16, 2024
\t\t"foo": "~0.1.0"
\t},
\t"peerDependencies": {
\t\t"bar": ">= 1.0.0"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test that validates the peer dependency is not updated.

const packageJson = new PackageJson({
version: Version.parse('14.0.0'),
versionsMap,
updatePeerDependencies: true,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test implicitly dependended on the updater always updating the peer dependencies. So it was updated and produces the same output.

snapshot(newContent.replace(/\r\n/g, '\n'));
});

it('does not update peer dependencies by default', async () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New test which does not update peer dependencies.

Copy link
Contributor

@chingor13 chingor13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@chingor13 chingor13 merged commit 2d80f12 into googleapis:main Apr 16, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: m Pull request size is medium.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Peer dependencies are updated regardless of "updatePeerDependencies" setting.
2 participants