Allow Changesets to be executed from non-root directories#1806
Conversation
🦋 Changeset detectedLatest commit: 204a570 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1806 +/- ##
==========================================
+ Coverage 81.74% 81.91% +0.17%
==========================================
Files 55 55
Lines 2355 2356 +1
Branches 705 705
==========================================
+ Hits 1925 1930 +5
+ Misses 425 421 -4
Partials 5 5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
5aa603c to
4fbd2bd
Compare
…-find-changeset-root-folder
…-find-changeset-root-folder
…#1806) * add find-root package * find root and use it across commands * import the package dinamically to avoid the resolution errors? * add some types and expect the error from module resolution * changeset * add tests * enable esm in jest * enable it in ci too * test no changeset folder * test rest of commands * do it better * missing line * assert the error thrown is actually a lack of changeset folder * revert redundant changes * simplify * fix * tweak * tweak * fix * fix * tweak tests * fix test * Apply suggestion from @Andarist --------- Co-authored-by: Mateusz Burzyński <[email protected]>
|
If the .changeset directory is included in the execution directory, it will still look up to the parent directory until the most root .changeset directory is found, which will cause the configuration of the .changeset folder in my subdirectory to be invalidated |
|
@xccxcs please raise a new issue describing your directory structure in more detail |
Context
Allows changesets to be executed from deeply nested folders within a monorepo that has the .changeset folder at the root of it.
A common example of this is a monorepo with two packages: frontend and backend. These packages might have different scripts that people run within those folders. When they finish some piece of work, they have to change directories back to the root to create a changeset.
This change helps exactly with that, but also, with most of the changeset commands.
Implementation details
I've added a new package to determine the root of the project: @manypkg/find-root. This package gets dynamically imported when the current directory doesn't have a changeset folder. Then, it will try to determine if the root has a changeset folder or not. Otherwise the same behavior as always executes, which is throwing an error.
Questions/Unknowns
The new package is an ES module and therefore I've had some issues using it here, in terms of typings, execution, and testing.
My question is, are we ok with this? I'm open to other ideas or suggestions.
fixes #545
fixes #1824