@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.
Files changed (206) hide show
  1. package/_index.scss +8 -0
  2. package/a11y/_index.import.scss +2 -0
  3. package/a11y/_index.scss +102 -0
  4. package/a11y/a11y-prebuilt.scss +3 -0
  5. package/fesm2022/stagefright5-cdk-a11y.mjs +2381 -0
  6. package/fesm2022/stagefright5-cdk-a11y.mjs.map +1 -0
  7. package/fesm2022/stagefright5-cdk-accordion.mjs +267 -0
  8. package/fesm2022/stagefright5-cdk-accordion.mjs.map +1 -0
  9. package/fesm2022/stagefright5-cdk-bidi.mjs +185 -0
  10. package/fesm2022/stagefright5-cdk-bidi.mjs.map +1 -0
  11. package/fesm2022/stagefright5-cdk-clipboard.mjs +250 -0
  12. package/fesm2022/stagefright5-cdk-clipboard.mjs.map +1 -0
  13. package/fesm2022/stagefright5-cdk-coercion.mjs +128 -0
  14. package/fesm2022/stagefright5-cdk-coercion.mjs.map +1 -0
  15. package/fesm2022/stagefright5-cdk-collections.mjs +472 -0
  16. package/fesm2022/stagefright5-cdk-collections.mjs.map +1 -0
  17. package/fesm2022/stagefright5-cdk-drag-drop.mjs +3690 -0
  18. package/fesm2022/stagefright5-cdk-drag-drop.mjs.map +1 -0
  19. package/fesm2022/stagefright5-cdk-keycodes.mjs +159 -0
  20. package/fesm2022/stagefright5-cdk-keycodes.mjs.map +1 -0
  21. package/fesm2022/stagefright5-cdk-layout.mjs +246 -0
  22. package/fesm2022/stagefright5-cdk-layout.mjs.map +1 -0
  23. package/fesm2022/stagefright5-cdk-observers.mjs +203 -0
  24. package/fesm2022/stagefright5-cdk-observers.mjs.map +1 -0
  25. package/fesm2022/stagefright5-cdk-overlay.mjs +3033 -0
  26. package/fesm2022/stagefright5-cdk-overlay.mjs.map +1 -0
  27. package/fesm2022/stagefright5-cdk-platform.mjs +375 -0
  28. package/fesm2022/stagefright5-cdk-platform.mjs.map +1 -0
  29. package/fesm2022/stagefright5-cdk-portal.mjs +672 -0
  30. package/fesm2022/stagefright5-cdk-portal.mjs.map +1 -0
  31. package/fesm2022/stagefright5-cdk-scrolling.mjs +1399 -0
  32. package/fesm2022/stagefright5-cdk-scrolling.mjs.map +1 -0
  33. package/fesm2022/stagefright5-cdk-stepper.mjs +624 -0
  34. package/fesm2022/stagefright5-cdk-stepper.mjs.map +1 -0
  35. package/fesm2022/stagefright5-cdk-table.mjs +2346 -0
  36. package/fesm2022/stagefright5-cdk-table.mjs.map +1 -0
  37. package/fesm2022/stagefright5-cdk-testing-protractor.mjs +324 -0
  38. package/fesm2022/stagefright5-cdk-testing-protractor.mjs.map +1 -0
  39. package/fesm2022/stagefright5-cdk-testing-selenium-webdriver.mjs +364 -0
  40. package/fesm2022/stagefright5-cdk-testing-selenium-webdriver.mjs.map +1 -0
  41. package/fesm2022/stagefright5-cdk-testing-testbed.mjs +806 -0
  42. package/fesm2022/stagefright5-cdk-testing-testbed.mjs.map +1 -0
  43. package/fesm2022/stagefright5-cdk-testing.mjs +740 -0
  44. package/fesm2022/stagefright5-cdk-testing.mjs.map +1 -0
  45. package/fesm2022/stagefright5-cdk-text-field.mjs +453 -0
  46. package/fesm2022/stagefright5-cdk-text-field.mjs.map +1 -0
  47. package/fesm2022/stagefright5-cdk-tree.mjs +945 -0
  48. package/fesm2022/stagefright5-cdk-tree.mjs.map +1 -0
  49. package/fesm2022/stagefright5-cdk.mjs +26 -0
  50. package/fesm2022/stagefright5-cdk.mjs.map +1 -0
  51. package/overlay/_index-deprecated.scss +13 -0
  52. package/overlay/_index.import.scss +13 -0
  53. package/overlay/_index.scss +148 -0
  54. package/overlay/overlay-prebuilt.scss +3 -0
  55. package/package.json +159 -0
  56. package/schematics/ng-update/test-cases/misc/global-stylesheets-test.scss +3 -0
  57. package/schematics/schematics/BUILD.bazel +104 -0
  58. package/schematics/schematics/README.md +4 -0
  59. package/schematics/schematics/collection.json +18 -0
  60. package/schematics/schematics/index.ts +22 -0
  61. package/schematics/schematics/migration.json +50 -0
  62. package/schematics/schematics/ng-add/index.spec.ts +50 -0
  63. package/schematics/schematics/ng-add/index.ts +39 -0
  64. package/schematics/schematics/ng-add/package-config.ts +62 -0
  65. package/schematics/schematics/ng-add/schema.json +16 -0
  66. package/schematics/schematics/ng-add/schema.ts +12 -0
  67. package/schematics/schematics/ng-generate/drag-drop/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.__style__.template +53 -0
  68. package/schematics/schematics/ng-generate/drag-drop/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.html.template +17 -0
  69. package/schematics/schematics/ng-generate/drag-drop/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.spec.ts.template +29 -0
  70. package/schematics/schematics/ng-generate/drag-drop/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.ts.template +43 -0
  71. package/schematics/schematics/ng-generate/drag-drop/index.spec.ts +205 -0
  72. package/schematics/schematics/ng-generate/drag-drop/index.ts +35 -0
  73. package/schematics/schematics/ng-generate/drag-drop/schema.json +93 -0
  74. package/schematics/schematics/ng-generate/drag-drop/schema.ts +11 -0
  75. package/schematics/schematics/ng-update/data/attribute-selectors.ts +29 -0
  76. package/schematics/schematics/ng-update/data/class-names.ts +50 -0
  77. package/schematics/schematics/ng-update/data/constructor-checks.ts +75 -0
  78. package/schematics/schematics/ng-update/data/css-selectors.ts +33 -0
  79. package/schematics/schematics/ng-update/data/element-selectors.ts +21 -0
  80. package/schematics/schematics/ng-update/data/index.ts +18 -0
  81. package/schematics/schematics/ng-update/data/input-names.ts +118 -0
  82. package/schematics/schematics/ng-update/data/method-call-checks.ts +63 -0
  83. package/schematics/schematics/ng-update/data/output-names.ts +42 -0
  84. package/schematics/schematics/ng-update/data/property-names.ts +151 -0
  85. package/schematics/schematics/ng-update/data/symbol-removal.ts +22 -0
  86. package/schematics/schematics/ng-update/devkit-file-system.ts +87 -0
  87. package/schematics/schematics/ng-update/devkit-migration-rule.ts +185 -0
  88. package/schematics/schematics/ng-update/devkit-migration.ts +47 -0
  89. package/schematics/schematics/ng-update/find-stylesheets.ts +43 -0
  90. package/schematics/schematics/ng-update/html-parsing/angular.ts +49 -0
  91. package/schematics/schematics/ng-update/html-parsing/elements.ts +66 -0
  92. package/schematics/schematics/ng-update/index.ts +113 -0
  93. package/schematics/schematics/ng-update/migrations/attribute-selectors.ts +83 -0
  94. package/schematics/schematics/ng-update/migrations/class-inheritance.ts +63 -0
  95. package/schematics/schematics/ng-update/migrations/class-names.ts +107 -0
  96. package/schematics/schematics/ng-update/migrations/constructor-signature.ts +170 -0
  97. package/schematics/schematics/ng-update/migrations/css-selectors.ts +83 -0
  98. package/schematics/schematics/ng-update/migrations/element-selectors.ts +75 -0
  99. package/schematics/schematics/ng-update/migrations/input-names.ts +83 -0
  100. package/schematics/schematics/ng-update/migrations/method-call-arguments.ts +70 -0
  101. package/schematics/schematics/ng-update/migrations/misc-template.ts +36 -0
  102. package/schematics/schematics/ng-update/migrations/output-names.ts +61 -0
  103. package/schematics/schematics/ng-update/migrations/property-names.ts +61 -0
  104. package/schematics/schematics/ng-update/migrations/symbol-removal.ts +51 -0
  105. package/schematics/schematics/ng-update/migrations/tilde-import-v13/tilde-import-migration.ts +40 -0
  106. package/schematics/schematics/ng-update/public-api.ts +18 -0
  107. package/schematics/schematics/ng-update/test-cases/index.spec.ts +18 -0
  108. package/schematics/schematics/ng-update/test-cases/misc/external-resource-resolution.spec.ts +32 -0
  109. package/schematics/schematics/ng-update/test-cases/misc/external-resource-resolution_input.ts +22 -0
  110. package/schematics/schematics/ng-update/test-cases/misc/global-stylesheets-test.scss +3 -0
  111. package/schematics/schematics/ng-update/test-cases/misc/global-stylesheets.spec.ts +50 -0
  112. package/schematics/schematics/ng-update/test-cases/misc/global-stylesheets_input.ts +8 -0
  113. package/schematics/schematics/ng-update/test-cases/misc/method-call-checks.spec.ts +20 -0
  114. package/schematics/schematics/ng-update/test-cases/misc/method-call-checks_input.ts +18 -0
  115. package/schematics/schematics/ng-update/test-cases/misc/module-resolution.spec.ts +27 -0
  116. package/schematics/schematics/ng-update/test-cases/v13/misc/tilde-import-v13.spec.ts +149 -0
  117. package/schematics/schematics/ng-update/test-cases/v6/attribute-selectors_expected_output.ts +36 -0
  118. package/schematics/schematics/ng-update/test-cases/v6/attribute-selectors_input.ts +36 -0
  119. package/schematics/schematics/ng-update/test-cases/v6/class-names_expected_output.ts +8 -0
  120. package/schematics/schematics/ng-update/test-cases/v6/class-names_input.ts +8 -0
  121. package/schematics/schematics/ng-update/test-cases/v6/input-names_expected_output.ts +22 -0
  122. package/schematics/schematics/ng-update/test-cases/v6/input-names_input.ts +22 -0
  123. package/schematics/schematics/ng-update/test-cases/v6/property-names_expected_output.ts +64 -0
  124. package/schematics/schematics/ng-update/test-cases/v6/property-names_input.ts +64 -0
  125. package/schematics/schematics/ng-update/test-cases/v7/property-names_expected_output.ts +28 -0
  126. package/schematics/schematics/ng-update/test-cases/v7/property-names_input.ts +28 -0
  127. package/schematics/schematics/ng-update/typescript/base-types.ts +22 -0
  128. package/schematics/schematics/ng-update/typescript/imports.ts +54 -0
  129. package/schematics/schematics/ng-update/typescript/literal.ts +32 -0
  130. package/schematics/schematics/ng-update/typescript/module-specifiers.ts +39 -0
  131. package/schematics/schematics/ng-update/update-schematic.md +209 -0
  132. package/schematics/schematics/ng-update/upgrade-data.ts +79 -0
  133. package/schematics/schematics/paths.ts +15 -0
  134. package/schematics/schematics/testing/BUILD.bazel +27 -0
  135. package/schematics/schematics/testing/file-content.ts +20 -0
  136. package/schematics/schematics/testing/index.ts +14 -0
  137. package/schematics/schematics/testing/post-scheduled-tasks.ts +45 -0
  138. package/schematics/schematics/testing/resolve-bazel-path.ts +46 -0
  139. package/schematics/schematics/testing/test-app.ts +21 -0
  140. package/schematics/schematics/testing/test-case-setup.ts +236 -0
  141. package/schematics/schematics/testing/test-library.ts +21 -0
  142. package/schematics/schematics/testing/test-project.ts +40 -0
  143. package/schematics/schematics/testing/tsconfig.json +7 -0
  144. package/schematics/schematics/tsconfig.json +28 -0
  145. package/schematics/schematics/update-tool/BUILD.bazel +19 -0
  146. package/schematics/schematics/update-tool/component-resource-collector.ts +195 -0
  147. package/schematics/schematics/update-tool/file-system.ts +78 -0
  148. package/schematics/schematics/update-tool/index.ts +191 -0
  149. package/schematics/schematics/update-tool/logger.ts +23 -0
  150. package/schematics/schematics/update-tool/migration.ts +88 -0
  151. package/schematics/schematics/update-tool/public-api.ts +16 -0
  152. package/schematics/schematics/update-tool/target-version.ts +31 -0
  153. package/schematics/schematics/update-tool/tsconfig.json +7 -0
  154. package/schematics/schematics/update-tool/update-recorder.ts +14 -0
  155. package/schematics/schematics/update-tool/utils/decorators.ts +54 -0
  156. package/schematics/schematics/update-tool/utils/functions.ts +18 -0
  157. package/schematics/schematics/update-tool/utils/imports.ts +128 -0
  158. package/schematics/schematics/update-tool/utils/line-mappings.ts +84 -0
  159. package/schematics/schematics/update-tool/utils/parse-tsconfig.ts +25 -0
  160. package/schematics/schematics/update-tool/utils/property-name.ts +28 -0
  161. package/schematics/schematics/update-tool/utils/virtual-host.ts +116 -0
  162. package/schematics/schematics/update-tool/version-changes.ts +49 -0
  163. package/schematics/schematics/utils/ast/ng-module-imports.spec.ts +43 -0
  164. package/schematics/schematics/utils/ast/ng-module-imports.ts +102 -0
  165. package/schematics/schematics/utils/ast.ts +88 -0
  166. package/schematics/schematics/utils/build-component.ts +252 -0
  167. package/schematics/schematics/utils/get-project.ts +27 -0
  168. package/schematics/schematics/utils/html-manipulation.ts +105 -0
  169. package/schematics/schematics/utils/index.ts +19 -0
  170. package/schematics/schematics/utils/parse5-element.ts +34 -0
  171. package/schematics/schematics/utils/project-index-file.ts +21 -0
  172. package/schematics/schematics/utils/project-main-file.ts +26 -0
  173. package/schematics/schematics/utils/project-style-file.ts +53 -0
  174. package/schematics/schematics/utils/project-targets.ts +43 -0
  175. package/schematics/schematics/utils/project-tsconfig-paths.spec.ts +91 -0
  176. package/schematics/schematics/utils/project-tsconfig-paths.ts +49 -0
  177. package/schematics/schematics/utils/schematic-options.ts +65 -0
  178. package/schematics/schematics/utils/vendored-ast-utils/index.ts +599 -0
  179. package/scrolling/virtual-scroll-viewport.scss +87 -0
  180. package/table/table.scss +3 -0
  181. package/text-field/_index.import.scss +2 -0
  182. package/text-field/_index.scss +89 -0
  183. package/text-field/text-field-prebuilt.scss +4 -0
  184. package/types/stagefright5-cdk-a11y.d.ts +1160 -0
  185. package/types/stagefright5-cdk-accordion.d.ts +95 -0
  186. package/types/stagefright5-cdk-bidi.d.ts +95 -0
  187. package/types/stagefright5-cdk-clipboard.d.ts +116 -0
  188. package/types/stagefright5-cdk-coercion.d.ts +101 -0
  189. package/types/stagefright5-cdk-collections.d.ts +405 -0
  190. package/types/stagefright5-cdk-drag-drop.d.ts +1471 -0
  191. package/types/stagefright5-cdk-keycodes.d.ts +142 -0
  192. package/types/stagefright5-cdk-layout.d.ts +96 -0
  193. package/types/stagefright5-cdk-observers.d.ts +91 -0
  194. package/types/stagefright5-cdk-overlay.d.ts +1258 -0
  195. package/types/stagefright5-cdk-platform.d.ts +130 -0
  196. package/types/stagefright5-cdk-portal.d.ts +327 -0
  197. package/types/stagefright5-cdk-scrolling.d.ts +631 -0
  198. package/types/stagefright5-cdk-stepper.d.ts +302 -0
  199. package/types/stagefright5-cdk-table.d.ts +1128 -0
  200. package/types/stagefright5-cdk-testing-protractor.d.ts +146 -0
  201. package/types/stagefright5-cdk-testing-selenium-webdriver.d.ts +161 -0
  202. package/types/stagefright5-cdk-testing-testbed.d.ts +168 -0
  203. package/types/stagefright5-cdk-testing.d.ts +735 -0
  204. package/types/stagefright5-cdk-text-field.d.ts +171 -0
  205. package/types/stagefright5-cdk-tree.d.ts +522 -0
  206. package/types/stagefright5-cdk.d.ts +14 -0
@@ -0,0 +1,151 @@
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 {TargetVersion} from '../../update-tool/target-version';
10
+ import {VersionChanges} from '../../update-tool/version-changes';
11
+
12
+ export interface PropertyNameUpgradeData {
13
+ /** The property name to replace. */
14
+ replace: string;
15
+ /** The new name for the property. */
16
+ replaceWith: string;
17
+ /** Controls which classes in which this replacement is made. */
18
+ limitedTo: {
19
+ /** Replace the property only when its type is one of the given Classes. */
20
+ classes: string[];
21
+ };
22
+ }
23
+
24
+ export const propertyNames: VersionChanges<PropertyNameUpgradeData> = {
25
+ [TargetVersion.V9]: [
26
+ {
27
+ pr: 'https://github.com/angular/components/pull/17084',
28
+ changes: [
29
+ {
30
+ replace: 'boundaryElementSelector',
31
+ replaceWith: 'boundaryElement',
32
+ limitedTo: {classes: ['CdkDrag']},
33
+ },
34
+ ],
35
+ },
36
+ {
37
+ pr: 'https://github.com/angular/components/pull/17302',
38
+ changes: [
39
+ {
40
+ replace: 'onChange',
41
+ replaceWith: 'changed',
42
+ limitedTo: {classes: ['SelectionModel']},
43
+ },
44
+ ],
45
+ },
46
+ ],
47
+ [TargetVersion.V8]: [],
48
+ [TargetVersion.V7]: [
49
+ {
50
+ pr: 'https://github.com/angular/components/pull/8286',
51
+ changes: [
52
+ {replace: 'onChange', replaceWith: 'changed', limitedTo: {classes: ['SelectionModel']}},
53
+ ],
54
+ },
55
+
56
+ {
57
+ pr: 'https://github.com/angular/components/pull/12927',
58
+ changes: [
59
+ {
60
+ replace: 'flexibleDiemsions',
61
+ replaceWith: 'flexibleDimensions',
62
+ limitedTo: {classes: ['CdkConnectedOverlay']},
63
+ },
64
+ ],
65
+ },
66
+ ],
67
+
68
+ [TargetVersion.V6]: [
69
+ {
70
+ pr: 'https://github.com/angular/components/pull/10161',
71
+ changes: [
72
+ {
73
+ replace: '_deprecatedOrigin',
74
+ replaceWith: 'origin',
75
+ limitedTo: {classes: ['CdkConnectedOverlay', 'ConnectedOverlayDirective']},
76
+ },
77
+ {
78
+ replace: '_deprecatedPositions',
79
+ replaceWith: 'positions',
80
+ limitedTo: {classes: ['CdkConnectedOverlay', 'ConnectedOverlayDirective']},
81
+ },
82
+ {
83
+ replace: '_deprecatedOffsetX',
84
+ replaceWith: 'offsetX',
85
+ limitedTo: {classes: ['CdkConnectedOverlay', 'ConnectedOverlayDirective']},
86
+ },
87
+ {
88
+ replace: '_deprecatedOffsetY',
89
+ replaceWith: 'offsetY',
90
+ limitedTo: {classes: ['CdkConnectedOverlay', 'ConnectedOverlayDirective']},
91
+ },
92
+ {
93
+ replace: '_deprecatedWidth',
94
+ replaceWith: 'width',
95
+ limitedTo: {classes: ['CdkConnectedOverlay', 'ConnectedOverlayDirective']},
96
+ },
97
+ {
98
+ replace: '_deprecatedHeight',
99
+ replaceWith: 'height',
100
+ limitedTo: {classes: ['CdkConnectedOverlay', 'ConnectedOverlayDirective']},
101
+ },
102
+ {
103
+ replace: '_deprecatedMinWidth',
104
+ replaceWith: 'minWidth',
105
+ limitedTo: {classes: ['CdkConnectedOverlay', 'ConnectedOverlayDirective']},
106
+ },
107
+ {
108
+ replace: '_deprecatedMinHeight',
109
+ replaceWith: 'minHeight',
110
+ limitedTo: {classes: ['CdkConnectedOverlay', 'ConnectedOverlayDirective']},
111
+ },
112
+ {
113
+ replace: '_deprecatedBackdropClass',
114
+ replaceWith: 'backdropClass',
115
+ limitedTo: {classes: ['CdkConnectedOverlay', 'ConnectedOverlayDirective']},
116
+ },
117
+ {
118
+ replace: '_deprecatedScrollStrategy',
119
+ replaceWith: 'scrollStrategy',
120
+ limitedTo: {classes: ['CdkConnectedOverlay', 'ConnectedOverlayDirective']},
121
+ },
122
+ {
123
+ replace: '_deprecatedOpen',
124
+ replaceWith: 'open',
125
+ limitedTo: {classes: ['CdkConnectedOverlay', 'ConnectedOverlayDirective']},
126
+ },
127
+ {
128
+ replace: '_deprecatedHasBackdrop',
129
+ replaceWith: 'hasBackdrop',
130
+ limitedTo: {classes: ['CdkConnectedOverlay', 'ConnectedOverlayDirective']},
131
+ },
132
+ ],
133
+ },
134
+
135
+ {
136
+ pr: 'https://github.com/angular/components/pull/10257',
137
+ changes: [
138
+ {
139
+ replace: '_deprecatedPortal',
140
+ replaceWith: 'portal',
141
+ limitedTo: {classes: ['CdkPortalOutlet']},
142
+ },
143
+ {
144
+ replace: '_deprecatedPortalHost',
145
+ replaceWith: 'portal',
146
+ limitedTo: {classes: ['CdkPortalOutlet']},
147
+ },
148
+ ],
149
+ },
150
+ ],
151
+ };
@@ -0,0 +1,22 @@
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 {VersionChanges} from '../../update-tool/version-changes';
10
+
11
+ export interface SymbolRemovalUpgradeData {
12
+ /** Module that the symbol was removed from. */
13
+ module: string;
14
+
15
+ /** Name of the symbol being removed. */
16
+ name: string;
17
+
18
+ /** Message to log explaining why the symbol was removed. */
19
+ message: string;
20
+ }
21
+
22
+ export const symbolRemoval: VersionChanges<SymbolRemovalUpgradeData> = {};
@@ -0,0 +1,87 @@
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 {normalize, Path} from '@angular-devkit/core';
10
+ import {Tree, UpdateRecorder} from '@angular-devkit/schematics';
11
+ import {DirectoryEntry, FileSystem} from '../update-tool/file-system';
12
+ import * as path from 'path';
13
+
14
+ /**
15
+ * File system that leverages the virtual tree from the CLI devkit. This file
16
+ * system is commonly used by `ng update` migrations that run as part of the
17
+ * Angular CLI.
18
+ */
19
+ export class DevkitFileSystem extends FileSystem {
20
+ private _updateRecorderCache = new Map<string, UpdateRecorder>();
21
+
22
+ constructor(private _tree: Tree) {
23
+ super();
24
+ }
25
+
26
+ resolve(...segments: string[]): Path {
27
+ // Note: We use `posix.resolve` as the devkit paths are using posix separators.
28
+ return normalize(path.posix.resolve('/', ...segments.map(normalize)));
29
+ }
30
+
31
+ edit(filePath: Path) {
32
+ if (this._updateRecorderCache.has(filePath)) {
33
+ return this._updateRecorderCache.get(filePath)!;
34
+ }
35
+ const recorder = this._tree.beginUpdate(filePath);
36
+ this._updateRecorderCache.set(filePath, recorder);
37
+ return recorder;
38
+ }
39
+
40
+ commitEdits() {
41
+ this._updateRecorderCache.forEach(r => this._tree.commitUpdate(r));
42
+ this._updateRecorderCache.clear();
43
+ }
44
+
45
+ fileExists(filePath: Path) {
46
+ return this._tree.exists(filePath);
47
+ }
48
+
49
+ directoryExists(dirPath: Path) {
50
+ // The devkit tree does not expose an API for checking whether a given
51
+ // directory exists. It throws a specific error though if a directory
52
+ // is being read as a file. We use that to check if a directory exists.
53
+ try {
54
+ this._tree.get(dirPath);
55
+ } catch (e) {
56
+ // Note: We do not use an `instanceof` check here. It could happen that the devkit version
57
+ // used by the CLI is different than the one we end up loading. This can happen depending
58
+ // on how Yarn/NPM hoists the NPM packages / whether there are multiple versions installed.
59
+ if (e instanceof Error && e.constructor.name === 'PathIsDirectoryException') {
60
+ return true;
61
+ }
62
+ }
63
+ return false;
64
+ }
65
+
66
+ overwrite(filePath: Path, content: string) {
67
+ this._tree.overwrite(filePath, content);
68
+ }
69
+
70
+ create(filePath: Path, content: string) {
71
+ this._tree.create(filePath, content);
72
+ }
73
+
74
+ delete(filePath: Path) {
75
+ this._tree.delete(filePath);
76
+ }
77
+
78
+ read(filePath: Path) {
79
+ const buffer = this._tree.read(filePath);
80
+ return buffer !== null ? buffer.toString() : null;
81
+ }
82
+
83
+ readDirectory(dirPath: Path): DirectoryEntry {
84
+ const {subdirs: directories, subfiles: files} = this._tree.getDir(dirPath);
85
+ return {directories, files};
86
+ }
87
+ }
@@ -0,0 +1,185 @@
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 {Rule, SchematicContext, Tree} from '@angular-devkit/schematics';
10
+ import {NodePackageInstallTask} from '@angular-devkit/schematics/tasks';
11
+ import {ProjectDefinition} from '@angular-devkit/core/src/workspace';
12
+
13
+ import {UpdateProject} from '../update-tool';
14
+ import {WorkspacePath} from '../update-tool/file-system';
15
+ import {MigrationCtor} from '../update-tool/migration';
16
+ import {TargetVersion} from '../update-tool/target-version';
17
+ import {getTargetTsconfigPath, getWorkspaceConfigGracefully} from '../utils/project-tsconfig-paths';
18
+
19
+ import {DevkitFileSystem} from './devkit-file-system';
20
+ import {DevkitContext, DevkitMigration, DevkitMigrationCtor} from './devkit-migration';
21
+ import {findStylesheetFiles} from './find-stylesheets';
22
+ import {AttributeSelectorsMigration} from './migrations/attribute-selectors';
23
+ import {ClassInheritanceMigration} from './migrations/class-inheritance';
24
+ import {ClassNamesMigration} from './migrations/class-names';
25
+ import {ConstructorSignatureMigration} from './migrations/constructor-signature';
26
+ import {CssSelectorsMigration} from './migrations/css-selectors';
27
+ import {ElementSelectorsMigration} from './migrations/element-selectors';
28
+ import {InputNamesMigration} from './migrations/input-names';
29
+ import {MethodCallArgumentsMigration} from './migrations/method-call-arguments';
30
+ import {MiscTemplateMigration} from './migrations/misc-template';
31
+ import {OutputNamesMigration} from './migrations/output-names';
32
+ import {PropertyNamesMigration} from './migrations/property-names';
33
+ import {UpgradeData} from './upgrade-data';
34
+ import {SymbolRemovalMigration} from './migrations/symbol-removal';
35
+
36
+ /** List of migrations which run for the CDK update. */
37
+ export const cdkMigrations: MigrationCtor<UpgradeData>[] = [
38
+ AttributeSelectorsMigration,
39
+ ClassInheritanceMigration,
40
+ ClassNamesMigration,
41
+ ConstructorSignatureMigration,
42
+ CssSelectorsMigration,
43
+ ElementSelectorsMigration,
44
+ InputNamesMigration,
45
+ MethodCallArgumentsMigration,
46
+ MiscTemplateMigration,
47
+ OutputNamesMigration,
48
+ PropertyNamesMigration,
49
+ SymbolRemovalMigration,
50
+ ];
51
+
52
+ export type NullableDevkitMigration = MigrationCtor<UpgradeData | null, DevkitContext>;
53
+
54
+ type PostMigrationFn = (
55
+ context: SchematicContext,
56
+ targetVersion: TargetVersion,
57
+ hasFailure: boolean,
58
+ ) => void;
59
+
60
+ /**
61
+ * Creates a Angular schematic rule that runs the upgrade for the
62
+ * specified target version.
63
+ */
64
+ export function createMigrationSchematicRule(
65
+ targetVersion: TargetVersion,
66
+ extraMigrations: NullableDevkitMigration[],
67
+ upgradeData: UpgradeData,
68
+ onMigrationCompleteFn?: PostMigrationFn,
69
+ ): Rule {
70
+ return async (tree: Tree, context: SchematicContext) => {
71
+ const logger = context.logger;
72
+ const workspace = await getWorkspaceConfigGracefully(tree);
73
+
74
+ if (workspace === null) {
75
+ logger.error('Could not find workspace configuration file.');
76
+ return;
77
+ }
78
+
79
+ // Keep track of all project source files which have been checked/migrated. This is
80
+ // necessary because multiple TypeScript projects can contain the same source file and
81
+ // we don't want to check these again, as this would result in duplicated failure messages.
82
+ const analyzedFiles = new Set<WorkspacePath>();
83
+ const fileSystem = new DevkitFileSystem(tree);
84
+ const projectNames = workspace.projects.keys();
85
+ const migrations = [...cdkMigrations, ...extraMigrations] as NullableDevkitMigration[];
86
+ let hasFailures = false;
87
+
88
+ for (const projectName of projectNames) {
89
+ const project = workspace.projects.get(projectName)!;
90
+ const buildTsconfigPath = getTargetTsconfigPath(project, 'build');
91
+ const testTsconfigPath = getTargetTsconfigPath(project, 'test');
92
+
93
+ if (!buildTsconfigPath && !testTsconfigPath) {
94
+ logger.warn(
95
+ `Skipping migration for project ${projectName}. Unable to determine 'tsconfig.json' file in workspace config.`,
96
+ );
97
+ continue;
98
+ }
99
+
100
+ // In some applications, developers will have global stylesheets which are not
101
+ // specified in any Angular component. Therefore we glob up all CSS and SCSS files
102
+ // in the project and migrate them if needed.
103
+ // TODO: rework this to collect global stylesheets from the workspace config. COMP-280.
104
+ const additionalStylesheetPaths = findStylesheetFiles(tree, project.root);
105
+
106
+ if (buildTsconfigPath !== null) {
107
+ runMigrations(project, projectName, buildTsconfigPath, additionalStylesheetPaths, false);
108
+ }
109
+ if (testTsconfigPath !== null) {
110
+ runMigrations(project, projectName, testTsconfigPath, additionalStylesheetPaths, true);
111
+ }
112
+ }
113
+
114
+ let runPackageManager = false;
115
+ // Run the global post migration static members for all
116
+ // registered devkit migrations.
117
+ migrations.forEach(m => {
118
+ const actionResult =
119
+ isDevkitMigration(m) && m.globalPostMigration !== undefined
120
+ ? m.globalPostMigration(tree, targetVersion, context)
121
+ : null;
122
+ if (actionResult) {
123
+ runPackageManager = runPackageManager || actionResult.runPackageManager;
124
+ }
125
+ });
126
+
127
+ // If a migration requested the package manager to run, we run it as an
128
+ // asynchronous post migration task. We cannot run it synchronously,
129
+ // as file changes from the current migration task are not applied to
130
+ // the file system yet.
131
+ if (runPackageManager) {
132
+ context.addTask(new NodePackageInstallTask({quiet: false}));
133
+ }
134
+
135
+ if (onMigrationCompleteFn) {
136
+ onMigrationCompleteFn(context, targetVersion, hasFailures);
137
+ }
138
+
139
+ /** Runs the migrations for the specified workspace project. */
140
+ function runMigrations(
141
+ project: ProjectDefinition,
142
+ projectName: string,
143
+ tsconfigPath: WorkspacePath,
144
+ additionalStylesheetPaths: string[],
145
+ isTestTarget: boolean,
146
+ ) {
147
+ const program = UpdateProject.createProgramFromTsconfig(tsconfigPath, fileSystem);
148
+ const updateContext: DevkitContext = {
149
+ isTestTarget,
150
+ projectName,
151
+ project,
152
+ tree,
153
+ };
154
+
155
+ const updateProject = new UpdateProject(
156
+ updateContext,
157
+ program,
158
+ fileSystem,
159
+ analyzedFiles,
160
+ context.logger,
161
+ );
162
+
163
+ const result = updateProject.migrate(
164
+ migrations,
165
+ targetVersion,
166
+ upgradeData,
167
+ additionalStylesheetPaths,
168
+ );
169
+
170
+ // Commit all recorded edits in the update recorder. We apply the edits after all
171
+ // migrations ran because otherwise offsets in the TypeScript program would be
172
+ // shifted and individual migrations could no longer update the same source file.
173
+ fileSystem.commitEdits();
174
+
175
+ hasFailures = hasFailures || result.hasFailures;
176
+ }
177
+ };
178
+ }
179
+
180
+ /** Whether the given migration type refers to a devkit migration */
181
+ export function isDevkitMigration(
182
+ value: MigrationCtor<any, any>,
183
+ ): value is DevkitMigrationCtor<any> {
184
+ return DevkitMigration.isPrototypeOf(value);
185
+ }
@@ -0,0 +1,47 @@
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 {SchematicContext, Tree} from '@angular-devkit/schematics';
10
+ import {ProjectDefinition} from '@angular-devkit/core/src/workspace';
11
+ import {Constructor, Migration, PostMigrationAction} from '../update-tool/migration';
12
+ import {TargetVersion} from '../update-tool/target-version';
13
+
14
+ export type DevkitContext = {
15
+ /** Devkit tree for the current migrations. Can be used to insert/remove files. */
16
+ tree: Tree;
17
+ /** Name of the project the migrations run against. */
18
+ projectName: string;
19
+ /** Workspace project the migrations run against. */
20
+ project: ProjectDefinition;
21
+ /** Whether the migrations run for a test target. */
22
+ isTestTarget: boolean;
23
+ };
24
+
25
+ export abstract class DevkitMigration<Data> extends Migration<Data, DevkitContext> {
26
+ /** Prints an informative message with context on the current target. */
27
+ protected printInfo(text: string) {
28
+ const targetName = this.context.isTestTarget ? 'test' : 'build';
29
+ this.logger.info(`- ${this.context.projectName}@${targetName}: ${text}`);
30
+ }
31
+
32
+ /**
33
+ * Optional static method that will be called once the migration of all project
34
+ * targets has been performed. This method can be used to make changes respecting the
35
+ * migration result of all individual targets. e.g. removing HammerJS if it
36
+ * is not needed in any project target.
37
+ */
38
+ static globalPostMigration?(
39
+ tree: Tree,
40
+ targetVersion: TargetVersion,
41
+ context: SchematicContext,
42
+ ): PostMigrationAction;
43
+ }
44
+
45
+ export type DevkitMigrationCtor<Data> = Constructor<DevkitMigration<Data>> & {
46
+ [m in keyof typeof DevkitMigration]: typeof DevkitMigration[m];
47
+ };
@@ -0,0 +1,43 @@
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, Path} from '@angular-devkit/core';
10
+ import {Tree} from '@angular-devkit/schematics';
11
+
12
+ /** Regular expression that matches stylesheet paths */
13
+ const STYLESHEET_REGEX = /.*\.(css|scss)/;
14
+
15
+ /**
16
+ * Finds stylesheets in the given directory from within the specified tree.
17
+ * @param tree Devkit tree where stylesheet files can be found in.
18
+ * @param startDirectory Optional start directory where stylesheets should be searched in.
19
+ * This can be useful if only stylesheets within a given folder are relevant (to avoid
20
+ * unnecessary iterations).
21
+ */
22
+ export function findStylesheetFiles(tree: Tree, startDirectory: string = '/'): string[] {
23
+ const result: string[] = [];
24
+ const visitDir = (dirPath: Path) => {
25
+ const {subfiles, subdirs} = tree.getDir(dirPath);
26
+
27
+ subfiles.forEach(fileName => {
28
+ if (STYLESHEET_REGEX.test(fileName)) {
29
+ result.push(join(dirPath, fileName));
30
+ }
31
+ });
32
+
33
+ // Visit directories within the current directory to find other stylesheets.
34
+ subdirs.forEach(fragment => {
35
+ // Do not visit directories or files inside node modules or `dist/` folders.
36
+ if (fragment !== 'node_modules' && fragment !== 'dist') {
37
+ visitDir(join(dirPath, fragment));
38
+ }
39
+ });
40
+ };
41
+ visitDir(startDirectory as Path);
42
+ return result;
43
+ }
@@ -0,0 +1,49 @@
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 {findAttributeOnElementWithAttrs, findAttributeOnElementWithTag} from './elements';
10
+
11
+ /** Finds the specified Angular @Input in the given elements with tag name. */
12
+ export function findInputsOnElementWithTag(html: string, inputName: string, tagNames: string[]) {
13
+ return [
14
+ // Inputs can be also used without brackets (e.g. `<mat-toolbar color="primary">`)
15
+ ...findAttributeOnElementWithTag(html, inputName, tagNames),
16
+ // Add one column to the mapped offset because the first bracket for the @Input
17
+ // is part of the attribute and therefore also part of the offset. We only want to return
18
+ // the offset for the inner name of the bracketed input.
19
+ ...findAttributeOnElementWithTag(html, `[${inputName}]`, tagNames).map(offset => offset + 1),
20
+ ];
21
+ }
22
+
23
+ /** Finds the specified Angular @Input in elements that have one of the specified attributes. */
24
+ export function findInputsOnElementWithAttr(html: string, inputName: string, attrs: string[]) {
25
+ return [
26
+ // Inputs can be also used without brackets (e.g. `<button mat-button color="primary">`)
27
+ ...findAttributeOnElementWithAttrs(html, inputName, attrs),
28
+ // Add one column to the mapped offset because the first bracket for the @Input
29
+ // is part of the attribute and therefore also part of the offset. We only want to return
30
+ // the offset for the inner name of the bracketed input.
31
+ ...findAttributeOnElementWithAttrs(html, `[${inputName}]`, attrs).map(offset => offset + 1),
32
+ ];
33
+ }
34
+
35
+ /** Finds the specified Angular @Output in the given elements with tag name. */
36
+ export function findOutputsOnElementWithTag(html: string, outputName: string, tagNames: string[]) {
37
+ // Add one column to the mapped offset because the first parenthesis for the @Output
38
+ // is part of the attribute and therefore also part of the offset. We only want to return
39
+ // the offset for the inner name of the output.
40
+ return findAttributeOnElementWithTag(html, `(${outputName})`, tagNames).map(offset => offset + 1);
41
+ }
42
+
43
+ /** Finds the specified Angular @Output in elements that have one of the specified attributes. */
44
+ export function findOutputsOnElementWithAttr(html: string, outputName: string, attrs: string[]) {
45
+ // Add one column to the mapped offset because the first bracket for the @Output
46
+ // is part of the attribute and therefore also part of the offset. We only want to return
47
+ // the offset for the inner name of the output.
48
+ return findAttributeOnElementWithAttrs(html, `(${outputName})`, attrs).map(offset => offset + 1);
49
+ }
@@ -0,0 +1,66 @@
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 {ChildNode, Element, parseFragment} from 'parse5';
10
+
11
+ /**
12
+ * Parses a HTML fragment and traverses all AST nodes in order find elements that
13
+ * include the specified attribute.
14
+ */
15
+ export function findElementsWithAttribute(html: string, attributeName: string) {
16
+ const document = parseFragment(html, {sourceCodeLocationInfo: true});
17
+ const elements: Element[] = [];
18
+
19
+ const visitNodes = (nodes: ChildNode[]) => {
20
+ nodes.forEach(n => {
21
+ const node = n as Element;
22
+
23
+ if (node.childNodes) {
24
+ visitNodes(node.childNodes);
25
+ }
26
+
27
+ if (node.attrs?.some(attr => attr.name === attributeName.toLowerCase())) {
28
+ elements.push(node);
29
+ }
30
+ });
31
+ };
32
+
33
+ visitNodes(document.childNodes);
34
+
35
+ return elements;
36
+ }
37
+
38
+ /**
39
+ * Finds elements with explicit tag names that also contain the specified attribute. Returns the
40
+ * attribute start offset based on the specified HTML.
41
+ */
42
+ export function findAttributeOnElementWithTag(html: string, name: string, tagNames: string[]) {
43
+ return findElementsWithAttribute(html, name)
44
+ .filter(element => tagNames.includes(element.tagName))
45
+ .map(element => getStartOffsetOfAttribute(element, name));
46
+ }
47
+
48
+ /**
49
+ * Finds elements that contain the given attribute and contain at least one of the other
50
+ * specified attributes. Returns the primary attribute's start offset based on the specified HTML.
51
+ */
52
+ export function findAttributeOnElementWithAttrs(html: string, name: string, attrs: string[]) {
53
+ return findElementsWithAttribute(html, name)
54
+ .filter(element => attrs.some(attr => hasElementAttribute(element, attr)))
55
+ .map(element => getStartOffsetOfAttribute(element, name));
56
+ }
57
+
58
+ /** Shorthand function that checks if the specified element contains the given attribute. */
59
+ function hasElementAttribute(element: Element, attributeName: string): boolean {
60
+ return element.attrs && element.attrs.some(attr => attr.name === attributeName.toLowerCase());
61
+ }
62
+
63
+ /** Gets the start offset of the given attribute from a Parse5 element. */
64
+ export function getStartOffsetOfAttribute(element: any, attributeName: string): number {
65
+ return element.sourceCodeLocation.attrs[attributeName.toLowerCase()].startOffset;
66
+ }