Skip to content

Commit 155e4ab

Browse files
authored
feat(material/schematics): add the scaffolding for an mdc-migration schematic (#23804)
1 parent 202c667 commit 155e4ab

32 files changed

+9555
-0
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
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
2+
# For additional information regarding the format and rule options, please see:
3+
# https://github.com/browserslist/browserslist#queries
4+
5+
# For the full list of supported browsers by the Angular framework, please see:
6+
# https://angular.io/guide/browser-support
7+
8+
# You can see what browsers were selected by your queries by running:
9+
# npx browserslist
10+
11+
last 1 Chrome version
12+
last 1 Firefox version
13+
last 2 Edge major versions
14+
last 2 Safari major versions
15+
last 2 iOS major versions
16+
Firefox ESR
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Editor configuration, see https://editorconfig.org
2+
root = true
3+
4+
[*]
5+
charset = utf-8
6+
indent_style = space
7+
indent_size = 2
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
11+
[*.ts]
12+
quote_type = single
13+
14+
[*.md]
15+
max_line_length = off
16+
trim_trailing_whitespace = false

integration/mdc-migration/.gitignore

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# See http://help.github.com/ignore-files/ for more about ignoring files.
2+
3+
# compiled output
4+
/dist
5+
/tmp
6+
/out-tsc
7+
# Only exists if Bazel was run
8+
/bazel-out
9+
10+
# dependencies
11+
/node_modules
12+
13+
# profiling files
14+
chrome-profiler-events*.json
15+
16+
# IDEs and editors
17+
/.idea
18+
.project
19+
.classpath
20+
.c9/
21+
*.launch
22+
.settings/
23+
*.sublime-workspace
24+
25+
# IDE - VSCode
26+
.vscode/*
27+
!.vscode/settings.json
28+
!.vscode/tasks.json
29+
!.vscode/launch.json
30+
!.vscode/extensions.json
31+
.history/*
32+
33+
# misc
34+
/.sass-cache
35+
/connect.lock
36+
/coverage
37+
/libpeerconnection.log
38+
npm-debug.log
39+
yarn-error.log
40+
testem.log
41+
/typings
42+
43+
# System Files
44+
.DS_Store
45+
Thumbs.db

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/README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# MdcMigrationExample
2+
3+
This project serves as an example app to test the MDC migration schematic on.
4+
5+
## Development server
6+
7+
Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.
8+
9+
## Code scaffolding
10+
11+
Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`.
12+
13+
## Build
14+
15+
Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory.
16+
17+
## Running unit tests
18+
19+
Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).
20+
21+
## Running end-to-end tests
22+
23+
Run `ng e2e` to execute the end-to-end tests via a platform of your choice. To use this command, you need to first add a package that implements end-to-end testing capabilities.
24+
25+
## Further help
26+
27+
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page.
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
{
2+
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3+
"version": 1,
4+
"newProjectRoot": "projects",
5+
"projects": {
6+
"mdc-migration": {
7+
"projectType": "application",
8+
"schematics": {
9+
"@schematics/angular:component": {
10+
"style": "scss"
11+
},
12+
"@schematics/angular:application": {
13+
"strict": true
14+
}
15+
},
16+
"root": "",
17+
"sourceRoot": "src",
18+
"prefix": "app",
19+
"architect": {
20+
"build": {
21+
"builder": "@angular-devkit/build-angular:browser",
22+
"options": {
23+
"outputPath": "dist/mdc-migration",
24+
"index": "src/index.html",
25+
"main": "src/main.ts",
26+
"polyfills": "src/polyfills.ts",
27+
"tsConfig": "tsconfig.app.json",
28+
"inlineStyleLanguage": "scss",
29+
"assets": [
30+
"src/favicon.ico",
31+
"src/assets"
32+
],
33+
"styles": [
34+
"src/styles.scss"
35+
],
36+
"scripts": []
37+
},
38+
"configurations": {
39+
"production": {
40+
"budgets": [
41+
{
42+
"type": "initial",
43+
"maximumWarning": "500kb",
44+
"maximumError": "1mb"
45+
},
46+
{
47+
"type": "anyComponentStyle",
48+
"maximumWarning": "2kb",
49+
"maximumError": "4kb"
50+
}
51+
],
52+
"fileReplacements": [
53+
{
54+
"replace": "src/environments/environment.ts",
55+
"with": "src/environments/environment.prod.ts"
56+
}
57+
],
58+
"outputHashing": "all"
59+
},
60+
"development": {
61+
"buildOptimizer": false,
62+
"optimization": false,
63+
"vendorChunk": true,
64+
"extractLicenses": false,
65+
"sourceMap": true,
66+
"namedChunks": true
67+
}
68+
},
69+
"defaultConfiguration": "production"
70+
},
71+
"serve": {
72+
"builder": "@angular-devkit/build-angular:dev-server",
73+
"configurations": {
74+
"production": {
75+
"browserTarget": "mdc-migration:build:production"
76+
},
77+
"development": {
78+
"browserTarget": "mdc-migration:build:development"
79+
}
80+
},
81+
"defaultConfiguration": "development"
82+
},
83+
"extract-i18n": {
84+
"builder": "@angular-devkit/build-angular:extract-i18n",
85+
"options": {
86+
"browserTarget": "mdc-migration:build"
87+
}
88+
},
89+
"test": {
90+
"builder": "@angular-devkit/build-angular:karma",
91+
"options": {
92+
"main": "src/test.ts",
93+
"polyfills": "src/polyfills.ts",
94+
"tsConfig": "tsconfig.spec.json",
95+
"karmaConfig": "karma.conf.js",
96+
"inlineStyleLanguage": "scss",
97+
"assets": [
98+
"src/favicon.ico",
99+
"src/assets"
100+
],
101+
"styles": [
102+
"src/styles.scss"
103+
],
104+
"scripts": [],
105+
"watch": false
106+
}
107+
}
108+
}
109+
}
110+
},
111+
"defaultProject": "mdc-migration"
112+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// Karma configuration file, see link for more information
2+
// https://karma-runner.github.io/1.0/config/configuration-file.html
3+
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+
9+
module.exports = function (config) {
10+
config.set({
11+
basePath: '',
12+
frameworks: ['jasmine', '@angular-devkit/build-angular'],
13+
plugins: [
14+
require('karma-jasmine'),
15+
require('karma-chrome-launcher'),
16+
require('karma-jasmine-html-reporter'),
17+
require('karma-coverage'),
18+
require('@angular-devkit/build-angular/plugins/karma'),
19+
],
20+
client: {
21+
jasmine: {
22+
// you can add configuration options for Jasmine here
23+
// the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html
24+
// for example, you can disable the random execution with `random: false`
25+
// or set a specific seed with `seed: 4321`
26+
},
27+
clearContext: false, // leave Jasmine Spec Runner output visible in browser
28+
},
29+
jasmineHtmlReporter: {
30+
suppressAll: true, // removes the duplicated traces
31+
},
32+
coverageReporter: {
33+
dir: require('path').join(__dirname, './coverage/mdc-migration'),
34+
subdir: '.',
35+
reporters: [{type: 'html'}, {type: 'text-summary'}],
36+
},
37+
reporters: ['progress', 'kjhtml'],
38+
port: 9876,
39+
colors: true,
40+
logLevel: config.LOG_INFO,
41+
autoWatch: true,
42+
browsers: ['ChromeHeadless'],
43+
singleRun: false,
44+
restartOnFileChange: true,
45+
});
46+
};
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+
}

0 commit comments

Comments
 (0)