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

Schematics: ng generate feature {folder}/{featureName} not working #1064

Closed
alexanderwende opened this issue May 14, 2018 · 1 comment
Closed

Comments

@alexanderwende
Copy link

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report  
[ ] Feature request
[ ] Documentation issue or request

What is the current behavior?

When trying to generate a feature in a module folder as described in the documentation...

ng generate module User
ng generate feature user/User -m user --group

...the produced actions, reducers and effects don't get generated in the module folder, but instead in the project root...

CREATE src/app/actions/user/user.actions.ts (274 bytes)
CREATE src/app/reducers/user/user.reducer.ts (411 bytes)
CREATE src/app/reducers/user/user.reducer.spec.ts (332 bytes)
CREATE src/app/effects/user/user.effects.ts (358 bytes)
CREATE src/app/effects/user/user.effects.spec.ts (607 bytes)
UPDATE src/app/user/user.module.ts (521 bytes)

...and the generated types in the actions, reducers and effects are treating the feature path user/User as type name. Here's what the users module looks like after that:

;
import { EffectsModule } from '@ngrx/effects';
import { User/UserEffects } from '../effects/user/user.effects'import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { StoreModule } from '@ngrx/store';
import * as fromUser/User from '../reducers/user/user.reducer';

@NgModule({
  imports: [
    CommonModule,
    StoreModule.forFeature('user/User', fromUser/User.reducer),
    EffectsModule.forFeature([User/UserEffects])
  ],
  declarations: []
})
export class UserModule { }

Another example, the generated actions:

import { Action } from '@ngrx/store';

export enum User/UserActionTypes {
  LoadUser/Users = '[User/User] Load User/Users'
}

export class User/User implements Action {
  readonly type = User/UserActionTypes.LoadUser/Users;
}

export type User/UserActions = LoadUser/Users;

Of course, the same happens for effects and reducers. I'll leave that out for brevity.

Expected behavior:

The feature files (actions, reducers, effects) should be generated inside the specified module folder and the path should be stripped off the feature name when generating the types.

Minimal reproduction of the problem with instructions:

  • generate a new angular/cli project
  • add ngrx/schematics following the docs including the initial state setup
  • generate a module ng generate module User
  • generate a feature ng generate feature user/User -m user --group

Version of affected browser(s),operating system(s), npm, node and ngrx:

node v9.11.1
npm 6.0.1
angular, ngrx on latest, package.json:

"dependencies": {
    "@angular/animations": "^6.0.0",
    "@angular/cdk": "^6.0.1",
    "@angular/common": "^6.0.0",
    "@angular/compiler": "^6.0.0",
    "@angular/core": "^6.0.0",
    "@angular/forms": "^6.0.0",
    "@angular/http": "^6.0.0",
    "@angular/platform-browser": "^6.0.0",
    "@angular/platform-browser-dynamic": "^6.0.0",
    "@angular/router": "^6.0.0",
    "@ngrx/effects": "^6.0.0-beta.3",
    "@ngrx/entity": "^6.0.0-beta.3",
    "@ngrx/router-store": "^6.0.0-beta.3",
    "@ngrx/store": "^6.0.0-beta.3",
    "@ngrx/store-devtools": "^6.0.0-beta.3",
    "core-js": "^2.5.4",
    "jwt-decode": "^2.2.0",
    "rxjs": "^6.0.0",
    "zone.js": "^0.8.26"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.6.1",
    "@angular/cli": "~6.0.1",
    "@angular/compiler-cli": "^6.0.0",
    "@angular/language-service": "^6.0.0",
    "@ngrx/schematics": "^6.0.0-beta.3",
    "@types/jasmine": "~2.8.6",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "~8.9.4",
    "body-parser": "^1.18.2",
    "codelyzer": "~4.2.1",
    "cors": "^2.8.4",
    "express": "^4.16.3",
    "jasmine-core": "~2.99.1",
    "jasmine-spec-reporter": "~4.2.1",
    "jsonwebtoken": "^8.2.1",
    "karma": "~1.7.1",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~1.4.2",
    "karma-jasmine": "~1.1.1",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.3.0",
    "ts-node": "~5.0.1",
    "tslint": "~5.9.1",
    "typescript": "~2.7.2"
  }
@mjh5153
Copy link

mjh5153 commented Jul 9, 2019

which version of ngrx schematics is this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants