Skip to content

Commit 0e17aad

Browse files
MichaelWarnekeMikeRyanDev
authored andcommitted
feat(Schematcis): Extend from @schematics/angular
BREAKING CHANGE: NgRx Schematics now has a minimum version dependency on @angular-devkit/core and @angular-devkit/schematics of v0.4.0.
1 parent bd415a1 commit 0e17aad

File tree

3 files changed

+34
-46
lines changed

3 files changed

+34
-46
lines changed

modules/schematics/collection.json

Lines changed: 1 addition & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"extends": ["@schematics/angular"],
23
"schematics": {
34
"action": {
45
"aliases": [ "a" ],
@@ -7,28 +8,13 @@
78
"description": "Add store actions"
89
},
910

10-
"class": {
11-
"aliases": [ "cl" ],
12-
"extends": "@schematics/angular:class"
13-
},
14-
15-
"component": {
16-
"aliases": [ "c" ],
17-
"extends": "@schematics/angular:component"
18-
},
19-
2011
"container": {
2112
"aliases": [ "co" ],
2213
"factory": "./src/container",
2314
"schema": "./src/container/schema.json",
2415
"description": "Add store container component"
2516
},
2617

27-
"directive": {
28-
"aliases": [ "d" ],
29-
"extends": "@schematics/angular:directive"
30-
},
31-
3218
"effect": {
3319
"aliases": [ "ef" ],
3420
"factory": "./src/effect",
@@ -43,50 +29,20 @@
4329
"description": "Add entity state"
4430
},
4531

46-
"enum": {
47-
"aliases": [ "e" ],
48-
"extends": "@schematics/angular:enum"
49-
},
50-
5132
"feature": {
5233
"aliases": [ "f" ],
5334
"factory": "./src/feature",
5435
"schema": "./src/feature/schema.json",
5536
"description": "Add feature state"
5637
},
5738

58-
"guard": {
59-
"aliases": [ "g" ],
60-
"extends": "@schematics/angular:guard"
61-
},
62-
63-
"interface": {
64-
"aliases": [ "i" ],
65-
"extends": "@schematics/angular:interface"
66-
},
67-
68-
"module": {
69-
"aliases": [ "m" ],
70-
"extends": "@schematics/angular:module"
71-
},
72-
73-
"pipe": {
74-
"aliases": [ "p" ],
75-
"extends": "@schematics/angular:pipe"
76-
},
77-
7839
"reducer": {
7940
"aliases": [ "r" ],
8041
"factory": "./src/reducer",
8142
"schema": "./src/reducer/schema.json",
8243
"description": "Add state reducer"
8344
},
8445

85-
"service": {
86-
"aliases": [ "s" ],
87-
"extends": "@schematics/angular:service"
88-
},
89-
9046
"store": {
9147
"aliases": [ "st" ],
9248
"factory": "./src/store",

modules/schematics/package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,9 @@
2020
"url": "https://github.com/ngrx/platform/issues"
2121
},
2222
"homepage": "https://github.com/ngrx/platform#readme",
23-
"schematics": "./collection.json"
23+
"schematics": "./collection.json",
24+
"peerDependencies": {
25+
"@angular-devkit/core": "^0.4.0",
26+
"@angular-devkit/schematics": "^0.4.0"
27+
}
2428
}

modules/schematics/src/cli.spec.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { Tree, VirtualTree } from '@angular-devkit/schematics';
2+
import { SchematicTestRunner } from '@angular-devkit/schematics/testing';
3+
import * as path from 'path';
4+
import { createAppModule, getFileContent } from './utility/test';
5+
6+
describe('CLI Schematic', () => {
7+
const schematicRunner = new SchematicTestRunner(
8+
'@ngrx/schematics',
9+
path.join(__dirname, '../collection.json')
10+
);
11+
const defaultOptions = {
12+
name: 'foo',
13+
};
14+
15+
let appTree: Tree;
16+
17+
beforeEach(() => {
18+
appTree = new VirtualTree();
19+
appTree = createAppModule(appTree);
20+
});
21+
22+
it('should create a class by the angular/cli', () => {
23+
const options = { ...defaultOptions, state: undefined };
24+
const tree = schematicRunner.runSchematic('class', options, appTree);
25+
const content = getFileContent(tree, '/src/app/foo.ts');
26+
expect(content).toMatch(/export class Foo/);
27+
});
28+
});

0 commit comments

Comments
 (0)