Skip to content

Commit

Permalink
[rush] Fix "rush init" regression (#4836)
Browse files Browse the repository at this point in the history
* Fix a couple "rush init" regressions

* rush change
  • Loading branch information
octogonz authored Jul 17, 2024
1 parent 8b64754 commit 4d97807
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 29 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@microsoft/rush",
"comment": "Fix a recent regression for `rush init`",
"type": "none"
}
],
"packageName": "@microsoft/rush"
}
2 changes: 1 addition & 1 deletion common/config/rush/version-policies.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
"policyName": "rush",
"definitionName": "lockStepVersion",
"version": "5.130.0",
"nextBump": "minor",
"nextBump": "patch",
"mainProject": "@microsoft/rush"
}
]
47 changes: 25 additions & 22 deletions libraries/rush-lib/src/cli/RushCommandLineParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 2 additions & 6 deletions libraries/rush-lib/src/cli/actions/InitAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 4d97807

Please sign in to comment.