forked from nrwl/nx
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 7ac762c
Showing
17 changed files
with
236 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
node_modules | ||
.idea | ||
dist | ||
build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/bash | ||
|
||
rm -rf build | ||
rm -rf tmp | ||
tsc | ||
rsync -a --exclude=*.ts src/ build/ |
Empty file.
7 changes: 7 additions & 0 deletions
7
src/schematics/addNgRxToModule/files/+state/__fileName__.actions.ts__tmpl__
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export interface SomeAction { | ||
type: 'SOME_ACTION'; | ||
payload: {}; | ||
} | ||
|
||
export type <%= className %>Action = SomeAction; | ||
|
17 changes: 17 additions & 0 deletions
17
src/schematics/addNgRxToModule/files/+state/__fileName__.effects.spec.ts__tmpl__
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'} | ||
]); | ||
}); | ||
}); | ||
}); |
13 changes: 13 additions & 0 deletions
13
src/schematics/addNgRxToModule/files/+state/__fileName__.effects.ts__tmpl__
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) {} | ||
} |
5 changes: 5 additions & 0 deletions
5
src/schematics/addNgRxToModule/files/+state/__fileName__.init.ts__tmpl__
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import {<%= className %>} from './<%= fileName %>.interfaces'; | ||
|
||
export const <%= propertyName %>InitialState: <%= className %> = { | ||
// fill it initial state here | ||
}; |
7 changes: 7 additions & 0 deletions
7
src/schematics/addNgRxToModule/files/+state/__fileName__.interfaces.ts__tmpl__
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export interface <%= className %> { | ||
// define state here | ||
} | ||
|
||
export interface <%= className %>State { | ||
readonly <%= propertyName %>: <%= className %>; | ||
} |
13 changes: 13 additions & 0 deletions
13
src/schematics/addNgRxToModule/files/+state/__fileName__.reducer.spec.ts__tmpl__
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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({}); | ||
}); | ||
}); |
13 changes: 13 additions & 0 deletions
13
src/schematics/addNgRxToModule/files/+state/__fileName__.reducer.ts__tmpl__
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
])), | ||
]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"name": "nrwl", | ||
"version": "0.1", | ||
"schematics": { | ||
"addNgRxToModule": { | ||
"factory": "./addNgRxToModule", | ||
"schema": "./addNgRxToModule/schema.json", | ||
"description": "Add NgRx support to a module." | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. | ||
# yarn lockfile v1 | ||
|
||
|
||
"@angular-devkit/[email protected]": | ||
version "0.0.6" | ||
resolved "https://registry.yarnpkg.com/@angular-devkit/core/-/core-0.0.6.tgz#caf25c0c7928196e244b5fe5124256fcef6bce7c" | ||
|
||
"@angular-devkit/[email protected]": | ||
version "0.0.9" | ||
resolved "https://registry.yarnpkg.com/@angular-devkit/core/-/core-0.0.9.tgz#d4620b4355e73f1ccbd1fe8334848d596a80e272" | ||
|
||
"@angular-devkit/[email protected]": | ||
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/[email protected]": | ||
version "2.5.53" | ||
resolved "https://registry.yarnpkg.com/@types/jasmine/-/jasmine-2.5.53.tgz#4e0cefad09df5ec48c8dd40433512f84b1568d61" | ||
|
||
"@types/[email protected]": | ||
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" | ||
|
||
[email protected]: | ||
version "2.4.2" | ||
resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.4.2.tgz#f8395f85d459276067c988aa41837a8f82870844" |