From 5dfbe59dfd1e76edd056b9a0a0ca4a58d3f882f0 Mon Sep 17 00:00:00 2001 From: Ze Cheng Date: Tue, 21 Mar 2023 07:40:32 +0000 Subject: [PATCH 1/6] feat(rush-lib): enable output for event hook scripts by default --- libraries/rush-lib/src/logic/EventHooksManager.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/rush-lib/src/logic/EventHooksManager.ts b/libraries/rush-lib/src/logic/EventHooksManager.ts index d950c7ffd9b..4a3b25d04bb 100644 --- a/libraries/rush-lib/src/logic/EventHooksManager.ts +++ b/libraries/rush-lib/src/logic/EventHooksManager.ts @@ -40,7 +40,7 @@ export class EventHooksManager { rushConfiguration: this._rushConfiguration, workingDirectory: this._rushConfiguration.rushJsonFolder, initCwd: this._commonTempFolder, - handleOutput: !isDebug, + handleOutput: false, environmentPathOptions: { includeRepoBin: true } From c35d1263de0774be968ed292c7c57570ab4e2e32 Mon Sep 17 00:00:00 2001 From: Ze Cheng Date: Tue, 21 Mar 2023 07:44:41 +0000 Subject: [PATCH 2/6] feat(rush-lib): add changelog --- ...eature-rush-event-hook-output_2023-03-21-07-43.json | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 common/changes/@microsoft/rush/feature-rush-event-hook-output_2023-03-21-07-43.json diff --git a/common/changes/@microsoft/rush/feature-rush-event-hook-output_2023-03-21-07-43.json b/common/changes/@microsoft/rush/feature-rush-event-hook-output_2023-03-21-07-43.json new file mode 100644 index 00000000000..8d1c2f491c8 --- /dev/null +++ b/common/changes/@microsoft/rush/feature-rush-event-hook-output_2023-03-21-07-43.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@microsoft/rush", + "comment": "enable event hook scripts output by default", + "type": "none" + } + ], + "packageName": "@microsoft/rush" +} \ No newline at end of file From 3b26170a620fe522ab30b0646a32389c015d4d7e Mon Sep 17 00:00:00 2001 From: Ian Clanton-Thuon Date: Wed, 22 Mar 2023 13:28:08 -0700 Subject: [PATCH 3/6] Rush change. --- .../rush/feature-rush-event-hook-output_2023-03-21-07-43.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/changes/@microsoft/rush/feature-rush-event-hook-output_2023-03-21-07-43.json b/common/changes/@microsoft/rush/feature-rush-event-hook-output_2023-03-21-07-43.json index 8d1c2f491c8..52b53fc07fa 100644 --- a/common/changes/@microsoft/rush/feature-rush-event-hook-output_2023-03-21-07-43.json +++ b/common/changes/@microsoft/rush/feature-rush-event-hook-output_2023-03-21-07-43.json @@ -2,7 +2,7 @@ "changes": [ { "packageName": "@microsoft/rush", - "comment": "enable event hook scripts output by default", + "comment": "Update event hook scripts to print their output to the console.", "type": "none" } ], From a73c29ede74240e9850311c95d331f1cb0def745 Mon Sep 17 00:00:00 2001 From: Ze Cheng Date: Thu, 23 Mar 2023 06:12:44 +0000 Subject: [PATCH 4/6] feat(rush-lib): add experiment 'printEventHooksOutputToConsole' to allow printing outputs from event hooks to the console --- ...> feature-rush-event-hook-output_2023-03-23-06-10.json} | 2 +- common/reviews/api/rush-lib.api.md | 1 + .../assets/rush-init/common/config/rush/experiments.json | 7 ++++++- libraries/rush-lib/src/api/ExperimentsConfiguration.ts | 5 +++++ libraries/rush-lib/src/logic/EventHooksManager.ts | 6 +++++- libraries/rush-lib/src/schemas/experiments.schema.json | 4 ++++ 6 files changed, 22 insertions(+), 3 deletions(-) rename common/changes/@microsoft/rush/{feature-rush-event-hook-output_2023-03-21-07-43.json => feature-rush-event-hook-output_2023-03-23-06-10.json} (50%) diff --git a/common/changes/@microsoft/rush/feature-rush-event-hook-output_2023-03-21-07-43.json b/common/changes/@microsoft/rush/feature-rush-event-hook-output_2023-03-23-06-10.json similarity index 50% rename from common/changes/@microsoft/rush/feature-rush-event-hook-output_2023-03-21-07-43.json rename to common/changes/@microsoft/rush/feature-rush-event-hook-output_2023-03-23-06-10.json index 52b53fc07fa..8fcf3b8685d 100644 --- a/common/changes/@microsoft/rush/feature-rush-event-hook-output_2023-03-21-07-43.json +++ b/common/changes/@microsoft/rush/feature-rush-event-hook-output_2023-03-23-06-10.json @@ -2,7 +2,7 @@ "changes": [ { "packageName": "@microsoft/rush", - "comment": "Update event hook scripts to print their output to the console.", + "comment": "Add experiment `printEventHooksOutputToConsole` to allow printing outputs from event hooks to the console.", "type": "none" } ], diff --git a/common/reviews/api/rush-lib.api.md b/common/reviews/api/rush-lib.api.md index 1d7c3f99816..93df8c4d2eb 100644 --- a/common/reviews/api/rush-lib.api.md +++ b/common/reviews/api/rush-lib.api.md @@ -307,6 +307,7 @@ export interface IExperimentsJson { phasedCommands?: boolean; usePnpmFrozenLockfileForRushInstall?: boolean; usePnpmPreferFrozenLockfileForRushUpdate?: boolean; + printEventHooksOutputToConsole?: boolean; } // @beta diff --git a/libraries/rush-lib/assets/rush-init/common/config/rush/experiments.json b/libraries/rush-lib/assets/rush-init/common/config/rush/experiments.json index 29539c4876b..151718a75fd 100644 --- a/libraries/rush-lib/assets/rush-init/common/config/rush/experiments.json +++ b/libraries/rush-lib/assets/rush-init/common/config/rush/experiments.json @@ -46,5 +46,10 @@ * If true, perform a clean install after when running `rush install` or `rush update` if the * `.npmrc` file has changed since the last install. */ - /*[LINE "HYPOTHETICAL"]*/ "cleanInstallAfterNpmrcChanges": true + /*[LINE "HYPOTHETICAL"]*/ "cleanInstallAfterNpmrcChanges": true, + + /** + * If true, print the outputs of shell commands defined in event hooks to the console. + */ + /*[LINE "HYPOTHETICAL"]*/ "printEventHooksOutputToConsole": true } diff --git a/libraries/rush-lib/src/api/ExperimentsConfiguration.ts b/libraries/rush-lib/src/api/ExperimentsConfiguration.ts index 17fddb8d731..b428d50d1f3 100644 --- a/libraries/rush-lib/src/api/ExperimentsConfiguration.ts +++ b/libraries/rush-lib/src/api/ExperimentsConfiguration.ts @@ -53,6 +53,11 @@ export interface IExperimentsJson { * `.npmrc` file has changed since the last install. */ cleanInstallAfterNpmrcChanges?: boolean; + + /** + * If true, print the outputs of shell commands defined in event hooks to the console. + */ + printEventHooksOutputToConsole?: boolean; } /** diff --git a/libraries/rush-lib/src/logic/EventHooksManager.ts b/libraries/rush-lib/src/logic/EventHooksManager.ts index 4a3b25d04bb..9abdfd44de0 100644 --- a/libraries/rush-lib/src/logic/EventHooksManager.ts +++ b/libraries/rush-lib/src/logic/EventHooksManager.ts @@ -34,13 +34,17 @@ export class EventHooksManager { const stopwatch: Stopwatch = Stopwatch.start(); console.log('\n' + colors.green(`Executing event hooks for ${Event[event]}`)); + + const printEventHooksOutputToConsole = + isDebug || + this._rushConfiguration.experimentsConfiguration.configuration.printEventHooksOutputToConsole; scripts.forEach((script) => { try { Utilities.executeLifecycleCommand(script, { rushConfiguration: this._rushConfiguration, workingDirectory: this._rushConfiguration.rushJsonFolder, initCwd: this._commonTempFolder, - handleOutput: false, + handleOutput: !printEventHooksOutputToConsole, environmentPathOptions: { includeRepoBin: true } diff --git a/libraries/rush-lib/src/schemas/experiments.schema.json b/libraries/rush-lib/src/schemas/experiments.schema.json index caff117b104..bb1e8e92602 100644 --- a/libraries/rush-lib/src/schemas/experiments.schema.json +++ b/libraries/rush-lib/src/schemas/experiments.schema.json @@ -37,6 +37,10 @@ "cleanInstallAfterNpmrcChanges": { "description": "If true, perform a clean install after when running `rush install` or `rush update` if the `.npmrc` file has changed since the last install.", "type": "boolean" + }, + "printEventHooksOutputToConsole": { + "description": "If true, print the outputs of shell commands defined in event hooks to the console.", + "type": "boolean" } }, "additionalProperties": false From 8550f2d001f86abc559dcd8c0332c68de6249860 Mon Sep 17 00:00:00 2001 From: Ze Cheng Date: Thu, 23 Mar 2023 06:34:08 +0000 Subject: [PATCH 5/6] feat(rush-lib): add a placeholder to rushstack repo config --- common/config/rush/experiments.json | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/common/config/rush/experiments.json b/common/config/rush/experiments.json index 0182df63eb9..fef826208c3 100644 --- a/common/config/rush/experiments.json +++ b/common/config/rush/experiments.json @@ -46,5 +46,10 @@ * If true, perform a clean install after when running `rush install` or `rush update` if the * `.npmrc` file has changed since the last install. */ - // "cleanInstallAfterNpmrcChanges": true + // "cleanInstallAfterNpmrcChanges": true, + + /** + * If true, print the outputs of shell commands defined in event hooks to the console. + */ + // "printEventHooksOutputToConsole": true } From 86166abe72dcbab3049608a3dc227fb1f552bc66 Mon Sep 17 00:00:00 2001 From: Ian Clanton-Thuon Date: Thu, 23 Mar 2023 20:41:42 -0700 Subject: [PATCH 6/6] Fix a lint issue and update the API review file. --- common/reviews/api/rush-lib.api.md | 2 +- libraries/rush-lib/src/logic/EventHooksManager.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/common/reviews/api/rush-lib.api.md b/common/reviews/api/rush-lib.api.md index 93df8c4d2eb..e0f71c699f7 100644 --- a/common/reviews/api/rush-lib.api.md +++ b/common/reviews/api/rush-lib.api.md @@ -305,9 +305,9 @@ export interface IExperimentsJson { noChmodFieldInTarHeaderNormalization?: boolean; omitImportersFromPreventManualShrinkwrapChanges?: boolean; phasedCommands?: boolean; + printEventHooksOutputToConsole?: boolean; usePnpmFrozenLockfileForRushInstall?: boolean; usePnpmPreferFrozenLockfileForRushUpdate?: boolean; - printEventHooksOutputToConsole?: boolean; } // @beta diff --git a/libraries/rush-lib/src/logic/EventHooksManager.ts b/libraries/rush-lib/src/logic/EventHooksManager.ts index 9abdfd44de0..7156466e403 100644 --- a/libraries/rush-lib/src/logic/EventHooksManager.ts +++ b/libraries/rush-lib/src/logic/EventHooksManager.ts @@ -35,7 +35,7 @@ export class EventHooksManager { const stopwatch: Stopwatch = Stopwatch.start(); console.log('\n' + colors.green(`Executing event hooks for ${Event[event]}`)); - const printEventHooksOutputToConsole = + const printEventHooksOutputToConsole: boolean | undefined = isDebug || this._rushConfiguration.experimentsConfiguration.configuration.printEventHooksOutputToConsole; scripts.forEach((script) => {