|
8 | 8 | * @fileoverview Schematics for ng-new project that builds with Bazel.
|
9 | 9 | */
|
10 | 10 |
|
11 |
| -import {JsonAstObject, parseJsonAst, strings} from '@angular-devkit/core'; |
12 |
| -import {Rule, SchematicContext, SchematicsException, Tree, apply, applyTemplates, chain, mergeWith, move, schematic, url} from '@angular-devkit/schematics'; |
| 11 | +import {JsonAstObject, parseJsonAst} from '@angular-devkit/core'; |
| 12 | +import {Rule, SchematicContext, SchematicsException, Tree, apply, applyTemplates, chain, mergeWith, url} from '@angular-devkit/schematics'; |
13 | 13 | import {getWorkspacePath} from '@schematics/angular/utility/config';
|
14 | 14 | import {findPropertyInAstObject, insertPropertyInAstObjectInOrder} from '@schematics/angular/utility/json-utils';
|
15 | 15 | import {validateProjectName} from '@schematics/angular/utility/validation';
|
| 16 | + |
16 | 17 | import {isJsonAstObject, removeKeyValueInAstObject, replacePropertyInAstObject} from '../utility/json-utils';
|
| 18 | +import {findE2eArchitect} from '../utility/workspace-utils'; |
| 19 | + |
17 | 20 | import {Schema} from './schema';
|
18 | 21 |
|
| 22 | + |
19 | 23 | /**
|
20 | 24 | * Packages that build under Bazel require additional dev dependencies. This
|
21 | 25 | * function adds those dependencies to "devDependencies" section in
|
@@ -98,6 +102,9 @@ function updateGitignore() {
|
98 | 102 | };
|
99 | 103 | }
|
100 | 104 |
|
| 105 | +/** |
| 106 | + * Change the architect in angular.json to use Bazel builder. |
| 107 | + */ |
101 | 108 | function updateAngularJsonToUseBazelBuilder(options: Schema): Rule {
|
102 | 109 | return (host: Tree, context: SchematicContext) => {
|
103 | 110 | const {name} = options;
|
@@ -153,13 +160,10 @@ function updateAngularJsonToUseBazelBuilder(options: Schema): Rule {
|
153 | 160 | },
|
154 | 161 | indent);
|
155 | 162 |
|
156 |
| - const e2e = `${options.name}-e2e`; |
157 |
| - const e2eNode = findPropertyInAstObject(projects as JsonAstObject, e2e); |
158 |
| - if (e2eNode) { |
159 |
| - const architect = |
160 |
| - findPropertyInAstObject(e2eNode as JsonAstObject, 'architect') as JsonAstObject; |
| 163 | + const e2eArchitect = findE2eArchitect(workspaceJsonAst, name); |
| 164 | + if (e2eArchitect) { |
161 | 165 | replacePropertyInAstObject(
|
162 |
| - recorder, architect, 'e2e', { |
| 166 | + recorder, e2eArchitect, 'e2e', { |
163 | 167 | builder: '@angular/bazel:build',
|
164 | 168 | options: {
|
165 | 169 | bazelCommand: 'test',
|
|
0 commit comments