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(version): allowPeerDependenciesUpdate should work w/workspace:^, fix #590 #591

Merged
merged 6 commits into from
May 2, 2023

Conversation

ghiscoding
Copy link
Member

@ghiscoding ghiscoding commented Apr 27, 2023

Description

The peerDependencies is a special case and will only be bumped when the flag --allow-peer-dependencies-update is enabled. A package set as workspace:^ (without any semver number) should be able to be bumped and it wasn't before this PR.

Motivation and Context

The --allow-peer-dependencies-update implementation was only tested with workspace: and semver, but it wasn't tested with just workspace:^ (or ~) and the end result was actually producing an invalid version ^ (which is obviously wrong).

This PR fixes 2 problems with peerDependencies identified in #587 and #590:

the example below is assuming that the version is at 1.0.0 and we are processing a minor bump

  1. when version is workspace:^ and --allow-peer-dependencies-update is enabled, the version in package.json should remain as workspace:^ but the version that will be published should be bumped to "1.1.0"
    • this issue was caused by a very small RegEx that wasn't being match when using workspace:^ without a semver number
  2. when version is workspace:^ and we do not provide --allow-peer-dependencies-update, it was previously trying to publish as ^ (which is an invalid version). In this case we now fallback to the previously resolved version when publishing (in this case "1.0.0")

How Has This Been Tested?

Types of changes

  • Chore (change that has absolutely no effect on users)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@codecov
Copy link

codecov bot commented Apr 27, 2023

Codecov Report

Merging #591 (96a9bd7) into main (b804aac) will increase coverage by 0.01%.
The diff coverage is 100.00%.

❗ Current head 96a9bd7 differs from pull request most recent head 472eac4. Consider uploading reports for the commit 472eac4 to get more accurate results

@@            Coverage Diff             @@
##             main     #591      +/-   ##
==========================================
+ Coverage   98.13%   98.13%   +0.01%     
==========================================
  Files         152      152              
  Lines       11437    11468      +31     
  Branches     2034     2039       +5     
==========================================
+ Hits        11222    11253      +31     
  Misses        214      214              
  Partials        1        1              
Impacted Files Coverage Δ
packages/core/src/package.ts 100.00% <100.00%> (ø)

... and 1 file with indirect coverage changes

@ghiscoding ghiscoding changed the title fix(version): peer deps with workspace:^ should work, fixes #590 fix(version): allowPeerDependenciesUpdate should work w/workspace:^, fix #590 Apr 27, 2023
@ma-multipla
Copy link
Contributor

This looks great! What might be confusing is the inconsistency to yarn pack - not sure how pnpm is currently handling this. When using workspace:* it would be bumped to the locally resolved version as exact version (no range operator) and with this change it will resolve "*", this is a huge difference to the native handling. Might be sufficient to document this.

@ghiscoding
Copy link
Member Author

ghiscoding commented May 2, 2023

The workspace: protocol documentation is separate and can be found under both version#workspace-protocol and publish#workspace-protocol which is literally a copy of pnpm workspace:. I don't really want to add more docs than what I have now for peer deps (maybe just a link to point to these other docs), since workspace: docs already covers that info. in pnpm workspace:* resolves to the exact version (ie 1.2.0) and looking at Yarn workspace: documentation, it is also doing the same thing and using workspace:* in a peer dependencies will also resolve to the current exact version (I found a comment to be wrong in my PR which is related to workspace:* and its output is correct)

@ma-multipla
Copy link
Contributor

The workspace: protocol documentation is separate and can be found under both version#workspace-protocol and publish#workspace-protocol which is literally a copy of pnpm workspace:. I don't really want to add more docs than what I have now for peer deps (maybe just a link to point to these other docs), since workspace: docs already covers that info. in pnpm workspace:* resolves to the exact version (ie 1.2.0) and looking at Yarn workspace: documentation, it is also doing the same thing and using workspace:* in a peer dependencies will also resolve to the current exact version (I found a comment to be wrong in my PR which is related to workspace:* and its output is correct)

I see. I just checked again, made a mistake reading the PR before. Looks good.

@ghiscoding ghiscoding merged commit 0de00e1 into main May 2, 2023
4 checks passed
@ghiscoding ghiscoding deleted the bugfix/workspace-protocol-peer-deps-bumps branch May 2, 2023 16:55
@ghiscoding
Copy link
Member Author

@ma-multipla fixed under the new v2.2.0 release. Thanks for the feedback and contributions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants