Skip to content
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

[rush] Only check for overlapping output folders within operations that will be invoked as part of the same command. #3168

Merged
merged 4 commits into from
Jan 19, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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
84 changes: 51 additions & 33 deletions apps/rush-lib/src/api/RushProjectConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,6 @@ export class RushProjectConfiguration {
IOperationSettings
>();
if (rushProjectJson.operationSettings) {
const overlappingPathAnalyzer: OverlappingPathAnalyzer<string> = new OverlappingPathAnalyzer<string>();
for (const operationSettings of rushProjectJson.operationSettings) {
const operationName: string = operationSettings.operationName;
const existingOperationSettings: IOperationSettings | undefined =
Expand Down Expand Up @@ -329,41 +328,60 @@ export class RushProjectConfiguration {
} else {
operationSettingsByOperationName.set(operationName, operationSettings);
}
}

if (operationSettings.outputFolderNames) {
for (const outputFolderName of operationSettings.outputFolderNames) {
const overlappingOperationNames: string[] | undefined =
overlappingPathAnalyzer.addPathAndGetFirstEncounteredLabels(outputFolderName, operationName);
if (overlappingOperationNames) {
const overlapsWithOwnOperation: boolean = overlappingOperationNames?.includes(operationName);
if (overlapsWithOwnOperation) {
if (overlappingOperationNames.length === 1) {
terminal.writeErrorLine(
`Invalid "${RUSH_PROJECT_CONFIGURATION_FILE.projectRelativeFilePath}" ` +
`for project "${project.packageName}". The project output folder name "${outputFolderName}" in ` +
`operation ${operationName} overlaps with another folder name in the same operation.`
);
} else {
const otherOperationNames: string[] = overlappingOperationNames.filter(
(overlappingOperationName) => overlappingOperationName !== operationName
);
terminal.writeErrorLine(
`Invalid "${RUSH_PROJECT_CONFIGURATION_FILE.projectRelativeFilePath}" ` +
`for project "${project.packageName}". The project output folder name "${outputFolderName}" in ` +
`operation ${operationName} overlaps with other folder names in the same operation and with ` +
`folder names in the following other operations: ${otherOperationNames.join(', ')}.`
);
// For each phased command, check if any of its phases' output folders overlap.
for (const [, command] of repoCommandLineConfiguration.commands) {
iclanton marked this conversation as resolved.
Show resolved Hide resolved
if (command.commandKind === 'phased') {
const phasesOverlappingPathAnalyzer: OverlappingPathAnalyzer<string> =
new OverlappingPathAnalyzer<string>();

for (const operationName of command.phases) {
const operationSettings: IOperationSettings | undefined =
operationSettingsByOperationName.get(operationName);
if (operationSettings) {
if (operationSettings.outputFolderNames) {
for (const outputFolderName of operationSettings.outputFolderNames) {
const overlappingOperationNames: string[] | undefined =
phasesOverlappingPathAnalyzer.addPathAndGetFirstEncounteredLabels(
outputFolderName,
operationName
);
if (overlappingOperationNames) {
const overlapsWithOwnOperation: boolean =
overlappingOperationNames?.includes(operationName);
if (overlapsWithOwnOperation) {
if (overlappingOperationNames.length === 1) {
terminal.writeErrorLine(
`Invalid "${RUSH_PROJECT_CONFIGURATION_FILE.projectRelativeFilePath}" ` +
iclanton marked this conversation as resolved.
Show resolved Hide resolved
`for project "${project.packageName}". The project output folder name "${outputFolderName}" in ` +
`operation "${operationName}" overlaps with another folder name in the same operation.`
iclanton marked this conversation as resolved.
Show resolved Hide resolved
);
} else {
const otherOperationNames: string[] = overlappingOperationNames.filter(
(overlappingOperationName) => overlappingOperationName !== operationName
);
terminal.writeErrorLine(
`Invalid "${RUSH_PROJECT_CONFIGURATION_FILE.projectRelativeFilePath}" ` +
`for project "${project.packageName}". The project output folder name "${outputFolderName}" in ` +
`operation "${operationName}" overlaps with other folder names in the same operation and with ` +
'folder names in the following other operations invoked by the ' +
`"${command.name}" command: ${otherOperationNames.join(', ')}.`
iclanton marked this conversation as resolved.
Show resolved Hide resolved
);
}
} else {
terminal.writeErrorLine(
`Invalid "${RUSH_PROJECT_CONFIGURATION_FILE.projectRelativeFilePath}" ` +
`for project "${project.packageName}". The project output folder name "${outputFolderName}" in ` +
`operation "${operationName}" overlaps with other folder name(s) in the following other operations ` +
`invoked by the "${command.name}" command: ${overlappingOperationNames.join(', ')}.`
);
}

throw new AlreadyReportedError();
}
}
} else {
terminal.writeErrorLine(
`Invalid "${RUSH_PROJECT_CONFIGURATION_FILE.projectRelativeFilePath}" ` +
`for project "${project.packageName}". The project output folder name "${outputFolderName}" in ` +
`operation ${operationName} overlaps with other folder name(s) in the following other operations: ` +
`${overlappingOperationNames.join(', ')}.`
);
}

throw new AlreadyReportedError();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@microsoft/rush",
"comment": "",
"type": "none"
}
],
"packageName": "@microsoft/rush"
}