-
Notifications
You must be signed in to change notification settings - Fork 147
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
update workspace-run-commands to more detail #87
Conversation
Overall I like the idea. Monorepos are becoming more popular so increasing the tooling around them makes sense. I also don't like that currently I still have a Can we include doing actual docs around workspaces to this RFC? The complete lack of docs is pretty frustrating. Even as a contributor I barely understand how they work. The existing Also in
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the improvements, it makes sense to include it in Yarn.
But it also calls into question how we should be referring to specific folders inside those directories. Is the packages folder a "workspace"? Or is each of the directories inside packages a "workspace"?
I don't have a strong opinion here.
To me referring workspaces by name from package.json seems intuitive and easy.
Anyway, I would trust you to chose the easiest solution to the open questions and send a PR.
If no one objects let's merge this PR next week |
I agree with @rally25rs, we need a champion to document Workspaces docs. |
@giridharangm, do you agree with the changes? @giridharangm, @ianstormtaylor are you ready to split the work and send PRs for those features? |
@bestander I realize this is not as helpful, but unfortunately I won't have the time to be able to submit a PR implementing this. I was just trying to be helpful by fleshing out the spec for the commands more, ensuring that we port some of the good aspects of Lerna, so that whoever does work on them has something more concrete to work from. Btw, another open question I think during implementation will be:
|
@ianstormtaylor, whatever help you can offer is appreciated.
Good question. |
Ah okay cool, I didn't realize there were also flags on the regular |
@ianstormtaylor thanks for the refinements. It looks great!. @bestander as much as I'd like to contribute, unfortunately, my hands are already full with multiple projects (both prod and dev) now. Besides, I don't have that much knowledge about yarn's code base and would require me to start from the ground up 😞 . I'm awfully sorry... |
Ok, let's merge it and look for champions |
Thank you all for the work. Just a short question: This RFC enforces that the script name is available in all packages when you run |
@donaldpipowitch Yes. it'll throw an error if the specified script is missing from any one of the packages. |
Skipping does sound like it could be useful to me too. @donaldpipowitch do you have a specific use case in mind? |
Hi! Sorry about the duplicate comment - just thought I'd mention (since the RFC does not list alternatives) this alternative: https://github.com/whoeverest/wsrun which was made specifically with yarn in mind. |
@ianstormtaylor IMHO, skipping would make unintentional side effects. I think it's better to let the user know that script doesn't exists in that package rather than silently (with a subtle warning) skips it. In a CI pipeline, what if the user forgot to add the Clearly, you guys are the pro(s) around here. So, what do you think? |
In Bolt we went with the flags |
@thejameskyle that sounds like a good way to go to me! Good point that the "workspace names" are always going to be valid paths anyways. I'd suggest using (I almost submitted this comment asking what does |
Yeah I'd be happy with We already have implementations for many of the pieces of this btw: |
Also this is Bolt's full API (some of which is unimplemented: # Run a command on your project package
bolt project/p [add/upgrade/remove/run/exec]
bolt project/p [script name]
# Run a command on a single workspace by its name
bolt workspace/w [workspace name] [add/upgrade/remove/run/exec/link/unlink]
bolt workspace/w [workspace name] [script name]
# Run a command on all of your workspaces
bolt workspaces/ws [list/add/upgrade/remove/run/exec] <...workspaces flags>
bolt workspaces/ws [script name] <...workspaces flags>
# Run a command on changed (with git) workspaces
bolt changed/c [list/install/run/exec] <...workspaces flags>
bolt changed/c [script name] <...workspaces flags> Anything that runs on multiple packages gets the workspaces flags |
@thejameskyle looks really good! |
It seems to become a habit while working with Lerna that many of our packages don't share some commands in all cases. Say we develop some React components in one monorepo and we add several examples as standalone applications showcasing these components, than the components maybe have a I'd be fine with some additional param like |
Both lerna run and oao run-script seems to be doing fine by just skipping missing scripts. This seems to be the community standard, so if yarn will not follow that, I think there should be a really good reason. I think the deviation from de facto standard should be motivated with a real-world scenario where skipping is really bad. I cannot think of one myself, but I can think of many real-world scenarios where skipping is the wanted behaviour (like the ones mentioned by @donaldpipowitch above), and I think that is why both lerna and oao went that route. If skipping is the more commonly wanted behaviour (which it seems to be given both lerna and oao does that and AFAIK none of their users has complained) then it follows that verifying that all packages have a script is the less common scenario. I would therefore propose that it would be better to have a switch like We have several monorepos and I have never felt the need to make sure that all packages have a certain script. The most common scripts we have are start, build, bundle, test, graphql-code-gen. Not all packages have those scripts. The only scenario I've seen mentioned in this discussion as a use-case for forcing all packages to have a script is running the test script in a CI pipeline mentioned by @giridharangm. In that scenario I think the |
Short question: Was it ever discussed alongside with this RFC to include meta data about the called processes/scripts as environment variables? Say you call |
👋 Happy to go with either though, Also, I see that it was suggested to add Yarns
The noise can be cleaned up pretty easily too
Just wanted to check if that was intended. I'd be happy to document it if so. |
cc @bestander from discussion in #83
This expands the existing
workspace-run-commands
to add more detail, and borrow a few more of the useful pieces of the functionality Lerna offers for running commands in workspaces.Specifically, it introduces:
yarn workspaces exec
.yarn workspaces run
.--parallel
.--concurrency
.--workspaces
flag.--packages
flag.Almost all of this functionality is based on Lerna's prior art, which has been super useful to managing monorepos in my experience—for all things from running tests, to building source, to automating other useful tasks.
One open question I have is how the Yarn team thinks about what a "workspace" is. In the
package.json
configuration, they're defined like:Which makes it simple to have multiple directories of workspaces, or to list individual top-level directories as workspaces too. This is super useful in my experience.
But it also calls into question how we should be referring to specific folders inside those directories. Is the
packages
folder a "workspace"? Or is each of the directories insidepackages
a "workspace"?This question becomes more important when trying to figure out how to let people filter things. Because it would be super useful to be able to do something like:
To restrict the command to run only in the
services/*
workspaces above.Lerna solves this by instead calling the configuration
packages
, and then only ever refers to packages by their name inpackage.json
instead, which simplifies things. It's possible that Yarn should follow their lead, and ignore the idea of a "workspace name", and only treat package names. (Which would eliminate the--workspaces
flag in this pull request.)In this sense, the
--packages
and--workspaces
flags are just strawmen. If there were to only be a single filtering mechanism, it could use--only
and--ignore
flags instead.That said, it feels slightly weird for Yarn to declare workspaces the way it does, and then not to let people filter by
services/*
orpackages/*
in this case. Thoughts?