[Feature]: `yarn workspaces focus` should make all subsequent operations "focused"
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 8.1k
- Forks
- 1.3k
- PR merge metrics
- No merged PRs in 30d
Description
- I'd be willing to implement this feature
- This feature can already be implemented through a plugin
Describe the user story
Essentially https://twitter.com/VLecrubier/status/1301620546589913088.
Our current workflow when building a module/artifact on CI (with yarn v1, fwiw) is:
- a custom script that does
yarn workspaces infoand finds a package and its dependencies - it then runsrm -rfon all other packages and runsyarnin root (so essentiallyyarn workspaces focus, but will modify lockfile) - we then use
oaoto runyarn buildin all packages which has that command following the inverse dependency tree etc.
That last step is still needed if we were to migrate to Yarn v2 as we cannot do yarn workspaces foreach -pt run build as yarn will run that in all workspaces rather than the ones focus has... focused.
Describe the solution you'd like
After running yarn workspace focus all further yarn workspaces * commands should respect the fact we're currently "focused" and not do work on all workspaces. I'm specifically after yarn workspaces foreach run, but I think other commands like yarn why or yarn up should also only operate on the "focused" workspace and its dependencies.
As an aside, for this I think it'd make more sense if focus just "focused" without installing anything. So yarn workspaces focus foobar would just set some somewhere in .yarn/ I guess, and when we then run yarn install afterwards, only foobar (and its dependencies) would be "installed".
Describe the drawbacks of your solution
Not sure... It would probably mean more forking of logic ("all workspaces" vs "some workspaces") in multiple places, but I don't think there's any drawbacks beyond the implementation aspect of it?
Describe alternatives you've considered
Not use yarn workspaces focus at all as it doesn't work for our use cases and keep using a manual approach.
Additional context
Happy to chat on Discord about what other stuff we do on CI to build if applicable.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the command entry points for yarn workspaces focus and yarn workspaces foreach run, then inspect how workspace selection is represented. Done means subsequent workspace operations consistently honor the focused workspace and its dependencies, including the requested foreach behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- nodejs, typescript
- Domain
- cli, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100