[ ] Regression (a behavior that used to work and stopped working in a new release)
[ x ] Bug report
[ ] Feature request
[ ] Documentation issue or request
I am seeing an error when trying to create a new store on a sub-module. Currently it seems to just try and create a store for the root application instead of the sub-module I pointed it at.
It should create a store for my sub-module.
I haven't added much to my existing application than the CLI created so far. So I guess:
1) create a new project form the ngCLI
2) Add ngrx schematic
3) have it generate the root store and reducers using ng generate store State --root --module app.module.ts
4) create a sub-module using the ng CLI
5) try and add a store using the schematic for the sub-module
Angular CLI: 1.7.4
Node: 10.0.0
OS: darwin x64
Angular: 5.2.10
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router
@angular/cli: 1.7.4
@angular-devkit/build-optimizer: 0.3.2
@angular-devkit/core: 0.3.2
@angular-devkit/schematics: 0.3.2
@ngtools/json-schema: 1.2.0
@ngtools/webpack: 1.10.2
@schematics/angular: 0.3.2
@schematics/package-update: 0.3.2
typescript: 2.5.3
webpack: 3.11.0
ng generate module auth --flat false
create src/app/auth/auth.module.ts (188 bytes)
ng generate store Auth -m auth/auth.module.ts
error! src/app/reducers/index.ts already exists.
Maybe I just missed something? If you think I did just poke me in the right direction hopefully?
I've just followed the instructions at the schematics docs and it seems like you're right.
I don't know if this is fixable atm since the master is at v6.
But, a workaround is to cd into the module folder.
So in your case it should be:
ng generate module auth --flat false
cd src/app/auth
ng generate store Auth -m auth/auth.module.ts
This workaround will be fine for me. Hopefully, a solution to restore documented functionality can be found at some point though.
What version of schematics are you on? I know this worked previously with the example in the docs
ng generate module admin --flat false
ng generate store admin/Admin -m admin/admin.module.ts
I could reproduce it with:
Angular Cli 1.7.4
Angular-devkit schematics: 0.3.2
Ngrx schematics 5.2
If you want I could create a repo.
ngrx/schematics: ^5.2.0
angular-devkit/schematics: 0.3.2
Angular CLI: 1.7.4
Node 10.0.0 on my machine
No repro needed. Something may have changed on how paths are constructed.
Specifically using ng generate store admin/Admin -m admin/admin.module.ts where it's specifically admin/Admin as the module seems to work. The documented way as per https://github.com/ngrx/platform/blob/master/docs/schematics/store.md is just a single Admin.
I see. Can you submit a PR for the docs? We'll assist if you need help.
I can if that is the expected method. I will do that now and hope to have a PR after my lunch.