x)- [ ] new
- [ ] build
- [ ] serve
- [ ] test
- [ ] e2e
- [x] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc
Some of ng g schematic commands have --flat=true|false option but some others don't, i.e. ng g class. Please add that option to all schematic commands because as a developer want to have classes and their .spec files together in separate directories.
The solution is very simple, just define that option to all schematic commands, please.
A workaround is first to create a folder and open a terminal in that directory, then run the command. This hurts!
Thanks, everyone 馃槝
Makes sense from consistency point of view. @clydin @alan-agius4 any comments?
While I do agree that this is a bit confusing that some offer flat and some not,
You can achieve the desired output by providing the path together with the class name.
Example
ng g class buz/foo
CREATE src/app/buz/foo.spec.ts (142 bytes)
CREATE src/app/buz/foo.ts (21 bytes)
or using the --path option
ng g class foo --path bar
CREATE bar/foo.spec.ts (142 bytes)
CREATE bar/foo.ts (21 bytes)
I do agree that we should try to align all schematics to have same options as much as possible. However, this case would be a breaking change as adding a flat option to the class schematic will change the current behaviour, As by default flat is false. which means that users using ng g class foo will end up with /src/foo/foo.ts, instead of the current /src/foo.ts.
While we can change the default value of the flat option for the class schematic, this will be more confused that some flat options are true and some are false by default.
Flat being false by default for components will, IMO, not be ideal from DX perspective. The common scenario, folks don't want to generate their class inside of a directory. Having to specify every time --flat true would increase verbosity.
Given that this would also be a breaking change, I'd suggest to keep the proposal out of the scope of the CLI for now.
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._