Skip to content

[rush] Fix "rush init" regression #4836

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading