Skip to content

Commit eddb354

Browse files
committed
feat(blueprints): add enum blueprint.
* Adds a basic blueprint for a typescript enum. Closes angular#707
1 parent 679d0e6 commit eddb354

File tree

3 files changed

+48
-0
lines changed

3 files changed

+48
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export enum <%= classifiedModuleName %> {
2+
3+
}

addon/ng2/blueprints/enum/index.js

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
const stringUtils = require('ember-cli-string-utils');
2+
var dynamicPathParser = require('../../utilities/dynamic-path-parser');
3+
var addBarrelRegistration = require('../../utilities/barrel-management');
4+
5+
module.exports = {
6+
description: '',
7+
8+
normalizeEntityName: function (entityName) {
9+
var parsedPath = dynamicPathParser(this.project, entityName);
10+
11+
this.dynamicPath = parsedPath;
12+
return parsedPath.name;
13+
},
14+
15+
locals: function (options) {
16+
this.fileName = stringUtils.dasherize(options.entity.name);
17+
18+
return {
19+
dynamicPath: this.dynamicPath.dir,
20+
flat: options.flat,
21+
fileName: this.fileName
22+
};
23+
},
24+
25+
fileMapTokens: function () {
26+
// Return custom template variables here.
27+
return {
28+
__path__: () => {
29+
this.generatePath = this.dynamicPath.dir;
30+
return this.generatePath;
31+
},
32+
__name__: () => {
33+
return this.fileName;
34+
}
35+
};
36+
},
37+
38+
afterInstall: function() {
39+
return addBarrelRegistration(
40+
this,
41+
this.generatePath,
42+
this.fileName);
43+
}
44+
};

addon/ng2/commands/generate.ts

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ const aliasMap = {
5252
'cl': 'class',
5353
'c': 'component',
5454
'd': 'directive',
55+
'e': 'enum',
5556
'p': 'pipe',
5657
'r': 'route',
5758
's': 'service'

0 commit comments

Comments
 (0)