Repository navigation
RFC for running workspace commands from root - #83
Conversation
BYK
left a comment
There was a problem hiding this comment.
Great start, thank you! Pinging @bestander for comments. and also @arcanis
| * `yarn workspaces list` | ||
| * `yarn workspaces run <command>` | ||
|
|
||
| By introducing `workpaces` command, it brings a modular approach from the CLI's perspective. |
There was a problem hiding this comment.
Possible additions:
yarn workspaces add : This would create the folder if it doesn't exist and make sure it is included in the top-level workspaces config.
yarn workspaces remove : Remove a specific workspace from the config and optionally delete the folder if -D flag is passed.
There was a problem hiding this comment.
For the yarn workspaces add, shouldn't we pass the workspace name too?
There was a problem hiding this comment.
I believe yarn workspaces run is already implemented via https://github.com/yarnpkg/rfcs/blob/master/implemented/0000-workspaces-command.md#yarn-workspace-workspace-name-command-name-?
|
|
||
| ## `yarn workspaces list` | ||
|
|
||
| This command lists out the package names inside that workspace. In the case of multiple workspace configuration, we'll need to pass the workspace name like `yarn workspaces <workspace_name> list`. By defaut, when no workspace name is not given, it'll pick the first workspace name from the root package.json. |
There was a problem hiding this comment.
Can you clarify what you mean by a multi-workspace config?
There was a problem hiding this comment.
Seems more logical to either list all packages for all workspaces or fail with error.
Picking first workspace is strange and not really useful
There was a problem hiding this comment.
+1 to listing all of the packages in all the workspaces. That would also allow for easy "filtering" of workspaces if you only want to list a specific few of them, like:
yarn workspaces --filter workspace-a list
...or similar. (I think something like --filter functionality would ideally be available on all the workspaces commands.)
|
This feature could be useful to help clean files from individual packages in workspace, such as Some related issues from non-workspace yarn are: |
|
What are other peoples' thoughts on being able to execute a particular package's script in isolation? I.e If |
|
|
||
| ## `yarn workspace remove <workspace_name> --opts` | ||
|
|
||
| Remove a specific workspace from the config. And by passing `-D` as an option, it'll delete the folder. |
There was a problem hiding this comment.
For simplicity I would focus only on list/run commands.
Add/delete are less utility and more like sugar on top of editing package.json and adding/removing folders.
Also I don't like inconsistency workspaces/workspace for those commands
And in Yarn we prefer using explicit flags and not shorts --delete-folder would be more consistent with other commands
There was a problem hiding this comment.
On a second thought, yeah, you're right. This doesn't gives any extra convenience. Removed!
|
@James-E-Adams, seems logical however it can be achieved with a |
|
@giridharangm, sorry for a delay in review. |
|
No worries @bestander . Me too, was packed with tasks (I'm a full-time dev in a private firm). I'm in the middle of a production release, but I'll update the docs as per your review ASAP. |
|
No rush, just ping whenever you are ready |
|
|
||
| This command will execute the specified command in all the packages under the workspace. Before we run the scripts, it should make sure that all packages has the script specified in the package.json. Otherwise, it should throw an error specifying which pacakge is missing that script. | ||
|
|
||
| Just like the `list` command, by default, it'll select the first workspace in case of no workspace name is provided. |
There was a problem hiding this comment.
I think this should again run the command in all workspaces, not just the first one. And then later a "filtering" mechanism can be added to restrict further. But otherwise it seems to arbitrary.
There was a problem hiding this comment.
I think, like @bestander said earlier, if we want to execute a command in a specific workspace, it's better to cd to that package and yarn run.
I've updated this command to execute all in all workspaces.
|
@bestander I've made some few change. Could you please have a look? |
|
@bestander would you reconsider the ability to offer filtering to run commands in specific subsets of packages? I think there are three usage patterns for this:
I agree that (3) can be easily solved by My use case for (3) is having workspaces split up into workspaces: [
'services/*',
'utils/*',
]Which allows me to keep things more organized, and then for example I could run build watchers across all workspaces, but only run server-starting commands in the |
|
To get the ball rolling let's merge this one. |
|
@ianstormtaylor, sure, can you send a PR for the same file with the proposed change? |
|
Just to add my 2¢... I personally think this is a great idea, and will certainly help a lot when dealing with a monorepo. I also can't think of anything that this change would "break" in current functionality, which is always good! Lerna is fantastic and all, but not all monorepo projects need/should to be published to NPM. We're currently investigating using monorepos to hold a number of SPAs that are all for a given "project". So for CI/CD integration this would be hugely useful as well as for local development. |

Redirected from here
It would be great if we have a single command to execute a package script for all the packages under a workspace.