Skip to content

Commit c9c9fd2

Browse files
committed
fix(material/schematics): address comments
1 parent 66fb091 commit c9c9fd2

33 files changed

+2818
-1118
lines changed

.bazelignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@ integration/ng-update-v13/node_modules
55

66
integration/ng-add/.angular
77
integration/ng-add/node_modules
8+
9+
integration/mdc-migration/.angular
10+
integration/mdc-migration/node_modules

integration/mdc-migration-example/package.json

Lines changed: 0 additions & 41 deletions
This file was deleted.

integration/mdc-migration/BUILD.bazel

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
load("@bazel_skylib//lib:dicts.bzl", "dicts")
2+
load("//tools:integration.bzl", "CLI_PROJECT_MAPPINGS")
3+
load("//tools:defaults.bzl", "node_integration_test")
4+
5+
npmPackageMappings = dicts.add(
6+
CLI_PROJECT_MAPPINGS,
7+
{
8+
"//src/cdk:npm_package_archive": "@angular/cdk",
9+
"//src/material:npm_package_archive": "@angular/material",
10+
"//src/material-experimental:npm_package_archive": "@angular/material-experimental",
11+
},
12+
)
13+
14+
node_integration_test(
15+
name = "test",
16+
srcs = glob(["**/*"]),
17+
commands = [
18+
# Note: We use a cache folder within the integration test as otherwise
19+
# the NPM package mapped archive would be cached in the system.
20+
# See: https://github.com/yarnpkg/yarn/issues/2165.
21+
# TODO(devversion): determine if a solution/workaround could live in the test runner.
22+
"yarn install --cache-folder .yarn_cache_folder/",
23+
"yarn ng generate @angular/material:mdc-migration -c all",
24+
"yarn test",
25+
],
26+
npm_packages = npmPackageMappings,
27+
tags = [
28+
# Chromium cannot run in Sandbox. For this test, sandbox is disabled.
29+
# Additionally, we need to disable RBE as this test relies on internet
30+
# access for installing the NPM packages.
31+
"no-sandbox",
32+
"no-remote-exec",
33+
],
34+
)

integration/mdc-migration-example/angular.json renamed to integration/mdc-migration/angular.json

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": 1,
44
"newProjectRoot": "projects",
55
"projects": {
6-
"mdc-migration-example": {
6+
"mdc-migration": {
77
"projectType": "application",
88
"schematics": {
99
"@schematics/angular:component": {
@@ -20,7 +20,7 @@
2020
"build": {
2121
"builder": "@angular-devkit/build-angular:browser",
2222
"options": {
23-
"outputPath": "dist/mdc-migration-example",
23+
"outputPath": "dist/mdc-migration",
2424
"index": "src/index.html",
2525
"main": "src/main.ts",
2626
"polyfills": "src/polyfills.ts",
@@ -72,18 +72,18 @@
7272
"builder": "@angular-devkit/build-angular:dev-server",
7373
"configurations": {
7474
"production": {
75-
"browserTarget": "mdc-migration-example:build:production"
75+
"browserTarget": "mdc-migration:build:production"
7676
},
7777
"development": {
78-
"browserTarget": "mdc-migration-example:build:development"
78+
"browserTarget": "mdc-migration:build:development"
7979
}
8080
},
8181
"defaultConfiguration": "development"
8282
},
8383
"extract-i18n": {
8484
"builder": "@angular-devkit/build-angular:extract-i18n",
8585
"options": {
86-
"browserTarget": "mdc-migration-example:build"
86+
"browserTarget": "mdc-migration:build"
8787
}
8888
},
8989
"test": {
@@ -101,11 +101,12 @@
101101
"styles": [
102102
"src/styles.scss"
103103
],
104-
"scripts": []
104+
"scripts": [],
105+
"watch": false
105106
}
106107
}
107108
}
108109
}
109110
},
110-
"defaultProject": "mdc-migration-example"
111+
"defaultProject": "mdc-migration"
111112
}

integration/mdc-migration-example/karma.conf.js renamed to integration/mdc-migration/karma.conf.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
// Karma configuration file, see link for more information
22
// https://karma-runner.github.io/1.0/config/configuration-file.html
33

4+
// This code runs within Bazel where the environment does not have access to
5+
// the system Chrome browser. To workaround this we use Puppeteer to provide
6+
// a local version of Chromium that can run within Bazel.
7+
process.env.CHROME_BIN = require('puppeteer').executablePath();
8+
49
module.exports = function (config) {
510
config.set({
611
basePath: '',
@@ -25,7 +30,7 @@ module.exports = function (config) {
2530
suppressAll: true, // removes the duplicated traces
2631
},
2732
coverageReporter: {
28-
dir: require('path').join(__dirname, './coverage/mdc-migration-example'),
33+
dir: require('path').join(__dirname, './coverage/mdc-migration'),
2934
subdir: '.',
3035
reporters: [{type: 'html'}, {type: 'text-summary'}],
3136
},
@@ -34,7 +39,7 @@ module.exports = function (config) {
3439
colors: true,
3540
logLevel: config.LOG_INFO,
3641
autoWatch: true,
37-
browsers: ['Chrome'],
42+
browsers: ['ChromeHeadless'],
3843
singleRun: false,
3944
restartOnFileChange: true,
4045
});
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"name": "mdc-migration",
3+
"version": "0.0.0",
4+
"scripts": {
5+
"ng": "ng",
6+
"start": "ng serve",
7+
"build": "ng build",
8+
"watch": "ng build --watch --configuration development",
9+
"test": "ng test"
10+
},
11+
"private": true,
12+
"dependencies": {
13+
"@angular/animations": "^12.2.11",
14+
"@angular/cdk": "^12.2.11",
15+
"@angular/common": "^12.2.11",
16+
"@angular/compiler": "^12.2.11",
17+
"@angular/core": "^12.2.11",
18+
"@angular/forms": "^12.2.11",
19+
"@angular/material": "^12.2.11",
20+
"@angular/platform-browser": "^12.2.11",
21+
"@angular/platform-browser-dynamic": "^12.2.11",
22+
"@angular/router": "^12.2.11",
23+
"rxjs": "^6.5.3",
24+
"tslib": "^2.3.0",
25+
"zone.js": "~0.11.4"
26+
},
27+
"devDependencies": {
28+
"@angular-devkit/build-angular": "^12.2.11",
29+
"@angular/cli": "^12.2.11",
30+
"@angular/compiler-cli": "^12.2.11",
31+
"@types/jasmine": "~3.9.0",
32+
"@types/node": "^12.11.1",
33+
"glob": "^7.2.0",
34+
"jasmine-core": "~3.9.0",
35+
"karma": "~6.3.0",
36+
"karma-chrome-launcher": "~3.1.0",
37+
"karma-coverage": "~2.0.3",
38+
"karma-jasmine": "~4.0.0",
39+
"karma-jasmine-html-reporter": "~1.7.0",
40+
"puppeteer": "^10.4.0",
41+
"typescript": "~4.4.2"
42+
}
43+
}

integration/mdc-migration-example/src/app/app.component.spec.ts renamed to integration/mdc-migration/src/app/app.component.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,18 @@ describe('AppComponent', () => {
1414
expect(app).toBeTruthy();
1515
});
1616

17-
it(`should have as title 'mdc-migration-example'`, () => {
17+
it(`should have as title 'mdc-migration'`, () => {
1818
const fixture = TestBed.createComponent(AppComponent);
1919
const app = fixture.componentInstance;
20-
expect(app.title).toEqual('mdc-migration-example');
20+
expect(app.title).toEqual('mdc-migration');
2121
});
2222

2323
it('should render title', () => {
2424
const fixture = TestBed.createComponent(AppComponent);
2525
fixture.detectChanges();
2626
const compiled = fixture.nativeElement as HTMLElement;
2727
expect(compiled.querySelector('.content span')?.textContent).toContain(
28-
'mdc-migration-example app is running!',
28+
'mdc-migration app is running!',
2929
);
3030
});
3131
});

integration/mdc-migration-example/src/app/app.component.ts renamed to integration/mdc-migration/src/app/app.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ import {Component} from '@angular/core';
66
styleUrls: ['./app.component.scss'],
77
})
88
export class AppComponent {
9-
title = 'mdc-migration-example';
9+
title = 'mdc-migration';
1010
}

integration/mdc-migration-example/src/styles.scss renamed to integration/mdc-migration/src/styles.scss

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
// Custom Theming for Angular Material
33
// For more information: https://material.angular.io/guide/theming
4-
@use '~@angular/material' as mat;
4+
@use '@angular/material' as mat;
55
// Plus imports for other components in your app.
66

77
// Include the common styles for Angular Material. We include this here so that you only
@@ -12,26 +12,26 @@
1212
// Define the palettes for your theme using the Material Design palettes available in palette.scss
1313
// (imported above). For each palette, you can optionally specify a default, lighter, and darker
1414
// hue. Available color palettes: https://material.io/design/color/
15-
$mdc-migration-example-primary: mat.define-palette(mat.$indigo-palette);
16-
$mdc-migration-example-accent: mat.define-palette(mat.$pink-palette, A200, A100, A400);
15+
$mdc-migration-primary: mat.define-palette(mat.$indigo-palette);
16+
$mdc-migration-accent: mat.define-palette(mat.$pink-palette, A200, A100, A400);
1717

1818
// The warn palette is optional (defaults to red).
19-
$mdc-migration-example-warn: mat.define-palette(mat.$red-palette);
19+
$mdc-migration-warn: mat.define-palette(mat.$red-palette);
2020

2121
// Create the theme object. A theme consists of configurations for individual
2222
// theming systems such as "color" or "typography".
23-
$mdc-migration-example-theme: mat.define-light-theme((
23+
$mdc-migration-theme: mat.define-light-theme((
2424
color: (
25-
primary: $mdc-migration-example-primary,
26-
accent: $mdc-migration-example-accent,
27-
warn: $mdc-migration-example-warn,
25+
primary: $mdc-migration-primary,
26+
accent: $mdc-migration-accent,
27+
warn: $mdc-migration-warn,
2828
)
2929
));
3030

3131
// Include theme styles for core and each component used in your app.
3232
// Alternatively, you can import and @include the theme mixins for each component
3333
// that you are using.
34-
@include mat.all-component-themes($mdc-migration-example-theme);
34+
@include mat.all-component-themes($mdc-migration-theme);
3535

3636
/* You can add global styles to this file, and also import other style files */
3737

0 commit comments

Comments
 (0)