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

project wrongly in required flags in some schematics #13010

Closed
cyrilletuzi opened this issue Nov 20, 2018 · 11 comments · Fixed by #13377
Closed

project wrongly in required flags in some schematics #13010

cyrilletuzi opened this issue Nov 20, 2018 · 11 comments · Fixed by #13377
Labels
area: schematics/angular freq1: low Only reported by a handful of users who observe it rarely severity3: broken type: bug/fix
Milestone

Comments

@cyrilletuzi
Copy link
Contributor

Bug Report or Feature Request (mark with an x)

- [x] bug report

Command (mark with an x)

- [x] generate

Versions

CLI v7.0.6

The log given by the failure

#12196 wrongly added 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.

Desired functionality

project should be removed from required in schematics JSON schemas, as it's only an option (the CLI defaults to the main project).

@alan-agius4
Copy link
Collaborator

alan-agius4 commented Nov 20, 2018

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

project = project || getProjectByCwd(workspace);

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.

@ngbot ngbot bot added this to the needsTriage milestone Nov 20, 2018
@cyrilletuzi
Copy link
Contributor Author

cyrilletuzi commented Nov 20, 2018

@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?

@alan-agius4
Copy link
Collaborator

@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.

@cyrilletuzi
Copy link
Contributor Author

@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.

@cyrilletuzi
Copy link
Contributor Author

cyrilletuzi commented Nov 20, 2018

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?

@alan-agius4
Copy link
Collaborator

alan-agius4 commented Nov 20, 2018

@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)?

@alan-agius4 alan-agius4 added freq1: low Only reported by a handful of users who observe it rarely severity3: broken type: bug/fix labels Nov 20, 2018
@ngbot ngbot bot modified the milestones: needsTriage, Backlog Nov 20, 2018
@cyrilletuzi
Copy link
Contributor Author

Hi, any news about this issue? Thanks.

@alan-agius4
Copy link
Collaborator

There’s an open PR for address this.

kyliau pushed a commit that referenced this issue Jan 11, 2019
…from required

At the moment, these would end up being required to be passed even though a default is provided.

Fixes #13010
kyliau pushed a commit that referenced this issue Jan 11, 2019
…from required

At the moment, these would end up being required to be passed even though a default is provided.

Fixes #13010
@cyrilletuzi
Copy link
Contributor Author

@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?

@cyrilletuzi
Copy link
Contributor Author

Seems my comment triggered something, all is OK now, thanks.

@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: schematics/angular freq1: low Only reported by a handful of users who observe it rarely severity3: broken type: bug/fix
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants