-
Notifications
You must be signed in to change notification settings - Fork 592
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
[rush] Add "suppressStartupBanner" flag for CLI actions #2777
base: main
Are you sure you want to change the base?
Conversation
@@ -23,6 +23,7 @@ export class CheckAction extends BaseRushAction { | |||
"Checks each project's package.json files and ensures that all dependencies are of the " + | |||
'same version throughout the repository.', | |||
safeForSimultaneousRushProcesses: true, | |||
suppressStartupBanner: true, |
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.
You think this command should never print the startup banner?
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.
The startup banner is noise that reduces the clarity of the error. Ideally we'd implement alternative reporters for CI such that we could, e.g. use Azure DevOps logging commands to specify exactly the problem (instead of just exiting with code 1), but that's not really in scope here. Currently rush check
having the startup banner is a nuisance.
@@ -34,7 +34,8 @@ export class ListAction extends BaseRushAction { | |||
'List package names, and optionally version (--version) and ' + | |||
'path (--path) or full path (--full-path), for projects in the ' + | |||
'current rush config.', | |||
parser | |||
parser, | |||
suppressStartupBanner: true |
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.
Can the startup banner only be suppressed if the --json
flag is passed?
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.
I'd like to be able to use rush list --to PROJECT | ForEach-Object { # Do stuff }
in PowerShell, instead of rush list --to PROJECT --json | ConvertFrom-Json | % { # Do stuff with $_.name }
. More importantly, bash or batch scripts can work well with the former but not the latter.
Much of the intent of this feature was to avoid the "only suppressed if --json flag passed" logic and make it be the entire command having that decision.
Was talking with @octogonz about this feature yesterday. If I were to list out some requirements, I think I'd include:
And then some nice-to-haves:
The reason I think (1) and (2) are more important than (5) and (6) is because a parameter is able to show intent -- "suppressing a banner" is a little arbitrary, whereas a parameter like If we assume that all Rush commands are by default intended for humans, then we probably shouldn't suppress banners for any built-in commands... I would make the same argument for user commands, except that forcing a user to add a parameter to show intent requires them to make a custom parameter, add associatedCommands, to it, etc., which seems needlessly pedantic. So we probably should support user-created "always suppressed" commands. One possible suggestion for the interface could be to add a section to {
"suppressBannerOutput": {
/**
* If any of these parameters are specified on the command line for any command, startup banners
* will automatically be suppressed.
*/
"parameters": ["--json"],
/**
* These commands will automatically suppress the startup banner when run.
*/
"commands": ["my-custom-command"]
}
} (This would allow the user to suppress startup banners for In the future, we might even add an |
I'm not sure I like the name Also, JSON and CSV seem like special "recommended" formats:
(Maybe YAML could also be lumped in there, if you want comments in your output. Although none of the popular NPM packages for writing YAML seem to actually support comments.) So perhaps all the other non-recommended formats could be grouped under a single parameter like |
BTW @elliot-nelson in this discussion we've been assuming that the motivation for suppressing the banner is to enable deserialization of the output. A different motivation would be if someone simply finds the banners to be too noisy. So we could imagine a And speaking of guarantees: If the tool aborts with an error, ideally |
@octogonz , @elliot-nelson , I'm pretty much at the point where I would rather only display the banner when |
@dmichon-msft @octogonz I guess I'd hate to lose the "normal" banners all at once just because it's too complicated to hide them some of the time. Maybe the first step is a lot simpler than either PR idea -- just a "rush --quiet list"? That seems like it satisfies almost all the would-be script and pipeline uses of rush commands, including built in and custom. And would probably be quite easy to do (most of the work is in this PR). |
I don't want look too pushy, but just in case it might be useful, there is an API from Hope it helps. |
Summary
Adds an option
suppressStartupBanner
that can be specified incommand-line.json
to skip logging of Rush's startup banner, e.g. if the command output is meant to be parsed as JSON or piped to some other tool.Details
Changes the startup banner to be written to a string and defer printing to command line action invocation.
Suppresses logging from
install-run-rush.ts
unless--debug
or-d
are passed.Fixes #2607
How it was tested
Ran various local commands and verified presence or absence of the banner.