Handling Workspace Protocol in Peer Dependencies with Lerna #587
-
I'm having trouble comprehending the purpose of a specific code fragment. In the context of utilizing the workspace protocol for peer dependencies (e.g. Using the Why isn't the {
"name": "B",
"dependencies": {
"A": "workspace:^1.2.0" // will update to "workspace:^1.3.0",
"B": "^0.4.0": // will update to "^0.5.0"
},
"peerDependencies": {
"A": "workspace:^1.2.0" // will update to "workspace:^1.3.0"
"B": ">=0.2.0": // will not be updateed because range with operator (>=) are skipped
}
} https://github.com/lerna-lite/lerna-lite/blob/main/packages/version/README.md#with-flag-enabled It will update to "^1.3.0" not "workspace:^1.3.0". My expectation would be that either Here's the code snippet in question: // Perform certain actions when there are peer dependencies
if (this.peerDependencies?.[depName]) {
// If the user allows peer bump and it's a regular semver version, add it to the array of dependencies to potentially bump
// However, don't do this when the semver has a range with an operator, e.g., bump ("^2.0.0") but not (">=2.0.0" or "workspace:<2.0.0" or "workspace:*")
// prettier-ignore
if (allowPeerDependenciesUpdate && /^(workspace:)?[~^]?[\d\.]+([\-]+[\w\.\-\+]+)*$/i.test(this.peerDependencies[depName] || '')) {
updatingDependencies.push(this.peerDependencies);
}
// When peer bump is disabled, some peerDependencies might not be reviewed and could still have the `workspace:` prefix, so ensure to remove any of these prefixes
else if (updatedByCommand === 'publish' && this.peerDependencies[depName].startsWith('workspace:')) {
this.peerDependencies[depName] = this.peerDependencies[depName].replace('workspace:', '');
}
} Source: Lerna Lite Core Package.ts |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 8 replies
-
First of all, this flag never existed in the original Lerna and then to avoid unexpected behavior to unfamiliar users, this feature was added under a flag in the PR #363, there are also examples and unit tests associated with it under that PR. Note that I do not use this flag, even though I created the PR #363. At the time I asked the user who requested this flag to provide more info but barely got any feedback and as far as I know this user still doesn't use the flag, so it's possible that it's incorrect in some use case because of that reason.
Unless there's a bug, what you said here is incorrect, Lerna-Lite does the substitution but only at the end just before publishing, if you're only executing
Reading your comments, I am assuming that you might not have tried it, perhaps you should give it a try with the
Again I assume you did not give it a try, and if you find the docs too confusing, you can always create a PR to make it clearer. Maybe the confusing part is the comment and should be changed to something like this // will update the version to "workspace:^1.3.0" or "^1.3.0" at publish time Also note that you were also reading the documentation related to Lastly, I would really suggest you to try with the Please Note that this entire project is an ongoing effort executed in my spare time (like many other Open Source projects) and I only use it on other Open Source projects of mine, I am not paid for any of these projects including this one. On the contrary, the Lerna project is now run by Nrwl paid employees, so please keep that in mind (in other words, I'm doing my best here). |
Beta Was this translation helpful? Give feedback.
-
Thanks for the fast feedback! I did try it, but might have used it wrong. with or without
|
Beta Was this translation helpful? Give feedback.
I have converted the Discussion to an issue #590 and opened a PR #591, in it I identified and fixed 2 problems which are mentioned in the PR. I also updated the docs, it would be good if you could do a quick review of the PR #591
Note, the missing flag in the CLI was not addressed in this PR since you said you wanted to contribute a PR