fix(bazel): Support new e2e project layout (#29318)
https://github.com/angular/angular-cli/pull/13780 changes the project layout for the e2e application. It is no longer a separate project and the e2e directory is now located alongside the existing project. This commit updates Bazel scheamtics to support both old and new project layout. PR Close #29318
This commit is contained in:

committed by
Matias Niemelä

parent
3facdebd07
commit
8ef690c342
@ -8,14 +8,18 @@
|
||||
* @fileoverview Schematics for ng-new project that builds with Bazel.
|
||||
*/
|
||||
|
||||
import {JsonAstObject, parseJsonAst, strings} from '@angular-devkit/core';
|
||||
import {Rule, SchematicContext, SchematicsException, Tree, apply, applyTemplates, chain, mergeWith, move, schematic, url} from '@angular-devkit/schematics';
|
||||
import {JsonAstObject, parseJsonAst} from '@angular-devkit/core';
|
||||
import {Rule, SchematicContext, SchematicsException, Tree, apply, applyTemplates, chain, mergeWith, url} from '@angular-devkit/schematics';
|
||||
import {getWorkspacePath} from '@schematics/angular/utility/config';
|
||||
import {findPropertyInAstObject, insertPropertyInAstObjectInOrder} from '@schematics/angular/utility/json-utils';
|
||||
import {validateProjectName} from '@schematics/angular/utility/validation';
|
||||
|
||||
import {isJsonAstObject, removeKeyValueInAstObject, replacePropertyInAstObject} from '../utility/json-utils';
|
||||
import {findE2eArchitect} from '../utility/workspace-utils';
|
||||
|
||||
import {Schema} from './schema';
|
||||
|
||||
|
||||
/**
|
||||
* Packages that build under Bazel require additional dev dependencies. This
|
||||
* function adds those dependencies to "devDependencies" section in
|
||||
@ -98,6 +102,9 @@ function updateGitignore() {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the architect in angular.json to use Bazel builder.
|
||||
*/
|
||||
function updateAngularJsonToUseBazelBuilder(options: Schema): Rule {
|
||||
return (host: Tree, context: SchematicContext) => {
|
||||
const {name} = options;
|
||||
@ -153,13 +160,10 @@ function updateAngularJsonToUseBazelBuilder(options: Schema): Rule {
|
||||
},
|
||||
indent);
|
||||
|
||||
const e2e = `${options.name}-e2e`;
|
||||
const e2eNode = findPropertyInAstObject(projects as JsonAstObject, e2e);
|
||||
if (e2eNode) {
|
||||
const architect =
|
||||
findPropertyInAstObject(e2eNode as JsonAstObject, 'architect') as JsonAstObject;
|
||||
const e2eArchitect = findE2eArchitect(workspaceJsonAst, name);
|
||||
if (e2eArchitect) {
|
||||
replacePropertyInAstObject(
|
||||
recorder, architect, 'e2e', {
|
||||
recorder, e2eArchitect, 'e2e', {
|
||||
builder: '@angular/bazel:build',
|
||||
options: {
|
||||
bazelCommand: 'test',
|
||||
|
Reference in New Issue
Block a user