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-lib] Use pnpm-sync-lib logging APIs to customize the log message for pnpm-sync operations. #4594
[rush-lib] Use pnpm-sync-lib logging APIs to customize the log message for pnpm-sync operations. #4594
Conversation
d9a29be
to
28b521d
Compare
libraries/rush-lib/src/logic/installManager/WorkspaceInstallManager.ts
Outdated
Show resolved
Hide resolved
libraries/rush-lib/src/logic/installManager/WorkspaceInstallManager.ts
Outdated
Show resolved
Hide resolved
libraries/rush-lib/src/logic/operations/PnpmSyncCopyOperationPlugin.ts
Outdated
Show resolved
Hide resolved
libraries/rush-lib/src/logic/installManager/WorkspaceInstallManager.ts
Outdated
Show resolved
Hide resolved
libraries/rush-lib/src/logic/operations/PnpmSyncCopyOperationPlugin.ts
Outdated
Show resolved
Hide resolved
libraries/rush-lib/src/logic/operations/PnpmSyncCopyOperationPlugin.ts
Outdated
Show resolved
Hide resolved
@g-chao I've proposed some upstream changes that should to go in first: tiktok/pnpm-sync#20 The formatting improvements in d490478 rely on that new API. |
(details.fileCount === 1 ? 'file' : 'files') + | ||
` in ${Math.round(details.executionTimeInMs)} ms`; | ||
|
||
terminal.writeVerboseLine(Colorize.cyan(`pnpm-sync: `) + customMessage); |
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.
@g-chao For some reason this doesn't get printed with rush rebuild --verbose
. I didn't have time to investigate why.
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 checked a little bit, this seems a general bug. Basically, the --verbose
is not take effect for rush rebuild
command.
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.
It is because BaseInstallManager
creates its own ConsoleTerminalProvider
rather than reusing the existing one:
rushstack/libraries/rush-lib/src/logic/base/BaseInstallManager.ts
Lines 105 to 106 in e0de053
this._terminalProvider = new ConsoleTerminalProvider(); | |
this._terminal = new Terminal(this._terminalProvider); |
Seems this code was introduced in PR #3575 and was probably just an oversight.
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 top-level Rush terminal provider is created here:
rushstack/libraries/rush-lib/src/cli/RushCommandLineParser.ts
Lines 106 to 107 in e0de053
this._terminalProvider = new ConsoleTerminalProvider(); | |
this._terminal = new Terminal(this._terminalProvider); |
It sets verboseEnabled
based on the --debug
flag not the --verbose
flag:
rushstack/libraries/rush-lib/src/cli/RushCommandLineParser.ts
Lines 190 to 193 in e0de053
public async execute(args?: string[]): Promise<boolean> { | |
// debugParameter will be correctly parsed during super.execute(), so manually parse here. | |
this._terminalProvider.verboseEnabled = this._terminalProvider.debugEnabled = | |
process.argv.indexOf('--debug') >= 0; |
I wonder if this was a historical decision? Maybe because of this definition of --verbose
?
-v, --verbose Display the logs during the build, rather than just
displaying the build status summary
Or maybe because not all commands have the --verbose
flag?
I'll discuss it with some other maintainers today.
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.
In afffe7c I have wired up the terminal so that pnpm-sync
output is now printed with rush --debug
. To unblock this PR, we'll address the problem where --verbose
doesn't work in a followup PR.
3e53b1c
to
1d684c0
Compare
Summary
pnpm-sync-lib
now have a logMessage API which allow us to customize the log message printing behavior. Check here to see how it implemented.So, on Rush side, we can use this API to preventing unexpected log message and customize the log message format.
Details
Generally, there will be four types of message coming from
pnpm-sync-lib
, there are'info' | 'warning' | 'error' | 'verbose'
.info
message.error
andwarning
will be printed if there are errors or warnings.verbose
will be printed out if we pass--debug
or--vebose
flag to the rush commands.The
pnpm-sync-lib
also provides operation metadata in the API, so if don't want the message content frompnpm-sync-lib
, we can utilize that metadata to fully customize the log message on the Rush side.How it was tested
Manually tested on local.
Impacted documentation
N/A