Skip to content

Commit

Permalink
feat(schematics): remove creators option (#3311)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
timdeschryver committed May 27, 2022
1 parent 9764634 commit e86278a
Show file tree
Hide file tree
Showing 50 changed files with 460 additions and 979 deletions.
6 changes: 0 additions & 6 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -757,12 +757,6 @@
{
"command": "cpy modules/schematics/src/**/files/**/*.* dist/ --parents"
},
{
"command": "cpy modules/schematics/src/**/creator-files/**/*.* dist/ --parents"
},
{
"command": "cpy modules/schematics/src/**/common-files/**/*.* dist/ --parents"
},
{
"command": "cpy modules/schematics/src/**/integration-files/**/*.* dist/ --parents"
},
Expand Down
6 changes: 2 additions & 4 deletions modules/component-store/schematics-core/utility/ngrx-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,6 @@ export function omit<T extends { [key: string]: any }>(
.reduce((result, key) => Object.assign(result, { [key]: object[key] }), {});
}

export function getPrefix(options: { prefix?: string; creators?: boolean }) {
return options.creators
? stringUtils.camelize(options.prefix || 'load')
: stringUtils.capitalize(options.prefix || 'load');
export function getPrefix(options: { prefix?: string }) {
return stringUtils.camelize(options.prefix || 'load');
}
6 changes: 2 additions & 4 deletions modules/component/schematics-core/utility/ngrx-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,6 @@ export function omit<T extends { [key: string]: any }>(
.reduce((result, key) => Object.assign(result, { [key]: object[key] }), {});
}

export function getPrefix(options: { prefix?: string; creators?: boolean }) {
return options.creators
? stringUtils.camelize(options.prefix || 'load')
: stringUtils.capitalize(options.prefix || 'load');
export function getPrefix(options: { prefix?: string }) {
return stringUtils.camelize(options.prefix || 'load');
}
6 changes: 2 additions & 4 deletions modules/data/schematics-core/utility/ngrx-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,6 @@ export function omit<T extends { [key: string]: any }>(
.reduce((result, key) => Object.assign(result, { [key]: object[key] }), {});
}

export function getPrefix(options: { prefix?: string; creators?: boolean }) {
return options.creators
? stringUtils.camelize(options.prefix || 'load')
: stringUtils.capitalize(options.prefix || 'load');
export function getPrefix(options: { prefix?: string }) {
return stringUtils.camelize(options.prefix || 'load');
}
6 changes: 2 additions & 4 deletions modules/effects/schematics-core/utility/ngrx-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,6 @@ export function omit<T extends { [key: string]: any }>(
.reduce((result, key) => Object.assign(result, { [key]: object[key] }), {});
}

export function getPrefix(options: { prefix?: string; creators?: boolean }) {
return options.creators
? stringUtils.camelize(options.prefix || 'load')
: stringUtils.capitalize(options.prefix || 'load');
export function getPrefix(options: { prefix?: string }) {
return stringUtils.camelize(options.prefix || 'load');
}
6 changes: 2 additions & 4 deletions modules/entity/schematics-core/utility/ngrx-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,6 @@ export function omit<T extends { [key: string]: any }>(
.reduce((result, key) => Object.assign(result, { [key]: object[key] }), {});
}

export function getPrefix(options: { prefix?: string; creators?: boolean }) {
return options.creators
? stringUtils.camelize(options.prefix || 'load')
: stringUtils.capitalize(options.prefix || 'load');
export function getPrefix(options: { prefix?: string }) {
return stringUtils.camelize(options.prefix || 'load');
}
6 changes: 2 additions & 4 deletions modules/router-store/schematics-core/utility/ngrx-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,6 @@ export function omit<T extends { [key: string]: any }>(
.reduce((result, key) => Object.assign(result, { [key]: object[key] }), {});
}

export function getPrefix(options: { prefix?: string; creators?: boolean }) {
return options.creators
? stringUtils.camelize(options.prefix || 'load')
: stringUtils.capitalize(options.prefix || 'load');
export function getPrefix(options: { prefix?: string }) {
return stringUtils.camelize(options.prefix || 'load');
}
6 changes: 2 additions & 4 deletions modules/schematics-core/utility/ngrx-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,6 @@ export function omit<T extends { [key: string]: any }>(
.reduce((result, key) => Object.assign(result, { [key]: object[key] }), {});
}

export function getPrefix(options: { prefix?: string; creators?: boolean }) {
return options.creators
? stringUtils.camelize(options.prefix || 'load')
: stringUtils.capitalize(options.prefix || 'load');
export function getPrefix(options: { prefix?: string }) {
return stringUtils.camelize(options.prefix || 'load');
}
6 changes: 2 additions & 4 deletions modules/schematics/schematics-core/utility/ngrx-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,6 @@ export function omit<T extends { [key: string]: any }>(
.reduce((result, key) => Object.assign(result, { [key]: object[key] }), {});
}

export function getPrefix(options: { prefix?: string; creators?: boolean }) {
return options.creators
? stringUtils.camelize(options.prefix || 'load')
: stringUtils.capitalize(options.prefix || 'load');
export function getPrefix(options: { prefix?: string }) {
return stringUtils.camelize(options.prefix || 'load');
}

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,24 +1,15 @@
import { Action } from '@ngrx/store';
import { createAction, props } from '@ngrx/store';

export enum <%= classify(name) %>ActionTypes {
<%= prefix %><%= classify(name) %>s = '[<%= classify(name) %>] <%= prefix %> <%= classify(name) %>s',
<% if (api) { %><%= prefix %><%= classify(name) %>sSuccess = '[<%= classify(name) %>] <%= prefix %> <%= classify(name) %>s Success',<% } %>
<% if (api) { %><%= prefix %><%= classify(name) %>sFailure = '[<%= classify(name) %>] <%= prefix %> <%= classify(name) %>s Failure',<% } %>
}
export const <%= prefix %><%= classify(name) %>s = createAction(
'[<%= classify(name) %>] <%= classify(prefix) %> <%= classify(name) %>s'
);

export class <%= prefix %><%= classify(name) %>s implements Action {
readonly type = <%= classify(name) %>ActionTypes.<%= prefix %><%= classify(name) %>s;
}
<% if (api) { %>
export class <%= prefix %><%= classify(name) %>sSuccess implements Action {
readonly type = <%= classify(name) %>ActionTypes.<%= prefix %><%= classify(name) %>sSuccess;
constructor(public payload: { data: any }) { }
}
<% if (api) { %>export const <%= prefix %><%= classify(name) %>sSuccess = createAction(
'[<%= classify(name) %>] <%= classify(prefix) %> <%= classify(name) %>s Success',
props<{ data: any }>()
);<% } %>

export class <%= prefix %><%= classify(name) %>sFailure implements Action {
readonly type = <%= classify(name) %>ActionTypes.<%= prefix %><%= classify(name) %>sFailure;
constructor(public payload: { error: any }) { }
}
<% } %>
<% if (api) { %>export type <%= classify(name) %>Actions = <%= prefix %><%= classify(name) %>s | <%= prefix %><%= classify(name) %>sSuccess | <%= prefix %><%= classify(name) %>sFailure;<% } %>
<% if (!api) { %>export type <%= classify(name) %>Actions = <%= prefix %><%= classify(name) %>s;<% } %>
<% if (api) { %>export const <%= prefix %><%= classify(name) %>sFailure = createAction(
'[<%= classify(name) %>] <%= classify(prefix) %> <%= classify(name) %>s Failure',
props<{ error: any }>()
);<% } %>

0 comments on commit e86278a

Please sign in to comment.