2012-10-21 06:37:59 +00:00
var files = require ( './angularFiles' ) . files ;
var util = require ( './lib/grunt/utils.js' ) ;
2013-09-17 12:38:52 +00:00
var path = require ( 'path' ) ;
2012-10-21 06:37:59 +00:00
module . exports = function ( grunt ) {
//grunt plugins
grunt . loadNpmTasks ( 'grunt-contrib-clean' ) ;
grunt . loadNpmTasks ( 'grunt-contrib-copy' ) ;
grunt . loadNpmTasks ( 'grunt-contrib-connect' ) ;
grunt . loadNpmTasks ( 'grunt-contrib-compress' ) ;
2013-10-11 12:38:20 +00:00
grunt . loadNpmTasks ( 'grunt-jasmine-node' ) ;
2013-07-03 18:10:23 +00:00
grunt . loadNpmTasks ( 'grunt-ddescribe-iit' ) ;
grunt . loadNpmTasks ( 'grunt-merge-conflict' ) ;
2013-07-01 23:21:56 +00:00
grunt . loadNpmTasks ( 'grunt-parallel' ) ;
2013-08-21 23:17:07 +00:00
grunt . loadNpmTasks ( 'grunt-shell' ) ;
2012-10-21 06:37:59 +00:00
grunt . loadTasks ( 'lib/grunt' ) ;
var NG _VERSION = util . getVersion ( ) ;
2013-03-06 20:43:56 +00:00
var dist = 'angular-' + NG _VERSION . full ;
2012-10-21 06:37:59 +00:00
//global beforeEach
util . init ( ) ;
//config
grunt . initConfig ( {
NG _VERSION : NG _VERSION ,
2013-07-01 23:21:56 +00:00
parallel : {
travis : {
tasks : [
2013-08-21 23:17:07 +00:00
util . parallelTask ( [ 'test:unit' , 'test:docgen' , 'test:promises-aplus' , 'tests:docs' ] , { stream : true } ) ,
2013-08-20 21:43:15 +00:00
util . parallelTask ( [ 'test:e2e' ] )
2013-07-01 23:21:56 +00:00
]
}
} ,
2012-10-21 06:37:59 +00:00
connect : {
devserver : {
options : {
port : 8000 ,
2013-03-11 22:07:51 +00:00
hostname : '0.0.0.0' ,
2012-10-21 06:37:59 +00:00
base : '.' ,
keepalive : true ,
middleware : function ( connect , options ) {
return [
//uncomment to enable CSP
// util.csp(),
util . rewrite ( ) ,
connect . favicon ( 'images/favicon.ico' ) ,
connect . static ( options . base ) ,
connect . directory ( options . base )
] ;
}
}
} ,
2013-07-01 23:21:56 +00:00
testserver : {
options : {
2013-08-13 04:41:20 +00:00
// We use end2end task (which does not start the webserver)
// and start the webserver as a separate process (in travis_build.sh)
// to avoid https://github.com/joyent/libuv/issues/826
port : 8000 ,
hostname : '0.0.0.0' ,
2013-07-01 23:21:56 +00:00
middleware : function ( connect , options ) {
return [
function ( req , resp , next ) {
// cache get requests to speed up tests on travis
if ( req . method === 'GET' ) {
resp . setHeader ( 'Cache-control' , 'public, max-age=3600' ) ;
}
next ( ) ;
} ,
connect . favicon ( 'images/favicon.ico' ) ,
connect . static ( options . base )
] ;
}
}
}
2012-10-21 06:37:59 +00:00
} ,
2013-08-01 20:14:52 +00:00
tests : {
2013-03-21 01:57:13 +00:00
jqlite : 'karma-jqlite.conf.js' ,
jquery : 'karma-jquery.conf.js' ,
2013-06-05 18:31:32 +00:00
docs : 'karma-docs.conf.js' ,
2013-03-21 01:57:13 +00:00
modules : 'karma-modules.conf.js' ,
2012-10-21 06:37:59 +00:00
//NOTE run grunt test:e2e instead and it will start a webserver for you
2013-03-21 01:57:13 +00:00
end2end : 'karma-e2e.conf.js'
2012-10-21 06:37:59 +00:00
} ,
autotest : {
2013-03-21 01:57:13 +00:00
jqlite : 'karma-jqlite.conf.js' ,
2013-06-06 21:07:32 +00:00
jquery : 'karma-jquery.conf.js' ,
2013-06-05 18:31:32 +00:00
modules : 'karma-modules.conf.js' ,
2013-08-01 20:14:52 +00:00
docs : 'karma-docs.conf.js'
2012-10-21 06:37:59 +00:00
} ,
2013-08-21 23:17:07 +00:00
clean : {
build : [ 'build' ] ,
tmp : [ 'tmp' ]
} ,
2012-10-21 06:37:59 +00:00
build : {
scenario : {
dest : 'build/angular-scenario.js' ,
src : [
2013-07-29 23:58:55 +00:00
'bower_components/jquery/jquery.js' ,
2012-10-21 06:37:59 +00:00
util . wrap ( [ files [ 'angularSrc' ] , files [ 'angularScenario' ] ] , 'ngScenario/angular' )
] ,
styles : {
css : [ 'css/angular.css' , 'css/angular-scenario.css' ]
}
} ,
angular : {
dest : 'build/angular.js' ,
src : util . wrap ( [ files [ 'angularSrc' ] ] , 'angular' ) ,
styles : {
css : [ 'css/angular.css' ] ,
minify : true
}
} ,
loader : {
dest : 'build/angular-loader.js' ,
src : util . wrap ( [ 'src/loader.js' ] , 'loader' )
} ,
2013-08-09 17:02:48 +00:00
touch : {
dest : 'build/angular-touch.js' ,
2013-02-08 18:39:23 +00:00
src : util . wrap ( [
2013-08-09 17:02:48 +00:00
'src/ngTouch/touch.js' ,
'src/ngTouch/swipe.js' ,
'src/ngTouch/directive/ngClick.js' ,
'src/ngTouch/directive/ngSwipe.js'
2013-02-08 18:39:23 +00:00
] , 'module' )
} ,
2012-10-21 06:37:59 +00:00
mocks : {
dest : 'build/angular-mocks.js' ,
src : [ 'src/ngMock/angular-mocks.js' ] ,
strict : false
} ,
sanitize : {
dest : 'build/angular-sanitize.js' ,
src : util . wrap ( [
'src/ngSanitize/sanitize.js' ,
2013-06-05 22:30:31 +00:00
'src/ngSanitize/filter/linky.js'
2012-10-21 06:37:59 +00:00
] , 'module' )
} ,
resource : {
dest : 'build/angular-resource.js' ,
src : util . wrap ( [ 'src/ngResource/resource.js' ] , 'module' )
} ,
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
animate : {
dest : 'build/angular-animate.js' ,
src : util . wrap ( [ 'src/ngAnimate/animate.js' ] , 'module' )
} ,
2013-06-05 22:30:31 +00:00
route : {
dest : 'build/angular-route.js' ,
src : util . wrap ( [
'src/ngRoute/routeUtils.js' ,
'src/ngRoute/route.js' ,
'src/ngRoute/routeParams.js' ,
'src/ngRoute/directive/ngView.js'
] , 'module' )
} ,
2012-10-21 06:37:59 +00:00
cookies : {
dest : 'build/angular-cookies.js' ,
src : util . wrap ( [ 'src/ngCookies/cookies.js' ] , 'module' )
2013-08-21 23:17:07 +00:00
} ,
"promises-aplus-adapter" : {
dest : 'tmp/promises-aplus-adapter++.js' ,
src : [ 'src/ng/q.js' , 'lib/promises-aplus/promises-aplus-test-adapter.js' ]
2012-10-21 06:37:59 +00:00
}
} ,
min : {
angular : 'build/angular.js' ,
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
animate : 'build/angular-animate.js' ,
2012-10-21 06:37:59 +00:00
cookies : 'build/angular-cookies.js' ,
loader : 'build/angular-loader.js' ,
2013-08-09 17:02:48 +00:00
touch : 'build/angular-touch.js' ,
2012-10-21 06:37:59 +00:00
resource : 'build/angular-resource.js' ,
2013-06-05 22:30:31 +00:00
route : 'build/angular-route.js' ,
2013-06-04 23:05:50 +00:00
sanitize : 'build/angular-sanitize.js'
2012-10-21 06:37:59 +00:00
} ,
docs : {
process : [ 'build/docs/*.html' , 'build/docs/.htaccess' ]
} ,
2013-06-23 21:27:18 +00:00
"jasmine-node" : {
run : { spec : 'docs/spec' }
} ,
2012-10-21 06:37:59 +00:00
2013-07-03 18:10:23 +00:00
"ddescribe-iit" : {
files : [
'test/**/*.js' ,
'!test/ngScenario/DescribeSpec.js'
]
} ,
"merge-conflict" : {
files : [
'src/**/*' ,
'test/**/*' ,
'docs/**/*' ,
'css/**/*'
]
} ,
2012-10-21 06:37:59 +00:00
copy : {
i18n : {
files : [
{ src : 'src/ngLocale/**' , dest : 'build/i18n/' , expand : true , flatten : true }
]
}
} ,
compress : {
build : {
2013-08-13 22:14:42 +00:00
options : { archive : 'build/' + dist + '.zip' , mode : 'zip' } ,
2013-03-06 22:23:05 +00:00
src : [ '**' ] , cwd : 'build' , expand : true , dot : true , dest : dist + '/'
2012-10-21 06:37:59 +00:00
}
} ,
2013-08-21 23:17:07 +00:00
shell : {
"promises-aplus-tests" : {
options : {
//stdout:true,
stderr : true ,
failOnError : true
} ,
2013-09-17 12:38:52 +00:00
command : path . normalize ( './node_modules/.bin/promises-aplus-tests tmp/promises-aplus-adapter++.js' )
2013-08-21 23:17:07 +00:00
}
} ,
2012-10-21 06:37:59 +00:00
write : {
versionTXT : { file : 'build/version.txt' , val : NG _VERSION . full } ,
versionJSON : { file : 'build/version.json' , val : JSON . stringify ( NG _VERSION ) }
}
} ) ;
//alias tasks
2013-08-21 23:17:07 +00:00
grunt . registerTask ( 'test' , 'Run unit, docs and e2e tests with Karma' , [ 'package' , 'test:unit' , 'test:promises-aplus' , 'tests:docs' , 'test:e2e' ] ) ;
2013-08-04 15:40:24 +00:00
grunt . registerTask ( 'test:jqlite' , 'Run the unit tests with Karma' , [ 'tests:jqlite' ] ) ;
grunt . registerTask ( 'test:jquery' , 'Run the jQuery unit tests with Karma' , [ 'tests:jquery' ] ) ;
grunt . registerTask ( 'test:modules' , 'Run the Karma module tests with Karma' , [ 'tests:modules' ] ) ;
grunt . registerTask ( 'test:docs' , 'Run the doc-page tests with Karma' , [ 'package' , 'tests:docs' ] ) ;
grunt . registerTask ( 'test:unit' , 'Run unit, jQuery and Karma module tests with Karma' , [ 'tests:jqlite' , 'tests:jquery' , 'tests:modules' ] ) ;
grunt . registerTask ( 'test:e2e' , 'Run the end to end tests with Karma and keep a test server running in the background' , [ 'connect:testserver' , 'tests:end2end' ] ) ;
2013-06-23 21:27:18 +00:00
grunt . registerTask ( 'test:docgen' , [ 'jasmine-node' ] ) ;
2013-08-21 23:17:07 +00:00
grunt . registerTask ( 'test:promises-aplus' , [ 'build:promises-aplus-adapter' , 'shell:promises-aplus-tests' ] ) ;
2013-08-01 20:14:52 +00:00
2013-07-30 22:25:54 +00:00
grunt . registerTask ( 'minify' , [ 'bower' , 'clean' , 'build' , 'minall' ] ) ;
2012-10-21 06:37:59 +00:00
grunt . registerTask ( 'webserver' , [ 'connect:devserver' ] ) ;
2013-07-30 22:25:54 +00:00
grunt . registerTask ( 'package' , [ 'bower' , 'clean' , 'buildall' , 'minall' , 'collect-errors' , 'docs' , 'copy' , 'write' , 'compress' ] ) ;
2013-08-29 00:48:46 +00:00
grunt . registerTask ( 'package-without-bower' , [ 'clean' , 'buildall' , 'minall' , 'collect-errors' , 'docs' , 'copy' , 'write' , 'compress' ] ) ;
2013-07-03 18:10:23 +00:00
grunt . registerTask ( 'ci-checks' , [ 'ddescribe-iit' , 'merge-conflict' ] ) ;
2012-10-21 06:37:59 +00:00
grunt . registerTask ( 'default' , [ 'package' ] ) ;
} ;