@openrewrite/recipes-angular 1.28.0 → 1.29.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.
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +42 -6
- package/dist/index.js.map +1 -1
- package/dist/libraries/cdk/find-cdk-signature-changes.d.ts +0 -2
- package/dist/libraries/cdk/find-cdk-signature-changes.d.ts.map +1 -1
- package/dist/libraries/cdk/find-cdk-signature-changes.js +2 -8
- package/dist/libraries/cdk/find-cdk-signature-changes.js.map +1 -1
- package/dist/libraries/cdk/migrate-cdk-sass-imports.d.ts.map +1 -1
- package/dist/libraries/cdk/migrate-cdk-sass-imports.js +4 -7
- package/dist/libraries/cdk/migrate-cdk-sass-imports.js.map +1 -1
- package/dist/libraries/cdk/migrate-cdk-stepper.js +1 -1
- package/dist/libraries/cdk/migrate-cdk-stepper.js.map +1 -1
- package/dist/libraries/cdk/migrate-deprecated-overlay-sass.d.ts.map +1 -1
- package/dist/libraries/cdk/migrate-deprecated-overlay-sass.js +2 -4
- package/dist/libraries/cdk/migrate-deprecated-overlay-sass.js.map +1 -1
- package/dist/libraries/cdk/migrate-focus-trap-factory-create.d.ts.map +1 -1
- package/dist/libraries/cdk/migrate-focus-trap-factory-create.js +2 -1
- package/dist/libraries/cdk/migrate-focus-trap-factory-create.js.map +1 -1
- package/dist/libraries/cdk/remove-cdk-super-arguments.d.ts.map +1 -1
- package/dist/libraries/cdk/remove-cdk-super-arguments.js +1 -2
- package/dist/libraries/cdk/remove-cdk-super-arguments.js.map +1 -1
- package/dist/libraries/cdk/remove-portal-factory-resolver-arguments.d.ts.map +1 -1
- package/dist/libraries/cdk/remove-portal-factory-resolver-arguments.js +5 -7
- package/dist/libraries/cdk/remove-portal-factory-resolver-arguments.js.map +1 -1
- package/dist/libraries/cdk/rename-portal-template-selectors.d.ts.map +1 -1
- package/dist/libraries/cdk/rename-portal-template-selectors.js +3 -4
- package/dist/libraries/cdk/rename-portal-template-selectors.js.map +1 -1
- package/dist/libraries/cdk/upgrade-to-cdk.d.ts.map +1 -1
- package/dist/libraries/cdk/upgrade-to-cdk.js +7 -12
- package/dist/libraries/cdk/upgrade-to-cdk.js.map +1 -1
- package/dist/libraries/components/lst.d.ts +5 -1
- package/dist/libraries/components/lst.d.ts.map +1 -1
- package/dist/libraries/components/lst.js +28 -0
- package/dist/libraries/components/lst.js.map +1 -1
- package/dist/libraries/components/style-sources.d.ts +2 -5
- package/dist/libraries/components/style-sources.d.ts.map +1 -1
- package/dist/libraries/components/style-sources.js +31 -46
- package/dist/libraries/components/style-sources.js.map +1 -1
- package/dist/libraries/components/stylesheets.d.ts +1 -0
- package/dist/libraries/components/stylesheets.d.ts.map +1 -1
- package/dist/libraries/components/stylesheets.js +18 -16
- package/dist/libraries/components/stylesheets.js.map +1 -1
- package/dist/libraries/components/symbols.d.ts +4 -21
- package/dist/libraries/components/symbols.d.ts.map +1 -1
- package/dist/libraries/components/symbols.js +12 -124
- package/dist/libraries/components/symbols.js.map +1 -1
- package/dist/libraries/components/template-elements.d.ts +2 -0
- package/dist/libraries/components/template-elements.d.ts.map +1 -1
- package/dist/libraries/components/template-elements.js +6 -0
- package/dist/libraries/components/template-elements.js.map +1 -1
- package/dist/libraries/components/templates.d.ts +1 -0
- package/dist/libraries/components/templates.d.ts.map +1 -1
- package/dist/libraries/components/templates.js +43 -47
- package/dist/libraries/components/templates.js.map +1 -1
- package/dist/libraries/material/add-system-variables-prefix.d.ts +5 -3
- package/dist/libraries/material/add-system-variables-prefix.d.ts.map +1 -1
- package/dist/libraries/material/add-system-variables-prefix.js +35 -11
- package/dist/libraries/material/add-system-variables-prefix.js.map +1 -1
- package/dist/libraries/material/add-theme-base-mixins.d.ts.map +1 -1
- package/dist/libraries/material/add-theme-base-mixins.js +7 -7
- package/dist/libraries/material/add-theme-base-mixins.js.map +1 -1
- package/dist/libraries/material/find-chip-input-event-without-chip-input.d.ts.map +1 -1
- package/dist/libraries/material/find-chip-input-event-without-chip-input.js +1 -2
- package/dist/libraries/material/find-chip-input-event-without-chip-input.js.map +1 -1
- package/dist/libraries/material/find-legacy-material-usage.d.ts.map +1 -1
- package/dist/libraries/material/find-legacy-material-usage.js +3 -11
- package/dist/libraries/material/find-legacy-material-usage.js.map +1 -1
- package/dist/libraries/material/find-material-constructor-changes.d.ts.map +1 -1
- package/dist/libraries/material/find-material-constructor-changes.js +2 -3
- package/dist/libraries/material/find-material-constructor-changes.js.map +1 -1
- package/dist/libraries/material/find-mdc-breaking-changes.d.ts.map +1 -1
- package/dist/libraries/material/find-mdc-breaking-changes.js +4 -18
- package/dist/libraries/material/find-mdc-breaking-changes.js.map +1 -1
- package/dist/libraries/material/find-mixin-error-state-without-state-changes.js +1 -1
- package/dist/libraries/material/find-mixin-error-state-without-state-changes.js.map +1 -1
- package/dist/libraries/material/find-raw-palette-themes.d.ts.map +1 -1
- package/dist/libraries/material/find-raw-palette-themes.js +3 -5
- package/dist/libraries/material/find-raw-palette-themes.js.map +1 -1
- package/dist/libraries/material/find-removed-material-classes.d.ts.map +1 -1
- package/dist/libraries/material/find-removed-material-classes.js +4 -14
- package/dist/libraries/material/find-removed-material-classes.js.map +1 -1
- package/dist/libraries/material/find-removed-material-members.d.ts.map +1 -1
- package/dist/libraries/material/find-removed-material-members.js +2 -3
- package/dist/libraries/material/find-removed-material-members.js.map +1 -1
- package/dist/libraries/material/find-slide-toggle-drag-options.d.ts +5 -3
- package/dist/libraries/material/find-slide-toggle-drag-options.d.ts.map +1 -1
- package/dist/libraries/material/find-slide-toggle-drag-options.js +7 -13
- package/dist/libraries/material/find-slide-toggle-drag-options.js.map +1 -1
- package/dist/libraries/material/material-version.d.ts +16 -2
- package/dist/libraries/material/material-version.d.ts.map +1 -1
- package/dist/libraries/material/material-version.js +35 -5
- package/dist/libraries/material/material-version.js.map +1 -1
- package/dist/libraries/material/migrate-legacy-material.d.ts.map +1 -1
- package/dist/libraries/material/migrate-legacy-material.js +5 -11
- package/dist/libraries/material/migrate-legacy-material.js.map +1 -1
- package/dist/libraries/material/migrate-m2-theming-api.d.ts.map +1 -1
- package/dist/libraries/material/migrate-m2-theming-api.js +3 -6
- package/dist/libraries/material/migrate-m2-theming-api.js.map +1 -1
- package/dist/libraries/material/migrate-mat-core-to-elevation-classes.d.ts +5 -3
- package/dist/libraries/material/migrate-mat-core-to-elevation-classes.d.ts.map +1 -1
- package/dist/libraries/material/migrate-mat-core-to-elevation-classes.js +15 -3
- package/dist/libraries/material/migrate-mat-core-to-elevation-classes.js.map +1 -1
- package/dist/libraries/material/migrate-material-15-typography.d.ts.map +1 -1
- package/dist/libraries/material/migrate-material-15-typography.js +9 -20
- package/dist/libraries/material/migrate-material-15-typography.js.map +1 -1
- package/dist/libraries/material/migrate-material-secondary-entry-points.d.ts.map +1 -1
- package/dist/libraries/material/migrate-material-secondary-entry-points.js +41 -2
- package/dist/libraries/material/migrate-material-secondary-entry-points.js.map +1 -1
- package/dist/libraries/material/migrate-material-theming-api.d.ts +1 -0
- package/dist/libraries/material/migrate-material-theming-api.d.ts.map +1 -1
- package/dist/libraries/material/migrate-material-theming-api.js +33 -24
- package/dist/libraries/material/migrate-material-theming-api.js.map +1 -1
- package/dist/libraries/material/migrate-mdc-styles.d.ts.map +1 -1
- package/dist/libraries/material/migrate-mdc-styles.js +5 -14
- package/dist/libraries/material/migrate-mdc-styles.js.map +1 -1
- package/dist/libraries/material/migrate-mdc-templates.d.ts.map +1 -1
- package/dist/libraries/material/migrate-mdc-templates.js +54 -30
- package/dist/libraries/material/migrate-mdc-templates.js.map +1 -1
- package/dist/libraries/material/remove-mat-stepper-document-argument.d.ts.map +1 -1
- package/dist/libraries/material/remove-mat-stepper-document-argument.js +1 -2
- package/dist/libraries/material/remove-mat-stepper-document-argument.js.map +1 -1
- package/dist/libraries/material/remove-update-active-link-argument.d.ts.map +1 -1
- package/dist/libraries/material/remove-update-active-link-argument.js +1 -2
- package/dist/libraries/material/remove-update-active-link-argument.js.map +1 -1
- package/dist/libraries/material/rename-material-style-names.d.ts +14 -7
- package/dist/libraries/material/rename-material-style-names.d.ts.map +1 -1
- package/dist/libraries/material/rename-material-style-names.js +69 -35
- package/dist/libraries/material/rename-material-style-names.js.map +1 -1
- package/dist/libraries/material/rename-textarea-autosize-attributes.d.ts +5 -15
- package/dist/libraries/material/rename-textarea-autosize-attributes.d.ts.map +1 -1
- package/dist/libraries/material/rename-textarea-autosize-attributes.js +30 -15
- package/dist/libraries/material/rename-textarea-autosize-attributes.js.map +1 -1
- package/dist/libraries/material/upgrade-to-material.d.ts.map +1 -1
- package/dist/libraries/material/upgrade-to-material.js +19 -31
- package/dist/libraries/material/upgrade-to-material.js.map +1 -1
- package/dist/migration/js-support.d.ts +1 -1
- package/dist/migration/js-support.d.ts.map +1 -1
- package/dist/migration/js-support.js +2 -2
- package/dist/migration/js-support.js.map +1 -1
- package/dist/migration/json-support.d.ts +11 -0
- package/dist/migration/json-support.d.ts.map +1 -1
- package/dist/migration/json-support.js +50 -0
- package/dist/migration/json-support.js.map +1 -1
- package/dist/migration/move-common-engine-to-ssr-node.d.ts +8 -0
- package/dist/migration/move-common-engine-to-ssr-node.d.ts.map +1 -0
- package/dist/migration/move-common-engine-to-ssr-node.js +68 -0
- package/dist/migration/move-common-engine-to-ssr-node.js.map +1 -0
- package/dist/migration/remove-guard-and-resolve-interfaces.d.ts +8 -0
- package/dist/migration/remove-guard-and-resolve-interfaces.d.ts.map +1 -0
- package/dist/migration/remove-guard-and-resolve-interfaces.js +117 -0
- package/dist/migration/remove-guard-and-resolve-interfaces.js.map +1 -0
- package/dist/migration/remove-show-circular-dependencies.d.ts +8 -0
- package/dist/migration/remove-show-circular-dependencies.d.ts.map +1 -0
- package/dist/migration/remove-show-circular-dependencies.js +57 -0
- package/dist/migration/remove-show-circular-dependencies.js.map +1 -0
- package/dist/migration/rename-ssr-experimental-platform.d.ts.map +1 -1
- package/dist/migration/rename-ssr-experimental-platform.js +10 -47
- package/dist/migration/rename-ssr-experimental-platform.js.map +1 -1
- package/dist/migration/replace-browser-target.d.ts +8 -0
- package/dist/migration/replace-browser-target.d.ts.map +1 -0
- package/dist/migration/replace-browser-target.js +62 -0
- package/dist/migration/replace-browser-target.js.map +1 -0
- package/dist/migration/replace-default-collection.d.ts +8 -0
- package/dist/migration/replace-default-collection.d.ts.map +1 -0
- package/dist/migration/replace-default-collection.js +59 -0
- package/dist/migration/replace-default-collection.js.map +1 -0
- package/dist/migration/replace-get-current-navigation.d.ts +8 -0
- package/dist/migration/replace-get-current-navigation.d.ts.map +1 -0
- package/dist/migration/replace-get-current-navigation.js +69 -0
- package/dist/migration/replace-get-current-navigation.js.map +1 -0
- package/dist/migration/replace-initializer-providers.d.ts +8 -0
- package/dist/migration/replace-initializer-providers.d.ts.map +1 -0
- package/dist/migration/replace-initializer-providers.js +169 -0
- package/dist/migration/replace-initializer-providers.js.map +1 -0
- package/dist/migration/replace-preserve-query-params.d.ts +8 -0
- package/dist/migration/replace-preserve-query-params.d.ts.map +1 -0
- package/dist/migration/replace-preserve-query-params.js +115 -0
- package/dist/migration/replace-preserve-query-params.js.map +1 -0
- package/dist/migration/replace-provide-server-routing.d.ts +8 -0
- package/dist/migration/replace-provide-server-routing.d.ts.map +1 -0
- package/dist/migration/replace-provide-server-routing.js +98 -0
- package/dist/migration/replace-provide-server-routing.js.map +1 -0
- package/dist/migration/upgrade-angular-dependencies.d.ts +0 -2
- package/dist/migration/upgrade-angular-dependencies.d.ts.map +1 -1
- package/dist/migration/upgrade-angular-dependencies.js +0 -6
- package/dist/migration/upgrade-angular-dependencies.js.map +1 -1
- package/dist/migration/upgrade-to-angular-10.d.ts.map +1 -1
- package/dist/migration/upgrade-to-angular-10.js +1 -2
- package/dist/migration/upgrade-to-angular-10.js.map +1 -1
- package/dist/migration/upgrade-to-angular-11.d.ts.map +1 -1
- package/dist/migration/upgrade-to-angular-11.js +5 -3
- package/dist/migration/upgrade-to-angular-11.js.map +1 -1
- package/dist/migration/upgrade-to-angular-12.d.ts.map +1 -1
- package/dist/migration/upgrade-to-angular-12.js +1 -2
- package/dist/migration/upgrade-to-angular-12.js.map +1 -1
- package/dist/migration/upgrade-to-angular-13.d.ts.map +1 -1
- package/dist/migration/upgrade-to-angular-13.js +1 -2
- package/dist/migration/upgrade-to-angular-13.js.map +1 -1
- package/dist/migration/upgrade-to-angular-14.d.ts.map +1 -1
- package/dist/migration/upgrade-to-angular-14.js +8 -2
- package/dist/migration/upgrade-to-angular-14.js.map +1 -1
- package/dist/migration/upgrade-to-angular-15.d.ts.map +1 -1
- package/dist/migration/upgrade-to-angular-15.js +1 -2
- package/dist/migration/upgrade-to-angular-15.js.map +1 -1
- package/dist/migration/upgrade-to-angular-16.d.ts.map +1 -1
- package/dist/migration/upgrade-to-angular-16.js +4 -2
- package/dist/migration/upgrade-to-angular-16.js.map +1 -1
- package/dist/migration/upgrade-to-angular-17.d.ts.map +1 -1
- package/dist/migration/upgrade-to-angular-17.js +1 -2
- package/dist/migration/upgrade-to-angular-17.js.map +1 -1
- package/dist/migration/upgrade-to-angular-18.d.ts.map +1 -1
- package/dist/migration/upgrade-to-angular-18.js +1 -2
- package/dist/migration/upgrade-to-angular-18.js.map +1 -1
- package/dist/migration/upgrade-to-angular-19.d.ts.map +1 -1
- package/dist/migration/upgrade-to-angular-19.js +12 -4
- package/dist/migration/upgrade-to-angular-19.js.map +1 -1
- package/dist/migration/upgrade-to-angular-20.d.ts.map +1 -1
- package/dist/migration/upgrade-to-angular-20.js +12 -3
- package/dist/migration/upgrade-to-angular-20.js.map +1 -1
- package/dist/migration/upgrade-to-angular-21.d.ts.map +1 -1
- package/dist/migration/upgrade-to-angular-21.js +4 -2
- package/dist/migration/upgrade-to-angular-21.js.map +1 -1
- package/dist/migration/upgrade-to-angular-22.d.ts.map +1 -1
- package/dist/migration/upgrade-to-angular-22.js +1 -2
- package/dist/migration/upgrade-to-angular-22.js.map +1 -1
- package/dist/migration/upgrade-to-angular-8.d.ts.map +1 -1
- package/dist/migration/upgrade-to-angular-8.js +1 -3
- package/dist/migration/upgrade-to-angular-8.js.map +1 -1
- package/dist/migration/upgrade-to-angular-9.d.ts.map +1 -1
- package/dist/migration/upgrade-to-angular-9.js +1 -2
- package/dist/migration/upgrade-to-angular-9.js.map +1 -1
- package/package.json +6 -5
- package/src/index.ts +27 -0
- package/src/libraries/cdk/find-cdk-signature-changes.ts +1 -6
- package/src/libraries/cdk/migrate-cdk-sass-imports.ts +4 -7
- package/src/libraries/cdk/migrate-cdk-stepper.ts +2 -2
- package/src/libraries/cdk/migrate-deprecated-overlay-sass.ts +2 -4
- package/src/libraries/cdk/migrate-focus-trap-factory-create.ts +2 -1
- package/src/libraries/cdk/remove-cdk-super-arguments.ts +1 -2
- package/src/libraries/cdk/remove-portal-factory-resolver-arguments.ts +4 -6
- package/src/libraries/cdk/rename-portal-template-selectors.ts +3 -4
- package/src/libraries/cdk/upgrade-to-cdk.ts +7 -12
- package/src/libraries/components/lst.ts +17 -1
- package/src/libraries/components/style-sources.ts +20 -31
- package/src/libraries/components/stylesheets.ts +13 -10
- package/src/libraries/components/symbols.ts +12 -96
- package/src/libraries/components/template-elements.ts +5 -0
- package/src/libraries/components/templates.ts +32 -33
- package/src/libraries/material/add-system-variables-prefix.ts +27 -11
- package/src/libraries/material/add-theme-base-mixins.ts +7 -7
- package/src/libraries/material/find-chip-input-event-without-chip-input.ts +1 -2
- package/src/libraries/material/find-legacy-material-usage.ts +5 -11
- package/src/libraries/material/find-material-constructor-changes.ts +2 -3
- package/src/libraries/material/find-mdc-breaking-changes.ts +6 -17
- package/src/libraries/material/find-mixin-error-state-without-state-changes.ts +2 -2
- package/src/libraries/material/find-raw-palette-themes.ts +3 -5
- package/src/libraries/material/find-removed-material-classes.ts +6 -14
- package/src/libraries/material/find-removed-material-members.ts +2 -3
- package/src/libraries/material/find-slide-toggle-drag-options.ts +10 -13
- package/src/libraries/material/material-version.ts +37 -5
- package/src/libraries/material/migrate-legacy-material.ts +5 -11
- package/src/libraries/material/migrate-m2-theming-api.ts +3 -6
- package/src/libraries/material/migrate-mat-core-to-elevation-classes.ts +8 -5
- package/src/libraries/material/migrate-material-15-typography.ts +12 -20
- package/src/libraries/material/migrate-material-secondary-entry-points.ts +35 -3
- package/src/libraries/material/migrate-material-theming-api.ts +30 -22
- package/src/libraries/material/migrate-mdc-styles.ts +6 -13
- package/src/libraries/material/migrate-mdc-templates.ts +51 -28
- package/src/libraries/material/remove-mat-stepper-document-argument.ts +1 -2
- package/src/libraries/material/remove-update-active-link-argument.ts +1 -2
- package/src/libraries/material/rename-material-style-names.ts +79 -31
- package/src/libraries/material/rename-textarea-autosize-attributes.ts +24 -16
- package/src/libraries/material/upgrade-to-material.ts +19 -31
- package/src/migration/js-support.ts +2 -2
- package/src/migration/json-support.ts +50 -1
- package/src/migration/move-common-engine-to-ssr-node.ts +46 -0
- package/src/migration/remove-guard-and-resolve-interfaces.ts +89 -0
- package/src/migration/remove-show-circular-dependencies.ts +40 -0
- package/src/migration/rename-ssr-experimental-platform.ts +8 -49
- package/src/migration/replace-browser-target.ts +45 -0
- package/src/migration/replace-default-collection.ts +45 -0
- package/src/migration/replace-get-current-navigation.ts +50 -0
- package/src/migration/replace-initializer-providers.ts +153 -0
- package/src/migration/replace-preserve-query-params.ts +88 -0
- package/src/migration/replace-provide-server-routing.ts +79 -0
- package/src/migration/upgrade-angular-dependencies.ts +0 -6
- package/src/migration/upgrade-to-angular-10.ts +2 -3
- package/src/migration/upgrade-to-angular-11.ts +6 -4
- package/src/migration/upgrade-to-angular-12.ts +2 -3
- package/src/migration/upgrade-to-angular-13.ts +2 -3
- package/src/migration/upgrade-to-angular-14.ts +9 -3
- package/src/migration/upgrade-to-angular-15.ts +2 -3
- package/src/migration/upgrade-to-angular-16.ts +5 -3
- package/src/migration/upgrade-to-angular-17.ts +2 -3
- package/src/migration/upgrade-to-angular-18.ts +2 -3
- package/src/migration/upgrade-to-angular-19.ts +13 -5
- package/src/migration/upgrade-to-angular-20.ts +13 -4
- package/src/migration/upgrade-to-angular-21.ts +5 -3
- package/src/migration/upgrade-to-angular-22.ts +2 -3
- package/src/migration/upgrade-to-angular-8.ts +1 -3
- 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 {
|
|
7
|
+
import {ExecutionContext, TreeVisitor} from "@openrewrite/rewrite";
|
|
8
8
|
import {Json, JsonVisitor} from "@openrewrite/rewrite/json";
|
|
9
|
-
import {renameNames,
|
|
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
|
|
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
|
|
31
|
+
export class RenameMaterial18Tokens extends MaterialVersionRecipe {
|
|
24
32
|
readonly name = "org.openrewrite.angular.material.RenameMaterial18Tokens";
|
|
25
|
-
readonly displayName = "
|
|
26
|
-
readonly description = "Material 18
|
|
27
|
-
"`--mat-checkbox-label-text
|
|
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(
|
|
31
|
-
return renameNames(text, Object.fromEntries(
|
|
32
|
-
.map(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
|
|
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
|
|
67
|
-
"component prefixes
|
|
68
|
-
"
|
|
69
|
-
|
|
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(
|
|
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
|
|
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
|
|
88
|
-
"
|
|
89
|
-
"
|
|
90
|
-
|
|
91
|
-
|
|
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
|
|
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
|
-
|
|
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 {
|
|
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
|
|
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
|
|
13
|
-
"to those of `CdkTextareaAutosize`,
|
|
14
|
-
"
|
|
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
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
|
94
|
-
"`MatButtonToggleGroupMultiple` to `MatButtonToggleGroup
|
|
95
|
-
"
|
|
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
|
|
115
|
-
"`MatDatepickerInput.getPopupConnectionElementRef` to `getConnectedOverlayOrigin
|
|
116
|
-
"
|
|
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
|
|
150
|
-
"`MatTextareaAutosize` with `CdkTextareaAutosize
|
|
151
|
-
"
|
|
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
|
|
172
|
-
"`MatVerticalStepper` and `MatHorizontalStepper` with `MatStepper
|
|
173
|
-
"
|
|
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
|
|
200
|
-
"MDC-based components
|
|
201
|
-
"
|
|
202
|
-
"
|
|
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
|
|
226
|
-
"
|
|
227
|
-
"
|
|
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:
|
|
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
|
+
}
|