From 25b4da0106a19df6eec95b05b0e1605094ab1ee1 Mon Sep 17 00:00:00 2001 From: Pete Gonzalez <4673363+octogonz@users.noreply.github.com> Date: Wed, 17 Jul 2024 00:11:30 -0700 Subject: [PATCH 1/2] Fix a couple "rush init" regressions --- .../rush-lib/src/cli/RushCommandLineParser.ts | 47 ++++++++++--------- .../rush-lib/src/cli/actions/InitAction.ts | 8 +--- 2 files changed, 27 insertions(+), 28 deletions(-) diff --git a/libraries/rush-lib/src/cli/RushCommandLineParser.ts b/libraries/rush-lib/src/cli/RushCommandLineParser.ts index 74893b48952..80009e6d883 100644 --- a/libraries/rush-lib/src/cli/RushCommandLineParser.ts +++ b/libraries/rush-lib/src/cli/RushCommandLineParser.ts @@ -224,30 +224,33 @@ export class RushCommandLineParser extends CommandLineParser { try { await this._wrapOnExecuteAsync(); - try { - const { configuration: experiments } = this.rushConfiguration.experimentsConfiguration; - if (experiments.rushAlerts) { - this._terminal.writeDebugLine('Checking Rush alerts...'); - // Print out alerts if have after each successful command actions - const rushAlerts: RushAlerts = new RushAlerts({ - rushConfiguration: this.rushConfiguration, - terminal: this._terminal - }); - if (await rushAlerts.isAlertsStateUpToDateAsync()) { - await rushAlerts.printAlertsAsync(); - } else { - await rushAlerts.retrieveAlertsAsync(); + // TODO: rushConfiguration is typed as "!: RushConfiguration" here, but can sometimes be undefined + if (this.rushConfiguration) { + try { + const { configuration: experiments } = this.rushConfiguration.experimentsConfiguration; + if (experiments.rushAlerts) { + this._terminal.writeDebugLine('Checking Rush alerts...'); + // Print out alerts if have after each successful command actions + const rushAlerts: RushAlerts = new RushAlerts({ + rushConfiguration: this.rushConfiguration, + terminal: this._terminal + }); + if (await rushAlerts.isAlertsStateUpToDateAsync()) { + await rushAlerts.printAlertsAsync(); + } else { + await rushAlerts.retrieveAlertsAsync(); + } } + } catch (error) { + if (error instanceof AlreadyReportedError) { + throw error; + } + // Generally the RushAlerts implementation should handle its own error reporting; if not, + // clarify the source, since the Rush Alerts behavior is nondeterministic and may not repro easily: + this._terminal.writeErrorLine(`\nAn unexpected error was encountered by the Rush alerts feature:`); + this._terminal.writeErrorLine(error.message); + throw new AlreadyReportedError(); } - } catch (error) { - if (error instanceof AlreadyReportedError) { - throw error; - } - // Generally the RushAlerts implementation should handle its own error reporting; if not, - // clarify the source, since the Rush Alerts behavior is nondeterministic and may not repro easily: - this._terminal.writeErrorLine(`\nAn unexpected error was encountered by the Rush alerts feature:`); - this._terminal.writeErrorLine(error.message); - throw new AlreadyReportedError(); } // If we make it here, everything went fine, so reset the exit code back to 0 diff --git a/libraries/rush-lib/src/cli/actions/InitAction.ts b/libraries/rush-lib/src/cli/actions/InitAction.ts index bad633ceb58..efcadd12cf4 100644 --- a/libraries/rush-lib/src/cli/actions/InitAction.ts +++ b/libraries/rush-lib/src/cli/actions/InitAction.ts @@ -15,7 +15,6 @@ import type { RushCommandLineParser } from '../RushCommandLineParser'; import { BaseConfiglessRushAction } from './BaseRushAction'; import { assetsFolderPath } from '../../utilities/PathConstants'; -import { RushConstants } from '../../logic/RushConstants'; import { copyTemplateFileAsync } from '../../utilities/templateUtilities'; export class InitAction extends BaseConfiglessRushAction { @@ -139,13 +138,10 @@ export class InitAction extends BaseConfiglessRushAction { '[dot]gitattributes', '[dot]gitignore', - RushConstants.rushJsonFilename + 'rush.json' ]; - const experimentalTemplateFilePaths: string[] = [ - `common/config/rush/${RushConstants.subspacesConfigFilename}`, - 'common/config/rush/rush-alerts.json' - ]; + const experimentalTemplateFilePaths: string[] = ['common/config/rush/rush-alerts.json']; if (this._experimentsParameter.value) { templateFilePaths.push(...experimentalTemplateFilePaths); From 5c25cde3bf11784271f041fa58397d16f9b09eda Mon Sep 17 00:00:00 2001 From: Pete Gonzalez <4673363+octogonz@users.noreply.github.com> Date: Wed, 17 Jul 2024 00:12:34 -0700 Subject: [PATCH 2/2] rush change --- .../rush/octogonz-rush-init-fix2_2024-07-17-07-12.json | 10 ++++++++++ common/config/rush/version-policies.json | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 common/changes/@microsoft/rush/octogonz-rush-init-fix2_2024-07-17-07-12.json diff --git a/common/changes/@microsoft/rush/octogonz-rush-init-fix2_2024-07-17-07-12.json b/common/changes/@microsoft/rush/octogonz-rush-init-fix2_2024-07-17-07-12.json new file mode 100644 index 00000000000..c1ea0a64a9a --- /dev/null +++ b/common/changes/@microsoft/rush/octogonz-rush-init-fix2_2024-07-17-07-12.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@microsoft/rush", + "comment": "Fix a recent regression for `rush init`", + "type": "none" + } + ], + "packageName": "@microsoft/rush" +} \ No newline at end of file diff --git a/common/config/rush/version-policies.json b/common/config/rush/version-policies.json index 056f0eb4a89..365f2237805 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.130.0", - "nextBump": "minor", + "nextBump": "patch", "mainProject": "@microsoft/rush" } ]