Skip to content

Commit e86278a

Browse files
feat(schematics): remove creators option (#3311)
BREAKING CHANGES: BEFORE: Creating actions, reducers, and effects is possible without using the creator syntax is possible. AFTER: - All schematics use the non-creator syntax to scaffold the code. - The option `--creators` (and `-c`) is removed from the schematic options. - The `skipTests` option is removed while generating actions.
1 parent 9764634 commit e86278a

File tree

50 files changed

+460
-979
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+460
-979
lines changed

angular.json

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -757,12 +757,6 @@
757757
{
758758
"command": "cpy modules/schematics/src/**/files/**/*.* dist/ --parents"
759759
},
760-
{
761-
"command": "cpy modules/schematics/src/**/creator-files/**/*.* dist/ --parents"
762-
},
763-
{
764-
"command": "cpy modules/schematics/src/**/common-files/**/*.* dist/ --parents"
765-
},
766760
{
767761
"command": "cpy modules/schematics/src/**/integration-files/**/*.* dist/ --parents"
768762
},

modules/component-store/schematics-core/utility/ngrx-utils.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,6 @@ export function omit<T extends { [key: string]: any }>(
269269
.reduce((result, key) => Object.assign(result, { [key]: object[key] }), {});
270270
}
271271

272-
export function getPrefix(options: { prefix?: string; creators?: boolean }) {
273-
return options.creators
274-
? stringUtils.camelize(options.prefix || 'load')
275-
: stringUtils.capitalize(options.prefix || 'load');
272+
export function getPrefix(options: { prefix?: string }) {
273+
return stringUtils.camelize(options.prefix || 'load');
276274
}

modules/component/schematics-core/utility/ngrx-utils.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,6 @@ export function omit<T extends { [key: string]: any }>(
269269
.reduce((result, key) => Object.assign(result, { [key]: object[key] }), {});
270270
}
271271

272-
export function getPrefix(options: { prefix?: string; creators?: boolean }) {
273-
return options.creators
274-
? stringUtils.camelize(options.prefix || 'load')
275-
: stringUtils.capitalize(options.prefix || 'load');
272+
export function getPrefix(options: { prefix?: string }) {
273+
return stringUtils.camelize(options.prefix || 'load');
276274
}

modules/data/schematics-core/utility/ngrx-utils.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,6 @@ export function omit<T extends { [key: string]: any }>(
269269
.reduce((result, key) => Object.assign(result, { [key]: object[key] }), {});
270270
}
271271

272-
export function getPrefix(options: { prefix?: string; creators?: boolean }) {
273-
return options.creators
274-
? stringUtils.camelize(options.prefix || 'load')
275-
: stringUtils.capitalize(options.prefix || 'load');
272+
export function getPrefix(options: { prefix?: string }) {
273+
return stringUtils.camelize(options.prefix || 'load');
276274
}

modules/effects/schematics-core/utility/ngrx-utils.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,6 @@ export function omit<T extends { [key: string]: any }>(
269269
.reduce((result, key) => Object.assign(result, { [key]: object[key] }), {});
270270
}
271271

272-
export function getPrefix(options: { prefix?: string; creators?: boolean }) {
273-
return options.creators
274-
? stringUtils.camelize(options.prefix || 'load')
275-
: stringUtils.capitalize(options.prefix || 'load');
272+
export function getPrefix(options: { prefix?: string }) {
273+
return stringUtils.camelize(options.prefix || 'load');
276274
}

modules/entity/schematics-core/utility/ngrx-utils.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,6 @@ export function omit<T extends { [key: string]: any }>(
269269
.reduce((result, key) => Object.assign(result, { [key]: object[key] }), {});
270270
}
271271

272-
export function getPrefix(options: { prefix?: string; creators?: boolean }) {
273-
return options.creators
274-
? stringUtils.camelize(options.prefix || 'load')
275-
: stringUtils.capitalize(options.prefix || 'load');
272+
export function getPrefix(options: { prefix?: string }) {
273+
return stringUtils.camelize(options.prefix || 'load');
276274
}

modules/router-store/schematics-core/utility/ngrx-utils.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,6 @@ export function omit<T extends { [key: string]: any }>(
269269
.reduce((result, key) => Object.assign(result, { [key]: object[key] }), {});
270270
}
271271

272-
export function getPrefix(options: { prefix?: string; creators?: boolean }) {
273-
return options.creators
274-
? stringUtils.camelize(options.prefix || 'load')
275-
: stringUtils.capitalize(options.prefix || 'load');
272+
export function getPrefix(options: { prefix?: string }) {
273+
return stringUtils.camelize(options.prefix || 'load');
276274
}

modules/schematics-core/utility/ngrx-utils.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,6 @@ export function omit<T extends { [key: string]: any }>(
269269
.reduce((result, key) => Object.assign(result, { [key]: object[key] }), {});
270270
}
271271

272-
export function getPrefix(options: { prefix?: string; creators?: boolean }) {
273-
return options.creators
274-
? stringUtils.camelize(options.prefix || 'load')
275-
: stringUtils.capitalize(options.prefix || 'load');
272+
export function getPrefix(options: { prefix?: string }) {
273+
return stringUtils.camelize(options.prefix || 'load');
276274
}

modules/schematics/schematics-core/utility/ngrx-utils.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,6 @@ export function omit<T extends { [key: string]: any }>(
269269
.reduce((result, key) => Object.assign(result, { [key]: object[key] }), {});
270270
}
271271

272-
export function getPrefix(options: { prefix?: string; creators?: boolean }) {
273-
return options.creators
274-
? stringUtils.camelize(options.prefix || 'load')
275-
: stringUtils.capitalize(options.prefix || 'load');
272+
export function getPrefix(options: { prefix?: string }) {
273+
return stringUtils.camelize(options.prefix || 'load');
276274
}

modules/schematics/src/action/creator-files/__name@dasherize@if-flat__/__name@dasherize__.actions.spec.ts.template

Lines changed: 0 additions & 7 deletions
This file was deleted.

modules/schematics/src/action/creator-files/__name@dasherize@if-flat__/__name@dasherize__.actions.ts.template

Lines changed: 0 additions & 15 deletions
This file was deleted.

modules/schematics/src/action/files/__name@dasherize@if-flat__/__name@dasherize__.actions.spec.ts.template

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,15 @@
1-
import { Action } from '@ngrx/store';
1+
import { createAction, props } from '@ngrx/store';
22

3-
export enum <%= classify(name) %>ActionTypes {
4-
<%= prefix %><%= classify(name) %>s = '[<%= classify(name) %>] <%= prefix %> <%= classify(name) %>s',
5-
<% if (api) { %><%= prefix %><%= classify(name) %>sSuccess = '[<%= classify(name) %>] <%= prefix %> <%= classify(name) %>s Success',<% } %>
6-
<% if (api) { %><%= prefix %><%= classify(name) %>sFailure = '[<%= classify(name) %>] <%= prefix %> <%= classify(name) %>s Failure',<% } %>
7-
}
3+
export const <%= prefix %><%= classify(name) %>s = createAction(
4+
'[<%= classify(name) %>] <%= classify(prefix) %> <%= classify(name) %>s'
5+
);
86

9-
export class <%= prefix %><%= classify(name) %>s implements Action {
10-
readonly type = <%= classify(name) %>ActionTypes.<%= prefix %><%= classify(name) %>s;
11-
}
12-
<% if (api) { %>
13-
export class <%= prefix %><%= classify(name) %>sSuccess implements Action {
14-
readonly type = <%= classify(name) %>ActionTypes.<%= prefix %><%= classify(name) %>sSuccess;
15-
constructor(public payload: { data: any }) { }
16-
}
7+
<% if (api) { %>export const <%= prefix %><%= classify(name) %>sSuccess = createAction(
8+
'[<%= classify(name) %>] <%= classify(prefix) %> <%= classify(name) %>s Success',
9+
props<{ data: any }>()
10+
);<% } %>
1711

18-
export class <%= prefix %><%= classify(name) %>sFailure implements Action {
19-
readonly type = <%= classify(name) %>ActionTypes.<%= prefix %><%= classify(name) %>sFailure;
20-
constructor(public payload: { error: any }) { }
21-
}
22-
<% } %>
23-
<% if (api) { %>export type <%= classify(name) %>Actions = <%= prefix %><%= classify(name) %>s | <%= prefix %><%= classify(name) %>sSuccess | <%= prefix %><%= classify(name) %>sFailure;<% } %>
24-
<% if (!api) { %>export type <%= classify(name) %>Actions = <%= prefix %><%= classify(name) %>s;<% } %>
12+
<% if (api) { %>export const <%= prefix %><%= classify(name) %>sFailure = createAction(
13+
'[<%= classify(name) %>] <%= classify(prefix) %> <%= classify(name) %>s Failure',
14+
props<{ error: any }>()
15+
);<% } %>

0 commit comments

Comments
 (0)