ngxtension/ngxtension-platform

feat: migrate field (component field or input) to signal

eneajaho opened this issue · 1 comments

  • Per file and per component and per field
    ng g ngxtension:convert-di-to-inject --path $FilePathRelativeToProjectRoot$ --field $SelectedText$

Same thing can be done using vscode tasks: https://code.visualstudio.com/docs/editor/variables-reference#_predefined-variables

This can be a one-click thing in webstorm where you select the field and click the run button in the top bar run configurations.

Screenshot 2024-06-13 at 3 43 28 PM

The migration will follow this steps:

  • Check if it's already a signal -> skip
  • convert the field to signal
  • find the usages and if it's being assigned use set or update depending on the use case
  • replace only reads to include () -> we already do this for signal inputs
  • replace the template references -> we already do this for signal inputs

At this point we can easily migrate to signals by select a field and running a migration schematic

This should work for most of the cases and fail for some advanced ones, but we're not reaching for perfection here 😄