From 0c20bca44d57bb660fc117f7e16672b7c6416331 Mon Sep 17 00:00:00 2001 From: Basix Date: Wed, 21 Aug 2024 17:37:37 +0900 Subject: [PATCH 1/5] Add warnings option for `explain peer-requirements` Fixes #6465. --- .../sources/commands/explain/peerRequirements.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/plugin-essentials/sources/commands/explain/peerRequirements.ts b/packages/plugin-essentials/sources/commands/explain/peerRequirements.ts index 6455d31ad924..15e039e1a6d4 100644 --- a/packages/plugin-essentials/sources/commands/explain/peerRequirements.ts +++ b/packages/plugin-essentials/sources/commands/explain/peerRequirements.ts @@ -38,6 +38,11 @@ export default class ExplainPeerRequirementsCommand extends BaseCommand { ]), }); + warnings = Option.Boolean(`--warnings`, { + description: `Only show umnet peer requirements.`, + required: false, + }); + async execute() { const configuration = await Configuration.find(this.context.cwd, this.context.plugins); const {project} = await Project.find(configuration, this.context.cwd); @@ -55,6 +60,7 @@ export default class ExplainPeerRequirementsCommand extends BaseCommand { } else { return await explainPeerRequirements(project, { stdout: this.context.stdout, + onlyWarnings: this.warnings ?? false, }); } } @@ -168,7 +174,7 @@ export async function explainPeerRequirement(peerRequirementsHash: string, proje return report.exitCode(); } -export async function explainPeerRequirements(project: Project, opts: {stdout: Writable}) { +export async function explainPeerRequirements(project: Project, opts: {stdout: Writable, onlyWarnings: boolean}) { const report = await StreamReport.start({ configuration: project.configuration, stdout: opts.stdout, @@ -190,6 +196,8 @@ export async function explainPeerRequirements(project: Project, opts: {stdout: W return warning.hash === peerRequirement.hash; }); + if (!warning && opts.onlyWarnings) continue; + const allRequests = [...structUtils.allPeerRequests(peerRequirement)]; let andOthers; if (allRequests.length > 2) From 427233f0b3d72f324b8e90a6fa9b2832f6a8cbb4 Mon Sep 17 00:00:00 2001 From: Basix Date: Wed, 21 Aug 2024 17:51:10 +0900 Subject: [PATCH 2/5] Add version file --- .yarn/versions/4e0a01ef.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .yarn/versions/4e0a01ef.yml diff --git a/.yarn/versions/4e0a01ef.yml b/.yarn/versions/4e0a01ef.yml new file mode 100644 index 000000000000..54642a287609 --- /dev/null +++ b/.yarn/versions/4e0a01ef.yml @@ -0,0 +1,23 @@ +releases: + "@yarnpkg/cli": minor + "@yarnpkg/plugin-essentials": minor + +declined: + - "@yarnpkg/plugin-compat" + - "@yarnpkg/plugin-constraints" + - "@yarnpkg/plugin-dlx" + - "@yarnpkg/plugin-init" + - "@yarnpkg/plugin-interactive-tools" + - "@yarnpkg/plugin-nm" + - "@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/plugin-workspace-tools" + - "@yarnpkg/builder" + - "@yarnpkg/core" + - "@yarnpkg/doctor" From 1a84d42c8400399c6465970c12743cb5c35f7e9e Mon Sep 17 00:00:00 2001 From: Basix Date: Wed, 21 Aug 2024 20:07:53 +0900 Subject: [PATCH 3/5] Set default value inside flag definition --- .../sources/commands/explain/peerRequirements.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/plugin-essentials/sources/commands/explain/peerRequirements.ts b/packages/plugin-essentials/sources/commands/explain/peerRequirements.ts index 15e039e1a6d4..b2b6c39c0dc7 100644 --- a/packages/plugin-essentials/sources/commands/explain/peerRequirements.ts +++ b/packages/plugin-essentials/sources/commands/explain/peerRequirements.ts @@ -38,9 +38,8 @@ export default class ExplainPeerRequirementsCommand extends BaseCommand { ]), }); - warnings = Option.Boolean(`--warnings`, { + warnings = Option.Boolean(`--warnings`, false, { description: `Only show umnet peer requirements.`, - required: false, }); async execute() { @@ -60,7 +59,7 @@ export default class ExplainPeerRequirementsCommand extends BaseCommand { } else { return await explainPeerRequirements(project, { stdout: this.context.stdout, - onlyWarnings: this.warnings ?? false, + onlyWarnings: this.warnings, }); } } From c092d398542a82453360778de9e8516bbe39c5b7 Mon Sep 17 00:00:00 2001 From: Clement Yan Date: Fri, 23 Aug 2024 13:59:42 +0800 Subject: [PATCH 4/5] feat: Add --warning flag to peer warnings CTA --- packages/yarnpkg-core/sources/Project.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/yarnpkg-core/sources/Project.ts b/packages/yarnpkg-core/sources/Project.ts index 0cdeed944125..f2061c1f5057 100644 --- a/packages/yarnpkg-core/sources/Project.ts +++ b/packages/yarnpkg-core/sources/Project.ts @@ -2779,6 +2779,6 @@ function emitPeerDependencyWarnings(project: Project, report: Report) { }); if (hasTransitiveWarnings) { - report.reportWarning(MessageName.EXPLAIN_PEER_DEPENDENCIES_CTA, `Some peer dependencies are incorrectly met by dependencies; run ${formatUtils.pretty(project.configuration, `yarn explain peer-requirements`, formatUtils.Type.CODE)} for details.`); + report.reportWarning(MessageName.EXPLAIN_PEER_DEPENDENCIES_CTA, `Some peer dependencies are incorrectly met by dependencies; run ${formatUtils.pretty(project.configuration, `yarn explain peer-requirements --warnings`, formatUtils.Type.CODE)} for details.`); } } From 48c920e433d5e3b5e3c877d30eb7528f8ee8d8c7 Mon Sep 17 00:00:00 2001 From: Basix Date: Fri, 27 Sep 2024 04:54:23 +0900 Subject: [PATCH 5/5] Update version file --- .yarn/versions/4e0a01ef.yml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/.yarn/versions/4e0a01ef.yml b/.yarn/versions/4e0a01ef.yml index 54642a287609..b3aacffd1f6d 100644 --- a/.yarn/versions/4e0a01ef.yml +++ b/.yarn/versions/4e0a01ef.yml @@ -1,14 +1,22 @@ releases: "@yarnpkg/cli": minor + "@yarnpkg/core": minor "@yarnpkg/plugin-essentials": minor declined: - "@yarnpkg/plugin-compat" - "@yarnpkg/plugin-constraints" - "@yarnpkg/plugin-dlx" + - "@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" @@ -19,5 +27,8 @@ declined: - "@yarnpkg/plugin-version" - "@yarnpkg/plugin-workspace-tools" - "@yarnpkg/builder" - - "@yarnpkg/core" - "@yarnpkg/doctor" + - "@yarnpkg/extensions" + - "@yarnpkg/nm" + - "@yarnpkg/pnpify" + - "@yarnpkg/sdks"