Skip to content

Commit e96fbd3

Browse files
committed
refactor(@angular-devkit/build-angular): change errors and warnings messages
Sometimes the WARNING IN/ERROR IN can lead of ambiguous messages - Use `Warning` instead of `WARNING IN` - Use `Error` instead of `Error In`
1 parent 84e07e9 commit e96fbd3

File tree

15 files changed

+35
-38
lines changed

15 files changed

+35
-38
lines changed

packages/angular/cli/models/schematic-command.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ export abstract class SchematicCommand<
442442

443443
if (positions.length > 0) {
444444
const warning = tags.oneLine`
445-
WARNING: This command may not execute successfully.
445+
Warning: This command may not execute successfully.
446446
The package/collection may not support the 'targets' field within '${configPath}'.
447447
This can be corrected by renaming the following 'targets' fields to 'architect':
448448
`;

packages/angular_devkit/build_angular/src/browser/index.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ export function buildWebpackBrowser(
250250

251251
if (target > ScriptTarget.ES2015 && isDifferentialLoadingNeeded) {
252252
context.logger.warn(tags.stripIndent`
253-
WARNING: Using differential loading with targets ES5 and ES2016 or higher may
253+
Warning: Using differential loading with targets ES5 and ES2016 or higher may
254254
cause problems. Browsers with support for ES2015 will load the ES2016+ scripts
255255
referenced with script[type="module"] but they may not support ES2016+ syntax.
256256
`);
@@ -262,7 +262,7 @@ export function buildWebpackBrowser(
262262
const browsers =
263263
(hasIE9 ? 'IE 9' + (hasIE10 ? ' & ' : '') : '') + (hasIE10 ? 'IE 10' : '');
264264
context.logger.warn(
265-
`WARNING: Support was requested for ${browsers} in the project's browserslist configuration. ` +
265+
`Warning: Support was requested for ${browsers} in the project's browserslist configuration. ` +
266266
(hasIE9 && hasIE10 ? 'These browsers are' : 'This browser is') +
267267
' no longer officially supported with Angular v11 and higher.' +
268268
'\nFor additional information: https://v10.angular.io/guide/deprecations#ie-9-10-and-mobile',
@@ -654,13 +654,12 @@ export function buildWebpackBrowser(
654654
const budgets = options.budgets || [];
655655
const budgetFailures = checkBudgets(budgets, webpackStats, processResults);
656656
for (const { severity, message } of budgetFailures) {
657-
const msg = `budgets: ${message}`;
658657
switch (severity) {
659658
case ThresholdSeverity.Warning:
660-
webpackStats.warnings.push(msg);
659+
webpackStats.warnings.push(message);
661660
break;
662661
case ThresholdSeverity.Error:
663-
webpackStats.errors.push(msg);
662+
webpackStats.errors.push(message);
664663
break;
665664
default:
666665
assertNever(severity);

packages/angular_devkit/build_angular/src/browser/specs/browser-support_spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ describe('Browser Builder browser support', () => {
3535

3636
const fullLog = logs.join();
3737
expect(fullLog).toContain(
38-
"WARNING: Support was requested for IE 9 in the project's browserslist configuration.",
38+
"Warning: Support was requested for IE 9 in the project's browserslist configuration.",
3939
);
4040
expect(fullLog).toContain('This browser is ');
4141

@@ -55,7 +55,7 @@ describe('Browser Builder browser support', () => {
5555

5656
const fullLog = logs.join();
5757
expect(fullLog).toContain(
58-
"WARNING: Support was requested for IE 10 in the project's browserslist configuration.",
58+
"Warning: Support was requested for IE 10 in the project's browserslist configuration.",
5959
);
6060
expect(fullLog).toContain('This browser is ');
6161

@@ -75,7 +75,7 @@ describe('Browser Builder browser support', () => {
7575

7676
const fullLog = logs.join();
7777
expect(fullLog).toContain(
78-
"WARNING: Support was requested for IE 9 & IE 10 in the project's browserslist configuration.",
78+
"Warning: Support was requested for IE 9 & IE 10 in the project's browserslist configuration.",
7979
);
8080
expect(fullLog).toContain('These browsers are ');
8181

packages/angular_devkit/build_angular/src/browser/specs/bundle-budgets_spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ describe('Browser Builder bundle budgets', () => {
3333
const run = await architect.scheduleTarget(targetSpec, overrides, { logger });
3434
const output = await run.result;
3535
expect(output.success).toBe(true);
36-
expect(logs.join()).not.toContain('WARNING');
36+
expect(logs.join()).not.toContain('Warning');
3737
await run.stop();
3838
});
3939

@@ -61,7 +61,7 @@ describe('Browser Builder bundle budgets', () => {
6161
const run = await architect.scheduleTarget(targetSpec, overrides, { logger });
6262
const output = await run.result;
6363
expect(output.success).toBe(true);
64-
expect(logs.join()).toContain('WARNING');
64+
expect(logs.join()).toContain('Warning');
6565
await run.stop();
6666
});
6767

@@ -100,7 +100,7 @@ describe('Browser Builder bundle budgets', () => {
100100
const output = await run.result;
101101
expect(output.success).toBe(true);
102102
expect(logs.length).toBe(2);
103-
expect(logs.join()).toMatch(`WARNING.+app\.component\.${ext}`);
103+
expect(logs.join()).toMatch(`Warning.+app\.component\.${ext}`);
104104
await run.stop();
105105
});
106106
});
@@ -140,7 +140,7 @@ describe('Browser Builder bundle budgets', () => {
140140
const output = await run.result;
141141
expect(output.success).toBe(false);
142142
expect(logs.length).toBe(2);
143-
expect(logs.join()).toMatch(`ERROR.+app\.component\.${ext}`);
143+
expect(logs.join()).toMatch(`Error.+app\.component\.${ext}`);
144144
await run.stop();
145145
});
146146
});

packages/angular_devkit/build_angular/src/browser/specs/common-js-warning_spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ describe('Browser Builder commonjs warning', () => {
4646
const run = await architect.scheduleTarget(targetSpec, { aot }, { logger });
4747
const output = await run.result;
4848
expect(output.success).toBe(true);
49-
expect(logs.join()).not.toContain('WARNING');
49+
expect(logs.join()).not.toContain('Warning');
5050
await run.stop();
5151
});
5252

@@ -60,7 +60,7 @@ describe('Browser Builder commonjs warning', () => {
6060
const output = await run.result;
6161
expect(output.success).toBe(true);
6262
const logMsg = logs.join();
63-
expect(logMsg).toMatch(/WARNING in.+app\.component\.ts depends on 'bootstrap'\. CommonJS or AMD dependencies/);
63+
expect(logMsg).toMatch(/Warning: .+app\.component\.ts depends on 'bootstrap'\. CommonJS or AMD dependencies/);
6464
expect(logMsg).not.toContain('jquery', 'Should not warn on transitive CommonJS packages which parent is also CommonJS.');
6565
await run.stop();
6666
});
@@ -83,7 +83,7 @@ describe('Browser Builder commonjs warning', () => {
8383
const run = await architect.scheduleTarget(targetSpec, overrides, { logger });
8484
const output = await run.result;
8585
expect(output.success).toBe(true);
86-
expect(logs.join()).not.toContain('WARNING');
86+
expect(logs.join()).not.toContain('Warning');
8787
await run.stop();
8888
});
8989

@@ -97,7 +97,7 @@ describe('Browser Builder commonjs warning', () => {
9797
const output = await run.result;
9898
expect(output.success).toBe(true);
9999

100-
expect(logs.join()).not.toContain('WARNING');
100+
expect(logs.join()).not.toContain('Warning');
101101
await run.stop();
102102
});
103103

packages/angular_devkit/build_angular/src/browser/specs/web-worker_spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ describe('Browser Builder Web Worker support', () => {
104104
const mainContent = virtualFs.fileBufferToString(
105105
host.scopedSync().read(join(outputPath, 'main.js')));
106106
expect(mainContent).toContain('0.worker.js');
107-
expect(logs.join().includes('WARNING')).toBe(false, 'Should show no warnings.');
107+
expect(logs.join().includes('Warning')).toBe(false, 'Should show no warnings.');
108108
});
109109

110110
it('minimizes and hashes worker', async () => {

packages/angular_devkit/build_angular/src/dev-server/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ export function buildServerConfig(
376376
&& serverOptions.host !== 'localhost'
377377
) {
378378
logger.warn(tags.stripIndent`
379-
WARNING: This is a simple server for use in testing or debugging Angular applications
379+
Warning: This is a simple server for use in testing or debugging Angular applications
380380
locally. It hasn't been reviewed for security issues.
381381
382382
Binding this server to an open connection can result in compromising your application or
@@ -388,7 +388,7 @@ export function buildServerConfig(
388388

389389
if (serverOptions.disableHostCheck) {
390390
logger.warn(tags.oneLine`
391-
WARNING: Running a server with --disable-host-check is a security risk.
391+
Warning: Running a server with --disable-host-check is a security risk.
392392
See https://medium.com/webpack/webpack-dev-server-middleware-security-issues-1489d950874a
393393
for more information.
394394
`);
@@ -466,7 +466,7 @@ export function buildServePath(
466466
const showWarning = serverOptions.servePathDefaultWarning;
467467
if (defaultPath == null && showWarning) {
468468
logger.warn(tags.oneLine`
469-
WARNING: --deploy-url and/or --base-href contain unsupported values for ng serve. Default
469+
Warning: --deploy-url and/or --base-href contain unsupported values for ng serve. Default
470470
serve path of '/' used. Use --serve-path to override.
471471
`);
472472
}

packages/angular_devkit/build_angular/src/server/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export function execute(
7474
(main as string).includes('__ivy_ngcc__')
7575
) {
7676
context.logger.warn(tags.stripIndent`
77-
WARNING: Turning off 'bundleDependencies' with Ivy may result in undefined behaviour
77+
Warning: Turning off 'bundleDependencies' with Ivy may result in undefined behaviour
7878
unless 'node_modules' are transformed using the standalone Angular compatibility compiler (NGCC).
7979
See: http://v9.angular.io/guide/ivy#ivy-and-universal-app-shell
8080
`);

packages/angular_devkit/build_angular/src/webpack/configs/browser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export function getBrowserConfig(wco: WebpackConfigOptions): webpack.Configurati
4141
// TODO_WEBPACK_5: Investigate build/serve issues with the `license-webpack-plugin` package
4242
if (extractLicenses && isWebpackFiveOrHigher()) {
4343
wco.logger.warn(
44-
'WARNING: License extraction is currently disabled when using Webpack 5. ' +
44+
'Warning: License extraction is currently disabled when using Webpack 5. ' +
4545
'This is temporary and will be corrected in a future update.',
4646
);
4747
} else if (extractLicenses) {

packages/angular_devkit/build_angular/src/webpack/configs/common.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ export function getCommonConfig(wco: WebpackConfigOptions): Configuration {
467467
wco.tsConfig.options.target >= ScriptTarget.ES2017
468468
) {
469469
wco.logger.warn(tags.stripIndent`
470-
WARNING: Zone.js does not support native async/await in ES2017.
470+
Warning: Zone.js does not support native async/await in ES2017.
471471
These blocks are not intercepted by zone.js and will not triggering change detection.
472472
See: https://github.com/angular/zone.js/pull/1140 for more information.
473473
`);

packages/angular_devkit/build_angular/src/webpack/utils/stats.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ export function statsWarningsToString(json: any, statsConfig: any): string {
174174
if (!ERRONEOUS_WARNINGS_FILTER(warning)) {
175175
continue;
176176
}
177-
output += yb(`WARNING in ${warning}\n\n`);
177+
output += yb(`Warning: ${warning}\n\n`);
178178
} else {
179179
if (!ERRONEOUS_WARNINGS_FILTER(warning.message)) {
180180
continue;
@@ -218,7 +218,7 @@ export function statsErrorsToString(json: any, statsConfig: any): string {
218218
let output = '';
219219
for (const error of errors as (string | WebpackDiagnostic)[]) {
220220
if (typeof error === 'string') {
221-
output += r(`ERROR in ${error}\n\n`);
221+
output += r(`Error: ${error}\n\n`);
222222
} else {
223223
const file = error.file || error.moduleName;
224224
if (file) {

packages/ngtools/webpack/src/type_checker.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ export class TypeChecker {
114114
if (!cancellationToken.isCancellationRequested()) {
115115
reportDiagnostics(
116116
allDiagnostics,
117-
msg => this.sendMessage(new LogMessage('error', 'ERROR in ' + msg)),
118-
msg => this.sendMessage(new LogMessage('warn', 'WARNING in ' + msg)),
117+
msg => this.sendMessage(new LogMessage('error', 'Error: ' + msg)),
118+
msg => this.sendMessage(new LogMessage('warn', 'Warning: ' + msg)),
119119
);
120120
}
121121
}

tests/legacy-cli/e2e/tests/build/bundle-budgets.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import { getGlobalVariable } from '../../utils/env';
109
import { ng } from '../../utils/process';
1110
import { updateJsonFile } from '../../utils/project';
1211
import { expectToFail } from '../../utils/utils';
@@ -39,7 +38,7 @@ export default function () {
3938
})
4039
.then(() => expectToFail(() => ng('build', '--optimization')))
4140
.then(errorMessage => {
42-
if (!/ERROR in budgets/.test(errorMessage)) {
41+
if (!/Error.+budgets/.test(errorMessage)) {
4342
throw new Error(cfg.message);
4443
}
4544
});
@@ -51,7 +50,7 @@ export default function () {
5150
})
5251
.then(() => ng('build', '--optimization'))
5352
.then(({ stderr }) => {
54-
if (!/WARNING in budgets/.test(stderr)) {
53+
if (!/Warning.+budgets/.test(stderr)) {
5554
throw new Error(cfg.message);
5655
}
5756
});
@@ -63,7 +62,7 @@ export default function () {
6362
})
6463
.then(() => ng('build', '--optimization'))
6564
.then(({ stderr }) => {
66-
if (/(WARNING|ERROR)/.test(stderr)) {
65+
if (/(Warning|Error)/.test(stderr)) {
6766
throw new Error(cfg.message);
6867
}
6968
});

tests/legacy-cli/e2e/tests/build/rebuild-deps-type-check.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@ import {
44
execAndWaitForOutputToMatch,
55
} from '../../utils/process';
66
import {writeFile, prependToFile, appendToFile} from '../../utils/fs';
7-
import {getGlobalVariable} from '../../utils/env';
87

98

109
const doneRe =
1110
/: Compiled successfully.|: Failed to compile./;
12-
const errorRe = /ERROR in/;
11+
const errorRe = /Error/;
1312

1413

1514
export default function() {
@@ -49,7 +48,7 @@ export default function() {
4948
]))
5049
.then((results) => {
5150
const stderr = results[0].stderr;
52-
if (!/ERROR in (.*src\/)?main\.ts/.test(stderr)) {
51+
if (!/Error: (.*src\/)?main\.ts/.test(stderr)) {
5352
throw new Error('Expected an error but none happened.');
5453
}
5554
})
@@ -63,7 +62,7 @@ export default function() {
6362
]))
6463
.then((results) => {
6564
const stderr = results[0].stderr;
66-
if (!/ERROR in (.*src\/)?main\.ts/.test(stderr)) {
65+
if (!/Error: (.*src\/)?main\.ts/.test(stderr)) {
6766
throw new Error('Expected an error to still be there but none was.');
6867
}
6968
})
@@ -78,7 +77,7 @@ export default function() {
7877
]))
7978
.then((results) => {
8079
const stderr = results[0].stderr;
81-
if (/ERROR in (.*src\/)?main\.ts/.test(stderr)) {
80+
if (/Error: (.*src\/)?main\.ts/.test(stderr)) {
8281
throw new Error('Expected no error but an error was shown.');
8382
}
8483
})

tests/legacy-cli/e2e/tests/misc/circular-dependency.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default async function () {
88
await prependToFile('src/app/app.component.ts',
99
`import { AppModule } from './app.module'; console.log(AppModule);`);
1010
const { stderr } = await ng('build', '--show-circular-dependencies');
11-
if (!stderr.match(/WARNING in Circular dependency detected/)) {
11+
if (!stderr.match(/Warning: Circular dependency detected/)) {
1212
throw new Error('Expected to have circular dependency warning in output.');
1313
}
1414
}

0 commit comments

Comments
 (0)