[rush] --except selector
I think with tag selectors there's value in just --except selector when building. For example, I could run rush build --except tag:app to build everything, except stuff that will be run in dev/watch mode anyway.
Currently all selectors are additive. By its nature, --except is a subtraction, unless you mean that --except tag:app is "invert --only tag:app". The main reason we don't have any selectors of this nature is that right now there is no defined order of precedence to application of selectors to the project selection. In the implementation, there is an order, but only insofar as is necessary to efficiently compute the result with the minimum number of distinct operations; any ordering of applying the current selectors would produce the same result.
If defining --except, this needs details on how it is expected to interact with --to, --from, --only, etc. A true subtraction would operate last, which is doable, but may produce unexpected results if used to remove a project that is consumed by other projects.
Well, my personal expectation would be to get everything selected by additive selectors, minus what's selected by --except.
E.g. with A -> B -> C rush build --to A --except -B means A and C. I guess should be marked as unsafe similarly to --impacted-by?
--only A --except A is an empty list, I guess, but that's probably already possible with git selectors.
In your rush build --except tag:app example, are you looking to build up to, but not including projects with tag app? Because you can currently do that with rush build --to-except tag:app.
Mmm... This is a good solution, yes, but there might be packages not in that chain. This is a hypothetical, but I imagine things like:
- Lambdas, which are a different kind of app that I wouldn't want tagged the same.
- Libraries that are a "dead end" - published, but not consumed by any app in the repo.
- Tooling that operates on the repo itself (like using
rush-libfor some complicated dependency manipulation en-bulke)
I ran into wanting something similar, where --to-except is not enough.
During a CI deployment, we want to call a npm script for all Applications to build an artifact (usually dockerfile, but could be any custom artifact defined by the project). We call this script in a matrix, so first we have to get a list of projects.
rush list --impacted-by git:origin/main gives us this list of projects. This contains all projects, including libs. These libs will and should never define this script. But are still part of the list result, and will be included in the matrix. So what we would like to do is:
rush list --impacted-by git:origin/main --only-version-policy Application --only-version-policy Frontend which should:
- list all projects based on
--impacted-byetc criteria - Filter it down to only any project with the given version policy.
In this case, as mentioned above, i don't really care about the dependency tree safety.