Angular-cli: Allow to override schematics files for default library individually

Created on 13 Nov 2018  路  4Comments  路  Source: angular/angular-cli

Bug Report or Feature Request (mark with an x)

- [ ] bug report -> please search issues before submitting
- [x] feature request

Command (mark with an x)

- [x] new
- [ ] build
- [ ] serve
- [ ] test
- [ ] e2e
- [x] generate
- [x] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Versions

node: v8.12.0
npm: 6.4.1
ng:

Angular CLI: 6.2.3
Node: 8.12.0
OS: win32 x64
Angular:
...

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.8.3
@angular-devkit/core         0.8.3
@angular-devkit/schematics   0.8.3
@schematics/angular          0.8.3
@schematics/update           0.8.3
rxjs                         6.2.2
typescript                   2.9.2

Desired functionality

I would like to override a single schematic in the default angular schematics. In my case, I would like to replace the spec files with a custom Jest optimized file instead of the Jasmine file. One thing I notice I could do with Jest, is to resolve promises using async/await, but the current schematics uses async function instead.

I don't want to create a package just to change one schematics, but just to configure the Angular CLI to read a custom schematic when it would create a file that I want to override.

Mention any other details that might be useful

angulacli feature

Most helpful comment

The same use case here. Ideally, I'd like to change the way *.component.spec.ts files are generated.

All 4 comments

I have almost the same exact use-case as you. I have some default stuff I want to change in the default templates, and I'd like to support everything the default templates do options/schema-wise, but just be able to tweak the output, but it doesn't seem as though this is possible. :(

The same use case here. Ideally, I'd like to change the way *.component.spec.ts files are generated.

Same issues here. I want my spec files to use Jest and Spectator, which is possible with spectator's schematics. However, in order to use the custom schematics, it requires a different command than the default. In this case, I have to generate my components with ng g cs <comp-name> instead of ng g c <comp-name>. It can be challenging to re-educate all the devs working on the project to use the different generator. It also means we only have whatever options are given by Spectator's schematic, which doesn't necessarily include all the options in the default component schematic. For example, Spectator's component schematic doesn't have a --spec-only flag, which I would find very useful.

We have a requirement to place spec files in a test folder outside of src/app. It would be nice for developers to use the same generate commands e.g.ng g c <name> but have it use an overridden version of the default schematic.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sysmat picture sysmat  路  3Comments

JanStureNielsen picture JanStureNielsen  路  3Comments

daBishMan picture daBishMan  路  3Comments

delasteve picture delasteve  路  3Comments

rajjejosefsson picture rajjejosefsson  路  3Comments