Skip to content

Commit a9975da

Browse files
dgp1130clydin
authored andcommitted
refactor(@angular-devkit/build-angular): adds protractor builder which throws with a clear error message
This should help users who upgrade more easily discover that the builder has been removed and find the resources needed to migrate any existing tests. (cherry picked from commit ed8f96a)
1 parent ea8379b commit a9975da

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

packages/angular_devkit/build_angular/builders.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@
4242
"schema": "./src/builders/web-test-runner/schema.json",
4343
"description": "Run unit tests with Web Test Runner."
4444
},
45+
"protractor": {
46+
"implementation": "./src/builders/protractor-error",
47+
"schema": "./src/builders/protractor/schema.json",
48+
"description": "Throw an error that Protractor is end-of-life and no longer supported."
49+
},
4550
"private-protractor": {
4651
"implementation": "./src/builders/protractor",
4752
"schema": "./src/builders/protractor/schema.json",
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* @license
3+
* Copyright Google LLC All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.dev/license
7+
*/
8+
9+
import { BuilderContext, createBuilder } from '@angular-devkit/architect';
10+
import { Schema as ProtractorBuilderOptions } from '../protractor/schema';
11+
12+
export default createBuilder<ProtractorBuilderOptions>(
13+
(_options: ProtractorBuilderOptions, context: BuilderContext) => {
14+
context.logger.error(
15+
'Protractor has reached end-of-life and is no longer supported. For additional information and alternatives, please see https://blog.angular.dev/protractor-deprecation-update-august-2023-2beac7402ce0.',
16+
);
17+
18+
return { success: false };
19+
},
20+
);
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { execAndCaptureError } from '../../utils/process';
2+
import { updateJsonFile } from '../../utils/project';
3+
4+
export default async function () {
5+
// Revert the `private-protractor` builder name back to the previous `protractor`.
6+
await updateJsonFile('angular.json', (config) => {
7+
config.projects['test-project'].architect['e2e'].builder =
8+
'@angular-devkit/build-angular:protractor';
9+
});
10+
11+
const error = await execAndCaptureError('ng', ['e2e']);
12+
if (!error.message.includes('Protractor has reached end-of-life')) {
13+
throw new Error(`Protractor did not fail with an appropriate message. Got:\n${error.message}`);
14+
}
15+
}

0 commit comments

Comments
 (0)