-
-
Notifications
You must be signed in to change notification settings - Fork 35
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
Versioning for nested packages #491
Comments
That's a bit outside of my comfortable zone and knowledge of the code, feel free to create a Pull Request with this change, however this seems like a potential change of behavior and it would probably be better to put this under a new flag to not break expectation. |
@ghiscoding Yea, I do understand. Already thought about possible negative effects for others but could not find a problematic case, but that's just what I had in mind. But you do get what the change aims at, do you? Just to give a bit more background: We are maintaining a > 600 packages Monorepo with some packages having something like 20 subpackages and other packages with > 60 dependencies from within the repo. So any unnecessary version can easily lead to a 100 new versions on packages that would really need no change at all. I will see if I am able to deal with implementing a flag for this to be enabled when required and issue a PR ;) |
wow that is quite a large monorepo, my biggest one is still below 20 packages and I use the same version for all packages (not independent). I assume that you are using the independent mode which is why you want less changes detected (probably make sense with such a large mono). So anyway, I would still prefer a flag to avoid possible surprises for some, though I know this would involve more code change, it's a safer approach to avoid surprises |
@dlueth so I copied your code and gave it a try and wanted to see if any unit tests failed and we sure do have some failures in regards to that predicate file (because we have 2 |
@ghiscoding Ah, you are right. Find is Unix/Linux/BSD/MacOS only. Have not worked with Windows for a looooong time so completely forgot that. What the find command does is it looks for Although this is most likely the "fastest" way it is not the only way - and, as you mentioned, not working on Windows :( 2 Options:
|
@ghiscoding I will prepare a glob snippet for you, seems to better fit than globby |
OK, as globby is already present I implemented it utilizing it. You need to add In addition, replace the complete
|
@dlueth I created a PR #495 with the information you provided, could you please review it. I'm also not sure if the flag name is a good name (it could be changed), let me know if I misunderstood anything or if the docs I wrote is incorrect or is missing something. The new opt-in option is the following lerna version --exclude-subpackages |
@ghiscoding Thanks, a lot of work you had to do! I reviewed as far as I could and commented where necessary. I think |
@dlueth thanks for the review, I'll rename it, however I think you might have forgot to finish the review because I don't see any comments in the PR |
@ghiscoding Yep, sorry - forgot to submit the review... Still a bit lazy at 6:12 in the morning XD |
and it's time for me to go to bed, it's past midnight here in Eastern Canada 😉 |
@ghiscoding hope it's OK to reuse this issue instead of opening a new one for one related question left: Do you happen to know if it is already possible to pass in/through If so that would be absolutely awesome. If not, would it be possible make this a public flag as well? |
@dlueth in lerna-lite/packages/core/src/utils/collect-updates/collect-updates.ts Lines 98 to 102 in dfbe1eb
and lerna-lite/packages/core/src/utils/collect-updates/collect-updates.ts Lines 117 to 121 in dfbe1eb
then used in lerna-lite/packages/core/src/utils/collect-updates/lib/collect-packages.ts Lines 28 to 30 in dfbe1eb
So after looking at all that code, which came from Lerna, it does seem to be implemented. Have you tried it? Should I wait to prepare a release? |
@ghiscoding nö need to wait with a release for this. But yes, I saw it implemented there but is it settable via a Lerna version CLI flag? |
@dlueth |
@ghiscoding so I need to install the optional filter package and I should be able to use this flag with lerna version? I wonder because docs nowhere state it can be used with version command |
no it's a subpackage used by the core, it's installed by default and there's nothing for you to do to take advantage of it. I simply sent you the link to provide you the docs, which seems to be the only docs available, I believe it is global and can be used by any Lerna command (version, publish, run, ...). |
@ghiscoding thx, will check that tomorrow and report back. That would be perfect for our usecase ;) |
@dlueth so this might not work because like I found in the post just before it wasn't part of the version & publish version, but just the sake of trying it out, I added |
@ghiscoding Release with the new flag works as perfectly fine & as expected. Regarding the I can confirm the CLI flag reaches the code but it has some quirks when used with |
not surprising that there's quirks around the usage of that flag since it wasn't specifically added to the lerna version command. If you're not using Also just as a reminder, I wrote it on the main readme but in case you didn't see... my main purpose when creating Lerna-Lite fork was to update all deps (when Lerna was no longer supported a year ago), make it more modular and add couple of features like the |
@ghiscoding many thanks for all your efforts! In our case it seems to be sufficient to simply use "*" instead of a version for NPM. We do not need to publish to a registry luckily ;) |
@ghiscoding I did, yes. No need to roll it back but I am not 100% it works as it should in this case. Still testing |
@ghiscoding OK, I think I have finished my testing but results are highly specific for our Project/Monorepo:
The trick I used so far, as NPM does not support We are currently running What happens now is that ... but it fails hard whenever you do a new release afterwards and there are any other versions than So i wrote a post-script that resets all versions to |
Whenever I go with multiple, I now always choose pnpm and I don't remember or know how Lerna deals with lerna-lite/packages/version/src/version-command.ts Lines 633 to 644 in 7dd260f
in this process it also pushes git changes and creates git tags, then when the user is ready to publish it goes and call the same method to mutate back the package to its original version value lerna-lite/packages/publish/src/publish-command.ts Lines 676 to 709 in 7dd260f
I'm not sure if similar mutations are done with I most say, I don't fully understand why you're calling lerna version if you're not publishing? It would be helpful to see your expected workflow. Are you using it just to create git tags of version at that point in time, or is it for other reasons? Have you also searched on the original Lerna issues, I often search there to see if anyone posted anything similar with possible solutions. |
@ghiscoding I would say that our need is really special but I thought, and you seem to agree, that Lerna seems to be doing something similar under the hood ;) We do not need to publish because the complete project is the monorepo. There is absolutely no need to ever use any of it's packages from somewhere else. But, what we need is the relationship between packages and, even more important, versions. We do write ES6 packages with static imports but transform them, via Rollup, to a format that is a bit similar to AMD. So what is written as a static import becomes a dynamic dependency (if from the monorepo) and gets picked up by a loader in the frontend that loads it with its version and caches it in local storage for fastest reuse as possible. To further speed up the, in an AMD context, chain of step by step package resolution and dependency loading we have a lookup JSON included that contains every package, its version and all it's dependencies, recursively. Just to share the rough idea XD |
I still wish to see the workflow of the expected steps (1. bump version, 2. git tag, ....). Looking at Lerna's issue, I found these 2 comments which might be helpful (or not). |
Looking at the comments you linked I would presume that my current status is as close to these steps as we can get. Adding no git-tags via Lerna would mean we would have to re-implement it's logic of what actually changed. So it seems easier to read out and re-apply the tags Lerna added currently |
After trying with dry-run, it looks like I was wrong in the sense that it doesn't replace any dependencies with For the steps that you provided, which ones are working and which ones are you having problems with? |
If you use From the bullets above only 2. is actually not working for our case. The rest works just fine |
I'm afraid there isn't much more I can do at this point, the implementation of Personally with the issue you're having, I would give a try to pnpm |
@ghiscoding yeah, I think we will try out pnpm when we find some time as our needs are clearly a bit special and most likely out of scope regarding Lerna+ NPM. Thanks a thousand times for all your (awesome) efforts for such weird requirements ;) |
@ghiscoding I ended up removing Lerna completely. I refactored most of our scripts to run without Lerna over the last 2 weeks and the only thing left we needed was Lerna version anyway. Having had the base from refactoring the other scripts a minimal, but sufficient, replacement for our case took approx half a day extra |
oh ok, that's too bad you're not using anymore but if it simplifies your process then it's probably best for you.. and you can always use it on future project 😉 Cheers |
Clear and concise description of the problem
As a developer using Lerna-Lite I would love to have the possibility to work with nested packages in a way that changes to a
package B
being a subpackage ofpackage A
directory-wise do not lead to a version-change ofpackage A
onlerna version
purely due togit diff
but only ifpackage A
actaully depends onpackage B
. This example reflects our current development structure but produces many new, but unnecessary, versions.Suggested solution
Potential fix would be in
packages/core/src/utils/collect-updates/lib/make-diff-predicate.ts
. Replace the if-condition starting on line 65 with the following code:Alternative
It would also be possible to exclude subpackages after getting the diff via packages like read-pkg-up but that feels suboptimal due to the overhead for diffing and necessary filesystem operations implied.
Additional context
No response
Validations
The text was updated successfully, but these errors were encountered: