Skip to content

Commit

Permalink
feat: add ngxs-schematics
Browse files Browse the repository at this point in the history
  • Loading branch information
kyusupov33 committed Oct 26, 2018
1 parent 5bd0d66 commit 0a38c39
Show file tree
Hide file tree
Showing 74 changed files with 5,515 additions and 731 deletions.
22 changes: 22 additions & 0 deletions .codeclimate.yml
@@ -0,0 +1,22 @@
version: "2"
plugins:
tslint:
enabled: true
config: tslint.json
nodesecurity:
enabled: true
checks:
method-complexity:
config:
threshold: 20
method-lines:
config:
threshold: 50
exclude_paths:
- ".github/"
- "node_modules/**/*"
- "test/**/*"
- "src/templates/**/*"
ratings:
paths:
- "src/**/**.ts"
55 changes: 55 additions & 0 deletions .github/ISSUE_TEMPLATE.md
@@ -0,0 +1,55 @@
<!--
## Feature Request?
For feature requests, delete the form below and describe the requirements and use case.
-->

<!--
## Question?
For questions, please ask them on stack overflow with the `ngxs` tag:
https://stackoverflow.com/questions/ask?tags=ngxs
This is so that the issue tracker doesn't get overrun with questions.
And stackoverflow is a better place for questions.
-->

### Versions

<!--
Please provide ther version of NGXS that you are using as well as the version of Angular
-->

```
* ngxs:
* @angular/core:
```

### Repro steps

<!--
If possible a link to a http://stackblitz.com (or github) repo with a repro or a failing test would be great.
Please provide simple steps to reproduce this bug.
Please include: commands run, packages added, related code changes.
-->

Stackblitz / Github link: https://stackblitz.com/fork/ngxs-simple

* Step 1
* Step 2
* Step 3

### Observed behavior

```
<!-- Normally this includes a stack trace and some more information. -->
```

### Desired behavior

<!--
What would like to see implemented?
What is the usecase?
What did you expect to see?
-->

### Mention any other details that might be useful (optional)
41 changes: 41 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
@@ -0,0 +1,41 @@
## PR Checklist
Please check if your PR fulfills the following requirements:

- [ ] The commit message follows our guidelines: https://github.com/ngxs/store/blob/master/CONTRIBUTING.md#commit
- [ ] Tests for the changes have been added (for bug fixes / features)
- [ ] Docs have been added / updated (for bug fixes / features)

## PR Type
What kind of change does this PR introduce?

<!-- Please check the one that applies to this PR using "x". -->
```
[ ] Bugfix
[ ] 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?
<!-- Please describe the current behavior that you are modifying, or link to a relevant issue. -->

Issue Number: N/A


## What is the new behavior?


## Does this PR introduce a breaking change?
```
[ ] Yes
[ ] No
```

<!-- If this PR contains a breaking change, please describe the impact and migration path for existing applications below. -->


## Other information
2 changes: 1 addition & 1 deletion .gitignore
@@ -1,7 +1,7 @@
# Outputs
src/**/*.js
src/**/*.js.map
src/**/*.d.ts
coverage/*

# IDEs
.idea/
Expand Down
15 changes: 15 additions & 0 deletions .npmignore
@@ -0,0 +1,15 @@
# Outputs
coverage/*

#tests
test
coverage

#build tools
.travis.yml
.codeclimate.yml

#settings
.idea
.editorconfig
.github
18 changes: 18 additions & 0 deletions .travis.yml
@@ -0,0 +1,18 @@
env:
global:
- CC_TEST_REPORTER_ID=$COVERAGE_TOKEN
language: node_js
sudo: false
node_js:
- "9.3"
before_script:
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
- chmod +x ./cc-test-reporter
- ./cc-test-reporter before-build
install:
- npm install
script:
- npm run lint
- npm run test
after_script:
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
21 changes: 21 additions & 0 deletions LICENCE
@@ -0,0 +1,21 @@
(The MIT License)

Copyright (c) 2018 Kirill Yusupov <kyusupov33@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
159 changes: 158 additions & 1 deletion README.md
@@ -1 +1,158 @@
# NGXS Schematics
<p align="center">
<img src="https://habrastorage.org/webt/y2/m3/yt/y2m3ytqadzph9hos5taqwyp6axw.png" />
</p>
<h1 align="center">Schematics</h1>
<p align="center">This repository contains schematics for generating NGXS Store in Angular apps using the Angular CLI.</p>
<p align="center">
<a href="https://travis-ci.org/ngxs/schematics"><img src="https://travis-ci.org/ngxs/schematics.svg?branch=master" /></a>
<a href="https://github.com/ngxs/schematics/blob/master/LICENCE"><img src="https://img.shields.io/badge/License-MIT-green.svg" /></a>
<a href="https://codeclimate.com/github/ngxs/schematics/maintainability"><img src="https://api.codeclimate.com/v1/badges/f5c522a094a9303cac05/maintainability" /></a>
<a href="https://codeclimate.com/github/ngxs/schematics/test_coverage"><img src="https://api.codeclimate.com/v1/badges/f5c522a094a9303cac05/test_coverage" /></a>
<a href="https://now-examples-slackin-eqzjxuxoem.now.sh/"><img src="https://now-examples-slackin-eqzjxuxoem.now.sh/badge.svg"></a>
</p>

## Installation

### Install Angular CLI

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

```bash
npm i -g @angular/cli
```

### Install NGXS Schematics
```bash
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.

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

### Create a NGXS Store
To generate store with `@ngxs/schematics`:

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

Result:

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

```

Or with spec:

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

Result:

```ts
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`:

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

Result:

```ts
CREATE src/todo/todo.state.ts

```

Or with spec:

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

Result:

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

### Create a NGXS Actions
To generate state with `@ngxs/schematics`:

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

Result:

```ts
CREATE src/todo/todo.actions.ts

```

## NGXS Starter Kit

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

```bash
ng generate @ngxs/schematics:starter-kit
```

Result:

```ts
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.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.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.ts
CREATE src/store/dashboard/states/user/model/person.model.ts
```

Or with spec:

```bash
ng generate @ngxs/schematics:starter-kit --spec
```

Result:

```ts
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
```

0 comments on commit 0a38c39

Please sign in to comment.