Skip to content

Commit 984723e

Browse files
authored
fix(material/schematics): treat lower dependency builder as default builder (angular#29833)
1 parent 02823c0 commit 984723e

File tree

2 files changed

+63
-1
lines changed

2 files changed

+63
-1
lines changed

src/cdk/schematics/utils/project-targets.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ export function getProjectBuildTargets(
3434
builder =>
3535
builder === '@angular-devkit/build-angular:application' ||
3636
builder === '@angular-devkit/build-angular:browser' ||
37-
builder === '@angular-devkit/build-angular:browser-esbuild',
37+
builder === '@angular-devkit/build-angular:browser-esbuild' ||
38+
builder === '@angular/build:application',
3839
);
3940
}
4041

src/material/schematics/ng-add/index.spec.ts

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,67 @@ describe('ng-add schematic', () => {
657657
);
658658
});
659659
});
660+
661+
describe('using lower dependency builder', () => {
662+
beforeEach(() => {
663+
const config = {
664+
version: 1,
665+
projects: {
666+
material: {
667+
projectType: 'application',
668+
root: 'projects/material',
669+
sourceRoot: 'projects/material/src',
670+
prefix: 'app',
671+
architect: {
672+
build: {
673+
builder: '@angular/build:application',
674+
options: {
675+
outputPath: 'dist/material',
676+
index: 'projects/material/src/index.html',
677+
browser: 'projects/material/src/main.ts',
678+
styles: ['projects/material/src/styles.css'],
679+
},
680+
},
681+
},
682+
},
683+
},
684+
};
685+
686+
appTree.overwrite('/angular.json', JSON.stringify(config, null, 2));
687+
});
688+
689+
it('should add a theme', async () => {
690+
const tree = await runner.runSchematic('ng-add-setup-project', baseOptions, appTree);
691+
const workspace = await getWorkspace(tree);
692+
const project = getProjectFromWorkspace(workspace, baseOptions.project);
693+
694+
expectProjectStyleFile(project, '@angular/material/prebuilt-themes/azure-blue.css');
695+
});
696+
697+
it('should add material app styles', async () => {
698+
const tree = await runner.runSchematic('ng-add-setup-project', baseOptions, appTree);
699+
const workspace = await getWorkspace(tree);
700+
const project = getProjectFromWorkspace(workspace, baseOptions.project);
701+
702+
const defaultStylesPath = getProjectStyleFile(project)!;
703+
const htmlContent = tree.read(defaultStylesPath)!.toString();
704+
705+
expect(htmlContent).toContain('html, body { height: 100%; }');
706+
expect(htmlContent).toContain(
707+
'body { margin: 0; font-family: Roboto, "Helvetica Neue", sans-serif; }',
708+
);
709+
});
710+
711+
it('should add the provideAnimationsAsync to the project module', async () => {
712+
const tree = await runner.runSchematic('ng-add-setup-project', baseOptions, appTree);
713+
const fileContent = getFileContent(tree, '/projects/material/src/app/app.module.ts');
714+
715+
expect(fileContent).toContain('provideAnimationsAsync()');
716+
expect(fileContent).toContain(
717+
`import { provideAnimationsAsync } from '@angular/platform-browser/animations/async';`,
718+
);
719+
});
720+
});
660721
});
661722

662723
describe('ng-add schematic - library project', () => {

0 commit comments

Comments
 (0)