diff --git a/modules/effects/schematics-core/utility/ngrx-utils.ts b/modules/effects/schematics-core/utility/ngrx-utils.ts index 56ee0b4cf3..18f0aa095c 100644 --- a/modules/effects/schematics-core/utility/ngrx-utils.ts +++ b/modules/effects/schematics-core/utility/ngrx-utils.ts @@ -90,10 +90,10 @@ export function addReducerToStateInterface( return new NoopChange(); } - const state = - options.plural === undefined - ? stringUtils.camelize(options.name) - : stringUtils.camelize(options.name) + 's'; + let state = stringUtils.camelize(options.name); + if (options.plural) { + state = stringUtils.camelize(options.name) + 's'; + } const keyInsert = state + ': from' + stringUtils.classify(options.name) + '.State;'; @@ -154,10 +154,10 @@ export function addReducerToActionReducerMap( let node = actionReducerMap.initializer; - const state = - options.plural === undefined - ? stringUtils.camelize(options.name) - : stringUtils.camelize(options.name) + 's'; + let state = stringUtils.camelize(options.name); + if (options.plural) { + state = stringUtils.camelize(options.name) + 's'; + } const keyInsert = state + ': from' + stringUtils.classify(options.name) + '.reducer,'; diff --git a/modules/entity/schematics-core/utility/ngrx-utils.ts b/modules/entity/schematics-core/utility/ngrx-utils.ts index 56ee0b4cf3..18f0aa095c 100644 --- a/modules/entity/schematics-core/utility/ngrx-utils.ts +++ b/modules/entity/schematics-core/utility/ngrx-utils.ts @@ -90,10 +90,10 @@ export function addReducerToStateInterface( return new NoopChange(); } - const state = - options.plural === undefined - ? stringUtils.camelize(options.name) - : stringUtils.camelize(options.name) + 's'; + let state = stringUtils.camelize(options.name); + if (options.plural) { + state = stringUtils.camelize(options.name) + 's'; + } const keyInsert = state + ': from' + stringUtils.classify(options.name) + '.State;'; @@ -154,10 +154,10 @@ export function addReducerToActionReducerMap( let node = actionReducerMap.initializer; - const state = - options.plural === undefined - ? stringUtils.camelize(options.name) - : stringUtils.camelize(options.name) + 's'; + let state = stringUtils.camelize(options.name); + if (options.plural) { + state = stringUtils.camelize(options.name) + 's'; + } const keyInsert = state + ': from' + stringUtils.classify(options.name) + '.reducer,'; diff --git a/modules/router-store/schematics-core/utility/ngrx-utils.ts b/modules/router-store/schematics-core/utility/ngrx-utils.ts index 56ee0b4cf3..18f0aa095c 100644 --- a/modules/router-store/schematics-core/utility/ngrx-utils.ts +++ b/modules/router-store/schematics-core/utility/ngrx-utils.ts @@ -90,10 +90,10 @@ export function addReducerToStateInterface( return new NoopChange(); } - const state = - options.plural === undefined - ? stringUtils.camelize(options.name) - : stringUtils.camelize(options.name) + 's'; + let state = stringUtils.camelize(options.name); + if (options.plural) { + state = stringUtils.camelize(options.name) + 's'; + } const keyInsert = state + ': from' + stringUtils.classify(options.name) + '.State;'; @@ -154,10 +154,10 @@ export function addReducerToActionReducerMap( let node = actionReducerMap.initializer; - const state = - options.plural === undefined - ? stringUtils.camelize(options.name) - : stringUtils.camelize(options.name) + 's'; + let state = stringUtils.camelize(options.name); + if (options.plural) { + state = stringUtils.camelize(options.name) + 's'; + } const keyInsert = state + ': from' + stringUtils.classify(options.name) + '.reducer,'; diff --git a/modules/schematics-core/utility/ngrx-utils.ts b/modules/schematics-core/utility/ngrx-utils.ts index 56ee0b4cf3..18f0aa095c 100644 --- a/modules/schematics-core/utility/ngrx-utils.ts +++ b/modules/schematics-core/utility/ngrx-utils.ts @@ -90,10 +90,10 @@ export function addReducerToStateInterface( return new NoopChange(); } - const state = - options.plural === undefined - ? stringUtils.camelize(options.name) - : stringUtils.camelize(options.name) + 's'; + let state = stringUtils.camelize(options.name); + if (options.plural) { + state = stringUtils.camelize(options.name) + 's'; + } const keyInsert = state + ': from' + stringUtils.classify(options.name) + '.State;'; @@ -154,10 +154,10 @@ export function addReducerToActionReducerMap( let node = actionReducerMap.initializer; - const state = - options.plural === undefined - ? stringUtils.camelize(options.name) - : stringUtils.camelize(options.name) + 's'; + let state = stringUtils.camelize(options.name); + if (options.plural) { + state = stringUtils.camelize(options.name) + 's'; + } const keyInsert = state + ': from' + stringUtils.classify(options.name) + '.reducer,'; diff --git a/modules/schematics/schematics-core/utility/ngrx-utils.ts b/modules/schematics/schematics-core/utility/ngrx-utils.ts index 56ee0b4cf3..18f0aa095c 100644 --- a/modules/schematics/schematics-core/utility/ngrx-utils.ts +++ b/modules/schematics/schematics-core/utility/ngrx-utils.ts @@ -90,10 +90,10 @@ export function addReducerToStateInterface( return new NoopChange(); } - const state = - options.plural === undefined - ? stringUtils.camelize(options.name) - : stringUtils.camelize(options.name) + 's'; + let state = stringUtils.camelize(options.name); + if (options.plural) { + state = stringUtils.camelize(options.name) + 's'; + } const keyInsert = state + ': from' + stringUtils.classify(options.name) + '.State;'; @@ -154,10 +154,10 @@ export function addReducerToActionReducerMap( let node = actionReducerMap.initializer; - const state = - options.plural === undefined - ? stringUtils.camelize(options.name) - : stringUtils.camelize(options.name) + 's'; + let state = stringUtils.camelize(options.name); + if (options.plural) { + state = stringUtils.camelize(options.name) + 's'; + } const keyInsert = state + ': from' + stringUtils.classify(options.name) + '.reducer,'; diff --git a/modules/schematics/src/entity/index.spec.ts b/modules/schematics/src/entity/index.spec.ts index fb23e2cfeb..3933d604b6 100644 --- a/modules/schematics/src/entity/index.spec.ts +++ b/modules/schematics/src/entity/index.spec.ts @@ -162,7 +162,7 @@ describe('Entity Schematic', () => { ).toBeGreaterThanOrEqual(0); }); - it('should create all files of an entity within grouped and nested folders', () => { + it('should update the state to plural', () => { const options = { ...defaultOptions, name: 'user', diff --git a/modules/schematics/src/entity/index.ts b/modules/schematics/src/entity/index.ts index bbdf70be63..9cf5572a09 100644 --- a/modules/schematics/src/entity/index.ts +++ b/modules/schematics/src/entity/index.ts @@ -31,7 +31,6 @@ export default function(options: EntityOptions): Rule { const parsedPath = parseName(options.path, options.name); options.name = parsedPath.name; options.path = parsedPath.path; - options.plural = true; if (options.module) { options.module = findModuleFromOptions(host, options); @@ -56,7 +55,7 @@ export default function(options: EntityOptions): Rule { ]); return chain([ - addReducerToState({ ...options }), + addReducerToState({ ...options, plural: true }), addReducerImportToNgModule({ ...options }), branchAndMerge(chain([mergeWith(templateSource)])), ])(host, context); diff --git a/modules/schematics/src/entity/schema.json b/modules/schematics/src/entity/schema.json index 7fe33e9b50..0bd229520c 100644 --- a/modules/schematics/src/entity/schema.json +++ b/modules/schematics/src/entity/schema.json @@ -49,11 +49,6 @@ "description": "Group actions, reducers and effects within relative subfolders", "aliases": ["g"] - }, - "plural": { - "type": "boolean", - "default": true, - "description": "Update state with plural." } }, "required": [] diff --git a/modules/schematics/src/entity/schema.ts b/modules/schematics/src/entity/schema.ts index 98cce4d77d..82b0f13ffe 100644 --- a/modules/schematics/src/entity/schema.ts +++ b/modules/schematics/src/entity/schema.ts @@ -36,9 +36,4 @@ export interface Schema { */ group?: boolean; - /** - * Specifies if this is state and reducer variable will be plural - */ - - plural?: boolean; } diff --git a/modules/store-devtools/schematics-core/utility/ngrx-utils.ts b/modules/store-devtools/schematics-core/utility/ngrx-utils.ts index 56ee0b4cf3..18f0aa095c 100644 --- a/modules/store-devtools/schematics-core/utility/ngrx-utils.ts +++ b/modules/store-devtools/schematics-core/utility/ngrx-utils.ts @@ -90,10 +90,10 @@ export function addReducerToStateInterface( return new NoopChange(); } - const state = - options.plural === undefined - ? stringUtils.camelize(options.name) - : stringUtils.camelize(options.name) + 's'; + let state = stringUtils.camelize(options.name); + if (options.plural) { + state = stringUtils.camelize(options.name) + 's'; + } const keyInsert = state + ': from' + stringUtils.classify(options.name) + '.State;'; @@ -154,10 +154,10 @@ export function addReducerToActionReducerMap( let node = actionReducerMap.initializer; - const state = - options.plural === undefined - ? stringUtils.camelize(options.name) - : stringUtils.camelize(options.name) + 's'; + let state = stringUtils.camelize(options.name); + if (options.plural) { + state = stringUtils.camelize(options.name) + 's'; + } const keyInsert = state + ': from' + stringUtils.classify(options.name) + '.reducer,'; diff --git a/modules/store/schematics-core/utility/ngrx-utils.ts b/modules/store/schematics-core/utility/ngrx-utils.ts index 56ee0b4cf3..18f0aa095c 100644 --- a/modules/store/schematics-core/utility/ngrx-utils.ts +++ b/modules/store/schematics-core/utility/ngrx-utils.ts @@ -90,10 +90,10 @@ export function addReducerToStateInterface( return new NoopChange(); } - const state = - options.plural === undefined - ? stringUtils.camelize(options.name) - : stringUtils.camelize(options.name) + 's'; + let state = stringUtils.camelize(options.name); + if (options.plural) { + state = stringUtils.camelize(options.name) + 's'; + } const keyInsert = state + ': from' + stringUtils.classify(options.name) + '.State;'; @@ -154,10 +154,10 @@ export function addReducerToActionReducerMap( let node = actionReducerMap.initializer; - const state = - options.plural === undefined - ? stringUtils.camelize(options.name) - : stringUtils.camelize(options.name) + 's'; + let state = stringUtils.camelize(options.name); + if (options.plural) { + state = stringUtils.camelize(options.name) + 's'; + } const keyInsert = state + ': from' + stringUtils.classify(options.name) + '.reducer,';