Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(inject-migration): ng CLI option name problem #403

Conversation

ilirbeqirii
Copy link
Contributor

@ilirbeqirii ilirbeqirii commented Jun 3, 2024

For the "inject-di-migration", a new option "useESPrivateFieldNotation" was added to support replacing TS "private" properties with ES private field properties.

However, an issue is found when executing the generator with the newly added option, and it's because of the option's name, "useESPrivateFieldNotation".

Running with Angular CLI

When running the schematic in a plain Angular app, i.e through Angular CLI with the "--help" option to get more insights about the schematic itself, we get the following:

ng-cli generator options Listed as the last one, besides the alias name provided in **schema json** , ngCLI also generates another, default alias: dash-separated name ( **--use-esprivate-field-notation** ).

Till now it's ok. but when we execute the schematic to do the work it's intended to and check the options at runtime, you can see that neither the alias nor the option name in the schema is being used:

ng-cli options at runtime

As you can notice, the original name option, "useESPrivateFieldNotation" is undefined, and ngCLI has created another option under the hood, "useEsprivateFieldNotation", which is the same as the original option name but with "...ESP..." subsection in lowercase:

                           useESPrivateFieldNotation -> useEsprivateFieldNotation

Because of this when running with Angular CLI, the schematic never applied the feature offered with that option.

Running with Nx

If you check the same config of the generator with Nx, there are no extra aliases generated, and naming is non-sensitive:

Screen Shot 2024-06-03 at 09 43 35

and the generator executes normally, see the options at runtime:

Screen Shot 2024-06-03 at 09 44 25

The fix

Use the same alias as the initial option name, but just update the option name internally at the source code.

@ilirbeqirii ilirbeqirii changed the title fix(inject-migration): update option name and add proper aliases fix(inject-migration): ng CLI option name problem Jun 3, 2024
@eneajaho eneajaho merged commit b4a3999 into ngxtension:main Jun 5, 2024
1 check passed
@ilirbeqirii ilirbeqirii deleted the fix-inject-migration-option-name-problem branch June 5, 2024 11:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants