Skip to content
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

[Feature] Workspaces foreach namespace or glob support #828

Closed
1 of 2 tasks
joshmeads opened this issue Jan 28, 2020 · 5 comments · Fixed by #1498
Closed
1 of 2 tasks

[Feature] Workspaces foreach namespace or glob support #828

joshmeads opened this issue Jan 28, 2020 · 5 comments · Fixed by #1498
Labels
enhancement New feature or request

Comments

@joshmeads
Copy link

joshmeads commented Jan 28, 2020

  • I'd be willing to implement this feature
  • This feature can already be implemented through a plugin

Describe the user story

Given an application structure such as:

workspaces: [
  "packages/*",
  "services/*",
  "utils/*"
]

You may want to run a command on all subsets. eg. yarn workspaces foreach --include services/* run start. Currently, it appears the include flag only works with direct names eg. yarn workspaces foreach --include api <command>

Describe the solution you'd like

  • Allow glob patterns in the --include/exclude flag.
  • Allow certain workspaces such as yarn workspaces foreach --include-workspace services <command>. Similarly for --exclude-workspace

Command names are of course open to discussion.

Describe the drawbacks of your solution

Not sure. Open to feedback.

Describe alternatives you've considered

  • Passing each manually into the script.
  • Use lerna via lerna run with filter glob patterns.

Additional context

Previously discussed for Yarn 1 here:

@joshmeads joshmeads added the enhancement New feature or request label Jan 28, 2020
@arcanis
Copy link
Member

arcanis commented Jan 28, 2020

I'd tend to say that the current feature set is low-level enough that you can implement the behaviour you're looking for directly within your scripts. This is for example what we do in ours.

@joshmeads
Copy link
Author

@arcanis I'd agree with you that it's low level enough to implement this with scripts. Given the previous discussions around yarn 1, and given the push towards DX friendly workspaces, I thought it would be a useful addition to the toolset. The glob pattern primarily. I can look into the code and see if I can work on implementation if it is something people other than myself want, otherwise as you said - scripts are fine. 😄

@andrewmclagan
Copy link

It seems an incredibly common workflow? I'd suggest a core implementation would be handy to allot of teams.

@NixBiks
Copy link

NixBiks commented Oct 11, 2021

Sorry for bringing this up again but whats the syntax to do something yarn workspaces foreach --include services/* run start?

@merceyz
Copy link
Member

merceyz commented Oct 28, 2021

--include takes patterns of workspace names, not their paths.
To provide an example this would run on all workspaces with a name matching the provided pattern

yarn workspaces foreach --include "@yarnpkg/plugin-*" run build

--include #0 An array of glob pattern idents; only matching workspaces will be traversed
https://yarnpkg.com/cli/workspaces/foreach#options-include%20%230

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants