From 8a5987212f625dad2f18b5ffcca550540967daea Mon Sep 17 00:00:00 2001 From: Chao Guo <10736839+g-chao@users.noreply.github.com> Date: Wed, 17 Jul 2024 13:38:56 -0700 Subject: [PATCH 1/7] fix: rush-pnpm patch-commit --- libraries/rush-lib/src/cli/RushPnpmCommandLineParser.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libraries/rush-lib/src/cli/RushPnpmCommandLineParser.ts b/libraries/rush-lib/src/cli/RushPnpmCommandLineParser.ts index 32a3c2d9131..fc95428af3f 100644 --- a/libraries/rush-lib/src/cli/RushPnpmCommandLineParser.ts +++ b/libraries/rush-lib/src/cli/RushPnpmCommandLineParser.ts @@ -452,11 +452,11 @@ export class RushPnpmCommandLineParser { const newGlobalPatchedDependencies: Record | undefined = commonPackageJson?.pnpm?.patchedDependencies; const currentGlobalPatchedDependencies: Record | undefined = - this._rushConfiguration.pnpmOptions.globalPatchedDependencies; + this._subspace.getPnpmOptions()?.globalPatchedDependencies; if (!objectsAreDeepEqual(currentGlobalPatchedDependencies, newGlobalPatchedDependencies)) { const commonTempPnpmPatchesFolder: string = `${subspaceTempFolder}/${RushConstants.pnpmPatchesFolderName}`; - const rushPnpmPatchesFolder: string = `${this._rushConfiguration.commonFolder}/${RushConstants.pnpmPatchesCommonFolderName}`; + const rushPnpmPatchesFolder: string = `${subspaceTempFolder}/${RushConstants.pnpmPatchesCommonFolderName}`; // Copy (or delete) common\temp\patches\ --> common\pnpm-patches\ if (FileSystem.exists(commonTempPnpmPatchesFolder)) { FileSystem.ensureEmptyFolder(rushPnpmPatchesFolder); @@ -477,14 +477,14 @@ export class RushPnpmCommandLineParser { } // Update patchedDependencies to pnpm configuration file - this._rushConfiguration.pnpmOptions.updateGlobalPatchedDependencies(newGlobalPatchedDependencies); + this._subspace.getPnpmOptions()?.updateGlobalPatchedDependencies(newGlobalPatchedDependencies); // Rerun installation to update await this._doRushUpdateAsync(); this._terminal.writeWarningLine( `Rush refreshed the ${RushConstants.pnpmConfigFilename}, shrinkwrap file and patch files under the ` + - `"${RushConstants.commonFolderName}/${RushConstants.pnpmPatchesCommonFolderName}" folder.\n` + + `"${commonTempPnpmPatchesFolder}" folder.\n` + ' Please commit this change to Git.' ); } From fb45e6a01b2a39e189e92dd1c7409d6012e69e62 Mon Sep 17 00:00:00 2001 From: Chao Guo <10736839+g-chao@users.noreply.github.com> Date: Wed, 17 Jul 2024 13:43:11 -0700 Subject: [PATCH 2/7] chore: rush change --- .../chao-fix-rush-pnpm-patch_2024-07-17-20-42.json | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 common/changes/@microsoft/rush/chao-fix-rush-pnpm-patch_2024-07-17-20-42.json diff --git a/common/changes/@microsoft/rush/chao-fix-rush-pnpm-patch_2024-07-17-20-42.json b/common/changes/@microsoft/rush/chao-fix-rush-pnpm-patch_2024-07-17-20-42.json new file mode 100644 index 00000000000..91870d5dc36 --- /dev/null +++ b/common/changes/@microsoft/rush/chao-fix-rush-pnpm-patch_2024-07-17-20-42.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@microsoft/rush", + "comment": "Fix an issue that `rush-pnpm patch-commit` can not generate correct pnpm-config.json file in subspace case", + "type": "none" + } + ], + "packageName": "@microsoft/rush" +} \ No newline at end of file From 512fa92dcf258f1726115eae788d98649b995663 Mon Sep 17 00:00:00 2001 From: Chao Guo <10736839+g-chao@users.noreply.github.com> Date: Wed, 17 Jul 2024 13:50:28 -0700 Subject: [PATCH 3/7] chore: address PR comments --- .../rush/chao-fix-rush-pnpm-patch_2024-07-17-20-42.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/changes/@microsoft/rush/chao-fix-rush-pnpm-patch_2024-07-17-20-42.json b/common/changes/@microsoft/rush/chao-fix-rush-pnpm-patch_2024-07-17-20-42.json index 91870d5dc36..45122ea2f25 100644 --- a/common/changes/@microsoft/rush/chao-fix-rush-pnpm-patch_2024-07-17-20-42.json +++ b/common/changes/@microsoft/rush/chao-fix-rush-pnpm-patch_2024-07-17-20-42.json @@ -2,7 +2,7 @@ "changes": [ { "packageName": "@microsoft/rush", - "comment": "Fix an issue that `rush-pnpm patch-commit` can not generate correct pnpm-config.json file in subspace case", + "comment": "Fix an issue where `rush-pnpm patch-commit` did not work correctly when subspaces are enabled.", "type": "none" } ], From 975a108f46984ed3e3e07a24594422fe984ca645 Mon Sep 17 00:00:00 2001 From: Chao Guo <10736839+g-chao@users.noreply.github.com> Date: Wed, 17 Jul 2024 14:00:39 -0700 Subject: [PATCH 4/7] fix: handle case where the pnpm-config.json not exists --- libraries/rush-lib/src/cli/RushPnpmCommandLineParser.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libraries/rush-lib/src/cli/RushPnpmCommandLineParser.ts b/libraries/rush-lib/src/cli/RushPnpmCommandLineParser.ts index fc95428af3f..768de26b286 100644 --- a/libraries/rush-lib/src/cli/RushPnpmCommandLineParser.ts +++ b/libraries/rush-lib/src/cli/RushPnpmCommandLineParser.ts @@ -446,6 +446,14 @@ export class RushPnpmCommandLineParser { switch (commandName) { case 'patch-commit': { + if (this._subspace.getPnpmOptions() === undefined) { + this._terminal.writeErrorLine( + `You are using rush-pnpm patch-commit command, but Rush could not find the pnpm-config.json for ${this._subspace.subspaceName} subspace! ` + + `Make sure the pnpm-config.json exists in ${this._subspace.getSubspaceConfigFolder()}` + ); + break; + } + // Example: "C:\MyRepo\common\temp\package.json" const commonPackageJsonFilename: string = `${subspaceTempFolder}/${FileConstants.PackageJson}`; const commonPackageJson: JsonObject = JsonFile.load(commonPackageJsonFilename); From b0dadb0ab43f52e1047b2be6df36b25068b71422 Mon Sep 17 00:00:00 2001 From: Chao Guo <10736839+g-chao@users.noreply.github.com> Date: Thu, 18 Jul 2024 14:04:21 -0700 Subject: [PATCH 5/7] chore: add comments --- libraries/rush-lib/src/cli/RushPnpmCommandLineParser.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libraries/rush-lib/src/cli/RushPnpmCommandLineParser.ts b/libraries/rush-lib/src/cli/RushPnpmCommandLineParser.ts index 768de26b286..ae25ae05e94 100644 --- a/libraries/rush-lib/src/cli/RushPnpmCommandLineParser.ts +++ b/libraries/rush-lib/src/cli/RushPnpmCommandLineParser.ts @@ -446,6 +446,10 @@ export class RushPnpmCommandLineParser { switch (commandName) { case 'patch-commit': { + // why need to throw error when pnpm-config.json not exists? + // 1. pnpm-config.json is required for `rush-pnpm patch-commit`. Rush writes the patched dependency to the pnpm-config.json when finishes. + // 2. we can not fallback to use Monorepo config folder (common/config/rush) due to that this command is intended to apply to input subspace only. + // It will produce unexpected behavior if we use the fallback. if (this._subspace.getPnpmOptions() === undefined) { this._terminal.writeErrorLine( `You are using rush-pnpm patch-commit command, but Rush could not find the pnpm-config.json for ${this._subspace.subspaceName} subspace! ` + From 2a6dba1a2f09837b0467a7d5a16865b58c7977aa Mon Sep 17 00:00:00 2001 From: Pete Gonzalez <4673363+octogonz@users.noreply.github.com> Date: Thu, 18 Jul 2024 20:03:04 -0700 Subject: [PATCH 6/7] Improve error message wording --- libraries/rush-lib/src/cli/RushPnpmCommandLineParser.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/rush-lib/src/cli/RushPnpmCommandLineParser.ts b/libraries/rush-lib/src/cli/RushPnpmCommandLineParser.ts index ae25ae05e94..3af75b88013 100644 --- a/libraries/rush-lib/src/cli/RushPnpmCommandLineParser.ts +++ b/libraries/rush-lib/src/cli/RushPnpmCommandLineParser.ts @@ -452,8 +452,8 @@ export class RushPnpmCommandLineParser { // It will produce unexpected behavior if we use the fallback. if (this._subspace.getPnpmOptions() === undefined) { this._terminal.writeErrorLine( - `You are using rush-pnpm patch-commit command, but Rush could not find the pnpm-config.json for ${this._subspace.subspaceName} subspace! ` + - `Make sure the pnpm-config.json exists in ${this._subspace.getSubspaceConfigFolder()}` + `The "rush-pnpm patch-commit" command cannot proceed without a pnpm-config.json file.` + + ` Create one in this folder: ${this._subspace.getSubspaceConfigFolder()}` ); break; } From b6783cd295861ddbd8a94b63e8381e0903d457b8 Mon Sep 17 00:00:00 2001 From: Pete Gonzalez <4673363+octogonz@users.noreply.github.com> Date: Thu, 18 Jul 2024 20:04:15 -0700 Subject: [PATCH 7/7] Prepare to publish a PATCH release --- common/config/rush/version-policies.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/config/rush/version-policies.json b/common/config/rush/version-policies.json index 9b3a8764da7..d5a207e4bd7 100644 --- a/common/config/rush/version-policies.json +++ b/common/config/rush/version-policies.json @@ -103,7 +103,7 @@ "policyName": "rush", "definitionName": "lockStepVersion", "version": "5.129.6", - "nextBump": "minor", + "nextBump": "patch", "mainProject": "@microsoft/rush" } ]