Add projectRoot option to config file
See original GitHub issueAffected Packages
cli config
Problem
Our monorepo gets placed not in the project root, but in a subfolder (call it @my-awesome-project), like this:
- @my-awesome-project/
- packages/
- package-1/
- package.json # @my-awesome-project/package-1
- package-2/
- package.json # @my-awesome-project/package-2
- ...etc
- package.json
- pnpm-workspace.yaml
- demo/
- src/
- package.json # a test React project that helps in the package development. Uses the packages from `@my-awesome-project`
- package.json # this is just for maintenance reasons, but must be kept
The reason of this approach is to be able to keep the demo test project in the same repo (but not being part of the workspace in @my-awesome-project), and completely separate the node_modules folders of @my-awesome-project and demo.
If I install changesets in the @my-awesome-project, it works as expected, except of the .changeset gets created in that folder (and not the root), and the changesets-bot cannot find it.
If I install changesets in the project root, it won’t find the @my-awesome-project and its packages.
Am I missing something? Is there any other solution?
Proposed solution
I think that it could be a viable solution to add a projectRoot
option to the config.json, where the user can set the path to the root folder of the workspace ("."
by default, and "./@my-awesome-project"
in my case), and use path.join(cwd, config.projectRoot)
instead of cwd
in all internal getPackages()
calls.
Possibly related to #545
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:5 (2 by maintainers)
Top GitHub Comments
@bencergazda sorry for the late reply - the last months were really busy for me (well, they still are) and I’m only digging through issues here now. Trying to respond as much as I can and maybe pick some stuff up.
I recognize your problem described here but I wonder if maybe instead of adding a new option your first intuition was right?
It seems that maybe the true issue here is in the implementation of the
changesets-bot
? Maybe it should not assume that the.changeset
directory is at the root of the project? Because what if you’d have multiple changeset “roots” in your huge monorepo? By making the detection smarter there we could cover a more broad set of possible monorepo structures.Sure thing - take your time. I probably won’t go into this (but could give you pointers on how to do this, review the PR, and so on) because the priority of this seems rather low at the moment. There are just more pressing issues to handle that affect more people.