From 5e9d3193297c22f8b9aaf7bdf6c1fbd02962c781 Mon Sep 17 00:00:00 2001 From: Santosh Yadav Date: Wed, 27 Feb 2019 00:51:36 +0530 Subject: [PATCH 01/10] fix(schematics):Schematics: rename template files to avoid compilation --- .../__name@dasherize__.actions.ts.template | 24 ++++++ .../__name@dasherize__.effects.ts.template | 38 ++++++++ ...herize@group-actions__.actions.ts.template | 86 +++++++++++++++++++ ...dasherize@group-models__.model.ts.template | 3 + ...erize@group-reducers__.reducer.ts.template | 71 +++++++++++++++ .../__name@dasherize__.reducer.ts.template | 27 ++++++ .../files/__statePath__/index.ts.template | 19 ++++ 7 files changed, 268 insertions(+) create mode 100644 modules/schematics/src/action/files/__name@dasherize@if-flat__/__name@dasherize__.actions.ts.template create mode 100644 modules/schematics/src/effect/files/__name@dasherize@if-flat__/__name@dasherize__.effects.ts.template create mode 100644 modules/schematics/src/entity/files/__name@dasherize@if-flat__/__name@dasherize@group-actions__.actions.ts.template create mode 100644 modules/schematics/src/entity/files/__name@dasherize@if-flat__/__name@dasherize@group-models__.model.ts.template create mode 100644 modules/schematics/src/entity/files/__name@dasherize@if-flat__/__name@dasherize@group-reducers__.reducer.ts.template create mode 100644 modules/schematics/src/reducer/files/__name@dasherize@if-flat__/__name@dasherize__.reducer.ts.template create mode 100644 modules/schematics/src/store/files/__statePath__/index.ts.template diff --git a/modules/schematics/src/action/files/__name@dasherize@if-flat__/__name@dasherize__.actions.ts.template b/modules/schematics/src/action/files/__name@dasherize@if-flat__/__name@dasherize__.actions.ts.template new file mode 100644 index 0000000000..98cd8c8a93 --- /dev/null +++ b/modules/schematics/src/action/files/__name@dasherize@if-flat__/__name@dasherize__.actions.ts.template @@ -0,0 +1,24 @@ +import { Action } from '@ngrx/store'; + +export enum <%= classify(name) %>ActionTypes { + Load<%= classify(name) %>s = '[<%= classify(name) %>] Load <%= classify(name) %>s', + <% if (api) { %>Load<%= classify(name) %>sSuccess = '[<%= classify(name) %>] Load <%= classify(name) %>s Success',<% } %> + <% if (api) { %>Load<%= classify(name) %>sFailure = '[<%= classify(name) %>] Load <%= classify(name) %>s Failure',<% } %> +} + +export class Load<%= classify(name) %>s implements Action { + readonly type = <%= classify(name) %>ActionTypes.Load<%= classify(name) %>s; +} +<% if (api) { %> +export class Load<%= classify(name) %>sSuccess implements Action { + readonly type = <%= classify(name) %>ActionTypes.Load<%= classify(name) %>sSuccess; + constructor(public payload: { data: any }) { } +} + +export class Load<%= classify(name) %>sFailure implements Action { + readonly type = <%= classify(name) %>ActionTypes.Load<%= classify(name) %>sFailure; + constructor(public payload: { error: any }) { } +} +<% } %> +<% if (api) { %>export type <%= classify(name) %>Actions = Load<%= classify(name) %>s | Load<%= classify(name) %>sSuccess | Load<%= classify(name) %>sFailure;<% } %> +<% if (!api) { %>export type <%= classify(name) %>Actions = Load<%= classify(name) %>s;<% } %> diff --git a/modules/schematics/src/effect/files/__name@dasherize@if-flat__/__name@dasherize__.effects.ts.template b/modules/schematics/src/effect/files/__name@dasherize@if-flat__/__name@dasherize__.effects.ts.template new file mode 100644 index 0000000000..09e7ebfcc3 --- /dev/null +++ b/modules/schematics/src/effect/files/__name@dasherize@if-flat__/__name@dasherize__.effects.ts.template @@ -0,0 +1,38 @@ +import { Injectable } from '@angular/core'; +import { Actions, Effect<% if (feature) { %>, ofType<% } %> } from '@ngrx/effects'; +<% if (feature && api) { %>import { catchError, map, concatMap } from 'rxjs/operators'; +import { EMPTY, of } from 'rxjs'; +import { Load<%= classify(name) %>sFailure, Load<%= classify(name) %>sSuccess, <%= classify(name) %>ActionTypes, <%= classify(name) %>Actions } from '<%= featurePath(group, flat, "actions", dasherize(name)) %><%= dasherize(name) %>.actions'; +<% } %> +<% if (feature && !api) { %>import { concatMap } from 'rxjs/operators'; +import { EMPTY } from 'rxjs'; +import { <%= classify(name) %>ActionTypes, <%= classify(name) %>Actions } from '<%= featurePath(group, flat, "actions", dasherize(name)) %><%= dasherize(name) %>.actions'; +<% } %> + +@Injectable() +export class <%= classify(name) %>Effects { +<% if (feature && api) { %> + @Effect() + load<%= classify(name) %>s$ = this.actions$.pipe( + ofType(<%= classify(name) %>ActionTypes.Load<%= classify(name) %>s), + concatMap(() => + /** An EMPTY observable only emits completion. Replace with your own observable API request */ + EMPTY.pipe( + map(data => new Load<%= classify(name) %>sSuccess({ data })), + catchError(error => of(new Load<%= classify(name) %>sFailure({ error })))) + ) + );<% } %> +<% if (feature && !api) { %> + @Effect() + load<%= classify(name) %>s$ = this.actions$.pipe( + ofType(<%= classify(name) %>ActionTypes.Load<%= classify(name) %>s), + /** An EMPTY observable only emits completion. Replace with your own observable API request */ + concatMap(() => EMPTY) + ); +<% } %> +<% if (feature) { %> + constructor(private actions$: Actions<<%= classify(name) %>Actions>) {} +<% } else { %> + constructor(private actions$: Actions) {} +<% } %> +} diff --git a/modules/schematics/src/entity/files/__name@dasherize@if-flat__/__name@dasherize@group-actions__.actions.ts.template b/modules/schematics/src/entity/files/__name@dasherize@if-flat__/__name@dasherize@group-actions__.actions.ts.template new file mode 100644 index 0000000000..31bec63799 --- /dev/null +++ b/modules/schematics/src/entity/files/__name@dasherize@if-flat__/__name@dasherize@group-actions__.actions.ts.template @@ -0,0 +1,86 @@ +import { Action } from '@ngrx/store'; +import { Update } from '@ngrx/entity'; +import { <%= classify(name) %> } from '<%= featurePath(group, flat, "models", dasherize(name)) %><%= dasherize(name) %>.model'; + +export enum <%= classify(name) %>ActionTypes { + Load<%= classify(name) %>s = '[<%= classify(name) %>] Load <%= classify(name) %>s', + Add<%= classify(name) %> = '[<%= classify(name) %>] Add <%= classify(name) %>', + Upsert<%= classify(name) %> = '[<%= classify(name) %>] Upsert <%= classify(name) %>', + Add<%= classify(name) %>s = '[<%= classify(name) %>] Add <%= classify(name) %>s', + Upsert<%= classify(name) %>s = '[<%= classify(name) %>] Upsert <%= classify(name) %>s', + Update<%= classify(name) %> = '[<%= classify(name) %>] Update <%= classify(name) %>', + Update<%= classify(name) %>s = '[<%= classify(name) %>] Update <%= classify(name) %>s', + Delete<%= classify(name) %> = '[<%= classify(name) %>] Delete <%= classify(name) %>', + Delete<%= classify(name) %>s = '[<%= classify(name) %>] Delete <%= classify(name) %>s', + Clear<%= classify(name) %>s = '[<%= classify(name) %>] Clear <%= classify(name) %>s' +} + +export class Load<%= classify(name) %>s implements Action { + readonly type = <%= classify(name) %>ActionTypes.Load<%= classify(name) %>s; + + constructor(public payload: { <%= camelize(name) %>s: <%= classify(name) %>[] }) {} +} + +export class Add<%= classify(name) %> implements Action { + readonly type = <%= classify(name) %>ActionTypes.Add<%= classify(name) %>; + + constructor(public payload: { <%= camelize(name) %>: <%= classify(name) %> }) {} +} + +export class Upsert<%= classify(name) %> implements Action { + readonly type = <%= classify(name) %>ActionTypes.Upsert<%= classify(name) %>; + + constructor(public payload: { <%= camelize(name) %>: <%= classify(name) %> }) {} +} + +export class Add<%= classify(name) %>s implements Action { + readonly type = <%= classify(name) %>ActionTypes.Add<%= classify(name) %>s; + + constructor(public payload: { <%= camelize(name) %>s: <%= classify(name) %>[] }) {} +} + +export class Upsert<%= classify(name) %>s implements Action { + readonly type = <%= classify(name) %>ActionTypes.Upsert<%= classify(name) %>s; + + constructor(public payload: { <%= camelize(name) %>s: <%= classify(name) %>[] }) {} +} + +export class Update<%= classify(name) %> implements Action { + readonly type = <%= classify(name) %>ActionTypes.Update<%= classify(name) %>; + + constructor(public payload: { <%= camelize(name) %>: Update<<%= classify(name) %>> }) {} +} + +export class Update<%= classify(name) %>s implements Action { + readonly type = <%= classify(name) %>ActionTypes.Update<%= classify(name) %>s; + + constructor(public payload: { <%= camelize(name) %>s: Update<<%= classify(name) %>>[] }) {} +} + +export class Delete<%= classify(name) %> implements Action { + readonly type = <%= classify(name) %>ActionTypes.Delete<%= classify(name) %>; + + constructor(public payload: { id: string }) {} +} + +export class Delete<%= classify(name) %>s implements Action { + readonly type = <%= classify(name) %>ActionTypes.Delete<%= classify(name) %>s; + + constructor(public payload: { ids: string[] }) {} +} + +export class Clear<%= classify(name) %>s implements Action { + readonly type = <%= classify(name) %>ActionTypes.Clear<%= classify(name) %>s; +} + +export type <%= classify(name) %>Actions = + Load<%= classify(name) %>s + | Add<%= classify(name) %> + | Upsert<%= classify(name) %> + | Add<%= classify(name) %>s + | Upsert<%= classify(name) %>s + | Update<%= classify(name) %> + | Update<%= classify(name) %>s + | Delete<%= classify(name) %> + | Delete<%= classify(name) %>s + | Clear<%= classify(name) %>s; diff --git a/modules/schematics/src/entity/files/__name@dasherize@if-flat__/__name@dasherize@group-models__.model.ts.template b/modules/schematics/src/entity/files/__name@dasherize@if-flat__/__name@dasherize@group-models__.model.ts.template new file mode 100644 index 0000000000..993c019780 --- /dev/null +++ b/modules/schematics/src/entity/files/__name@dasherize@if-flat__/__name@dasherize@group-models__.model.ts.template @@ -0,0 +1,3 @@ +export interface <%= classify(name) %> { + id: string; +} diff --git a/modules/schematics/src/entity/files/__name@dasherize@if-flat__/__name@dasherize@group-reducers__.reducer.ts.template b/modules/schematics/src/entity/files/__name@dasherize@if-flat__/__name@dasherize@group-reducers__.reducer.ts.template new file mode 100644 index 0000000000..ca3c401963 --- /dev/null +++ b/modules/schematics/src/entity/files/__name@dasherize@if-flat__/__name@dasherize@group-reducers__.reducer.ts.template @@ -0,0 +1,71 @@ +import { EntityState, EntityAdapter, createEntityAdapter } from '@ngrx/entity'; +import { <%= classify(name) %> } from '<%= featurePath(group, flat, "models", dasherize(name)) %><%= dasherize(name) %>.model'; +import { <%= classify(name) %>Actions, <%= classify(name) %>ActionTypes } from '<%= featurePath(group, flat, "actions", dasherize(name)) %><%= dasherize(name) %>.actions'; + +export interface State extends EntityState<<%= classify(name) %>> { + // additional entities state properties +} + +export const adapter: EntityAdapter<<%= classify(name) %>> = createEntityAdapter<<%= classify(name) %>>(); + +export const initialState: State = adapter.getInitialState({ + // additional entity state properties +}); + +export function reducer( + state = initialState, + action: <%= classify(name) %>Actions +): State { + switch (action.type) { + case <%= classify(name) %>ActionTypes.Add<%= classify(name) %>: { + return adapter.addOne(action.payload.<%= camelize(name) %>, state); + } + + case <%= classify(name) %>ActionTypes.Upsert<%= classify(name) %>: { + return adapter.upsertOne(action.payload.<%= camelize(name) %>, state); + } + + case <%= classify(name) %>ActionTypes.Add<%= classify(name) %>s: { + return adapter.addMany(action.payload.<%= camelize(name) %>s, state); + } + + case <%= classify(name) %>ActionTypes.Upsert<%= classify(name) %>s: { + return adapter.upsertMany(action.payload.<%= camelize(name) %>s, state); + } + + case <%= classify(name) %>ActionTypes.Update<%= classify(name) %>: { + return adapter.updateOne(action.payload.<%= camelize(name) %>, state); + } + + case <%= classify(name) %>ActionTypes.Update<%= classify(name) %>s: { + return adapter.updateMany(action.payload.<%= camelize(name) %>s, state); + } + + case <%= classify(name) %>ActionTypes.Delete<%= classify(name) %>: { + return adapter.removeOne(action.payload.id, state); + } + + case <%= classify(name) %>ActionTypes.Delete<%= classify(name) %>s: { + return adapter.removeMany(action.payload.ids, state); + } + + case <%= classify(name) %>ActionTypes.Load<%= classify(name) %>s: { + return adapter.addAll(action.payload.<%= camelize(name) %>s, state); + } + + case <%= classify(name) %>ActionTypes.Clear<%= classify(name) %>s: { + return adapter.removeAll(state); + } + + default: { + return state; + } + } +} + +export const { + selectIds, + selectEntities, + selectAll, + selectTotal, +} = adapter.getSelectors(); diff --git a/modules/schematics/src/reducer/files/__name@dasherize@if-flat__/__name@dasherize__.reducer.ts.template b/modules/schematics/src/reducer/files/__name@dasherize@if-flat__/__name@dasherize__.reducer.ts.template new file mode 100644 index 0000000000..7901446675 --- /dev/null +++ b/modules/schematics/src/reducer/files/__name@dasherize@if-flat__/__name@dasherize__.reducer.ts.template @@ -0,0 +1,27 @@ +<% if(!feature) { %>import { Action } from '@ngrx/store';<% } %> +<% if(feature) { %>import { <%= classify(name) %>Actions, <%= classify(name) %>ActionTypes } from '<%= featurePath(group, flat, "actions", dasherize(name)) %><%= dasherize(name) %>.actions';<% } %> + +export interface State { + +} + +export const initialState: State = { + +}; + +export function reducer(state = initialState, action: <% if(feature) { %><%= classify(name) %>Actions<% } else { %>Action<% } %>): State { + switch (action.type) { +<% if(feature) { %> + case <%= classify(name) %>ActionTypes.Load<%= classify(name) %>s: + return state; +<% if(api) { %> + case <%= classify(name) %>ActionTypes.Load<%= classify(name) %>sSuccess: + return state; + + case <%= classify(name) %>ActionTypes.Load<%= classify(name) %>sFailure: + return state; +<% } %><% } %> + default: + return state; + } +} diff --git a/modules/schematics/src/store/files/__statePath__/index.ts.template b/modules/schematics/src/store/files/__statePath__/index.ts.template new file mode 100644 index 0000000000..0d86d8d1db --- /dev/null +++ b/modules/schematics/src/store/files/__statePath__/index.ts.template @@ -0,0 +1,19 @@ +import { + ActionReducer, + ActionReducerMap, + createFeatureSelector, + createSelector, + MetaReducer +} from '@ngrx/store'; +<% if (!isLib) { %>import { environment } from '<%= environmentsPath %>';<% } %> + +export interface <%= classify(stateInterface) %> { + +} + +export const reducers: ActionReducerMap<<%= classify(stateInterface) %>> = { + +}; + + +export const metaReducers: MetaReducer<<%= classify(stateInterface) %>>[] = <% if (!isLib) { %>!environment.production ? [] : <% } %>[]; From c1ddee4e6be5090e043ea0438203e66c471d926b Mon Sep 17 00:00:00 2001 From: Santosh Yadav Date: Wed, 27 Feb 2019 01:33:50 +0530 Subject: [PATCH 02/10] removed .ts files --- .../__name@dasherize__.actions.ts | 24 ------ .../__name@dasherize__.effects.ts | 38 -------- ..._name@dasherize@group-actions__.actions.ts | 86 ------------------- .../__name@dasherize@group-models__.model.ts | 3 - ...name@dasherize@group-reducers__.reducer.ts | 71 --------------- .../__name@dasherize__.reducer.ts | 27 ------ .../src/store/files/__statePath__/index.ts | 19 ---- 7 files changed, 268 deletions(-) delete mode 100644 modules/schematics/src/action/files/__name@dasherize@if-flat__/__name@dasherize__.actions.ts delete mode 100644 modules/schematics/src/effect/files/__name@dasherize@if-flat__/__name@dasherize__.effects.ts delete mode 100644 modules/schematics/src/entity/files/__name@dasherize@if-flat__/__name@dasherize@group-actions__.actions.ts delete mode 100644 modules/schematics/src/entity/files/__name@dasherize@if-flat__/__name@dasherize@group-models__.model.ts delete mode 100644 modules/schematics/src/entity/files/__name@dasherize@if-flat__/__name@dasherize@group-reducers__.reducer.ts delete mode 100644 modules/schematics/src/reducer/files/__name@dasherize@if-flat__/__name@dasherize__.reducer.ts delete mode 100644 modules/schematics/src/store/files/__statePath__/index.ts diff --git a/modules/schematics/src/action/files/__name@dasherize@if-flat__/__name@dasherize__.actions.ts b/modules/schematics/src/action/files/__name@dasherize@if-flat__/__name@dasherize__.actions.ts deleted file mode 100644 index 98cd8c8a93..0000000000 --- a/modules/schematics/src/action/files/__name@dasherize@if-flat__/__name@dasherize__.actions.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { Action } from '@ngrx/store'; - -export enum <%= classify(name) %>ActionTypes { - Load<%= classify(name) %>s = '[<%= classify(name) %>] Load <%= classify(name) %>s', - <% if (api) { %>Load<%= classify(name) %>sSuccess = '[<%= classify(name) %>] Load <%= classify(name) %>s Success',<% } %> - <% if (api) { %>Load<%= classify(name) %>sFailure = '[<%= classify(name) %>] Load <%= classify(name) %>s Failure',<% } %> -} - -export class Load<%= classify(name) %>s implements Action { - readonly type = <%= classify(name) %>ActionTypes.Load<%= classify(name) %>s; -} -<% if (api) { %> -export class Load<%= classify(name) %>sSuccess implements Action { - readonly type = <%= classify(name) %>ActionTypes.Load<%= classify(name) %>sSuccess; - constructor(public payload: { data: any }) { } -} - -export class Load<%= classify(name) %>sFailure implements Action { - readonly type = <%= classify(name) %>ActionTypes.Load<%= classify(name) %>sFailure; - constructor(public payload: { error: any }) { } -} -<% } %> -<% if (api) { %>export type <%= classify(name) %>Actions = Load<%= classify(name) %>s | Load<%= classify(name) %>sSuccess | Load<%= classify(name) %>sFailure;<% } %> -<% if (!api) { %>export type <%= classify(name) %>Actions = Load<%= classify(name) %>s;<% } %> diff --git a/modules/schematics/src/effect/files/__name@dasherize@if-flat__/__name@dasherize__.effects.ts b/modules/schematics/src/effect/files/__name@dasherize@if-flat__/__name@dasherize__.effects.ts deleted file mode 100644 index 09e7ebfcc3..0000000000 --- a/modules/schematics/src/effect/files/__name@dasherize@if-flat__/__name@dasherize__.effects.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { Injectable } from '@angular/core'; -import { Actions, Effect<% if (feature) { %>, ofType<% } %> } from '@ngrx/effects'; -<% if (feature && api) { %>import { catchError, map, concatMap } from 'rxjs/operators'; -import { EMPTY, of } from 'rxjs'; -import { Load<%= classify(name) %>sFailure, Load<%= classify(name) %>sSuccess, <%= classify(name) %>ActionTypes, <%= classify(name) %>Actions } from '<%= featurePath(group, flat, "actions", dasherize(name)) %><%= dasherize(name) %>.actions'; -<% } %> -<% if (feature && !api) { %>import { concatMap } from 'rxjs/operators'; -import { EMPTY } from 'rxjs'; -import { <%= classify(name) %>ActionTypes, <%= classify(name) %>Actions } from '<%= featurePath(group, flat, "actions", dasherize(name)) %><%= dasherize(name) %>.actions'; -<% } %> - -@Injectable() -export class <%= classify(name) %>Effects { -<% if (feature && api) { %> - @Effect() - load<%= classify(name) %>s$ = this.actions$.pipe( - ofType(<%= classify(name) %>ActionTypes.Load<%= classify(name) %>s), - concatMap(() => - /** An EMPTY observable only emits completion. Replace with your own observable API request */ - EMPTY.pipe( - map(data => new Load<%= classify(name) %>sSuccess({ data })), - catchError(error => of(new Load<%= classify(name) %>sFailure({ error })))) - ) - );<% } %> -<% if (feature && !api) { %> - @Effect() - load<%= classify(name) %>s$ = this.actions$.pipe( - ofType(<%= classify(name) %>ActionTypes.Load<%= classify(name) %>s), - /** An EMPTY observable only emits completion. Replace with your own observable API request */ - concatMap(() => EMPTY) - ); -<% } %> -<% if (feature) { %> - constructor(private actions$: Actions<<%= classify(name) %>Actions>) {} -<% } else { %> - constructor(private actions$: Actions) {} -<% } %> -} diff --git a/modules/schematics/src/entity/files/__name@dasherize@if-flat__/__name@dasherize@group-actions__.actions.ts b/modules/schematics/src/entity/files/__name@dasherize@if-flat__/__name@dasherize@group-actions__.actions.ts deleted file mode 100644 index 31bec63799..0000000000 --- a/modules/schematics/src/entity/files/__name@dasherize@if-flat__/__name@dasherize@group-actions__.actions.ts +++ /dev/null @@ -1,86 +0,0 @@ -import { Action } from '@ngrx/store'; -import { Update } from '@ngrx/entity'; -import { <%= classify(name) %> } from '<%= featurePath(group, flat, "models", dasherize(name)) %><%= dasherize(name) %>.model'; - -export enum <%= classify(name) %>ActionTypes { - Load<%= classify(name) %>s = '[<%= classify(name) %>] Load <%= classify(name) %>s', - Add<%= classify(name) %> = '[<%= classify(name) %>] Add <%= classify(name) %>', - Upsert<%= classify(name) %> = '[<%= classify(name) %>] Upsert <%= classify(name) %>', - Add<%= classify(name) %>s = '[<%= classify(name) %>] Add <%= classify(name) %>s', - Upsert<%= classify(name) %>s = '[<%= classify(name) %>] Upsert <%= classify(name) %>s', - Update<%= classify(name) %> = '[<%= classify(name) %>] Update <%= classify(name) %>', - Update<%= classify(name) %>s = '[<%= classify(name) %>] Update <%= classify(name) %>s', - Delete<%= classify(name) %> = '[<%= classify(name) %>] Delete <%= classify(name) %>', - Delete<%= classify(name) %>s = '[<%= classify(name) %>] Delete <%= classify(name) %>s', - Clear<%= classify(name) %>s = '[<%= classify(name) %>] Clear <%= classify(name) %>s' -} - -export class Load<%= classify(name) %>s implements Action { - readonly type = <%= classify(name) %>ActionTypes.Load<%= classify(name) %>s; - - constructor(public payload: { <%= camelize(name) %>s: <%= classify(name) %>[] }) {} -} - -export class Add<%= classify(name) %> implements Action { - readonly type = <%= classify(name) %>ActionTypes.Add<%= classify(name) %>; - - constructor(public payload: { <%= camelize(name) %>: <%= classify(name) %> }) {} -} - -export class Upsert<%= classify(name) %> implements Action { - readonly type = <%= classify(name) %>ActionTypes.Upsert<%= classify(name) %>; - - constructor(public payload: { <%= camelize(name) %>: <%= classify(name) %> }) {} -} - -export class Add<%= classify(name) %>s implements Action { - readonly type = <%= classify(name) %>ActionTypes.Add<%= classify(name) %>s; - - constructor(public payload: { <%= camelize(name) %>s: <%= classify(name) %>[] }) {} -} - -export class Upsert<%= classify(name) %>s implements Action { - readonly type = <%= classify(name) %>ActionTypes.Upsert<%= classify(name) %>s; - - constructor(public payload: { <%= camelize(name) %>s: <%= classify(name) %>[] }) {} -} - -export class Update<%= classify(name) %> implements Action { - readonly type = <%= classify(name) %>ActionTypes.Update<%= classify(name) %>; - - constructor(public payload: { <%= camelize(name) %>: Update<<%= classify(name) %>> }) {} -} - -export class Update<%= classify(name) %>s implements Action { - readonly type = <%= classify(name) %>ActionTypes.Update<%= classify(name) %>s; - - constructor(public payload: { <%= camelize(name) %>s: Update<<%= classify(name) %>>[] }) {} -} - -export class Delete<%= classify(name) %> implements Action { - readonly type = <%= classify(name) %>ActionTypes.Delete<%= classify(name) %>; - - constructor(public payload: { id: string }) {} -} - -export class Delete<%= classify(name) %>s implements Action { - readonly type = <%= classify(name) %>ActionTypes.Delete<%= classify(name) %>s; - - constructor(public payload: { ids: string[] }) {} -} - -export class Clear<%= classify(name) %>s implements Action { - readonly type = <%= classify(name) %>ActionTypes.Clear<%= classify(name) %>s; -} - -export type <%= classify(name) %>Actions = - Load<%= classify(name) %>s - | Add<%= classify(name) %> - | Upsert<%= classify(name) %> - | Add<%= classify(name) %>s - | Upsert<%= classify(name) %>s - | Update<%= classify(name) %> - | Update<%= classify(name) %>s - | Delete<%= classify(name) %> - | Delete<%= classify(name) %>s - | Clear<%= classify(name) %>s; diff --git a/modules/schematics/src/entity/files/__name@dasherize@if-flat__/__name@dasherize@group-models__.model.ts b/modules/schematics/src/entity/files/__name@dasherize@if-flat__/__name@dasherize@group-models__.model.ts deleted file mode 100644 index 993c019780..0000000000 --- a/modules/schematics/src/entity/files/__name@dasherize@if-flat__/__name@dasherize@group-models__.model.ts +++ /dev/null @@ -1,3 +0,0 @@ -export interface <%= classify(name) %> { - id: string; -} diff --git a/modules/schematics/src/entity/files/__name@dasherize@if-flat__/__name@dasherize@group-reducers__.reducer.ts b/modules/schematics/src/entity/files/__name@dasherize@if-flat__/__name@dasherize@group-reducers__.reducer.ts deleted file mode 100644 index ca3c401963..0000000000 --- a/modules/schematics/src/entity/files/__name@dasherize@if-flat__/__name@dasherize@group-reducers__.reducer.ts +++ /dev/null @@ -1,71 +0,0 @@ -import { EntityState, EntityAdapter, createEntityAdapter } from '@ngrx/entity'; -import { <%= classify(name) %> } from '<%= featurePath(group, flat, "models", dasherize(name)) %><%= dasherize(name) %>.model'; -import { <%= classify(name) %>Actions, <%= classify(name) %>ActionTypes } from '<%= featurePath(group, flat, "actions", dasherize(name)) %><%= dasherize(name) %>.actions'; - -export interface State extends EntityState<<%= classify(name) %>> { - // additional entities state properties -} - -export const adapter: EntityAdapter<<%= classify(name) %>> = createEntityAdapter<<%= classify(name) %>>(); - -export const initialState: State = adapter.getInitialState({ - // additional entity state properties -}); - -export function reducer( - state = initialState, - action: <%= classify(name) %>Actions -): State { - switch (action.type) { - case <%= classify(name) %>ActionTypes.Add<%= classify(name) %>: { - return adapter.addOne(action.payload.<%= camelize(name) %>, state); - } - - case <%= classify(name) %>ActionTypes.Upsert<%= classify(name) %>: { - return adapter.upsertOne(action.payload.<%= camelize(name) %>, state); - } - - case <%= classify(name) %>ActionTypes.Add<%= classify(name) %>s: { - return adapter.addMany(action.payload.<%= camelize(name) %>s, state); - } - - case <%= classify(name) %>ActionTypes.Upsert<%= classify(name) %>s: { - return adapter.upsertMany(action.payload.<%= camelize(name) %>s, state); - } - - case <%= classify(name) %>ActionTypes.Update<%= classify(name) %>: { - return adapter.updateOne(action.payload.<%= camelize(name) %>, state); - } - - case <%= classify(name) %>ActionTypes.Update<%= classify(name) %>s: { - return adapter.updateMany(action.payload.<%= camelize(name) %>s, state); - } - - case <%= classify(name) %>ActionTypes.Delete<%= classify(name) %>: { - return adapter.removeOne(action.payload.id, state); - } - - case <%= classify(name) %>ActionTypes.Delete<%= classify(name) %>s: { - return adapter.removeMany(action.payload.ids, state); - } - - case <%= classify(name) %>ActionTypes.Load<%= classify(name) %>s: { - return adapter.addAll(action.payload.<%= camelize(name) %>s, state); - } - - case <%= classify(name) %>ActionTypes.Clear<%= classify(name) %>s: { - return adapter.removeAll(state); - } - - default: { - return state; - } - } -} - -export const { - selectIds, - selectEntities, - selectAll, - selectTotal, -} = adapter.getSelectors(); diff --git a/modules/schematics/src/reducer/files/__name@dasherize@if-flat__/__name@dasherize__.reducer.ts b/modules/schematics/src/reducer/files/__name@dasherize@if-flat__/__name@dasherize__.reducer.ts deleted file mode 100644 index 7901446675..0000000000 --- a/modules/schematics/src/reducer/files/__name@dasherize@if-flat__/__name@dasherize__.reducer.ts +++ /dev/null @@ -1,27 +0,0 @@ -<% if(!feature) { %>import { Action } from '@ngrx/store';<% } %> -<% if(feature) { %>import { <%= classify(name) %>Actions, <%= classify(name) %>ActionTypes } from '<%= featurePath(group, flat, "actions", dasherize(name)) %><%= dasherize(name) %>.actions';<% } %> - -export interface State { - -} - -export const initialState: State = { - -}; - -export function reducer(state = initialState, action: <% if(feature) { %><%= classify(name) %>Actions<% } else { %>Action<% } %>): State { - switch (action.type) { -<% if(feature) { %> - case <%= classify(name) %>ActionTypes.Load<%= classify(name) %>s: - return state; -<% if(api) { %> - case <%= classify(name) %>ActionTypes.Load<%= classify(name) %>sSuccess: - return state; - - case <%= classify(name) %>ActionTypes.Load<%= classify(name) %>sFailure: - return state; -<% } %><% } %> - default: - return state; - } -} diff --git a/modules/schematics/src/store/files/__statePath__/index.ts b/modules/schematics/src/store/files/__statePath__/index.ts deleted file mode 100644 index 0d86d8d1db..0000000000 --- a/modules/schematics/src/store/files/__statePath__/index.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { - ActionReducer, - ActionReducerMap, - createFeatureSelector, - createSelector, - MetaReducer -} from '@ngrx/store'; -<% if (!isLib) { %>import { environment } from '<%= environmentsPath %>';<% } %> - -export interface <%= classify(stateInterface) %> { - -} - -export const reducers: ActionReducerMap<<%= classify(stateInterface) %>> = { - -}; - - -export const metaReducers: MetaReducer<<%= classify(stateInterface) %>>[] = <% if (!isLib) { %>!environment.production ? [] : <% } %>[]; From dbf9728f50aa3fd12abe60c830127164b8902f38 Mon Sep 17 00:00:00 2001 From: Santosh Yadav Date: Thu, 28 Feb 2019 02:13:15 +0530 Subject: [PATCH 03/10] applyTemplates method to generate the templates --- ...name@dasherize__.effects.spec.ts.template} | 0 ...=> __name@dasherize__.effects.ts.template} | 0 modules/effects/schematics/ng-add/index.ts | 7 +++-- ...name@dasherize__.actions.spec.ts.template} | 0 modules/schematics/src/action/index.ts | 16 ++++++---- ...herize__.component__dot__spec.ts.template} | 0 modules/schematics/src/container/index.ts | 9 ++++-- ...name@dasherize__.effects.spec.ts.template} | 0 modules/schematics/src/effect/index.ts | 9 ++++-- ...reducers__.reducer__dot__spec.ts.template} | 0 modules/schematics/src/entity/index.ts | 9 ++++-- ...name@dasherize__.reducer.spec.ts.template} | 0 modules/schematics/src/reducer/index.ts | 9 ++++-- modules/schematics/src/store/index.ts | 5 ++-- .../{index.ts => index.ts.template} | 0 modules/store/schematics/ng-add/index.spec.ts | 6 ++-- modules/store/schematics/ng-add/index.ts | 10 ++++--- package.json | 1 + yarn.lock | 29 +++++++++++++++++++ 19 files changed, 82 insertions(+), 28 deletions(-) rename modules/effects/schematics/ng-add/files/__name@dasherize@if-flat__/{__name@dasherize__.effects__dot__spec.ts => __name@dasherize__.effects.spec.ts.template} (100%) rename modules/effects/schematics/ng-add/files/__name@dasherize@if-flat__/{__name@dasherize__.effects.ts => __name@dasherize__.effects.ts.template} (100%) rename modules/schematics/src/action/files/__name@dasherize@if-flat__/{__name@dasherize__.actions__dot__spec.ts => __name@dasherize__.actions.spec.ts.template} (100%) rename modules/schematics/src/container/files/__name@dasherize@if-flat__/{__name@dasherize__.component__dot__spec.ts => __name@dasherize__.component__dot__spec.ts.template} (100%) rename modules/schematics/src/effect/files/__name@dasherize@if-flat__/{__name@dasherize__.effects__dot__spec.ts => __name@dasherize__.effects.spec.ts.template} (100%) rename modules/schematics/src/entity/files/__name@dasherize@if-flat__/{__name@dasherize@group-reducers__.reducer__dot__spec.ts => __name@dasherize@group-reducers__.reducer__dot__spec.ts.template} (100%) rename modules/schematics/src/reducer/files/__name@dasherize@if-flat__/{__name@dasherize__.reducer__dot__spec.ts => __name@dasherize__.reducer.spec.ts.template} (100%) rename modules/store/schematics/ng-add/files/__statePath__/{index.ts => index.ts.template} (100%) diff --git a/modules/effects/schematics/ng-add/files/__name@dasherize@if-flat__/__name@dasherize__.effects__dot__spec.ts b/modules/effects/schematics/ng-add/files/__name@dasherize@if-flat__/__name@dasherize__.effects.spec.ts.template similarity index 100% rename from modules/effects/schematics/ng-add/files/__name@dasherize@if-flat__/__name@dasherize__.effects__dot__spec.ts rename to modules/effects/schematics/ng-add/files/__name@dasherize@if-flat__/__name@dasherize__.effects.spec.ts.template diff --git a/modules/effects/schematics/ng-add/files/__name@dasherize@if-flat__/__name@dasherize__.effects.ts b/modules/effects/schematics/ng-add/files/__name@dasherize@if-flat__/__name@dasherize__.effects.ts.template similarity index 100% rename from modules/effects/schematics/ng-add/files/__name@dasherize@if-flat__/__name@dasherize__.effects.ts rename to modules/effects/schematics/ng-add/files/__name@dasherize@if-flat__/__name@dasherize__.effects.ts.template diff --git a/modules/effects/schematics/ng-add/index.ts b/modules/effects/schematics/ng-add/index.ts index 6c7b1cdecc..dd3ed2f99f 100644 --- a/modules/effects/schematics/ng-add/index.ts +++ b/modules/effects/schematics/ng-add/index.ts @@ -4,6 +4,7 @@ import { SchematicsException, Tree, apply, + applyTemplates, branchAndMerge, chain, filter, @@ -121,8 +122,10 @@ export default function(options: RootEffectOptions): Rule { options.path = parsedPath.path; const templateSource = apply(url('./files'), [ - options.spec ? noop() : filter(path => !path.endsWith('__spec.ts')), - template({ + options.spec + ? noop() + : filter(path => !path.endsWith('.spec.ts.template')), + applyTemplates({ ...stringUtils, 'if-flat': (s: string) => stringUtils.group( diff --git a/modules/schematics/src/action/files/__name@dasherize@if-flat__/__name@dasherize__.actions__dot__spec.ts b/modules/schematics/src/action/files/__name@dasherize@if-flat__/__name@dasherize__.actions.spec.ts.template similarity index 100% rename from modules/schematics/src/action/files/__name@dasherize@if-flat__/__name@dasherize__.actions__dot__spec.ts rename to modules/schematics/src/action/files/__name@dasherize@if-flat__/__name@dasherize__.actions.spec.ts.template diff --git a/modules/schematics/src/action/index.ts b/modules/schematics/src/action/index.ts index 53f4852e09..408e2671cb 100644 --- a/modules/schematics/src/action/index.ts +++ b/modules/schematics/src/action/index.ts @@ -1,7 +1,9 @@ +import { strings } from '@angular-devkit/core'; import { Rule, SchematicsException, apply, + applyTemplates, branchAndMerge, chain, filter, @@ -29,17 +31,19 @@ export default function(options: ActionOptions): Rule { options.path = parsedPath.path; const templateSource = apply(url('./files'), [ - options.spec ? noop() : filter(path => !path.endsWith('__spec.ts')), - template({ + options.spec + ? noop() + : filter(path => !path.endsWith('.spec.ts.template')), + applyTemplates({ + ...stringUtils, 'if-flat': (s: string) => stringUtils.group( options.flat ? '' : s, options.group ? 'actions' : '' ), - ...stringUtils, - ...(options as object), - dot: () => '.', - } as any), + ...options, + dot: '.', + }), move(parsedPath.path), ]); diff --git a/modules/schematics/src/container/files/__name@dasherize@if-flat__/__name@dasherize__.component__dot__spec.ts b/modules/schematics/src/container/files/__name@dasherize@if-flat__/__name@dasherize__.component__dot__spec.ts.template similarity index 100% rename from modules/schematics/src/container/files/__name@dasherize@if-flat__/__name@dasherize__.component__dot__spec.ts rename to modules/schematics/src/container/files/__name@dasherize@if-flat__/__name@dasherize__.component__dot__spec.ts.template diff --git a/modules/schematics/src/container/index.ts b/modules/schematics/src/container/index.ts index 7e9d112430..759066a1b6 100644 --- a/modules/schematics/src/container/index.ts +++ b/modules/schematics/src/container/index.ts @@ -6,6 +6,7 @@ import { chain, externalSchematic, apply, + applyTemplates, url, noop, filter, @@ -136,12 +137,14 @@ export default function(options: ContainerOptions): Rule { ); const templateSource = apply(url('./files'), [ - options.spec ? noop() : filter(path => !path.endsWith('__spec.ts')), - template({ + options.spec + ? noop() + : filter(path => !path.endsWith('__spec.ts.template')), + applyTemplates({ 'if-flat': (s: string) => (options.flat ? '' : s), ...stringUtils, ...(options as object), - dot: () => '.', + dot: '.', } as any), move(parsedPath.path), ]); diff --git a/modules/schematics/src/effect/files/__name@dasherize@if-flat__/__name@dasherize__.effects__dot__spec.ts b/modules/schematics/src/effect/files/__name@dasherize@if-flat__/__name@dasherize__.effects.spec.ts.template similarity index 100% rename from modules/schematics/src/effect/files/__name@dasherize@if-flat__/__name@dasherize__.effects__dot__spec.ts rename to modules/schematics/src/effect/files/__name@dasherize@if-flat__/__name@dasherize__.effects.spec.ts.template diff --git a/modules/schematics/src/effect/index.ts b/modules/schematics/src/effect/index.ts index 40a599a191..fde516cd51 100644 --- a/modules/schematics/src/effect/index.ts +++ b/modules/schematics/src/effect/index.ts @@ -4,6 +4,7 @@ import { SchematicsException, Tree, apply, + applyTemplates, branchAndMerge, chain, filter, @@ -105,8 +106,10 @@ export default function(options: EffectOptions): Rule { options.path = parsedPath.path; const templateSource = apply(url('./files'), [ - options.spec ? noop() : filter(path => !path.endsWith('__spec.ts')), - template({ + options.spec + ? noop() + : filter(path => !path.endsWith('.spec.ts.template')), + applyTemplates({ ...stringUtils, 'if-flat': (s: string) => stringUtils.group( @@ -114,7 +117,7 @@ export default function(options: EffectOptions): Rule { options.group ? 'effects' : '' ), ...(options as object), - dot: () => '.', + dot: '.', } as any), move(parsedPath.path), ]); diff --git a/modules/schematics/src/entity/files/__name@dasherize@if-flat__/__name@dasherize@group-reducers__.reducer__dot__spec.ts b/modules/schematics/src/entity/files/__name@dasherize@if-flat__/__name@dasherize@group-reducers__.reducer__dot__spec.ts.template similarity index 100% rename from modules/schematics/src/entity/files/__name@dasherize@if-flat__/__name@dasherize@group-reducers__.reducer__dot__spec.ts rename to modules/schematics/src/entity/files/__name@dasherize@if-flat__/__name@dasherize@group-reducers__.reducer__dot__spec.ts.template diff --git a/modules/schematics/src/entity/index.ts b/modules/schematics/src/entity/index.ts index 6ecac95ed2..d5b8f92922 100644 --- a/modules/schematics/src/entity/index.ts +++ b/modules/schematics/src/entity/index.ts @@ -2,6 +2,7 @@ import { Rule, SchematicsException, apply, + applyTemplates, branchAndMerge, chain, filter, @@ -36,8 +37,10 @@ export default function(options: EntityOptions): Rule { } const templateSource = apply(url('./files'), [ - options.spec ? noop() : filter(path => !path.endsWith('__spec.ts')), - template({ + options.spec + ? noop() + : filter(path => !path.endsWith('.spec.ts.template')), + applyTemplates({ ...stringUtils, 'if-flat': (s: string) => (options.flat ? '' : s), 'group-actions': (name: string) => @@ -47,7 +50,7 @@ export default function(options: EntityOptions): Rule { 'group-reducers': (s: string) => stringUtils.group(s, options.group ? 'reducers' : ''), ...(options as object), - dot: () => '.', + dot: '.', } as any), move(parsedPath.path), ]); diff --git a/modules/schematics/src/reducer/files/__name@dasherize@if-flat__/__name@dasherize__.reducer__dot__spec.ts b/modules/schematics/src/reducer/files/__name@dasherize@if-flat__/__name@dasherize__.reducer.spec.ts.template similarity index 100% rename from modules/schematics/src/reducer/files/__name@dasherize@if-flat__/__name@dasherize__.reducer__dot__spec.ts rename to modules/schematics/src/reducer/files/__name@dasherize@if-flat__/__name@dasherize__.reducer.spec.ts.template diff --git a/modules/schematics/src/reducer/index.ts b/modules/schematics/src/reducer/index.ts index 60e1f852b2..ee3e608e23 100644 --- a/modules/schematics/src/reducer/index.ts +++ b/modules/schematics/src/reducer/index.ts @@ -4,6 +4,7 @@ import { SchematicsException, Tree, apply, + applyTemplates, branchAndMerge, chain, filter, @@ -37,8 +38,10 @@ export default function(options: ReducerOptions): Rule { options.path = parsedPath.path; const templateSource = apply(url('./files'), [ - options.spec ? noop() : filter(path => !path.endsWith('__spec.ts')), - template({ + options.spec + ? noop() + : filter(path => !path.endsWith('.spec.ts.template')), + applyTemplates({ ...stringUtils, 'if-flat': (s: string) => stringUtils.group( @@ -46,7 +49,7 @@ export default function(options: ReducerOptions): Rule { options.group ? 'reducers' : '' ), ...(options as object), - dot: () => '.', + dot: '.', } as any), move(parsedPath.path), ]); diff --git a/modules/schematics/src/store/index.ts b/modules/schematics/src/store/index.ts index a56aff9ba6..db06f31df2 100644 --- a/modules/schematics/src/store/index.ts +++ b/modules/schematics/src/store/index.ts @@ -4,6 +4,7 @@ import { SchematicsException, Tree, apply, + applyTemplates, branchAndMerge, chain, mergeWith, @@ -156,12 +157,12 @@ export default function(options: StoreOptions): Rule { } const templateSource = apply(url('./files'), [ - template({ + applyTemplates({ ...stringUtils, ...(options as object), isLib: isLib(host, options), environmentsPath, - } as any), + }), move(parsedPath.path), ]); diff --git a/modules/store/schematics/ng-add/files/__statePath__/index.ts b/modules/store/schematics/ng-add/files/__statePath__/index.ts.template similarity index 100% rename from modules/store/schematics/ng-add/files/__statePath__/index.ts rename to modules/store/schematics/ng-add/files/__statePath__/index.ts.template diff --git a/modules/store/schematics/ng-add/index.spec.ts b/modules/store/schematics/ng-add/index.spec.ts index 156a345693..32ecc24754 100644 --- a/modules/store/schematics/ng-add/index.spec.ts +++ b/modules/store/schematics/ng-add/index.spec.ts @@ -22,7 +22,6 @@ describe('Store ng-add Schematic', () => { }; const projectPath = getTestProjectPath(); - let appTree: UnitTestTree; beforeEach(() => { @@ -33,6 +32,7 @@ describe('Store ng-add Schematic', () => { const options = { ...defaultOptions }; const tree = schematicRunner.runSchematic('ng-add', options, appTree); + const packageJson = JSON.parse(tree.readContent('/package.json')); expect(packageJson.dependencies['@ngrx/store']).toBeDefined(); @@ -105,11 +105,11 @@ describe('Store ng-add Schematic', () => { it('should support a default root state interface name', () => { const options = { ...defaultOptions, name: 'State' }; - const tree = schematicRunner.runSchematic('ng-add', options, appTree); const content = tree.readContent( `${projectPath}/src/app/reducers/index.ts` ); + expect(content).toMatch(/export interface State {/); }); @@ -121,9 +121,11 @@ describe('Store ng-add Schematic', () => { }; const tree = schematicRunner.runSchematic('ng-add', options, appTree); + const content = tree.readContent( `${projectPath}/src/app/reducers/index.ts` ); + expect(content).toMatch(/export interface AppState {/); }); }); diff --git a/modules/store/schematics/ng-add/index.ts b/modules/store/schematics/ng-add/index.ts index 4bf04f81e1..f58346c068 100644 --- a/modules/store/schematics/ng-add/index.ts +++ b/modules/store/schematics/ng-add/index.ts @@ -1,9 +1,11 @@ +import { strings } from '@angular-devkit/core'; import { Rule, SchematicContext, SchematicsException, Tree, apply, + applyTemplates, branchAndMerge, chain, mergeWith, @@ -121,11 +123,11 @@ export default function(options: RootStoreOptions): Rule { } const templateSource = apply(url('./files'), [ - template({ - ...stringUtils, - ...(options as object), + applyTemplates({ + ...strings, + ...options, environmentsPath, - } as any), + }), move(parsedPath.path), ]); diff --git a/package.json b/package.json index 979767241f..220ff66ca2 100644 --- a/package.json +++ b/package.json @@ -72,6 +72,7 @@ ] }, "dependencies": { + "@angular-devkit/schematics": "^7.3.3", "@angular/animations": "^7.0.1", "@angular/bazel": "^7.0.1", "@angular/cdk": "^7.0.1", diff --git a/yarn.lock b/yarn.lock index c5f3c43255..91dd2d39c2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -106,6 +106,17 @@ rxjs "6.3.3" source-map "0.7.3" +"@angular-devkit/core@7.3.3": + version "7.3.3" + resolved "https://registry.yarnpkg.com/@angular-devkit/core/-/core-7.3.3.tgz#cd6d5a8eca25ef07b6394bc2b08133d90d08d39f" + integrity sha512-fosULDtMoDWrOyUzTmBkJccOy7zodo02kENyKai7vOv9EWfv9jytkVdNc+jl0ys9OE2QadvSYBo49jhnZxFXfQ== + dependencies: + ajv "6.9.1" + chokidar "2.0.4" + fast-json-stable-stringify "2.0.0" + rxjs "6.3.3" + source-map "0.7.3" + "@angular-devkit/schematics@7.0.1": version "7.0.1" resolved "https://registry.yarnpkg.com/@angular-devkit/schematics/-/schematics-7.0.1.tgz#ccd7c5349c08aaf6224a28881bfeeacaf0ee0307" @@ -113,6 +124,14 @@ "@angular-devkit/core" "7.0.1" rxjs "6.3.3" +"@angular-devkit/schematics@^7.3.3": + version "7.3.3" + resolved "https://registry.yarnpkg.com/@angular-devkit/schematics/-/schematics-7.3.3.tgz#80e9dc3197a3181f32edfb5c07e7ac016eace7d3" + integrity sha512-SdDq9eKwceb6WLwci1fywtZ/kARR5CYyzi5dZIR1lOxrz00682uUBqH/X39mKdqc6eVqR7rtPceqNm6nQpOIMg== + dependencies: + "@angular-devkit/core" "7.3.3" + rxjs "6.3.3" + "@angular/animations@^7.0.1": version "7.0.1" resolved "https://registry.yarnpkg.com/@angular/animations/-/animations-7.0.1.tgz#2df561c0959e156985297e69b7c30614537b4ffe" @@ -1350,6 +1369,16 @@ ajv@6.5.3: json-schema-traverse "^0.4.1" uri-js "^4.2.2" +ajv@6.9.1: + version "6.9.1" + resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.9.1.tgz#a4d3683d74abc5670e75f0b16520f70a20ea8dc1" + integrity sha512-XDN92U311aINL77ieWHmqCcNlwjoP5cHXDxIxbf2MaPYuCXOHS7gHH8jktxeK5omgd52XbSTX6a4Piwd1pQmzA== + dependencies: + fast-deep-equal "^2.0.1" + fast-json-stable-stringify "^2.0.0" + json-schema-traverse "^0.4.1" + uri-js "^4.2.2" + ajv@^5.0.0, ajv@^5.1.0, ajv@^5.3.0: version "5.5.2" resolved "https://registry.yarnpkg.com/ajv/-/ajv-5.5.2.tgz#73b5eeca3fab653e3d3f9422b341ad42205dc965" From 98017dd8895ff9c75952698d797aa561b920fb10 Mon Sep 17 00:00:00 2001 From: Santosh Yadav Date: Thu, 28 Feb 2019 02:15:04 +0530 Subject: [PATCH 04/10] schematics as ded dependency --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 220ff66ca2..9d6b583de9 100644 --- a/package.json +++ b/package.json @@ -72,7 +72,6 @@ ] }, "dependencies": { - "@angular-devkit/schematics": "^7.3.3", "@angular/animations": "^7.0.1", "@angular/bazel": "^7.0.1", "@angular/cdk": "^7.0.1", @@ -96,6 +95,7 @@ "zone.js": "^0.8.26" }, "devDependencies": { + "@angular-devkit/schematics": "^7.3.3", "@angular-devkit/build-angular": "^0.10.0", "@bazel/bazel": "^0.19.1", "@cypress/webpack-preprocessor": "^4.0.3", From dd34bbb81f37ee2598d2adab9c13b3eaeda3bd67 Mon Sep 17 00:00:00 2001 From: Santosh Yadav Date: Thu, 28 Feb 2019 02:35:57 +0530 Subject: [PATCH 05/10] added @angular-devkit/core as dev dependency --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 9d6b583de9..d7d2750ad9 100644 --- a/package.json +++ b/package.json @@ -95,8 +95,9 @@ "zone.js": "^0.8.26" }, "devDependencies": { - "@angular-devkit/schematics": "^7.3.3", "@angular-devkit/build-angular": "^0.10.0", + "@angular-devkit/core": "^7.3.3", + "@angular-devkit/schematics": "^7.3.3", "@bazel/bazel": "^0.19.1", "@cypress/webpack-preprocessor": "^4.0.3", "@octokit/rest": "^15.17.0", From 5e6a6ee606f4db9af756932bb900bcea5105496c Mon Sep 17 00:00:00 2001 From: Santosh Yadav Date: Fri, 1 Mar 2019 01:35:15 +0530 Subject: [PATCH 06/10] code review changes --- modules/schematics/src/action/index.ts | 1 - ....template => __name@dasherize__.component.spec.ts.template} | 0 modules/schematics/src/container/index.ts | 2 +- modules/store/schematics/ng-add/index.ts | 3 +-- package.json | 1 - 5 files changed, 2 insertions(+), 5 deletions(-) rename modules/schematics/src/container/files/__name@dasherize@if-flat__/{__name@dasherize__.component__dot__spec.ts.template => __name@dasherize__.component.spec.ts.template} (100%) diff --git a/modules/schematics/src/action/index.ts b/modules/schematics/src/action/index.ts index 408e2671cb..5f662a9fdb 100644 --- a/modules/schematics/src/action/index.ts +++ b/modules/schematics/src/action/index.ts @@ -1,4 +1,3 @@ -import { strings } from '@angular-devkit/core'; import { Rule, SchematicsException, diff --git a/modules/schematics/src/container/files/__name@dasherize@if-flat__/__name@dasherize__.component__dot__spec.ts.template b/modules/schematics/src/container/files/__name@dasherize@if-flat__/__name@dasherize__.component.spec.ts.template similarity index 100% rename from modules/schematics/src/container/files/__name@dasherize@if-flat__/__name@dasherize__.component__dot__spec.ts.template rename to modules/schematics/src/container/files/__name@dasherize@if-flat__/__name@dasherize__.component.spec.ts.template diff --git a/modules/schematics/src/container/index.ts b/modules/schematics/src/container/index.ts index 759066a1b6..99d1650ec9 100644 --- a/modules/schematics/src/container/index.ts +++ b/modules/schematics/src/container/index.ts @@ -139,7 +139,7 @@ export default function(options: ContainerOptions): Rule { const templateSource = apply(url('./files'), [ options.spec ? noop() - : filter(path => !path.endsWith('__spec.ts.template')), + : filter(path => !path.endsWith('.spec.ts.template')), applyTemplates({ 'if-flat': (s: string) => (options.flat ? '' : s), ...stringUtils, diff --git a/modules/store/schematics/ng-add/index.ts b/modules/store/schematics/ng-add/index.ts index f58346c068..c12caa1a4b 100644 --- a/modules/store/schematics/ng-add/index.ts +++ b/modules/store/schematics/ng-add/index.ts @@ -1,4 +1,3 @@ -import { strings } from '@angular-devkit/core'; import { Rule, SchematicContext, @@ -124,7 +123,7 @@ export default function(options: RootStoreOptions): Rule { const templateSource = apply(url('./files'), [ applyTemplates({ - ...strings, + ...stringUtils, ...options, environmentsPath, }), diff --git a/package.json b/package.json index d7d2750ad9..8e5f524d6b 100644 --- a/package.json +++ b/package.json @@ -96,7 +96,6 @@ }, "devDependencies": { "@angular-devkit/build-angular": "^0.10.0", - "@angular-devkit/core": "^7.3.3", "@angular-devkit/schematics": "^7.3.3", "@bazel/bazel": "^0.19.1", "@cypress/webpack-preprocessor": "^4.0.3", From a5bd5b16cffa226fd298fa4cb3cf576e5bf013ec Mon Sep 17 00:00:00 2001 From: Santosh Yadav Date: Fri, 1 Mar 2019 01:38:08 +0530 Subject: [PATCH 07/10] removed import from yarn.lock --- yarn.lock | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/yarn.lock b/yarn.lock index 91dd2d39c2..f96917e80c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -106,17 +106,6 @@ rxjs "6.3.3" source-map "0.7.3" -"@angular-devkit/core@7.3.3": - version "7.3.3" - resolved "https://registry.yarnpkg.com/@angular-devkit/core/-/core-7.3.3.tgz#cd6d5a8eca25ef07b6394bc2b08133d90d08d39f" - integrity sha512-fosULDtMoDWrOyUzTmBkJccOy7zodo02kENyKai7vOv9EWfv9jytkVdNc+jl0ys9OE2QadvSYBo49jhnZxFXfQ== - dependencies: - ajv "6.9.1" - chokidar "2.0.4" - fast-json-stable-stringify "2.0.0" - rxjs "6.3.3" - source-map "0.7.3" - "@angular-devkit/schematics@7.0.1": version "7.0.1" resolved "https://registry.yarnpkg.com/@angular-devkit/schematics/-/schematics-7.0.1.tgz#ccd7c5349c08aaf6224a28881bfeeacaf0ee0307" From 3cdf7f740a2d1b7bfb82aa57673427079424cfbd Mon Sep 17 00:00:00 2001 From: Santosh Yadav Date: Fri, 1 Mar 2019 01:51:12 +0530 Subject: [PATCH 08/10] removed dot and remove unused import --- modules/effects/schematics/ng-add/index.ts | 1 - modules/schematics/src/action/index.ts | 1 - modules/schematics/src/container/index.ts | 1 - modules/schematics/src/effect/index.ts | 1 - modules/schematics/src/entity/index.ts | 1 - modules/schematics/src/reducer/index.ts | 1 - package.json | 1 - yarn.lock | 8 -------- 8 files changed, 15 deletions(-) diff --git a/modules/effects/schematics/ng-add/index.ts b/modules/effects/schematics/ng-add/index.ts index dd3ed2f99f..e0853a1034 100644 --- a/modules/effects/schematics/ng-add/index.ts +++ b/modules/effects/schematics/ng-add/index.ts @@ -133,7 +133,6 @@ export default function(options: RootEffectOptions): Rule { options.group ? 'effects' : '' ), ...(options as object), - dot: () => '.', } as any), move(parsedPath.path), ]); diff --git a/modules/schematics/src/action/index.ts b/modules/schematics/src/action/index.ts index 5f662a9fdb..58b45ad5eb 100644 --- a/modules/schematics/src/action/index.ts +++ b/modules/schematics/src/action/index.ts @@ -41,7 +41,6 @@ export default function(options: ActionOptions): Rule { options.group ? 'actions' : '' ), ...options, - dot: '.', }), move(parsedPath.path), ]); diff --git a/modules/schematics/src/container/index.ts b/modules/schematics/src/container/index.ts index 99d1650ec9..81ace4cfaa 100644 --- a/modules/schematics/src/container/index.ts +++ b/modules/schematics/src/container/index.ts @@ -144,7 +144,6 @@ export default function(options: ContainerOptions): Rule { 'if-flat': (s: string) => (options.flat ? '' : s), ...stringUtils, ...(options as object), - dot: '.', } as any), move(parsedPath.path), ]); diff --git a/modules/schematics/src/effect/index.ts b/modules/schematics/src/effect/index.ts index fde516cd51..6ac96571a5 100644 --- a/modules/schematics/src/effect/index.ts +++ b/modules/schematics/src/effect/index.ts @@ -117,7 +117,6 @@ export default function(options: EffectOptions): Rule { options.group ? 'effects' : '' ), ...(options as object), - dot: '.', } as any), move(parsedPath.path), ]); diff --git a/modules/schematics/src/entity/index.ts b/modules/schematics/src/entity/index.ts index d5b8f92922..4278b6ad9e 100644 --- a/modules/schematics/src/entity/index.ts +++ b/modules/schematics/src/entity/index.ts @@ -50,7 +50,6 @@ export default function(options: EntityOptions): Rule { 'group-reducers': (s: string) => stringUtils.group(s, options.group ? 'reducers' : ''), ...(options as object), - dot: '.', } as any), move(parsedPath.path), ]); diff --git a/modules/schematics/src/reducer/index.ts b/modules/schematics/src/reducer/index.ts index ee3e608e23..0b9e9679f2 100644 --- a/modules/schematics/src/reducer/index.ts +++ b/modules/schematics/src/reducer/index.ts @@ -49,7 +49,6 @@ export default function(options: ReducerOptions): Rule { options.group ? 'reducers' : '' ), ...(options as object), - dot: '.', } as any), move(parsedPath.path), ]); diff --git a/package.json b/package.json index 8e5f524d6b..979767241f 100644 --- a/package.json +++ b/package.json @@ -96,7 +96,6 @@ }, "devDependencies": { "@angular-devkit/build-angular": "^0.10.0", - "@angular-devkit/schematics": "^7.3.3", "@bazel/bazel": "^0.19.1", "@cypress/webpack-preprocessor": "^4.0.3", "@octokit/rest": "^15.17.0", diff --git a/yarn.lock b/yarn.lock index f96917e80c..5c7cedd8df 100644 --- a/yarn.lock +++ b/yarn.lock @@ -113,14 +113,6 @@ "@angular-devkit/core" "7.0.1" rxjs "6.3.3" -"@angular-devkit/schematics@^7.3.3": - version "7.3.3" - resolved "https://registry.yarnpkg.com/@angular-devkit/schematics/-/schematics-7.3.3.tgz#80e9dc3197a3181f32edfb5c07e7ac016eace7d3" - integrity sha512-SdDq9eKwceb6WLwci1fywtZ/kARR5CYyzi5dZIR1lOxrz00682uUBqH/X39mKdqc6eVqR7rtPceqNm6nQpOIMg== - dependencies: - "@angular-devkit/core" "7.3.3" - rxjs "6.3.3" - "@angular/animations@^7.0.1": version "7.0.1" resolved "https://registry.yarnpkg.com/@angular/animations/-/animations-7.0.1.tgz#2df561c0959e156985297e69b7c30614537b4ffe" From 04bf8c54dca6e5b24dfbb51fbdc6fa4a01927eb3 Mon Sep 17 00:00:00 2001 From: Santosh Yadav Date: Fri, 1 Mar 2019 01:57:49 +0530 Subject: [PATCH 09/10] removed __dot from template --- ...=> __name@dasherize@group-reducers__.reducer.spec.ts.template} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename modules/schematics/src/entity/files/__name@dasherize@if-flat__/{__name@dasherize@group-reducers__.reducer__dot__spec.ts.template => __name@dasherize@group-reducers__.reducer.spec.ts.template} (100%) diff --git a/modules/schematics/src/entity/files/__name@dasherize@if-flat__/__name@dasherize@group-reducers__.reducer__dot__spec.ts.template b/modules/schematics/src/entity/files/__name@dasherize@if-flat__/__name@dasherize@group-reducers__.reducer.spec.ts.template similarity index 100% rename from modules/schematics/src/entity/files/__name@dasherize@if-flat__/__name@dasherize@group-reducers__.reducer__dot__spec.ts.template rename to modules/schematics/src/entity/files/__name@dasherize@if-flat__/__name@dasherize@group-reducers__.reducer.spec.ts.template From a27e9af9a6f38ba1d9633e249a34f35123f836de Mon Sep 17 00:00:00 2001 From: Santosh Yadav Date: Fri, 1 Mar 2019 02:34:00 +0530 Subject: [PATCH 10/10] rolledback changes to lock file --- yarn.lock | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/yarn.lock b/yarn.lock index 5c7cedd8df..c5f3c43255 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1350,16 +1350,6 @@ ajv@6.5.3: json-schema-traverse "^0.4.1" uri-js "^4.2.2" -ajv@6.9.1: - version "6.9.1" - resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.9.1.tgz#a4d3683d74abc5670e75f0b16520f70a20ea8dc1" - integrity sha512-XDN92U311aINL77ieWHmqCcNlwjoP5cHXDxIxbf2MaPYuCXOHS7gHH8jktxeK5omgd52XbSTX6a4Piwd1pQmzA== - dependencies: - fast-deep-equal "^2.0.1" - fast-json-stable-stringify "^2.0.0" - json-schema-traverse "^0.4.1" - uri-js "^4.2.2" - ajv@^5.0.0, ajv@^5.1.0, ajv@^5.3.0: version "5.5.2" resolved "https://registry.yarnpkg.com/ajv/-/ajv-5.5.2.tgz#73b5eeca3fab653e3d3f9422b341ad42205dc965"