@dugararchit/cdk 0.0.0-dugararchit
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/_index.scss +8 -0
- package/a11y/_index.import.scss +2 -0
- package/a11y/_index.scss +102 -0
- package/a11y/a11y-prebuilt.scss +3 -0
- package/fesm2022/stagefright5-cdk-a11y.mjs +2381 -0
- package/fesm2022/stagefright5-cdk-a11y.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-accordion.mjs +267 -0
- package/fesm2022/stagefright5-cdk-accordion.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-bidi.mjs +185 -0
- package/fesm2022/stagefright5-cdk-bidi.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-clipboard.mjs +250 -0
- package/fesm2022/stagefright5-cdk-clipboard.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-coercion.mjs +128 -0
- package/fesm2022/stagefright5-cdk-coercion.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-collections.mjs +472 -0
- package/fesm2022/stagefright5-cdk-collections.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-drag-drop.mjs +3690 -0
- package/fesm2022/stagefright5-cdk-drag-drop.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-keycodes.mjs +159 -0
- package/fesm2022/stagefright5-cdk-keycodes.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-layout.mjs +246 -0
- package/fesm2022/stagefright5-cdk-layout.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-observers.mjs +203 -0
- package/fesm2022/stagefright5-cdk-observers.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-overlay.mjs +3033 -0
- package/fesm2022/stagefright5-cdk-overlay.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-platform.mjs +375 -0
- package/fesm2022/stagefright5-cdk-platform.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-portal.mjs +672 -0
- package/fesm2022/stagefright5-cdk-portal.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-scrolling.mjs +1399 -0
- package/fesm2022/stagefright5-cdk-scrolling.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-stepper.mjs +624 -0
- package/fesm2022/stagefright5-cdk-stepper.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-table.mjs +2346 -0
- package/fesm2022/stagefright5-cdk-table.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-testing-protractor.mjs +324 -0
- package/fesm2022/stagefright5-cdk-testing-protractor.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-testing-selenium-webdriver.mjs +364 -0
- package/fesm2022/stagefright5-cdk-testing-selenium-webdriver.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-testing-testbed.mjs +806 -0
- package/fesm2022/stagefright5-cdk-testing-testbed.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-testing.mjs +740 -0
- package/fesm2022/stagefright5-cdk-testing.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-text-field.mjs +453 -0
- package/fesm2022/stagefright5-cdk-text-field.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-tree.mjs +945 -0
- package/fesm2022/stagefright5-cdk-tree.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk.mjs +26 -0
- package/fesm2022/stagefright5-cdk.mjs.map +1 -0
- package/overlay/_index-deprecated.scss +13 -0
- package/overlay/_index.import.scss +13 -0
- package/overlay/_index.scss +148 -0
- package/overlay/overlay-prebuilt.scss +3 -0
- package/package.json +159 -0
- package/schematics/ng-update/test-cases/misc/global-stylesheets-test.scss +3 -0
- package/schematics/schematics/BUILD.bazel +104 -0
- package/schematics/schematics/README.md +4 -0
- package/schematics/schematics/collection.json +18 -0
- package/schematics/schematics/index.ts +22 -0
- package/schematics/schematics/migration.json +50 -0
- package/schematics/schematics/ng-add/index.spec.ts +50 -0
- package/schematics/schematics/ng-add/index.ts +39 -0
- package/schematics/schematics/ng-add/package-config.ts +62 -0
- package/schematics/schematics/ng-add/schema.json +16 -0
- package/schematics/schematics/ng-add/schema.ts +12 -0
- package/schematics/schematics/ng-generate/drag-drop/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.__style__.template +53 -0
- package/schematics/schematics/ng-generate/drag-drop/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.html.template +17 -0
- package/schematics/schematics/ng-generate/drag-drop/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.spec.ts.template +29 -0
- package/schematics/schematics/ng-generate/drag-drop/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.ts.template +43 -0
- package/schematics/schematics/ng-generate/drag-drop/index.spec.ts +205 -0
- package/schematics/schematics/ng-generate/drag-drop/index.ts +35 -0
- package/schematics/schematics/ng-generate/drag-drop/schema.json +93 -0
- package/schematics/schematics/ng-generate/drag-drop/schema.ts +11 -0
- package/schematics/schematics/ng-update/data/attribute-selectors.ts +29 -0
- package/schematics/schematics/ng-update/data/class-names.ts +50 -0
- package/schematics/schematics/ng-update/data/constructor-checks.ts +75 -0
- package/schematics/schematics/ng-update/data/css-selectors.ts +33 -0
- package/schematics/schematics/ng-update/data/element-selectors.ts +21 -0
- package/schematics/schematics/ng-update/data/index.ts +18 -0
- package/schematics/schematics/ng-update/data/input-names.ts +118 -0
- package/schematics/schematics/ng-update/data/method-call-checks.ts +63 -0
- package/schematics/schematics/ng-update/data/output-names.ts +42 -0
- package/schematics/schematics/ng-update/data/property-names.ts +151 -0
- package/schematics/schematics/ng-update/data/symbol-removal.ts +22 -0
- package/schematics/schematics/ng-update/devkit-file-system.ts +87 -0
- package/schematics/schematics/ng-update/devkit-migration-rule.ts +185 -0
- package/schematics/schematics/ng-update/devkit-migration.ts +47 -0
- package/schematics/schematics/ng-update/find-stylesheets.ts +43 -0
- package/schematics/schematics/ng-update/html-parsing/angular.ts +49 -0
- package/schematics/schematics/ng-update/html-parsing/elements.ts +66 -0
- package/schematics/schematics/ng-update/index.ts +113 -0
- package/schematics/schematics/ng-update/migrations/attribute-selectors.ts +83 -0
- package/schematics/schematics/ng-update/migrations/class-inheritance.ts +63 -0
- package/schematics/schematics/ng-update/migrations/class-names.ts +107 -0
- package/schematics/schematics/ng-update/migrations/constructor-signature.ts +170 -0
- package/schematics/schematics/ng-update/migrations/css-selectors.ts +83 -0
- package/schematics/schematics/ng-update/migrations/element-selectors.ts +75 -0
- package/schematics/schematics/ng-update/migrations/input-names.ts +83 -0
- package/schematics/schematics/ng-update/migrations/method-call-arguments.ts +70 -0
- package/schematics/schematics/ng-update/migrations/misc-template.ts +36 -0
- package/schematics/schematics/ng-update/migrations/output-names.ts +61 -0
- package/schematics/schematics/ng-update/migrations/property-names.ts +61 -0
- package/schematics/schematics/ng-update/migrations/symbol-removal.ts +51 -0
- package/schematics/schematics/ng-update/migrations/tilde-import-v13/tilde-import-migration.ts +40 -0
- package/schematics/schematics/ng-update/public-api.ts +18 -0
- package/schematics/schematics/ng-update/test-cases/index.spec.ts +18 -0
- package/schematics/schematics/ng-update/test-cases/misc/external-resource-resolution.spec.ts +32 -0
- package/schematics/schematics/ng-update/test-cases/misc/external-resource-resolution_input.ts +22 -0
- package/schematics/schematics/ng-update/test-cases/misc/global-stylesheets-test.scss +3 -0
- package/schematics/schematics/ng-update/test-cases/misc/global-stylesheets.spec.ts +50 -0
- package/schematics/schematics/ng-update/test-cases/misc/global-stylesheets_input.ts +8 -0
- package/schematics/schematics/ng-update/test-cases/misc/method-call-checks.spec.ts +20 -0
- package/schematics/schematics/ng-update/test-cases/misc/method-call-checks_input.ts +18 -0
- package/schematics/schematics/ng-update/test-cases/misc/module-resolution.spec.ts +27 -0
- package/schematics/schematics/ng-update/test-cases/v13/misc/tilde-import-v13.spec.ts +149 -0
- package/schematics/schematics/ng-update/test-cases/v6/attribute-selectors_expected_output.ts +36 -0
- package/schematics/schematics/ng-update/test-cases/v6/attribute-selectors_input.ts +36 -0
- package/schematics/schematics/ng-update/test-cases/v6/class-names_expected_output.ts +8 -0
- package/schematics/schematics/ng-update/test-cases/v6/class-names_input.ts +8 -0
- package/schematics/schematics/ng-update/test-cases/v6/input-names_expected_output.ts +22 -0
- package/schematics/schematics/ng-update/test-cases/v6/input-names_input.ts +22 -0
- package/schematics/schematics/ng-update/test-cases/v6/property-names_expected_output.ts +64 -0
- package/schematics/schematics/ng-update/test-cases/v6/property-names_input.ts +64 -0
- package/schematics/schematics/ng-update/test-cases/v7/property-names_expected_output.ts +28 -0
- package/schematics/schematics/ng-update/test-cases/v7/property-names_input.ts +28 -0
- package/schematics/schematics/ng-update/typescript/base-types.ts +22 -0
- package/schematics/schematics/ng-update/typescript/imports.ts +54 -0
- package/schematics/schematics/ng-update/typescript/literal.ts +32 -0
- package/schematics/schematics/ng-update/typescript/module-specifiers.ts +39 -0
- package/schematics/schematics/ng-update/update-schematic.md +209 -0
- package/schematics/schematics/ng-update/upgrade-data.ts +79 -0
- package/schematics/schematics/paths.ts +15 -0
- package/schematics/schematics/testing/BUILD.bazel +27 -0
- package/schematics/schematics/testing/file-content.ts +20 -0
- package/schematics/schematics/testing/index.ts +14 -0
- package/schematics/schematics/testing/post-scheduled-tasks.ts +45 -0
- package/schematics/schematics/testing/resolve-bazel-path.ts +46 -0
- package/schematics/schematics/testing/test-app.ts +21 -0
- package/schematics/schematics/testing/test-case-setup.ts +236 -0
- package/schematics/schematics/testing/test-library.ts +21 -0
- package/schematics/schematics/testing/test-project.ts +40 -0
- package/schematics/schematics/testing/tsconfig.json +7 -0
- package/schematics/schematics/tsconfig.json +28 -0
- package/schematics/schematics/update-tool/BUILD.bazel +19 -0
- package/schematics/schematics/update-tool/component-resource-collector.ts +195 -0
- package/schematics/schematics/update-tool/file-system.ts +78 -0
- package/schematics/schematics/update-tool/index.ts +191 -0
- package/schematics/schematics/update-tool/logger.ts +23 -0
- package/schematics/schematics/update-tool/migration.ts +88 -0
- package/schematics/schematics/update-tool/public-api.ts +16 -0
- package/schematics/schematics/update-tool/target-version.ts +31 -0
- package/schematics/schematics/update-tool/tsconfig.json +7 -0
- package/schematics/schematics/update-tool/update-recorder.ts +14 -0
- package/schematics/schematics/update-tool/utils/decorators.ts +54 -0
- package/schematics/schematics/update-tool/utils/functions.ts +18 -0
- package/schematics/schematics/update-tool/utils/imports.ts +128 -0
- package/schematics/schematics/update-tool/utils/line-mappings.ts +84 -0
- package/schematics/schematics/update-tool/utils/parse-tsconfig.ts +25 -0
- package/schematics/schematics/update-tool/utils/property-name.ts +28 -0
- package/schematics/schematics/update-tool/utils/virtual-host.ts +116 -0
- package/schematics/schematics/update-tool/version-changes.ts +49 -0
- package/schematics/schematics/utils/ast/ng-module-imports.spec.ts +43 -0
- package/schematics/schematics/utils/ast/ng-module-imports.ts +102 -0
- package/schematics/schematics/utils/ast.ts +88 -0
- package/schematics/schematics/utils/build-component.ts +252 -0
- package/schematics/schematics/utils/get-project.ts +27 -0
- package/schematics/schematics/utils/html-manipulation.ts +105 -0
- package/schematics/schematics/utils/index.ts +19 -0
- package/schematics/schematics/utils/parse5-element.ts +34 -0
- package/schematics/schematics/utils/project-index-file.ts +21 -0
- package/schematics/schematics/utils/project-main-file.ts +26 -0
- package/schematics/schematics/utils/project-style-file.ts +53 -0
- package/schematics/schematics/utils/project-targets.ts +43 -0
- package/schematics/schematics/utils/project-tsconfig-paths.spec.ts +91 -0
- package/schematics/schematics/utils/project-tsconfig-paths.ts +49 -0
- package/schematics/schematics/utils/schematic-options.ts +65 -0
- package/schematics/schematics/utils/vendored-ast-utils/index.ts +599 -0
- package/scrolling/virtual-scroll-viewport.scss +87 -0
- package/table/table.scss +3 -0
- package/text-field/_index.import.scss +2 -0
- package/text-field/_index.scss +89 -0
- package/text-field/text-field-prebuilt.scss +4 -0
- package/types/stagefright5-cdk-a11y.d.ts +1160 -0
- package/types/stagefright5-cdk-accordion.d.ts +95 -0
- package/types/stagefright5-cdk-bidi.d.ts +95 -0
- package/types/stagefright5-cdk-clipboard.d.ts +116 -0
- package/types/stagefright5-cdk-coercion.d.ts +101 -0
- package/types/stagefright5-cdk-collections.d.ts +405 -0
- package/types/stagefright5-cdk-drag-drop.d.ts +1471 -0
- package/types/stagefright5-cdk-keycodes.d.ts +142 -0
- package/types/stagefright5-cdk-layout.d.ts +96 -0
- package/types/stagefright5-cdk-observers.d.ts +91 -0
- package/types/stagefright5-cdk-overlay.d.ts +1258 -0
- package/types/stagefright5-cdk-platform.d.ts +130 -0
- package/types/stagefright5-cdk-portal.d.ts +327 -0
- package/types/stagefright5-cdk-scrolling.d.ts +631 -0
- package/types/stagefright5-cdk-stepper.d.ts +302 -0
- package/types/stagefright5-cdk-table.d.ts +1128 -0
- package/types/stagefright5-cdk-testing-protractor.d.ts +146 -0
- package/types/stagefright5-cdk-testing-selenium-webdriver.d.ts +161 -0
- package/types/stagefright5-cdk-testing-testbed.d.ts +168 -0
- package/types/stagefright5-cdk-testing.d.ts +735 -0
- package/types/stagefright5-cdk-text-field.d.ts +171 -0
- package/types/stagefright5-cdk-tree.d.ts +522 -0
- package/types/stagefright5-cdk.d.ts +14 -0
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
# ng-update schematic
|
|
2
|
+
|
|
3
|
+
**Note** The CDK ng-update schematic is the foundation for the Angular Material update schematic.
|
|
4
|
+
This is achieved by making the ng-update code for the CDK as reusable as possible.
|
|
5
|
+
|
|
6
|
+
This document also applies for the Angular Material `ng-update`.
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
The `ng-update` schematic consists of multiple migration entry-points where every entry-point
|
|
11
|
+
targets a specific Angular CDK or Angular Material version.
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
As of right now, we have multiple migration entry-points that handle the breaking changes for a
|
|
15
|
+
given target version:
|
|
16
|
+
|
|
17
|
+
| Target Version | Description |
|
|
18
|
+
|----------------|------------------------|
|
|
19
|
+
| V6 | Upgrade from any version to v6.0.0 |
|
|
20
|
+
| V7 | Upgrade from any version to v7.0.0 |
|
|
21
|
+
| V8 | Upgrade from any version to v8.0.0 |
|
|
22
|
+
| V9 | Upgrade from any version to v9.0.0 |
|
|
23
|
+
|
|
24
|
+
Note that the migrations run _in order_ if multiple versions are implicitly targeted. For
|
|
25
|
+
example, consider an application which uses Angular Material v5.0.0. In case the developer runs
|
|
26
|
+
`ng update`, the Angular CLI **only** installs V7 and runs the V6 and V7 migrations _in order_.
|
|
27
|
+
|
|
28
|
+
This shows that we technically need to keep all migrations in the code base because
|
|
29
|
+
the CLI usually only installs the latest version and expects all migrations for past
|
|
30
|
+
major versions to be present.
|
|
31
|
+
|
|
32
|
+
## Update concept
|
|
33
|
+
|
|
34
|
+
The goal of the update schematic is to automatically migrate code that is affected by breaking
|
|
35
|
+
changes of the target version. Most of the time we can apply such automatic migrations, but
|
|
36
|
+
there are also a few breaking changes that cannot be migrated automatically.
|
|
37
|
+
|
|
38
|
+
In that case, our goal should be to notify the developer about the breaking change that needs
|
|
39
|
+
attention.
|
|
40
|
+
|
|
41
|
+
## Transforming TypeScript files
|
|
42
|
+
|
|
43
|
+
In order to automatically migrate TypeScript source files, we take advantage of the TypeScript
|
|
44
|
+
Compiler API which allows us to parse and work with the AST of project source files. We built
|
|
45
|
+
a small framework for analyzing and updating project source files that is called `update-tool`.
|
|
46
|
+
|
|
47
|
+
The `update-tool` has been specifically built with the goal of being extremely fast and
|
|
48
|
+
flexible. This tool had to be built because our initial `ng update` implementation which
|
|
49
|
+
used `tslint` had various issues:
|
|
50
|
+
|
|
51
|
+
* No support for HTML templates and stylesheets (workaround was needed)
|
|
52
|
+
* Reruns all upgrade lint rules after file has been updated (significant performance issue for projects with a lot of files)
|
|
53
|
+
* Recreates the TypeScript program each time a source file has been updated (significant memory pressure for big TypeScript projects, causing OOM exceptions)
|
|
54
|
+
* TSLint recursively visits the nodes of all source files for each upgrade lint rule (performance issue)
|
|
55
|
+
* TSLint is not guaranteed to be installed in CLI projects. See: https://github.com/angular/angular-cli/issues/14555
|
|
56
|
+
* TSLint replacements lead to memory leaks due to the retained TypeScript nodes
|
|
57
|
+
* No way to have a *global analysis* phase since lint rules are only able to visit source files.
|
|
58
|
+
* No flexibility. i.e.
|
|
59
|
+
* No way to ensure source files are only analyzed a single time
|
|
60
|
+
* No way to implement a progress bar
|
|
61
|
+
* No easy way to add support for HTML templates or stylesheets
|
|
62
|
+
|
|
63
|
+
All of these problems that `tslint` had, have been solved when we built the
|
|
64
|
+
`update-tool`. The tool currently has the following differences compared to `tslint`:
|
|
65
|
+
|
|
66
|
+
* Abstraction of file system and ability to run migrations programmatically.
|
|
67
|
+
* Migrations can run in the CLI and in google3.
|
|
68
|
+
* Migrations can run standalone outside of `ng update`
|
|
69
|
+
* Integrated support for the HTML templates and stylesheets
|
|
70
|
+
* Only runs migrations once per source file.
|
|
71
|
+
* Even if a source file is part of multiple TypeScript projects.
|
|
72
|
+
* Program is only created once per TypeScript project. Also the type checker is only retrieved once.
|
|
73
|
+
* Migration failures are guaranteed to not retain `ts.Node` instances (avoiding a common tslint memory leak)
|
|
74
|
+
* Replacements are performed within the virtual file system (best practice for schematics)
|
|
75
|
+
* TypeScript program is only recursively visited **once**
|
|
76
|
+
* Full flexibility (e.g. allowing us to implement a progress bar)
|
|
77
|
+
* Possibility to have a *global analysis* phase (unlike with tslint where only individual source files can be analyzed)
|
|
78
|
+
|
|
79
|
+
There also other various concepts for transforming TypeScript source files, but most of them
|
|
80
|
+
don't provide a simple API for replacements and reporting. Read more about the possible
|
|
81
|
+
approaches below:
|
|
82
|
+
|
|
83
|
+
|Description | Evaluation |
|
|
84
|
+
|------------|------------|
|
|
85
|
+
| Regular Expressions | Too brittle. No type checking possible. Regular Expression _can_ be used in combination with some real AST walking |
|
|
86
|
+
| TypeScript transforms (no emit) | This would be a good solution but there is no API to serialize the transformed AST into source code without using the `ts.Printer`. The printer can be used to serialize the AST but it breaks formatting, code style and more. This is not acceptable for a migration. |
|
|
87
|
+
|
|
88
|
+
### Upgrade data for target versions
|
|
89
|
+
|
|
90
|
+
The upgrade data for migrations is separated based on the target version. This is necessary in
|
|
91
|
+
order to allow migrations run sequentially. For example:
|
|
92
|
+
|
|
93
|
+
* In V6: `onChange` has been renamed to `changed`
|
|
94
|
+
* In V7: `changed` has been renamed to `onValueChange`
|
|
95
|
+
|
|
96
|
+
If we would not run the migrations in order, or don't separate the upgrade data, we would not be
|
|
97
|
+
able to properly handle the migrations for each target version. e.g. someone is on
|
|
98
|
+
5.0.0 and *only* wants to upgrade to 6.0.0. In that case he would end up with `onValueChange`
|
|
99
|
+
because the non-separated upgrade data would just include: _`onChange` => `onValueChange`_
|
|
100
|
+
|
|
101
|
+
Also besides separating the upgrade data based on the target version, we split the upgrade data
|
|
102
|
+
based on the type of code that is affected by these migrations:
|
|
103
|
+
|
|
104
|
+
* See here: [src/material/schematics/update/material/data](https://github.com/angular/components/tree/main/src/material/schematics/update/material/data)
|
|
105
|
+
|
|
106
|
+
### Adding upgrade data
|
|
107
|
+
|
|
108
|
+
Adding upgrade data is now a **mandatory** step before breaking changes should be merged
|
|
109
|
+
into `upstream`. For simple and common breaking changes, there should be already an upgrade
|
|
110
|
+
data file that just needs the new change inserted.
|
|
111
|
+
|
|
112
|
+
In case there is no upgrade data for a breaking change, we need to evaluate if there should be
|
|
113
|
+
a single `misc` migration that is tied to that specific breaking change, or if we should
|
|
114
|
+
create a new migration that accepts upgrade data (as other configurable migrations).
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
**Example**: Adding upgrade data for a property rename
|
|
119
|
+
**Scenario**: In Angular Material V7.0.0, we rename `MatRipple#color` to `MatRipple#newColor`.
|
|
120
|
+
|
|
121
|
+
First, look for an existing upgrade data file that covers similar breaking changes. In that case
|
|
122
|
+
an existing upgrade data file for `property-names` already exists. Insert the new breaking change
|
|
123
|
+
within the proper `VersionTarget`.
|
|
124
|
+
|
|
125
|
+
_src/material/schematics/ng-update/material/data/property-names.ts_
|
|
126
|
+
```ts
|
|
127
|
+
export const propertyNames: VersionChanges<MaterialPropertyNameData> = {
|
|
128
|
+
[TargetVersion.V7]: [
|
|
129
|
+
{
|
|
130
|
+
pr: '{PULL_REQUEST_LINK_FOR_BREAKING_CHANGE}',
|
|
131
|
+
changes: [
|
|
132
|
+
{
|
|
133
|
+
replace: 'color',
|
|
134
|
+
replaceWith: 'newColor',
|
|
135
|
+
limitedTo: {
|
|
136
|
+
classes: ['MatRipple']
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
]
|
|
140
|
+
}
|
|
141
|
+
],
|
|
142
|
+
...
|
|
143
|
+
};
|
|
144
|
+
```
|
|
145
|
+
Once the data is inserted into the upgrade data file, the update schematic will properly migrate
|
|
146
|
+
`MatRipple#color` to `MatRipple#newColor` if someone upgrades to Angular Material V7.0.0.
|
|
147
|
+
|
|
148
|
+
But that's not all. It's encouraged to add a test-case for the new migration data. In this case,
|
|
149
|
+
a test case already exists for the type of migration and we just need to add our breaking change
|
|
150
|
+
to it. Read more about adding a test case in the next section.
|
|
151
|
+
|
|
152
|
+
### Adding a breaking change to a test case
|
|
153
|
+
|
|
154
|
+
Considering we added a breaking change to the update schematic, it's encouraged to add a proper
|
|
155
|
+
test case for the new change that has been added.
|
|
156
|
+
|
|
157
|
+
In the scenario where a property from `MatRipple` has been renamed in V7, we don't need to create
|
|
158
|
+
a new test-case file because there is already a test case for the `property-names` upgrade data.
|
|
159
|
+
In that case, we just need to add the breaking change to the existing test case.
|
|
160
|
+
|
|
161
|
+
_src/material/schematics/ng-update/test-cases/v7/property-names_input.ts_
|
|
162
|
+
```ts
|
|
163
|
+
...
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Mock definitions. This test case does not have access to @dugararchit/material.
|
|
167
|
+
*/
|
|
168
|
+
class MatRipple {
|
|
169
|
+
color: string;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/*
|
|
173
|
+
* Actual test cases using the previously defined definitions.
|
|
174
|
+
*/
|
|
175
|
+
class A implements OnInit {
|
|
176
|
+
constructor(private a: MatRipple) {}
|
|
177
|
+
|
|
178
|
+
ngOnInit() {
|
|
179
|
+
this.a.color = 'primary';
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
_src/material/schematics/ng-update/test-cases/v7/property-names_expected_output.ts_
|
|
185
|
+
```ts
|
|
186
|
+
...
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Mock definitions. This test case does not have access to @dugararchit/material.
|
|
190
|
+
*/
|
|
191
|
+
class MatRipple {
|
|
192
|
+
color: string;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/*
|
|
196
|
+
* Actual test cases using the previously defined definitions.
|
|
197
|
+
*/
|
|
198
|
+
class A implements OnInit {
|
|
199
|
+
constructor(private a: MatRipple) {}
|
|
200
|
+
|
|
201
|
+
ngOnInit() {
|
|
202
|
+
this.a.newColor = 'primary';
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
**Note**: The `_input.ts` file will be just transformed by the V7 migrations and compared to
|
|
208
|
+
the `_expected_output.ts` file. This means that it's necessary to also include the no longer
|
|
209
|
+
valid mock declarations to the expected output file.
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.io/license
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import {Migration} from '../update-tool/migration';
|
|
10
|
+
import {getChangesForTarget, ValueOfChanges, VersionChanges} from '../update-tool/version-changes';
|
|
11
|
+
import {
|
|
12
|
+
attributeSelectors,
|
|
13
|
+
AttributeSelectorUpgradeData,
|
|
14
|
+
classNames,
|
|
15
|
+
ClassNameUpgradeData,
|
|
16
|
+
constructorChecks,
|
|
17
|
+
ConstructorChecksUpgradeData,
|
|
18
|
+
cssSelectors,
|
|
19
|
+
CssSelectorUpgradeData,
|
|
20
|
+
elementSelectors,
|
|
21
|
+
ElementSelectorUpgradeData,
|
|
22
|
+
inputNames,
|
|
23
|
+
InputNameUpgradeData,
|
|
24
|
+
methodCallChecks,
|
|
25
|
+
MethodCallUpgradeData,
|
|
26
|
+
outputNames,
|
|
27
|
+
OutputNameUpgradeData,
|
|
28
|
+
propertyNames,
|
|
29
|
+
PropertyNameUpgradeData,
|
|
30
|
+
SymbolRemovalUpgradeData,
|
|
31
|
+
symbolRemoval,
|
|
32
|
+
} from './data';
|
|
33
|
+
|
|
34
|
+
/** Upgrade data for the Angular CDK. */
|
|
35
|
+
export const cdkUpgradeData: UpgradeData = {
|
|
36
|
+
attributeSelectors,
|
|
37
|
+
classNames,
|
|
38
|
+
constructorChecks,
|
|
39
|
+
cssSelectors,
|
|
40
|
+
elementSelectors,
|
|
41
|
+
inputNames,
|
|
42
|
+
methodCallChecks,
|
|
43
|
+
outputNames,
|
|
44
|
+
propertyNames,
|
|
45
|
+
symbolRemoval,
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Interface that describes the upgrade data that needs to be defined when using the CDK
|
|
50
|
+
* upgrade rules.
|
|
51
|
+
*/
|
|
52
|
+
export interface UpgradeData {
|
|
53
|
+
attributeSelectors: VersionChanges<AttributeSelectorUpgradeData>;
|
|
54
|
+
classNames: VersionChanges<ClassNameUpgradeData>;
|
|
55
|
+
constructorChecks: VersionChanges<ConstructorChecksUpgradeData>;
|
|
56
|
+
cssSelectors: VersionChanges<CssSelectorUpgradeData>;
|
|
57
|
+
elementSelectors: VersionChanges<ElementSelectorUpgradeData>;
|
|
58
|
+
inputNames: VersionChanges<InputNameUpgradeData>;
|
|
59
|
+
methodCallChecks: VersionChanges<MethodCallUpgradeData>;
|
|
60
|
+
outputNames: VersionChanges<OutputNameUpgradeData>;
|
|
61
|
+
propertyNames: VersionChanges<PropertyNameUpgradeData>;
|
|
62
|
+
symbolRemoval: VersionChanges<SymbolRemovalUpgradeData>;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Gets the reduced upgrade data for the specified data key. The function reads out the
|
|
67
|
+
* target version and upgrade data object from the migration and resolves the specified
|
|
68
|
+
* data portion that is specifically tied to the target version.
|
|
69
|
+
*/
|
|
70
|
+
export function getVersionUpgradeData<
|
|
71
|
+
T extends keyof UpgradeData,
|
|
72
|
+
U = ValueOfChanges<UpgradeData[T]>,
|
|
73
|
+
>(migration: Migration<UpgradeData>, dataName: T): U[] {
|
|
74
|
+
// Note that below we need to cast to `unknown` first TS doesn't infer the type of T correctly.
|
|
75
|
+
return getChangesForTarget<U>(
|
|
76
|
+
migration.targetVersion,
|
|
77
|
+
migration.upgradeData[dataName] as unknown as VersionChanges<U>,
|
|
78
|
+
);
|
|
79
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.io/license
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import {join} from 'path';
|
|
10
|
+
|
|
11
|
+
/** Path to the schematic collection for non-migration schematics. */
|
|
12
|
+
export const COLLECTION_PATH = join(__dirname, 'collection.json');
|
|
13
|
+
|
|
14
|
+
/** Path to the schematic collection that includes the migrations. */
|
|
15
|
+
export const MIGRATION_PATH = join(__dirname, 'migration.json');
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
load("//tools:defaults.bzl", "ts_library")
|
|
2
|
+
|
|
3
|
+
package(default_visibility = ["//visibility:public"])
|
|
4
|
+
|
|
5
|
+
ts_library(
|
|
6
|
+
name = "testing",
|
|
7
|
+
testonly = True,
|
|
8
|
+
srcs = glob(["**/*.ts"]),
|
|
9
|
+
# Schematics can not yet run in ESM module. For now we continue to use CommonJS.
|
|
10
|
+
# TODO(ESM): remove this once the Angular CLI supports ESM schematics.
|
|
11
|
+
devmode_module = "commonjs",
|
|
12
|
+
prodmode_module = "commonjs",
|
|
13
|
+
tsconfig = "tsconfig.json",
|
|
14
|
+
deps = [
|
|
15
|
+
"@npm//@angular-devkit/core",
|
|
16
|
+
"@npm//@angular-devkit/schematics",
|
|
17
|
+
"@npm//@bazel/runfiles",
|
|
18
|
+
"@npm//@schematics/angular",
|
|
19
|
+
"@npm//@types/fs-extra",
|
|
20
|
+
"@npm//@types/glob",
|
|
21
|
+
"@npm//@types/jasmine",
|
|
22
|
+
"@npm//@types/node",
|
|
23
|
+
"@npm//fs-extra",
|
|
24
|
+
"@npm//jsonc-parser",
|
|
25
|
+
"@npm//rxjs",
|
|
26
|
+
],
|
|
27
|
+
)
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.io/license
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import {Tree} from '@angular-devkit/schematics';
|
|
10
|
+
|
|
11
|
+
/** Gets the content of a specified file from a schematic tree. */
|
|
12
|
+
export function getFileContent(tree: Tree, filePath: string): string {
|
|
13
|
+
const contentBuffer = tree.read(filePath);
|
|
14
|
+
|
|
15
|
+
if (!contentBuffer) {
|
|
16
|
+
throw new Error(`Cannot read "${filePath}" because it does not exist.`);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return contentBuffer.toString();
|
|
20
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.io/license
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export * from './post-scheduled-tasks';
|
|
10
|
+
export * from './test-app';
|
|
11
|
+
export * from './test-case-setup';
|
|
12
|
+
export * from './test-library';
|
|
13
|
+
export * from './file-content';
|
|
14
|
+
export * from './resolve-bazel-path';
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.io/license
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import {EngineHost, TaskExecutor, TaskScheduler} from '@angular-devkit/schematics';
|
|
10
|
+
import {SchematicTestRunner} from '@angular-devkit/schematics/testing';
|
|
11
|
+
import {from as observableFrom, Observable} from 'rxjs';
|
|
12
|
+
import {concatMap, filter, last} from 'rxjs/operators';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Due to the fact that the Angular devkit does not support running scheduled tasks from a
|
|
16
|
+
* schematic that has been launched through the TestRunner, we need to manually find the task
|
|
17
|
+
* executor for the given task name and run all scheduled instances.
|
|
18
|
+
*
|
|
19
|
+
* Note that this means that there can be multiple tasks with the same name. The observable emits
|
|
20
|
+
* only when all tasks finished executing.
|
|
21
|
+
*/
|
|
22
|
+
export function runPostScheduledTasks(
|
|
23
|
+
runner: SchematicTestRunner,
|
|
24
|
+
taskName: string,
|
|
25
|
+
): Observable<any> {
|
|
26
|
+
// Workaround until there is a public API to run scheduled tasks in the @angular-devkit.
|
|
27
|
+
// See: https://github.com/angular/angular-cli/issues/11739
|
|
28
|
+
const host = runner.engine['_host'] as EngineHost<{}, {}>;
|
|
29
|
+
const tasks = runner.engine['_taskSchedulers'] as TaskScheduler[];
|
|
30
|
+
const createTaskExecutor = (name: string) =>
|
|
31
|
+
host.createTaskExecutor(name) as any as Observable<TaskExecutor<any>>;
|
|
32
|
+
|
|
33
|
+
return observableFrom(tasks).pipe(
|
|
34
|
+
concatMap(scheduler => scheduler.finalize()),
|
|
35
|
+
filter(task => task.configuration.name === taskName),
|
|
36
|
+
concatMap(task => {
|
|
37
|
+
return createTaskExecutor(task.configuration.name).pipe(
|
|
38
|
+
concatMap(executor => executor(task.configuration.options, task.context)),
|
|
39
|
+
);
|
|
40
|
+
}),
|
|
41
|
+
// Only emit the last emitted value because there can be multiple tasks with the same name.
|
|
42
|
+
// The observable should only emit a value if all tasks completed.
|
|
43
|
+
last(),
|
|
44
|
+
);
|
|
45
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.io/license
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import * as path from 'path';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Resolves a given path through Bazel while respecting the specified parent directory.
|
|
13
|
+
* Usually `require.resolve` could just be used for resolving runfiles relatively, but support
|
|
14
|
+
* for this has been removed and absolute manifest paths or the runfile helpers are now needed
|
|
15
|
+
* on Windows. This helper provides a resolution method that works the same on all platforms.
|
|
16
|
+
*/
|
|
17
|
+
export function resolveBazelPath(parent: string, relativePath: string) {
|
|
18
|
+
if (process.env['RUNFILES_MANIFEST_ONLY'] !== '1') {
|
|
19
|
+
return path.join(parent, relativePath);
|
|
20
|
+
}
|
|
21
|
+
// Note: We don't want to import this outside of this function as the runfile helpers are
|
|
22
|
+
// quite large we don't want to load them for every import to `../testing/private`.
|
|
23
|
+
const {runfiles} = require('@bazel/runfiles');
|
|
24
|
+
const projectDirs = [
|
|
25
|
+
// Workspace symlinked into `@npm//:node_modules/`.
|
|
26
|
+
path.join(runfiles.resolve('npm/node_modules'), runfiles.workspace),
|
|
27
|
+
// Workspace bazel-bin directory.
|
|
28
|
+
runfiles.resolve(runfiles.workspace),
|
|
29
|
+
];
|
|
30
|
+
|
|
31
|
+
for (const projectDir of projectDirs) {
|
|
32
|
+
const relativeParent = path.relative(projectDir, parent);
|
|
33
|
+
const workspacePath = path.join(relativeParent, relativePath).replace(/\\/g, '/');
|
|
34
|
+
|
|
35
|
+
try {
|
|
36
|
+
// In newer versions `resolveWorkspaceRelative` throws an error if it doesn't succeed.
|
|
37
|
+
const result = runfiles.resolveWorkspaceRelative(workspacePath);
|
|
38
|
+
|
|
39
|
+
if (result) {
|
|
40
|
+
return result;
|
|
41
|
+
}
|
|
42
|
+
} catch {}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
throw Error(`Could not resolve path. Looked in: ${projectDirs.join(', ')}`);
|
|
46
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.io/license
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import {Tree} from '@angular-devkit/schematics';
|
|
10
|
+
import {SchematicTestRunner, UnitTestTree} from '@angular-devkit/schematics/testing';
|
|
11
|
+
|
|
12
|
+
import {createTestProject} from './test-project';
|
|
13
|
+
|
|
14
|
+
/** Create a base app used for testing. */
|
|
15
|
+
export async function createTestApp(
|
|
16
|
+
runner: SchematicTestRunner,
|
|
17
|
+
appOptions = {},
|
|
18
|
+
tree?: Tree,
|
|
19
|
+
): Promise<UnitTestTree> {
|
|
20
|
+
return createTestProject(runner, 'application', appOptions, tree);
|
|
21
|
+
}
|