@openrewrite/recipes-angular 1.28.0 → 1.30.0

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 (302) hide show
  1. package/dist/index.d.ts +9 -0
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +42 -6
  4. package/dist/index.js.map +1 -1
  5. package/dist/libraries/cdk/find-cdk-signature-changes.d.ts +0 -2
  6. package/dist/libraries/cdk/find-cdk-signature-changes.d.ts.map +1 -1
  7. package/dist/libraries/cdk/find-cdk-signature-changes.js +2 -8
  8. package/dist/libraries/cdk/find-cdk-signature-changes.js.map +1 -1
  9. package/dist/libraries/cdk/migrate-cdk-sass-imports.d.ts.map +1 -1
  10. package/dist/libraries/cdk/migrate-cdk-sass-imports.js +4 -7
  11. package/dist/libraries/cdk/migrate-cdk-sass-imports.js.map +1 -1
  12. package/dist/libraries/cdk/migrate-cdk-stepper.js +1 -1
  13. package/dist/libraries/cdk/migrate-cdk-stepper.js.map +1 -1
  14. package/dist/libraries/cdk/migrate-deprecated-overlay-sass.d.ts.map +1 -1
  15. package/dist/libraries/cdk/migrate-deprecated-overlay-sass.js +2 -4
  16. package/dist/libraries/cdk/migrate-deprecated-overlay-sass.js.map +1 -1
  17. package/dist/libraries/cdk/migrate-focus-trap-factory-create.d.ts.map +1 -1
  18. package/dist/libraries/cdk/migrate-focus-trap-factory-create.js +2 -1
  19. package/dist/libraries/cdk/migrate-focus-trap-factory-create.js.map +1 -1
  20. package/dist/libraries/cdk/remove-cdk-super-arguments.d.ts.map +1 -1
  21. package/dist/libraries/cdk/remove-cdk-super-arguments.js +1 -2
  22. package/dist/libraries/cdk/remove-cdk-super-arguments.js.map +1 -1
  23. package/dist/libraries/cdk/remove-portal-factory-resolver-arguments.d.ts.map +1 -1
  24. package/dist/libraries/cdk/remove-portal-factory-resolver-arguments.js +5 -7
  25. package/dist/libraries/cdk/remove-portal-factory-resolver-arguments.js.map +1 -1
  26. package/dist/libraries/cdk/rename-portal-template-selectors.d.ts.map +1 -1
  27. package/dist/libraries/cdk/rename-portal-template-selectors.js +3 -4
  28. package/dist/libraries/cdk/rename-portal-template-selectors.js.map +1 -1
  29. package/dist/libraries/cdk/upgrade-to-cdk.d.ts.map +1 -1
  30. package/dist/libraries/cdk/upgrade-to-cdk.js +7 -12
  31. package/dist/libraries/cdk/upgrade-to-cdk.js.map +1 -1
  32. package/dist/libraries/components/lst.d.ts +5 -1
  33. package/dist/libraries/components/lst.d.ts.map +1 -1
  34. package/dist/libraries/components/lst.js +28 -0
  35. package/dist/libraries/components/lst.js.map +1 -1
  36. package/dist/libraries/components/style-sources.d.ts +2 -5
  37. package/dist/libraries/components/style-sources.d.ts.map +1 -1
  38. package/dist/libraries/components/style-sources.js +31 -46
  39. package/dist/libraries/components/style-sources.js.map +1 -1
  40. package/dist/libraries/components/stylesheets.d.ts +1 -0
  41. package/dist/libraries/components/stylesheets.d.ts.map +1 -1
  42. package/dist/libraries/components/stylesheets.js +18 -16
  43. package/dist/libraries/components/stylesheets.js.map +1 -1
  44. package/dist/libraries/components/symbols.d.ts +4 -21
  45. package/dist/libraries/components/symbols.d.ts.map +1 -1
  46. package/dist/libraries/components/symbols.js +12 -124
  47. package/dist/libraries/components/symbols.js.map +1 -1
  48. package/dist/libraries/components/template-elements.d.ts +2 -0
  49. package/dist/libraries/components/template-elements.d.ts.map +1 -1
  50. package/dist/libraries/components/template-elements.js +6 -0
  51. package/dist/libraries/components/template-elements.js.map +1 -1
  52. package/dist/libraries/components/templates.d.ts +1 -0
  53. package/dist/libraries/components/templates.d.ts.map +1 -1
  54. package/dist/libraries/components/templates.js +43 -47
  55. package/dist/libraries/components/templates.js.map +1 -1
  56. package/dist/libraries/material/add-system-variables-prefix.d.ts +5 -3
  57. package/dist/libraries/material/add-system-variables-prefix.d.ts.map +1 -1
  58. package/dist/libraries/material/add-system-variables-prefix.js +35 -11
  59. package/dist/libraries/material/add-system-variables-prefix.js.map +1 -1
  60. package/dist/libraries/material/add-theme-base-mixins.d.ts.map +1 -1
  61. package/dist/libraries/material/add-theme-base-mixins.js +7 -7
  62. package/dist/libraries/material/add-theme-base-mixins.js.map +1 -1
  63. package/dist/libraries/material/find-chip-input-event-without-chip-input.d.ts.map +1 -1
  64. package/dist/libraries/material/find-chip-input-event-without-chip-input.js +1 -2
  65. package/dist/libraries/material/find-chip-input-event-without-chip-input.js.map +1 -1
  66. package/dist/libraries/material/find-legacy-material-usage.d.ts.map +1 -1
  67. package/dist/libraries/material/find-legacy-material-usage.js +3 -11
  68. package/dist/libraries/material/find-legacy-material-usage.js.map +1 -1
  69. package/dist/libraries/material/find-material-constructor-changes.d.ts.map +1 -1
  70. package/dist/libraries/material/find-material-constructor-changes.js +2 -3
  71. package/dist/libraries/material/find-material-constructor-changes.js.map +1 -1
  72. package/dist/libraries/material/find-mdc-breaking-changes.d.ts.map +1 -1
  73. package/dist/libraries/material/find-mdc-breaking-changes.js +4 -18
  74. package/dist/libraries/material/find-mdc-breaking-changes.js.map +1 -1
  75. package/dist/libraries/material/find-mixin-error-state-without-state-changes.js +1 -1
  76. package/dist/libraries/material/find-mixin-error-state-without-state-changes.js.map +1 -1
  77. package/dist/libraries/material/find-raw-palette-themes.d.ts.map +1 -1
  78. package/dist/libraries/material/find-raw-palette-themes.js +3 -5
  79. package/dist/libraries/material/find-raw-palette-themes.js.map +1 -1
  80. package/dist/libraries/material/find-removed-material-classes.d.ts.map +1 -1
  81. package/dist/libraries/material/find-removed-material-classes.js +4 -14
  82. package/dist/libraries/material/find-removed-material-classes.js.map +1 -1
  83. package/dist/libraries/material/find-removed-material-members.d.ts.map +1 -1
  84. package/dist/libraries/material/find-removed-material-members.js +2 -3
  85. package/dist/libraries/material/find-removed-material-members.js.map +1 -1
  86. package/dist/libraries/material/find-slide-toggle-drag-options.d.ts +5 -3
  87. package/dist/libraries/material/find-slide-toggle-drag-options.d.ts.map +1 -1
  88. package/dist/libraries/material/find-slide-toggle-drag-options.js +7 -13
  89. package/dist/libraries/material/find-slide-toggle-drag-options.js.map +1 -1
  90. package/dist/libraries/material/material-version.d.ts +16 -2
  91. package/dist/libraries/material/material-version.d.ts.map +1 -1
  92. package/dist/libraries/material/material-version.js +35 -5
  93. package/dist/libraries/material/material-version.js.map +1 -1
  94. package/dist/libraries/material/migrate-legacy-material.d.ts.map +1 -1
  95. package/dist/libraries/material/migrate-legacy-material.js +5 -11
  96. package/dist/libraries/material/migrate-legacy-material.js.map +1 -1
  97. package/dist/libraries/material/migrate-m2-theming-api.d.ts.map +1 -1
  98. package/dist/libraries/material/migrate-m2-theming-api.js +3 -6
  99. package/dist/libraries/material/migrate-m2-theming-api.js.map +1 -1
  100. package/dist/libraries/material/migrate-mat-core-to-elevation-classes.d.ts +5 -3
  101. package/dist/libraries/material/migrate-mat-core-to-elevation-classes.d.ts.map +1 -1
  102. package/dist/libraries/material/migrate-mat-core-to-elevation-classes.js +15 -3
  103. package/dist/libraries/material/migrate-mat-core-to-elevation-classes.js.map +1 -1
  104. package/dist/libraries/material/migrate-material-15-typography.d.ts.map +1 -1
  105. package/dist/libraries/material/migrate-material-15-typography.js +9 -20
  106. package/dist/libraries/material/migrate-material-15-typography.js.map +1 -1
  107. package/dist/libraries/material/migrate-material-secondary-entry-points.d.ts.map +1 -1
  108. package/dist/libraries/material/migrate-material-secondary-entry-points.js +41 -2
  109. package/dist/libraries/material/migrate-material-secondary-entry-points.js.map +1 -1
  110. package/dist/libraries/material/migrate-material-theming-api.d.ts +1 -0
  111. package/dist/libraries/material/migrate-material-theming-api.d.ts.map +1 -1
  112. package/dist/libraries/material/migrate-material-theming-api.js +33 -24
  113. package/dist/libraries/material/migrate-material-theming-api.js.map +1 -1
  114. package/dist/libraries/material/migrate-mdc-styles.d.ts.map +1 -1
  115. package/dist/libraries/material/migrate-mdc-styles.js +5 -14
  116. package/dist/libraries/material/migrate-mdc-styles.js.map +1 -1
  117. package/dist/libraries/material/migrate-mdc-templates.d.ts.map +1 -1
  118. package/dist/libraries/material/migrate-mdc-templates.js +54 -30
  119. package/dist/libraries/material/migrate-mdc-templates.js.map +1 -1
  120. package/dist/libraries/material/remove-mat-stepper-document-argument.d.ts.map +1 -1
  121. package/dist/libraries/material/remove-mat-stepper-document-argument.js +1 -2
  122. package/dist/libraries/material/remove-mat-stepper-document-argument.js.map +1 -1
  123. package/dist/libraries/material/remove-update-active-link-argument.d.ts.map +1 -1
  124. package/dist/libraries/material/remove-update-active-link-argument.js +1 -2
  125. package/dist/libraries/material/remove-update-active-link-argument.js.map +1 -1
  126. package/dist/libraries/material/rename-material-style-names.d.ts +14 -7
  127. package/dist/libraries/material/rename-material-style-names.d.ts.map +1 -1
  128. package/dist/libraries/material/rename-material-style-names.js +69 -35
  129. package/dist/libraries/material/rename-material-style-names.js.map +1 -1
  130. package/dist/libraries/material/rename-textarea-autosize-attributes.d.ts +5 -15
  131. package/dist/libraries/material/rename-textarea-autosize-attributes.d.ts.map +1 -1
  132. package/dist/libraries/material/rename-textarea-autosize-attributes.js +30 -15
  133. package/dist/libraries/material/rename-textarea-autosize-attributes.js.map +1 -1
  134. package/dist/libraries/material/upgrade-to-material.d.ts.map +1 -1
  135. package/dist/libraries/material/upgrade-to-material.js +19 -31
  136. package/dist/libraries/material/upgrade-to-material.js.map +1 -1
  137. package/dist/migration/js-support.d.ts +1 -1
  138. package/dist/migration/js-support.d.ts.map +1 -1
  139. package/dist/migration/js-support.js +2 -2
  140. package/dist/migration/js-support.js.map +1 -1
  141. package/dist/migration/json-support.d.ts +11 -0
  142. package/dist/migration/json-support.d.ts.map +1 -1
  143. package/dist/migration/json-support.js +50 -0
  144. package/dist/migration/json-support.js.map +1 -1
  145. package/dist/migration/move-common-engine-to-ssr-node.d.ts +8 -0
  146. package/dist/migration/move-common-engine-to-ssr-node.d.ts.map +1 -0
  147. package/dist/migration/move-common-engine-to-ssr-node.js +68 -0
  148. package/dist/migration/move-common-engine-to-ssr-node.js.map +1 -0
  149. package/dist/migration/remove-guard-and-resolve-interfaces.d.ts +8 -0
  150. package/dist/migration/remove-guard-and-resolve-interfaces.d.ts.map +1 -0
  151. package/dist/migration/remove-guard-and-resolve-interfaces.js +117 -0
  152. package/dist/migration/remove-guard-and-resolve-interfaces.js.map +1 -0
  153. package/dist/migration/remove-show-circular-dependencies.d.ts +8 -0
  154. package/dist/migration/remove-show-circular-dependencies.d.ts.map +1 -0
  155. package/dist/migration/remove-show-circular-dependencies.js +57 -0
  156. package/dist/migration/remove-show-circular-dependencies.js.map +1 -0
  157. package/dist/migration/rename-ssr-experimental-platform.d.ts.map +1 -1
  158. package/dist/migration/rename-ssr-experimental-platform.js +10 -47
  159. package/dist/migration/rename-ssr-experimental-platform.js.map +1 -1
  160. package/dist/migration/replace-browser-target.d.ts +8 -0
  161. package/dist/migration/replace-browser-target.d.ts.map +1 -0
  162. package/dist/migration/replace-browser-target.js +62 -0
  163. package/dist/migration/replace-browser-target.js.map +1 -0
  164. package/dist/migration/replace-default-collection.d.ts +8 -0
  165. package/dist/migration/replace-default-collection.d.ts.map +1 -0
  166. package/dist/migration/replace-default-collection.js +59 -0
  167. package/dist/migration/replace-default-collection.js.map +1 -0
  168. package/dist/migration/replace-get-current-navigation.d.ts +8 -0
  169. package/dist/migration/replace-get-current-navigation.d.ts.map +1 -0
  170. package/dist/migration/replace-get-current-navigation.js +69 -0
  171. package/dist/migration/replace-get-current-navigation.js.map +1 -0
  172. package/dist/migration/replace-initializer-providers.d.ts +8 -0
  173. package/dist/migration/replace-initializer-providers.d.ts.map +1 -0
  174. package/dist/migration/replace-initializer-providers.js +169 -0
  175. package/dist/migration/replace-initializer-providers.js.map +1 -0
  176. package/dist/migration/replace-preserve-query-params.d.ts +8 -0
  177. package/dist/migration/replace-preserve-query-params.d.ts.map +1 -0
  178. package/dist/migration/replace-preserve-query-params.js +115 -0
  179. package/dist/migration/replace-preserve-query-params.js.map +1 -0
  180. package/dist/migration/replace-provide-server-routing.d.ts +8 -0
  181. package/dist/migration/replace-provide-server-routing.d.ts.map +1 -0
  182. package/dist/migration/replace-provide-server-routing.js +98 -0
  183. package/dist/migration/replace-provide-server-routing.js.map +1 -0
  184. package/dist/migration/upgrade-angular-dependencies.d.ts +0 -2
  185. package/dist/migration/upgrade-angular-dependencies.d.ts.map +1 -1
  186. package/dist/migration/upgrade-angular-dependencies.js +0 -6
  187. package/dist/migration/upgrade-angular-dependencies.js.map +1 -1
  188. package/dist/migration/upgrade-to-angular-10.d.ts.map +1 -1
  189. package/dist/migration/upgrade-to-angular-10.js +1 -2
  190. package/dist/migration/upgrade-to-angular-10.js.map +1 -1
  191. package/dist/migration/upgrade-to-angular-11.d.ts.map +1 -1
  192. package/dist/migration/upgrade-to-angular-11.js +5 -3
  193. package/dist/migration/upgrade-to-angular-11.js.map +1 -1
  194. package/dist/migration/upgrade-to-angular-12.d.ts.map +1 -1
  195. package/dist/migration/upgrade-to-angular-12.js +1 -2
  196. package/dist/migration/upgrade-to-angular-12.js.map +1 -1
  197. package/dist/migration/upgrade-to-angular-13.d.ts.map +1 -1
  198. package/dist/migration/upgrade-to-angular-13.js +1 -2
  199. package/dist/migration/upgrade-to-angular-13.js.map +1 -1
  200. package/dist/migration/upgrade-to-angular-14.d.ts.map +1 -1
  201. package/dist/migration/upgrade-to-angular-14.js +8 -2
  202. package/dist/migration/upgrade-to-angular-14.js.map +1 -1
  203. package/dist/migration/upgrade-to-angular-15.d.ts.map +1 -1
  204. package/dist/migration/upgrade-to-angular-15.js +1 -2
  205. package/dist/migration/upgrade-to-angular-15.js.map +1 -1
  206. package/dist/migration/upgrade-to-angular-16.d.ts.map +1 -1
  207. package/dist/migration/upgrade-to-angular-16.js +4 -2
  208. package/dist/migration/upgrade-to-angular-16.js.map +1 -1
  209. package/dist/migration/upgrade-to-angular-17.d.ts.map +1 -1
  210. package/dist/migration/upgrade-to-angular-17.js +1 -2
  211. package/dist/migration/upgrade-to-angular-17.js.map +1 -1
  212. package/dist/migration/upgrade-to-angular-18.d.ts.map +1 -1
  213. package/dist/migration/upgrade-to-angular-18.js +1 -2
  214. package/dist/migration/upgrade-to-angular-18.js.map +1 -1
  215. package/dist/migration/upgrade-to-angular-19.d.ts.map +1 -1
  216. package/dist/migration/upgrade-to-angular-19.js +12 -4
  217. package/dist/migration/upgrade-to-angular-19.js.map +1 -1
  218. package/dist/migration/upgrade-to-angular-20.d.ts.map +1 -1
  219. package/dist/migration/upgrade-to-angular-20.js +12 -3
  220. package/dist/migration/upgrade-to-angular-20.js.map +1 -1
  221. package/dist/migration/upgrade-to-angular-21.d.ts.map +1 -1
  222. package/dist/migration/upgrade-to-angular-21.js +4 -2
  223. package/dist/migration/upgrade-to-angular-21.js.map +1 -1
  224. package/dist/migration/upgrade-to-angular-22.d.ts.map +1 -1
  225. package/dist/migration/upgrade-to-angular-22.js +1 -2
  226. package/dist/migration/upgrade-to-angular-22.js.map +1 -1
  227. package/dist/migration/upgrade-to-angular-8.d.ts.map +1 -1
  228. package/dist/migration/upgrade-to-angular-8.js +1 -3
  229. package/dist/migration/upgrade-to-angular-8.js.map +1 -1
  230. package/dist/migration/upgrade-to-angular-9.d.ts.map +1 -1
  231. package/dist/migration/upgrade-to-angular-9.js +1 -2
  232. package/dist/migration/upgrade-to-angular-9.js.map +1 -1
  233. package/package.json +6 -5
  234. package/src/index.ts +27 -0
  235. package/src/libraries/cdk/find-cdk-signature-changes.ts +1 -6
  236. package/src/libraries/cdk/migrate-cdk-sass-imports.ts +4 -7
  237. package/src/libraries/cdk/migrate-cdk-stepper.ts +2 -2
  238. package/src/libraries/cdk/migrate-deprecated-overlay-sass.ts +2 -4
  239. package/src/libraries/cdk/migrate-focus-trap-factory-create.ts +2 -1
  240. package/src/libraries/cdk/remove-cdk-super-arguments.ts +1 -2
  241. package/src/libraries/cdk/remove-portal-factory-resolver-arguments.ts +4 -6
  242. package/src/libraries/cdk/rename-portal-template-selectors.ts +3 -4
  243. package/src/libraries/cdk/upgrade-to-cdk.ts +7 -12
  244. package/src/libraries/components/lst.ts +17 -1
  245. package/src/libraries/components/style-sources.ts +20 -31
  246. package/src/libraries/components/stylesheets.ts +13 -10
  247. package/src/libraries/components/symbols.ts +12 -96
  248. package/src/libraries/components/template-elements.ts +5 -0
  249. package/src/libraries/components/templates.ts +32 -33
  250. package/src/libraries/material/add-system-variables-prefix.ts +27 -11
  251. package/src/libraries/material/add-theme-base-mixins.ts +7 -7
  252. package/src/libraries/material/find-chip-input-event-without-chip-input.ts +1 -2
  253. package/src/libraries/material/find-legacy-material-usage.ts +5 -11
  254. package/src/libraries/material/find-material-constructor-changes.ts +2 -3
  255. package/src/libraries/material/find-mdc-breaking-changes.ts +6 -17
  256. package/src/libraries/material/find-mixin-error-state-without-state-changes.ts +2 -2
  257. package/src/libraries/material/find-raw-palette-themes.ts +3 -5
  258. package/src/libraries/material/find-removed-material-classes.ts +6 -14
  259. package/src/libraries/material/find-removed-material-members.ts +2 -3
  260. package/src/libraries/material/find-slide-toggle-drag-options.ts +10 -13
  261. package/src/libraries/material/material-version.ts +37 -5
  262. package/src/libraries/material/migrate-legacy-material.ts +5 -11
  263. package/src/libraries/material/migrate-m2-theming-api.ts +3 -6
  264. package/src/libraries/material/migrate-mat-core-to-elevation-classes.ts +8 -5
  265. package/src/libraries/material/migrate-material-15-typography.ts +12 -20
  266. package/src/libraries/material/migrate-material-secondary-entry-points.ts +35 -3
  267. package/src/libraries/material/migrate-material-theming-api.ts +30 -22
  268. package/src/libraries/material/migrate-mdc-styles.ts +6 -13
  269. package/src/libraries/material/migrate-mdc-templates.ts +51 -28
  270. package/src/libraries/material/remove-mat-stepper-document-argument.ts +1 -2
  271. package/src/libraries/material/remove-update-active-link-argument.ts +1 -2
  272. package/src/libraries/material/rename-material-style-names.ts +79 -31
  273. package/src/libraries/material/rename-textarea-autosize-attributes.ts +24 -16
  274. package/src/libraries/material/upgrade-to-material.ts +19 -31
  275. package/src/migration/js-support.ts +2 -2
  276. package/src/migration/json-support.ts +50 -1
  277. package/src/migration/move-common-engine-to-ssr-node.ts +46 -0
  278. package/src/migration/remove-guard-and-resolve-interfaces.ts +89 -0
  279. package/src/migration/remove-show-circular-dependencies.ts +40 -0
  280. package/src/migration/rename-ssr-experimental-platform.ts +8 -49
  281. package/src/migration/replace-browser-target.ts +45 -0
  282. package/src/migration/replace-default-collection.ts +45 -0
  283. package/src/migration/replace-get-current-navigation.ts +50 -0
  284. package/src/migration/replace-initializer-providers.ts +153 -0
  285. package/src/migration/replace-preserve-query-params.ts +88 -0
  286. package/src/migration/replace-provide-server-routing.ts +79 -0
  287. package/src/migration/upgrade-angular-dependencies.ts +0 -6
  288. package/src/migration/upgrade-to-angular-10.ts +2 -3
  289. package/src/migration/upgrade-to-angular-11.ts +6 -4
  290. package/src/migration/upgrade-to-angular-12.ts +2 -3
  291. package/src/migration/upgrade-to-angular-13.ts +2 -3
  292. package/src/migration/upgrade-to-angular-14.ts +9 -3
  293. package/src/migration/upgrade-to-angular-15.ts +2 -3
  294. package/src/migration/upgrade-to-angular-16.ts +5 -3
  295. package/src/migration/upgrade-to-angular-17.ts +2 -3
  296. package/src/migration/upgrade-to-angular-18.ts +2 -3
  297. package/src/migration/upgrade-to-angular-19.ts +13 -5
  298. package/src/migration/upgrade-to-angular-20.ts +13 -4
  299. package/src/migration/upgrade-to-angular-21.ts +5 -3
  300. package/src/migration/upgrade-to-angular-22.ts +2 -3
  301. package/src/migration/upgrade-to-angular-8.ts +1 -3
  302. package/src/migration/upgrade-to-angular-9.ts +2 -3
@@ -4,35 +4,84 @@
4
4
  * Moderne Proprietary. Only for use by Moderne customers under the terms of a commercial contract.
5
5
  */
6
6
 
7
- import {Cursor, ExecutionContext, Tree, TreeVisitor} from "@openrewrite/rewrite";
7
+ import {ExecutionContext, TreeVisitor} from "@openrewrite/rewrite";
8
8
  import {Json, JsonVisitor} from "@openrewrite/rewrite/json";
9
- import {renameNames, RewriteStyleSources} from "../components/style-sources";
9
+ import {renameNames, styleSourcesEditor} from "../components/style-sources";
10
+ import {MaterialVersionRecipe} from "./material-version";
11
+ import {inSequence} from "../components/lst";
10
12
 
11
- export class RenameListItemAvatarClass extends RewriteStyleSources {
13
+ export class RenameListItemAvatarClass extends MaterialVersionRecipe {
12
14
  readonly name = "org.openrewrite.angular.material.RenameListItemAvatarClass";
13
15
  readonly displayName = "Rename the `mat-list-item-avatar` CSS class";
14
16
  readonly description = "Material 14 renamed the `mat-list-item-avatar` class of list items with an avatar to " +
15
17
  "`mat-list-item-with-avatar`. Renames the `.mat-list-item-avatar` selector in stylesheets, templates and " +
16
18
  "TypeScript strings.";
17
19
 
20
+ protected readonly version = 14;
21
+
22
+ protected async editorBeforeVersion(): Promise<TreeVisitor<any, ExecutionContext>> {
23
+ return styleSourcesEditor(text => this.rewrite(text));
24
+ }
25
+
18
26
  protected rewrite(text: string): string {
19
27
  return renameNames(text, {'.mat-list-item-avatar': '.mat-list-item-with-avatar'});
20
28
  }
21
29
  }
22
30
 
23
- export class RenameMaterial18Tokens extends RewriteStyleSources {
31
+ export class RenameMaterial18Tokens extends MaterialVersionRecipe {
24
32
  readonly name = "org.openrewrite.angular.material.RenameMaterial18Tokens";
25
- readonly displayName = "Rename the checkbox label CSS tokens of Angular Material 18";
26
- readonly description = "Material 18 moved the checkbox label tokens from `--mdc-form-field-label-text-*` to " +
27
- "`--mat-checkbox-label-text-*`. Renames them in stylesheets, templates and TypeScript strings.";
33
+ readonly displayName = "Split the form field label CSS tokens of Angular Material 18";
34
+ readonly description = "Material 18 split the `--mdc-form-field-label-text-*` tokens into " +
35
+ "`--mat-checkbox-label-text-*`, `--mat-radio-label-text-*` and `--mat-switch-label-text-*`. Sets all three " +
36
+ "where the old token was set, so that radio buttons and slide toggles keep the override, which the `ng " +
37
+ "update` renames to the checkbox token only.";
38
+
39
+ protected readonly version = 18;
40
+
41
+ protected async editorBeforeVersion(): Promise<TreeVisitor<any, ExecutionContext>> {
42
+ return styleSourcesEditor(text => this.rewrite(text));
43
+ }
28
44
 
29
45
  protected rewrite(text: string): string {
30
- if (!text.includes('--mdc-form-field-label-text-')) return text;
31
- return renameNames(text, Object.fromEntries(['color', 'font', 'line-height', 'size', 'tracking', 'weight']
32
- .map(t => [`--mdc-form-field-label-text-${t}`, `--mat-checkbox-label-text-${t}`])));
46
+ if (!text.includes(LABEL_TOKEN)) return text;
47
+ return renameNames(text.replace(LABEL_TOKEN_DECLARATION, splitLabelTokenDeclaration), Object.fromEntries(
48
+ LABEL_TOKEN_PROPERTIES.map(t => [`${LABEL_TOKEN}${t}`, `--mat-checkbox-label-text-${t}`])));
33
49
  }
34
50
  }
35
51
 
52
+ const LABEL_TOKEN = '--mdc-form-field-label-text-';
53
+
54
+ const LABEL_TOKEN_PROPERTIES = ['color', 'font', 'line-height', 'size', 'tracking', 'weight'];
55
+
56
+ /**
57
+ * A declaration of a label token that ends with `;`, or at the end of its block, line, or the attribute or string
58
+ * that holds it.
59
+ */
60
+ const LABEL_TOKEN_DECLARATION = new RegExp(`${LABEL_TOKEN}(${LABEL_TOKEN_PROPERTIES.join('|')})(\\s*:\\s*)` +
61
+ `((?:[^;{}\\n"'\`]|"[^"\\n]*"|'[^'\\n]*'|#\\{[^{}\\n]*\\})*)(\\s*;|(?=\\s*[}"'\`]|[ \\t]*\\r?$))`, 'gm');
62
+
63
+ function splitLabelTokenDeclaration(_declaration: string, property: string, colon: string, value: string, end: string,
64
+ offset: number, text: string): string {
65
+ const lineStart = text.lastIndexOf('\n', offset - 1) + 1;
66
+ const indent = text.slice(lineStart, offset);
67
+ const separator = /^\s*$/.test(indent) ? `${text[lineStart - 2] === '\r' ? '\r\n' : '\n'}${indent}` : ' ';
68
+ const trimmed = value.trimEnd();
69
+ return ['checkbox', 'radio', 'switch']
70
+ .map(component => `--mat-${component}-label-text-${property}${colon}${trimmed}`)
71
+ .join(`;${separator}`) + value.slice(trimmed.length) + end;
72
+ }
73
+
74
+ /**
75
+ * The components whose tokens Material 19 named with `--mdc-`. MDC Web uses that prefix too, for variables such as
76
+ * `--mdc-theme-primary` that Material never read.
77
+ */
78
+ const MATERIAL_19_MDC_TOKEN = new RegExp(`--mdc-(?=(?:${[
79
+ 'checkbox', 'chip', 'circular-progress', 'dialog', 'elevated-card', 'extended-fab', 'fab', 'filled-button',
80
+ 'filled-text-field', 'icon-button', 'linear-progress', 'list', 'outlined-button', 'outlined-card',
81
+ 'outlined-text-field', 'plain-tooltip', 'protected-button', 'radio', 'secondary-navigation-tab', 'slider',
82
+ 'snackbar', 'switch', 'tab-indicator', 'text-button',
83
+ ].join('|')})-)`, 'g');
84
+
36
85
  /** Component token prefixes that Material 20 renamed, after the `--mdc-` prefix became `--mat-`. */
37
86
  const MATERIAL_20_TOKEN_PREFIXES: Record<string, string> = {
38
87
  '--mat-circular-progress': '--mat-progress-spinner',
@@ -60,17 +109,22 @@ const MATERIAL_20_TOKEN_PREFIXES: Record<string, string> = {
60
109
  '--mat-tonal-button': '--mat-button-tonal',
61
110
  };
62
111
 
63
- export class RenameMaterial20Tokens extends RewriteStyleSources {
112
+ export class RenameMaterial20Tokens extends MaterialVersionRecipe {
64
113
  readonly name = "org.openrewrite.angular.material.RenameMaterial20Tokens";
65
114
  readonly displayName = "Rename the CSS tokens of Angular Material 20";
66
- readonly description = "Material 20 replaced the `--mdc-` prefix of its CSS tokens with `--mat-` and renamed the " +
67
- "component prefixes after the component, such as `--mat-switch` to `--mat-slide-toggle` and `--mdc-snackbar` to " +
68
- "`--mat-snack-bar`. Renames them in stylesheets, templates and TypeScript strings, matching the longest prefix " +
69
- "first so that `--mat-tab-header-with-background-*` becomes `--mat-tab-*`.";
115
+ readonly description = "Material 20 replaced the `--mdc-` prefix of its CSS tokens with `--mat-` and renamed " +
116
+ "some component prefixes, such as `--mat-switch` to `--mat-slide-toggle`. Renames them in stylesheets, " +
117
+ "templates and strings.";
118
+
119
+ protected readonly version = 20;
120
+
121
+ protected async editorBeforeVersion(): Promise<TreeVisitor<any, ExecutionContext>> {
122
+ return styleSourcesEditor(text => this.rewrite(text));
123
+ }
70
124
 
71
125
  protected rewrite(text: string): string {
72
126
  if (!text.includes('--mdc-') && !Object.keys(MATERIAL_20_TOKEN_PREFIXES).some(prefix => text.includes(prefix))) return text;
73
- let updated = text.replace(/--mdc-/g, '--mat-');
127
+ let updated = text.replace(MATERIAL_19_MDC_TOKEN, '--mat-');
74
128
  for (const prefix of Object.keys(MATERIAL_20_TOKEN_PREFIXES).sort((a, b) => b.length - a.length)) {
75
129
  updated = updated.replace(new RegExp(`${prefix}(?=-|[^\\w-]|$)`, 'g'), MATERIAL_20_TOKEN_PREFIXES[prefix]);
76
130
  }
@@ -81,22 +135,22 @@ export class RenameMaterial20Tokens extends RewriteStyleSources {
81
135
  /** A prebuilt theme of the legacy components, with the name of the matching theme of the MDC-based components. */
82
136
  const LEGACY_PREBUILT_THEME = /(@angular\/material\/)legacy-prebuilt-themes\/legacy-([\w-]+\.css)/g;
83
137
 
84
- export class RenameLegacyPrebuiltThemes extends RewriteStyleSources {
138
+ export class RenameLegacyPrebuiltThemes extends MaterialVersionRecipe {
85
139
  readonly name = "org.openrewrite.angular.material.RenameLegacyPrebuiltThemes";
86
140
  readonly displayName = "Use the prebuilt themes of the MDC-based Angular Material components";
87
- readonly description = "Material 17 removed the `legacy-prebuilt-themes` of the legacy components, which the " +
88
- "Material 15 `ng update` pointed projects to. Replaces each one, such as " +
89
- "`@angular/material/legacy-prebuilt-themes/legacy-indigo-pink.css`, with the matching theme in " +
90
- "`@angular/material/prebuilt-themes`, in `angular.json` and other JSON files, stylesheets, templates and " +
91
- "TypeScript strings.";
141
+ readonly description = "Material 17 removed the `legacy-prebuilt-themes`. Replaces each one, such as " +
142
+ "`legacy-prebuilt-themes/legacy-indigo-pink.css`, with the matching theme in `prebuilt-themes`, in " +
143
+ "`angular.json`, stylesheets, templates and strings.";
144
+
145
+ protected readonly version = 17;
92
146
 
93
147
  protected rewrite(text: string): string {
94
148
  return text.includes('legacy-prebuilt-themes') ? text.replace(LEGACY_PREBUILT_THEME, '$1prebuilt-themes/$2') : text;
95
149
  }
96
150
 
97
- async editor(): Promise<TreeVisitor<any, ExecutionContext>> {
98
- const sources = await super.editor();
151
+ protected async editorBeforeVersion(): Promise<TreeVisitor<any, ExecutionContext>> {
99
152
  const rewrite = (text: string) => this.rewrite(text);
153
+ const sources = styleSourcesEditor(rewrite);
100
154
  const json = new class extends JsonVisitor<ExecutionContext> {
101
155
  protected async visitLiteral(literal: Json.Literal, p: ExecutionContext): Promise<Json | undefined> {
102
156
  const l = await super.visitLiteral(literal, p) as Json.Literal;
@@ -105,12 +159,6 @@ export class RenameLegacyPrebuiltThemes extends RewriteStyleSources {
105
159
  return source === l.source ? l : {...l, source, value: rewrite(l.value)} as Json.Literal;
106
160
  }
107
161
  }();
108
- // Each visitor returns a source file it does not accept unchanged.
109
- return new class extends TreeVisitor<any, ExecutionContext> {
110
- async visit<R extends Tree>(tree: Tree, p: ExecutionContext, parent?: Cursor): Promise<R | undefined> {
111
- const visited = await sources.visit<Tree>(tree, p, parent);
112
- return visited && await json.visit(visited, p, parent) as R | undefined;
113
- }
114
- }();
162
+ return inSequence(sources, json);
115
163
  }
116
164
  }
@@ -4,24 +4,32 @@
4
4
  * Moderne Proprietary. Only for use by Moderne customers under the terms of a commercial contract.
5
5
  */
6
6
 
7
- import {RenameTemplateAttributes} from "../components/templates";
7
+ import {ExecutionContext, TreeVisitor} from "@openrewrite/rewrite";
8
+ import {templateAttributesEditor} from "../components/templates";
9
+ import {MaterialVersionRecipe} from "./material-version";
8
10
 
9
- export class RenameTextareaAutosizeAttributes extends RenameTemplateAttributes {
11
+ export class RenameTextareaAutosizeAttributes extends MaterialVersionRecipe {
10
12
  readonly name = "org.openrewrite.angular.material.RenameTextareaAutosizeAttributes";
11
13
  readonly displayName = "Replace `matTextareaAutosize` with `cdkTextareaAutosize` in templates";
12
- readonly description = "Material 13 removed the `MatTextareaAutosize` directive. Renames its selectors and inputs " +
13
- "to those of `CdkTextareaAutosize`, which `MatInputModule` exports: `matTextareaAutosize` and `mat-autosize` " +
14
- "become `cdkTextareaAutosize`, and `matAutosizeMinRows` and `matAutosizeMaxRows` become `cdkAutosizeMinRows` " +
15
- "and `cdkAutosizeMaxRows`, in `.html` templates and inline `template` metadata.";
14
+ readonly description = "Material 13 removed the `MatTextareaAutosize` directive. Renames its selectors and " +
15
+ "inputs in templates to those of `CdkTextareaAutosize`, such as `matAutosizeMinRows` to " +
16
+ "`cdkAutosizeMinRows`.";
16
17
 
17
- protected readonly attributes = [
18
- {name: 'matTextareaAutosize', newName: 'cdkTextareaAutosize'},
19
- {name: 'mat-autosize', newName: 'cdkTextareaAutosize', element: 'textarea'},
20
- {name: 'matAutosize', newName: 'cdkTextareaAutosize'},
21
- {name: 'matAutosizeMinRows', newName: 'cdkAutosizeMinRows'},
22
- {name: 'matAutosizeMaxRows', newName: 'cdkAutosizeMaxRows'},
23
- ];
24
- protected readonly exportAs = [
25
- {name: 'matTextareaAutosize', newName: 'cdkTextareaAutosize'},
26
- ];
18
+ protected readonly version = 13;
19
+
20
+ protected async editorBeforeVersion(): Promise<TreeVisitor<any, ExecutionContext>> {
21
+ return templateAttributesEditor(ATTRIBUTES, EXPORT_AS);
22
+ }
27
23
  }
24
+
25
+ const ATTRIBUTES = [
26
+ {name: 'matTextareaAutosize', newName: 'cdkTextareaAutosize'},
27
+ {name: 'mat-autosize', newName: 'cdkTextareaAutosize', element: 'textarea'},
28
+ {name: 'matAutosize', newName: 'cdkTextareaAutosize'},
29
+ {name: 'matAutosizeMinRows', newName: 'cdkAutosizeMinRows'},
30
+ {name: 'matAutosizeMaxRows', newName: 'cdkAutosizeMaxRows'},
31
+ ];
32
+
33
+ const EXPORT_AS = [
34
+ {name: 'matTextareaAutosize', newName: 'cdkTextareaAutosize'},
35
+ ];
@@ -90,10 +90,9 @@ export class UpgradeToMaterial9CodeChanges extends Recipe {
90
90
  export class UpgradeToMaterial10CodeChanges extends Recipe {
91
91
  readonly name = "org.openrewrite.angular.material.UpgradeToMaterial10CodeChanges";
92
92
  readonly displayName = "Angular Material 10 code changes";
93
- readonly description = "The `@angular/material` source changes of the version 10 migration: renames " +
94
- "`MatButtonToggleGroupMultiple` to `MatButtonToggleGroup`, and finds the removed HammerJS gesture APIs, the " +
95
- "removed slide toggle drag options and events, and constructor calls that no longer fit the changed " +
96
- "constructors. `UpgradeToAngular10` includes this recipe.";
93
+ readonly description = "The source changes of the `@angular/material` 10 migration, such as renaming " +
94
+ "`MatButtonToggleGroupMultiple` to `MatButtonToggleGroup`. Removed APIs, such as the HammerJS gesture APIs, " +
95
+ "are marked. `UpgradeToAngular10` includes this recipe.";
97
96
 
98
97
  async recipeList(): Promise<Recipe[]> {
99
98
  return [
@@ -111,11 +110,9 @@ export class UpgradeToMaterial10CodeChanges extends Recipe {
111
110
  export class UpgradeToMaterial11CodeChanges extends Recipe {
112
111
  readonly name = "org.openrewrite.angular.material.UpgradeToMaterial11CodeChanges";
113
112
  readonly displayName = "Angular Material 11 code changes";
114
- readonly description = "The `@angular/material` source changes of the version 11 migration: renames " +
115
- "`MatDatepickerInput.getPopupConnectionElementRef` to `getConnectedOverlayOrigin`, removes the argument of " +
116
- "`MatTabNav.updateActiveLink`, and finds the removed month constants and `MAT_CHECKBOX_CLICK_ACTION`, calls of " +
117
- "`MatSnackBarHarness.getRole`, and constructor calls that no longer fit the changed constructors. " +
118
- "`UpgradeToAngular11` includes this recipe.";
113
+ readonly description = "The source changes of the `@angular/material` 11 migration, such as renaming " +
114
+ "`MatDatepickerInput.getPopupConnectionElementRef` to `getConnectedOverlayOrigin`. Removed APIs and " +
115
+ "constructor calls that no longer fit are marked. `UpgradeToAngular11` includes this recipe.";
119
116
 
120
117
  async recipeList(): Promise<Recipe[]> {
121
118
  return [
@@ -146,10 +143,9 @@ export class UpgradeToMaterial12CodeChanges extends Recipe {
146
143
  export class UpgradeToMaterial13CodeChanges extends Recipe {
147
144
  readonly name = "org.openrewrite.angular.material.UpgradeToMaterial13CodeChanges";
148
145
  readonly displayName = "Angular Material 13 code changes";
149
- readonly description = "The `@angular/material` source changes of the version 13 migration: replaces the removed " +
150
- "`MatTextareaAutosize` with `CdkTextareaAutosize` in code and templates, and finds the removed mixin constructor " +
151
- "types, `MatFormField.underlineRef`, the removed form field and tab harness loaders, and constructor calls that " +
152
- "no longer fit the changed constructors. `UpgradeToAngular13` includes this recipe.";
146
+ readonly description = "The source changes of the `@angular/material` 13 migration, such as replacing " +
147
+ "`MatTextareaAutosize` with `CdkTextareaAutosize`. Removed APIs and constructor calls that no longer fit are " +
148
+ "marked. `UpgradeToAngular13` includes this recipe.";
153
149
 
154
150
  async recipeList(): Promise<Recipe[]> {
155
151
  return [
@@ -168,12 +164,9 @@ export class UpgradeToMaterial13CodeChanges extends Recipe {
168
164
  export class UpgradeToMaterial14CodeChanges extends Recipe {
169
165
  readonly name = "org.openrewrite.angular.material.UpgradeToMaterial14CodeChanges";
170
166
  readonly displayName = "Angular Material 14 code changes";
171
- readonly description = "The `@angular/material` source changes of the version 14 migration: replaces " +
172
- "`MatVerticalStepper` and `MatHorizontalStepper` with `MatStepper` and drops its `_document` argument, replaces " +
173
- "`MatSelectionListChange.option` and the `getHarnessLoaderForContent` of list item harnesses, renames the " +
174
- "`mat-list-item-avatar` class, and finds chip input " +
175
- "events without `chipInput`, `mixinErrorState` classes without `stateChanges`, `MatSelectionList.tabIndex`, and " +
176
- "constructor calls that no longer fit the changed constructors. `UpgradeToAngular14` includes this recipe.";
167
+ readonly description = "The source changes of the `@angular/material` 14 migration, such as replacing " +
168
+ "`MatVerticalStepper` and `MatHorizontalStepper` with `MatStepper`. Removed APIs and constructor calls that " +
169
+ "no longer fit are marked. `UpgradeToAngular14` includes this recipe.";
177
170
 
178
171
  async recipeList(): Promise<Recipe[]> {
179
172
  return [
@@ -196,13 +189,10 @@ export class UpgradeToMaterial14CodeChanges extends Recipe {
196
189
  export class UpgradeToMaterial15CodeChanges extends Recipe {
197
190
  readonly name = "org.openrewrite.angular.material.UpgradeToMaterial15CodeChanges";
198
191
  readonly displayName = "Angular Material 15 code changes";
199
- readonly description = "The `@angular/material` source changes of the version 15 migration. Imports stay on the " +
200
- "MDC-based components rather than the deprecated `legacy-*` entry points that Material 17 removed. Templates " +
201
- "and styles move to those components as the `mdc-migration` schematic does: chips, slider, form field " +
202
- "appearances, typography classes, renamed class selectors and the themes the components rely on. It finds " +
203
- "the rest: list directives, the tab nav bar panel, form field labels, removed exports and members, custom " +
204
- "snack bar content, themes built from palette maps without `define-palette`, and constructor calls that no " +
205
- "longer fit. `UpgradeToAngular15` includes this recipe.";
192
+ readonly description = "The source changes of the `@angular/material` 15 migration. Imports, templates and " +
193
+ "styles move to the MDC-based components, as the `mdc-migration` schematic does, rather than to the " +
194
+ "`legacy-*` entry points that Material 17 removed. API changes it can't migrate are marked. " +
195
+ "`UpgradeToAngular15` includes this recipe.";
206
196
 
207
197
  async recipeList(): Promise<Recipe[]> {
208
198
  return [
@@ -222,11 +212,9 @@ export class UpgradeToMaterial15CodeChanges extends Recipe {
222
212
  export class UpgradeToMaterial17CodeChanges extends Recipe {
223
213
  readonly name = "org.openrewrite.angular.material.UpgradeToMaterial17CodeChanges";
224
214
  readonly displayName = "Angular Material 17 code changes";
225
- readonly description = "The `@angular/material` source changes of the version 17 migration. Projects that still " +
226
- "use the `legacy-*` components that Material 17 removed move to the MDC-based components, as the Material 15 " +
227
- "`mdc-migration` schematic does: imports, templates, styles and prebuilt themes, with the remaining API changes " +
228
- "marked. Then adds the theme base mixins that the color, typography and density mixins stopped including, and " +
229
- "finds the legacy component uses left. `UpgradeToAngular17` includes this recipe.";
215
+ readonly description = "The source changes of the `@angular/material` 17 migration. Projects still on the " +
216
+ "`legacy-*` components move to the MDC-based ones, and themes get the `base` mixins that the color, " +
217
+ "typography and density mixins stopped including. `UpgradeToAngular17` includes this recipe.";
230
218
 
231
219
  async recipeList(): Promise<Recipe[]> {
232
220
  return [
@@ -8,7 +8,7 @@ import {emptyMarkers, findMarker, Marker, randomId, removeMarkerByKind, replaceM
8
8
  import {JS} from "@openrewrite/rewrite/javascript";
9
9
  import {emptySpace, J, singleSpace, Type} from "@openrewrite/rewrite/java";
10
10
 
11
- export function buildPropertyAssignment(key: string, value: string): any {
11
+ export function buildPropertyAssignment(key: string, value: string, quote: string = "'"): any {
12
12
  return {
13
13
  kind: JS.Kind.PropertyAssignment,
14
14
  id: randomId(),
@@ -36,7 +36,7 @@ export function buildPropertyAssignment(key: string, value: string): any {
36
36
  prefix: singleSpace,
37
37
  markers: emptyMarkers,
38
38
  value: value,
39
- valueSource: `'${value}'`,
39
+ valueSource: `${quote}${value}${quote}`,
40
40
  unicodeEscapes: undefined,
41
41
  type: Type.Primitive.String,
42
42
  },
@@ -4,7 +4,7 @@
4
4
  * Moderne Proprietary. Only for use by Moderne customers under the terms of a commercial contract.
5
5
  */
6
6
 
7
- import {Json, valueAt} from "@openrewrite/rewrite/json";
7
+ import {findMember, getMemberKeyName, isMember, isObject, Json, jsonLiteral, toPlain, updateMember, valueAt} from "@openrewrite/rewrite/json";
8
8
 
9
9
  export function isRootTsconfig(sourcePath: string): boolean {
10
10
  return (sourcePath.split('/').pop() ?? '') === 'tsconfig.json';
@@ -17,3 +17,52 @@ export function isRootTsconfig(sourcePath: string): boolean {
17
17
  export function declaresAngularCompilerOptions(doc: Json.Document): boolean {
18
18
  return valueAt(doc, ['angularCompilerOptions']) !== undefined;
19
19
  }
20
+
21
+ export function plainAt(obj: Json.Object, key: string): unknown {
22
+ const value = valueAt(obj, [key]);
23
+ return value && toPlain(value);
24
+ }
25
+
26
+ /** Applies `fn` to the object held by `key`, if any. */
27
+ export function mapObjectMember(obj: Json.Object, key: string, fn: (child: Json.Object) => Json.Object): Json.Object {
28
+ return updateMember(obj, key, value => isObject(value) ? fn(value) : value);
29
+ }
30
+
31
+ /** Applies `fn` to every member of `obj` that holds an object. */
32
+ export function mapObjectMembers(obj: Json.Object, fn: (child: Json.Object) => Json.Object): Json.Object {
33
+ const members = obj.members.map(rp => {
34
+ if (!isMember(rp.element)) return rp;
35
+ const m = rp.element as Json.Member;
36
+ if (!isObject(m.value)) return rp;
37
+ const updated = fn(m.value as Json.Object);
38
+ return updated === m.value ? rp : {...rp, element: {...m, value: updated} as Json.Member};
39
+ });
40
+ return members.every((rp, i) => rp === obj.members[i]) ? obj : {...obj, members};
41
+ }
42
+
43
+ /** Leaves `obj` alone when `to` is taken, because which key wins differs between Angular's schematics. */
44
+ export function renameMember(obj: Json.Object, from: string, to: string): Json.Object {
45
+ if (findMember(obj, to)) return obj;
46
+
47
+ const members = obj.members.map(rp => {
48
+ if (!isMember(rp.element)) return rp;
49
+ const m = rp.element as Json.Member;
50
+ if (getMemberKeyName(m) !== from) return rp;
51
+ return {...rp, element: {...m, key: {...m.key, element: jsonLiteral(to, m.key.element.prefix)}} as Json.Member};
52
+ });
53
+ return members.every((rp, i) => rp === obj.members[i]) ? obj : {...obj, members};
54
+ }
55
+
56
+ /** Applies `fn` to a build target's `options` and to each of its `configurations`. */
57
+ export function mapTargetOptions(target: Json.Object, fn: (options: Json.Object) => Json.Object): Json.Object {
58
+ const updated = mapObjectMember(target, 'options', fn);
59
+ return mapObjectMember(updated, 'configurations', configurations => mapObjectMembers(configurations, fn));
60
+ }
61
+
62
+ /** Applies `fn` to every build target of every project in an `angular.json` root object. */
63
+ export function mapProjectTargets(root: Json.Object, fn: (target: Json.Object, project: Json.Object) => Json.Object): Json.Object {
64
+ return mapObjectMember(root, 'projects', projects =>
65
+ mapObjectMembers(projects, project =>
66
+ mapObjectMember(project, 'architect', architect =>
67
+ mapObjectMembers(architect, target => fn(target, project)))));
68
+ }
@@ -0,0 +1,46 @@
1
+ /*
2
+ * Copyright 2026 the original author or authors.
3
+ *
4
+ * Moderne Proprietary. Only for use by Moderne customers under the terms of a commercial contract.
5
+ */
6
+
7
+ import {ExecutionContext, Recipe, TreeVisitor} from "@openrewrite/rewrite";
8
+ import {JavaScriptVisitor, JS} from "@openrewrite/rewrite/javascript";
9
+ import {isIdentifier, J} from "@openrewrite/rewrite/java";
10
+
11
+ export class MoveCommonEngineToSsrNode extends Recipe {
12
+ readonly name = "org.openrewrite.angular.migration.move-common-engine-to-ssr-node";
13
+ readonly displayName: string = "Move `CommonEngine` imports to `@angular/ssr/node`";
14
+ readonly description: string = "Rewrites `@angular/ssr` imports of `CommonEngine` and its option types to the " +
15
+ "`@angular/ssr/node` entry point, which Angular 19 introduced. Matches the `update-ssr-imports` schematic.";
16
+
17
+ async editor(): Promise<TreeVisitor<any, ExecutionContext>> {
18
+ return new class extends JavaScriptVisitor<ExecutionContext> {
19
+ protected async visitImportDeclaration(jsImport: JS.Import, p: ExecutionContext): Promise<J | undefined> {
20
+ const imp = await super.visitImportDeclaration(jsImport, p) as JS.Import;
21
+ if (!imp?.moduleSpecifier) return imp;
22
+
23
+ const moduleSpec = imp.moduleSpecifier.element;
24
+ if (moduleSpec.kind !== J.Kind.Literal) return imp;
25
+
26
+ const literal = moduleSpec as J.Literal;
27
+ if (literal.value !== '@angular/ssr') return imp;
28
+
29
+ const namedBindings = imp.importClause?.namedBindings;
30
+ if (namedBindings?.kind !== JS.Kind.NamedImports) return imp;
31
+
32
+ const usesCommonEngine = (namedBindings as JS.NamedImports).elements.elements.some(specifier => {
33
+ const spec = specifier.element as JS.ImportSpecifier;
34
+ return isIdentifier(spec.specifier)
35
+ && (spec.specifier as J.Identifier).simpleName.startsWith('CommonEngine');
36
+ });
37
+ if (!usesCommonEngine) return imp;
38
+
39
+ const quote = literal.valueSource?.charAt(0) ?? "'";
40
+ const specifier: J.Literal = {...literal, value: '@angular/ssr/node', valueSource: `${quote}@angular/ssr/node${quote}`};
41
+ const updated: JS.Import = {...imp, moduleSpecifier: {...imp.moduleSpecifier, element: specifier}};
42
+ return updated;
43
+ }
44
+ };
45
+ }
46
+ }
@@ -0,0 +1,89 @@
1
+ /*
2
+ * Copyright 2026 the original author or authors.
3
+ *
4
+ * Moderne Proprietary. Only for use by Moderne customers under the terms of a commercial contract.
5
+ */
6
+
7
+ import {ExecutionContext, Recipe, TreeVisitor} from "@openrewrite/rewrite";
8
+ import {JavaScriptVisitor, JS, maybeRemoveImport} from "@openrewrite/rewrite/javascript";
9
+ import {isIdentifier, J} from "@openrewrite/rewrite/java";
10
+
11
+ const ROUTER_MODULE = '@angular/router';
12
+
13
+ const DEPRECATED_INTERFACES = new Set([
14
+ 'CanLoad', 'CanMatch', 'CanActivate', 'CanDeactivate', 'CanActivateChild', 'Resolve',
15
+ ]);
16
+
17
+ export class RemoveGuardAndResolveInterfaces extends Recipe {
18
+ readonly name = "org.openrewrite.angular.migration.remove-guard-and-resolve-interfaces";
19
+ readonly displayName: string = "Remove guard and resolver interfaces";
20
+ readonly description: string = "Removes `CanLoad`, `CanMatch`, `CanActivate`, `CanDeactivate`, `CanActivateChild`, " +
21
+ "and `Resolve` from `implements` clauses and drops their imports. Angular 15.2 deprecated these interfaces " +
22
+ "because a route can inject the class and call any method it likes. Uses in type position are left alone. " +
23
+ "Matches the `guard-and-resolve-interfaces` schematic.";
24
+
25
+ async editor(): Promise<TreeVisitor<any, ExecutionContext>> {
26
+ return new class extends JavaScriptVisitor<ExecutionContext> {
27
+ private routerInterfaces = new Set<string>();
28
+
29
+ protected async visitImportDeclaration(jsImport: JS.Import, p: ExecutionContext): Promise<J | undefined> {
30
+ const imp = await super.visitImportDeclaration(jsImport, p) as JS.Import;
31
+ if (!imp?.moduleSpecifier) return imp;
32
+
33
+ const moduleSpec = imp.moduleSpecifier.element;
34
+ if (moduleSpec.kind !== J.Kind.Literal) return imp;
35
+ if ((moduleSpec as J.Literal).value !== ROUTER_MODULE) return imp;
36
+
37
+ const namedBindings = imp.importClause?.namedBindings;
38
+ if (namedBindings?.kind === JS.Kind.NamedImports) {
39
+ for (const specifier of (namedBindings as JS.NamedImports).elements.elements) {
40
+ const spec = specifier.element as JS.ImportSpecifier;
41
+ if (isIdentifier(spec.specifier)) {
42
+ const name = (spec.specifier as J.Identifier).simpleName;
43
+ if (DEPRECATED_INTERFACES.has(name)) this.routerInterfaces.add(name);
44
+ }
45
+ }
46
+ }
47
+ return imp;
48
+ }
49
+
50
+ protected async visitClassDeclaration(classDecl: J.ClassDeclaration, p: ExecutionContext): Promise<J | undefined> {
51
+ const c = await super.visitClassDeclaration(classDecl, p) as J.ClassDeclaration;
52
+ if (!c?.implements) return c;
53
+
54
+ const removed: string[] = [];
55
+ const kept = c.implements.elements.filter(rp => {
56
+ const name = implementedName(rp.element);
57
+ if (!name || !this.routerInterfaces.has(name)) return true;
58
+ removed.push(name);
59
+ return false;
60
+ });
61
+ if (removed.length === 0) return c;
62
+
63
+ for (const name of removed) maybeRemoveImport(this, ROUTER_MODULE, name);
64
+
65
+ if (kept.length === 0) {
66
+ const withoutClause: J.ClassDeclaration = {...c, implements: undefined};
67
+ return withoutClause;
68
+ }
69
+
70
+ // The clause's leading space lives on its first entry, so it moves to the new first.
71
+ const elements = [...kept];
72
+ elements[0] = {...elements[0], element: {...elements[0].element, prefix: c.implements.elements[0].element.prefix}};
73
+ const updated: J.ClassDeclaration = {...c, implements: {...c.implements, elements}};
74
+ return updated;
75
+ }
76
+ };
77
+ }
78
+ }
79
+
80
+ /** The simple name of an `implements` entry, ignoring any type arguments. */
81
+ function implementedName(type: J): string | undefined {
82
+ if (isIdentifier(type)) return (type as J.Identifier).simpleName;
83
+
84
+ if (type.kind === JS.Kind.ExpressionWithTypeArguments) {
85
+ const clazz = (type as JS.ExpressionWithTypeArguments).clazz;
86
+ if (clazz && isIdentifier(clazz)) return (clazz as J.Identifier).simpleName;
87
+ }
88
+ return undefined;
89
+ }
@@ -0,0 +1,40 @@
1
+ /*
2
+ * Copyright 2026 the original author or authors.
3
+ *
4
+ * Moderne Proprietary. Only for use by Moderne customers under the terms of a commercial contract.
5
+ */
6
+
7
+ import {ExecutionContext, Recipe, TreeVisitor} from "@openrewrite/rewrite";
8
+ import {isObject, Json, JsonVisitor, removeMember} from "@openrewrite/rewrite/json";
9
+ import {mapProjectTargets, mapTargetOptions, plainAt} from "./json-support";
10
+
11
+ const BUILDERS_WITH_OPTION = new Set([
12
+ '@angular-devkit/build-angular:browser',
13
+ '@angular-devkit/build-angular:server',
14
+ ]);
15
+
16
+ export class RemoveShowCircularDependencies extends Recipe {
17
+ readonly name = "org.openrewrite.angular.migration.remove-show-circular-dependencies";
18
+ readonly displayName: string = "Remove `showCircularDependencies` from `angular.json`";
19
+ readonly description: string = "Removes the `showCircularDependencies` option from the `browser` and `server` builders. " +
20
+ "Angular 14 removed the option. Matches the `remove-show-circular-dependencies-option` schematic.";
21
+
22
+ async editor(): Promise<TreeVisitor<any, ExecutionContext>> {
23
+ return new class extends JsonVisitor<ExecutionContext> {
24
+ protected async visitDocument(doc: Json.Document, p: ExecutionContext): Promise<Json | undefined> {
25
+ if (!doc.sourcePath.endsWith('angular.json')) return doc;
26
+
27
+ const root = doc.value;
28
+ if (!isObject(root)) return doc;
29
+
30
+ const updated = mapProjectTargets(root, target => {
31
+ const builder = plainAt(target, 'builder');
32
+ if (typeof builder !== 'string' || !BUILDERS_WITH_OPTION.has(builder)) return target;
33
+ return mapTargetOptions(target, options => removeMember(options, 'showCircularDependencies'));
34
+ });
35
+
36
+ return updated === root ? doc : {...doc, value: updated} as Json.Document;
37
+ }
38
+ }();
39
+ }
40
+ }