@openrewrite/recipes-angular 1.27.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 +37 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +227 -4
- 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 +11 -0
- package/dist/libraries/components/lst.d.ts.map +1 -1
- package/dist/libraries/components/lst.js +40 -0
- package/dist/libraries/components/lst.js.map +1 -1
- package/dist/libraries/components/style-sources.d.ts +12 -0
- package/dist/libraries/components/style-sources.d.ts.map +1 -0
- package/dist/libraries/components/style-sources.js +93 -0
- package/dist/libraries/components/style-sources.js.map +1 -0
- package/dist/libraries/components/stylesheets.d.ts +13 -0
- package/dist/libraries/components/stylesheets.d.ts.map +1 -1
- package/dist/libraries/components/stylesheets.js +55 -17
- package/dist/libraries/components/stylesheets.js.map +1 -1
- package/dist/libraries/components/symbols.d.ts +4 -1
- package/dist/libraries/components/symbols.d.ts.map +1 -1
- package/dist/libraries/components/symbols.js +6 -3
- package/dist/libraries/components/symbols.js.map +1 -1
- package/dist/libraries/components/template-elements.d.ts +40 -0
- package/dist/libraries/components/template-elements.d.ts.map +1 -0
- package/dist/libraries/components/template-elements.js +96 -0
- package/dist/libraries/components/template-elements.js.map +1 -0
- package/dist/libraries/components/templates.d.ts +7 -0
- package/dist/libraries/components/templates.d.ts.map +1 -1
- package/dist/libraries/components/templates.js +59 -48
- package/dist/libraries/components/templates.js.map +1 -1
- package/dist/libraries/material/add-system-variables-prefix.d.ts +11 -0
- package/dist/libraries/material/add-system-variables-prefix.d.ts.map +1 -0
- package/dist/libraries/material/add-system-variables-prefix.js +98 -0
- package/dist/libraries/material/add-system-variables-prefix.js.map +1 -0
- package/dist/libraries/material/add-theme-base-mixins.d.ts +19 -0
- package/dist/libraries/material/add-theme-base-mixins.d.ts.map +1 -0
- package/dist/libraries/material/add-theme-base-mixins.js +176 -0
- package/dist/libraries/material/add-theme-base-mixins.js.map +1 -0
- package/dist/libraries/material/find-chip-input-event-without-chip-input.d.ts +8 -0
- package/dist/libraries/material/find-chip-input-event-without-chip-input.d.ts.map +1 -0
- package/dist/libraries/material/find-chip-input-event-without-chip-input.js +94 -0
- package/dist/libraries/material/find-chip-input-event-without-chip-input.js.map +1 -0
- package/dist/libraries/material/find-legacy-material-usage.d.ts +8 -0
- package/dist/libraries/material/find-legacy-material-usage.d.ts.map +1 -0
- package/dist/libraries/material/find-legacy-material-usage.js +95 -0
- package/dist/libraries/material/find-legacy-material-usage.js.map +1 -0
- package/dist/libraries/material/find-material-constructor-changes.d.ts +74 -0
- package/dist/libraries/material/find-material-constructor-changes.d.ts.map +1 -0
- package/dist/libraries/material/find-material-constructor-changes.js +266 -0
- package/dist/libraries/material/find-material-constructor-changes.js.map +1 -0
- package/dist/libraries/material/find-mdc-breaking-changes.d.ts +45 -0
- package/dist/libraries/material/find-mdc-breaking-changes.d.ts.map +1 -0
- package/dist/libraries/material/find-mdc-breaking-changes.js +312 -0
- package/dist/libraries/material/find-mdc-breaking-changes.js.map +1 -0
- package/dist/libraries/material/find-mixin-error-state-without-state-changes.d.ts +8 -0
- package/dist/libraries/material/find-mixin-error-state-without-state-changes.d.ts.map +1 -0
- package/dist/libraries/material/find-mixin-error-state-without-state-changes.js +125 -0
- package/dist/libraries/material/find-mixin-error-state-without-state-changes.js.map +1 -0
- package/dist/libraries/material/find-raw-palette-themes.d.ts +28 -0
- package/dist/libraries/material/find-raw-palette-themes.d.ts.map +1 -0
- package/dist/libraries/material/find-raw-palette-themes.js +122 -0
- package/dist/libraries/material/find-raw-palette-themes.js.map +1 -0
- package/dist/libraries/material/find-removed-material-apis.d.ts +20 -0
- package/dist/libraries/material/find-removed-material-apis.d.ts.map +1 -0
- package/dist/libraries/material/find-removed-material-apis.js +60 -0
- package/dist/libraries/material/find-removed-material-apis.js.map +1 -0
- package/dist/libraries/material/find-removed-material-classes.d.ts +13 -0
- package/dist/libraries/material/find-removed-material-classes.d.ts.map +1 -0
- package/dist/libraries/material/find-removed-material-classes.js +144 -0
- package/dist/libraries/material/find-removed-material-classes.js.map +1 -0
- package/dist/libraries/material/find-removed-material-members.d.ts +67 -0
- package/dist/libraries/material/find-removed-material-members.d.ts.map +1 -0
- package/dist/libraries/material/find-removed-material-members.js +167 -0
- package/dist/libraries/material/find-removed-material-members.js.map +1 -0
- package/dist/libraries/material/find-slide-toggle-drag-options.d.ts +10 -0
- package/dist/libraries/material/find-slide-toggle-drag-options.d.ts.map +1 -0
- package/dist/libraries/material/find-slide-toggle-drag-options.js +96 -0
- package/dist/libraries/material/find-slide-toggle-drag-options.js.map +1 -0
- package/dist/libraries/material/material-15-classes.d.ts +6 -0
- package/dist/libraries/material/material-15-classes.d.ts.map +1 -0
- package/dist/libraries/material/material-15-classes.js +435 -0
- package/dist/libraries/material/material-15-classes.js.map +1 -0
- package/dist/libraries/material/material-entry-points.d.ts +3 -0
- package/dist/libraries/material/material-entry-points.d.ts.map +1 -0
- package/dist/libraries/material/material-entry-points.js +201 -0
- package/dist/libraries/material/material-entry-points.js.map +1 -0
- package/dist/libraries/material/material-legacy-symbols.d.ts +2 -0
- package/dist/libraries/material/material-legacy-symbols.d.ts.map +1 -0
- package/dist/libraries/material/material-legacy-symbols.js +559 -0
- package/dist/libraries/material/material-legacy-symbols.js.map +1 -0
- package/dist/libraries/material/material-theming-api.d.ts +23 -0
- package/dist/libraries/material/material-theming-api.d.ts.map +1 -0
- package/dist/libraries/material/material-theming-api.js +446 -0
- package/dist/libraries/material/material-theming-api.js.map +1 -0
- package/dist/libraries/material/material-version.d.ts +38 -0
- package/dist/libraries/material/material-version.d.ts.map +1 -0
- package/dist/libraries/material/material-version.js +190 -0
- package/dist/libraries/material/material-version.js.map +1 -0
- package/dist/libraries/material/migrate-legacy-material.d.ts +60 -0
- package/dist/libraries/material/migrate-legacy-material.d.ts.map +1 -0
- package/dist/libraries/material/migrate-legacy-material.js +224 -0
- package/dist/libraries/material/migrate-legacy-material.js.map +1 -0
- package/dist/libraries/material/migrate-list-item-harness-content-loader.d.ts +8 -0
- package/dist/libraries/material/migrate-list-item-harness-content-loader.d.ts.map +1 -0
- package/dist/libraries/material/migrate-list-item-harness-content-loader.js +62 -0
- package/dist/libraries/material/migrate-list-item-harness-content-loader.js.map +1 -0
- package/dist/libraries/material/migrate-m2-theming-api.d.ts +12 -0
- package/dist/libraries/material/migrate-m2-theming-api.d.ts.map +1 -0
- package/dist/libraries/material/migrate-m2-theming-api.js +117 -0
- package/dist/libraries/material/migrate-m2-theming-api.js.map +1 -0
- package/dist/libraries/material/migrate-mat-core-to-elevation-classes.d.ts +11 -0
- package/dist/libraries/material/migrate-mat-core-to-elevation-classes.d.ts.map +1 -0
- package/dist/libraries/material/migrate-mat-core-to-elevation-classes.js +48 -0
- package/dist/libraries/material/migrate-mat-core-to-elevation-classes.js.map +1 -0
- package/dist/libraries/material/migrate-material-15-typography.d.ts +21 -0
- package/dist/libraries/material/migrate-material-15-typography.d.ts.map +1 -0
- package/dist/libraries/material/migrate-material-15-typography.js +174 -0
- package/dist/libraries/material/migrate-material-15-typography.js.map +1 -0
- package/dist/libraries/material/migrate-material-secondary-entry-points.d.ts +8 -0
- package/dist/libraries/material/migrate-material-secondary-entry-points.d.ts.map +1 -0
- package/dist/libraries/material/migrate-material-secondary-entry-points.js +196 -0
- package/dist/libraries/material/migrate-material-secondary-entry-points.js.map +1 -0
- package/dist/libraries/material/migrate-material-theming-api.d.ts +18 -0
- package/dist/libraries/material/migrate-material-theming-api.d.ts.map +1 -0
- package/dist/libraries/material/migrate-material-theming-api.js +199 -0
- package/dist/libraries/material/migrate-material-theming-api.js.map +1 -0
- package/dist/libraries/material/migrate-mdc-styles.d.ts +23 -0
- package/dist/libraries/material/migrate-mdc-styles.d.ts.map +1 -0
- package/dist/libraries/material/migrate-mdc-styles.js +136 -0
- package/dist/libraries/material/migrate-mdc-styles.js.map +1 -0
- package/dist/libraries/material/migrate-mdc-templates.d.ts +18 -0
- package/dist/libraries/material/migrate-mdc-templates.d.ts.map +1 -0
- package/dist/libraries/material/migrate-mdc-templates.js +330 -0
- package/dist/libraries/material/migrate-mdc-templates.js.map +1 -0
- package/dist/libraries/material/migrate-selection-list-change-option.d.ts +8 -0
- package/dist/libraries/material/migrate-selection-list-change-option.d.ts.map +1 -0
- package/dist/libraries/material/migrate-selection-list-change-option.js +49 -0
- package/dist/libraries/material/migrate-selection-list-change-option.js.map +1 -0
- package/dist/libraries/material/remove-mat-stepper-document-argument.d.ts +8 -0
- package/dist/libraries/material/remove-mat-stepper-document-argument.d.ts.map +1 -0
- package/dist/libraries/material/remove-mat-stepper-document-argument.js +71 -0
- package/dist/libraries/material/remove-mat-stepper-document-argument.js.map +1 -0
- package/dist/libraries/material/remove-update-active-link-argument.d.ts +8 -0
- package/dist/libraries/material/remove-update-active-link-argument.d.ts.map +1 -0
- package/dist/libraries/material/remove-update-active-link-argument.js +53 -0
- package/dist/libraries/material/remove-update-active-link-argument.js.map +1 -0
- package/dist/libraries/material/rename-material-members.d.ts +51 -0
- package/dist/libraries/material/rename-material-members.d.ts.map +1 -0
- package/dist/libraries/material/rename-material-members.js +125 -0
- package/dist/libraries/material/rename-material-members.js.map +1 -0
- package/dist/libraries/material/rename-material-style-names.d.ts +35 -0
- package/dist/libraries/material/rename-material-style-names.d.ts.map +1 -0
- package/dist/libraries/material/rename-material-style-names.js +182 -0
- package/dist/libraries/material/rename-material-style-names.js.map +1 -0
- package/dist/libraries/material/rename-textarea-autosize-attributes.d.ts +10 -0
- package/dist/libraries/material/rename-textarea-autosize-attributes.d.ts.map +1 -0
- package/dist/libraries/material/rename-textarea-autosize-attributes.js +47 -0
- package/dist/libraries/material/rename-textarea-autosize-attributes.js.map +1 -0
- package/dist/libraries/material/upgrade-to-material.d.ts +74 -0
- package/dist/libraries/material/upgrade-to-material.d.ts.map +1 -0
- package/dist/libraries/material/upgrade-to-material.js +312 -0
- package/dist/libraries/material/upgrade-to-material.js.map +1 -0
- 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-to-angular-10.d.ts.map +1 -1
- package/dist/migration/upgrade-to-angular-10.js +4 -1
- 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 +13 -2
- 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 +4 -1
- 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 +4 -1
- 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 +11 -1
- 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 +4 -1
- 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 +3 -0
- 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 +4 -1
- 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 +4 -1
- 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 +14 -2
- 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 +14 -1
- 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 +3 -0
- package/dist/migration/upgrade-to-angular-21.js.map +1 -1
- package/dist/migration/upgrade-to-angular-8.d.ts.map +1 -1
- package/dist/migration/upgrade-to-angular-8.js +4 -1
- 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 +4 -1
- package/dist/migration/upgrade-to-angular-9.js.map +1 -1
- package/package.json +6 -5
- package/src/index.ts +216 -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 +29 -2
- package/src/libraries/components/style-sources.ts +69 -0
- package/src/libraries/components/stylesheets.ts +50 -10
- package/src/libraries/components/symbols.ts +5 -4
- package/src/libraries/components/template-elements.ts +118 -0
- package/src/libraries/components/templates.ts +48 -35
- package/src/libraries/material/add-system-variables-prefix.ts +87 -0
- package/src/libraries/material/add-theme-base-mixins.ts +159 -0
- package/src/libraries/material/find-chip-input-event-without-chip-input.ts +62 -0
- package/src/libraries/material/find-legacy-material-usage.ts +67 -0
- package/src/libraries/material/find-material-constructor-changes.ts +230 -0
- package/src/libraries/material/find-mdc-breaking-changes.ts +262 -0
- package/src/libraries/material/find-mixin-error-state-without-state-changes.ts +89 -0
- package/src/libraries/material/find-raw-palette-themes.ts +98 -0
- package/src/libraries/material/find-removed-material-apis.ts +54 -0
- package/src/libraries/material/find-removed-material-classes.ts +119 -0
- package/src/libraries/material/find-removed-material-members.ts +145 -0
- package/src/libraries/material/find-slide-toggle-drag-options.ts +66 -0
- package/src/libraries/material/material-15-classes.ts +435 -0
- package/src/libraries/material/material-entry-points.ts +198 -0
- package/src/libraries/material/material-legacy-symbols.ts +557 -0
- package/src/libraries/material/material-theming-api.ts +454 -0
- package/src/libraries/material/material-version.ts +174 -0
- package/src/libraries/material/migrate-legacy-material.ts +196 -0
- package/src/libraries/material/migrate-list-item-harness-content-loader.ts +39 -0
- package/src/libraries/material/migrate-m2-theming-api.ts +95 -0
- package/src/libraries/material/migrate-mat-core-to-elevation-classes.ts +35 -0
- package/src/libraries/material/migrate-material-15-typography.ts +145 -0
- package/src/libraries/material/migrate-material-secondary-entry-points.ts +186 -0
- package/src/libraries/material/migrate-material-theming-api.ts +197 -0
- package/src/libraries/material/migrate-mdc-styles.ts +110 -0
- package/src/libraries/material/migrate-mdc-templates.ts +292 -0
- package/src/libraries/material/migrate-selection-list-change-option.ts +28 -0
- package/src/libraries/material/remove-mat-stepper-document-argument.ts +43 -0
- package/src/libraries/material/remove-update-active-link-argument.ts +32 -0
- package/src/libraries/material/rename-material-members.ts +109 -0
- package/src/libraries/material/rename-material-style-names.ts +164 -0
- package/src/libraries/material/rename-textarea-autosize-attributes.ts +35 -0
- package/src/libraries/material/upgrade-to-material.ts +274 -0
- 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-to-angular-10.ts +4 -1
- package/src/migration/upgrade-to-angular-11.ts +13 -2
- package/src/migration/upgrade-to-angular-12.ts +4 -1
- package/src/migration/upgrade-to-angular-13.ts +4 -1
- package/src/migration/upgrade-to-angular-14.ts +11 -1
- package/src/migration/upgrade-to-angular-15.ts +4 -1
- package/src/migration/upgrade-to-angular-16.ts +3 -0
- package/src/migration/upgrade-to-angular-17.ts +4 -1
- package/src/migration/upgrade-to-angular-18.ts +4 -1
- package/src/migration/upgrade-to-angular-19.ts +14 -2
- package/src/migration/upgrade-to-angular-20.ts +14 -1
- package/src/migration/upgrade-to-angular-21.ts +3 -0
- package/src/migration/upgrade-to-angular-8.ts +4 -1
- package/src/migration/upgrade-to-angular-9.ts +4 -1
|
@@ -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
|
+
}
|
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import {ExecutionContext, Recipe, TreeVisitor} from "@openrewrite/rewrite";
|
|
8
|
-
import {
|
|
8
|
+
import {isObject, Json, JsonVisitor} from "@openrewrite/rewrite/json";
|
|
9
|
+
import {mapObjectMember, mapProjectTargets, mapTargetOptions, plainAt, renameMember} from "./json-support";
|
|
9
10
|
|
|
10
11
|
const APPLICATION_BUILDERS = new Set([
|
|
11
12
|
'@angular-devkit/build-angular:application',
|
|
@@ -36,58 +37,16 @@ export class RenameSsrExperimentalPlatform extends Recipe {
|
|
|
36
37
|
}
|
|
37
38
|
|
|
38
39
|
function mapProjects(root: Json.Object): Json.Object {
|
|
39
|
-
return
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function mapProject(project: Json.Object): Json.Object {
|
|
44
|
-
if (plainAt(project, 'projectType') !== 'application') return project;
|
|
45
|
-
return mapObjectMember(project, 'architect', architect =>
|
|
46
|
-
mapObjectMembers(architect, target => mapTarget(target)));
|
|
47
|
-
}
|
|
40
|
+
return mapProjectTargets(root, (target, project) => {
|
|
41
|
+
if (plainAt(project, 'projectType') !== 'application') return target;
|
|
48
42
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
if (typeof builder !== 'string' || !APPLICATION_BUILDERS.has(builder)) return target;
|
|
43
|
+
const builder = plainAt(target, 'builder');
|
|
44
|
+
if (typeof builder !== 'string' || !APPLICATION_BUILDERS.has(builder)) return target;
|
|
52
45
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
mapObjectMembers(configurations, renameSsrPlatform));
|
|
56
|
-
return updated;
|
|
46
|
+
return mapTargetOptions(target, renameSsrPlatform);
|
|
47
|
+
});
|
|
57
48
|
}
|
|
58
49
|
|
|
59
50
|
function renameSsrPlatform(options: Json.Object): Json.Object {
|
|
60
51
|
return mapObjectMember(options, 'ssr', ssr => renameMember(ssr, 'experimentalPlatform', 'platform'));
|
|
61
52
|
}
|
|
62
|
-
|
|
63
|
-
function plainAt(obj: Json.Object, key: string): unknown {
|
|
64
|
-
const value = valueAt(obj, [key]);
|
|
65
|
-
return value && toPlain(value);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
function mapObjectMember(obj: Json.Object, key: string, fn: (child: Json.Object) => Json.Object): Json.Object {
|
|
69
|
-
return updateMember(obj, key, value => isObject(value) ? fn(value) : value);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function mapObjectMembers(obj: Json.Object, fn: (child: Json.Object) => Json.Object): Json.Object {
|
|
73
|
-
const members = obj.members.map(rp => {
|
|
74
|
-
if (!isMember(rp.element)) return rp;
|
|
75
|
-
const m = rp.element as Json.Member;
|
|
76
|
-
if (!isObject(m.value)) return rp;
|
|
77
|
-
const updated = fn(m.value as Json.Object);
|
|
78
|
-
return updated === m.value ? rp : {...rp, element: {...m, value: updated} as Json.Member};
|
|
79
|
-
});
|
|
80
|
-
return members.every((rp, i) => rp === obj.members[i]) ? obj : {...obj, members};
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
function renameMember(obj: Json.Object, from: string, to: string): Json.Object {
|
|
84
|
-
if (findMember(obj, to)) return obj;
|
|
85
|
-
|
|
86
|
-
const members = obj.members.map(rp => {
|
|
87
|
-
if (!isMember(rp.element)) return rp;
|
|
88
|
-
const m = rp.element as Json.Member;
|
|
89
|
-
if (getMemberKeyName(m) !== from) return rp;
|
|
90
|
-
return {...rp, element: {...m, key: {...m.key, element: jsonLiteral(to, m.key.element.prefix)}} as Json.Member};
|
|
91
|
-
});
|
|
92
|
-
return members.every((rp, i) => rp === obj.members[i]) ? obj : {...obj, members};
|
|
93
|
-
}
|
|
@@ -0,0 +1,45 @@
|
|
|
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 {findMember, isObject, Json, JsonVisitor, removeMember} from "@openrewrite/rewrite/json";
|
|
9
|
+
import {mapProjectTargets, mapTargetOptions, plainAt, renameMember} from "./json-support";
|
|
10
|
+
|
|
11
|
+
const BUILD_TARGET_BUILDERS = new Set([
|
|
12
|
+
'@angular-devkit/build-angular:dev-server',
|
|
13
|
+
'@angular-devkit/build-angular:extract-i18n',
|
|
14
|
+
'@angular/build:dev-server',
|
|
15
|
+
'@angular/build:extract-i18n',
|
|
16
|
+
]);
|
|
17
|
+
|
|
18
|
+
export class ReplaceBrowserTarget extends Recipe {
|
|
19
|
+
readonly name = "org.openrewrite.angular.migration.replace-browser-target";
|
|
20
|
+
readonly displayName: string = "Replace `browserTarget` with `buildTarget` in `angular.json`";
|
|
21
|
+
readonly description: string = "Renames the `browserTarget` option to `buildTarget` on the `dev-server` and " +
|
|
22
|
+
"`extract-i18n` builders. Angular 19 removed `browserTarget`. Matches the `update-workspace-config` schematic.";
|
|
23
|
+
|
|
24
|
+
async editor(): Promise<TreeVisitor<any, ExecutionContext>> {
|
|
25
|
+
return new class extends JsonVisitor<ExecutionContext> {
|
|
26
|
+
protected async visitDocument(doc: Json.Document, p: ExecutionContext): Promise<Json | undefined> {
|
|
27
|
+
if (!doc.sourcePath.endsWith('angular.json')) return doc;
|
|
28
|
+
|
|
29
|
+
const root = doc.value;
|
|
30
|
+
if (!isObject(root)) return doc;
|
|
31
|
+
|
|
32
|
+
const updated = mapProjectTargets(root, target => {
|
|
33
|
+
const builder = plainAt(target, 'builder');
|
|
34
|
+
if (typeof builder !== 'string' || !BUILD_TARGET_BUILDERS.has(builder)) return target;
|
|
35
|
+
// Angular keeps an explicit `buildTarget` and discards `browserTarget` either way.
|
|
36
|
+
return mapTargetOptions(target, options => findMember(options, 'buildTarget')
|
|
37
|
+
? removeMember(options, 'browserTarget')
|
|
38
|
+
: renameMember(options, 'browserTarget', 'buildTarget'));
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
return updated === root ? doc : {...doc, value: updated} as Json.Document;
|
|
42
|
+
}
|
|
43
|
+
}();
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
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 {appendElement, emptyArray, emptySpace, findMember, isObject, Json, JsonVisitor, removeMember, updateMember} from "@openrewrite/rewrite/json";
|
|
9
|
+
import {mapObjectMember, mapObjectMembers, renameMember} from "./json-support";
|
|
10
|
+
|
|
11
|
+
export class ReplaceDefaultCollection extends Recipe {
|
|
12
|
+
readonly name = "org.openrewrite.angular.migration.replace-default-collection";
|
|
13
|
+
readonly displayName: string = "Replace `defaultCollection` with `schematicCollections`";
|
|
14
|
+
readonly description: string = "Replaces the `cli.defaultCollection` option in `angular.json` with " +
|
|
15
|
+
"`cli.schematicCollections`, which takes a list of collections. Angular 14 deprecated `defaultCollection`. " +
|
|
16
|
+
"Matches the `replace-default-collection-option` schematic.";
|
|
17
|
+
|
|
18
|
+
async editor(): Promise<TreeVisitor<any, ExecutionContext>> {
|
|
19
|
+
return new class extends JsonVisitor<ExecutionContext> {
|
|
20
|
+
protected async visitDocument(doc: Json.Document, p: ExecutionContext): Promise<Json | undefined> {
|
|
21
|
+
if (!doc.sourcePath.endsWith('angular.json')) return doc;
|
|
22
|
+
|
|
23
|
+
const root = doc.value;
|
|
24
|
+
if (!isObject(root)) return doc;
|
|
25
|
+
|
|
26
|
+
let updated = mapObjectMember(root, 'cli', replaceDefaultCollection);
|
|
27
|
+
updated = mapObjectMember(updated, 'projects', projects =>
|
|
28
|
+
mapObjectMembers(projects, project => mapObjectMember(project, 'cli', replaceDefaultCollection)));
|
|
29
|
+
|
|
30
|
+
return updated === root ? doc : {...doc, value: updated} as Json.Document;
|
|
31
|
+
}
|
|
32
|
+
}();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function replaceDefaultCollection(cli: Json.Object): Json.Object {
|
|
37
|
+
if (!findMember(cli, 'defaultCollection')) return cli;
|
|
38
|
+
|
|
39
|
+
// `schematicCollections` already takes precedence at runtime, so the old key is only dropped.
|
|
40
|
+
if (findMember(cli, 'schematicCollections')) return removeMember(cli, 'defaultCollection');
|
|
41
|
+
|
|
42
|
+
const renamed = renameMember(cli, 'defaultCollection', 'schematicCollections');
|
|
43
|
+
return updateMember(renamed, 'schematicCollections', collection =>
|
|
44
|
+
appendElement(emptyArray(collection.prefix), {...collection, prefix: emptySpace}));
|
|
45
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
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 {capture, JavaScriptVisitor, pattern, rewrite, template} from "@openrewrite/rewrite/javascript";
|
|
9
|
+
import {J, Type} from "@openrewrite/rewrite/java";
|
|
10
|
+
|
|
11
|
+
const ROUTER_CONTEXT = {
|
|
12
|
+
context: ['import { Router } from "@angular/router"'],
|
|
13
|
+
dependencies: {'@angular/router': '^21.0.0'},
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* The receiver has to be a `Router`; `getCurrentNavigation` is a plausible name on a hand-rolled
|
|
18
|
+
* wrapper. The pattern's type context alone does not constrain a capture, so this stays explicit.
|
|
19
|
+
*/
|
|
20
|
+
function isRouter(node: J): boolean {
|
|
21
|
+
const type = (node as J & {type?: Type}).type;
|
|
22
|
+
return type?.kind === Type.Kind.Class
|
|
23
|
+
&& (type as Type.Class).fullyQualifiedName === '@angular/router.Router';
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const replaceCall = rewrite(() => {
|
|
27
|
+
const router = capture({constraint: isRouter});
|
|
28
|
+
return {
|
|
29
|
+
before: pattern`${router}.getCurrentNavigation()`.configure(ROUTER_CONTEXT),
|
|
30
|
+
after: template`${router}.currentNavigation()`.configure(ROUTER_CONTEXT),
|
|
31
|
+
};
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
export class ReplaceGetCurrentNavigation extends Recipe {
|
|
35
|
+
readonly name = "org.openrewrite.angular.migration.replace-get-current-navigation";
|
|
36
|
+
readonly displayName: string = "Replace `Router.getCurrentNavigation()` with `Router.currentNavigation()`";
|
|
37
|
+
readonly description: string = "Replaces calls to the deprecated `Router.getCurrentNavigation()` method with the " +
|
|
38
|
+
"`Router.currentNavigation()` signal, which Angular 21 introduced. Matches the `router-current-navigation` schematic.";
|
|
39
|
+
|
|
40
|
+
async editor(): Promise<TreeVisitor<any, ExecutionContext>> {
|
|
41
|
+
return new class extends JavaScriptVisitor<ExecutionContext> {
|
|
42
|
+
protected async visitMethodInvocation(method: J.MethodInvocation, p: ExecutionContext): Promise<J | undefined> {
|
|
43
|
+
const m = await super.visitMethodInvocation(method, p) as J.MethodInvocation;
|
|
44
|
+
// The template declares `@angular/router` in its context, so the rule needs a visitor to
|
|
45
|
+
// bind that module in, and only binds it once the pattern has actually matched.
|
|
46
|
+
return await replaceCall.tryOn(this.cursor, m, {visitor: this}) ?? m;
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,153 @@
|
|
|
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, maybeAddImport, maybeRemoveImport, Template} from "@openrewrite/rewrite/javascript";
|
|
9
|
+
import {isIdentifier, J} from "@openrewrite/rewrite/java";
|
|
10
|
+
|
|
11
|
+
const TOKEN_TO_PROVIDER: Record<string, string> = {
|
|
12
|
+
'APP_INITIALIZER': 'provideAppInitializer',
|
|
13
|
+
'ENVIRONMENT_INITIALIZER': 'provideEnvironmentInitializer',
|
|
14
|
+
'PLATFORM_INITIALIZER': 'providePlatformInitializer',
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
interface Provider {
|
|
18
|
+
token: string;
|
|
19
|
+
providerFn: string;
|
|
20
|
+
useValue?: J;
|
|
21
|
+
useExisting?: J;
|
|
22
|
+
useFactory?: J;
|
|
23
|
+
deps: J[];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export class ReplaceInitializerProviders extends Recipe {
|
|
27
|
+
readonly name = "org.openrewrite.angular.migration.replace-initializer-providers";
|
|
28
|
+
readonly displayName: string = "Replace initializer tokens with provider functions";
|
|
29
|
+
readonly description: string = "Replaces `APP_INITIALIZER`, `ENVIRONMENT_INITIALIZER`, and `PLATFORM_INITIALIZER` " +
|
|
30
|
+
"multi providers with `provideAppInitializer`, `provideEnvironmentInitializer`, and `providePlatformInitializer`. " +
|
|
31
|
+
"The provider functions were introduced in Angular 19 and the tokens are deprecated.";
|
|
32
|
+
|
|
33
|
+
async editor(): Promise<TreeVisitor<any, ExecutionContext>> {
|
|
34
|
+
return new class extends JavaScriptVisitor<ExecutionContext> {
|
|
35
|
+
private coreTokens = new Set<string>();
|
|
36
|
+
|
|
37
|
+
protected async visitImportDeclaration(jsImport: JS.Import, p: ExecutionContext): Promise<J | undefined> {
|
|
38
|
+
const imp = await super.visitImportDeclaration(jsImport, p) as JS.Import;
|
|
39
|
+
if (!imp?.moduleSpecifier) return imp;
|
|
40
|
+
|
|
41
|
+
const moduleSpec = imp.moduleSpecifier.element;
|
|
42
|
+
if (moduleSpec.kind !== J.Kind.Literal) return imp;
|
|
43
|
+
if ((moduleSpec as J.Literal).value !== '@angular/core') return imp;
|
|
44
|
+
|
|
45
|
+
const namedBindings = imp.importClause?.namedBindings;
|
|
46
|
+
if (namedBindings?.kind === JS.Kind.NamedImports) {
|
|
47
|
+
for (const specifier of (namedBindings as JS.NamedImports).elements.elements) {
|
|
48
|
+
const spec = specifier.element as JS.ImportSpecifier;
|
|
49
|
+
if (isIdentifier(spec.specifier)) {
|
|
50
|
+
this.coreTokens.add((spec.specifier as J.Identifier).simpleName);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return imp;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
protected async visitNewClass(newClass: J.NewClass, p: ExecutionContext): Promise<J | undefined> {
|
|
58
|
+
const nc = await super.visitNewClass(newClass, p) as J.NewClass;
|
|
59
|
+
if (!nc?.body) return nc;
|
|
60
|
+
|
|
61
|
+
const provider = this.parseProvider(nc);
|
|
62
|
+
if (!provider) return nc;
|
|
63
|
+
|
|
64
|
+
maybeRemoveImport(this, '@angular/core', provider.token);
|
|
65
|
+
maybeAddImport(this, {module: '@angular/core', member: provider.providerFn});
|
|
66
|
+
if (provider.useExisting || provider.deps.length > 0) {
|
|
67
|
+
maybeAddImport(this, {module: '@angular/core', member: 'inject'});
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return await buildProviderCall(provider).apply(nc, this.cursor);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
private parseProvider(nc: J.NewClass): Provider | undefined {
|
|
74
|
+
const props = new Map<string, J>();
|
|
75
|
+
for (const statement of nc.body!.statements) {
|
|
76
|
+
const stmt = statement.element;
|
|
77
|
+
if (stmt.kind !== JS.Kind.PropertyAssignment) return undefined;
|
|
78
|
+
|
|
79
|
+
const prop = stmt as JS.PropertyAssignment;
|
|
80
|
+
const name = prop.name.element;
|
|
81
|
+
if (!isIdentifier(name) || !prop.initializer) return undefined;
|
|
82
|
+
props.set((name as J.Identifier).simpleName, prop.initializer);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const provide = props.get('provide');
|
|
86
|
+
if (!provide || !isIdentifier(provide)) return undefined;
|
|
87
|
+
|
|
88
|
+
const token = (provide as J.Identifier).simpleName;
|
|
89
|
+
const providerFn = TOKEN_TO_PROVIDER[token];
|
|
90
|
+
// A token of the same name from another module is unrelated to Angular's.
|
|
91
|
+
if (!providerFn || !this.coreTokens.has(token)) return undefined;
|
|
92
|
+
|
|
93
|
+
// The provider functions always register a multi provider, so a single-valued
|
|
94
|
+
// initializer token has no equivalent. Angular's schematic skips these too.
|
|
95
|
+
const multi = props.get('multi');
|
|
96
|
+
if (!multi || multi.kind !== J.Kind.Literal || (multi as J.Literal).value !== true) return undefined;
|
|
97
|
+
|
|
98
|
+
const useValue = props.get('useValue');
|
|
99
|
+
const useExisting = props.get('useExisting');
|
|
100
|
+
const useFactory = props.get('useFactory');
|
|
101
|
+
if (!useValue && !useExisting && !useFactory) return undefined;
|
|
102
|
+
|
|
103
|
+
const deps = props.get('deps');
|
|
104
|
+
return {
|
|
105
|
+
token,
|
|
106
|
+
providerFn,
|
|
107
|
+
useValue,
|
|
108
|
+
useExisting,
|
|
109
|
+
useFactory,
|
|
110
|
+
deps: deps?.kind === J.Kind.NewArray
|
|
111
|
+
? ((deps as J.NewArray).initializer?.elements ?? []).map(e => e.element)
|
|
112
|
+
: [],
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** Typed template params emit an invalid `let <placeholder>: <fqn>;` preamble; see `replace-inject-flags.ts`. */
|
|
120
|
+
function untyped(node: J): J {
|
|
121
|
+
return {...node, type: undefined} as J;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* A factory that is not a plain reference has to be parenthesised to be called immediately.
|
|
126
|
+
* Parenthesising a reference that does not need it is not merely noise: Prettier rewrites it away,
|
|
127
|
+
* and the whitespace reconciler then abandons formatting for the whole subtree.
|
|
128
|
+
*/
|
|
129
|
+
function needsParens(factory: J): boolean {
|
|
130
|
+
return !isIdentifier(factory) && factory.kind !== J.Kind.FieldAccess;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function buildProviderCall(provider: Provider): Template {
|
|
134
|
+
const b = Template.builder().code(`${provider.providerFn}(`);
|
|
135
|
+
|
|
136
|
+
if (provider.useExisting) {
|
|
137
|
+
b.code('() => inject(').param(untyped(provider.useExisting)).code(')()');
|
|
138
|
+
} else if (provider.useFactory) {
|
|
139
|
+
const wrap = needsParens(provider.useFactory);
|
|
140
|
+
b.code(`() => {\nconst initializerFn = ${wrap ? '(' : ''}`)
|
|
141
|
+
.param(untyped(provider.useFactory))
|
|
142
|
+
.code(`${wrap ? ')' : ''}(`);
|
|
143
|
+
provider.deps.forEach((dep, i) => {
|
|
144
|
+
if (i > 0) b.code(', ');
|
|
145
|
+
b.code('inject(').param(untyped(dep)).code(')');
|
|
146
|
+
});
|
|
147
|
+
b.code(');\nreturn initializerFn();\n}');
|
|
148
|
+
} else {
|
|
149
|
+
b.param(untyped(provider.useValue!));
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
return b.code(')').build();
|
|
153
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
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
|
+
import {buildPropertyAssignment} from "./js-support";
|
|
11
|
+
|
|
12
|
+
const NAVIGATION_METHODS = new Set(['navigate', 'createUrlTree']);
|
|
13
|
+
|
|
14
|
+
export class ReplacePreserveQueryParams extends Recipe {
|
|
15
|
+
readonly name = "org.openrewrite.angular.migration.replace-preserve-query-params";
|
|
16
|
+
readonly displayName: string = "Replace `preserveQueryParams` with `queryParamsHandling`";
|
|
17
|
+
readonly description: string = "Rewrites `preserveQueryParams: true` in `navigate()` and `createUrlTree()` " +
|
|
18
|
+
"navigation extras to `queryParamsHandling: 'preserve'`, and drops the option when it holds any other value, " +
|
|
19
|
+
"which is what `false` already meant. Angular 11 removed `preserveQueryParams`. " +
|
|
20
|
+
"Matches the `migration-v11-router-preserve-query-params` schematic.";
|
|
21
|
+
|
|
22
|
+
async editor(): Promise<TreeVisitor<any, ExecutionContext>> {
|
|
23
|
+
return new class extends JavaScriptVisitor<ExecutionContext> {
|
|
24
|
+
/** Children are visited first, so this holds the quote of the nearest preceding string. */
|
|
25
|
+
private quote = "'";
|
|
26
|
+
|
|
27
|
+
protected async visitLiteral(literal: J.Literal, p: ExecutionContext): Promise<J | undefined> {
|
|
28
|
+
const source = literal.valueSource;
|
|
29
|
+
if (typeof literal.value === 'string' && (source?.startsWith('"') || source?.startsWith("'"))) {
|
|
30
|
+
this.quote = source.charAt(0);
|
|
31
|
+
}
|
|
32
|
+
return super.visitLiteral(literal, p);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
protected async visitMethodInvocation(method: J.MethodInvocation, p: ExecutionContext): Promise<J | undefined> {
|
|
36
|
+
const m = await super.visitMethodInvocation(method, p) as J.MethodInvocation;
|
|
37
|
+
if (!isIdentifier(m.name) || !NAVIGATION_METHODS.has(m.name.simpleName)) return m;
|
|
38
|
+
|
|
39
|
+
const args = m.arguments?.elements;
|
|
40
|
+
if (!args) return m;
|
|
41
|
+
|
|
42
|
+
let changed = false;
|
|
43
|
+
const rewritten = args.map(rp => {
|
|
44
|
+
if (rp.element.kind !== J.Kind.NewClass) return rp;
|
|
45
|
+
const extras = rp.element as J.NewClass;
|
|
46
|
+
if (!extras.body) return rp;
|
|
47
|
+
|
|
48
|
+
const updated = migrateExtras(extras, this.quote);
|
|
49
|
+
if (updated === extras) return rp;
|
|
50
|
+
changed = true;
|
|
51
|
+
return {...rp, element: updated};
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
return changed ? {...m, arguments: {...m.arguments!, elements: rewritten}} as J.MethodInvocation : m;
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function migrateExtras(extras: J.NewClass, quote: string): J.NewClass {
|
|
61
|
+
const statements = extras.body!.statements;
|
|
62
|
+
const index = statements.findIndex(rp => propertyName(rp.element) === 'preserveQueryParams');
|
|
63
|
+
if (index === -1) return extras;
|
|
64
|
+
|
|
65
|
+
const property = statements[index].element as JS.PropertyAssignment;
|
|
66
|
+
const preserved = property.initializer?.kind === J.Kind.Literal
|
|
67
|
+
&& (property.initializer as J.Literal).value === true;
|
|
68
|
+
|
|
69
|
+
const updated = [...statements];
|
|
70
|
+
if (preserved) {
|
|
71
|
+
const replacement = buildPropertyAssignment('queryParamsHandling', 'preserve', quote);
|
|
72
|
+
updated[index] = {...updated[index], element: {...replacement, prefix: property.prefix}};
|
|
73
|
+
} else {
|
|
74
|
+
updated.splice(index, 1);
|
|
75
|
+
// The first surviving property carries the brace's trailing space.
|
|
76
|
+
if (updated.length > 0 && index === 0) {
|
|
77
|
+
updated[0] = {...updated[0], element: {...updated[0].element, prefix: property.prefix}};
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return {...extras, body: {...extras.body!, statements: updated}} as J.NewClass;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function propertyName(statement: J): string | undefined {
|
|
85
|
+
if (statement.kind !== JS.Kind.PropertyAssignment) return undefined;
|
|
86
|
+
const name = (statement as JS.PropertyAssignment).name.element;
|
|
87
|
+
return isIdentifier(name) ? (name as J.Identifier).simpleName : undefined;
|
|
88
|
+
}
|