From cd043d34ab7f0f8e06e061985453df3169902051 Mon Sep 17 00:00:00 2001 From: Elizabeth Craig Date: Wed, 10 Apr 2019 12:30:17 -0700 Subject: [PATCH 1/2] Add suppressedWarnings option --- .vscode/settings.json | 4 ++++ apps/rush-lib/assets/rush-init/rush.json | 12 ++++++++++++ apps/rush-lib/src/api/RushConfiguration.ts | 12 ++++++++++++ apps/rush-lib/src/logic/taskRunner/ProjectTask.ts | 10 ++++++++-- apps/rush-lib/src/schemas/rush.schema.json | 9 ++++++++- .../rush/ignore-warnings_2019-04-10-19-30.json | 11 +++++++++++ common/reviews/api/rush-lib.api.md | 1 + rush.json | 12 ++++++++++++ 8 files changed, 68 insertions(+), 3 deletions(-) create mode 100644 common/changes/@microsoft/rush/ignore-warnings_2019-04-10-19-30.json diff --git a/.vscode/settings.json b/.vscode/settings.json index 0f0399082a6..cb928ceff40 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -17,5 +17,9 @@ "temp": true, "**/test/**/temp": false, "coverage": true + }, + "files.associations": { + "rush.json": "jsonc", + "**/common/config/rush/*.json": "jsonc" } } diff --git a/apps/rush-lib/assets/rush-init/rush.json b/apps/rush-lib/assets/rush-init/rush.json index 62fa181790e..c9e1a23d493 100644 --- a/apps/rush-lib/assets/rush-init/rush.json +++ b/apps/rush-lib/assets/rush-init/rush.json @@ -270,6 +270,18 @@ */ /*[LINE "HYPOTHETICAL"]*/ "hotfixChangeEnabled": false, + /** + * If a warning message includes any substrings listed here, it should be treated as a standard + * log message rather than a warning. This prevents inconsequential warning messages caused by + * external packages from breaking incremental builds (packages marked as "success with warnings" + * will be rebuilt on each rush build). + * + * For example, certain npm packages with C++ bindings intermittently cause Node to display a warning + * starting with "Using a domain property in MakeCallback is deprecated." The source of this warning + * has been hard to track down, so it can be added to this list to make incremental builds work. + */ + /*[LINE "HYPOTHETICAL"]*/ "suppressedWarnings": [], + /** * (Required) This is the inventory of projects to be managed by Rush. * diff --git a/apps/rush-lib/src/api/RushConfiguration.ts b/apps/rush-lib/src/api/RushConfiguration.ts index fb337793f31..f5d6572ae71 100644 --- a/apps/rush-lib/src/api/RushConfiguration.ts +++ b/apps/rush-lib/src/api/RushConfiguration.ts @@ -122,6 +122,7 @@ export interface IRushConfigurationJson { yarnOptions?: IYarnOptionsJson; ensureConsistentVersions?: boolean; variants?: IRushVariantOptionsJson[]; + suppressedWarnings?: string[]; } /** @@ -246,6 +247,7 @@ export class RushConfiguration { private _variants: { [variantName: string]: boolean; }; + private _suppressedWarnings: string[]; // "approvedPackagesPolicy" feature private _approvedPackagesPolicy: ApprovedPackagesPolicy; @@ -734,6 +736,14 @@ export class RushConfiguration { return this._ensureConsistentVersions; } + /** + * Gets the list of warning message substrings which should be suppressed (treated as standard + * log messages rather than warnings). + */ + public get suppressedWarnings(): string[] { + return this._suppressedWarnings; + } + /** * Indicates whether telemetry collection is enabled for Rush runs. * @beta @@ -974,6 +984,8 @@ export class RushConfiguration { this._ensureConsistentVersions = !!rushConfigurationJson.ensureConsistentVersions; + this._suppressedWarnings = rushConfigurationJson.suppressedWarnings || []; + this._pnpmOptions = new PnpmOptionsConfiguration(rushConfigurationJson.pnpmOptions || {}); this._yarnOptions = new YarnOptionsConfiguration(rushConfigurationJson.yarnOptions || { }); diff --git a/apps/rush-lib/src/logic/taskRunner/ProjectTask.ts b/apps/rush-lib/src/logic/taskRunner/ProjectTask.ts index 95a7ba38a6e..6f176829fd3 100644 --- a/apps/rush-lib/src/logic/taskRunner/ProjectTask.ts +++ b/apps/rush-lib/src/logic/taskRunner/ProjectTask.ts @@ -160,8 +160,14 @@ export class ProjectTask implements ITaskDefinition { }); task.stderr.on('data', (data: string) => { - writer.writeError(data); - this._hasWarningOrError = true; + // If this error matches any of the suppressed warnings from the config, write it to + // stdout instead of stderr and don't treat the task as having a warning/error. + if (this._rushConfiguration.suppressedWarnings.some((warning: string) => data.indexOf(warning) !== -1)) { + writer.write(data); + } else { + writer.writeError(data); + this._hasWarningOrError = true; + } }); return new Promise((resolve: (status: TaskStatus) => void, reject: (error: TaskError) => void) => { diff --git a/apps/rush-lib/src/schemas/rush.schema.json b/apps/rush-lib/src/schemas/rush.schema.json index 714969a6345..2251e161cb2 100644 --- a/apps/rush-lib/src/schemas/rush.schema.json +++ b/apps/rush-lib/src/schemas/rush.schema.json @@ -234,7 +234,14 @@ } }, "additionalProperties": false - } + }, + "suppressedWarnings": { + "description": "A list of warning messages which should be treated as standard log messages instead of warnings.", + "type": "array", + "items": { + "type": "string" + } +} }, "additionalProperties": false, "required": [ diff --git a/common/changes/@microsoft/rush/ignore-warnings_2019-04-10-19-30.json b/common/changes/@microsoft/rush/ignore-warnings_2019-04-10-19-30.json new file mode 100644 index 00000000000..6b63444b726 --- /dev/null +++ b/common/changes/@microsoft/rush/ignore-warnings_2019-04-10-19-30.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "comment": "Add suppressedWarnings option", + "packageName": "@microsoft/rush", + "type": "none" + } + ], + "packageName": "@microsoft/rush", + "email": "ecraig12345@users.noreply.github.com" +} \ No newline at end of file diff --git a/common/reviews/api/rush-lib.api.md b/common/reviews/api/rush-lib.api.md index 8220d670d8c..9dc98910839 100644 --- a/common/reviews/api/rush-lib.api.md +++ b/common/reviews/api/rush-lib.api.md @@ -259,6 +259,7 @@ export class RushConfiguration { readonly rushJsonFolder: string; readonly rushLinkJsonFilename: string; readonly shrinkwrapFilePhrase: string; + readonly suppressedWarnings: string[]; // @beta readonly telemetryEnabled: boolean; readonly tempShrinkwrapFilename: string; diff --git a/rush.json b/rush.json index 0ad0659eab9..607b320e7a1 100644 --- a/rush.json +++ b/rush.json @@ -223,6 +223,18 @@ */ // "hotfixChangeEnabled": false, + /** + * If a warning message includes any substrings listed here, it should be treated as a standard + * log message rather than a warning. This prevents inconsequential warning messages caused by + * external packages from breaking incremental builds (packages marked as "success with warnings" + * will be rebuilt on each rush build). + * + * For example, certain npm packages with C++ bindings intermittently cause Node to display a warning + * starting with "Using a domain property in MakeCallback is deprecated." The source of this warning + * has been hard to track down, so it can be added to this list to make incremental builds work. + */ + // "suppressedWarnings": [], + /** * (Required) This is the inventory of projects to be managed by Rush. * From 542d405faee683833dca0ad2a71933d5172923b2 Mon Sep 17 00:00:00 2001 From: Elizabeth Craig Date: Thu, 11 Apr 2019 09:28:59 -0700 Subject: [PATCH 2/2] Use regular expressions --- apps/rush-lib/assets/rush-init/rush.json | 12 ++++-------- apps/rush-lib/src/api/RushConfiguration.ts | 11 ++++++----- apps/rush-lib/src/logic/taskRunner/ProjectTask.ts | 2 +- rush.json | 12 ++++-------- 4 files changed, 15 insertions(+), 22 deletions(-) diff --git a/apps/rush-lib/assets/rush-init/rush.json b/apps/rush-lib/assets/rush-init/rush.json index c9e1a23d493..ccef81732ee 100644 --- a/apps/rush-lib/assets/rush-init/rush.json +++ b/apps/rush-lib/assets/rush-init/rush.json @@ -271,14 +271,10 @@ /*[LINE "HYPOTHETICAL"]*/ "hotfixChangeEnabled": false, /** - * If a warning message includes any substrings listed here, it should be treated as a standard - * log message rather than a warning. This prevents inconsequential warning messages caused by - * external packages from breaking incremental builds (packages marked as "success with warnings" - * will be rebuilt on each rush build). - * - * For example, certain npm packages with C++ bindings intermittently cause Node to display a warning - * starting with "Using a domain property in MakeCallback is deprecated." The source of this warning - * has been hard to track down, so it can be added to this list to make incremental builds work. + * If a warning message matches any of the regular expressions listed here, it should be treated + * as a standard log message rather than a warning. This prevents inconsequential warning messages + * caused by external packages from breaking incremental builds (packages marked as "success with + * warnings" will be rebuilt on each rush build). */ /*[LINE "HYPOTHETICAL"]*/ "suppressedWarnings": [], diff --git a/apps/rush-lib/src/api/RushConfiguration.ts b/apps/rush-lib/src/api/RushConfiguration.ts index f5d6572ae71..5b954585dc1 100644 --- a/apps/rush-lib/src/api/RushConfiguration.ts +++ b/apps/rush-lib/src/api/RushConfiguration.ts @@ -247,7 +247,7 @@ export class RushConfiguration { private _variants: { [variantName: string]: boolean; }; - private _suppressedWarnings: string[]; + private _suppressedWarnings: RegExp[]; // "approvedPackagesPolicy" feature private _approvedPackagesPolicy: ApprovedPackagesPolicy; @@ -737,10 +737,10 @@ export class RushConfiguration { } /** - * Gets the list of warning message substrings which should be suppressed (treated as standard - * log messages rather than warnings). + * Gets a list of regular expressions for suppressing warnings. If a warning message + * matches any of these, it should be treated as a standard message rather than an error. */ - public get suppressedWarnings(): string[] { + public get suppressedWarnings(): RegExp[] { return this._suppressedWarnings; } @@ -984,7 +984,8 @@ export class RushConfiguration { this._ensureConsistentVersions = !!rushConfigurationJson.ensureConsistentVersions; - this._suppressedWarnings = rushConfigurationJson.suppressedWarnings || []; + const suppressedWarnings: string[] = rushConfigurationJson.suppressedWarnings || []; + this._suppressedWarnings = suppressedWarnings.map((value: string) => new RegExp(value)); this._pnpmOptions = new PnpmOptionsConfiguration(rushConfigurationJson.pnpmOptions || {}); this._yarnOptions = new YarnOptionsConfiguration(rushConfigurationJson.yarnOptions || { }); diff --git a/apps/rush-lib/src/logic/taskRunner/ProjectTask.ts b/apps/rush-lib/src/logic/taskRunner/ProjectTask.ts index 6f176829fd3..43033f28d96 100644 --- a/apps/rush-lib/src/logic/taskRunner/ProjectTask.ts +++ b/apps/rush-lib/src/logic/taskRunner/ProjectTask.ts @@ -162,7 +162,7 @@ export class ProjectTask implements ITaskDefinition { task.stderr.on('data', (data: string) => { // If this error matches any of the suppressed warnings from the config, write it to // stdout instead of stderr and don't treat the task as having a warning/error. - if (this._rushConfiguration.suppressedWarnings.some((warning: string) => data.indexOf(warning) !== -1)) { + if (this._rushConfiguration.suppressedWarnings.some((warning: RegExp) => warning.test(data))) { writer.write(data); } else { writer.writeError(data); diff --git a/rush.json b/rush.json index 607b320e7a1..1f1a345d668 100644 --- a/rush.json +++ b/rush.json @@ -224,14 +224,10 @@ // "hotfixChangeEnabled": false, /** - * If a warning message includes any substrings listed here, it should be treated as a standard - * log message rather than a warning. This prevents inconsequential warning messages caused by - * external packages from breaking incremental builds (packages marked as "success with warnings" - * will be rebuilt on each rush build). - * - * For example, certain npm packages with C++ bindings intermittently cause Node to display a warning - * starting with "Using a domain property in MakeCallback is deprecated." The source of this warning - * has been hard to track down, so it can be added to this list to make incremental builds work. + * If a warning message matches any of the regular expressions listed here, it should be treated + * as a standard log message rather than a warning. This prevents inconsequential warning messages + * caused by external packages from breaking incremental builds (packages marked as "success with + * warnings" will be rebuilt on each rush build). */ // "suppressedWarnings": [],