x)- [x] bug report
x)- [x] generate
CLI v7.0.6
project as a required flag in class, guard and service-worker schematics JSON schemas.It creates wrong behavior in tools using schematics, which check the required flags to ask the user, like cyrilletuzi/vscode-angular-schematics#20.
project should be removed from required in schematics JSON schemas, as it's only an option (the CLI defaults to the main project).
Hi, the project is always required when running a schematic as without it the schematic will not execute successfully.
At the moment, when no project is provided and you use the schematics via the ng generate command. The default project is picked up and passed from Angular CLI to the schematics https://github.com/angular/angular-cli/blob/a3e3bb2524d51ca77c1f937ed6b1abca2ae6a4d7/packages/angular/cli/utilities/config.ts#L303
If you try to run the schematics directly without ng generate command such as when using the schematics cli you need to always provide the project name.
schematics @schematics/angular:class foo --project my-app
Looping in @hansl as he is more aware of this, but look to me that this is working as expected.
@alan-agius4 Thanks for your answer. I'm not aware of the raw schematics cli behavior, but it seems there is a problem somewhere: or project should be required in all schematics, or optional everywhere. Currently, it is required only in class, guard and service-worker schematics JSON schemas.
Then, do you confirm project as required is the expected behavior, so I should filter this flag in my project? Or will it be reversed, so no action needed on my side?
@cyrilletuzi, AFAIK this is the indented behaviour as in some cases when no Project is provided we throw an error, such as https://github.com/angular/angular-cli/blob/master/packages/schematics/angular/component/index.ts#L131
That said, I am not sure why project is not required in all schemas.
@alan-agius4 Thanks for the answer.
As a feedback for other tools maintainers, I discovered a similar problem with other options like target and configuration in service worker schematics, which are now marked as required too, despite the fact they have a default value in their schemas.
So I'll filtered required options if they have default or $default in their schemas.
Thanks again for your quick answer.
I think the issue is wider than expected and not resolved.
For example, ng g service-worker (with no option) is not working anymore, as --target and --configuration are now flagged as required, despite the fact they have a default in their schemas.
@alan-agius4 Is it the expected behavior?
@cyrilletuzi, that seems like a genuine bug.
@hansl should properties that have a default be present in the required (https://github.com/angular/angular-cli/blob/master/packages/schematics/angular/service-worker/schema.json)?
Hi, any news about this issue? Thanks.
There鈥檚 an open PR for address this.
@alan-agius4 I don't know why, but this issue stays in my Github opened issues list. Surely a Github bug, but could you please reopen and close this issue to try to clean this?
Seems my comment triggered something, all is OK now, thanks.
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
_This action has been performed automatically by a bot._
Most helpful comment
There鈥檚 an open PR for address this.