2014-06-23 23:17:31 +02:00
'use strict' ;
2012-10-21 00:37:59 -06:00
var files = require ( './angularFiles' ) . files ;
var util = require ( './lib/grunt/utils.js' ) ;
2014-03-11 06:34:09 +00:00
var versionInfo = require ( './lib/versions/version-info' ) ;
2013-09-17 13:38:52 +01:00
var path = require ( 'path' ) ;
2014-10-15 13:58:24 -04:00
var e2e = require ( './test/e2e/tools' ) ;
2012-10-21 00:37:59 -06:00
module . exports = function ( grunt ) {
//grunt plugins
2014-02-01 23:14:07 -08:00
require ( 'load-grunt-tasks' ) ( grunt ) ;
2012-10-21 00:37:59 -06:00
grunt . loadTasks ( 'lib/grunt' ) ;
2014-08-13 23:00:00 -07:00
grunt . loadNpmTasks ( 'angular-benchpress' ) ;
2012-10-21 00:37:59 -06:00
2014-03-11 06:34:09 +00:00
var NG _VERSION = versionInfo . currentVersion ;
2014-03-26 15:51:11 -07:00
NG _VERSION . cdn = versionInfo . cdnVersion ;
2013-03-06 13:43:56 -07:00
var dist = 'angular-' + NG _VERSION . full ;
2012-10-21 00:37:59 -06:00
//config
grunt . initConfig ( {
NG _VERSION : NG _VERSION ,
2014-08-13 23:00:00 -07:00
bp _build : {
options : {
buildPath : 'build/benchmarks' ,
benchmarksPath : 'benchmarks'
}
} ,
2013-07-01 16:21:56 -07:00
2012-10-21 00:37:59 -06:00
connect : {
devserver : {
options : {
port : 8000 ,
2013-03-11 15:07:51 -07:00
hostname : '0.0.0.0' ,
2012-10-21 00:37:59 -06:00
base : '.' ,
keepalive : true ,
middleware : function ( connect , options ) {
2014-10-11 21:58:38 +02:00
var base = Array . isArray ( options . base ) ? options . base [ options . base . length - 1 ] : options . base ;
2012-10-21 00:37:59 -06:00
return [
2014-09-17 10:43:49 -07:00
util . conditionalCsp ( ) ,
2012-10-21 00:37:59 -06:00
util . rewrite ( ) ,
2014-10-15 13:58:24 -04:00
e2e . middleware ( ) ,
2012-10-21 00:37:59 -06:00
connect . favicon ( 'images/favicon.ico' ) ,
2014-10-11 21:58:38 +02:00
connect . static ( base ) ,
connect . directory ( base )
2012-10-21 00:37:59 -06:00
] ;
}
}
} ,
2013-07-01 16:21:56 -07:00
testserver : {
options : {
2013-08-12 21:41:20 -07: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 16:21:56 -07:00
middleware : function ( connect , options ) {
2014-10-11 21:58:38 +02:00
var base = Array . isArray ( options . base ) ? options . base [ options . base . length - 1 ] : options . base ;
2013-07-01 16:21:56 -07:00
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 ( ) ;
} ,
2014-09-17 10:43:49 -07:00
util . conditionalCsp ( ) ,
2014-10-15 13:58:24 -04:00
e2e . middleware ( ) ,
2013-07-01 16:21:56 -07:00
connect . favicon ( 'images/favicon.ico' ) ,
2014-10-11 21:58:38 +02:00
connect . static ( base )
2013-07-01 16:21:56 -07:00
] ;
}
}
}
2012-10-21 00:37:59 -06:00
} ,
2013-08-01 16:14:52 -04:00
tests : {
2013-03-20 18:57:13 -07:00
jqlite : 'karma-jqlite.conf.js' ,
jquery : 'karma-jquery.conf.js' ,
2014-02-21 21:36:22 +00:00
docs : 'karma-docs.conf.js' ,
2014-01-11 16:59:15 -08:00
modules : 'karma-modules.conf.js'
2012-10-21 00:37:59 -06:00
} ,
autotest : {
2013-03-20 18:57:13 -07:00
jqlite : 'karma-jqlite.conf.js' ,
2013-06-06 14:07:32 -07:00
jquery : 'karma-jquery.conf.js' ,
2013-06-05 14:31:32 -04:00
modules : 'karma-modules.conf.js' ,
2014-02-21 21:36:22 +00:00
docs : 'karma-docs.conf.js'
2012-10-21 00:37:59 -06:00
} ,
2014-01-30 22:09:09 -08:00
protractor : {
2014-01-30 18:49:58 -08:00
normal : 'protractor-conf.js' ,
2014-02-19 21:01:54 -08:00
travis : 'protractor-travis-conf.js' ,
2014-01-30 18:49:58 -08:00
jenkins : 'protractor-jenkins-conf.js'
2014-01-07 11:51:32 -08:00
} ,
2013-08-21 19:17:07 -04:00
clean : {
build : [ 'build' ] ,
tmp : [ 'tmp' ]
} ,
2012-10-21 00:37:59 -06:00
2013-10-21 09:06:53 +01:00
jshint : {
2013-11-26 13:26:10 -08:00
options : {
jshintrc : true ,
} ,
2014-06-23 23:17:31 +02:00
node : {
files : { src : [ '*.js' , 'lib/**/*.js' ] } ,
} ,
2014-04-26 23:07:28 +03:00
tests : {
files : { src : 'test/**/*.js' } ,
} ,
2013-10-21 09:06:53 +01:00
ng : {
files : { src : files [ 'angularSrc' ] } ,
} ,
ngAnimate : {
files : { src : 'src/ngAnimate/**/*.js' } ,
} ,
ngCookies : {
files : { src : 'src/ngCookies/**/*.js' } ,
} ,
ngLocale : {
files : { src : 'src/ngLocale/**/*.js' } ,
} ,
2014-04-22 02:15:01 -04:00
ngMessages : {
files : { src : 'src/ngMessages/**/*.js' } ,
} ,
2013-10-21 09:06:53 +01:00
ngMock : {
files : { src : 'src/ngMock/**/*.js' } ,
} ,
ngResource : {
files : { src : 'src/ngResource/**/*.js' } ,
} ,
ngRoute : {
files : { src : 'src/ngRoute/**/*.js' } ,
} ,
ngSanitize : {
files : { src : 'src/ngSanitize/**/*.js' } ,
} ,
ngScenario : {
files : { src : 'src/ngScenario/**/*.js' } ,
} ,
ngTouch : {
files : { src : 'src/ngTouch/**/*.js' } ,
2014-07-26 01:15:19 +08:00
} ,
ngAria : {
files : { src : 'src/ngAria/**/*.js' } ,
2013-10-21 09:06:53 +01:00
}
} ,
2012-10-21 00:37:59 -06:00
2014-01-30 10:51:10 -08:00
jscs : {
src : [ 'src/**/*.js' , 'test/**/*.js' ] ,
options : {
2015-12-17 21:59:31 +00:00
config : '.jscsrc'
2014-01-30 10:51:10 -08:00
}
} ,
2012-10-21 00:37:59 -06:00
build : {
scenario : {
dest : 'build/angular-scenario.js' ,
src : [
2014-04-30 12:13:48 +02:00
'bower_components/jquery/dist/jquery.js' ,
2012-10-21 00:37:59 -06: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' ] ,
2013-10-14 12:06:26 -07:00
generateCspCssFile : true ,
2012-10-21 00:37:59 -06:00
minify : true
}
} ,
loader : {
dest : 'build/angular-loader.js' ,
2013-10-21 09:06:53 +01:00
src : util . wrap ( files [ 'angularLoader' ] , 'loader' )
2012-10-21 00:37:59 -06:00
} ,
2013-08-09 10:02:48 -07:00
touch : {
dest : 'build/angular-touch.js' ,
2013-10-21 09:06:53 +01:00
src : util . wrap ( files [ 'angularModules' ] [ 'ngTouch' ] , 'module' )
2013-02-08 13:39:23 -05:00
} ,
2012-10-21 00:37:59 -06:00
mocks : {
dest : 'build/angular-mocks.js' ,
2013-11-21 19:50:23 -05:00
src : util . wrap ( files [ 'angularModules' ] [ 'ngMock' ] , 'module' ) ,
2012-10-21 00:37:59 -06:00
strict : false
} ,
sanitize : {
dest : 'build/angular-sanitize.js' ,
2013-10-21 09:06:53 +01:00
src : util . wrap ( files [ 'angularModules' ] [ 'ngSanitize' ] , 'module' )
2012-10-21 00:37:59 -06:00
} ,
resource : {
dest : 'build/angular-resource.js' ,
2013-10-21 09:06:53 +01:00
src : util . wrap ( files [ 'angularModules' ] [ 'ngResource' ] , 'module' )
2012-10-21 00:37:59 -06:00
} ,
2014-04-22 02:15:01 -04:00
messages : {
dest : 'build/angular-messages.js' ,
src : util . wrap ( files [ 'angularModules' ] [ 'ngMessages' ] , '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 13:59:57 -04:00
animate : {
dest : 'build/angular-animate.js' ,
2013-10-21 09:06:53 +01:00
src : util . wrap ( files [ 'angularModules' ] [ 'ngAnimate' ] , '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 13:59:57 -04:00
} ,
2013-06-05 15:30:31 -07:00
route : {
dest : 'build/angular-route.js' ,
2013-10-21 09:06:53 +01:00
src : util . wrap ( files [ 'angularModules' ] [ 'ngRoute' ] , 'module' )
2013-06-05 15:30:31 -07:00
} ,
2012-10-21 00:37:59 -06:00
cookies : {
dest : 'build/angular-cookies.js' ,
2013-10-21 09:06:53 +01:00
src : util . wrap ( files [ 'angularModules' ] [ 'ngCookies' ] , 'module' )
2013-08-21 19:17:07 -04:00
} ,
2014-07-26 01:15:19 +08:00
aria : {
dest : 'build/angular-aria.js' ,
src : util . wrap ( files [ 'angularModules' ] [ 'ngAria' ] , 'module' )
} ,
2015-12-17 21:59:31 +00:00
'promises-aplus-adapter' : {
2013-08-21 19:17:07 -04:00
dest : 'tmp/promises-aplus-adapter++.js' ,
2015-12-17 14:56:49 +00:00
src : [ 'src/ng/q.js' , 'lib/promises-aplus/promises-aplus-test-adapter.js' ]
2012-10-21 00:37:59 -06: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 13:59:57 -04:00
animate : 'build/angular-animate.js' ,
2012-10-21 00:37:59 -06:00
cookies : 'build/angular-cookies.js' ,
loader : 'build/angular-loader.js' ,
2014-05-09 17:37:41 -04:00
messages : 'build/angular-messages.js' ,
2013-08-09 10:02:48 -07:00
touch : 'build/angular-touch.js' ,
2012-10-21 00:37:59 -06:00
resource : 'build/angular-resource.js' ,
2013-06-05 15:30:31 -07:00
route : 'build/angular-route.js' ,
2014-07-26 01:15:19 +08:00
sanitize : 'build/angular-sanitize.js' ,
aria : 'build/angular-aria.js'
2012-10-21 00:37:59 -06:00
} ,
2015-12-17 21:59:31 +00:00
'ddescribe-iit' : {
2013-07-03 11:10:23 -07:00
files : [
2014-05-22 18:08:07 -07:00
'src/**/*.js' ,
2013-07-03 11:10:23 -07:00
'test/**/*.js' ,
2014-05-22 18:08:07 -07:00
'!test/ngScenario/DescribeSpec.js' ,
2014-06-09 14:51:35 -04:00
'!src/ng/directive/attrs.js' , // legitimate xit here
2015-03-04 12:20:49 +00:00
'!src/ngScenario/**/*.js' ,
'!test/helpers/privateMocks*.js'
] ,
options : {
disallowed : [
'iit' ,
'xit' ,
'tthey' ,
'xthey' ,
'ddescribe' ,
'xdescribe'
]
}
2013-07-03 11:10:23 -07:00
} ,
2015-12-17 21:59:31 +00:00
'merge-conflict' : {
2013-07-03 11:10:23 -07:00
files : [
'src/**/*' ,
'test/**/*' ,
'docs/**/*' ,
'css/**/*'
]
} ,
2012-10-21 00:37:59 -06:00
copy : {
i18n : {
files : [
{ src : 'src/ngLocale/**' , dest : 'build/i18n/' , expand : true , flatten : true }
]
}
} ,
compress : {
build : {
2013-08-13 15:14:42 -07:00
options : { archive : 'build/' + dist + '.zip' , mode : 'zip' } ,
2014-06-23 23:17:31 +02:00
src : [ '**' ] ,
cwd : 'build' ,
expand : true ,
dot : true ,
dest : dist + '/'
2012-10-21 00:37:59 -06:00
}
} ,
2014-10-11 21:58:38 +02:00
shell : {
2015-12-17 21:59:31 +00:00
'npm-install' : {
2015-09-09 03:27:45 +03:00
command : 'node scripts/npm/check-node-modules.js'
2015-02-21 17:40:33 -08:00
} ,
2015-12-17 21:59:31 +00:00
'promises-aplus-tests' : {
2014-10-11 21:58:38 +02:00
options : {
stdout : false ,
stderr : true ,
failOnError : true
2013-08-21 19:17:07 -04:00
} ,
2014-10-11 21:58:38 +02:00
command : path . normalize ( './node_modules/.bin/promises-aplus-tests tmp/promises-aplus-adapter++.js' )
2013-08-21 19:17:07 -04:00
}
} ,
2012-10-21 00:37:59 -06:00
write : {
versionTXT : { file : 'build/version.txt' , val : NG _VERSION . full } ,
versionJSON : { file : 'build/version.json' , val : JSON . stringify ( NG _VERSION ) }
2013-12-13 12:49:42 -08:00
} ,
bump : {
options : {
files : [ 'package.json' ] ,
commit : false ,
createTag : false ,
push : false
}
2012-10-21 00:37:59 -06:00
}
} ) ;
2015-02-21 17:40:33 -08:00
// global beforeEach task
if ( ! process . env . TRAVIS ) {
grunt . task . run ( 'shell:npm-install' ) ;
}
2012-10-21 00:37:59 -06:00
2015-12-15 11:46:50 -08:00
2012-10-21 00:37:59 -06:00
//alias tasks
2015-12-17 14:56:49 +00:00
grunt . registerTask ( 'test' , 'Run unit, docs and e2e tests with Karma' , [ 'jshint' , 'jscs' , 'package' , 'test:unit' , 'test:promises-aplus' , 'tests:docs' , 'test:protractor' ] ) ;
2013-08-04 11:40:24 -04: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' ] ) ;
2014-11-22 14:04:08 -08:00
grunt . registerTask ( 'test:modules' , 'Run the Karma module tests with Karma' , [ 'build' , 'tests:modules' ] ) ;
2014-02-21 21:36:22 +00:00
grunt . registerTask ( 'test:docs' , 'Run the doc-page tests with Karma' , [ 'package' , 'tests:docs' ] ) ;
2014-11-22 14:04:08 -08:00
grunt . registerTask ( 'test:unit' , 'Run unit, jQuery and Karma module tests with Karma' , [ 'test:jqlite' , 'test:jquery' , 'test:modules' ] ) ;
2014-01-30 22:09:09 -08:00
grunt . registerTask ( 'test:protractor' , 'Run the end to end tests with Protractor and keep a test server running in the background' , [ 'webdriver' , 'connect:testserver' , 'protractor:normal' ] ) ;
2014-02-19 21:01:54 -08:00
grunt . registerTask ( 'test:travis-protractor' , 'Run the end to end tests with Protractor for Travis CI builds' , [ 'connect:testserver' , 'protractor:travis' ] ) ;
grunt . registerTask ( 'test:ci-protractor' , 'Run the end to end tests with Protractor for Jenkins CI builds' , [ 'webdriver' , 'connect:testserver' , 'protractor:jenkins' ] ) ;
2014-01-11 16:59:15 -08:00
grunt . registerTask ( 'test:e2e' , 'Alias for test:protractor' , [ 'test:protractor' ] ) ;
2015-12-17 14:56:49 +00:00
grunt . registerTask ( 'test:promises-aplus' , [ 'build:promises-aplus-adapter' , 'shell:promises-aplus-tests' ] ) ;
2013-08-01 16:14:52 -04:00
2015-12-17 14:56:49 +00:00
grunt . registerTask ( 'minify' , [ 'bower' , 'clean' , 'build' , 'minall' ] ) ;
2012-10-21 00:37:59 -06:00
grunt . registerTask ( 'webserver' , [ 'connect:devserver' ] ) ;
2015-12-17 14:56:49 +00:00
grunt . registerTask ( 'package' , [ 'bower' , 'validate-angular-files' , 'clean' , 'buildall' , 'minall' , 'collect-errors' , 'docs' , 'copy' , 'write' , 'compress' ] ) ;
2014-01-30 10:51:10 -08:00
grunt . registerTask ( 'ci-checks' , [ 'ddescribe-iit' , 'merge-conflict' , 'jshint' , 'jscs' ] ) ;
2012-10-21 00:37:59 -06:00
grunt . registerTask ( 'default' , [ 'package' ] ) ;
} ;