Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: feat: add schematics for @ngxs/store #3

Merged
merged 6 commits into from Oct 29, 2018
Merged

WIP: feat: add schematics for @ngxs/store #3

merged 6 commits into from Oct 29, 2018

Conversation

splincode
Copy link
Member

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[ ] Bugfix
[x] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] Other... Please describe:

What is the current behavior?

ngxs/store#35

What is the new behavior?

Installation

Install Angular CLI

You should be using @angular/cli@6.1.0 or newer.

npm i -g @angular/cli

Install NGXS Schematics

npm i -g @ngxs/schematics

Usage

Creating a new project

To generate new Angular project with NGXS Store, you can use ng new with @ngxs/schematics specified as the schematics collection.

ng new --collection=@ngxs/schematics my-app

Create a NGXS Store

To generate store with @ngxs/schematics:

ng generate @ngxs/schematics:store --name todo

Result:

CREATE src/todo/todo.actions.ts
CREATE src/todo/todo.state.ts

Or with spec:

ng generate @ngxs/schematics:store --name todo --spec

Result:

CREATE src/todo/todo.actions.ts
CREATE src/todo/todo.state.spec.ts
CREATE src/todo/todo.state.ts

Create a NGXS State

To generate state with @ngxs/schematics:

ng generate @ngxs/schematics:state --name todo

Result:

CREATE src/todo/todo.state.ts

Or with spec:

ng generate @ngxs/schematics:state --name todo --spec

Result:

CREATE src/todo/todo.state.spec.ts
CREATE src/todo/todo.state.ts

Create a NGXS Actions

To generate state with @ngxs/schematics:

ng generate @ngxs/schematics:actions --name todo

Result:

CREATE src/todo/todo.actions.ts

NGXS Starter Kit

Usage

To generate store with @ngxs/schematics:starter-kit:

ng generate @ngxs/schematics:starter-kit

Result:

CREATE src/store/store.config.ts
CREATE src/store/store.module.ts
CREATE src/store/auth/auth.actions.ts
CREATE src/store/auth/auth.state.spec.ts
CREATE src/store/auth/auth.state.ts
CREATE src/store/auth/model/auth.model.ts
CREATE src/store/dashboard/index.ts
CREATE src/store/dashboard/states/dictionary/dictionary.actions.ts
CREATE src/store/dashboard/states/dictionary/dictionary.state.spec.ts
CREATE src/store/dashboard/states/dictionary/dictionary.state.ts
CREATE src/store/dashboard/states/dictionary/model/dictionary-response.model.ts
CREATE src/store/dashboard/states/user/user.actions.ts
CREATE src/store/dashboard/states/user/user.state.spec.ts
CREATE src/store/dashboard/states/user/user.state.ts
CREATE src/store/dashboard/states/user/model/person.model.ts

Does this PR introduce a breaking change?

[ ] Yes
[x] No

@splincode splincode added this to the v1.0.0 milestone Oct 18, 2018
Copy link
Member

@markwhitfeld markwhitfeld left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing! The only thing that needs to be tweaked is that the StateModel definitions should be interfaces and not classes. Strictly you should only store plain old javascript objects in your store, not any objects with prototypes or classes

@kyusupov33
Copy link
Collaborator

WIP

@kyusupov33 kyusupov33 self-assigned this Oct 24, 2018
@kyusupov33 kyusupov33 added the enhancement New feature or request label Oct 24, 2018
@splincode splincode changed the title feat: add schematics for @ngxs/store WIP: feat: add schematics for @ngxs/store Oct 26, 2018
@splincode splincode removed the request for review from amcdnl October 28, 2018 17:43
Copy link
Member

@markwhitfeld markwhitfeld left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost there.
Just a few variable name updates and an old library name left around.
Also we could potentially improve the auth module in the starter kit, but it depends on how far you want to go here. I think we could tweak the auth template later though after merging.
PS Just push a new commit into your branch with the fixes as opposed to squashing or rebasing so that it makes it easier to see the changes after this review. Thanks!

Copy link
Member

@markwhitfeld markwhitfeld left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few more small tweaks

src/templates/starter-kit/store/auth/auth.state.ts Outdated Show resolved Hide resolved
src/templates/starter-kit/store/auth/auth.state.spec.ts Outdated Show resolved Hide resolved
src/templates/starter-kit/store/auth/auth.state.spec.ts Outdated Show resolved Hide resolved
Copy link
Member

@markwhitfeld markwhitfeld left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Nicely done!

@markwhitfeld markwhitfeld merged commit c9dd9b9 into master Oct 29, 2018
@markwhitfeld markwhitfeld deleted the develop branch October 29, 2018 19:03
@markwhitfeld markwhitfeld restored the develop branch October 29, 2018 19:03
markwhitfeld pushed a commit that referenced this pull request Oct 29, 2018
feat: add schematics for @ngxs/store (#3)
@ahnpnl
Copy link

ahnpnl commented Dec 1, 2018

Hi, I have a question regarding to this feature. Would it be possible to have a sorter command line ? Something like ng generate ngxs (inspired from nrwl ). In my opinion, @ngxs/schematics is kind of long to type.

@splincode
Copy link
Member Author

Create issue please

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants