@openrewrite/recipes-angular 1.27.0 → 1.28.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 +28 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +188 -1
- package/dist/index.js.map +1 -1
- package/dist/libraries/components/lst.d.ts +7 -0
- package/dist/libraries/components/lst.d.ts.map +1 -1
- package/dist/libraries/components/lst.js +12 -0
- package/dist/libraries/components/lst.js.map +1 -1
- package/dist/libraries/components/style-sources.d.ts +15 -0
- package/dist/libraries/components/style-sources.d.ts.map +1 -0
- package/dist/libraries/components/style-sources.js +108 -0
- package/dist/libraries/components/style-sources.js.map +1 -0
- package/dist/libraries/components/stylesheets.d.ts +12 -0
- package/dist/libraries/components/stylesheets.d.ts.map +1 -1
- package/dist/libraries/components/stylesheets.js +37 -1
- package/dist/libraries/components/stylesheets.js.map +1 -1
- package/dist/libraries/components/symbols.d.ts +21 -1
- package/dist/libraries/components/symbols.d.ts.map +1 -1
- package/dist/libraries/components/symbols.js +124 -9
- package/dist/libraries/components/symbols.js.map +1 -1
- package/dist/libraries/components/template-elements.d.ts +38 -0
- package/dist/libraries/components/template-elements.d.ts.map +1 -0
- package/dist/libraries/components/template-elements.js +90 -0
- package/dist/libraries/components/template-elements.js.map +1 -0
- package/dist/libraries/components/templates.d.ts +6 -0
- package/dist/libraries/components/templates.d.ts.map +1 -1
- package/dist/libraries/components/templates.js +17 -2
- package/dist/libraries/components/templates.js.map +1 -1
- package/dist/libraries/material/add-system-variables-prefix.d.ts +9 -0
- package/dist/libraries/material/add-system-variables-prefix.d.ts.map +1 -0
- package/dist/libraries/material/add-system-variables-prefix.js +74 -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 +95 -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 +103 -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 +267 -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 +326 -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 +124 -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 +154 -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 +168 -0
- package/dist/libraries/material/find-removed-material-members.js.map +1 -0
- package/dist/libraries/material/find-slide-toggle-drag-options.d.ts +8 -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 +102 -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 +24 -0
- package/dist/libraries/material/material-version.d.ts.map +1 -0
- package/dist/libraries/material/material-version.js +160 -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 +230 -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 +120 -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 +9 -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 +36 -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 +185 -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 +157 -0
- package/dist/libraries/material/migrate-material-secondary-entry-points.js.map +1 -0
- package/dist/libraries/material/migrate-material-theming-api.d.ts +17 -0
- package/dist/libraries/material/migrate-material-theming-api.d.ts.map +1 -0
- package/dist/libraries/material/migrate-material-theming-api.js +190 -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 +145 -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 +306 -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 +72 -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 +54 -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 +28 -0
- package/dist/libraries/material/rename-material-style-names.d.ts.map +1 -0
- package/dist/libraries/material/rename-material-style-names.js +148 -0
- package/dist/libraries/material/rename-material-style-names.js.map +1 -0
- package/dist/libraries/material/rename-textarea-autosize-attributes.d.ts +20 -0
- package/dist/libraries/material/rename-textarea-autosize-attributes.d.ts.map +1 -0
- package/dist/libraries/material/rename-textarea-autosize-attributes.js +32 -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 +324 -0
- package/dist/libraries/material/upgrade-to-material.js.map +1 -0
- package/dist/migration/upgrade-angular-dependencies.d.ts +2 -0
- package/dist/migration/upgrade-angular-dependencies.d.ts.map +1 -1
- package/dist/migration/upgrade-angular-dependencies.js +6 -0
- 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 +5 -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 +10 -1
- 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 +5 -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 +5 -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 +5 -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 +5 -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 +2 -1
- 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 +5 -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 +5 -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 +5 -1
- 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 +5 -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 +2 -1
- 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 +2 -1
- 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 +6 -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 +5 -1
- package/dist/migration/upgrade-to-angular-9.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +189 -0
- package/src/libraries/components/lst.ts +13 -2
- package/src/libraries/components/style-sources.ts +80 -0
- package/src/libraries/components/stylesheets.ts +37 -0
- package/src/libraries/components/symbols.ts +95 -10
- package/src/libraries/components/template-elements.ts +113 -0
- package/src/libraries/components/templates.ts +18 -4
- package/src/libraries/material/add-system-variables-prefix.ts +71 -0
- package/src/libraries/material/add-theme-base-mixins.ts +159 -0
- package/src/libraries/material/find-chip-input-event-without-chip-input.ts +63 -0
- package/src/libraries/material/find-legacy-material-usage.ts +73 -0
- package/src/libraries/material/find-material-constructor-changes.ts +231 -0
- package/src/libraries/material/find-mdc-breaking-changes.ts +273 -0
- package/src/libraries/material/find-mixin-error-state-without-state-changes.ts +89 -0
- package/src/libraries/material/find-raw-palette-themes.ts +100 -0
- package/src/libraries/material/find-removed-material-apis.ts +54 -0
- package/src/libraries/material/find-removed-material-classes.ts +127 -0
- package/src/libraries/material/find-removed-material-members.ts +146 -0
- package/src/libraries/material/find-slide-toggle-drag-options.ts +69 -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 +142 -0
- package/src/libraries/material/migrate-legacy-material.ts +202 -0
- package/src/libraries/material/migrate-list-item-harness-content-loader.ts +39 -0
- package/src/libraries/material/migrate-m2-theming-api.ts +98 -0
- package/src/libraries/material/migrate-mat-core-to-elevation-classes.ts +32 -0
- package/src/libraries/material/migrate-material-15-typography.ts +153 -0
- package/src/libraries/material/migrate-material-secondary-entry-points.ts +154 -0
- package/src/libraries/material/migrate-material-theming-api.ts +189 -0
- package/src/libraries/material/migrate-mdc-styles.ts +117 -0
- package/src/libraries/material/migrate-mdc-templates.ts +269 -0
- package/src/libraries/material/migrate-selection-list-change-option.ts +28 -0
- package/src/libraries/material/remove-mat-stepper-document-argument.ts +44 -0
- package/src/libraries/material/remove-update-active-link-argument.ts +33 -0
- package/src/libraries/material/rename-material-members.ts +109 -0
- package/src/libraries/material/rename-material-style-names.ts +116 -0
- package/src/libraries/material/rename-textarea-autosize-attributes.ts +27 -0
- package/src/libraries/material/upgrade-to-material.ts +286 -0
- package/src/migration/upgrade-angular-dependencies.ts +6 -0
- package/src/migration/upgrade-to-angular-10.ts +6 -2
- package/src/migration/upgrade-to-angular-11.ts +11 -2
- package/src/migration/upgrade-to-angular-12.ts +6 -2
- package/src/migration/upgrade-to-angular-13.ts +6 -2
- package/src/migration/upgrade-to-angular-14.ts +6 -2
- package/src/migration/upgrade-to-angular-15.ts +6 -2
- package/src/migration/upgrade-to-angular-16.ts +3 -2
- package/src/migration/upgrade-to-angular-17.ts +6 -2
- package/src/migration/upgrade-to-angular-18.ts +6 -2
- package/src/migration/upgrade-to-angular-19.ts +6 -2
- package/src/migration/upgrade-to-angular-20.ts +6 -2
- package/src/migration/upgrade-to-angular-21.ts +3 -2
- package/src/migration/upgrade-to-angular-22.ts +3 -2
- package/src/migration/upgrade-to-angular-8.ts +6 -1
- package/src/migration/upgrade-to-angular-9.ts +6 -2
package/src/index.ts
CHANGED
|
@@ -179,6 +179,68 @@ import {MigrateCdkStepper} from './libraries/cdk/migrate-cdk-stepper';
|
|
|
179
179
|
import {MigrateDragDropRegistry} from './libraries/cdk/migrate-drag-drop-registry';
|
|
180
180
|
import {MigrateDeprecatedOverlaySass} from './libraries/cdk/migrate-deprecated-overlay-sass';
|
|
181
181
|
import {RemoveCdkSuperArguments} from './libraries/cdk/remove-cdk-super-arguments';
|
|
182
|
+
import {
|
|
183
|
+
UpgradeToMaterial10CodeChanges,
|
|
184
|
+
UpgradeToMaterial15CodeChanges,
|
|
185
|
+
UpgradeToMaterial17CodeChanges,
|
|
186
|
+
UpgradeToMaterial18CodeChanges,
|
|
187
|
+
UpgradeToMaterial19CodeChanges,
|
|
188
|
+
UpgradeToMaterial20CodeChanges,
|
|
189
|
+
UpgradeToMaterial11CodeChanges,
|
|
190
|
+
UpgradeToMaterial12CodeChanges,
|
|
191
|
+
UpgradeToMaterial13CodeChanges,
|
|
192
|
+
UpgradeToMaterial14CodeChanges,
|
|
193
|
+
UpgradeToMaterial8CodeChanges,
|
|
194
|
+
UpgradeToMaterial9CodeChanges
|
|
195
|
+
} from './libraries/material/upgrade-to-material';
|
|
196
|
+
import {MigrateMaterialSecondaryEntryPoints} from './libraries/material/migrate-material-secondary-entry-points';
|
|
197
|
+
import {RenameMaterial11Members, RenameMaterial13Members, RenameMaterial9Members} from './libraries/material/rename-material-members';
|
|
198
|
+
import {RemoveUpdateActiveLinkArgument} from './libraries/material/remove-update-active-link-argument';
|
|
199
|
+
import {FindRemovedMaterial10Apis, FindRemovedMaterial11Apis, FindRemovedMaterial13Apis} from './libraries/material/find-removed-material-apis';
|
|
200
|
+
import {
|
|
201
|
+
FindRemovedMaterial10Members,
|
|
202
|
+
FindRemovedMaterial11Members,
|
|
203
|
+
FindRemovedMaterial13Members,
|
|
204
|
+
FindRemovedMaterial14Members
|
|
205
|
+
} from './libraries/material/find-removed-material-members';
|
|
206
|
+
import {FindSlideToggleDragOptions} from './libraries/material/find-slide-toggle-drag-options';
|
|
207
|
+
import {MigrateMaterialThemingApi} from './libraries/material/migrate-material-theming-api';
|
|
208
|
+
import {RenameLegacyPrebuiltThemes, RenameListItemAvatarClass, RenameMaterial18Tokens, RenameMaterial20Tokens} from './libraries/material/rename-material-style-names';
|
|
209
|
+
import {FindLegacyRawPaletteThemes, FindRawPaletteThemes} from './libraries/material/find-raw-palette-themes';
|
|
210
|
+
import {FindRemovedMaterialClasses} from './libraries/material/find-removed-material-classes';
|
|
211
|
+
import {MigrateMaterial15Typography} from './libraries/material/migrate-material-15-typography';
|
|
212
|
+
import {AddThemeBaseMixins} from './libraries/material/add-theme-base-mixins';
|
|
213
|
+
import {FindLegacyMaterialUsage} from './libraries/material/find-legacy-material-usage';
|
|
214
|
+
import {MigrateM2ThemingApi} from './libraries/material/migrate-m2-theming-api';
|
|
215
|
+
import {AddSystemVariablesPrefix} from './libraries/material/add-system-variables-prefix';
|
|
216
|
+
import {MigrateMatCoreToElevationClasses} from './libraries/material/migrate-mat-core-to-elevation-classes';
|
|
217
|
+
import {FindMdcTemplateChanges, FindRemovedMaterial15Apis, FindRemovedMaterial15Members} from './libraries/material/find-mdc-breaking-changes';
|
|
218
|
+
import {MigrateMdcTemplates} from './libraries/material/migrate-mdc-templates';
|
|
219
|
+
import {
|
|
220
|
+
FindLegacyMaterialClasses,
|
|
221
|
+
FindLegacyMaterialMembers,
|
|
222
|
+
FindLegacyMdcTemplateChanges,
|
|
223
|
+
MigrateLegacyMaterialImports,
|
|
224
|
+
MigrateLegacyMaterialStyles,
|
|
225
|
+
MigrateLegacyMaterialTemplates
|
|
226
|
+
} from './libraries/material/migrate-legacy-material';
|
|
227
|
+
import {MigrateMdcStyles} from './libraries/material/migrate-mdc-styles';
|
|
228
|
+
import {RenameTextareaAutosizeAttributes} from './libraries/material/rename-textarea-autosize-attributes';
|
|
229
|
+
import {FindChipInputEventWithoutChipInput} from './libraries/material/find-chip-input-event-without-chip-input';
|
|
230
|
+
import {FindMixinErrorStateWithoutStateChanges} from './libraries/material/find-mixin-error-state-without-state-changes';
|
|
231
|
+
import {MigrateListItemHarnessContentLoader} from './libraries/material/migrate-list-item-harness-content-loader';
|
|
232
|
+
import {MigrateSelectionListChangeOption} from './libraries/material/migrate-selection-list-change-option';
|
|
233
|
+
import {RemoveMatStepperDocumentArgument} from './libraries/material/remove-mat-stepper-document-argument';
|
|
234
|
+
import {
|
|
235
|
+
FindMaterial10ConstructorChanges,
|
|
236
|
+
FindMaterial11ConstructorChanges,
|
|
237
|
+
FindMaterial12ConstructorChanges,
|
|
238
|
+
FindMaterial13ConstructorChanges,
|
|
239
|
+
FindMaterial14ConstructorChanges,
|
|
240
|
+
FindMaterial15ConstructorChanges,
|
|
241
|
+
FindMaterial8ConstructorChanges,
|
|
242
|
+
FindMaterial9ConstructorChanges
|
|
243
|
+
} from './libraries/material/find-material-constructor-changes';
|
|
182
244
|
import {CategoryDescriptor, JavaScript, RecipeMarketplace} from "@openrewrite/rewrite";
|
|
183
245
|
|
|
184
246
|
const Angular: CategoryDescriptor[] = [...JavaScript, {displayName: "Angular"}];
|
|
@@ -186,6 +248,7 @@ const AngularMigration: CategoryDescriptor[] = [...Angular, {displayName: "Migra
|
|
|
186
248
|
const AngularSearch: CategoryDescriptor[] = [...Angular, {displayName: "Search"}];
|
|
187
249
|
const PrimeNG: CategoryDescriptor[] = [...JavaScript, {displayName: "PrimeNG"}];
|
|
188
250
|
const AngularCdk: CategoryDescriptor[] = [...Angular, {displayName: "CDK"}];
|
|
251
|
+
const AngularMaterial: CategoryDescriptor[] = [...Angular, {displayName: "Material"}];
|
|
189
252
|
|
|
190
253
|
// noinspection JSUnusedGlobalSymbols
|
|
191
254
|
export async function activate(marketplace: RecipeMarketplace) {
|
|
@@ -361,6 +424,70 @@ export async function activate(marketplace: RecipeMarketplace) {
|
|
|
361
424
|
await marketplace.install(RemoveCdkSuperArguments, AngularCdk);
|
|
362
425
|
await marketplace.install(FindComponentPortalFactoryResolver, AngularCdk);
|
|
363
426
|
await marketplace.install(FindSelectionModelVoidOverrides, AngularCdk);
|
|
427
|
+
await marketplace.install(UpgradeToMaterial8CodeChanges, AngularMaterial);
|
|
428
|
+
await marketplace.install(UpgradeToMaterial9CodeChanges, AngularMaterial);
|
|
429
|
+
await marketplace.install(UpgradeToMaterial10CodeChanges, AngularMaterial);
|
|
430
|
+
await marketplace.install(UpgradeToMaterial11CodeChanges, AngularMaterial);
|
|
431
|
+
await marketplace.install(UpgradeToMaterial12CodeChanges, AngularMaterial);
|
|
432
|
+
await marketplace.install(UpgradeToMaterial13CodeChanges, AngularMaterial);
|
|
433
|
+
await marketplace.install(UpgradeToMaterial14CodeChanges, AngularMaterial);
|
|
434
|
+
await marketplace.install(MigrateMaterialSecondaryEntryPoints, AngularMaterial);
|
|
435
|
+
await marketplace.install(RenameMaterial9Members, AngularMaterial);
|
|
436
|
+
await marketplace.install(RenameMaterial11Members, AngularMaterial);
|
|
437
|
+
await marketplace.install(RemoveUpdateActiveLinkArgument, AngularMaterial);
|
|
438
|
+
await marketplace.install(FindRemovedMaterial13Apis, AngularMaterial);
|
|
439
|
+
await marketplace.install(RenameMaterial13Members, AngularMaterial);
|
|
440
|
+
await marketplace.install(FindRemovedMaterial10Apis, AngularMaterial);
|
|
441
|
+
await marketplace.install(FindRemovedMaterial11Apis, AngularMaterial);
|
|
442
|
+
await marketplace.install(FindRemovedMaterial10Members, AngularMaterial);
|
|
443
|
+
await marketplace.install(FindRemovedMaterial11Members, AngularMaterial);
|
|
444
|
+
await marketplace.install(FindRemovedMaterial13Members, AngularMaterial);
|
|
445
|
+
await marketplace.install(FindRemovedMaterial14Members, AngularMaterial);
|
|
446
|
+
await marketplace.install(FindSlideToggleDragOptions, AngularMaterial);
|
|
447
|
+
await marketplace.install(RenameTextareaAutosizeAttributes, AngularMaterial);
|
|
448
|
+
await marketplace.install(RemoveMatStepperDocumentArgument, AngularMaterial);
|
|
449
|
+
await marketplace.install(MigrateSelectionListChangeOption, AngularMaterial);
|
|
450
|
+
await marketplace.install(MigrateListItemHarnessContentLoader, AngularMaterial);
|
|
451
|
+
await marketplace.install(FindChipInputEventWithoutChipInput, AngularMaterial);
|
|
452
|
+
await marketplace.install(FindMixinErrorStateWithoutStateChanges, AngularMaterial);
|
|
453
|
+
await marketplace.install(UpgradeToMaterial15CodeChanges, AngularMaterial);
|
|
454
|
+
await marketplace.install(UpgradeToMaterial17CodeChanges, AngularMaterial);
|
|
455
|
+
await marketplace.install(UpgradeToMaterial18CodeChanges, AngularMaterial);
|
|
456
|
+
await marketplace.install(UpgradeToMaterial19CodeChanges, AngularMaterial);
|
|
457
|
+
await marketplace.install(UpgradeToMaterial20CodeChanges, AngularMaterial);
|
|
458
|
+
await marketplace.install(MigrateMaterialThemingApi, AngularMaterial);
|
|
459
|
+
await marketplace.install(RenameListItemAvatarClass, AngularMaterial);
|
|
460
|
+
await marketplace.install(RenameMaterial18Tokens, AngularMaterial);
|
|
461
|
+
await marketplace.install(RenameMaterial20Tokens, AngularMaterial);
|
|
462
|
+
await marketplace.install(FindRemovedMaterialClasses, AngularMaterial);
|
|
463
|
+
await marketplace.install(FindRawPaletteThemes, AngularMaterial);
|
|
464
|
+
await marketplace.install(MigrateMaterial15Typography, AngularMaterial);
|
|
465
|
+
await marketplace.install(AddThemeBaseMixins, AngularMaterial);
|
|
466
|
+
await marketplace.install(FindLegacyMaterialUsage, AngularMaterial);
|
|
467
|
+
await marketplace.install(MigrateM2ThemingApi, AngularMaterial);
|
|
468
|
+
await marketplace.install(AddSystemVariablesPrefix, AngularMaterial);
|
|
469
|
+
await marketplace.install(MigrateMatCoreToElevationClasses, AngularMaterial);
|
|
470
|
+
await marketplace.install(FindRemovedMaterial15Apis, AngularMaterial);
|
|
471
|
+
await marketplace.install(FindRemovedMaterial15Members, AngularMaterial);
|
|
472
|
+
await marketplace.install(FindMdcTemplateChanges, AngularMaterial);
|
|
473
|
+
await marketplace.install(FindMaterial15ConstructorChanges, AngularMaterial);
|
|
474
|
+
await marketplace.install(MigrateMdcTemplates, AngularMaterial);
|
|
475
|
+
await marketplace.install(MigrateMdcStyles, AngularMaterial);
|
|
476
|
+
await marketplace.install(FindLegacyMaterialClasses, AngularMaterial);
|
|
477
|
+
await marketplace.install(FindLegacyRawPaletteThemes, AngularMaterial);
|
|
478
|
+
await marketplace.install(RenameLegacyPrebuiltThemes, AngularMaterial);
|
|
479
|
+
await marketplace.install(FindLegacyMaterialMembers, AngularMaterial);
|
|
480
|
+
await marketplace.install(FindLegacyMdcTemplateChanges, AngularMaterial);
|
|
481
|
+
await marketplace.install(MigrateLegacyMaterialImports, AngularMaterial);
|
|
482
|
+
await marketplace.install(MigrateLegacyMaterialStyles, AngularMaterial);
|
|
483
|
+
await marketplace.install(MigrateLegacyMaterialTemplates, AngularMaterial);
|
|
484
|
+
await marketplace.install(FindMaterial8ConstructorChanges, AngularMaterial);
|
|
485
|
+
await marketplace.install(FindMaterial9ConstructorChanges, AngularMaterial);
|
|
486
|
+
await marketplace.install(FindMaterial10ConstructorChanges, AngularMaterial);
|
|
487
|
+
await marketplace.install(FindMaterial11ConstructorChanges, AngularMaterial);
|
|
488
|
+
await marketplace.install(FindMaterial12ConstructorChanges, AngularMaterial);
|
|
489
|
+
await marketplace.install(FindMaterial13ConstructorChanges, AngularMaterial);
|
|
490
|
+
await marketplace.install(FindMaterial14ConstructorChanges, AngularMaterial);
|
|
364
491
|
}
|
|
365
492
|
|
|
366
493
|
export {RenameFile} from './migration/rename-file';
|
|
@@ -548,3 +675,65 @@ export {MigrateCdkStepper} from './libraries/cdk/migrate-cdk-stepper';
|
|
|
548
675
|
export {MigrateDragDropRegistry} from './libraries/cdk/migrate-drag-drop-registry';
|
|
549
676
|
export {MigrateDeprecatedOverlaySass} from './libraries/cdk/migrate-deprecated-overlay-sass';
|
|
550
677
|
export {RemoveCdkSuperArguments} from './libraries/cdk/remove-cdk-super-arguments';
|
|
678
|
+
export {
|
|
679
|
+
UpgradeToMaterial10CodeChanges,
|
|
680
|
+
UpgradeToMaterial15CodeChanges,
|
|
681
|
+
UpgradeToMaterial17CodeChanges,
|
|
682
|
+
UpgradeToMaterial18CodeChanges,
|
|
683
|
+
UpgradeToMaterial19CodeChanges,
|
|
684
|
+
UpgradeToMaterial20CodeChanges,
|
|
685
|
+
UpgradeToMaterial11CodeChanges,
|
|
686
|
+
UpgradeToMaterial12CodeChanges,
|
|
687
|
+
UpgradeToMaterial13CodeChanges,
|
|
688
|
+
UpgradeToMaterial14CodeChanges,
|
|
689
|
+
UpgradeToMaterial8CodeChanges,
|
|
690
|
+
UpgradeToMaterial9CodeChanges
|
|
691
|
+
} from './libraries/material/upgrade-to-material';
|
|
692
|
+
export {MigrateMaterialSecondaryEntryPoints} from './libraries/material/migrate-material-secondary-entry-points';
|
|
693
|
+
export {RenameMaterial11Members, RenameMaterial13Members, RenameMaterial9Members} from './libraries/material/rename-material-members';
|
|
694
|
+
export {RemoveUpdateActiveLinkArgument} from './libraries/material/remove-update-active-link-argument';
|
|
695
|
+
export {FindRemovedMaterial10Apis, FindRemovedMaterial11Apis, FindRemovedMaterial13Apis} from './libraries/material/find-removed-material-apis';
|
|
696
|
+
export {
|
|
697
|
+
FindRemovedMaterial10Members,
|
|
698
|
+
FindRemovedMaterial11Members,
|
|
699
|
+
FindRemovedMaterial13Members,
|
|
700
|
+
FindRemovedMaterial14Members
|
|
701
|
+
} from './libraries/material/find-removed-material-members';
|
|
702
|
+
export {FindSlideToggleDragOptions} from './libraries/material/find-slide-toggle-drag-options';
|
|
703
|
+
export {MigrateMaterialThemingApi} from './libraries/material/migrate-material-theming-api';
|
|
704
|
+
export {RenameLegacyPrebuiltThemes, RenameListItemAvatarClass, RenameMaterial18Tokens, RenameMaterial20Tokens} from './libraries/material/rename-material-style-names';
|
|
705
|
+
export {FindLegacyRawPaletteThemes, FindRawPaletteThemes} from './libraries/material/find-raw-palette-themes';
|
|
706
|
+
export {FindRemovedMaterialClasses} from './libraries/material/find-removed-material-classes';
|
|
707
|
+
export {MigrateMaterial15Typography} from './libraries/material/migrate-material-15-typography';
|
|
708
|
+
export {AddThemeBaseMixins} from './libraries/material/add-theme-base-mixins';
|
|
709
|
+
export {FindLegacyMaterialUsage} from './libraries/material/find-legacy-material-usage';
|
|
710
|
+
export {MigrateM2ThemingApi} from './libraries/material/migrate-m2-theming-api';
|
|
711
|
+
export {AddSystemVariablesPrefix} from './libraries/material/add-system-variables-prefix';
|
|
712
|
+
export {MigrateMatCoreToElevationClasses} from './libraries/material/migrate-mat-core-to-elevation-classes';
|
|
713
|
+
export {FindMdcTemplateChanges, FindRemovedMaterial15Apis, FindRemovedMaterial15Members} from './libraries/material/find-mdc-breaking-changes';
|
|
714
|
+
export {MigrateMdcTemplates} from './libraries/material/migrate-mdc-templates';
|
|
715
|
+
export {MigrateMdcStyles} from './libraries/material/migrate-mdc-styles';
|
|
716
|
+
export {
|
|
717
|
+
FindLegacyMaterialClasses,
|
|
718
|
+
FindLegacyMaterialMembers,
|
|
719
|
+
FindLegacyMdcTemplateChanges,
|
|
720
|
+
MigrateLegacyMaterialImports,
|
|
721
|
+
MigrateLegacyMaterialStyles,
|
|
722
|
+
MigrateLegacyMaterialTemplates
|
|
723
|
+
} from './libraries/material/migrate-legacy-material';
|
|
724
|
+
export {RenameTextareaAutosizeAttributes} from './libraries/material/rename-textarea-autosize-attributes';
|
|
725
|
+
export {FindChipInputEventWithoutChipInput} from './libraries/material/find-chip-input-event-without-chip-input';
|
|
726
|
+
export {FindMixinErrorStateWithoutStateChanges} from './libraries/material/find-mixin-error-state-without-state-changes';
|
|
727
|
+
export {MigrateListItemHarnessContentLoader} from './libraries/material/migrate-list-item-harness-content-loader';
|
|
728
|
+
export {MigrateSelectionListChangeOption} from './libraries/material/migrate-selection-list-change-option';
|
|
729
|
+
export {RemoveMatStepperDocumentArgument} from './libraries/material/remove-mat-stepper-document-argument';
|
|
730
|
+
export {
|
|
731
|
+
FindMaterial10ConstructorChanges,
|
|
732
|
+
FindMaterial11ConstructorChanges,
|
|
733
|
+
FindMaterial12ConstructorChanges,
|
|
734
|
+
FindMaterial13ConstructorChanges,
|
|
735
|
+
FindMaterial14ConstructorChanges,
|
|
736
|
+
FindMaterial15ConstructorChanges,
|
|
737
|
+
FindMaterial8ConstructorChanges,
|
|
738
|
+
FindMaterial9ConstructorChanges
|
|
739
|
+
} from './libraries/material/find-material-constructor-changes';
|
|
@@ -4,9 +4,20 @@
|
|
|
4
4
|
* Moderne Proprietary. Only for use by Moderne customers under the terms of a commercial contract.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import {emptyMarkers, randomId} from "@openrewrite/rewrite";
|
|
7
|
+
import {emptyMarkers, Markers, MarkersKind, randomId, SearchResult} from "@openrewrite/rewrite";
|
|
8
8
|
import {JS} from "@openrewrite/rewrite/javascript";
|
|
9
|
-
import {emptySpace, Expression, isIdentifier, J} from "@openrewrite/rewrite/java";
|
|
9
|
+
import {emptySpace, Expression, isIdentifier, isLiteral, J} from "@openrewrite/rewrite/java";
|
|
10
|
+
|
|
11
|
+
/** Whether a tree carries a search result whose description contains `text`, which tells one recipe's marker from another's. */
|
|
12
|
+
export function hasSearchResult(tree: {markers: Markers}, text: string): boolean {
|
|
13
|
+
return tree.markers.markers.some(m => m.kind === MarkersKind.SearchResult && ((m as SearchResult).description ?? '').includes(text));
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** The name of an object property, written as an identifier or as a quoted string. */
|
|
17
|
+
export function propertyName(name: J | undefined): string | undefined {
|
|
18
|
+
if (name && isIdentifier(name)) return name.simpleName;
|
|
19
|
+
return name && isLiteral(name) && typeof name.value === 'string' ? name.value : undefined;
|
|
20
|
+
}
|
|
10
21
|
|
|
11
22
|
/** The argument list of a call without arguments, which the LST represents as one `J.Empty`. */
|
|
12
23
|
export function emptyArguments(container: J.Container<Expression>): J.Container<Expression> {
|
|
@@ -0,0 +1,80 @@
|
|
|
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 {Cursor, ExecutionContext, Recipe, Tree, TreeVisitor} from "@openrewrite/rewrite";
|
|
8
|
+
import {PlainText, PlainTextVisitor} from "@openrewrite/rewrite/text";
|
|
9
|
+
import {JavaScriptVisitor, JS} from "@openrewrite/rewrite/javascript";
|
|
10
|
+
import {J} from "@openrewrite/rewrite/java";
|
|
11
|
+
import {propertyName} from "./lst";
|
|
12
|
+
import {isStylesheet} from "./stylesheets";
|
|
13
|
+
import {requote} from "./templates";
|
|
14
|
+
|
|
15
|
+
/** Whether the source of a literal is a quoted string, rather than the text around an interpolation of a template string. */
|
|
16
|
+
function isWholeString(valueSource: string): boolean {
|
|
17
|
+
return /^(['"`])[\s\S]*\1$/.test(valueSource);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Whether a literal is the value of a `styles` property, directly or inside its array. */
|
|
21
|
+
function insideStyles(cursor: Cursor): boolean {
|
|
22
|
+
for (let c: Cursor | undefined = cursor.parent; c; c = c.parent) {
|
|
23
|
+
const value = c.value as any;
|
|
24
|
+
if (value?.kind === JS.Kind.PropertyAssignment) return propertyName(value.name?.element) === 'styles';
|
|
25
|
+
if (value?.kind === JS.Kind.CompilationUnit) return false;
|
|
26
|
+
}
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Applies `migrate` to a literal that is a whole stylesheet in the `styles` of a component. */
|
|
31
|
+
export function migrateInlineStyle(literal: J.Literal, cursor: Cursor, migrate: (content: string) => string): J.Literal {
|
|
32
|
+
if (typeof literal.value !== 'string' || !literal.valueSource || !isWholeString(literal.valueSource) || !insideStyles(cursor)) return literal;
|
|
33
|
+
const value = migrate(literal.value);
|
|
34
|
+
return value === literal.value ? literal : {...literal, value, valueSource: requote(literal.valueSource, value)} as J.Literal;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Rewrites the text of stylesheets, `.html` templates and TypeScript string literals, which hold inline templates and
|
|
39
|
+
* styles as well as selectors passed to calls such as `querySelector`.
|
|
40
|
+
*/
|
|
41
|
+
export abstract class RewriteStyleSources extends Recipe {
|
|
42
|
+
protected abstract rewrite(text: string): string;
|
|
43
|
+
|
|
44
|
+
async editor(): Promise<TreeVisitor<any, ExecutionContext>> {
|
|
45
|
+
const rewrite = (text: string) => this.rewrite(text);
|
|
46
|
+
const files = new class extends PlainTextVisitor<ExecutionContext> {
|
|
47
|
+
override async visitText(text: PlainText, p: ExecutionContext): Promise<PlainText | undefined> {
|
|
48
|
+
const t = await super.visitText(text, p) as PlainText;
|
|
49
|
+
if (!t || !(isStylesheet(t.sourcePath) || t.sourcePath.endsWith('.html'))) return t;
|
|
50
|
+
const updated = rewrite(t.text);
|
|
51
|
+
return updated === t.text ? t : {...t, text: updated, snippets: []};
|
|
52
|
+
}
|
|
53
|
+
}();
|
|
54
|
+
const literals = new class extends JavaScriptVisitor<ExecutionContext> {
|
|
55
|
+
protected async visitLiteral(literal: J.Literal, p: ExecutionContext): Promise<J | undefined> {
|
|
56
|
+
const l = await super.visitLiteral(literal, p) as J.Literal;
|
|
57
|
+
if (typeof l.value !== 'string' || !l.valueSource) return l;
|
|
58
|
+
const valueSource = rewrite(l.valueSource);
|
|
59
|
+
return valueSource === l.valueSource ? l : {...l, valueSource, value: rewrite(l.value)} as J.Literal;
|
|
60
|
+
}
|
|
61
|
+
}();
|
|
62
|
+
// Each visitor returns a source file it does not accept unchanged.
|
|
63
|
+
return new class extends TreeVisitor<any, ExecutionContext> {
|
|
64
|
+
async visit<R extends Tree>(tree: Tree, p: ExecutionContext, parent?: Cursor): Promise<R | undefined> {
|
|
65
|
+
const visited = await files.visit<Tree>(tree, p, parent);
|
|
66
|
+
return visited && await literals.visit(visited, p, parent) as R | undefined;
|
|
67
|
+
}
|
|
68
|
+
}();
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** Replaces each name with its new name where no name character follows, longest names first. */
|
|
73
|
+
export function renameNames(text: string, renames: Record<string, string>): string {
|
|
74
|
+
let updated = text;
|
|
75
|
+
for (const name of Object.keys(renames).sort((a, b) => b.length - a.length)) {
|
|
76
|
+
if (!updated.includes(name)) continue;
|
|
77
|
+
updated = updated.replace(new RegExp(`${name.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}(?![\\w-])`, 'g'), renames[name]);
|
|
78
|
+
}
|
|
79
|
+
return updated;
|
|
80
|
+
}
|
|
@@ -50,6 +50,43 @@ export function maskComments(content: string): string {
|
|
|
50
50
|
return content.replace(COMMENT, '');
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
+
function nestedParentheses(depth: number): string {
|
|
54
|
+
return depth === 0 ? '[^()]*' : `(?:[^()]|\\(${nestedParentheses(depth - 1)}\\))*`;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** A pattern for the text between the parentheses of a Sass call, with parentheses nested up to five levels deep. */
|
|
58
|
+
export const SASS_ARGUMENTS = nestedParentheses(5);
|
|
59
|
+
|
|
60
|
+
/** A pattern for the end of a Sass statement, whose `;` is optional when it is the last of its block. */
|
|
61
|
+
export const SASS_STATEMENT_END = '(?:\\s*;|(?=\\s*(?:\\}|$)))';
|
|
62
|
+
|
|
63
|
+
/** A Sass statement with its closing `;`, which a statement that had none needs once another one follows it. */
|
|
64
|
+
export function withSemicolon(statement: string): string {
|
|
65
|
+
return statement.endsWith(';') ? statement : `${statement};`;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** The offset of the `{` that opens the block around an offset of a stylesheet, or -1 at the top level. */
|
|
69
|
+
export function enclosingBlock(content: string, offset: number): number {
|
|
70
|
+
let depth = 0;
|
|
71
|
+
for (let i = offset - 1; i >= 0; i--) {
|
|
72
|
+
if (content[i] === '}') depth++;
|
|
73
|
+
else if (content[i] === '{' && depth-- === 0) return i;
|
|
74
|
+
}
|
|
75
|
+
return -1;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** Whether the block around an offset of a stylesheet includes a mixin with these arguments. */
|
|
79
|
+
export function includedInBlock(content: string, mixin: string, args: string, offset: number): boolean {
|
|
80
|
+
const include = new RegExp(`@include\\s+${escapeRegExp(mixin)}\\s*\\(\\s*${escapeRegExp(args.trim())}\\s*\\)`, 'g');
|
|
81
|
+
const block = enclosingBlock(content, offset);
|
|
82
|
+
return [...content.matchAll(include)].some(m => enclosingBlock(content, m.index) === block);
|
|
83
|
+
}
|
|
84
|
+
|
|
53
85
|
export function escapeRegExp(value: string): string {
|
|
54
86
|
return value.replace(/[.*+?^${}()|[\]\\/]/g, '\\$&');
|
|
55
87
|
}
|
|
88
|
+
|
|
89
|
+
/** An `@include` of a mixin with its arguments. */
|
|
90
|
+
export function includePattern(member: string): RegExp {
|
|
91
|
+
return new RegExp(`([ \\t]*)@include\\s+${escapeRegExp(member)}\\s*(?:\\((${SASS_ARGUMENTS})\\))?${SASS_STATEMENT_END}`, 'g');
|
|
92
|
+
}
|
|
@@ -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 {ExecutionContext, findMarker, foundSearchResult, MarkersKind, Recipe, TreeVisitor} from "@openrewrite/rewrite";
|
|
7
|
+
import {ExecutionContext, findMarker, foundSearchResult, MarkersKind, Option, Recipe, TreeVisitor} from "@openrewrite/rewrite";
|
|
8
8
|
import {ChangeImport, JavaScriptVisitor, JS} from "@openrewrite/rewrite/javascript";
|
|
9
9
|
import {isIdentifier, J} from "@openrewrite/rewrite/java";
|
|
10
10
|
|
|
@@ -23,14 +23,99 @@ export interface RemovedSymbol {
|
|
|
23
23
|
message: string;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
/**
|
|
26
|
+
/**
|
|
27
|
+
* One `ChangeImport` per renamed symbol, which also carries every reference bound to the import, plus a rename of
|
|
28
|
+
* namespace-qualified references and re-exports for symbols that stay in their module.
|
|
29
|
+
*/
|
|
27
30
|
export function renameSymbols(symbols: RenamedSymbol[]): Recipe[] {
|
|
28
|
-
return symbols.
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
return symbols.flatMap(s => [
|
|
32
|
+
new ChangeImport({
|
|
33
|
+
oldModule: s.module,
|
|
34
|
+
oldMember: s.name,
|
|
35
|
+
newModule: s.newModule ?? s.module,
|
|
36
|
+
newMember: s.newName,
|
|
37
|
+
}),
|
|
38
|
+
...(s.newModule && s.newModule !== s.module ? [] : [new RenameNamespacedSymbol({module: s.module, name: s.name, newName: s.newName})]),
|
|
39
|
+
]);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** Renames an exported symbol where `ChangeImport` does not reach it: `ns.Symbol` through a namespace import, and `export {Symbol} from` re-exports. */
|
|
43
|
+
export class RenameNamespacedSymbol extends Recipe {
|
|
44
|
+
readonly name = "org.openrewrite.angular.components.RenameNamespacedSymbol";
|
|
45
|
+
readonly displayName = "Rename a namespace-qualified or re-exported symbol";
|
|
46
|
+
readonly description = "Renames references to an exported symbol through a namespace import of its module, such " +
|
|
47
|
+
"as `ns.Symbol`, and named re-exports of it from that module.";
|
|
48
|
+
|
|
49
|
+
@Option({displayName: "Module", description: "The module that exports the symbol.", example: "@angular/material/button-toggle"})
|
|
50
|
+
module!: string;
|
|
51
|
+
|
|
52
|
+
@Option({displayName: "Name", description: "The current name of the symbol.", example: "MatButtonToggleGroupMultiple"})
|
|
53
|
+
symbolName!: string;
|
|
54
|
+
|
|
55
|
+
@Option({displayName: "New name", description: "The new name of the symbol.", example: "MatButtonToggleGroup"})
|
|
56
|
+
newName!: string;
|
|
57
|
+
|
|
58
|
+
constructor(options?: {module?: string; name?: string; newName?: string}) {
|
|
59
|
+
super();
|
|
60
|
+
this.module = options?.module ?? '';
|
|
61
|
+
this.symbolName = options?.name ?? '';
|
|
62
|
+
this.newName = options?.newName ?? '';
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
async editor(): Promise<TreeVisitor<any, ExecutionContext>> {
|
|
66
|
+
const {module, symbolName, newName} = this;
|
|
67
|
+
return new class extends JavaScriptVisitor<ExecutionContext> {
|
|
68
|
+
private namespaces = new Set<string>();
|
|
69
|
+
|
|
70
|
+
protected async visitJsCompilationUnit(cu: JS.CompilationUnit, p: ExecutionContext): Promise<J | undefined> {
|
|
71
|
+
this.namespaces = new Set(cu.statements.map(s => s.element)
|
|
72
|
+
.filter(s => s.kind === JS.Kind.Import && moduleOf(s as JS.Import) === module)
|
|
73
|
+
.map(s => (s as JS.Import).importClause?.namedBindings)
|
|
74
|
+
.filter((b): b is JS.Alias => b?.kind === JS.Kind.Alias)
|
|
75
|
+
.map(b => b.alias)
|
|
76
|
+
.filter(isIdentifier)
|
|
77
|
+
.map(alias => alias.simpleName));
|
|
78
|
+
return super.visitJsCompilationUnit(cu, p);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
protected async visitFieldAccess(fieldAccess: J.FieldAccess, p: ExecutionContext): Promise<J | undefined> {
|
|
82
|
+
const f = await super.visitFieldAccess(fieldAccess, p) as J.FieldAccess;
|
|
83
|
+
const name = f.name.element;
|
|
84
|
+
if (name.simpleName !== symbolName || !isIdentifier(f.target) || !this.namespaces.has(f.target.simpleName)) return f;
|
|
85
|
+
return {...f, name: {...f.name, element: {...name, simpleName: newName}}} as J.FieldAccess;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
protected async visitExportDeclaration(exportDeclaration: JS.ExportDeclaration, p: ExecutionContext): Promise<J | undefined> {
|
|
89
|
+
const e = await super.visitExportDeclaration(exportDeclaration, p) as JS.ExportDeclaration;
|
|
90
|
+
const specifier = e.moduleSpecifier?.element;
|
|
91
|
+
if (specifier?.kind !== J.Kind.Literal || (specifier as J.Literal).value !== module) return e;
|
|
92
|
+
if (e.exportClause?.kind !== JS.Kind.NamedExports) return e;
|
|
93
|
+
const named = e.exportClause as JS.NamedExports;
|
|
94
|
+
let changed = false;
|
|
95
|
+
const elements = named.elements.elements.map(element => {
|
|
96
|
+
const spec = element.element as JS.ExportSpecifier;
|
|
97
|
+
if (spec.kind !== JS.Kind.ExportSpecifier) return element;
|
|
98
|
+
const exported = spec.specifier;
|
|
99
|
+
if (isIdentifier(exported) && exported.simpleName === symbolName) {
|
|
100
|
+
changed = true;
|
|
101
|
+
return {...element, element: {...spec, specifier: {...exported, simpleName: newName}}};
|
|
102
|
+
}
|
|
103
|
+
if (exported.kind === JS.Kind.Alias) {
|
|
104
|
+
const alias = exported as JS.Alias;
|
|
105
|
+
const property = alias.propertyName.element;
|
|
106
|
+
if (isIdentifier(property) && property.simpleName === symbolName) {
|
|
107
|
+
changed = true;
|
|
108
|
+
const renamed = {...alias, propertyName: {...alias.propertyName, element: {...property, simpleName: newName}}};
|
|
109
|
+
return {...element, element: {...spec, specifier: renamed}};
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return element;
|
|
113
|
+
});
|
|
114
|
+
if (!changed) return e;
|
|
115
|
+
return {...e, exportClause: {...named, elements: {...named.elements, elements}}} as JS.ExportDeclaration;
|
|
116
|
+
}
|
|
117
|
+
}();
|
|
118
|
+
}
|
|
34
119
|
}
|
|
35
120
|
|
|
36
121
|
/** Local names that the imports of a compilation unit bind to the given symbols of the given module. */
|
|
@@ -93,12 +178,12 @@ export abstract class FindRemovedSymbols extends Recipe {
|
|
|
93
178
|
}
|
|
94
179
|
}
|
|
95
180
|
|
|
96
|
-
function moduleOf(imp: JS.Import): string | undefined {
|
|
181
|
+
export function moduleOf(imp: JS.Import): string | undefined {
|
|
97
182
|
const specifier = imp.moduleSpecifier?.element;
|
|
98
183
|
return specifier?.kind === J.Kind.Literal ? (specifier as J.Literal).value as string : undefined;
|
|
99
184
|
}
|
|
100
185
|
|
|
101
|
-
function importedName(spec: JS.ImportSpecifier): string | undefined {
|
|
186
|
+
export function importedName(spec: JS.ImportSpecifier): string | undefined {
|
|
102
187
|
const specifier = spec.specifier;
|
|
103
188
|
if (isIdentifier(specifier)) return specifier.simpleName;
|
|
104
189
|
if (specifier.kind === JS.Kind.Alias) {
|
|
@@ -0,0 +1,113 @@
|
|
|
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
|
+
/** An attribute of an opening tag, with offsets into the template. */
|
|
8
|
+
export interface TemplateAttribute {
|
|
9
|
+
/** The name as written, such as `[(ngModel)]` or `#slider`. */
|
|
10
|
+
name: string;
|
|
11
|
+
value?: string;
|
|
12
|
+
start: number;
|
|
13
|
+
end: number;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** An element of a template, with offsets into the template. */
|
|
17
|
+
export interface TemplateElement {
|
|
18
|
+
name: string;
|
|
19
|
+
start: number;
|
|
20
|
+
/** The offset right after the `>` of the opening tag. */
|
|
21
|
+
openEnd: number;
|
|
22
|
+
attributes: TemplateAttribute[];
|
|
23
|
+
/** The offsets of the closing tag, absent for void and self-closing elements. */
|
|
24
|
+
closeStart?: number;
|
|
25
|
+
closeEnd?: number;
|
|
26
|
+
parent?: TemplateElement;
|
|
27
|
+
children: TemplateElement[];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const VOID_ELEMENTS = new Set(['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'source', 'track', 'wbr']);
|
|
31
|
+
|
|
32
|
+
/** Parses the elements of an Angular template, skipping comments and honoring quoted attribute values. */
|
|
33
|
+
export function parseElements(template: string): TemplateElement[] {
|
|
34
|
+
const elements: TemplateElement[] = [];
|
|
35
|
+
const open: TemplateElement[] = [];
|
|
36
|
+
const tag = /<!--[\s\S]*?(?:-->|$)|<\/([a-zA-Z][\w-]*)\s*>|<([a-zA-Z][\w-]*)/g;
|
|
37
|
+
let match: RegExpExecArray | null;
|
|
38
|
+
while ((match = tag.exec(template)) !== null) {
|
|
39
|
+
if (match[1]) {
|
|
40
|
+
const name = match[1].toLowerCase();
|
|
41
|
+
const index = open.map(e => e.name).lastIndexOf(name);
|
|
42
|
+
if (index > -1) {
|
|
43
|
+
open[index].closeStart = match.index;
|
|
44
|
+
open[index].closeEnd = match.index + match[0].length;
|
|
45
|
+
open.length = index;
|
|
46
|
+
}
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
if (!match[2]) continue;
|
|
50
|
+
const {attributes, end, selfClosing} = parseAttributes(template, match.index + match[0].length);
|
|
51
|
+
const parent = open[open.length - 1];
|
|
52
|
+
const element: TemplateElement = {
|
|
53
|
+
name: match[2].toLowerCase(), start: match.index, openEnd: end, attributes, parent, children: [],
|
|
54
|
+
};
|
|
55
|
+
parent?.children.push(element);
|
|
56
|
+
elements.push(element);
|
|
57
|
+
if (!selfClosing && !VOID_ELEMENTS.has(element.name)) open.push(element);
|
|
58
|
+
tag.lastIndex = end;
|
|
59
|
+
}
|
|
60
|
+
return elements;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function parseAttributes(template: string, from: number): {attributes: TemplateAttribute[], end: number, selfClosing: boolean} {
|
|
64
|
+
const attributes: TemplateAttribute[] = [];
|
|
65
|
+
const attribute = /\s*(?:(\/?>)|([^\s=/>"']+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>"']+)))?|(\S))/y;
|
|
66
|
+
attribute.lastIndex = from;
|
|
67
|
+
let match: RegExpExecArray | null;
|
|
68
|
+
while ((match = attribute.exec(template)) !== null) {
|
|
69
|
+
if (match[1]) return {attributes, end: attribute.lastIndex, selfClosing: match[1] === '/>'};
|
|
70
|
+
if (match[2]) {
|
|
71
|
+
const start = attribute.lastIndex - match[0].trimStart().length;
|
|
72
|
+
attributes.push({name: match[2], value: match[3] ?? match[4] ?? match[5], start, end: attribute.lastIndex});
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return {attributes, end: template.length, selfClosing: false};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** The plain name of an attribute without binding syntax, such as `ngModel` for `[(ngModel)]`. */
|
|
79
|
+
export function bareName(attribute: TemplateAttribute): string {
|
|
80
|
+
return attribute.name.replace(/^(?:\[\(|\[|\(|bind-|on-|bindon-)/, '').replace(/(?:\)\]|\]|\))$/, '');
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export function attributeNamed(element: TemplateElement, name: string): TemplateAttribute | undefined {
|
|
84
|
+
return element.attributes.find(a => bareName(a) === name);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export function descendants(element: TemplateElement): TemplateElement[] {
|
|
88
|
+
return element.children.flatMap(child => [child, ...descendants(child)]);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** A replacement of the template text between two offsets. */
|
|
92
|
+
export interface TemplateEdit {
|
|
93
|
+
start: number;
|
|
94
|
+
end: number;
|
|
95
|
+
text: string;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** Applies edits that do not overlap, keeping the order of edits that insert at the same offset. */
|
|
99
|
+
export function applyEdits(template: string, edits: TemplateEdit[]): string {
|
|
100
|
+
const sorted = edits.map((edit, i) => ({edit, i}))
|
|
101
|
+
.sort((a, b) => b.edit.start - a.edit.start || b.edit.end - a.edit.end || b.i - a.i)
|
|
102
|
+
.map(({edit}) => edit);
|
|
103
|
+
let result = template;
|
|
104
|
+
for (const {start, end, text} of sorted) result = result.slice(0, start) + text + result.slice(end);
|
|
105
|
+
return result;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/** An edit that removes an attribute together with the whitespace before it. */
|
|
109
|
+
export function removeAttribute(template: string, attribute: TemplateAttribute): TemplateEdit {
|
|
110
|
+
let start = attribute.start;
|
|
111
|
+
while (start > 0 && /\s/.test(template[start - 1])) start--;
|
|
112
|
+
return {start, end: attribute.end, text: ''};
|
|
113
|
+
}
|
|
@@ -7,8 +7,9 @@
|
|
|
7
7
|
import {Cursor, ExecutionContext, Recipe, Tree, TreeVisitor} from "@openrewrite/rewrite";
|
|
8
8
|
import {PlainText, PlainTextVisitor} from "@openrewrite/rewrite/text";
|
|
9
9
|
import {JavaScriptVisitor} from "@openrewrite/rewrite/javascript";
|
|
10
|
-
import {
|
|
10
|
+
import {isLiteral, J} from "@openrewrite/rewrite/java";
|
|
11
11
|
import {create} from "mutative";
|
|
12
|
+
import {propertyName} from "./lst";
|
|
12
13
|
import {escapeRegExp} from "./stylesheets";
|
|
13
14
|
|
|
14
15
|
/** A directive selector or input that a major version renamed, as it appears in a template attribute. */
|
|
@@ -45,8 +46,7 @@ export abstract class RenameTemplateAttributes extends Recipe {
|
|
|
45
46
|
const inline = new class extends JavaScriptVisitor<ExecutionContext> {
|
|
46
47
|
protected async visitPropertyAssignment(property: any, p: ExecutionContext): Promise<J | undefined> {
|
|
47
48
|
const prop = await super.visitPropertyAssignment(property, p) as any;
|
|
48
|
-
|
|
49
|
-
if (!isIdentifier(name) || name.simpleName !== 'template') return prop;
|
|
49
|
+
if (propertyName(prop?.name?.element) !== 'template') return prop;
|
|
50
50
|
|
|
51
51
|
const initializer = prop.initializer;
|
|
52
52
|
if (!initializer || !isLiteral(initializer) || typeof initializer.value !== 'string') return prop;
|
|
@@ -94,8 +94,22 @@ function renameAttribute(attrs: string, name: string, newName: string): string {
|
|
|
94
94
|
return mapOutsideQuotes(attrs, segment => segment.replace(pattern, `$1$2${newName}`));
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
+
/** Quotes a migrated inline template with the delimiter of its original string literal. */
|
|
98
|
+
export function requote(valueSource: string, value: string): string {
|
|
99
|
+
const quote = valueSource[0];
|
|
100
|
+
let escaped = value.replace(/\\/g, '\\\\');
|
|
101
|
+
escaped = quote === '`' ? escaped.replace(/`/g, '\\`').replace(/\$\{/g, '\\${')
|
|
102
|
+
: escaped.replace(new RegExp(quote, 'g'), `\\${quote}`).replace(/\n/g, '\\n').replace(/\r/g, '\\r');
|
|
103
|
+
return `${quote}${escaped}${quote}`;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** A template without its comments, for checks that only care about live markup. */
|
|
107
|
+
export function withoutHtmlComments(template: string): string {
|
|
108
|
+
return template.replace(/<!--[\s\S]*?(?:-->|$)/g, '');
|
|
109
|
+
}
|
|
110
|
+
|
|
97
111
|
/** Calls `fn` for the attribute text of every opening tag, honoring quoted attribute values that contain `>`. */
|
|
98
|
-
function mapOpeningTags(template: string, fn: (tagName: string, attrs: string) => string): string {
|
|
112
|
+
export function mapOpeningTags(template: string, fn: (tagName: string, attrs: string) => string): string {
|
|
99
113
|
let result = '';
|
|
100
114
|
let index = 0;
|
|
101
115
|
const tagStart = /<([a-zA-Z][\w-]*)/g;
|