From 379fb8bb0389ee638b768ee86d6acce60072bda1 Mon Sep 17 00:00:00 2001 From: Ben Keen Date: Fri, 29 Aug 2025 08:39:57 -0700 Subject: [PATCH] Bridge cache fix and adding cache key to terminal logs --- ...enkeen-bridge-cache-updates_2025-08-29-15-37.json | 10 ++++++++++ .../src/BridgeCachePlugin.ts | 12 ++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) create mode 100644 common/changes/@microsoft/rush/benkeen-bridge-cache-updates_2025-08-29-15-37.json diff --git a/common/changes/@microsoft/rush/benkeen-bridge-cache-updates_2025-08-29-15-37.json b/common/changes/@microsoft/rush/benkeen-bridge-cache-updates_2025-08-29-15-37.json new file mode 100644 index 00000000000..0e1eef24d88 --- /dev/null +++ b/common/changes/@microsoft/rush/benkeen-bridge-cache-updates_2025-08-29-15-37.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@microsoft/rush", + "comment": "Fix to allow Bridge Cache plugin be installed but not used when build cache disabled; add cache key to terminal logs", + "type": "none" + } + ], + "packageName": "@microsoft/rush" +} \ No newline at end of file diff --git a/rush-plugins/rush-bridge-cache-plugin/src/BridgeCachePlugin.ts b/rush-plugins/rush-bridge-cache-plugin/src/BridgeCachePlugin.ts index fe4501cc69f..9552c35977f 100644 --- a/rush-plugins/rush-bridge-cache-plugin/src/BridgeCachePlugin.ts +++ b/rush-plugins/rush-bridge-cache-plugin/src/BridgeCachePlugin.ts @@ -83,16 +83,17 @@ export class BridgeCachePlugin implements IRushPlugin { ): Promise => { const { buildCacheConfiguration } = context; const { terminal } = logger; + + if (cacheAction === undefined) { + return; + } + if (!buildCacheConfiguration?.buildCacheEnabled) { throw new Error( `The build cache must be enabled to use the "${this._actionParameterName}" parameter.` ); } - if (cacheAction === undefined) { - return; - } - const filteredOperations: Set = new Set(); for (const operationExecutionResult of recordByOperation.values()) { if (!operationExecutionResult.operation.isNoOp) { @@ -122,6 +123,7 @@ export class BridgeCachePlugin implements IRushPlugin { terminal.writeLine( `Operation "${operation.name}": Outputs have been restored from the build cache."` ); + terminal.writeLine(`Cache key: ${projectBuildCache.cacheId}`); } else { terminal.writeWarningLine( `Operation "${operation.name}": Outputs could not be restored from the build cache.` @@ -155,6 +157,7 @@ export class BridgeCachePlugin implements IRushPlugin { terminal.writeLine( `Operation "${operation.name}": Existing outputs have been successfully written to the build cache."` ); + terminal.writeLine(`Cache key: ${projectBuildCache.cacheId}`); } else { terminal.writeErrorLine( `Operation "${operation.name}": An error occurred while writing existing outputs to the build cache.` @@ -179,6 +182,7 @@ export class BridgeCachePlugin implements IRushPlugin { const cacheActionParameter: CommandLineParameter | undefined = context.customParameters.get( this._actionParameterName ); + if (cacheActionParameter) { if (cacheActionParameter.kind !== CommandLineParameterKind.Choice) { throw new Error(