Michael Lando | 451a340 | 2017-02-19 10:28:42 +0200 | [diff] [blame^] | 1 | // Generated on 2015-04-28 using |
| 2 | // generator-webapp 0.5.1 |
| 3 | 'use strict'; |
| 4 | |
| 5 | // # Globbing |
| 6 | // for performance reasons we're only matching one level down: |
| 7 | // 'test/spec/{,*/}*.js' |
| 8 | // If you want to recursively match all subfolders, use: |
| 9 | // 'test/spec/**/*.js' |
| 10 | |
| 11 | module.exports = function (grunt) { |
| 12 | |
| 13 | // Time how long tasks take. Can help when optimizing build times |
| 14 | require('time-grunt')(grunt); |
| 15 | |
| 16 | // Load grunt tasks automatically |
| 17 | require('load-grunt-tasks')(grunt); |
| 18 | |
| 19 | // Configurable paths |
| 20 | var config = { |
| 21 | app: 'app', |
| 22 | appModuleName: 'sdcApp', |
| 23 | dist: 'app/dist' |
| 24 | }; |
| 25 | |
| 26 | // Define the configuration for all the tasks |
| 27 | grunt.initConfig({ |
| 28 | |
| 29 | // Project settings |
| 30 | config: config, |
| 31 | |
| 32 | // Watches files for changes and runs tasks based on the changed files |
| 33 | watch: { |
| 34 | html: { |
| 35 | files: ['<%= config.app %>/scripts/**/*.html'], |
| 36 | tasks: ['ngtemplates:app'] |
| 37 | }, |
| 38 | less: { |
| 39 | files: ['<%= config.app %>/**/*.less'], |
| 40 | tasks: ['less:all'] |
| 41 | }, |
| 42 | ts: { |
| 43 | files: ['<%= config.app %>/scripts/**/*.ts'], |
| 44 | tasks: ['ts:all'] |
| 45 | }, |
| 46 | bower: { |
| 47 | files: ['bower.json'], |
| 48 | tasks: ['wiredep'] |
| 49 | }, |
| 50 | |
| 51 | gruntfile: { |
| 52 | files: ['Gruntfile.js'] |
| 53 | }, |
| 54 | |
| 55 | livereload: { |
| 56 | options: { |
| 57 | livereload: '<%= connect.options.livereload %>' |
| 58 | }, |
| 59 | files: [ |
| 60 | '<%= config.app %>/{,*/}*.html', |
| 61 | '<%= config.app %>/scripts/**/*.html', |
| 62 | '<%= config.app %>/scripts/**/*.css', |
| 63 | '.tmp/styles/{,*/}*.css', |
| 64 | '<%= config.app %>/images/{,*/}*' |
| 65 | ] |
| 66 | }, |
| 67 | configurations: { |
| 68 | files: [ |
| 69 | 'configurations/*.json' |
| 70 | ], |
| 71 | tasks: ['ngconstant'] |
| 72 | } |
| 73 | }, |
| 74 | |
| 75 | ngconstant: { |
| 76 | options: { |
| 77 | dest: 'app/scripts/modules/configurations.js', |
| 78 | name: 'Sdc.Config' |
| 79 | }, |
| 80 | main: { |
| 81 | constants: { |
| 82 | sdcConfig: grunt.file.readJSON(grunt.option('env') ? 'configurations/' + grunt.option('env') + '.json' : 'configurations/prod.json'), |
| 83 | sdcMenu: grunt.file.readJSON('configurations/menu.json') |
| 84 | } |
| 85 | } |
| 86 | }, |
| 87 | |
| 88 | express: { |
| 89 | options: { |
| 90 | port: process.env.PORT || 9000 |
| 91 | }, |
| 92 | mock: { |
| 93 | options: { |
| 94 | script: 'server-mock/mock-server.js' |
| 95 | } |
| 96 | } |
| 97 | }, |
| 98 | |
| 99 | ts: { |
| 100 | all: { |
| 101 | src: [ |
| 102 | 'app/scripts/**/*.ts', |
| 103 | 'typings/**/*.ts' |
| 104 | ], |
| 105 | reference: 'app/scripts/references.ts' |
| 106 | }, |
| 107 | single: { |
| 108 | src: [] |
| 109 | } |
| 110 | }, |
| 111 | ngtemplates: { |
| 112 | app: { |
| 113 | options: { |
| 114 | module: '<%= config.appModuleName %>', |
| 115 | prefix: '/' |
| 116 | }, |
| 117 | src: [ |
| 118 | '<%= config.app %>/scripts/**/*.html', |
| 119 | '!index.html' |
| 120 | ], |
| 121 | dest: '<%= config.app %>/scripts/templates.js' |
| 122 | } |
| 123 | }, |
| 124 | less: { |
| 125 | all: { |
| 126 | options: { |
| 127 | paths: ['<%= config.app %>/scripts', |
| 128 | '<%= config.app %>/styles'] |
| 129 | }, |
| 130 | files: { |
| 131 | '<%= config.app %>/styles/app.css': '<%= config.app %>/styles/app.less' |
| 132 | } |
| 133 | }, |
| 134 | single: { |
| 135 | paths: ['<%= config.app %>/scripts', |
| 136 | '<%= config.app %>/styles'], |
| 137 | files: [] |
| 138 | } |
| 139 | }, |
| 140 | |
| 141 | injector: { |
| 142 | options: {}, |
| 143 | // Inject application script files into index.html (doesn't include bower) |
| 144 | scripts_models: { |
| 145 | options: { |
| 146 | transform: function (filePath) { |
| 147 | filePath = filePath.replace('/app/', ''); |
| 148 | return '<script src="' + filePath + '"></script>'; |
| 149 | }, |
| 150 | starttag: '<!-- injector:js_models -->', |
| 151 | endtag: '<!-- endinjector:js_models -->' |
| 152 | }, |
| 153 | files: { |
| 154 | '<%= config.app %>/index.html': [ |
| 155 | [ |
| 156 | '<%= config.app %>/scripts/models/**/*.js', |
| 157 | '!<%= config.app %>/scripts/models/**/*-tests.js' |
| 158 | ] |
| 159 | ] |
| 160 | } |
| 161 | }, |
| 162 | |
| 163 | scripts_utils: { |
| 164 | options: { |
| 165 | transform: function (filePath) { |
| 166 | filePath = filePath.replace('/app/', ''); |
| 167 | return '<script src="' + filePath + '"></script>'; |
| 168 | }, |
| 169 | starttag: '<!-- injector:js_utils -->', |
| 170 | endtag: '<!-- endinjector:js_utils -->' |
| 171 | }, |
| 172 | files: { |
| 173 | '<%= config.app %>/index.html': [ |
| 174 | [ |
| 175 | '<%= config.app %>/scripts/utils/**/*.js', |
| 176 | '!<%= config.app %>/scripts/models/**/*-tests.js' |
| 177 | ] |
| 178 | ] |
| 179 | } |
| 180 | }, |
| 181 | |
| 182 | scripts_filters: { |
| 183 | options: { |
| 184 | transform: function (filePath) { |
| 185 | filePath = filePath.replace('/app/', ''); |
| 186 | return '<script src="' + filePath + '"></script>'; |
| 187 | }, |
| 188 | starttag: '<!-- injector:js_filters -->', |
| 189 | endtag: '<!-- endinjector:js_filters -->' |
| 190 | }, |
| 191 | files: { |
| 192 | '<%= config.app %>/index.html': [ |
| 193 | ['<%= config.app %>/scripts/filters/**/*.js', |
| 194 | '!<%= config.app %>/scripts/filters/**/*-tests.js' |
| 195 | ] |
| 196 | ] |
| 197 | } |
| 198 | }, |
| 199 | |
| 200 | scripts_directives: { |
| 201 | options: { |
| 202 | transform: function (filePath) { |
| 203 | filePath = filePath.replace('/app/', ''); |
| 204 | return '<script src="' + filePath + '"></script>'; |
| 205 | }, |
| 206 | starttag: '<!-- injector:js_directives -->', |
| 207 | endtag: '<!-- endinjector:js_directives -->' |
| 208 | }, |
| 209 | files: { |
| 210 | '<%= config.app %>/index.html': [ |
| 211 | ['<%= config.app %>/scripts/directives/**/*.js', |
| 212 | '!<%= config.app %>/scripts/directives/**/*-tests.js' |
| 213 | ] |
| 214 | ] |
| 215 | } |
| 216 | }, |
| 217 | |
| 218 | scripts_services: { |
| 219 | options: { |
| 220 | transform: function (filePath) { |
| 221 | filePath = filePath.replace('/app/', ''); |
| 222 | return '<script src="' + filePath + '"></script>'; |
| 223 | }, |
| 224 | starttag: '<!-- injector:js_services -->', |
| 225 | endtag: '<!-- endinjector:js_services -->' |
| 226 | }, |
| 227 | files: { |
| 228 | '<%= config.app %>/index.html': [ |
| 229 | ['<%= config.app %>/scripts/services/**/*.js', |
| 230 | '!<%= config.app %>/scripts/services/**/*-tests.js' |
| 231 | ] |
| 232 | ] |
| 233 | } |
| 234 | }, |
| 235 | |
| 236 | scripts_view_models: { |
| 237 | options: { |
| 238 | transform: function (filePath) { |
| 239 | filePath = filePath.replace('/app/', ''); |
| 240 | return '<script src="' + filePath + '"></script>'; |
| 241 | }, |
| 242 | starttag: '<!-- injector:js_view_models -->', |
| 243 | endtag: '<!-- endinjector:js_view_models -->' |
| 244 | }, |
| 245 | files: { |
| 246 | '<%= config.app %>/index.html': [ |
| 247 | ['<%= config.app %>/scripts/view-models/**/*.js', |
| 248 | '!<%= config.app %>/scripts/view-models/**/*-tests.js'] |
| 249 | ] |
| 250 | } |
| 251 | }, |
| 252 | |
| 253 | // Inject component less into app.less |
| 254 | less: { |
| 255 | options: { |
| 256 | transform: function (filePath) { |
| 257 | filePath = filePath.replace('/app/scripts/', '../scripts/'); |
| 258 | filePath = filePath.replace('/app/styles/', ''); |
| 259 | return '@import \'' + filePath + '\';'; |
| 260 | }, |
| 261 | starttag: '// injector:less', |
| 262 | endtag: '// endinjector:less' |
| 263 | }, |
| 264 | files: { |
| 265 | '<%= config.app %>/styles/app.less': [ |
| 266 | '<%= config.app %>/styles/**/*.less', |
| 267 | '<%= config.app %>/scripts/**/*.less', |
| 268 | '!<%= config.app %>/styles/app.less' |
| 269 | ] |
| 270 | } |
| 271 | }, |
| 272 | |
| 273 | // Inject component css into index.html |
| 274 | css: { |
| 275 | options: { |
| 276 | transform: function (filePath) { |
| 277 | filePath = filePath.replace('/app/', ''); |
| 278 | filePath = filePath.replace('/.tmp/', ''); |
| 279 | return '<link rel="stylesheet" href="' + filePath + '">'; |
| 280 | }, |
| 281 | starttag: '<!-- injector:css -->', |
| 282 | endtag: '<!-- endinjector -->' |
| 283 | }, |
| 284 | files: { |
| 285 | '<%= config.app %>/index.html': [ |
| 286 | '<%= config.app %>/scripts/**/*.css', |
| 287 | '<%= config.app %>/styles/**/*.css', |
| 288 | '!<%= config.app %>/styles/app.css' |
| 289 | ] |
| 290 | } |
| 291 | } |
| 292 | }, |
| 293 | |
| 294 | // The actual grunt server settings |
| 295 | connect: { |
| 296 | options: { |
| 297 | port: 9000, |
| 298 | open: true, |
| 299 | livereload: 35729, |
| 300 | // Change this to '0.0.0.0' to access the server from outside |
| 301 | hostname: 'localhost' |
| 302 | }, |
| 303 | livereload: { |
| 304 | options: { |
| 305 | middleware: function (connect) { |
| 306 | return [ |
| 307 | connect().use(function (req, res, next) { |
| 308 | var mockApis = require('./configurations/mock.json').sdcConfig; |
| 309 | var userType; |
| 310 | switch (grunt.option('role')) { |
| 311 | case "admin": |
| 312 | userType = mockApis.userTypes.admin; |
| 313 | break; |
| 314 | case "tester": |
| 315 | userType = mockApis.userTypes.tester; |
| 316 | break; |
| 317 | case "governor": |
| 318 | userType = mockApis.userTypes.governor; |
| 319 | break; |
| 320 | case "ops": |
| 321 | userType = mockApis.userTypes.ops; |
| 322 | break; |
| 323 | case "designer": |
| 324 | userType = mockApis.userTypes.designer; |
| 325 | break; |
| 326 | case "product_strategist": |
| 327 | userType = mockApis.userTypes.product_strategist; |
| 328 | break; |
| 329 | case "product_manager": |
| 330 | userType = mockApis.userTypes.product_manager; |
| 331 | break; |
| 332 | default: |
| 333 | userType = mockApis.userTypes.designer; |
| 334 | } |
| 335 | res.cookie(mockApis.cookie.userIdSuffix, req.headers[mockApis.cookie.userIdSuffix] || userType.userId); |
| 336 | res.cookie(mockApis.cookie.userEmail, req.headers[mockApis.cookie.userEmail] || userType.email); |
| 337 | res.cookie(mockApis.cookie.userFirstName, req.headers[mockApis.cookie.userFirstName] || userType.firstName); |
| 338 | res.cookie(mockApis.cookie.userLastName, req.headers[mockApis.cookie.userLastName] || userType.lastName); |
| 339 | next(); |
| 340 | }), |
| 341 | connect().use(require('http-proxy-middleware')(['/onboarding', '/onboarding-api'], { |
| 342 | target: 'http://feHost:8181/', |
| 343 | changeOrigin: true, |
| 344 | secure: false |
| 345 | })), |
| 346 | connect().use('/bower_components', connect.static('./bower_components')), |
| 347 | connect().use('/non_bower_components', connect.static('./non_bower_components')), |
| 348 | connect.static(config.app) |
| 349 | ]; |
| 350 | } |
| 351 | } |
| 352 | }, |
| 353 | dist: { |
| 354 | options: { |
| 355 | base: '<%= config.dist %>', |
| 356 | livereload: false |
| 357 | } |
| 358 | } |
| 359 | }, |
| 360 | |
| 361 | // Empties folders to start fresh |
| 362 | clean: { |
| 363 | generated: { |
| 364 | files: [{ |
| 365 | dot: true, |
| 366 | src: [ |
| 367 | '<%= config.app %>/scripts/**/*.js', |
| 368 | '<%= config.app %>/scripts/**/*.css', |
| 369 | '!<%= config.app %>/scripts/**/welcome/styles/*.css', |
| 370 | '<%= config.app %>/styles/**/*.css', |
| 371 | '<%= config.app %>/scripts/**/*.js.map' |
| 372 | ] |
| 373 | }] |
| 374 | }, |
| 375 | dist: { |
| 376 | files: [{ |
| 377 | dot: true, |
| 378 | src: [ |
| 379 | '.tmp', |
| 380 | '<%= config.dist %>/*', |
| 381 | '!<%= config.dist %>/.git*' |
| 382 | ] |
| 383 | }] |
| 384 | }, |
| 385 | server: '.tmp' |
| 386 | }, |
| 387 | // Add vendor prefixed styles |
| 388 | autoprefixer: { |
| 389 | options: { |
| 390 | browsers: ['> 1%', 'last 2 versions', 'Firefox ESR', 'Opera 12.1'] |
| 391 | }, |
| 392 | dist: { |
| 393 | files: [{ |
| 394 | expand: true, |
| 395 | cwd: '.tmp/css/', |
| 396 | src: '{,*/**/}*.css', |
| 397 | dest: '.tmp/css/' |
| 398 | }] |
| 399 | } |
| 400 | }, |
| 401 | |
| 402 | // Automatically inject Bower components into the HTML file |
| 403 | wiredep: { |
| 404 | app: { |
| 405 | ignorePath: /^\/|\.\.\//, |
| 406 | src: ['<%= config.app %>/index.html'] |
| 407 | } |
| 408 | }, |
| 409 | |
| 410 | // Renames files for browser caching purposes |
| 411 | rev: { |
| 412 | dist: { |
| 413 | files: { |
| 414 | src: [ |
| 415 | '<%= config.dist %>/scripts/{,*/}*.js', |
| 416 | '<%= config.dist %>/styles/{,*/}*.css', |
| 417 | '<%= config.dist %>/images/{,*/}*.*', |
| 418 | '!<%= config.dist %>/images/resource-icons/{,*/}*.*', |
| 419 | '!<%= config.dist %>/images/service-icons/{,*/}*.*', |
| 420 | '!<%= config.dist %>/images/relationship-icons/{,*/}*.*', |
| 421 | '<%= config.dist %>/*.{ico,png}' |
| 422 | ] |
| 423 | } |
| 424 | } |
| 425 | }, |
| 426 | |
| 427 | // Reads HTML for usemin blocks to enable smart builds that automatically |
| 428 | // concat, minify and revision files. Creates configurations in memory so |
| 429 | // additional tasks can operate on them |
| 430 | useminPrepare: { |
| 431 | options: { |
| 432 | dest: '<%= config.dist %>' |
| 433 | }, |
| 434 | sdc: { |
| 435 | src: ['<%= config.app %>/index.html'] |
| 436 | }, |
| 437 | html: '<%= config.app %>/index.html' |
| 438 | }, |
| 439 | |
| 440 | // Performs rewrites based on rev and the useminPrepare configuration |
| 441 | usemin: { |
| 442 | options: { |
| 443 | assetsDirs: [ |
| 444 | '<%= config.dist %>', |
| 445 | '<%= config.dist %>/images', |
| 446 | '<%= config.dist %>/styles' |
| 447 | ], |
| 448 | // This is so we update image references in our ng-templates |
| 449 | patterns: { |
| 450 | js: [ |
| 451 | [/(assets\/images\/.*?\.(?:gif|jpeg|jpg|png|webp|svg))/gm, 'Update the JS to reference our revved images'] |
| 452 | ] |
| 453 | } |
| 454 | }, |
| 455 | html: ['<%= config.dist %>/{,*/}*.html'], |
| 456 | css: ['<%= config.dist %>/styles/{,*/}*.css'], |
| 457 | js: ['<%= config.dist %>/public/{,*/}*.js'] |
| 458 | }, |
| 459 | |
| 460 | // The following *-min tasks produce minified files in the dist folder |
| 461 | imagemin: { |
| 462 | dist: { |
| 463 | files: [{ |
| 464 | expand: true, |
| 465 | cwd: '<%= config.app %>/images', |
| 466 | src: '<%= config.app %>/**/*.{gif,jpeg,jpg,png}', |
| 467 | dest: '<%= config.dist %>/images' |
| 468 | }] |
| 469 | } |
| 470 | }, |
| 471 | |
| 472 | svgmin: { |
| 473 | dist: { |
| 474 | files: [{ |
| 475 | expand: true, |
| 476 | cwd: '<%= config.app %>/images', |
| 477 | src: '{,*/}*.svg', |
| 478 | dest: '<%= config.dist %>/images' |
| 479 | }] |
| 480 | } |
| 481 | }, |
| 482 | |
| 483 | htmlmin: { |
| 484 | dist: { |
| 485 | options: { |
| 486 | collapseBooleanAttributes: true, |
| 487 | collapseWhitespace: true, |
| 488 | conservativeCollapse: true, |
| 489 | removeAttributeQuotes: true, |
| 490 | removeCommentsFromCDATA: true, |
| 491 | removeEmptyAttributes: true, |
| 492 | removeOptionalTags: true, |
| 493 | removeRedundantAttributes: true, |
| 494 | useShortDoctype: true |
| 495 | }, |
| 496 | files: [{ |
| 497 | expand: true, |
| 498 | cwd: '<%= config.dist %>', |
| 499 | src: '{,*/}*.html', |
| 500 | dest: '<%= config.dist %>' |
| 501 | }] |
| 502 | } |
| 503 | }, |
| 504 | |
| 505 | // By default, your `index.html`'s <!-- Usemin block --> will take care |
| 506 | // of minification. These next options are pre-configured if you do not |
| 507 | // wish to use the Usemin blocks. |
| 508 | cssmin: { |
| 509 | dist: { |
| 510 | files: { |
| 511 | '<%= config.dist %>/styles/main.css': [ |
| 512 | '.tmp/css/{,*/**/}*.css', |
| 513 | '<%= config.app %>/scripts/{,*/**/}*.css', |
| 514 | '<%= config.app %>/styles/app.css' |
| 515 | ] |
| 516 | } |
| 517 | } |
| 518 | }, |
| 519 | uglify: { |
| 520 | dist: { |
| 521 | files: { |
| 522 | '<%= config.dist %>/scripts/scripts.js': [ |
| 523 | '<%= config.dist %>/scripts/scripts.js' |
| 524 | ] |
| 525 | } |
| 526 | } |
| 527 | }, |
| 528 | replace: { |
| 529 | cssReplace: { |
| 530 | src: ['<%= config.app %>/scripts/{,*/**/}*.css', |
| 531 | '<%= config.app %>/styles/{,*/**/}*.css'], |
| 532 | overwrite: true, |
| 533 | replacements: [ |
| 534 | { |
| 535 | from: '../../../images/', |
| 536 | to: '../images/' |
| 537 | }, |
| 538 | { |
| 539 | from: '../../images/', |
| 540 | to: '../images/' |
| 541 | }, |
| 542 | { |
| 543 | from: '../../../fonts/', |
| 544 | to: '../fonts/' |
| 545 | }, |
| 546 | { |
| 547 | from: '../../fonts/', |
| 548 | to: '../fonts/' |
| 549 | }, |
| 550 | { |
| 551 | from: '../../../styles/images/', |
| 552 | to: 'images/' |
| 553 | } |
| 554 | ] |
| 555 | }, |
| 556 | }, |
| 557 | concat: { |
| 558 | dist: { |
| 559 | options: { |
| 560 | separator: ';\n' |
| 561 | }, |
| 562 | src: ['<%= config.app %>/scripts/{,*/**/}*.js'], |
| 563 | dest: '.tmp/concat/scripts/scripts.js' |
| 564 | }, |
| 565 | generated: { |
| 566 | options: { |
| 567 | separator: '\n' |
| 568 | } |
| 569 | } |
| 570 | }, |
| 571 | |
| 572 | // Copies remaining files to places other tasks can use |
| 573 | copy: { |
| 574 | dist: { |
| 575 | files: [{ |
| 576 | expand: true, |
| 577 | dot: true, |
| 578 | cwd: '<%= config.app %>', |
| 579 | dest: '<%= config.dist %>', |
| 580 | src: [ |
| 581 | '*.{ico,png,txt}', |
| 582 | '.htaccess', |
| 583 | // 'bower_components/**/*', |
| 584 | 'styles/images/**/*', |
| 585 | 'styles/fonts/**/*', |
| 586 | 'languages/**/*', |
| 587 | 'index.html' |
| 588 | ] |
| 589 | }, { |
| 590 | src: 'node_modules/apache-server-configs/dist/.htaccess', |
| 591 | dest: '<%= config.dist %>/.htaccess' |
| 592 | }, |
| 593 | { |
| 594 | expand: true, |
| 595 | cwd: '.tmp/images', |
| 596 | dest: '<%= config.dist %>/images', |
| 597 | src: ['generated/*'] |
| 598 | }, |
| 599 | //TODO to remove this section after integration onboard finished |
| 600 | { |
| 601 | expand: true, |
| 602 | cwd: '<%= config.app %>/third-party', |
| 603 | dest: '<%= config.dist %>/third-party', |
| 604 | src: ['onboard_bundle_full.js'] |
| 605 | }, |
| 606 | { |
| 607 | expand: true, |
| 608 | dest: '<%= config.dist %>', |
| 609 | src: [ |
| 610 | 'package.json' |
| 611 | ] |
| 612 | } |
| 613 | ] |
| 614 | }, |
| 615 | styles: { |
| 616 | expand: true, |
| 617 | cwd: '<%= config.app %>/styles', |
| 618 | dest: '.tmp/css/', |
| 619 | src: '{,*/**/}*.css' |
| 620 | } |
| 621 | }, |
| 622 | |
| 623 | // Run some tasks in parallel to speed up build process |
| 624 | concurrent: { |
| 625 | server: ['copy:styles'], |
| 626 | test: ['copy:styles'], |
| 627 | dist: [ |
| 628 | 'copy:styles', |
| 629 | 'imagemin' |
| 630 | ] |
| 631 | }, |
| 632 | |
| 633 | // Test settings |
| 634 | karma: { |
| 635 | dev: { |
| 636 | configFile: "tests/karma.unit.conf.js", |
| 637 | singleRun: true, |
| 638 | options: { |
| 639 | browsers: ['Chrome'], |
| 640 | coverageReporter: { |
| 641 | type: 'html', |
| 642 | dir: 'tests/Coverage' |
| 643 | } |
| 644 | } |
| 645 | }, |
| 646 | debug: { |
| 647 | configFile: "tests/karma.unit.conf.js", |
| 648 | singleRun: false, |
| 649 | //comment out this line if you want to cancel the watch and see the UT log |
| 650 | background: true, |
| 651 | options: { |
| 652 | browsers: ['Chrome'], |
| 653 | reporters: [ |
| 654 | 'junit', |
| 655 | 'dots', |
| 656 | 'progress' |
| 657 | ] |
| 658 | } |
| 659 | }, |
| 660 | jenkins: { |
| 661 | configFile: "tests/karma.unit.conf.js", |
| 662 | singleRun: true, |
| 663 | options: { |
| 664 | browsers: ['PhantomJS'], |
| 665 | coverageReporter: { |
| 666 | type: 'text-summary', |
| 667 | dir: 'tests/Coverage', |
| 668 | file: 'coverage.txt' |
| 669 | } |
| 670 | } |
| 671 | } |
| 672 | }, |
| 673 | |
| 674 | tslint: { |
| 675 | options: { |
| 676 | configuration: 'tslint.json' |
| 677 | }, |
| 678 | files: { |
| 679 | src: ['<%= config.app %>/**/*.ts'] |
| 680 | } |
| 681 | } |
| 682 | }); |
| 683 | |
| 684 | grunt.registerTask('serve', 'start the server and preview your app, --allow-remote for remote access', function (target) { |
| 685 | |
| 686 | var env = grunt.option('env'); |
| 687 | |
| 688 | if (grunt.option('allow-remote')) { |
| 689 | grunt.config.set('connect.options.hostname', '0.0.0.0'); |
| 690 | } |
| 691 | if (target === 'dist') { |
| 692 | return grunt.task.run(['build', 'connect:dist:keepalive']); |
| 693 | } |
| 694 | |
| 695 | |
| 696 | if (env === 'mock') { |
| 697 | grunt.task.run([ |
| 698 | 'express:mock', |
| 699 | 'clean:generated', |
| 700 | 'ts:all', |
| 701 | 'ngtemplates:app', |
| 702 | 'injector', |
| 703 | 'less:all', |
| 704 | 'ngconstant', |
| 705 | 'wiredep', |
| 706 | 'concurrent:server', |
| 707 | 'autoprefixer', |
| 708 | 'connect:livereload', |
| 709 | 'watch:html', |
| 710 | 'watch:less' |
| 711 | ]); |
| 712 | } |
| 713 | |
| 714 | grunt.task.run([ |
| 715 | 'clean:generated', |
| 716 | 'ts:all', |
| 717 | 'ngtemplates:app', |
| 718 | 'injector', |
| 719 | 'less:all', |
| 720 | 'ngconstant', |
| 721 | 'wiredep', |
| 722 | 'concurrent:server', |
| 723 | 'autoprefixer', |
| 724 | 'connect:livereload', |
| 725 | 'watch' |
| 726 | ]); |
| 727 | }); |
| 728 | |
| 729 | grunt.registerTask('build', [ |
| 730 | 'clean:generated', |
| 731 | 'less:all', |
| 732 | 'ts:all', |
| 733 | 'ngconstant', |
| 734 | 'ngtemplates:app', |
| 735 | 'wiredep', |
| 736 | 'replace', |
| 737 | 'clean:dist', |
| 738 | 'useminPrepare:sdc', |
| 739 | 'concurrent:dist', |
| 740 | 'autoprefixer:dist', |
| 741 | 'concat', |
| 742 | 'copy:dist', |
| 743 | 'cssmin', |
| 744 | 'uglify', |
| 745 | 'rev', |
| 746 | 'usemin' |
| 747 | ]); |
| 748 | |
| 749 | grunt.registerTask("test", function (target) { |
| 750 | |
| 751 | if (!(target === 'debug' || target === 'dev' || target === 'jenkins')) { |
| 752 | throw new Error("target available for test are <dev|debug|jenkins>"); |
| 753 | } |
| 754 | var tasks = [ |
| 755 | // "tslint:karma", |
| 756 | // "ngconstant", |
| 757 | //// "concurrent:test", |
| 758 | // "servicesIconConstants", |
| 759 | // "autoprefixer", |
| 760 | // "ngtemplates:testsTemplates", |
| 761 | // "connect:test" |
| 762 | ]; |
| 763 | |
| 764 | tasks.push('karma:' + target); |
| 765 | if (target === 'debug') { |
| 766 | if (grunt.config.get('watch.ts')) { |
| 767 | tasks.push("watch:ts"); |
| 768 | } else { |
| 769 | throw new Error("target watch:ts is not available, verify that it exists in your Gruntfile"); |
| 770 | } |
| 771 | } |
| 772 | grunt.task.run(tasks); |
| 773 | }); |
| 774 | |
| 775 | |
| 776 | var lessSingleTask = function (filePath) { |
| 777 | var lessSingleFiles = [{ |
| 778 | expand: true, |
| 779 | src: [filePath.replace(/\\/g, '/')], |
| 780 | ext: '.css' |
| 781 | }]; |
| 782 | grunt.config('less.single.files', lessSingleFiles); |
| 783 | grunt.config('watch.less.tasks', 'less:single'); |
| 784 | |
| 785 | }; |
| 786 | |
| 787 | var tsSingleTask = function (filePath) { |
| 788 | |
| 789 | var tsSingleData = { |
| 790 | src: [filePath.replace(/\\/g, '/')] |
| 791 | }; |
| 792 | // grunt.config('ts.single', tsSingleData); |
| 793 | |
| 794 | }; |
| 795 | |
| 796 | var singleTaskByTaskName = { |
| 797 | //less: lessSingleTask, |
| 798 | ts: tsSingleTask |
| 799 | }; |
| 800 | |
| 801 | var onGruntWatchEvent = function (action, filepath, target) { |
| 802 | if (singleTaskByTaskName[target]) { |
| 803 | singleTaskByTaskName[target].call(undefined, filepath); |
| 804 | } |
| 805 | }; |
| 806 | grunt.event.on('watch', onGruntWatchEvent); |
| 807 | }; |