Skip to content

Commit 8a3e20b

Browse files
author
benholloway
committed
revised webstorm file templates
1 parent 234c127 commit 8a3e20b

15 files changed

+199
-236
lines changed

tasks/webstorm.js

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,15 +212,31 @@ gulp.task('webstorm:project', function () {
212212
gulp.task('webstorm:templates', function () {
213213
var srcDirectory = path.join(TEMPLATE_PATH, 'fileTemplates');
214214
var destDirectory = path.join(userPreferencesDirectory(), 'fileTemplates');
215+
var removed = [ ];
216+
var added = [ ];
217+
fs.readdirSync(destDirectory)
218+
.forEach(function eachTemplate(filename) {
219+
if (/^angularity/.test(path.basename(filename))) {
220+
removed.push(filename);
221+
fs.unlinkSync(path.join(destDirectory, filename));
222+
}
223+
});
215224
fs.readdirSync(srcDirectory)
216225
.forEach(function eachTemplate(filename) {
217226
var srcPath = path.join(srcDirectory, filename);
218227
var destPath = path.join(destDirectory, filename);
219-
if (!fs.existsSync(destPath)) {
220-
gutil.log('wrote template ' + filename);
221-
fs.writeFileSync(destPath, fs.readFileSync(srcPath))
228+
added.push(filename);
229+
fs.writeFileSync(destPath, fs.readFileSync(srcPath))
230+
});
231+
removed.forEach(function (filename) {
232+
var isRemove = (added.indexOf(filename) < 0);
233+
if (isRemove) {
234+
gutil.log('removed template ' + filename);
222235
}
223236
});
237+
added.forEach(function (filename) {
238+
gutil.log('wrote template ' + filename);
239+
});
224240
// TODO review with @impaler
225241
// ideTemplate.webStorm.copyFileTemplates(fileTemplatePath);
226242
});
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/* globals module, describe, beforeEach, inject, it, expect, spyOn */
2+
3+
var $declaration_to_test = require('./$file_that_exports_declaration');
4+
5+
describe('@', function() {
6+
7+
// variables
8+
var scope;
9+
/* TODO additional variables for each mock */
10+
11+
// definition
12+
angular.module('@', [ ])
13+
.controller('$declaration_to_test', $declaration_to_test);
14+
15+
// our temporary module
16+
beforeEach(angular.mock.module('@'));
17+
18+
// mocks
19+
beforeEach(function() {
20+
/* TODO create mocks and assign them to variables */
21+
});
22+
23+
// create the scope
24+
beforeEach(inject(function (${DS}rootScope, ${DS}controller /* TODO injectables.. */) {
25+
scope = ${DS}rootScope.${DS}new();
26+
${DS}controller('$declaration_to_test', {
27+
'${DS}scope': scope
28+
/* TODO map mock objects here */
29+
});
30+
}));
31+
32+
/* TODO jasmine description */
33+
34+
});
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* TODO description of this controller
3+
* @ngInject
4+
*/
5+
function $declaration(${DS}scope /*, TODO injectables.. */) {
6+
7+
// initialisation
8+
var somePrivateVar = 'delete-me';
9+
10+
// composition
11+
${DS}scope.somePublicVar = 'delete-me';
12+
${DS}scope.someMethod = someHoistedMethod;
13+
14+
/**
15+
* TODO description of this method per JSDoc
16+
*/
17+
function someHoistedMethod() {
18+
}
19+
}
20+
21+
module.exports = $declaration;
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/* globals module, describe, beforeEach, inject, it, expect, spyOn */
2+
3+
var $declaration_to_test = require('./$file_that_exports_declaration');
4+
5+
describe('@', function() {
6+
7+
// variables
8+
var scope;
9+
/* TODO additional variables for each mock */
10+
11+
// definition
12+
angular.module('@', [ ])
13+
.directive('$declaration_to_test', $declaration_to_test);
14+
15+
// our temporary module
16+
beforeEach(angular.mock.module('@'));
17+
18+
// mocks
19+
beforeEach(function() {
20+
/* TODO create mocks and assign them to variables */
21+
});
22+
23+
// create the scope
24+
beforeEach(inject(function (${DS}rootScope/*, TODO injectables.. */) {
25+
scope = ${DS}rootScope.${DS}new();
26+
/* TODO mock (contoller) methods on the scope using spies */
27+
}));
28+
29+
beforeEach(inject(function(${DS}compile) {
30+
${DS}compile(/* TODO html string goes here */)(scope);
31+
}));
32+
33+
/* TODO jasmine description */
34+
35+
});
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/**
2+
* TODO description of this Directive
3+
* @ngInject
4+
*/
5+
function $declaration(/* TODO injectables.. */) {
6+
return {
7+
scope : {
8+
/* TODO define isolated scope */
9+
foo: '@foo', /* initialise from attribute */
10+
bar: '&bar', /* 1 way binding with attribute */
11+
baz: '=baz' /* 2 way binding with attribute */
12+
},
13+
restrict : 'ACE',
14+
replace : true,
15+
transclude : false,
16+
template : require('./${NAME}.html'),
17+
templateUrl: undefined,
18+
require : undefined,
19+
link : link,
20+
controller : controller /* TODO set undefined if API is not required */
21+
};
22+
}
23+
24+
/**
25+
* The link function for the directive
26+
* @param {object} ${DS}element the DOM element
27+
* @param {object} ${DS}attributes attributes from the element
28+
* @param {object} ${DS}scope the directive scope
29+
*/
30+
function link(${DS}element, ${DS}attributes, ${DS}scope /*, TODO required controllers.. */) {
31+
/* TODO implement directive here, controller is only for API (where needed) */
32+
}
33+
34+
/**
35+
* The external API of the directive
36+
* @ngInject
37+
*/
38+
function controller(/* TODO injectables.. */) {
39+
/* TODO implement API only, delete if unused */
40+
}
41+
42+
module.exports = $declaration;

templates/webstorm/fileTemplates/angularity-es5-Controller.js

Lines changed: 0 additions & 29 deletions
This file was deleted.

templates/webstorm/fileTemplates/angularity-es5-Directive.js

Lines changed: 0 additions & 29 deletions
This file was deleted.

templates/webstorm/fileTemplates/angularity-es5-Factory.js

Lines changed: 0 additions & 21 deletions
This file was deleted.

templates/webstorm/fileTemplates/angularity-es5-TestSpec.js

Lines changed: 0 additions & 30 deletions
This file was deleted.

templates/webstorm/fileTemplates/angularity-es6-Controller.js

Lines changed: 0 additions & 34 deletions
This file was deleted.

0 commit comments

Comments
 (0)