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

fix(workspace-tools): remove message prefix from workspaces foreach #5152

Merged
merged 7 commits into from
Dec 29, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .yarn/versions/4aa0961e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
releases:
"@yarnpkg/core": patch
qrohlf marked this conversation as resolved.
Show resolved Hide resolved
"@yarnpkg/plugin-workspace-tools": patch
merceyz marked this conversation as resolved.
Show resolved Hide resolved

declined:
- "@yarnpkg/plugin-compat"
- "@yarnpkg/plugin-constraints"
- "@yarnpkg/plugin-dlx"
- "@yarnpkg/plugin-essentials"
- "@yarnpkg/plugin-exec"
- "@yarnpkg/plugin-file"
- "@yarnpkg/plugin-git"
- "@yarnpkg/plugin-github"
- "@yarnpkg/plugin-http"
- "@yarnpkg/plugin-init"
- "@yarnpkg/plugin-interactive-tools"
- "@yarnpkg/plugin-link"
- "@yarnpkg/plugin-nm"
- "@yarnpkg/plugin-npm"
- "@yarnpkg/plugin-npm-cli"
- "@yarnpkg/plugin-pack"
- "@yarnpkg/plugin-patch"
- "@yarnpkg/plugin-pnp"
- "@yarnpkg/plugin-pnpm"
- "@yarnpkg/plugin-stage"
- "@yarnpkg/plugin-typescript"
- "@yarnpkg/plugin-version"
- "@yarnpkg/builder"
- "@yarnpkg/cli"
- "@yarnpkg/doctor"
- "@yarnpkg/extensions"
- "@yarnpkg/nm"
- "@yarnpkg/pnpify"
- "@yarnpkg/sdks"
8 changes: 7 additions & 1 deletion packages/plugin-workspace-tools/sources/commands/foreach.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,15 @@ export default class WorkspacesForeachCommand extends BaseCommand {

let abortNextCommands = false;

// get the configuration again but override messageNames so that we don't double-nest message names
// in the foreach output stream if they're enabled.
const configWithoutMessageNames = await Configuration.find(this.context.cwd, this.context.plugins);
configWithoutMessageNames.values.set(`enableMessageNames`, false);
qrohlf marked this conversation as resolved.
Show resolved Hide resolved

const report = await StreamReport.start({
configuration,
configuration: configWithoutMessageNames,
stdout: this.context.stdout,
includeCaret: false,
}, async report => {
const runCommand = async (workspace: Workspace, {commandIndex}: {commandIndex: number}) => {
if (abortNextCommands)
Expand Down
7 changes: 6 additions & 1 deletion packages/yarnpkg-core/sources/StreamReport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export type StreamReportOptions = {
includeInfos?: boolean;
includeLogs?: boolean;
includeWarnings?: boolean;
includeCaret?: boolean;
json?: boolean;
stdout: Writable;
};
Expand Down Expand Up @@ -142,6 +143,7 @@ export class StreamReport extends Report {
}

private configuration: Configuration;
private includeCaret: boolean;
private includeFooter: boolean;
private includeInfos: boolean;
private includeWarnings: boolean;
Expand Down Expand Up @@ -184,6 +186,7 @@ export class StreamReport extends Report {
configuration,
stdout,
json = false,
includeCaret = true,
includeFooter = true,
includeLogs = !json,
includeInfos = includeLogs,
Expand All @@ -198,6 +201,7 @@ export class StreamReport extends Report {
this.configuration = configuration;
this.forgettableBufferSize = forgettableBufferSize;
this.forgettableNames = new Set([...forgettableNames, ...BASE_FORGETTABLE_NAMES]);
this.includeCaret = includeCaret;
this.includeFooter = includeFooter;
this.includeInfos = includeInfos;
this.includeWarnings = includeWarnings;
Expand Down Expand Up @@ -375,7 +379,8 @@ export class StreamReport extends Report {
const formattedName = this.formatNameWithHyperlink(name);
const prefix = formattedName ? `${formattedName}: ` : ``;

const message = `${formatUtils.pretty(this.configuration, `➤`, `blueBright`)} ${prefix}${this.formatIndent()}${text}`;
const caret = this.includeCaret ? `${formatUtils.pretty(this.configuration, `➤`, `blueBright`)} ` : ``;
const message = `${caret}${prefix}${this.formatIndent()}${text}`;

if (!this.json) {
if (this.forgettableNames.has(name)) {
Expand Down