init commit
This commit is contained in:
commit
7ac762c77f
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
node_modules
|
||||||
|
.idea
|
||||||
|
dist
|
||||||
|
build
|
||||||
19
package.json
Normal file
19
package.json
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
"name": "AngularExt",
|
||||||
|
"version": "0.0.1n",
|
||||||
|
"description": "",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"build": "./scripts/build.sh"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"typescript": "2.4.2",
|
||||||
|
"@types/node": "8.0.7",
|
||||||
|
"@types/jasmine": "2.5.53",
|
||||||
|
|
||||||
|
"@angular-devkit/core": "0.0.9",
|
||||||
|
"@angular-devkit/schematics": "0.0.9"
|
||||||
|
},
|
||||||
|
"author": "Victor Savkin",
|
||||||
|
"license": "MIT"
|
||||||
|
}
|
||||||
6
scripts/build.sh
Executable file
6
scripts/build.sh
Executable file
@ -0,0 +1,6 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
rm -rf build
|
||||||
|
rm -rf tmp
|
||||||
|
tsc
|
||||||
|
rsync -a --exclude=*.ts src/ build/
|
||||||
0
src/index.ts
Normal file
0
src/index.ts
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
export interface SomeAction {
|
||||||
|
type: 'SOME_ACTION';
|
||||||
|
payload: {};
|
||||||
|
}
|
||||||
|
|
||||||
|
export type <%= className %>Action = SomeAction;
|
||||||
|
|
||||||
@ -0,0 +1,17 @@
|
|||||||
|
import {TalksAndFiltersEffects} from './talks-and-filters.effects';
|
||||||
|
import {readAll} from '@nrwl/ext';
|
||||||
|
import {of} from 'rxjs/observable/of';
|
||||||
|
import {hot} from 'jasmine-marbles';
|
||||||
|
|
||||||
|
describe('<%= className %>Effects', () => {
|
||||||
|
describe('someEffect', () => {
|
||||||
|
it('should work', async () => {
|
||||||
|
const actions = new Actions(hot('-a-|', {a: {type: 'SOME_ACTION'}}));
|
||||||
|
const effects = new <%= className %>Effects();
|
||||||
|
|
||||||
|
expect(await readAll(effects.navigateToTalk)).toEqual([
|
||||||
|
{type: 'OTHER_ACTION'}
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
import {Injectable} from '@angular/core';
|
||||||
|
import {Effect, Actions} from '@ngrx/effects';
|
||||||
|
import {of} from 'rxjs/observable/of';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class <%= className %>Effects {
|
||||||
|
@Effect() someEffect = this.actions.ofType('SOME_ACTION').switchMap((a) => {
|
||||||
|
// process the action
|
||||||
|
return of({type: 'OTHER_ACTION'});
|
||||||
|
});
|
||||||
|
|
||||||
|
constructor(private actions: Actions) {}
|
||||||
|
}
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
import {<%= className %>} from './<%= fileName %>.interfaces';
|
||||||
|
|
||||||
|
export const <%= propertyName %>InitialState: <%= className %> = {
|
||||||
|
// fill it initial state here
|
||||||
|
};
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
export interface <%= className %> {
|
||||||
|
// define state here
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface <%= className %>State {
|
||||||
|
readonly <%= propertyName %>: <%= className %>;
|
||||||
|
}
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
import { <%= propertyName %>Reducer } from './<%= fileName %>.reducer';
|
||||||
|
import { <%= propertyName %>InitialState } from './<%= fileName %>.init';
|
||||||
|
import { <%= className %> } from './<%= fileName %>.interfaces';
|
||||||
|
import { SomeAction } from './<%= fileName %>.actions';
|
||||||
|
|
||||||
|
describe('<%= propertyName %>Reducer', () => {
|
||||||
|
it('should work', () => {
|
||||||
|
const state: <%= className %> = {};
|
||||||
|
const action: SomeAction = {type: 'SOME_ACTION', payload: {}};
|
||||||
|
const actual = <%= propertyName %>Reducer(state, action);
|
||||||
|
expect(actual).toEqual({});
|
||||||
|
});
|
||||||
|
});
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
import {<%= className %>} from './<%= fileName %>.interfaces';
|
||||||
|
import {<%= className %>Action} from './<%= fileName %>.actions';
|
||||||
|
|
||||||
|
export function <%= propertyName %>Reducer(state: <%= className %>, action: <%= className %>Action): <%= className %> {
|
||||||
|
switch (action.type) {
|
||||||
|
case 'SOME_ACTION': {
|
||||||
|
return {...state, ...action.payload};
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
14
src/schematics/addNgRxToModule/index.ts
Normal file
14
src/schematics/addNgRxToModule/index.ts
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import {apply, branchAndMerge, chain, mergeWith, Rule, template, Tree, url} from '@angular-devkit/schematics';
|
||||||
|
import { names } from "../name-utils";
|
||||||
|
|
||||||
|
export default function (options: any): Rule {
|
||||||
|
const templateSource = apply(url('./files'), [
|
||||||
|
template({...options, tmpl: '', ...names(options.name)})
|
||||||
|
]);
|
||||||
|
|
||||||
|
return chain([
|
||||||
|
branchAndMerge(chain([
|
||||||
|
mergeWith(templateSource)
|
||||||
|
])),
|
||||||
|
]);
|
||||||
|
}
|
||||||
14
src/schematics/addNgRxToModule/schema.json
Normal file
14
src/schematics/addNgRxToModule/schema.json
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"$schema": "http://json-schema.org/schema",
|
||||||
|
"id": "NewLib",
|
||||||
|
"title": "Add NgRx support to a module",
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"path": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"path"
|
||||||
|
]
|
||||||
|
}
|
||||||
11
src/schematics/collection.json
Normal file
11
src/schematics/collection.json
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"name": "nrwl",
|
||||||
|
"version": "0.1",
|
||||||
|
"schematics": {
|
||||||
|
"addNgRxToModule": {
|
||||||
|
"factory": "./addNgRxToModule",
|
||||||
|
"schema": "./addNgRxToModule/schema.json",
|
||||||
|
"description": "Add NgRx support to a module."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
26
src/schematics/name-utils.ts
Normal file
26
src/schematics/name-utils.ts
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
export function names(name: string): any {
|
||||||
|
return {
|
||||||
|
name,
|
||||||
|
className: toClassName(name),
|
||||||
|
propertyName: toPropertyName(name),
|
||||||
|
fileName: toFileName(name)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function toClassName(str: string): string {
|
||||||
|
return toCapitalCase(toPropertyName(str));
|
||||||
|
}
|
||||||
|
|
||||||
|
function toPropertyName(s: string): string {
|
||||||
|
return s
|
||||||
|
.replace(/(-|_|\.|\s)+(.)?/g, (_, __, chr) => chr ? chr.toUpperCase() : '')
|
||||||
|
.replace(/^([A-Z])/, m => m.toLowerCase());
|
||||||
|
}
|
||||||
|
|
||||||
|
function toFileName(s: string): string {
|
||||||
|
return s.replace(/([a-z\d])([A-Z])/g, '$1_$2').toLowerCase().replace(/[ _]/g, '-');
|
||||||
|
}
|
||||||
|
|
||||||
|
function toCapitalCase(s: string): string {
|
||||||
|
return s.charAt(0).toUpperCase() + s.substr(1);
|
||||||
|
}
|
||||||
17
tsconfig.json
Normal file
17
tsconfig.json
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "es5",
|
||||||
|
"module": "commonjs",
|
||||||
|
"moduleResolution": "node",
|
||||||
|
"outDir": "build",
|
||||||
|
"typeRoots": ["node_modules/@types"],
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"lib": [
|
||||||
|
"es2015"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"exclude": [
|
||||||
|
"tmp",
|
||||||
|
"node_modules"
|
||||||
|
]
|
||||||
|
}
|
||||||
50
yarn.lock
Normal file
50
yarn.lock
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
||||||
|
# yarn lockfile v1
|
||||||
|
|
||||||
|
|
||||||
|
"@angular-devkit/core@0.0.6":
|
||||||
|
version "0.0.6"
|
||||||
|
resolved "https://registry.yarnpkg.com/@angular-devkit/core/-/core-0.0.6.tgz#caf25c0c7928196e244b5fe5124256fcef6bce7c"
|
||||||
|
|
||||||
|
"@angular-devkit/core@0.0.9":
|
||||||
|
version "0.0.9"
|
||||||
|
resolved "https://registry.yarnpkg.com/@angular-devkit/core/-/core-0.0.9.tgz#d4620b4355e73f1ccbd1fe8334848d596a80e272"
|
||||||
|
|
||||||
|
"@angular-devkit/schematics@0.0.9":
|
||||||
|
version "0.0.9"
|
||||||
|
resolved "https://registry.yarnpkg.com/@angular-devkit/schematics/-/schematics-0.0.9.tgz#84668c0196648de7e88e1727b2e7defbd7962dfd"
|
||||||
|
dependencies:
|
||||||
|
"@angular-devkit/core" "0.0.6"
|
||||||
|
"@ngtools/json-schema" "^1.1.0"
|
||||||
|
minimist "^1.2.0"
|
||||||
|
rxjs "^5.4.2"
|
||||||
|
|
||||||
|
"@ngtools/json-schema@^1.1.0":
|
||||||
|
version "1.1.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/@ngtools/json-schema/-/json-schema-1.1.0.tgz#c3a0c544d62392acc2813a42c8a0dc6f58f86922"
|
||||||
|
|
||||||
|
"@types/jasmine@2.5.53":
|
||||||
|
version "2.5.53"
|
||||||
|
resolved "https://registry.yarnpkg.com/@types/jasmine/-/jasmine-2.5.53.tgz#4e0cefad09df5ec48c8dd40433512f84b1568d61"
|
||||||
|
|
||||||
|
"@types/node@8.0.7":
|
||||||
|
version "8.0.7"
|
||||||
|
resolved "https://registry.yarnpkg.com/@types/node/-/node-8.0.7.tgz#fb0ad04b5b6f6eabe0372a32a8f1fbba5c130cae"
|
||||||
|
|
||||||
|
minimist@^1.2.0:
|
||||||
|
version "1.2.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284"
|
||||||
|
|
||||||
|
rxjs@^5.4.2:
|
||||||
|
version "5.4.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-5.4.2.tgz#2a3236fcbf03df57bae06fd6972fd99e5c08fcf7"
|
||||||
|
dependencies:
|
||||||
|
symbol-observable "^1.0.1"
|
||||||
|
|
||||||
|
symbol-observable@^1.0.1:
|
||||||
|
version "1.0.4"
|
||||||
|
resolved "https://registry.yarnpkg.com/symbol-observable/-/symbol-observable-1.0.4.tgz#29bf615d4aa7121bdd898b22d4b3f9bc4e2aa03d"
|
||||||
|
|
||||||
|
typescript@2.4.2:
|
||||||
|
version "2.4.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.4.2.tgz#f8395f85d459276067c988aa41837a8f82870844"
|
||||||
Loading…
x
Reference in New Issue
Block a user