<commit_before>'use strict';

module.exports = function(grunt) {

    if (grunt.option('production')) {
        // Only load tasks from packages listed under `dependencies`.
        require('load-grunt-tasks')(grunt, {scope: 'dependencies'});
    } else {
        // Load tasks from all packages listed in package.json.
        require('load-grunt-tasks')(grunt);
    }

    grunt.initConfig({

        pkg: grunt.file.readJSON('package.json'),

        clean: {
            dist: ['dist/'],
            tmp: ['.tmp/']
        },

        htmlangular: {
            options: {
                reportpath: null
            },
            files: {
                src: ['ui/*.html'],
                nonull: true
            },
        },

        useminPrepare:{
            index: {
                src:'ui/index.html',
                nonull: true,
                options:{
                    dest:'dist'
                }
            },
            userguide: {
                src:'ui/userguide.html',
                nonull: true,
                options:{
                    dest:'dist'
                }
            },
            logviewer: {
                src:'ui/logviewer.html',
                nonull: true,
                options:{
                    dest:'dist'
                }
            },
            perf: {
                src:'ui/perf.html',
                nonull: true,
                options:{
                    dest:'dist'
                }
            },
        },

        usemin:{ html:['dist/index.html', 'dist/userguide.html', 'dist/logviewer.html',
                       'dist/perf.html'] },

        'cache-busting': {
            indexjs: {
                replace: ['dist/**/*.html'],
                replacement: 'index.min.js',
                file: 'dist/js/index.min.js',
                cleanup: true //Remove previously generated hashed files.
            },
            logviewerjs: {
                replace: ['dist/**/*.html'],
                replacement: 'logviewer.min.js',
                file: 'dist/js/logviewer.min.js',
                cleanup: true
            },
            perfjs: {
                replace: ['dist/**/*.html'],
                replacement: 'perf.min.js',
                file: 'dist/js/perf.min.js',
                cleanup: true
            },
            userguidejs: {
                replace: ['dist/**/*.html'],
                replacement: 'userguide.min.js',
                file: 'dist/js/userguide.min.js',
                cleanup: true
            },
            indexcss: {
                replace: ['dist/**/*.html'],
                replacement: 'index.min.css',
                file: 'dist/css/index.min.css',
                cleanup: true
            },
            logviewercss: {
                replace: ['dist/**/*.html'],
                replacement: 'logviewer.min.css',
                file: 'dist/css/logviewer.min.css',
                cleanup: true
            },
            perfcss: {
                replace: ['dist/**/*.html'],
                replacement: 'perf.min.css',
                file: 'dist/css/perf.min.css',
                cleanup: true
            },
            userguidecss: {
                replace: ['dist/**/*.html'],
                replacement: 'userguide.min.css',
                file: 'dist/css/userguide.min.css',
                cleanup: true
            }
        },

        copy:{

            main: {
                files: [
                    { src:'ui/robots.txt', dest:'dist/robots.txt', nonull: true },
                    { src:'ui/index.html', dest:'dist/index.html', nonull: true },
                    { src:'ui/userguide.html', dest:'dist/userguide.html', nonull: true },
                    { src:'ui/logviewer.html', dest:'dist/logviewer.html', nonull: true },
                    { src:'ui/perf.html', dest:'dist/perf.html', nonull: true }
                ]
            },
            // Copy img dir
            img:{
                expand: true,
                src: 'ui/img/*',
                dest: 'dist/img/',
                nonull: true,
                flatten: true
                },
            // Copy html in partials
            partials:{
                expand: true,
                src: 'ui/partials/*',
                dest: 'dist/partials/',
                nonull: true,
                flatten: true
                },
            // Copy fonts
            fonts:{
                expand: true,
                src: 'ui/vendor/fonts/*',
                dest: 'dist/fonts/',
                nonull: true,
                flatten: true
                },
            // Copy html in plugins, make sure not to flatten
            // to retain the directory structure for the html
            // and make paths relative with cwd definition.
            plugins:{
                expand: true,
                cwd: 'ui/plugins/',
                src: '**/*.html',
                dest: 'dist/plugins/',
                nonull: true,
                flatten: false
                }
        },
        uglify:{
            options:{
                report: 'min',
                // Cannot use mangle, it will break angularjs's dependency
                // injection
                mangle: false
            }
        },
        ngtemplates: {
            treeherder: {
                cwd: 'ui',
                src: ['partials/main/*.html', 'plugins/**/*.html'],
                dest: 'dist/js/index.min.js',
                options: {
                    usemin: 'dist/js/index.min.js',
                    append: true,
                    htmlmin: {
                        collapseBooleanAttributes:      true,
                        collapseWhitespace:             true,
                        conservativeCollapse:           true,
                        removeAttributeQuotes:          true,
                        removeComments:                 true,
                        removeEmptyAttributes:          true,
                        removeRedundantAttributes:      true,
                        removeScriptTypeAttributes:     true,
                        removeStyleLinkTypeAttributes:  true,
                        keepClosingSlash: true
                    }
                }
            },
            logviewer: {
                cwd: 'ui',
                src: ['partials/main/thNotificationsBox.html', 'partials/logviewer/*.html'],
                dest: 'dist/js/logviewer.min.js',
                options: {
                    usemin: 'dist/js/logviewer.min.js',
                    append: true,
                    htmlmin: {
                        collapseBooleanAttributes:      true,
                        collapseWhitespace:             true,
                        conservativeCollapse:           true,
                        removeAttributeQuotes:          true,
                        removeComments:                 true,
                        removeEmptyAttributes:          true,
                        removeRedundantAttributes:      true,
                        removeScriptTypeAttributes:     true,
                        removeStyleLinkTypeAttributes:  true,
                        keepClosingSlash: true
                    }
                }
            },
            perf: {
                cwd: 'ui',
                src: 'partials/perf/*.html',
                dest: 'dist/js/perf.min.js',
                options: {
                    usemin: 'dist/js/perf.min.js',
                    append: true,
                    htmlmin: {
                        collapseBooleanAttributes:      true,
                        collapseWhitespace:             true,
                        conservativeCollapse:           true,
                        removeAttributeQuotes:          true,
                        removeComments:                 true,
                        removeEmptyAttributes:          true,
                        removeRedundantAttributes:      true,
                        removeScriptTypeAttributes:     true,
                        removeStyleLinkTypeAttributes:  true,
                        keepClosingSlash: true
                    }
                }
            },
            userguide: {
                cwd: 'ui',
                src: 'partials/main/thShortcutTable.html',
                dest: 'dist/js/userguide.min.js',
                options: {
                    usemin: 'dist/js/userguide.min.js',
                    append: true,
                    htmlmin: {
                        collapseBooleanAttributes:      true,
                        collapseWhitespace:             true,
                        conservativeCollapse:           true,
                        removeAttributeQuotes:          true,
                        removeComments:                 true,
                        removeEmptyAttributes:          true,
                        removeRedundantAttributes:      true,
                        removeScriptTypeAttributes:     true,
                        removeStyleLinkTypeAttributes:  true,
                        keepClosingSlash: true
                    }
                }
            }
        },
        eslint: {
            options: {
                config: '.eslintrc'
            },
            target: ['ui/js/*.js',
                     'ui/js/**/*.js',
                     'ui/js/**/**/*.js']
        }
    });

    // Default tasks
    grunt.registerTask('build', [
        'clean:dist',
        'copy:main',
        'copy:img',
        'copy:fonts',
        'useminPrepare',
        'concat',
        'cssmin',
        'uglify',
        'usemin',
        'ngtemplates',
        'cache-busting',
        'clean:tmp'
        ]);

    grunt.registerTask('checkjs', [
        'eslint'
        ]);
};
<commit_msg>Bug 1205758 - Clean up the Gruntfile --production option<commit_after>'use strict';

module.exports = function(grunt) {

    var packageTypes = ['dependencies'];
    if (!grunt.option('production')) {
        // Also load tasks from packages listed under `devDependencies`, so
        // long as a `--production` option hasn't been passed to Grunt.
        packageTypes.push('devDependencies');
    }
    require('load-grunt-tasks')(grunt, {scope: packageTypes});

    grunt.initConfig({

        pkg: grunt.file.readJSON('package.json'),

        clean: {
            dist: ['dist/'],
            tmp: ['.tmp/']
        },

        htmlangular: {
            options: {
                reportpath: null
            },
            files: {
                src: ['ui/*.html'],
                nonull: true
            },
        },

        useminPrepare:{
            index: {
                src:'ui/index.html',
                nonull: true,
                options:{
                    dest:'dist'
                }
            },
            userguide: {
                src:'ui/userguide.html',
                nonull: true,
                options:{
                    dest:'dist'
                }
            },
            logviewer: {
                src:'ui/logviewer.html',
                nonull: true,
                options:{
                    dest:'dist'
                }
            },
            perf: {
                src:'ui/perf.html',
                nonull: true,
                options:{
                    dest:'dist'
                }
            },
        },

        usemin:{ html:['dist/index.html', 'dist/userguide.html', 'dist/logviewer.html',
                       'dist/perf.html'] },

        'cache-busting': {
            indexjs: {
                replace: ['dist/**/*.html'],
                replacement: 'index.min.js',
                file: 'dist/js/index.min.js',
                cleanup: true //Remove previously generated hashed files.
            },
            logviewerjs: {
                replace: ['dist/**/*.html'],
                replacement: 'logviewer.min.js',
                file: 'dist/js/logviewer.min.js',
                cleanup: true
            },
            perfjs: {
                replace: ['dist/**/*.html'],
                replacement: 'perf.min.js',
                file: 'dist/js/perf.min.js',
                cleanup: true
            },
            userguidejs: {
                replace: ['dist/**/*.html'],
                replacement: 'userguide.min.js',
                file: 'dist/js/userguide.min.js',
                cleanup: true
            },
            indexcss: {
                replace: ['dist/**/*.html'],
                replacement: 'index.min.css',
                file: 'dist/css/index.min.css',
                cleanup: true
            },
            logviewercss: {
                replace: ['dist/**/*.html'],
                replacement: 'logviewer.min.css',
                file: 'dist/css/logviewer.min.css',
                cleanup: true
            },
            perfcss: {
                replace: ['dist/**/*.html'],
                replacement: 'perf.min.css',
                file: 'dist/css/perf.min.css',
                cleanup: true
            },
            userguidecss: {
                replace: ['dist/**/*.html'],
                replacement: 'userguide.min.css',
                file: 'dist/css/userguide.min.css',
                cleanup: true
            }
        },

        copy:{

            main: {
                files: [
                    { src:'ui/robots.txt', dest:'dist/robots.txt', nonull: true },
                    { src:'ui/index.html', dest:'dist/index.html', nonull: true },
                    { src:'ui/userguide.html', dest:'dist/userguide.html', nonull: true },
                    { src:'ui/logviewer.html', dest:'dist/logviewer.html', nonull: true },
                    { src:'ui/perf.html', dest:'dist/perf.html', nonull: true }
                ]
            },
            // Copy img dir
            img:{
                expand: true,
                src: 'ui/img/*',
                dest: 'dist/img/',
                nonull: true,
                flatten: true
                },
            // Copy html in partials
            partials:{
                expand: true,
                src: 'ui/partials/*',
                dest: 'dist/partials/',
                nonull: true,
                flatten: true
                },
            // Copy fonts
            fonts:{
                expand: true,
                src: 'ui/vendor/fonts/*',
                dest: 'dist/fonts/',
                nonull: true,
                flatten: true
                },
            // Copy html in plugins, make sure not to flatten
            // to retain the directory structure for the html
            // and make paths relative with cwd definition.
            plugins:{
                expand: true,
                cwd: 'ui/plugins/',
                src: '**/*.html',
                dest: 'dist/plugins/',
                nonull: true,
                flatten: false
                }
        },
        uglify:{
            options:{
                report: 'min',
                // Cannot use mangle, it will break angularjs's dependency
                // injection
                mangle: false
            }
        },
        ngtemplates: {
            treeherder: {
                cwd: 'ui',
                src: ['partials/main/*.html', 'plugins/**/*.html'],
                dest: 'dist/js/index.min.js',
                options: {
                    usemin: 'dist/js/index.min.js',
                    append: true,
                    htmlmin: {
                        collapseBooleanAttributes:      true,
                        collapseWhitespace:             true,
                        conservativeCollapse:           true,
                        removeAttributeQuotes:          true,
                        removeComments:                 true,
                        removeEmptyAttributes:          true,
                        removeRedundantAttributes:      true,
                        removeScriptTypeAttributes:     true,
                        removeStyleLinkTypeAttributes:  true,
                        keepClosingSlash: true
                    }
                }
            },
            logviewer: {
                cwd: 'ui',
                src: ['partials/main/thNotificationsBox.html', 'partials/logviewer/*.html'],
                dest: 'dist/js/logviewer.min.js',
                options: {
                    usemin: 'dist/js/logviewer.min.js',
                    append: true,
                    htmlmin: {
                        collapseBooleanAttributes:      true,
                        collapseWhitespace:             true,
                        conservativeCollapse:           true,
                        removeAttributeQuotes:          true,
                        removeComments:                 true,
                        removeEmptyAttributes:          true,
                        removeRedundantAttributes:      true,
                        removeScriptTypeAttributes:     true,
                        removeStyleLinkTypeAttributes:  true,
                        keepClosingSlash: true
                    }
                }
            },
            perf: {
                cwd: 'ui',
                src: 'partials/perf/*.html',
                dest: 'dist/js/perf.min.js',
                options: {
                    usemin: 'dist/js/perf.min.js',
                    append: true,
                    htmlmin: {
                        collapseBooleanAttributes:      true,
                        collapseWhitespace:             true,
                        conservativeCollapse:           true,
                        removeAttributeQuotes:          true,
                        removeComments:                 true,
                        removeEmptyAttributes:          true,
                        removeRedundantAttributes:      true,
                        removeScriptTypeAttributes:     true,
                        removeStyleLinkTypeAttributes:  true,
                        keepClosingSlash: true
                    }
                }
            },
            userguide: {
                cwd: 'ui',
                src: 'partials/main/thShortcutTable.html',
                dest: 'dist/js/userguide.min.js',
                options: {
                    usemin: 'dist/js/userguide.min.js',
                    append: true,
                    htmlmin: {
                        collapseBooleanAttributes:      true,
                        collapseWhitespace:             true,
                        conservativeCollapse:           true,
                        removeAttributeQuotes:          true,
                        removeComments:                 true,
                        removeEmptyAttributes:          true,
                        removeRedundantAttributes:      true,
                        removeScriptTypeAttributes:     true,
                        removeStyleLinkTypeAttributes:  true,
                        keepClosingSlash: true
                    }
                }
            }
        },
        eslint: {
            options: {
                config: '.eslintrc'
            },
            target: ['ui/js/*.js',
                     'ui/js/**/*.js',
                     'ui/js/**/**/*.js']
        }
    });

    // Default tasks
    grunt.registerTask('build', [
        'clean:dist',
        'copy:main',
        'copy:img',
        'copy:fonts',
        'useminPrepare',
        'concat',
        'cssmin',
        'uglify',
        'usemin',
        'ngtemplates',
        'cache-busting',
        'clean:tmp'
        ]);

    grunt.registerTask('checkjs', [
        'eslint'
        ]);
};
<|endoftext|>


<commit_before>var ValidAccountOpening = (function(){
  var redirectCookie = function() {
    if (page.client.redirect_if_logout()) {
        return;
    }
    if (!page.client.is_virtual()) {
      window.location.href = page.url.url_for('user/my_accountws');
      return;
    }
    for (i = 0; i < page.user.loginid_array.length; i++){
      if (page.user.loginid_array[i].real === true){
        window.location.href = page.url.url_for('user/my_accountws');
        return;
      }
    }
  };
  var handler = function(response, message) {
    if (response.error) {
      var errorMessage = response.error.message;
      if (document.getElementById('real-form')) {
        $('#real-form').remove();
      } else if (document.getElementById('japan-form')) {
        $('#japan-form').remove();
      }
      var error = document.getElementsByClassName('notice-msg')[0];
      error.innerHTML = (response.msg_type === 'sanity_check') ? text.localize('There was some invalid character in an input field.') : errorMessage;
      error.parentNode.parentNode.parentNode.setAttribute('style', 'display:block');
      return;
    } else {
      var loginid = message.client_id;
      //set cookies
      var oldCookieValue = $.cookie('loginid_list');
      var cookie_domain = '.' + document.domain.split('.').slice(-2).join('.');
      $.cookie('loginid_list', loginid + ':R:E+' + oldCookieValue, {domain: cookie_domain, path:'/'});
      $.cookie('loginid', loginid, {domain: cookie_domain, path:'/'});
      // set a flag to push to gtm in my_account
      localStorage.setItem('new_account', '1');
      //generate dropdown list and switch
      page.client.clear_storage_values();
      var option = new Option('Real Account (' + loginid + ')', loginid);
      document.getElementById('client_loginid').appendChild(option);
      $('#client_loginid option[value="' + page.client.loginid + '"]').removeAttr('selected');
      option.setAttribute('selected', 'selected');
      $('#loginid-switch-form').submit();
    }
  };
  var letter, numbers, space, hyphen, period, apost;

  var initializeValues = function() {
    letters = Content.localize().textLetters;
    numbers = Content.localize().textNumbers;
    space   = Content.localize().textSpace;
    hyphen  = Content.localize().textHyphen;
    period  = Content.localize().textPeriod;
    apost   = Content.localize().textApost;
  };

  var checkFname = function(fname, errorFname) {
    if (Trim(fname.value).length < 2) {
      errorFname.innerHTML = Content.errorMessage('min', '2');
      Validate.displayErrorMessage(errorFname);
      window.accountErrorCounter++;
    } else if (!/^[a-zA-Z\s-.']+$/.test(fname.value)){
      initializeValues();
      errorFname.innerHTML = Content.errorMessage('reg', [letters, space, hyphen, period, apost]);
      Validate.displayErrorMessage(errorFname);
      window.accountErrorCounter++;
    }
    return;
  };
  var checkLname = function(lname, errorLname) {
    if (Trim(lname.value).length < 2) {
      errorLname.innerHTML = Content.errorMessage('min', '2');
      Validate.displayErrorMessage(errorLname);
      window.accountErrorCounter++;
    } else if (!/^[a-zA-Z\s-.']+$/.test(lname.value)){
      initializeValues();
      errorLname.innerHTML = Content.errorMessage('reg', [letters, space, hyphen, period, apost]);
      Validate.displayErrorMessage(errorLname);
      window.accountErrorCounter++;
    }
    return;
  };
  var checkDate = function(dobdd, dobmm, dobyy, errorDob) {
    if (!isValidDate(dobdd.value, dobmm.value, dobyy.value) || dobdd.value === '' || dobmm.value === '' || dobyy.value === '') {
      errorDob.innerHTML = Content.localize().textErrorBirthdate;
      Validate.displayErrorMessage(errorDob);
      window.accountErrorCounter++;
    }
    return;
  };
  var checkPostcode = function(postcode, errorPostcode) {
    if (postcode.value !== '' && !/^[a-zA-Z\d-]+$/.test(postcode.value)){
      initializeValues();
      errorPostcode.innerHTML = Content.errorMessage('reg', [letters, numbers, hyphen]);
      Validate.displayErrorMessage(errorPostcode);
      window.accountErrorCounter++;
    }
    return;
  };
  var checkTel = function(tel, errorTel) {
    if (tel.value.replace(/\+| /g,'').length < 6) {
      errorTel.innerHTML = Content.errorMessage('min', 6);
      Validate.displayErrorMessage(errorTel);
      window.accountErrorCounter++;
    } else if (!/^\+?[0-9\s]{6,35}$/.test(tel.value)){
      initializeValues();
      errorTel.innerHTML = Content.errorMessage('reg', [numbers, space]);
      Validate.displayErrorMessage(errorTel);
      window.accountErrorCounter++;
    }
    return;
  };
  var checkAnswer = function(answer, errorAnswer) {
    if (answer.value.length < 4) {
      errorAnswer.innerHTML = Content.errorMessage('min', 4);
      Validate.displayErrorMessage(errorAnswer);
      window.accountErrorCounter++;
    }
    return;
  };
  return {
    redirectCookie: redirectCookie,
    handler: handler,
    checkFname: checkFname,
    checkLname: checkLname,
    checkDate: checkDate,
    checkPostcode: checkPostcode,
    checkTel: checkTel,
    checkAnswer: checkAnswer
  };
}());
<commit_msg>Fix redirect handling for jp account<commit_after>var ValidAccountOpening = (function(){
  var redirectCookie = function() {
    if (page.client.redirect_if_logout()) {
        return;
    }
    if (!page.client.is_virtual()) {
      window.location.href = page.url.url_for('user/my_accountws');
      return;
    }
    for (i = 0; i < page.user.loginid_array.length; i++){
      if (page.user.loginid_array[i].real === true){
        window.location.href = page.url.url_for('user/my_accountws');
        return;
      }
    }
  };
  var handler = function(response, message) {
    if (response.error) {
      var errorMessage = response.error.message;
      if (document.getElementById('real-form')) {
        $('#real-form').remove();
      } else if (document.getElementById('japan-form')) {
        $('#japan-form').remove();
      }
      var error = document.getElementsByClassName('notice-msg')[0];
      error.innerHTML = (response.msg_type === 'sanity_check') ? text.localize('There was some invalid character in an input field.') : errorMessage;
      error.parentNode.parentNode.parentNode.setAttribute('style', 'display:block');
      return;
    } else if (getCookieItem('residence') !== 'jp') {     // jp account require more steps to have real account
      var loginid = message.client_id;
      //set cookies
      var oldCookieValue = $.cookie('loginid_list');
      var cookie_domain = '.' + document.domain.split('.').slice(-2).join('.');
      $.cookie('loginid_list', loginid + ':R:E+' + oldCookieValue, {domain: cookie_domain, path:'/'});
      $.cookie('loginid', loginid, {domain: cookie_domain, path:'/'});
      // set a flag to push to gtm in my_account
      localStorage.setItem('new_account', '1');
      //generate dropdown list and switch
      page.client.clear_storage_values();
      var option = new Option('Real Account (' + loginid + ')', loginid);
      document.getElementById('client_loginid').appendChild(option);
      $('#client_loginid option[value="' + page.client.loginid + '"]').removeAttr('selected');
      option.setAttribute('selected', 'selected');
      $('#loginid-switch-form').submit();
    }
  };
  var letters, numbers, space, hyphen, period, apost;

  var initializeValues = function() {
    letters = Content.localize().textLetters;
    numbers = Content.localize().textNumbers;
    space   = Content.localize().textSpace;
    hyphen  = Content.localize().textHyphen;
    period  = Content.localize().textPeriod;
    apost   = Content.localize().textApost;
  };

  var checkFname = function(fname, errorFname) {
    if (Trim(fname.value).length < 2) {
      errorFname.innerHTML = Content.errorMessage('min', '2');
      Validate.displayErrorMessage(errorFname);
      window.accountErrorCounter++;
    } else if (!/^[a-zA-Z\s-.']+$/.test(fname.value)){
      initializeValues();
      errorFname.innerHTML = Content.errorMessage('reg', [letters, space, hyphen, period, apost]);
      Validate.displayErrorMessage(errorFname);
      window.accountErrorCounter++;
    }
    return;
  };
  var checkLname = function(lname, errorLname) {
    if (Trim(lname.value).length < 2) {
      errorLname.innerHTML = Content.errorMessage('min', '2');
      Validate.displayErrorMessage(errorLname);
      window.accountErrorCounter++;
    } else if (!/^[a-zA-Z\s-.']+$/.test(lname.value)){
      initializeValues();
      errorLname.innerHTML = Content.errorMessage('reg', [letters, space, hyphen, period, apost]);
      Validate.displayErrorMessage(errorLname);
      window.accountErrorCounter++;
    }
    return;
  };
  var checkDate = function(dobdd, dobmm, dobyy, errorDob) {
    if (!isValidDate(dobdd.value, dobmm.value, dobyy.value) || dobdd.value === '' || dobmm.value === '' || dobyy.value === '') {
      errorDob.innerHTML = Content.localize().textErrorBirthdate;
      Validate.displayErrorMessage(errorDob);
      window.accountErrorCounter++;
    }
    return;
  };
  var checkPostcode = function(postcode, errorPostcode) {
    if (postcode.value !== '' && !/^[a-zA-Z\d-]+$/.test(postcode.value)){
      initializeValues();
      errorPostcode.innerHTML = Content.errorMessage('reg', [letters, numbers, hyphen]);
      Validate.displayErrorMessage(errorPostcode);
      window.accountErrorCounter++;
    }
    return;
  };
  var checkTel = function(tel, errorTel) {
    if (tel.value.replace(/\+| /g,'').length < 6) {
      errorTel.innerHTML = Content.errorMessage('min', 6);
      Validate.displayErrorMessage(errorTel);
      window.accountErrorCounter++;
    } else if (!/^\+?[0-9\s]{6,35}$/.test(tel.value)){
      initializeValues();
      errorTel.innerHTML = Content.errorMessage('reg', [numbers, space]);
      Validate.displayErrorMessage(errorTel);
      window.accountErrorCounter++;
    }
    return;
  };
  var checkAnswer = function(answer, errorAnswer) {
    if (answer.value.length < 4) {
      errorAnswer.innerHTML = Content.errorMessage('min', 4);
      Validate.displayErrorMessage(errorAnswer);
      window.accountErrorCounter++;
    }
    return;
  };
  return {
    redirectCookie: redirectCookie,
    handler: handler,
    checkFname: checkFname,
    checkLname: checkLname,
    checkDate: checkDate,
    checkPostcode: checkPostcode,
    checkTel: checkTel,
    checkAnswer: checkAnswer
  };
}());
<|endoftext|>


<commit_before>/*
 * Copyright 2014 Apereo Foundation (AF) Licensed under the
 * Educational Community License, Version 2.0 (the "License"); you may
 * not use this file except in compliance with the License. You may
 * obtain a copy of the License at
 *
 *     http://opensource.org/licenses/ECL-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an "AS IS"
 * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing
 * permissions and limitations under the License.
 */

module.exports = function(grunt) {
    var _ = require('underscore');
    var path = require('path');
    var shell = require('shelljs');
    var util = require('util');
    var mocha_grep = process.env['MOCHA_GREP'] || undefined;

    // Timeout used to determine when a test has failed
    var MOCHA_TIMEOUT = 40000;

    var regexErrors = false;

    // Project configuration.
    grunt.initConfig({
        'pkg': grunt.file.readJSON('package.json'),
        'jslint': {
            'files': [
                'Gruntfile.js',
                'node_modules/oae-*/lib/**/*.js',
                'node_modules/oae-*/tests/**/*.js',
                'node_modules/oae-*/config/**/*.js'
            ]
        },
        'jshint': {
            'options': {
                'node': true,
                'sub': true,
                'indent': 4,
                'trailing': true,
                'quotmark': 'single',
                'curly': true,
                'white': false,
                'strict': false,
                'globals': {
                    'it': true,
                    'describe': true,
                    'before': true,
                    'beforeEach': true,
                    'after': true,
                    'afterEach': true
                }
            },
            'files': '<%= jslint.files %>'
        },
        'mocha-hack': {
            'all': {
                'src': ['node_modules/oae-tests/runner/beforeTests.js', 'node_modules/oae-*/tests/**/*.js'],
                'options': {
                    'timeout': MOCHA_TIMEOUT,
                    'ignoreLeaks': true,
                    'reporter': 'spec',
                    'grep': mocha_grep,
                    'bail': false,
                    'slow': 500
                }
            }
        },
        'clean': ['target/'],
        'replace': {
            'check-style': {
                'src': ['node_modules/oae-*/**/*.js'],
                'overwrite': true,
                'replacements': [
                    {
                        'from': /@param (\S|\s\s)/,
                        'to': function(matchedWord, index, fullText, regexMatches) {
                            var msg ='@param should be followed by 2 spaces';
                            return logMatch(msg, matchedWord, index, fullText, regexMatches);
                        }
                    },
                    {
                        'from': /@return \s/,
                        'to': function(matchedWord, index, fullText, regexMatches) {
                            var msg ='@return should be followed by 1 space';
                            return logMatch(msg, matchedWord, index, fullText, regexMatches);
                        }
                    },
                    {
                        'from': /@returns/,
                        'to': function(matchedWord, index, fullText, regexMatches) {
                            var msg ='Use @return instead of @returns';
                            return logMatch(msg, matchedWord, index, fullText, regexMatches);
                        }
                    },
                    {
                        'from': /@throws \s/,
                        'to': function(matchedWord, index, fullText, regexMatches) {
                            var msg ='@throws should be followed by 1 space';
                            return logMatch(msg, matchedWord, index, fullText, regexMatches);
                        }
                    },
                    {
                        'from': /(tenant|globalAdmin)Server\.(get|post|put|head|del)\((.*)/,
                        'to': function(matchedWord, index, fullText, regexMatches) {
                            var msg = 'Do not use the tenantServer or globalAdminServer to bind routes. Use the Router object like this:\n\n  ' + regexMatches[0] + 'Router.on(\'' + regexMatches[1] + '\', ' + regexMatches[2];
                            return logMatch(msg, matchedWord, index, fullText, regexMatches);
                        }
                    }
                ]
            }
        }
    });

    // Utility function for logging regex matches
    var logMatch = function(msg, matchedWord, index, fullText, regexMatches) {
        var lineNum = fullText.substring(0, index).match(/\n/g).length + 1;
        var line = fullText.split('\n')[lineNum - 1];
        grunt.log.writeln(msg.red + ': ' + lineNum + ': ' + line);
        regexErrors = true;
        return matchedWord;
    };

    // Task to run the regex task and fail if it matches anything
    grunt.registerTask('check-style', ['replace', 'jshint', 'checkRegexErrors']);
    grunt.registerTask('checkRegexErrors', function() {
        grunt.task.requires('replace');
        if (regexErrors) {
            grunt.warn('Style rule validation failed');
        }
    });

    // Override default test task to use mocha-hack
    grunt.registerTask('test', ['mocha-hack']);

    // Make a task for running tests on a single module
    grunt.registerTask('test-module', 'Test a single module', function(module) {
        var config = {
            'src': ['node_modules/oae-tests/runner/beforeTests.js', 'node_modules/' + module + '/tests/**/*.js'],
            'options': {
                'timeout': MOCHA_TIMEOUT,
                'ignoreLeaks': true,
                'reporter': 'spec',
                'grep': mocha_grep
            }
        };
        grunt.config.set('mocha-hack.' + module, config);
        grunt.task.run('mocha-hack:' + module);
    });

    // Runs the unit tests and dumps some coverage data
    grunt.registerTask('test-instrumented', function(report) {
        // If no report format was provided, we default to `lcov` which generates lcov and html
        report = report || 'lcov';

        // Get the modules that should be excluded
        var nonOaeModules = grunt.file.expand({'filter': 'isDirectory'}, 'node_modules/*', '!node_modules/oae-*');
        var nonOaeModulesParameters = _.map(nonOaeModules, function(module) {
            return util.format('-x %s/\\*\\*', module);
        });

        // Exclude the tests from the coverage reports
        var oaeModules = grunt.file.expand({'filter': 'isDirectory'}, 'node_modules/oae-*');
        var testDirectories = _.map(oaeModules, function(directory) {
            return util.format('-x %s/tests/\\*\\*', directory);
        });

        // Exclude the config directories
        var configDirectories = _.map(oaeModules, function(module) {
            return util.format('-x %s/config/\\*\\*', module);
        });

        // Build up one big set of exlusion filters
        var excludeFilters = _.union(nonOaeModulesParameters, testDirectories, configDirectories);
        excludeFilters.push('-x Gruntfile.js');

        var cmd = util.format('node_modules/.bin/istanbul cover --verbose --dir target --no-default-excludes %s --report %s ./node_modules/grunt-cli/bin/grunt', excludeFilters.join(' '), report);

        var code = shell.exec(cmd).code;
        if (code !== 0) {
            process.exit(code);
        }
    });

    // Sends a coverage report to coveralls.io
    grunt.registerTask('coveralls', function() {
        // This assumes we're executing within the context of Travis CI
        // If not, you'll have to add a .converalls.yml file with `repo_token: ...` in it
        shell.exec('cat ./target/lcov.info | ./node_modules/coveralls/bin/coveralls.js');
    });

    // Run test coverage and open the report
    grunt.registerTask('test-coverage', ['clean', 'test-instrumented', 'showFile:target/lcov-report/index.html']);

    // Run test coverage
    grunt.registerTask('test-coverage-coveralls', ['clean', 'test-instrumented:lcovonly', 'coveralls']);

    // Make a task to open the browser
    grunt.registerTask('showFile', 'Open a file with the OS default viewer', function(file) {
        var browser = shell.env['BROWSER'];
        if (! browser) {
            if (process.platform === 'linux') {
                browser = 'xdg-open';
            } else if (process.platform === 'darwin') {
                browser = 'open';
            } else if (process.platform === 'win32') {
                browser = 'explorer.exe';
            }
        }
        if (browser) {
            shell.exec(browser + ' '  + ( file || 'target/coverage.html' ));
        }
    });

    // Bring in tasks from npm
    // Temporary work around till https://github.com/yaymukund/grunt-simple-mocha/issues/16 lands.
    grunt.loadNpmTasks('grunt-mocha-hack');
    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks('grunt-text-replace');

    // Copies the files that need to go in the release.
    // We remove the test files and the Grunt file as it could be potentially
    // devestating to run the tests in a production environment.
    // Example:
    //     grunt release:/tmp/release
    // will copy only those files you really need in order to run Hilary in a folder at `/tmp/release`.
    grunt.registerTask('release', function(outputDir) {
        if (!outputDir) {
            return grunt.log.writeln('Please provide a path where the files should be copied to'.red);
        }

        shell.exec('bin/package -so ' + outputDir);
    });

    // Default task.
    grunt.registerTask('default', ['check-style', 'test']);

};
<commit_msg>Removed line break<commit_after>/*
 * Copyright 2014 Apereo Foundation (AF) Licensed under the
 * Educational Community License, Version 2.0 (the "License"); you may
 * not use this file except in compliance with the License. You may
 * obtain a copy of the License at
 *
 *     http://opensource.org/licenses/ECL-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an "AS IS"
 * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing
 * permissions and limitations under the License.
 */

module.exports = function(grunt) {
    var _ = require('underscore');
    var path = require('path');
    var shell = require('shelljs');
    var util = require('util');
    var mocha_grep = process.env['MOCHA_GREP'] || undefined;

    // Timeout used to determine when a test has failed
    var MOCHA_TIMEOUT = 40000;

    var regexErrors = false;

    // Project configuration.
    grunt.initConfig({
        'pkg': grunt.file.readJSON('package.json'),
        'jslint': {
            'files': [
                'Gruntfile.js',
                'node_modules/oae-*/lib/**/*.js',
                'node_modules/oae-*/tests/**/*.js',
                'node_modules/oae-*/config/**/*.js'
            ]
        },
        'jshint': {
            'options': {
                'node': true,
                'sub': true,
                'indent': 4,
                'trailing': true,
                'quotmark': 'single',
                'curly': true,
                'white': false,
                'strict': false,
                'globals': {
                    'it': true,
                    'describe': true,
                    'before': true,
                    'beforeEach': true,
                    'after': true,
                    'afterEach': true
                }
            },
            'files': '<%= jslint.files %>'
        },
        'mocha-hack': {
            'all': {
                'src': ['node_modules/oae-tests/runner/beforeTests.js', 'node_modules/oae-*/tests/**/*.js'],
                'options': {
                    'timeout': MOCHA_TIMEOUT,
                    'ignoreLeaks': true,
                    'reporter': 'spec',
                    'grep': mocha_grep,
                    'bail': false,
                    'slow': 500
                }
            }
        },
        'clean': ['target/'],
        'replace': {
            'check-style': {
                'src': ['node_modules/oae-*/**/*.js'],
                'overwrite': true,
                'replacements': [
                    {
                        'from': /@param (\S|\s\s)/,
                        'to': function(matchedWord, index, fullText, regexMatches) {
                            var msg ='@param should be followed by 2 spaces';
                            return logMatch(msg, matchedWord, index, fullText, regexMatches);
                        }
                    },
                    {
                        'from': /@return \s/,
                        'to': function(matchedWord, index, fullText, regexMatches) {
                            var msg ='@return should be followed by 1 space';
                            return logMatch(msg, matchedWord, index, fullText, regexMatches);
                        }
                    },
                    {
                        'from': /@returns/,
                        'to': function(matchedWord, index, fullText, regexMatches) {
                            var msg ='Use @return instead of @returns';
                            return logMatch(msg, matchedWord, index, fullText, regexMatches);
                        }
                    },
                    {
                        'from': /@throws \s/,
                        'to': function(matchedWord, index, fullText, regexMatches) {
                            var msg ='@throws should be followed by 1 space';
                            return logMatch(msg, matchedWord, index, fullText, regexMatches);
                        }
                    },
                    {
                        'from': /(tenant|globalAdmin)Server\.(get|post|put|head|del)\((.*)/,
                        'to': function(matchedWord, index, fullText, regexMatches) {
                            var msg = 'Do not use the tenantServer or globalAdminServer to bind routes. Use the Router object like this:\n\n  ' + regexMatches[0] + 'Router.on(\'' + regexMatches[1] + '\', ' + regexMatches[2];
                            return logMatch(msg, matchedWord, index, fullText, regexMatches);
                        }
                    }
                ]
            }
        }
    });

    // Utility function for logging regex matches
    var logMatch = function(msg, matchedWord, index, fullText, regexMatches) {
        var lineNum = fullText.substring(0, index).match(/\n/g).length + 1;
        var line = fullText.split('\n')[lineNum - 1];
        grunt.log.writeln(msg.red + ': ' + lineNum + ': ' + line);
        regexErrors = true;
        return matchedWord;
    };

    // Task to run the regex task and fail if it matches anything
    grunt.registerTask('check-style', ['replace', 'jshint', 'checkRegexErrors']);
    grunt.registerTask('checkRegexErrors', function() {
        grunt.task.requires('replace');
        if (regexErrors) {
            grunt.warn('Style rule validation failed');
        }
    });

    // Override default test task to use mocha-hack
    grunt.registerTask('test', ['mocha-hack']);

    // Make a task for running tests on a single module
    grunt.registerTask('test-module', 'Test a single module', function(module) {
        var config = {
            'src': ['node_modules/oae-tests/runner/beforeTests.js', 'node_modules/' + module + '/tests/**/*.js'],
            'options': {
                'timeout': MOCHA_TIMEOUT,
                'ignoreLeaks': true,
                'reporter': 'spec',
                'grep': mocha_grep
            }
        };
        grunt.config.set('mocha-hack.' + module, config);
        grunt.task.run('mocha-hack:' + module);
    });

    // Runs the unit tests and dumps some coverage data
    grunt.registerTask('test-instrumented', function(report) {
        // If no report format was provided, we default to `lcov` which generates lcov and html
        report = report || 'lcov';

        // Get the modules that should be excluded
        var nonOaeModules = grunt.file.expand({'filter': 'isDirectory'}, 'node_modules/*', '!node_modules/oae-*');
        var nonOaeModulesParameters = _.map(nonOaeModules, function(module) {
            return util.format('-x %s/\\*\\*', module);
        });

        // Exclude the tests from the coverage reports
        var oaeModules = grunt.file.expand({'filter': 'isDirectory'}, 'node_modules/oae-*');
        var testDirectories = _.map(oaeModules, function(directory) {
            return util.format('-x %s/tests/\\*\\*', directory);
        });

        // Exclude the config directories
        var configDirectories = _.map(oaeModules, function(module) {
            return util.format('-x %s/config/\\*\\*', module);
        });

        // Build up one big set of exlusion filters
        var excludeFilters = _.union(nonOaeModulesParameters, testDirectories, configDirectories);
        excludeFilters.push('-x Gruntfile.js');

        var cmd = util.format('node_modules/.bin/istanbul cover --verbose --dir target --no-default-excludes %s --report %s ./node_modules/grunt-cli/bin/grunt', excludeFilters.join(' '), report);
        var code = shell.exec(cmd).code;
        if (code !== 0) {
            process.exit(code);
        }
    });

    // Sends a coverage report to coveralls.io
    grunt.registerTask('coveralls', function() {
        // This assumes we're executing within the context of Travis CI
        // If not, you'll have to add a .converalls.yml file with `repo_token: ...` in it
        shell.exec('cat ./target/lcov.info | ./node_modules/coveralls/bin/coveralls.js');
    });

    // Run test coverage and open the report
    grunt.registerTask('test-coverage', ['clean', 'test-instrumented', 'showFile:target/lcov-report/index.html']);

    // Run test coverage
    grunt.registerTask('test-coverage-coveralls', ['clean', 'test-instrumented:lcovonly', 'coveralls']);

    // Make a task to open the browser
    grunt.registerTask('showFile', 'Open a file with the OS default viewer', function(file) {
        var browser = shell.env['BROWSER'];
        if (! browser) {
            if (process.platform === 'linux') {
                browser = 'xdg-open';
            } else if (process.platform === 'darwin') {
                browser = 'open';
            } else if (process.platform === 'win32') {
                browser = 'explorer.exe';
            }
        }
        if (browser) {
            shell.exec(browser + ' '  + ( file || 'target/coverage.html' ));
        }
    });

    // Bring in tasks from npm
    // Temporary work around till https://github.com/yaymukund/grunt-simple-mocha/issues/16 lands.
    grunt.loadNpmTasks('grunt-mocha-hack');
    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks('grunt-text-replace');

    // Copies the files that need to go in the release.
    // We remove the test files and the Grunt file as it could be potentially
    // devestating to run the tests in a production environment.
    // Example:
    //     grunt release:/tmp/release
    // will copy only those files you really need in order to run Hilary in a folder at `/tmp/release`.
    grunt.registerTask('release', function(outputDir) {
        if (!outputDir) {
            return grunt.log.writeln('Please provide a path where the files should be copied to'.red);
        }

        shell.exec('bin/package -so ' + outputDir);
    });

    // Default task.
    grunt.registerTask('default', ['check-style', 'test']);

};
<|endoftext|>


<commit_before>module.exports = function(grunt) {
  var browsers = [{
    browserName: "chrome",
    platform: "OS X 10.8"
  }, {
    browserName: "chrome",
    platform: "XP"
  }, {
    browserName: "chrome",
    platform: "linux"
  }, {
    browserName: "firefox",
    version: "19",
    platform: "XP"
  }, {
    browserName: "safari",
    version: "6",
    platform: "OS X 10.8"
  }, {
    browserName: "opera",
    platform: "Windows 2008",
    version: "12"
// Tests pass on IE6, but a misc error is thrown. TODO: Sort out with SauceLabs
//  }, {
//    browserName: "internet explorer",
//    platform: "XP",
//    version: "6"
  }, {
    browserName: "internet explorer",
    platform: "XP",
    version: "7"
  }, {
    browserName: "internet explorer",
    platform: "XP",
    version: "8"
  }, {
    browserName: "internet explorer",
    platform: "VISTA",
    version: "9"
  }, {
    browserName: "internet explorer",
    platform: "WIN8",
    version: "10"
  }];

  grunt.initConfig({
    jasmine : {
      all: {
        src : 'src/**/*.js',
        options: {
          vendor: ['lib/jquery-1.10.2.js', 'lib/jasmine-jquery.js','lib/jquery.simulate.js'],
          helpers: ['spec/matchers.js','spec/helpers.js','spec/setup.js', 'spec/phantomjs-setup.js'],
          specs: 'spec/*Spec.js',
          styles: 'src/*.css',
          host: 'http://localhost:9999',

        }

      }
    },
    connect: {
      server: {
        options: {
          base: "",
          port: 9999
        }
      }
    },
    'saucelabs-custom': {
      all: {
        options: {
          urls: ["http://127.0.0.1:9999/#runner"],
          tunnelTimeout: 5,
          build: process.env.TRAVIS_JOB_ID,
          concurrency: 3,
          browsers: browsers,
          testname: "pasta tests",
          tags: ["master"]
        }
      }
    },
    watch: {}
  });

  // Loading dependencies
  for (var key in grunt.file.readJSON("package.json").devDependencies) {
    if (key !== "grunt" && key.indexOf("grunt") === 0) grunt.loadNpmTasks(key);
  }

  grunt.registerTask("dev", ["connect", "watch"]);
  grunt.registerTask("test-locally", ["connect", "jasmine"]);

  var secureEnvVars = process.env.TRAVIS_SECURE_ENV_VARS;
  if (secureEnvVars === undefined || secureEnvVars === "true") {
    grunt.registerTask("test", ["connect", "saucelabs-custom"]);
  } else {
    grunt.registerTask("test", ["test-locally"]);
  }
};
<commit_msg>use presence of saucelabs credentials as a way to detect the default way to run tests<commit_after>module.exports = function(grunt) {
  function isSauceLabsAvailableInEnvironment() {
    var sauceUser = process.env.SAUCE_USERNAME;
    var sauceKey = process.env.SAUCE_ACCESS_KEY;

    return !!sauceUser && !!sauceKey;
  }

  var browsers = [{
    browserName: "chrome",
    platform: "OS X 10.8"
  }, {
    browserName: "chrome",
    platform: "XP"
  }, {
    browserName: "chrome",
    platform: "linux"
  }, {
    browserName: "firefox",
    version: "19",
    platform: "XP"
  }, {
    browserName: "safari",
    version: "6",
    platform: "OS X 10.8"
  }, {
    browserName: "opera",
    platform: "Windows 2008",
    version: "12"
// Tests pass on IE6, but a misc error is thrown. TODO: Sort out with SauceLabs
//  }, {
//    browserName: "internet explorer",
//    platform: "XP",
//    version: "6"
  }, {
    browserName: "internet explorer",
    platform: "XP",
    version: "7"
  }, {
    browserName: "internet explorer",
    platform: "XP",
    version: "8"
  }, {
    browserName: "internet explorer",
    platform: "VISTA",
    version: "9"
  }, {
    browserName: "internet explorer",
    platform: "WIN8",
    version: "10"
  }];

  grunt.initConfig({
    jasmine : {
      all: {
        src : 'src/**/*.js',
        options: {
          vendor: ['lib/jquery-1.10.2.js', 'lib/jasmine-jquery.js','lib/jquery.simulate.js'],
          helpers: ['spec/matchers.js','spec/helpers.js','spec/setup.js', 'spec/phantomjs-setup.js'],
          specs: 'spec/*Spec.js',
          styles: 'src/*.css',
          host: 'http://localhost:9999',
        }
      }
    },
    connect: {
      server: {
        options: {
          base: "",
          port: 9999
        }
      }
    },
    'saucelabs-custom': {
      all: {
        options: {
          urls: ["http://127.0.0.1:9999/#runner"],
          tunnelTimeout: 5,
          build: process.env.TRAVIS_JOB_ID,
          concurrency: 3,
          browsers: browsers,
          testname: "pasta tests",
          tags: ["master"]
        }
      }
    },
    watch: {}
  });

  // Loading dependencies
  for (var key in grunt.file.readJSON("package.json").devDependencies) {
    if (key !== "grunt" && key.indexOf("grunt") === 0) grunt.loadNpmTasks(key);
  }

  grunt.registerTask("dev", ["connect", "watch"]);

  grunt.registerTask("test-phantomjs", ["connect", "jasmine"]);
  grunt.registerTask("test-saucelabs", ["connect", "saucelabs-custom"]);

  if (isSauceLabsAvailableInEnvironment()) {
    grunt.registerTask("test", ["test-saucelabs"]);
  } else {
    grunt.registerTask("test", ["test-phantomjs"]);
  }
};
<|endoftext|>


<commit_before>// Generated using generator-angular
'use strict';

const sass = require('node-sass');

module.exports = function(grunt) {
  /*jshint camelcase: false */

  // Load grunt tasks automatically
  require('load-grunt-tasks')(grunt);
  require('grunt-connect-proxy')(grunt);

  // Time how long tasks take. Can help when optimizing build times
  require('time-grunt')(grunt);

  var serveStatic = require('serve-static');

  //TODO Mandantenfähigkeit fehlt (siehe var config = ...)
  var env = 'dev';
  if (grunt.option('env') !== null && grunt.option('env') !== undefined) {
    env = grunt.option('env');
  }

  var config = {
    BUILD_NR: grunt.option('buildnr') || 'dev',
  };

  // Define the configuration for all the tasks
  grunt.initConfig({
    // Project settings
    openolitor: {
      // configurable paths
      app: require('./bower.json').appPath || 'app',
      dist: 'dist'
    },

    // task used to replace config values in js files
    replace: {
      options: {
        patterns: [{
          json: config
        }]
      },
      dev: {
        files: [{
          expand: true,
          flatten: true,
          src: ['<%= openolitor.app %>/scripts/app.js'],
          dest: '.tmp/scripts'
        }]
      },
      prod: {
        files: [{
          expand: true,
          flatten: true,
          src: ['.tmp/concat/scripts/scripts.js'],
          dest: '.tmp/concat/scripts'
        }]
      },
      index: {
        files: [{
          expand: true,
          flatten: true,
          src: ['<%= openolitor.dist %>/index.html'],
          dest: '<%= openolitor.dist %>'
        }]
      },
    },

    // Watches files for changes and runs tasks based on the changed files
    watch: {
      bower: {
        files: ['bower.json'],
        tasks: ['wiredep']
      },
      js: {
        files: [
          '<%= openolitor.app %>/scripts/**/*.js',
          '<%= openolitor.app %>/bower_components/openolitor-core/scripts/**/*.js'
        ],
        tasks: ['newer:jshint:all', 'replace:dev'],
        options: {
          livereload: '<%= connect.options.livereload %>'
        }
      },
      jsTest: {
        files: ['test/spec/{,*/}*.js'],
        tasks: ['newer:jshint:test', 'karma']
      },
      sass: {
        files: ['<%= openolitor.app %>/styles/**/*.{scss,sass}'],
        tasks: ['sass:server', 'autoprefixer']
      },
      gruntfile: {
        files: ['Gruntfile.js']
      },
      livereload: {
        options: {
          livereload: '<%= connect.options.livereload %>'
        },
        files: [
          '<%= openolitor.app %>/scripts/**/*.html',
          '<%= openolitor.app %>/index.html',
          '.tmp/styles/**/*.css',
          '<%= openolitor.app %>/images/**/*.{png,jpg,jpeg,gif,webp,svg}'
        ]
      }
    },

    // The actual grunt server settings
    connect: {
      proxies: [
        {
          context: '/api-',
          host: 'localhost',
          port: 9003,
          https: false,
          xforward: false,
          ws: true,
          rewrite: {
            '^/api-(.*)$': '/$1',
            '^/api-(.*/ws)$': '/$1'
          }
        }
      ],
      options: {
        port: 9001,
        // Change this to '0.0.0.0' to access the server from outside.
        hostname: '0.0.0.0',
        livereload: 35729
      },
      livereload: {
        options: {
          open: true,
          base: ['.tmp', '<%= openolitor.app %>'],
          middleware: function (connect, options) {
              if (!Array.isArray(options.base)) {
                  options.base = [options.base];
              }

              // Setup the proxy
              var middlewares = [require('grunt-connect-proxy/lib/utils').proxyRequest];

              // Serve static files.
              options.base.forEach(function(base) {
                  middlewares.push(serveStatic(base));
              });

              return middlewares;
          }
        }
      },
      test: {
        options: {
          port: 9001,
          base: ['.tmp', 'test', '<%= openolitor.app %>']
        }
      },
      dist: {
        options: {
          base: '<%= openolitor.dist %>'
        }
      }
    },

    // Make sure code styles are up to par and there are no obvious mistakes
    jshint: {
      options: {
        jshintrc: '.jshintrc',
        reporter: require('jshint-stylish')
      },
      all: [
        'Gruntfile.js',
        '<%= openolitor.app %>/scripts/{,*/}*.js',
        '!<%= openolitor.app %>/scripts/i18n/translations.js'
      ],
      test: {
        options: {
          jshintrc: 'test/.jshintrc'
        },
        src: ['test/spec/{,*/}*.js']
      }
    },

    // Empties folders to start fresh
    clean: {
      dist: {
        files: [{
          dot: true,
          src: [
            '.tmp',
            '<%= openolitor.dist %>/*',
            '!<%= openolitor.dist %>/.git*',
            '!<%= openolitor.dist %>/index.php'
          ]
        }]
      },
      server: '.tmp'
    },

    // Add vendor prefixed styles
    autoprefixer: {
      options: {
        browsers: ['last 1 version']
      },
      dist: {
        files: [{
          expand: true,
          cwd: '.tmp/styles/',
          src: '**/*.css',
          dest: '.tmp/styles/'
        }]
      }
    },

    // Automatically inject Bower components into the app
    wiredep: {
      options: {
        //        cwd: '<%= openolitor.app %>'
      },
      app: {
        src: ['<%= openolitor.app %>/index.html'],
        exclude: ['bower_components/bootstrap-sass-official/*'],
        ignorePath: '<%= openolitor.app %>/'
      },
      sass: {
        src: ['<%= openolitor.app %>/styles/**/*.{scss,sass}'],
        ignorePath: '<%= openolitor.app %>/bower_components/'
      }
    },

    // Compiles Sass to CSS and generates necessary files if requested
    sass: {
      options: {
        implementation: sass,
        sourceMap: true,
        includePaths: ['app/bower_components']
      },
      dist: {
        files: [{
          expand: true,
          cwd: '<%= openolitor.app %>/styles',
          src: ['*.scss'],
          dest: '.tmp/styles',
          ext: '.css'
        }]
      },
      server: {
        files: [{
          expand: true,
          cwd: '<%= openolitor.app %>/styles',
          src: ['*.scss'],
          dest: '.tmp/styles',
          ext: '.css'
        }]
      }
    },

    uglify: {
      options: {
        exceptionsFiles: [ 'uglifyExceptions.json' ]
      }
    },

    // Renames files for browser caching purposes
    rev: {
      dist: {
        files: {
          src: [
            '<%= openolitor.dist %>/scripts/**/*.js',
            '<%= openolitor.dist %>/styles/**/*.css',
            '<%= openolitor.dist %>/images/**/*.{png,jpg,jpeg,gif,webp,svg}',
            '<%= openolitor.dist %>/styles/fonts/**/*',
          ]
        }
      }
    },

    // Reads HTML for usemin blocks to enable smart builds that automatically
    // concat, minify and revision files. Creates configurations in memory so
    // additional tasks can operate on them
    useminPrepare: {
      html: '<%= openolitor.app %>/index.html',
      options: {
        dest: '<%= openolitor.dist %>',
        flow: {
          html: {
            steps: {
              js: ['concat', 'uglifyjs'],
              css: ['cssmin']
            },
            post: {}
          }
        }
      }
    },

    // Performs rewrites based on filerev and the useminPrepare configuration
    usemin: {
      html: ['<%= openolitor.dist %>/**/*.html'],
      css: ['<%= openolitor.dist %>/styles/**/*.css'],
      options: {
        assetsDirs: ['<%= openolitor.dist %>', '<%= openolitor.dist %>/images']
      }
    },

    // The following *-min tasks produce minified files in the dist folder
    cssmin: {
      options: {
        root: '<%= openolitor.app %>'
      }
    },

    imagemin: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= openolitor.app %>/images',
          src: '**/*.{jpg,jpeg,gif}', // png doesn't work on buildserver
          dest: '<%= openolitor.dist %>/images'
        }]
      }
    },

    svgmin: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= openolitor.app %>/images',
          src: '{,*/}*.svg',
          dest: '<%= openolitor.dist %>/images'
        }]
      }
    },

    htmlmin: {
      dist: {
        options: {
          collapseWhitespace: true,
          conservativeCollapse: true,
          collapseBooleanAttributes: false,
          removeCommentsFromCDATA: true,
          removeOptionalTags: true
        },
        files: [{
          expand: true,
          cwd: '<%= openolitor.dist %>',
          src: ['*.html', 'scripts/**/*.html'],
          dest: '<%= openolitor.dist %>'
        }]
      }
    },

    // ngAnnotate tries to make the code safe for minification automatically by
    // using the Angular long form for dependency injection. It doesn't work on
    // things like resolve or inject so those have to be done manually.
    ngAnnotate: {
      dist: {
        files: [{
          expand: true,
          cwd: '.tmp/concat/scripts',
          src: '*.js',
          dest: '.tmp/concat/scripts'
        }]
      }
    },

    // Copies remaining files to places other tasks can use
    copy: {
      dist: {
        files: [{
            expand: true,
            dot: true,
            cwd: '<%= openolitor.app %>',
            dest: '<%= openolitor.dist %>',
            src: [
              '*.{ico,png,txt}',
              '.htaccess',
              '*.html',
              'scripts/**/*.html',
              'images/**/*.{webp,png,jpg}',
              'fonts/**/*'
            ]
          },
          {
            expand: true,
            cwd: '<%= openolitor.app %>',
            dest: '<%= openolitor.dist %>',
            src: ['environments/*']
          },
          {
            expand: true,
            cwd: '.',
            dest: '<%= openolitor.dist %>',
            src: ['nginx.conf']
          },
          {
            expand: true,
            cwd: '.tmp/images',
            dest: '<%= openolitor.dist %>/images',
            src: ['generated/*']
          },
          {
            //for bootstrap fonts, maybe we could use the scss/less where the correct font url path will be inserted
            expand: true,
            dot: true,
            cwd: '<%= openolitor.app %>/bower_components/bootstrap/dist',
            src: ['fonts/*.*'],
            dest: '<%= openolitor.dist %>'
          },
          {
            //for font-awesome
            expand: true,
            dot: true,
            cwd: '<%= openolitor.app %>/bower_components/font-awsome',
            src: ['fonts/*.*'],
            dest: '<%= openolitor.dist %>'
          }
        ]
      },
      styles: {
        expand: true,
        cwd: '<%= openolitor.app %>/styles',
        dest: '.tmp/styles/',
        src: '**/*.css'
      }
    },

    // Run some tasks in parallel to speed up the build process
    concurrent: {
      server: ['sass:server', 'copy:styles'],
      test: ['copy:styles'],
      dist: ['sass', 'copy:styles', 'imagemin', 'svgmin']
    },

    // Test settings
    karma: {
      unit: {
        configFile: 'test/karma.conf.js',
        singleRun: true
      },
      live: {
        configFile: 'test/karma.conf.js',
        singleRun: false,
        autoWatch: true
      },
      continuous: {
        configFile: 'test/karma.conf.js',
        singleRun: 'true',
        browsers: ['PhantomJS'],
        reporters: ['dots', 'junit', 'coverage'],
        junitReporter: {
          outputFile: 'test/test-results.xml'
        },
        coverageReporter: {
          reporters: [{
              type: 'lcov',
              dir: 'test/coverage/reports'
            },
            {
              type: 'text',
              dir: 'test/coverage/reports'
            }
          ]
        },
        preprocessors: {
          // source files, that you wanna generate coverage for
          // do not include tests or libraries
          // (these files will be instrumented by Istanbul)
          'app/scripts/**/*.js': ['coverage'],
          'app/scripts/**/*.html': ['ng-html2js']
        }
      }
    },

    protractor: {
      options: {
        configFile: 'test/protractor.conf.js', // Default config file
        keepAlive: true, // If false, the grunt process stops when the test fails.
        noColor: false, // If true, protractor will not use colors in its output.
        args: {
          // Arguments passed to the command
        }
      },
      all: {} // Grunt requires at least one target to run so you can simply put 'all: {}' here too.
    },

    protractor_webdriver: {
      default: {
        options: {
          command: 'custom-webdriver-manager start --standalone'
        }
      }
    },

    // i18n
    nggettext_extract: {
      pot: {
        files: {
          'i18n/template.pot': [
            '<%= openolitor.app %>/**/*.html',
            '<%= openolitor.app %>/**/*.js',
            '!<%= openolitor.app %>/bower_components/**'
          ]
        }
      }
    },

    nggettext_compile: {
      all: {
        files: {
          '<%= openolitor.app %>/scripts/i18n/translations.js': ['i18n/*/*.po']
        }
      }
    }
  });

  grunt.registerTask('serve', function(target) {
    if (target === 'dist') {
      return grunt.task.run(['build', 'connect:dist:keepalive']);
    }

    grunt.task.run([
      'clean:server',
      'wiredep',
      'concurrent:server',
      'autoprefixer',
      'configureProxies:server',
      'connect:livereload',
      'replace:dev',
      'watch'
    ]);
  });

  grunt.registerTask('server', function(target) {
    grunt.log.warn(
      'The `server` task has been deprecated. Use `grunt serve` to start a server.'
    );
    grunt.task.run(['serve:' + target]);
  });

  grunt.registerTask('core-test', [
    'newer:jshint',
    'clean:server',
    'concurrent:test',
    'autoprefixer',
    'connect:test'
  ]);

  grunt.registerTask('test', ['core-test', 'karma:unit']);

  grunt.registerTask('~test', ['core-test', 'karma:live']);

  grunt.registerTask('citest', ['clean', 'core-test', 'karma:continuous']);

  grunt.registerTask('build', [
    'clean:dist',
    'wiredep',
    'useminPrepare',
    'concurrent:dist',
    'autoprefixer',
    'concat',
    'replace:prod',
    'ngAnnotate',
    'copy:dist',
    'cssmin',
    'uglify',
    'rev',
    'usemin',
    'htmlmin',
    'replace:index'
  ]);

  grunt.registerTask('i18nextract', ['nggettext_extract']);

  grunt.registerTask('default', ['citest', 'build']);
};
<commit_msg>added third_party again<commit_after>// Generated using generator-angular
'use strict';

const sass = require('node-sass');

module.exports = function(grunt) {
  /*jshint camelcase: false */

  // Load grunt tasks automatically
  require('load-grunt-tasks')(grunt);
  require('grunt-connect-proxy')(grunt);

  // Time how long tasks take. Can help when optimizing build times
  require('time-grunt')(grunt);

  var serveStatic = require('serve-static');

  //TODO Mandantenfähigkeit fehlt (siehe var config = ...)
  var env = 'dev';
  if (grunt.option('env') !== null && grunt.option('env') !== undefined) {
    env = grunt.option('env');
  }

  var config = {
    BUILD_NR: grunt.option('buildnr') || 'dev',
  };

  // Define the configuration for all the tasks
  grunt.initConfig({
    // Project settings
    openolitor: {
      // configurable paths
      app: require('./bower.json').appPath || 'app',
      dist: 'dist'
    },

    // task used to replace config values in js files
    replace: {
      options: {
        patterns: [{
          json: config
        }]
      },
      dev: {
        files: [{
          expand: true,
          flatten: true,
          src: ['<%= openolitor.app %>/scripts/app.js'],
          dest: '.tmp/scripts'
        }]
      },
      prod: {
        files: [{
          expand: true,
          flatten: true,
          src: ['.tmp/concat/scripts/scripts.js'],
          dest: '.tmp/concat/scripts'
        }]
      },
      index: {
        files: [{
          expand: true,
          flatten: true,
          src: ['<%= openolitor.dist %>/index.html'],
          dest: '<%= openolitor.dist %>'
        }]
      },
    },

    // Watches files for changes and runs tasks based on the changed files
    watch: {
      bower: {
        files: ['bower.json'],
        tasks: ['wiredep']
      },
      js: {
        files: [
          '<%= openolitor.app %>/scripts/**/*.js',
          '<%= openolitor.app %>/bower_components/openolitor-core/scripts/**/*.js'
        ],
        tasks: ['newer:jshint:all', 'replace:dev'],
        options: {
          livereload: '<%= connect.options.livereload %>'
        }
      },
      jsTest: {
        files: ['test/spec/{,*/}*.js'],
        tasks: ['newer:jshint:test', 'karma']
      },
      sass: {
        files: ['<%= openolitor.app %>/styles/**/*.{scss,sass}'],
        tasks: ['sass:server', 'autoprefixer']
      },
      gruntfile: {
        files: ['Gruntfile.js']
      },
      livereload: {
        options: {
          livereload: '<%= connect.options.livereload %>'
        },
        files: [
          '<%= openolitor.app %>/scripts/**/*.html',
          '<%= openolitor.app %>/index.html',
          '.tmp/styles/**/*.css',
          '<%= openolitor.app %>/images/**/*.{png,jpg,jpeg,gif,webp,svg}'
        ]
      }
    },

    // The actual grunt server settings
    connect: {
      proxies: [
        {
          context: '/api-',
          host: 'localhost',
          port: 9003,
          https: false,
          xforward: false,
          ws: true,
          rewrite: {
            '^/api-(.*)$': '/$1',
            '^/api-(.*/ws)$': '/$1'
          }
        }
      ],
      options: {
        port: 9001,
        // Change this to '0.0.0.0' to access the server from outside.
        hostname: '0.0.0.0',
        livereload: 35729
      },
      livereload: {
        options: {
          open: true,
          base: ['.tmp', '<%= openolitor.app %>'],
          middleware: function (connect, options) {
              if (!Array.isArray(options.base)) {
                  options.base = [options.base];
              }

              // Setup the proxy
              var middlewares = [require('grunt-connect-proxy/lib/utils').proxyRequest];

              // Serve static files.
              options.base.forEach(function(base) {
                  middlewares.push(serveStatic(base));
              });

              return middlewares;
          }
        }
      },
      test: {
        options: {
          port: 9001,
          base: ['.tmp', 'test', '<%= openolitor.app %>']
        }
      },
      dist: {
        options: {
          base: '<%= openolitor.dist %>'
        }
      }
    },

    // Make sure code styles are up to par and there are no obvious mistakes
    jshint: {
      options: {
        jshintrc: '.jshintrc',
        reporter: require('jshint-stylish')
      },
      all: [
        'Gruntfile.js',
        '<%= openolitor.app %>/scripts/{,*/}*.js',
        '!<%= openolitor.app %>/scripts/i18n/translations.js'
      ],
      test: {
        options: {
          jshintrc: 'test/.jshintrc'
        },
        src: ['test/spec/{,*/}*.js']
      }
    },

    // Empties folders to start fresh
    clean: {
      dist: {
        files: [{
          dot: true,
          src: [
            '.tmp',
            '<%= openolitor.dist %>/*',
            '!<%= openolitor.dist %>/.git*',
            '!<%= openolitor.dist %>/index.php'
          ]
        }]
      },
      server: '.tmp'
    },

    // Add vendor prefixed styles
    autoprefixer: {
      options: {
        browsers: ['last 1 version']
      },
      dist: {
        files: [{
          expand: true,
          cwd: '.tmp/styles/',
          src: '**/*.css',
          dest: '.tmp/styles/'
        }]
      }
    },

    // Automatically inject Bower components into the app
    wiredep: {
      options: {
        //        cwd: '<%= openolitor.app %>'
      },
      app: {
        src: ['<%= openolitor.app %>/index.html'],
        exclude: ['bower_components/bootstrap-sass-official/*'],
        ignorePath: '<%= openolitor.app %>/'
      },
      sass: {
        src: ['<%= openolitor.app %>/styles/**/*.{scss,sass}'],
        ignorePath: '<%= openolitor.app %>/bower_components/'
      }
    },

    // Compiles Sass to CSS and generates necessary files if requested
    sass: {
      options: {
        implementation: sass,
        sourceMap: true,
        includePaths: ['app/bower_components']
      },
      dist: {
        files: [{
          expand: true,
          cwd: '<%= openolitor.app %>/styles',
          src: ['*.scss'],
          dest: '.tmp/styles',
          ext: '.css'
        }]
      },
      server: {
        files: [{
          expand: true,
          cwd: '<%= openolitor.app %>/styles',
          src: ['*.scss'],
          dest: '.tmp/styles',
          ext: '.css'
        }]
      }
    },

    uglify: {
      options: {
        exceptionsFiles: [ 'uglifyExceptions.json' ]
      }
    },

    // Renames files for browser caching purposes
    rev: {
      dist: {
        files: {
          src: [
            '<%= openolitor.dist %>/scripts/**/*.js',
            '<%= openolitor.dist %>/styles/**/*.css',
            '<%= openolitor.dist %>/images/**/*.{png,jpg,jpeg,gif,webp,svg}',
            '<%= openolitor.dist %>/styles/fonts/**/*',
          ]
        }
      }
    },

    // Reads HTML for usemin blocks to enable smart builds that automatically
    // concat, minify and revision files. Creates configurations in memory so
    // additional tasks can operate on them
    useminPrepare: {
      html: '<%= openolitor.app %>/index.html',
      options: {
        dest: '<%= openolitor.dist %>',
        flow: {
          html: {
            steps: {
              js: ['concat', 'uglifyjs'],
              css: ['cssmin']
            },
            post: {}
          }
        }
      }
    },

    // Performs rewrites based on filerev and the useminPrepare configuration
    usemin: {
      html: ['<%= openolitor.dist %>/**/*.html'],
      css: ['<%= openolitor.dist %>/styles/**/*.css'],
      options: {
        assetsDirs: ['<%= openolitor.dist %>', '<%= openolitor.dist %>/images']
      }
    },

    // The following *-min tasks produce minified files in the dist folder
    cssmin: {
      options: {
        root: '<%= openolitor.app %>'
      }
    },

    imagemin: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= openolitor.app %>/images',
          src: '**/*.{jpg,jpeg,gif}', // png doesn't work on buildserver
          dest: '<%= openolitor.dist %>/images'
        }]
      }
    },

    svgmin: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= openolitor.app %>/images',
          src: '{,*/}*.svg',
          dest: '<%= openolitor.dist %>/images'
        }]
      }
    },

    htmlmin: {
      dist: {
        options: {
          collapseWhitespace: true,
          conservativeCollapse: true,
          collapseBooleanAttributes: false,
          removeCommentsFromCDATA: true,
          removeOptionalTags: true
        },
        files: [{
          expand: true,
          cwd: '<%= openolitor.dist %>',
          src: ['*.html', 'scripts/**/*.html'],
          dest: '<%= openolitor.dist %>'
        }]
      }
    },

    // ngAnnotate tries to make the code safe for minification automatically by
    // using the Angular long form for dependency injection. It doesn't work on
    // things like resolve or inject so those have to be done manually.
    ngAnnotate: {
      dist: {
        files: [{
          expand: true,
          cwd: '.tmp/concat/scripts',
          src: '*.js',
          dest: '.tmp/concat/scripts'
        }]
      }
    },

    // Copies remaining files to places other tasks can use
    copy: {
      dist: {
        files: [{
            expand: true,
            dot: true,
            cwd: '<%= openolitor.app %>',
            dest: '<%= openolitor.dist %>',
            src: [
              '*.{ico,png,txt}',
              '.htaccess',
              '*.html',
              'scripts/**/*.html',
              'images/**/*.{webp,png,jpg}',
              'third_party/**',
              'fonts/**/*'
            ]
          },
          {
            expand: true,
            cwd: '<%= openolitor.app %>',
            dest: '<%= openolitor.dist %>',
            src: ['environments/*']
          },
          {
            expand: true,
            cwd: '.',
            dest: '<%= openolitor.dist %>',
            src: ['nginx.conf']
          },
          {
            expand: true,
            cwd: '.tmp/images',
            dest: '<%= openolitor.dist %>/images',
            src: ['generated/*']
          },
          {
            //for bootstrap fonts, maybe we could use the scss/less where the correct font url path will be inserted
            expand: true,
            dot: true,
            cwd: '<%= openolitor.app %>/bower_components/bootstrap/dist',
            src: ['fonts/*.*'],
            dest: '<%= openolitor.dist %>'
          },
          {
            //for font-awesome
            expand: true,
            dot: true,
            cwd: '<%= openolitor.app %>/bower_components/font-awsome',
            src: ['fonts/*.*'],
            dest: '<%= openolitor.dist %>'
          }
        ]
      },
      styles: {
        expand: true,
        cwd: '<%= openolitor.app %>/styles',
        dest: '.tmp/styles/',
        src: '**/*.css'
      }
    },

    // Run some tasks in parallel to speed up the build process
    concurrent: {
      server: ['sass:server', 'copy:styles'],
      test: ['copy:styles'],
      dist: ['sass', 'copy:styles', 'imagemin', 'svgmin']
    },

    // Test settings
    karma: {
      unit: {
        configFile: 'test/karma.conf.js',
        singleRun: true
      },
      live: {
        configFile: 'test/karma.conf.js',
        singleRun: false,
        autoWatch: true
      },
      continuous: {
        configFile: 'test/karma.conf.js',
        singleRun: 'true',
        browsers: ['PhantomJS'],
        reporters: ['dots', 'junit', 'coverage'],
        junitReporter: {
          outputFile: 'test/test-results.xml'
        },
        coverageReporter: {
          reporters: [{
              type: 'lcov',
              dir: 'test/coverage/reports'
            },
            {
              type: 'text',
              dir: 'test/coverage/reports'
            }
          ]
        },
        preprocessors: {
          // source files, that you wanna generate coverage for
          // do not include tests or libraries
          // (these files will be instrumented by Istanbul)
          'app/scripts/**/*.js': ['coverage'],
          'app/scripts/**/*.html': ['ng-html2js']
        }
      }
    },

    protractor: {
      options: {
        configFile: 'test/protractor.conf.js', // Default config file
        keepAlive: true, // If false, the grunt process stops when the test fails.
        noColor: false, // If true, protractor will not use colors in its output.
        args: {
          // Arguments passed to the command
        }
      },
      all: {} // Grunt requires at least one target to run so you can simply put 'all: {}' here too.
    },

    protractor_webdriver: {
      default: {
        options: {
          command: 'custom-webdriver-manager start --standalone'
        }
      }
    },

    // i18n
    nggettext_extract: {
      pot: {
        files: {
          'i18n/template.pot': [
            '<%= openolitor.app %>/**/*.html',
            '<%= openolitor.app %>/**/*.js',
            '!<%= openolitor.app %>/bower_components/**'
          ]
        }
      }
    },

    nggettext_compile: {
      all: {
        files: {
          '<%= openolitor.app %>/scripts/i18n/translations.js': ['i18n/*/*.po']
        }
      }
    }
  });

  grunt.registerTask('serve', function(target) {
    if (target === 'dist') {
      return grunt.task.run(['build', 'connect:dist:keepalive']);
    }

    grunt.task.run([
      'clean:server',
      'wiredep',
      'concurrent:server',
      'autoprefixer',
      'configureProxies:server',
      'connect:livereload',
      'replace:dev',
      'watch'
    ]);
  });

  grunt.registerTask('server', function(target) {
    grunt.log.warn(
      'The `server` task has been deprecated. Use `grunt serve` to start a server.'
    );
    grunt.task.run(['serve:' + target]);
  });

  grunt.registerTask('core-test', [
    'newer:jshint',
    'clean:server',
    'concurrent:test',
    'autoprefixer',
    'connect:test'
  ]);

  grunt.registerTask('test', ['core-test', 'karma:unit']);

  grunt.registerTask('~test', ['core-test', 'karma:live']);

  grunt.registerTask('citest', ['clean', 'core-test', 'karma:continuous']);

  grunt.registerTask('build', [
    'clean:dist',
    'wiredep',
    'useminPrepare',
    'concurrent:dist',
    'autoprefixer',
    'concat',
    'replace:prod',
    'ngAnnotate',
    'copy:dist',
    'cssmin',
    'uglify',
    'rev',
    'usemin',
    'htmlmin',
    'replace:index'
  ]);

  grunt.registerTask('i18nextract', ['nggettext_extract']);

  grunt.registerTask('default', ['citest', 'build']);
};
<|endoftext|>


<commit_before>/**
 * @file pokemon command
 * @author Sankarsan Kampa (a.k.a k3rn31p4nic)
 * @license MIT
 */

const Pokedex = require('pokedex-api');
const pokedex = new Pokedex({
  userAgent: 'Bastion: Discord Bot (https://bastionbot.org)',
  version: 'v1'
});

exports.exec = async (Bastion, message, args) => {
  try {
    let pokemon;
    if (args.name) {
      pokemon = await pokedex.getPokemonByName(encodeURIComponent(args.name.join(' ')));
    }
    else if (args.number) {
      pokemon = await pokedex.getPokemonByNumber(args.number);
    }
    else {
      /**
      * The command was ran with invalid parameters.
      * @fires commandUsage
      */
      return Bastion.emit('commandUsage', message, this.help);
    }

    pokemon = pokemon[0];

    let fields = [
      {
        name: 'Number',
        value: pokemon.number,
        inline: true
      },
      {
        name: 'Species',
        value: pokemon.species,
        inline: true
      },
      {
        name: 'Types',
        value: pokemon.types.join('\n'),
        inline: true
      },
      {
        name: 'Abilities',
        value: `Normal: ${pokemon.abilities.normal.join(', ') || '-'}\nHidden: ${pokemon.abilities.hidden.join(', ') || '-'}`,
        inline: true
      },
      {
        name: 'Egg Groups',
        value: pokemon.eggGroups.join('\n'),
        inline: true
      },
      {
        name: 'Gender Ratio',
        value: pokemon.gender.length ? `${pokemon.gender[0]}:${pokemon.gender[1]}` : 'Genderless',
        inline: true
      },
      {
        name: 'Height',
        value: pokemon.height,
        inline: true
      },
      {
        name: 'Weight',
        value: pokemon.weight,
        inline: true
      },
      {
        name: 'Evolution Line',
        value: pokemon.family.evolutionLine.join(' -> ')
      }
    ];

    let note = '';
    if (pokemon.starter) {
      note = note.concat('Is a starter pokemon\n');
    }
    if (pokemon.legendary) {
      note = note.concat('Is a legendary pokemon\n');
    }
    if (pokemon.mythical) {
      note = note.concat('Is a mythical pokemon\n');
    }
    if (pokemon.ultraBeast) {
      note = note.concat('Is an ultra beast\n');
    }
    if (pokemon.mega) {
      note = note.concat('Can mega evolve\n');
    }

    fields.push({
      name: 'Notes',
      value: note.length ? note : '-'
    });

    message.channel.send({
      embed: {
        color: Bastion.colors.BLUE,
        title: pokemon.name,
        description: `Discovered in generation ${pokemon.gen}`,
        fields: fields,
        thumbnail: {
          url: pokemon.sprite
        },
        footer: {
          icon_url: 'https://pokedevs.bastionbot.org/favicon.png',
          text: 'Powered by Pokedex API by PokéDevs'
        }
      }
    }).catch(e => {
      Bastion.log.error(e);
    });
  }
  catch (e) {
    if (e.response) {
      return Bastion.emit('error', e.response.statusCode, e.response.statusMessage, message.channel);
    }
    Bastion.log.error(e);
  }
};

exports.config = {
  aliases: [],
  enabled: true,
  argsDefinitions: [
    { name: 'name', type: String, multiple: true, defaultOption: true },
    { name: 'number', type: Number, alias: 'n' }
  ]
};

exports.help = {
  name: 'pokemon',
  botPermission: '',
  userTextPermission: '',
  userVoicePermission: '',
  usage: 'pokemon < POKEMON NAME | -n POKEDEX_NUMBER >',
  example: [ 'pokemon Pikachu', 'pokemon -n 658' ]
};
<commit_msg>modules: backport pokemon command<commit_after>/**
 * @file pokemon command
 * @author Sankarsan Kampa (a.k.a k3rn31p4nic)
 * @license MIT
 */

const Pokedex = require('pokedex-api');
const pokedex = new Pokedex({
  userAgent: 'Bastion: Discord Bot (https://bastionbot.org)',
  version: 'v1'
});

exports.exec = async (Bastion, message, args) => {
  try {
    let pokemon;
    if (args.name) {
      pokemon = await pokedex.getPokemonByName(encodeURIComponent(args.name.join(' ')));
    }
    else if (args.number) {
      pokemon = await pokedex.getPokemonByNumber(args.number);
    }
    else {
      /**
      * The command was ran with invalid parameters.
      * @fires commandUsage
      */
      return Bastion.emit('commandUsage', message, this.help);
    }

    pokemon = pokemon[0];

    let fields = [
      {
        name: 'Number',
        value: pokemon.number,
        inline: true
      },
      {
        name: 'Species',
        value: pokemon.species,
        inline: true
      },
      {
        name: 'Types',
        value: pokemon.types.join('\n'),
        inline: true
      },
      {
        name: 'Abilities',
        value: `Normal: ${pokemon.abilities.normal.join(', ') || '-'}\nHidden: ${pokemon.abilities.hidden.join(', ') || '-'}`,
        inline: true
      },
      {
        name: 'Egg Groups',
        value: pokemon.eggGroups.join('\n'),
        inline: true
      },
      {
        name: 'Gender Ratio',
        value: pokemon.gender.length ? `${pokemon.gender[0]}:${pokemon.gender[1]}` : 'Genderless',
        inline: true
      },
      {
        name: 'Height',
        value: pokemon.height,
        inline: true
      },
      {
        name: 'Weight',
        value: pokemon.weight,
        inline: true
      },
      {
        name: 'Evolution Line',
        value: pokemon.family.evolutionLine.join(' -> ')
      },
      {
        name: 'Description',
        value: pokemon.description
      }
    ];

    let note = '';
    if (pokemon.starter) {
      note = note.concat('Is a starter pokemon\n');
    }
    if (pokemon.legendary) {
      note = note.concat('Is a legendary pokemon\n');
    }
    if (pokemon.mythical) {
      note = note.concat('Is a mythical pokemon\n');
    }
    if (pokemon.ultraBeast) {
      note = note.concat('Is an ultra beast\n');
    }
    if (pokemon.mega) {
      note = note.concat('Can mega evolve\n');
    }

    fields.push({
      name: 'Notes',
      value: note.length ? note : '-'
    });

    message.channel.send({
      embed: {
        color: Bastion.colors.BLUE,
        title: pokemon.name,
        description: `Discovered in generation ${pokemon.gen}`,
        fields: fields,
        thumbnail: {
          url: pokemon.sprite
        },
        footer: {
          icon_url: 'https://pokedevs.bastionbot.org/favicon.png',
          text: 'Powered by Pokedex API by PokéDevs'
        }
      }
    }).catch(e => {
      Bastion.log.error(e);
    });
  }
  catch (e) {
    if (e.response) {
      return Bastion.emit('error', e.response.statusCode, e.response.statusMessage, message.channel);
    }
    Bastion.log.error(e);
  }
};

exports.config = {
  aliases: [],
  enabled: true,
  argsDefinitions: [
    { name: 'name', type: String, multiple: true, defaultOption: true },
    { name: 'number', type: Number, alias: 'n' }
  ]
};

exports.help = {
  name: 'pokemon',
  botPermission: '',
  userTextPermission: '',
  userVoicePermission: '',
  usage: 'pokemon < POKEMON NAME | -n POKEDEX_NUMBER >',
  example: [ 'pokemon Pikachu', 'pokemon -n 658' ]
};
<|endoftext|>


<commit_before>/*
 * grunt-gconfig
 * https://github.com/goliatone/grunt-gconfig
 *
 * Copyright (c) 2014 goliatone
 * Licensed under the MIT license.
 */

'use strict';

module.exports = function(grunt) {

    // Project configuration.
    grunt.initConfig({
        jshint: {
            all: [
                'Gruntfile.js',
                'tasks/*.js',
                '<%= nodeunit.tests %>',
            ],
            options: {
                jshintrc: '.jshintrc',
            },
        },

        // Before generating any new files, remove any previously-created files.
        clean: {
            tests: ['tmp'],
        },

        // Configuration to be run (and then tested).
        gconfig: {
            dev:{
                // src:['app/*.html'],
                files: [
                    {
                        expand: true,     // Enable dynamic expansion.
                        cwd: 'test/fixtures',      // Src matches are relative to this path.
                        src: ['index.dev.html'], // Actual pattern(s) to match.
                        dest: 'tmp',   // Destination path prefix.
                        // ext: '.min.html',   // Dest filepaths will have this extension.
                    },
                ],
                gconfig:'test/fixtures/gconfig.dev.json',
                removeOriginalUnmatchedMeta:true
            },
            dist:{
                // src:['app/*.html'],
                files: [
                    {
                        expand: true,     // Enable dynamic expansion.
                        cwd: 'test/fixtures',      // Src matches are relative to this path.
                        src: ['index.dist.html'], // Actual pattern(s) to match.
                        dest: 'tmp',   // Destination path prefix.
                        // ext: '.min.html',   // Dest filepaths will have this extension.
                    },
                ],
                gconfig:'test/fixtures/gconfig.dist.json',
                removeOriginalUnmatchedMeta:false
            }
        },
        // Unit tests.
        nodeunit: {
            tests: ['test/*_test.js'],
        },
    });

    // Actually load this plugin's task(s).
    grunt.loadTasks('tasks');

    // These plugins provide necessary tasks.
    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks('grunt-contrib-nodeunit');

    // Whenever the "test" task is run, first clean the "tmp" dir, then run this
    // plugin's task(s), then test the result.
    grunt.registerTask('test', ['clean', 'gconfig', 'nodeunit']);

    // By default, lint and run all tests.
    grunt.registerTask('default', ['jshint', 'test']);
};
<commit_msg>Gruntfile: Added options to gconfig, merge files and grunt config options.<commit_after>/*
 * grunt-gconfig
 * https://github.com/goliatone/grunt-gconfig
 *
 * Copyright (c) 2014 goliatone
 * Licensed under the MIT license.
 */

'use strict';

module.exports = function(grunt) {

    // Project configuration.
    grunt.initConfig({
        jshint: {
            all: [
                'Gruntfile.js',
                'tasks/*.js',
                '<%= nodeunit.tests %>',
            ],
            options: {
                jshintrc: '.jshintrc',
            },
        },

        // Before generating any new files, remove any previously-created files.
        clean: {
            tests: ['tmp'],
        },

        // Configuration to be run (and then tested).
        gconfig: {

            dev:{
                // src:['app/*.html'],
                files: [
                    {
                        expand: true,     // Enable dynamic expansion.
                        cwd: 'test/fixtures',      // Src matches are relative to this path.
                        src: ['index.dev.html'], // Actual pattern(s) to match.
                        dest: 'tmp',   // Destination path prefix.
                    },
                ],
                gconfig:'test/fixtures/gconfig.dev.json',
                mergeConfigs:['gconfigMergeGrunt'], //SEE BELOW!
                mergeFiles:[
                    'test/fixtures/gconfig.merge.json'
                ],
                removeOriginalUnmatchedMeta:true
            },
            dist:{
                // src:['app/*.html'],
                files: [
                    {
                        expand: true,     // Enable dynamic expansion.
                        cwd: 'test/fixtures',      // Src matches are relative to this path.
                        src: ['index.dist.html'], // Actual pattern(s) to match.
                        dest: 'tmp',   // Destination path prefix.
                    },
                ],
                mergeFiles:[
                    'test/fixtures/gconfig.merge.json'
                ],
                gconfig:'test/fixtures/gconfig.dist.json',
                removeOriginalUnmatchedMeta:false
            }
        },
        // Unit tests.
        nodeunit: {
            tests: ['test/*_test.js'],
        },
        //We are going to merge this Object in final gconfig!
        gconfigMergeGrunt:{
            foo:'bar',
            baz:'fuz'
        }
    });

    // Actually load this plugin's task(s).
    grunt.loadTasks('tasks');

    // These plugins provide necessary tasks.
    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks('grunt-contrib-nodeunit');

    // Whenever the "test" task is run, first clean the "tmp" dir, then run this
    // plugin's task(s), then test the result.
    grunt.registerTask('test', ['clean', 'gconfig', 'nodeunit']);

    // By default, lint and run all tests.
    grunt.registerTask('default', ['jshint', 'test']);
};
<|endoftext|>