|
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
|
@@ -99,6 +103,9 @@ function updateGitignore() {
|
99 | 103 | };
|
100 | 104 | }
|
101 | 105 |
|
| 106 | +/** |
| 107 | + * Change the architect in angular.json to use Bazel builder. |
| 108 | + */ |
102 | 109 | function updateAngularJsonToUseBazelBuilder(options: Schema): Rule {
|
103 | 110 | return (host: Tree, context: SchematicContext) => {
|
104 | 111 | const {name} = options;
|
@@ -154,13 +161,10 @@ function updateAngularJsonToUseBazelBuilder(options: Schema): Rule {
|
154 | 161 | },
|
155 | 162 | indent);
|
156 | 163 |
|
157 |
| - const e2e = `${options.name}-e2e`; |
158 |
| - const e2eNode = findPropertyInAstObject(projects as JsonAstObject, e2e); |
159 |
| - if (e2eNode) { |
160 |
| - const architect = |
161 |
| - findPropertyInAstObject(e2eNode as JsonAstObject, 'architect') as JsonAstObject; |
| 164 | + const e2eArchitect = findE2eArchitect(workspaceJsonAst, name); |
| 165 | + if (e2eArchitect) { |
162 | 166 | replacePropertyInAstObject(
|
163 |
| - recorder, architect, 'e2e', { |
| 167 | + recorder, e2eArchitect, 'e2e', { |
164 | 168 | builder: '@angular/bazel:build',
|
165 | 169 | options: {
|
166 | 170 | bazelCommand: 'test',
|
|
0 commit comments