@@ -60,14 +60,18 @@ module.exports = function (grunt) {
6060 babel : {
6161 files : [ '<%%= yeoman.client %>/{app,components}/**/!(*.spec|*.mock).js' ] ,
6262 tasks : [ 'newer:babel:client' ]
63+ } , < % } % > < % if ( filters . ts ) { % >
64+ ts : {
65+ files : [ '<%%= yeoman.client %>/{app,components}/**/!(*.spec|*.mock).ts' ] ,
66+ tasks : [ 'ts:client' ]
6367 } , < % } % >
6468 ngconstant: {
6569 files : [ '<%%= yeoman.server %>/config/environment/shared.js' ] ,
6670 tasks : [ 'ngconstant' ]
6771 } ,
6872 injectJS: {
6973 files : [
70- '<%%= yeoman.client %>/{app,components}/**/!(*.spec|*.mock).js ' ,
74+ '<%%= yeoman.client %>/{app,components}/**/!(*.spec|*.mock).<%= scriptExt %> ' ,
7175 '!<%%= yeoman.client %>/app/app.js'
7276 ] ,
7377 tasks : [ 'injector:scripts' ]
@@ -77,12 +81,12 @@ module.exports = function (grunt) {
7781 tasks : [ 'injector:css' ]
7882 } ,
7983 mochaTest: {
80- files : [ '<%%= yeoman.server %>/**/*.{spec,integration}.js ' ] ,
84+ files : [ '<%%= yeoman.server %>/**/*.{spec,integration}.<%= scriptExt %> ' ] ,
8185 tasks : [ 'env:test' , 'mochaTest' ]
8286 } ,
8387 jsTest: {
84- files : [ '<%%= yeoman.client %>/{app,components}/**/*.{spec,mock}.js ' ] ,
85- tasks : [ 'newer:jshint:all' , 'wiredep:test' , 'karma' ]
88+ files : [ '<%%= yeoman.client %>/{app,components}/**/*.{spec,mock}.<%= scriptExt %> ' ] ,
89+ tasks : [ < % if ( filters . babel ) { % > 'newer:jshint:all' < % } if(filters.ts) { % > 'newer:tslint:all' , 'newer:ts:client_test' , < % } % > , 'wiredep :test ', 'karma ']
8690 } , < % if ( filters . stylus ) { % >
8791 injectStylus: {
8892 files : [ '<%%= yeoman.client %>/{app,components}/**/*.styl' ] ,
@@ -118,7 +122,7 @@ module.exports = function (grunt) {
118122 livereload: {
119123 files : [
120124 '{.tmp,<%%= yeoman.client %>}/{app,components}/**/*.{css,html}' ,
121- '{.tmp,<%%= yeoman.client %>}/{app,components}/**/!(*.spec|*.mock).js ' ,
125+ '{.tmp,<%%= yeoman.client %>}/{app,components}/**/!(*.spec|*.mock).<%= scriptExt %> ' ,
122126 '<%%= yeoman.client %>/assets/images/{,*//*}*.{png,jpg,jpeg,gif,webp,svg}'
123127 ] ,
124128 options : {
@@ -161,7 +165,16 @@ module.exports = function (grunt) {
161165 test : {
162166 src : [ '<%%= yeoman.client %>/{app,components}/**/*.{spec,mock}.js' ]
163167 }
164- } ,
168+ } ,< % if ( filters . ts ) { % >
169+
170+ tslint: {
171+ options : {
172+ configuration : '<%%= yeoman.client %>/tslint.json'
173+ } ,
174+ all : {
175+ src : [ '<%%= yeoman.client %>/{app,components}/**/!(*.spec|*.mock).ts' ]
176+ }
177+ } ,< % } % >
165178
166179 jscs: {
167180 options : {
@@ -420,7 +433,13 @@ module.exports = function (grunt) {
420433 cwd : '<%%= yeoman.client %>' ,
421434 dest : '.tmp/' ,
422435 src : [ '{app,components}/**/*.css' ]
423- }
436+ } < % if ( filters . ts ) { % > ,
437+ constant : {
438+ expand : true ,
439+ cwd : '<%%= yeoman.client %>' ,
440+ dest : '.tmp/' ,
441+ src : [ 'app/app.constant.js' ]
442+ } < % } %>
424443 } ,
425444
426445 buildcontrol : {
@@ -451,17 +470,23 @@ module.exports = function (grunt) {
451470 'injector:stylus' , < % } if (filters.less) { % >
452471 'injector:less' , < % } if (filters.sass) { % >
453472 'injector:sass' , < % } %>
454- 'ngconstant '
473+ 'ngconstant '< % if ( filters . ts ) { % > ,
474+ 'copy:constant'< % } % >
455475 ],
456476 server: [< % if ( filters . babel ) { % >
457- 'newer:babel:client',< % } if ( filters . jade ) { % >
477+ 'newer:babel:client',< % } if ( filters . ts ) { % >
478+ 'ts:client',
479+ 'copy:constant',< % } if ( filters . jade ) { % >
458480 'jade',< % } if ( filters . stylus ) { % >
459481 'stylus',< % } if ( filters . sass ) { % >
460482 'sass',< % } if ( filters . less ) { % >
461483 'less',< % } % >
462484 ],
463485 test: [< % if ( filters . babel ) { % >
464- 'newer:babel:client',< % } if ( filters . jade ) { % >
486+ 'newer:babel:client',< % } if ( filters . ts ) { % >
487+ 'ts:client',
488+ 'copy:constant',< % } if ( filters . ts ) { % >
489+ 'ts:client_test',< % } if ( filters . jade ) { % >
465490 'jade',< % } if ( filters . stylus ) { % >
466491 'stylus',< % } if ( filters . sass ) { % >
467492 'sass',< % } if ( filters . less ) { % >
@@ -477,7 +502,9 @@ module.exports = function (grunt) {
477502 }
478503 } ,
479504 dist: [< % if ( filters . babel ) { % >
480- 'newer:babel:client',< % } if ( filters . jade ) { % >
505+ 'newer:babel:client',< % } if ( filters . ts ) { % >
506+ 'ts:client',
507+ 'copy:constant',< % } if ( filters . jade ) { % >
481508 'jade',< % } if ( filters . stylus ) { % >
482509 'stylus',< % } if ( filters . sass ) { % >
483510 'sass',< % } if ( filters . less ) { % >
@@ -613,7 +640,37 @@ module.exports = function (grunt) {
613640 dest : '<%%= yeoman.dist %>/<%%= yeoman.server %>'
614641 } ]
615642 }
616- } , < % if ( filters . stylus ) { % >
643+ } , < % if ( filters . ts ) { % >
644+
645+ ts: {
646+ options : {
647+ sourceMap : true ,
648+ failOnTypeErrors : false
649+ } ,
650+ client : {
651+ tsconfig : './tsconfig.client.json' ,
652+ outDir : '.tmp'
653+ } ,
654+ client_test : {
655+ tsconfig : './tsconfig.client.test.json' ,
656+ outDir : '.tmp/test'
657+ }
658+ } ,
659+
660+ tsd: {
661+ install : {
662+ options : {
663+ command : 'reinstall' ,
664+ config : './tsd.json'
665+ }
666+ } ,
667+ install_test : {
668+ options : {
669+ command : 'reinstall' ,
670+ config : './tsd_test.json'
671+ }
672+ }
673+ } ,< % } % > < % if ( filters . stylus ) { % >
617674
618675 // Compiles Stylus to CSS
619676 stylus: {
@@ -649,16 +706,15 @@ module.exports = function (grunt) {
649706 } ,< % } % >
650707
651708 injector: {
652- options : {
653-
654- } ,
709+ options : { } ,
655710 // Inject application script files into index.html (doesn't include bower)
656711 scripts: {
657712 options : {
658713 transform : function ( filePath ) {
659714 var yoClient = grunt . config . get ( 'yeoman.client' ) ;
660715 filePath = filePath . replace ( '/' + yoClient + '/' , '' ) ;
661- filePath = filePath . replace ( '/.tmp/' , '' ) ;
716+ filePath = filePath . replace ( '/.tmp/' , '' ) ; < % if ( filters . ts ) { % >
717+ filePath = filePath . replace ( '.ts' , '.js' ) ; < % } % >
662718 return '<script src="' + filePath + '"></script>' ;
663719 } ,
664720 sort : function ( a , b ) {
@@ -673,10 +729,10 @@ module.exports = function (grunt) {
673729 } ,
674730 files : {
675731 '<%%= yeoman.client %>/index.html' : [
676- [ < % if ( filters . babel ) { % >
677- '.tmp /{app,components}/**/!(*.spec|*.mock).js ' , < % } else { % >
678- '{.tmp, <%%= yeoman.client %>}/{ app,components}/**/!(*.spec|*.mock) .js' , < % } % >
679- '!{ . tmp , < % %= yeoman . client % > } /app/app.js '
732+ [
733+ '<%%= yeoman.client %> /{app,components}/**/!(*.spec|*.mock).<%= scriptExt %> ' , < % if ( filters . ts ) { % >
734+ '<%%= yeoman.client %>/ app/app.constant .js' , < % } % >
735+ '!{ . tmp , < % %= yeoman . client % > } /app/app.{ js , ts } '
680736 ]
681737 ]
682738 }
@@ -788,7 +844,8 @@ module.exports = function (grunt) {
788844 return grunt . task . run ( [
789845 'clean:server' ,
790846 'env:all' ,
791- 'concurrent:pre' ,
847+ 'concurrent:pre' , < % if ( filters . ts ) { % >
848+ 'tsd' , < % } % >
792849 'concurrent:server',
793850 'injector',
794851 'wiredep:client',
@@ -800,7 +857,8 @@ module.exports = function (grunt) {
800857 grunt . task . run ( [
801858 'clean:server' ,
802859 'env:all' ,
803- 'concurrent:pre',
860+ 'concurrent:pre' , < % if ( filters . ts ) { % >
861+ 'tsd' , < % } % >
804862 'concurrent:server',
805863 'injector',
806864 'wiredep:client',
@@ -831,7 +889,10 @@ module.exports = function (grunt) {
831889 return grunt . task . run ( [
832890 'clean:server' ,
833891 'env:all' ,
834- 'concurrent:pre' ,
892+ 'concurrent:pre' , < % if ( filters . ts ) { % >
893+ 'ts:client' ,
894+ 'ts:client_test' ,
895+ 'tsd' , < % } % >
835896 'concurrent:test',
836897 'injector',
837898 'postcss',
@@ -857,7 +918,11 @@ module.exports = function (grunt) {
857918 'clean:server' ,
858919 'env:all' ,
859920 'env:test' ,
860- 'concurrent:pre' ,
921+ 'concurrent:pre' , < % if ( filters . ts ) { % >
922+ 'tsd:install' ,
923+ 'tsd:install_test' ,
924+ 'ts:client' ,
925+ 'ts:client_test' , < % } % >
861926 'concurrent:test',
862927 'injector',
863928 'wiredep:client',
@@ -911,7 +976,8 @@ module.exports = function (grunt) {
911976
912977 grunt . registerTask ( 'build' , [
913978 'clean:dist' ,
914- 'concurrent :pre ',
979+ 'concurrent:pre' , < % if ( filters . ts ) { % >
980+ 'tsd' , < % } % >
915981 'concurrent:dist',
916982 'injector',
917983 'wiredep:client',
@@ -929,8 +995,9 @@ module.exports = function (grunt) {
929995 'usemin'
930996 ]);
931997
932- grunt . registerTask ( 'default ', [
933- 'newer :jshint ',
998+ grunt.registerTask('default', [< % if ( filters . babel ) { % >
999+ 'newer:tslint',< % } % > < % if ( filters . ts ) { % >
1000+ 'newer:jshint',< % } % >
9341001 'test',
9351002 'build'
9361003 ]);
0 commit comments