fix(bazel): support running ng-add on minimal applications (#29681)
Minimal applications don't have `test` and `e2e` targets but we are not currently checking if they exists. Fixes #29680 PR Close #29681
This commit is contained in:
parent
8e83b3bec1
commit
9810c6c0f9
@ -154,15 +154,18 @@ function updateAngularJsonToUseBazelBuilder(options: Schema): Rule {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
indent);
|
indent);
|
||||||
replacePropertyInAstObject(
|
|
||||||
recorder, architect, 'test', {
|
if (findPropertyInAstObject(architect, 'test')) {
|
||||||
builder: '@angular/bazel:build',
|
replacePropertyInAstObject(
|
||||||
options: {'bazelCommand': 'test', 'targetLabel': '//src/...'},
|
recorder, architect, 'test', {
|
||||||
},
|
builder: '@angular/bazel:build',
|
||||||
indent);
|
options: {'bazelCommand': 'test', 'targetLabel': '//src/...'},
|
||||||
|
},
|
||||||
|
indent);
|
||||||
|
}
|
||||||
|
|
||||||
const e2eArchitect = findE2eArchitect(workspaceJsonAst, name);
|
const e2eArchitect = findE2eArchitect(workspaceJsonAst, name);
|
||||||
if (e2eArchitect) {
|
if (e2eArchitect && findPropertyInAstObject(e2eArchitect, 'e2e')) {
|
||||||
replacePropertyInAstObject(
|
replacePropertyInAstObject(
|
||||||
recorder, e2eArchitect, 'e2e', {
|
recorder, e2eArchitect, 'e2e', {
|
||||||
builder: '@angular/bazel:build',
|
builder: '@angular/bazel:build',
|
||||||
|
@ -246,4 +246,23 @@ describe('ng-add schematic', () => {
|
|||||||
const json = JSON.parse(content);
|
const json = JSON.parse(content);
|
||||||
expect(json.scripts.postinstall).toBe('ngc -p ./angular-metadata.tsconfig.json');
|
expect(json.scripts.postinstall).toBe('ngc -p ./angular-metadata.tsconfig.json');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should work when run on a minimal project (without test and e2e targets)', () => {
|
||||||
|
host.overwrite('angular.json', JSON.stringify({
|
||||||
|
projects: {
|
||||||
|
'demo': {
|
||||||
|
architect: {
|
||||||
|
build: {},
|
||||||
|
serve: {},
|
||||||
|
'extract-i18n': {
|
||||||
|
builder: '@angular-devkit/build-angular:extract-i18n',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
|
expect(() => schematicRunner.runSchematic('ng-add', defaultOptions, host)).not.toThrowError();
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user