Skip to content

Commit

Permalink
feat(Schematcis): Extend from @schematics/angular
Browse files Browse the repository at this point in the history
BREAKING CHANGE:
  NgRx Schematics now has a minimum version dependency on @angular-devkit/core
  and @angular-devkit/schematics of v0.4.0.
  • Loading branch information
MichaelWarneke authored and MikeRyanDev committed Mar 30, 2018
1 parent bd415a1 commit 0e17aad
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 46 deletions.
46 changes: 1 addition & 45 deletions modules/schematics/collection.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"extends": ["@schematics/angular"],
"schematics": {
"action": {
"aliases": [ "a" ],
Expand All @@ -7,28 +8,13 @@
"description": "Add store actions"
},

"class": {
"aliases": [ "cl" ],
"extends": "@schematics/angular:class"
},

"component": {
"aliases": [ "c" ],
"extends": "@schematics/angular:component"
},

"container": {
"aliases": [ "co" ],
"factory": "./src/container",
"schema": "./src/container/schema.json",
"description": "Add store container component"
},

"directive": {
"aliases": [ "d" ],
"extends": "@schematics/angular:directive"
},

"effect": {
"aliases": [ "ef" ],
"factory": "./src/effect",
Expand All @@ -43,50 +29,20 @@
"description": "Add entity state"
},

"enum": {
"aliases": [ "e" ],
"extends": "@schematics/angular:enum"
},

"feature": {
"aliases": [ "f" ],
"factory": "./src/feature",
"schema": "./src/feature/schema.json",
"description": "Add feature state"
},

"guard": {
"aliases": [ "g" ],
"extends": "@schematics/angular:guard"
},

"interface": {
"aliases": [ "i" ],
"extends": "@schematics/angular:interface"
},

"module": {
"aliases": [ "m" ],
"extends": "@schematics/angular:module"
},

"pipe": {
"aliases": [ "p" ],
"extends": "@schematics/angular:pipe"
},

"reducer": {
"aliases": [ "r" ],
"factory": "./src/reducer",
"schema": "./src/reducer/schema.json",
"description": "Add state reducer"
},

"service": {
"aliases": [ "s" ],
"extends": "@schematics/angular:service"
},

"store": {
"aliases": [ "st" ],
"factory": "./src/store",
Expand Down
6 changes: 5 additions & 1 deletion modules/schematics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,9 @@
"url": "https://github.com/ngrx/platform/issues"
},
"homepage": "https://github.com/ngrx/platform#readme",
"schematics": "./collection.json"
"schematics": "./collection.json",
"peerDependencies": {
"@angular-devkit/core": "^0.4.0",
"@angular-devkit/schematics": "^0.4.0"
}
}
28 changes: 28 additions & 0 deletions modules/schematics/src/cli.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { Tree, VirtualTree } from '@angular-devkit/schematics';
import { SchematicTestRunner } from '@angular-devkit/schematics/testing';
import * as path from 'path';
import { createAppModule, getFileContent } from './utility/test';

describe('CLI Schematic', () => {
const schematicRunner = new SchematicTestRunner(
'@ngrx/schematics',
path.join(__dirname, '../collection.json')
);
const defaultOptions = {
name: 'foo',
};

let appTree: Tree;

beforeEach(() => {
appTree = new VirtualTree();
appTree = createAppModule(appTree);
});

it('should create a class by the angular/cli', () => {
const options = { ...defaultOptions, state: undefined };
const tree = schematicRunner.runSchematic('class', options, appTree);
const content = getFileContent(tree, '/src/app/foo.ts');
expect(content).toMatch(/export class Foo/);
});
});

0 comments on commit 0e17aad

Please sign in to comment.