From e0981dedc34b40cfcfc696cc7b3474301fe209b4 Mon Sep 17 00:00:00 2001 From: profanis Date: Mon, 18 Dec 2023 20:49:22 +0200 Subject: [PATCH] fix(schematics): dasherize the state and store file name (#2090) * fix(schematics): dasherize the state and store file name * chore: remove public access modifier --- .../src/actions/files/__name__.actions.ts__template__ | 4 ++-- .../files/store/auth/auth.actions.ts__template__ | 5 ++--- .../files/store/auth/auth.state.ts__template__ | 4 ++-- .../states/dictionary/dictionary.actions.ts__template__ | 9 +++------ .../states/dictionary/dictionary.state.ts__template__ | 8 ++++---- .../dashboard/states/user/user.actions.ts__template__ | 4 ++-- .../dashboard/states/user/user.state.ts__template__ | 4 ++-- .../src/state/files/__name__.state.ts__template__ | 2 +- packages/store/schematics/src/state/state.factory.ts | 7 ++++++- .../src/store/files/__name__.actions.ts__template__ | 6 +++--- .../src/store/files/__name__.state.ts__template__ | 4 ++-- packages/store/schematics/src/store/store.factory.ts | 7 ++++++- 12 files changed, 35 insertions(+), 29 deletions(-) diff --git a/packages/store/schematics/src/actions/files/__name__.actions.ts__template__ b/packages/store/schematics/src/actions/files/__name__.actions.ts__template__ index 14ea951d9..3a6be5065 100644 --- a/packages/store/schematics/src/actions/files/__name__.actions.ts__template__ +++ b/packages/store/schematics/src/actions/files/__name__.actions.ts__template__ @@ -1,4 +1,4 @@ export class <%= classify(name) %>Action { - public static readonly type = '[<%= classify(name) %>] Add item'; - constructor(public payload: any) { } + static readonly type = '[<%= classify(name) %>] Add item'; + constructor(readonly payload: any) { } } diff --git a/packages/store/schematics/src/starter-kit/files/store/auth/auth.actions.ts__template__ b/packages/store/schematics/src/starter-kit/files/store/auth/auth.actions.ts__template__ index ac8baf382..59c74077f 100644 --- a/packages/store/schematics/src/starter-kit/files/store/auth/auth.actions.ts__template__ +++ b/packages/store/schematics/src/starter-kit/files/store/auth/auth.actions.ts__template__ @@ -1,7 +1,6 @@ import { AuthenticationStateModel } from './auth.state'; export class SetAuthData { - public static readonly type = '[Auth] Auth data'; - - constructor(public payload: AuthenticationStateModel) {} + static readonly type = '[Auth] Auth data'; + constructor(readonly payload: AuthenticationStateModel) {} } diff --git a/packages/store/schematics/src/starter-kit/files/store/auth/auth.state.ts__template__ b/packages/store/schematics/src/starter-kit/files/store/auth/auth.state.ts__template__ index 0af651207..00599260f 100644 --- a/packages/store/schematics/src/starter-kit/files/store/auth/auth.state.ts__template__ +++ b/packages/store/schematics/src/starter-kit/files/store/auth/auth.state.ts__template__ @@ -25,7 +25,7 @@ export interface AuthenticationStateModel { @Injectable() export class AuthState { @Selector() - public static getAuthData(state: AuthenticationStateModel): AuthenticationStateModel { + static getAuthData(state: AuthenticationStateModel): AuthenticationStateModel { return AuthState.getInstanceState(state); } @@ -38,7 +38,7 @@ export class AuthState { } @Action(SetAuthData) - public setAuthData( + setAuthData( { setState }: StateContext, { payload }: SetAuthData ) { diff --git a/packages/store/schematics/src/starter-kit/files/store/dashboard/states/dictionary/dictionary.actions.ts__template__ b/packages/store/schematics/src/starter-kit/files/store/dashboard/states/dictionary/dictionary.actions.ts__template__ index 9a1a476f5..1c990c96f 100644 --- a/packages/store/schematics/src/starter-kit/files/store/dashboard/states/dictionary/dictionary.actions.ts__template__ +++ b/packages/store/schematics/src/starter-kit/files/store/dashboard/states/dictionary/dictionary.actions.ts__template__ @@ -1,13 +1,10 @@ import { DictionaryStateModel } from './dictionary.state'; export class SetDictionaryData { - public static readonly type = '[Dictionary] Set dictionary data action'; - - constructor(public payload: DictionaryStateModel) {} + static readonly type = '[Dictionary] Set dictionary data action'; + constructor(readonly payload: DictionaryStateModel) {} } export class DictionaryReset { - public static readonly type = '[Dictionary] Reset dictionary action'; - - constructor() {} + static readonly type = '[Dictionary] Reset dictionary action'; } diff --git a/packages/store/schematics/src/starter-kit/files/store/dashboard/states/dictionary/dictionary.state.ts__template__ b/packages/store/schematics/src/starter-kit/files/store/dashboard/states/dictionary/dictionary.state.ts__template__ index 861a6c250..64631cedf 100644 --- a/packages/store/schematics/src/starter-kit/files/store/dashboard/states/dictionary/dictionary.state.ts__template__ +++ b/packages/store/schematics/src/starter-kit/files/store/dashboard/states/dictionary/dictionary.state.ts__template__ @@ -23,12 +23,12 @@ export interface DictionaryStateModel { @Injectable() export class DictionaryState { @Selector() - public static getDictionaryState(state: DictionaryStateModel): DictionaryStateModel { + static getDictionaryState(state: DictionaryStateModel): DictionaryStateModel { return DictionaryState.getInstanceState(state); } @Selector() - public static getDictionaryContent(state: DictionaryStateModel) { + static getDictionaryContent(state: DictionaryStateModel) { return state.content; } @@ -41,7 +41,7 @@ export class DictionaryState { } @Action(SetDictionaryData) - public setTasks( + setTasks( { setState }: StateContext, { payload }: SetDictionaryData ) { @@ -49,7 +49,7 @@ export class DictionaryState { } @Action(DictionaryReset) - public resetTasks({ setState }: StateContext) { + resetTasks({ setState }: StateContext) { const initialState = { content: [], page: 0, diff --git a/packages/store/schematics/src/starter-kit/files/store/dashboard/states/user/user.actions.ts__template__ b/packages/store/schematics/src/starter-kit/files/store/dashboard/states/user/user.actions.ts__template__ index cf8ac07be..ac1f41299 100644 --- a/packages/store/schematics/src/starter-kit/files/store/dashboard/states/user/user.actions.ts__template__ +++ b/packages/store/schematics/src/starter-kit/files/store/dashboard/states/user/user.actions.ts__template__ @@ -1,6 +1,6 @@ import { UserStateModel } from './user.state'; export class SetUser { - public static readonly type = '[SetUser] action'; - constructor(public payload: UserStateModel) {} + static readonly type = '[SetUser] action'; + constructor(readonly payload: UserStateModel) {} } diff --git a/packages/store/schematics/src/starter-kit/files/store/dashboard/states/user/user.state.ts__template__ b/packages/store/schematics/src/starter-kit/files/store/dashboard/states/user/user.state.ts__template__ index ad230f354..87f3cb93f 100644 --- a/packages/store/schematics/src/starter-kit/files/store/dashboard/states/user/user.state.ts__template__ +++ b/packages/store/schematics/src/starter-kit/files/store/dashboard/states/user/user.state.ts__template__ @@ -31,12 +31,12 @@ export interface UserStateModel { @Injectable() export class UserState { @Selector() - public static getUser(state: UserStateModel): UserStateModel { + static getUser(state: UserStateModel): UserStateModel { return state; } @Action(SetUser) - public setUser(ctx: StateContext, { payload }: SetUser) { + setUser(ctx: StateContext, { payload }: SetUser) { ctx.setState(payload); } } diff --git a/packages/store/schematics/src/state/files/__name__.state.ts__template__ b/packages/store/schematics/src/state/files/__name__.state.ts__template__ index 79f4b4fea..37f1fbbb7 100644 --- a/packages/store/schematics/src/state/files/__name__.state.ts__template__ +++ b/packages/store/schematics/src/state/files/__name__.state.ts__template__ @@ -15,7 +15,7 @@ export interface <%= classify(name) %>StateModel { export class <%= classify(name) %>State { @Selector() - public static getState(state: <%= classify(name) %>StateModel) { + static getState(state: <%= classify(name) %>StateModel) { return state; } diff --git a/packages/store/schematics/src/state/state.factory.ts b/packages/store/schematics/src/state/state.factory.ts index 3559ea2cb..c4ae47ee3 100644 --- a/packages/store/schematics/src/state/state.factory.ts +++ b/packages/store/schematics/src/state/state.factory.ts @@ -21,6 +21,11 @@ export function state(options: StateSchema): Rule { ? normalizedOptions.path : join(normalizedOptions.path, normalizedOptions.name); - return generateFiles(url('./files'), path, { ...options, isStandalone }, options.spec); + return generateFiles( + url('./files'), + path, + { ...normalizedOptions, isStandalone }, + options.spec + ); }; } diff --git a/packages/store/schematics/src/store/files/__name__.actions.ts__template__ b/packages/store/schematics/src/store/files/__name__.actions.ts__template__ index 7866f3334..462433db2 100644 --- a/packages/store/schematics/src/store/files/__name__.actions.ts__template__ +++ b/packages/store/schematics/src/store/files/__name__.actions.ts__template__ @@ -1,4 +1,4 @@ export class <%= classify(name) %>Action { - public static readonly type = '[<%= classify(name) %>] Add item'; - constructor(public payload: string) { } -} \ No newline at end of file + static readonly type = '[<%= classify(name) %>] Add item'; + constructor(readonly payload: string) { } +} diff --git a/packages/store/schematics/src/store/files/__name__.state.ts__template__ b/packages/store/schematics/src/store/files/__name__.state.ts__template__ index f4bfbb2bc..fe39e428e 100644 --- a/packages/store/schematics/src/store/files/__name__.state.ts__template__ +++ b/packages/store/schematics/src/store/files/__name__.state.ts__template__ @@ -16,12 +16,12 @@ export interface <%= classify(name) %>StateModel { export class <%= classify(name) %>State { @Selector() - public static getState(state: <%= classify(name) %>StateModel) { + static getState(state: <%= classify(name) %>StateModel) { return state; } @Action(<%= classify(name) %>Action) - public add(ctx: StateContext<<%= classify(name) %>StateModel>, { payload }: <%= classify(name) %>Action) { + add(ctx: StateContext<<%= classify(name) %>StateModel>, { payload }: <%= classify(name) %>Action) { const stateModel = ctx.getState(); stateModel.items = [...stateModel.items, payload]; ctx.setState(stateModel); diff --git a/packages/store/schematics/src/store/store.factory.ts b/packages/store/schematics/src/store/store.factory.ts index 486043446..9f461d692 100644 --- a/packages/store/schematics/src/store/store.factory.ts +++ b/packages/store/schematics/src/store/store.factory.ts @@ -21,6 +21,11 @@ export function store(options: StoreSchema): Rule { ? normalizedOptions.path : join(normalizedOptions.path, normalizedOptions.name); - return generateFiles(url('./files'), path, { ...options, isStandalone }, options.spec); + return generateFiles( + url('./files'), + path, + { ...normalizedOptions, isStandalone }, + options.spec + ); }; }