<commit_before>var path = require('path');

module.exports = function(grunt) {
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    FOREVER_DIR: '${HOME}/.forever',
    PIDFILE: '<%=FOREVER_DIR%>/<%= pkg.name %>.pid',
    LOGFILE: '<%=FOREVER_DIR%>/<%= pkg.name %>.log',
    copy: {
      vendor: {
        files: [
          {
            expand: true, cwd: 'bower_components/bootstrap/',
            src: ['js/**', 'less/**'], dest: 'public/vendor/bootstrap/'
          },
          {
            expand: true, cwd: 'bower_components/backbone/',
            src: ['backbone.js'], dest: 'public/vendor/backbone/'
          },
          {
            expand: true, cwd: 'bower_components/font-awesome/',
            src: ['fonts/**', 'less/**'], dest: 'public/vendor/font-awesome/'
          },
          {
            expand: true, cwd: 'bower_components/html5shiv/dist/',
            src: ['html5shiv.js'], dest: 'public/vendor/html5shiv/'
          },
          {
            expand: true, cwd: 'bower_components/jquery/dist/',
            src: ['jquery.js'], dest: 'public/vendor/jquery/'
          },
          {
            expand: true, cwd: 'bower_components/momentjs/',
            src: ['moment.js'], dest: 'public/vendor/momentjs/'
          },
          {
            expand: true, cwd: 'bower_components/respond/src/',
            src: ['respond.js'], dest: 'public/vendor/respond/'
          },
          {
            expand: true, cwd: 'bower_components/underscore/',
            src: ['underscore.js'], dest: 'public/vendor/underscore/'
          }
        ]
      }
    },
    concurrent: {
      dev: {
        tasks: ['nodemon', 'watch'],
        options: {
          logConcurrentOutput: true
        }
      }
    },
    nodemon: {
      dev: {
        script: 'app.js',
        options: {
          ignore: [
            'node_modules/**',
            'public/**'
          ],
          ext: 'js'
        }
      }
    },
    watch: {
      clientJS: {
         files: [
          'public/layouts/**/*.js', '!public/layouts/**/*.min.js',
          'public/views/**/*.js', '!public/views/**/*.min.js'
         ],
         tasks: ['newer:uglify', 'newer:jshint:client']
      },
      serverJS: {
         files: ['views/**/*.js'],
         tasks: ['newer:jshint:server']
      },
      clientLess: {
         files: [
          'public/layouts/**/*.less',
          'public/views/**/*.less',
          'public/less/**/*.less'
         ],
         tasks: ['newer:less']
      }
    },
    uglify: {
      options: {
        sourceMap: true,
        sourceMapName: function(filePath) {
          return filePath + '.map';
        }
      },
      layouts: {
        files: {
          'public/layouts/core.min.js': [
            'public/vendor/jquery/jquery.js',
            'public/vendor/underscore/underscore.js',
            'public/vendor/backbone/backbone.js',
            'public/vendor/bootstrap/js/affix.js',
            'public/vendor/bootstrap/js/alert.js',
            'public/vendor/bootstrap/js/button.js',
            'public/vendor/bootstrap/js/carousel.js',
            'public/vendor/bootstrap/js/collapse.js',
            'public/vendor/bootstrap/js/dropdown.js',
            'public/vendor/bootstrap/js/modal.js',
            'public/vendor/bootstrap/js/tooltip.js',
            'public/vendor/bootstrap/js/popover.js',
            'public/vendor/bootstrap/js/scrollspy.js',
            'public/vendor/bootstrap/js/tab.js',
            'public/vendor/bootstrap/js/transition.js',
            'public/vendor/momentjs/moment.js',
            'public/layouts/core.js'
          ],
          'public/layouts/ie-sucks.min.js': [
            'public/vendor/html5shiv/html5shiv.js',
            'public/vendor/respond/respond.js',
            'public/layouts/ie-sucks.js'
          ],
          'public/layouts/admin.min.js': ['public/layouts/admin.js']
        }
      },
      views: {
        files: [{
          expand: true,
          cwd: 'public/views/',
          src: ['**/*.js', '!**/*.min.js'],
          dest: 'public/views/',
          ext: '.min.js'
        }]
      }
    },
    jshint: {
      client: {
        options: {
          jshintrc: '.jshintrc-client',
          ignores: [
            'public/layouts/**/*.min.js',
            'public/views/**/*.min.js'
          ]
        },
        src: [
          'public/layouts/**/*.js',
          'public/views/**/*.js'
        ]
      },
      server: {
        options: {
          jshintrc: '.jshintrc-server'
        },
        src: [
          'schema/**/*.js',
          'views/**/*.js'
        ]
      }
    },
    less: {
      options: {
        compress: true
      },
      layouts: {
        files: {
          'public/layouts/core.min.css': [
            'public/less/bootstrap-build.less',
            'public/less/font-awesome-build.less',
            'public/layouts/core.less'
          ],
          'public/layouts/admin.min.css': ['public/layouts/admin.less']
        }
      },
      views: {
        files: [{
          expand: true,
          cwd: 'public/views/',
          src: ['**/*.less'],
          dest: 'public/views/',
          ext: '.min.css'
        }]
      }
    },
    clean: {
      js: {
        src: [
          'public/layouts/**/*.min.js',
          'public/layouts/**/*.min.js.map',
          'public/views/**/*.min.js',
          'public/views/**/*.min.js.map'
        ]
      },
      css: {
        src: [
          'public/layouts/**/*.min.css',
          'public/views/**/*.min.css'
        ]
      },
      vendor: {
        src: ['public/vendor/**']
      }
    },
    exec: {
        start_server: {
            cmd: 'if [ ! -f <%=PIDFILE%> ]; then touch <%=PIDFILE%> && PORT=5000 NODE_ENV=production forever start -p <%=FOREVER_DIR%> -l <%= pkg.name %>.log -c "node --max-old-space-size=8192 --nouse-idle-notification" -a app.js; else echo "Can\'t start <%= pkg.name %>: <%= pkg.name %> is already running."; fi'
        },
        stop_server: {
            cmd: 'if [ -f <%=PIDFILE%> ]; then rm -f <%=PIDFILE%> && forever stop app.js; else echo "Can\'t stop <%= pkg.name %>: <%= pkg.name %> is not running."; fi'
        }
    }
  });

  grunt.loadNpmTasks('grunt-contrib-copy');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-less');
  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-concurrent');
  grunt.loadNpmTasks('grunt-nodemon');
  grunt.loadNpmTasks('grunt-newer');
  grunt.loadNpmTasks('grunt-exec');

  grunt.registerTask('default', ['copy:vendor', 'newer:uglify', 'newer:less', 'concurrent']);
  grunt.registerTask('build', ['copy:vendor', 'uglify', 'less']);
  grunt.registerTask('lint', ['jshint']);

  grunt.registerTask('start', ['exec:start_server']);
  grunt.registerTask('stop', ['exec:stop_server']);
};
<commit_msg>fix port setting<commit_after>var path = require('path');

module.exports = function(grunt) {
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    FOREVER_DIR: '${HOME}/.forever',
    PIDFILE: '<%=FOREVER_DIR%>/<%= pkg.name %>.pid',
    LOGFILE: '<%=FOREVER_DIR%>/<%= pkg.name %>.log',
    copy: {
      vendor: {
        files: [
          {
            expand: true, cwd: 'bower_components/bootstrap/',
            src: ['js/**', 'less/**'], dest: 'public/vendor/bootstrap/'
          },
          {
            expand: true, cwd: 'bower_components/backbone/',
            src: ['backbone.js'], dest: 'public/vendor/backbone/'
          },
          {
            expand: true, cwd: 'bower_components/font-awesome/',
            src: ['fonts/**', 'less/**'], dest: 'public/vendor/font-awesome/'
          },
          {
            expand: true, cwd: 'bower_components/html5shiv/dist/',
            src: ['html5shiv.js'], dest: 'public/vendor/html5shiv/'
          },
          {
            expand: true, cwd: 'bower_components/jquery/dist/',
            src: ['jquery.js'], dest: 'public/vendor/jquery/'
          },
          {
            expand: true, cwd: 'bower_components/momentjs/',
            src: ['moment.js'], dest: 'public/vendor/momentjs/'
          },
          {
            expand: true, cwd: 'bower_components/respond/src/',
            src: ['respond.js'], dest: 'public/vendor/respond/'
          },
          {
            expand: true, cwd: 'bower_components/underscore/',
            src: ['underscore.js'], dest: 'public/vendor/underscore/'
          }
        ]
      }
    },
    concurrent: {
      dev: {
        tasks: ['nodemon', 'watch'],
        options: {
          logConcurrentOutput: true
        }
      }
    },
    nodemon: {
      dev: {
        script: 'app.js',
        options: {
          ignore: [
            'node_modules/**',
            'public/**'
          ],
          ext: 'js'
        }
      }
    },
    watch: {
      clientJS: {
         files: [
          'public/layouts/**/*.js', '!public/layouts/**/*.min.js',
          'public/views/**/*.js', '!public/views/**/*.min.js'
         ],
         tasks: ['newer:uglify', 'newer:jshint:client']
      },
      serverJS: {
         files: ['views/**/*.js'],
         tasks: ['newer:jshint:server']
      },
      clientLess: {
         files: [
          'public/layouts/**/*.less',
          'public/views/**/*.less',
          'public/less/**/*.less'
         ],
         tasks: ['newer:less']
      }
    },
    uglify: {
      options: {
        sourceMap: true,
        sourceMapName: function(filePath) {
          return filePath + '.map';
        }
      },
      layouts: {
        files: {
          'public/layouts/core.min.js': [
            'public/vendor/jquery/jquery.js',
            'public/vendor/underscore/underscore.js',
            'public/vendor/backbone/backbone.js',
            'public/vendor/bootstrap/js/affix.js',
            'public/vendor/bootstrap/js/alert.js',
            'public/vendor/bootstrap/js/button.js',
            'public/vendor/bootstrap/js/carousel.js',
            'public/vendor/bootstrap/js/collapse.js',
            'public/vendor/bootstrap/js/dropdown.js',
            'public/vendor/bootstrap/js/modal.js',
            'public/vendor/bootstrap/js/tooltip.js',
            'public/vendor/bootstrap/js/popover.js',
            'public/vendor/bootstrap/js/scrollspy.js',
            'public/vendor/bootstrap/js/tab.js',
            'public/vendor/bootstrap/js/transition.js',
            'public/vendor/momentjs/moment.js',
            'public/layouts/core.js'
          ],
          'public/layouts/ie-sucks.min.js': [
            'public/vendor/html5shiv/html5shiv.js',
            'public/vendor/respond/respond.js',
            'public/layouts/ie-sucks.js'
          ],
          'public/layouts/admin.min.js': ['public/layouts/admin.js']
        }
      },
      views: {
        files: [{
          expand: true,
          cwd: 'public/views/',
          src: ['**/*.js', '!**/*.min.js'],
          dest: 'public/views/',
          ext: '.min.js'
        }]
      }
    },
    jshint: {
      client: {
        options: {
          jshintrc: '.jshintrc-client',
          ignores: [
            'public/layouts/**/*.min.js',
            'public/views/**/*.min.js'
          ]
        },
        src: [
          'public/layouts/**/*.js',
          'public/views/**/*.js'
        ]
      },
      server: {
        options: {
          jshintrc: '.jshintrc-server'
        },
        src: [
          'schema/**/*.js',
          'views/**/*.js'
        ]
      }
    },
    less: {
      options: {
        compress: true
      },
      layouts: {
        files: {
          'public/layouts/core.min.css': [
            'public/less/bootstrap-build.less',
            'public/less/font-awesome-build.less',
            'public/layouts/core.less'
          ],
          'public/layouts/admin.min.css': ['public/layouts/admin.less']
        }
      },
      views: {
        files: [{
          expand: true,
          cwd: 'public/views/',
          src: ['**/*.less'],
          dest: 'public/views/',
          ext: '.min.css'
        }]
      }
    },
    clean: {
      js: {
        src: [
          'public/layouts/**/*.min.js',
          'public/layouts/**/*.min.js.map',
          'public/views/**/*.min.js',
          'public/views/**/*.min.js.map'
        ]
      },
      css: {
        src: [
          'public/layouts/**/*.min.css',
          'public/views/**/*.min.css'
        ]
      },
      vendor: {
        src: ['public/vendor/**']
      }
    },
    exec: {
        start_server: {
            cmd: 'if [ ! -f <%=PIDFILE%> ]; then touch <%=PIDFILE%> && PORT=3000 NODE_ENV=production forever start -p <%=FOREVER_DIR%> -l <%= pkg.name %>.log -c "node --max-old-space-size=8192 --nouse-idle-notification" -a app.js; else echo "Can\'t start <%= pkg.name %>: <%= pkg.name %> is already running."; fi'
        },
        stop_server: {
            cmd: 'if [ -f <%=PIDFILE%> ]; then rm -f <%=PIDFILE%> && forever stop app.js; else echo "Can\'t stop <%= pkg.name %>: <%= pkg.name %> is not running."; fi'
        }
    }
  });

  grunt.loadNpmTasks('grunt-contrib-copy');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-less');
  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-concurrent');
  grunt.loadNpmTasks('grunt-nodemon');
  grunt.loadNpmTasks('grunt-newer');
  grunt.loadNpmTasks('grunt-exec');

  grunt.registerTask('default', ['copy:vendor', 'newer:uglify', 'newer:less', 'concurrent']);
  grunt.registerTask('build', ['copy:vendor', 'uglify', 'less']);
  grunt.registerTask('lint', ['jshint']);

  grunt.registerTask('start', ['exec:start_server']);
  grunt.registerTask('stop', ['exec:stop_server']);
};
<|endoftext|>


<commit_before>module.exports = function(grunt) {

  // Project configuration.
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    copy: {
      indexPage: {
        expand: true,
        src: 'app/index.html',
        dest: 'build/',
        flatten: true
      },
      css: {
        expand: true,
        src: 'app/**/*.css',
        dest: 'build/',
        flatten: true
      },
      images: {
        expand: true,
        src: 'app/images/**/*.jpg',
        dest: 'build/img/',
        flatten: true
      },
      lib: {
        files: [
          {
            expand: true,
            cwd: 'lib/',
            src: [
              'angular/angular.min.js',
              'bootstrap/dist/css/bootstrap.min.css',
              'bootstrap/dist/js/bootstrap.min.js',
              'jquery/dist/jquery.min.js'
            ],
            dest: 'build/',
            flatten: true
          }
        ]
      }
    },
    clean: {
      build: ['temp/', 'build/']
    },
    ngtemplates:  {
      myApp:        {
        src:      ['app/**/*.html', '!app/index.html'],
        dest:     'temp/templates.js'
      }
    },
    watch: {
      scripts: {
        files: ['app/**/*.js', 'app/**/*.html', 'app/**/*.less'],
        tasks: ['default'],
        options: {
          spawn: false,
        },
      },
    },
    uglify: {
      options: {
        banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
      },
      build: {
        // src: 'src/<%= pkg.name %>.js',
        src: ['app/app.js', 'app/**/*.js', 'temp/templates.js'],
        dest: 'build/<%= pkg.name %>.min.js'
      }
    }
  });

  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-contrib-copy');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-angular-templates');

  grunt.registerTask('build', ['ngtemplates', 'uglify', 'copy']);

  // Default task(s).
  grunt.registerTask('default', ['build']);

};
<commit_msg>Update Gruntfile to include bootstrap fonts and copy all images to build folder<commit_after>module.exports = function(grunt) {

  // Project configuration.
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    copy: {
      indexPage: {
        expand: true,
        src: 'app/index.html',
        dest: 'build/',
        flatten: true
      },
      css: {
        expand: true,
        src: [
          'lib/bootstrap/dist/css/bootstrap.min.css',
          'app/**/*.css'
        ],
        dest: 'build/css/',
        flatten: true
      },
      images: {
        expand: true,
        src: 'app/images/**/*',
        dest: 'build/img/',
        flatten: true
      },
      lib: {
        files: [
          {
            expand: true,
            cwd: 'lib/',
            src: [
              'angular/angular.min.js',
              'bootstrap/dist/js/bootstrap.min.js',
              'jquery/dist/jquery.min.js'
            ],
            dest: 'build/',
            flatten: true
          }, {
            expand: true,
            src: [
              'lib/bootstrap/dist/fonts/*',
            ],
            dest: 'build/fonts/',
            flatten: true
          }
        ]
      }
    },
    clean: {
      build: ['temp/', 'build/']
    },
    ngtemplates:  {
      myApp:        {
        src:      ['app/**/*.html', '!app/index.html'],
        dest:     'temp/templates.js'
      }
    },
    watch: {
      scripts: {
        files: ['app/**/*.js', 'app/**/*.html', 'app/**/*.less'],
        tasks: ['default'],
        options: {
          spawn: false,
        },
      },
    },
    uglify: {
      options: {
        banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
      },
      build: {
        // src: 'src/<%= pkg.name %>.js',
        src: ['app/app.js', 'app/**/*.js', 'temp/templates.js'],
        dest: 'build/<%= pkg.name %>.min.js'
      }
    }
  });

  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-contrib-copy');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-angular-templates');

  grunt.registerTask('build', ['ngtemplates', 'uglify', 'copy']);

  // Default task(s).
  grunt.registerTask('default', ['build']);

};
<|endoftext|>


<commit_before>#!/usr/bin/env node

/*!
 * MeltXpert®
 * Improved Nucleic Acid homo & hetero duplexes thermal behavior analysis program.
 * ________________________________________________________________________________
 *
 * Grunt, http://gruntjs.com/.
 * The JavaScript Task Runner.
 * ________________________________________________________________________________
 *
 * Architecture and Code Handcrafted by Prabhat Kumar.
 * Architectuur en Code handgemaakt door Prabhat Kumar.
 * @author    : Prabhat Kumar [http://prabhatkumar.org/].
 * @copyright : Prabhat Kumar [http://prabhatkumar.org/].
 * @copyright : Sequømics Research [http://research.sequomics.com/].
 * @copyright : Sequømics Corporation [http://sequomics.com/].
 * ________________________________________________________________________________
 *
 * @date      : 11-Nov-2016
 * @license   : Apache, version 2.0
 * @require   : Node.js®
 * @require   : NPM
 * @require   : grunt-cli
 * @build     : SEED™ — Umeå
 *              └────── A Sequømics Product — http://sequomics.com/.
 * ________________________________________________________________________________
 *
 * --/The Heart of Build System/-- of "MeltXpert®".
 * ________________________________________________________________________________
 */

// "disallowMultipleSpaces": {"allowEOLComments": true}
// "disallowSemicolons": false
// "requireSemicolons": true
// "requireSpaceAfterLineComment": { "allExcept": ["#", "="] }

// global __dirname: true
// global require: true

//# Usage: $ node -v
//# Usage: $ npm -v
//# Usage: $ grunt -version

// Invoking strict mode.
// @purpose: Strict mode applies to entire scripts or to individual functions.
"use strict";

// To load required Node module.
//=-----------------------------
var fs          = require('fs');
var os          = require('os');
var path        = require('path');

// To load required NPM modules.
//=-----------------------------
var chalk       = require('chalk');
// Check if our code is running on Travis.
var isTravis    = require('is-travis');

// Global variables.
//=~~~~~~~~~~~~~~~~~
var rootPath    = './';
var appsPath    = './app/';
var docsPath    = './docs/';
var libsPath    = './libs/';
// A destination directory.
var buildPath   = './build/';

// Default color defined.
//=----------------------
var noop        = chalk.red;
var yeep        = chalk.green;
var okay        = chalk.blue;
var boop        = chalk.gray;

var message     = "SEED™ — Supported under Mac OS X and Linux only!";
// To use inside grunt task.
var pkg         = require('./package.json');
var bkg         = require('./bower.json');
var version     = process.env.VERSION || require('./package.json').version;

// ----------------------------------------------------------------------------------------------------------
var banner      =
    '/*!\n' +
    ' * ———————————\n' +
    ' * MeltXpert®: v' + version + '\n' +
    ' * ———————————\n' +
    ' * Improved Nucleic Acid homo & hetero duplexes thermal behavior analysis program.\n' +
    ' * Copyright © 2006 - ' + new Date().getFullYear() + ', Prabhat Kumar, All rights reserved.\n' +
    ' * Copyright © 2014 - ' + new Date().getFullYear() + ', Sequømics Corporation, All rights reserved.\n' +
    ' * Released under the Apache License (http://www.apache.org/licenses/).\n' +
    ' */';
// ----------------------------------------------------------------------------------------------------------
// All Grunt Operations Defined... |--------------------------------------------| 11/Nov/2016 | SEED™ — Umeå.
// ----------------------------------------------------------------------------------------------------------

module.exports = function(grunt) {

    // Force use of Unix newlines.
    grunt.util.linefeed = '\n';

    // A regular expression.
    RegExp.quote = function(string) {
        return string.replace(/[-\\^$*+?.()|[\]{}]/g, '\\$&');
    };

    // Date objects.
    var today    = new Date();
    var timems   = Date.now();

    // Advanced Grunt API.
    /// -->> A mode defaults to `0777`.
    var mode     = '0777';
    /// -->> A file globbing pattern.
    var pattern  = '**/*.js';
    // Exclude: remove from consideration.
    // grunt.file.expand([options, ] patterns)
    var excludes  = grunt.file.expand([
        '!/libs/assembly/assembly.js',
        '!/libs/assembly/convert.js'
    ]);
    // Includes: make part of a whole or set.
    // grunt.file.expand([options, ] patterns)
    var includes = grunt.file.expand([
        __dirname + '/core/source/script/' + pattern,
        __dirname + '/core/source/engine/' + pattern
    ]);
    // To write process log(s).
    var contents = null;

    // To generate data of nucleic acid(s).
    // ./pub/data/raw/ ——> ./pub/data/gold/
    var generateData = require('./pub/data/datagenerator.js');
    // A configuration bridge.
    var configBridge = grunt.file.readJSON('./grunt/configBridge.json', {
        encoding: 'utf8'
    });

    // A configuration bridge function.
    Object.keys(configBridge.paths).forEach(function(key) {
        configBridge.paths[key].forEach(function(val, i, arr) {
            arr[i] = path.join('./docs/', val);
        });
    });

    // 1. time-grunt
    // Display the elapsed execution time of grunt tasks.
    require('time-grunt')(grunt);

    // 2. load-grunt-tasks
    // Load multiple grunt tasks using globbing patterns.
    require('load-grunt-tasks')(grunt, {
        scope: ['devDependencies', 'dependencies']
    });

    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    // Project configuration for -//MeltXpert®//- |-----------------------------| 11/Nov/2016 | SEED™ — Umeå.
    //                  Copyright © 2014 - 2016, Sequømics Corporation, All rights reserved.
    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<commit_msg>Initial commit<commit_after>#!/usr/bin/env node

/*!
 * MeltXpert®
 * Improved Nucleic Acid homo & hetero duplexes thermal behavior analysis program.
 * ________________________________________________________________________________
 *
 * Grunt, http://gruntjs.com/.
 * The JavaScript Task Runner.
 * ________________________________________________________________________________
 *
 * Architecture and Code Handcrafted by Prabhat Kumar.
 * Architectuur en Code handgemaakt door Prabhat Kumar.
 * @author    : Prabhat Kumar [http://prabhatkumar.org/].
 * @copyright : Prabhat Kumar [http://prabhatkumar.org/].
 * @copyright : Sequømics Research [http://research.sequomics.com/].
 * @copyright : Sequømics Corporation [http://sequomics.com/].
 * ________________________________________________________________________________
 *
 * @date      : 11-Nov-2016
 * @license   : Apache, version 2.0
 * @require   : Node.js®
 * @require   : NPM
 * @require   : grunt-cli
 * @build     : SEED™ — Umeå
 *              └────── A Sequømics Product — http://sequomics.com/.
 * ________________________________________________________________________________
 *
 * --/The Heart of Build System/-- of "MeltXpert®".
 * ________________________________________________________________________________
 */

// "disallowMultipleSpaces": {"allowEOLComments": true}
// "disallowSemicolons": false
// "requireSemicolons": true
// "requireSpaceAfterLineComment": { "allExcept": ["#", "="] }

// global __dirname: true
// global require: true

//# Usage: $ node -v
//# Usage: $ npm -v
//# Usage: $ grunt -version

// Invoking strict mode.
// @purpose: Strict mode applies to entire scripts or to individual functions.
"use strict";

// To load required Node module.
//=-----------------------------
var fs          = require('fs');
var os          = require('os');
var path        = require('path');

// To load required NPM modules.
//=-----------------------------
var chalk       = require('chalk');
// Check if our code is running on Travis.
var isTravis    = require('is-travis');

// Global variables.
//=~~~~~~~~~~~~~~~~~
var rootPath    = './';
var appsPath    = './app/';
var docsPath    = './docs/';
var libsPath    = './libs/';
// A destination directory.
var buildPath   = './build/';

// Default color defined.
//=----------------------
var noop        = chalk.red;
var yeep        = chalk.green;
var okay        = chalk.blue;
var boop        = chalk.gray;

var message     = "SEED™ — Supported under Mac OS X and Linux only!";
// To use inside grunt task.
var pkg         = require('./package.json');
var bkg         = require('./bower.json');
var version     = process.env.VERSION || require('./package.json').version;

// ----------------------------------------------------------------------------------------------------------
var banner      =
    '/*!\n' +
    ' * ———————————\n' +
    ' * MeltXpert®: v' + version + '\n' +
    ' * ———————————\n' +
    ' * Improved Nucleic Acid homo & hetero duplexes thermal behavior analysis program.\n' +
    ' * Copyright © 2006 - ' + new Date().getFullYear() + ', Prabhat Kumar, All rights reserved.\n' +
    ' * Copyright © 2014 - ' + new Date().getFullYear() + ', Sequømics Corporation, All rights reserved.\n' +
    ' * Released under the Apache License (http://www.apache.org/licenses/).\n' +
    ' */';
// ----------------------------------------------------------------------------------------------------------
// All Grunt Operations Defined... |--------------------------------------------| 11/Nov/2016 | SEED™ — Umeå.
// ----------------------------------------------------------------------------------------------------------

module.exports = function(grunt) {

    // Force use of Unix newlines.
    grunt.util.linefeed = '\n';

    // A regular expression.
    RegExp.quote = function(string) {
        return string.replace(/[-\\^$*+?.()|[\]{}]/g, '\\$&');
    };

    // Date objects.
    var today    = new Date();
    var timems   = Date.now();

    // Advanced Grunt API.
    /// -->> A mode defaults to `0777`.
    var mode     = '0777';
    /// -->> A file globbing pattern.
    var pattern  = '**/*.js';
    // Exclude: remove from consideration.
    // grunt.file.expand([options, ] patterns)
    var excludes  = grunt.file.expand([
        '!/libs/assembly/assembly.js',
        '!/libs/assembly/convert.js'
    ]);
    // Includes: make part of a whole or set.
    // grunt.file.expand([options, ] patterns)
    var includes = grunt.file.expand([
        __dirname + '/core/source/script/' + pattern,
        __dirname + '/core/source/engine/' + pattern
    ]);
    // To write process log(s).
    var contents = null;

    // To generate data of nucleic acid(s).
    // ./pub/data/raw/ ——> ./pub/data/gold/
    var generateData = require('./pub/data/datagenerator.js');
    // A configuration bridge.
    var configBridge = grunt.file.readJSON('./grunt/configBridge.json', {
        encoding: 'utf8'
    });

    // A configuration bridge function.
    Object.keys(configBridge.paths).forEach(function(key) {
        configBridge.paths[key].forEach(function(val, i, arr) {
            arr[i] = path.join('./docs/', val);
        });
    });

    // 1. time-grunt
    // Display the elapsed execution time of grunt tasks.
    require('time-grunt')(grunt);

    // 2. load-grunt-tasks
    // Load multiple grunt tasks using globbing patterns.
    require('load-grunt-tasks')(grunt, {
        scope: ['devDependencies', 'dependencies']
    });

    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    // Project configuration for -//MeltXpert®//- |-----------------------------| 11/Nov/2016 | SEED™ — Umeå.
    //                  Copyright © 2014 - 2016, Sequømics Corporation, All rights reserved.
    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    // Grunt project configuration.
    grunt.initConfig({
<|endoftext|>


<commit_before>var path = require("path"),
    fs = require("fs");

var BannerPlugin = require("webpack/lib/BannerPlugin");

module.exports = function(grunt) {
  grunt.loadNpmTasks('grunt-recess');
  grunt.loadNpmTasks('grunt-webpack');
  grunt.loadNpmTasks('grunt-preprocess');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-copy');

  // Ripple client dependencies
  var deps = ["deps/js/jquery.js",
              "deps/js/swfobject.js",
              "deps/js/jquery.easing.js",
              "deps/js/json.js",
              "deps/js/setImmediate.js",
              "deps/js/psm.js",
              "deps/js/underscore.js",
              "deps/js/downloadify.js",
              "deps/js/angular.js",
              "deps/js/store.js",
              "deps/js/ripple.js",
              "deps/js/ripple-sjcl.js",
              "deps/js/moment.js",
              "deps/js/bootstrap-modal.js",
              "deps/js/bootstrap-tooltip.js",
              "deps/js/bootstrap-popover.js",
              "deps/js/bootstrap-datepicker.js",
              "deps/js/jquery.qrcode.min.js",
              "deps/js/spin.js"];

  var deps_ie = ["compat/ie/base64/base64.js",
                 "compat/ie/ws/web_socket.js",
                 "compat/ie/ws/config.js",
                 "compat/ie/xdr/xdr.js"];

  /**
   * Returns true if the source is newer than the destination.
   */
  var isNewer = function (src,dest) {
    if (!fs.existsSync(dest)) {
      return true;
    }
    var fromstat = fs.statSync(src);
    var tostat = fs.statSync(dest);
    return fromstat.mtime > tostat.mtime;
  };

  /**
   * Where there are many files that compile to one, this returns true
   * if any of the input files are newer than the output.
   */
  var manyToOne = function (dest, src) {
    var compile = true;
    if (fs.existsSync(dest)) {
      var from = grunt.file.expand(src);
      var tostat = fs.statSync(dest);
      compile = false;
      for (var i = from.length - 1; i >= 0; i--) {
        if (fs.statSync(from[i]).mtime > tostat.mtime) {
          compile = true;
          break;
        }
      }
    }
    return [{dest:dest, src:compile?src:[]}];
  };

  grunt.registerTask("version", "Describes current git commit", function (prop) {
    var done = this.async();

    grunt.log.write("Version: ");

    grunt.util.spawn({
      cmd : "git",
      args : [ "describe", "--tags", "--always", "--dirty" ]
    }, function (err, result) {
      if (err) {
        grunt.log.error(err);
        return done(false);
      }

      grunt.config(prop || "meta.version", result.stdout);

      grunt.log.writeln(result.stdout.green);

      done(result);
    });
  });

  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    meta: {},
    recess: {
      dist: {
        src: ['src/less/ripple/desktop.less'],
        dest: 'build/dist/ripple-desktop.css',
        options: {
          compile: true
        }
      }
    },
    webpack: {
      options: {
        entry: "./src/js/entry/desktop.js",
        module: {
          loaders: [
            { test: /\.jade$/, loader: "jade-loader" }
          ],
          preLoaders: [
            {
              test: /\.js$/,
              include: pathToRegExp(path.join(__dirname, 'src', 'js')),
              loader: "jshint-loader"
            }
          ]
        },
        output: {
          path: "build/dist/"
        },
        cache: true,
        jshint: {
          "validthis": true,
          "laxcomma" : true,
          "laxbreak" : true,
          "browser"  : true,
          "eqnull"   : true,
          "debug"    : true,
          "devel"    : true,
          "boss"     : true,
          "expr"     : true,
          "asi"      : true,
          "sub"      : true
        },
        plugins: [
          new BannerPlugin("Ripple Client v<%= meta.version %>\nCopyright (c) <%= grunt.template.today('yyyy') %> <%= pkg.author.name %>\nLicensed under the <%= pkg.license %> license.")
        ]
      },
      desktop: {
        output: {
          filename: "<%= pkg.name %>-desktop.js"
        },
        optimize: {
          minimize: true
        }
      },
      desktop_debug: {
        output: {
          filename: "<%= pkg.name %>-desktop-debug.js"
        },
        debug: true,
        devtool: 'eval'
      }
    },
    concat: {
      deps: {
        src: deps,
        cwd: 'build/',
        dest: 'build/dist/deps.js',
        separator: ';'
      },
      deps_ie: {
        src: deps_ie,
        cwd: 'build/',
        dest: 'build/dist/deps_ie.js'
      },
      deps_debug: {
        src: deps,
        dest: 'build/dist/deps-debug.js',
        separator: ';'
      },
      deps_ie_debug: {
        src: deps_ie,
        dest: 'build/dist/deps_ie-debug.js'
      }
    },
    uglify: {
      // JavaScript dependencies
      deps: {
        expand: true,
        src: deps,
        dest: "build/",
        filter: function (from) {
          return isNewer(from, "build/"+from);
        }
      },
      deps_ie: {
        expand: true,
        src: deps_ie,
        dest: "build/",
        filter: function (from) {
          return isNewer(from, "build/"+from);
        }
      }
    },
    preprocess: {
      web: {
        src: 'index.html',
        dest: 'build/dist/index.html',
        options: {
          context: {
            MODE_RELEASE: true,
            TARGET_WEB: true,
            VERSION: "<%= meta.version %>"
          }
        }
      },
      web_debug: {
        src: 'index.html',
        dest: 'build/dist/index_debug.html',
        options: {
          context: {
            MODE_DEBUG: true,
            TARGET_WEB: true,
            VERSION: "<%= meta.version %>"
          }
        }
      }
    },
    copy: {
      web: {
        files: [
        ]
      },
      nw_linux: {
        files: [
          {expand: true, src: ['build/dist/*.js'], dest: 'build/bundle/nw-linux'},
          {expand: true, src: ['build/dist/*.css'], dest: 'build/bundle/nw-linux'},
          {expand: true, src: ['build/dist/*.html'], dest: 'build/bundle/nw-linux', flatten: true},
          {expand: true, src: ['fonts/*'], dest: 'build/bundle/nw-linux'},
          {expand: true, src: ['img/*'], dest: 'build/bundle/nw-linux'},
          {expand: true, src: ['deps/js/modernizr*.js'], dest: 'build/bundle/nw-linux'},
          {src: 'res/nw/package_linux.json', dest: 'build/bundle/nw-linux/package.json'}
        ]
      },
      nw_linux_debug: {
        files: [
          {expand: true, src: ['build/dist/*.js'], dest: 'build/bundle/nw-linux-debug'},
          {expand: true, src: ['build/dist/*.css'], dest: 'build/bundle/nw-linux-debug'},
          {expand: true, src: ['build/dist/*.html'], dest: 'build/bundle/nw-linux-debug', flatten: true},
          {expand: true, src: ['fonts/*'], dest: 'build/bundle/nw-linux-debug'},
          {expand: true, src: ['img/*'], dest: 'build/bundle/nw-linux-debug'},
          {expand: true, src: ['deps/js/modernizr*.js'], dest: 'build/bundle/nw-linux-debug'},
          {src: 'res/nw/package_linux_debug.json', dest: 'build/bundle/nw-linux-debug/package.json'}
        ]
      }
    },
    watch: {
       livereload: {
        options: {
            livereload: true
        },
        files: ['build/css/**/*.css'],
        tasks: []
       },

      scripts_debug: {
        files: ['src/js/**/*.js', 'src/jade/**/*.jade'],
        tasks: ['webpack:desktop_debug'],
        options: { nospawn: true, livereload: true }
      },
      deps: {
        files: ['<%= concat.deps.src %>'],
        tasks: ['concat:deps_debug']
      },
      styles: {
        files: 'src/less/**/*.less',
        options: {livereload:true},
        tasks: 'recess'
      }
    }
  });

  // Tasks
  grunt.registerTask('default', ['version',
                                 'preprocess',
                                 'webpack', 'recess',
                                 'uglify:deps',
                                 'concat:deps','concat:deps_debug',
                                 'uglify:deps_ie',
                                 'concat:deps_ie', 'concat:deps_ie_debug']);
  grunt.registerTask('deps', ['concat:deps', 'min:deps']);
  grunt.registerTask('dist', [//'default',
                              'copy:web', 'copy:nw_linux', 'copy:nw_linux_debug']);
};
// Helpers
function escapeRegExpString(str) { return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"); }
function pathToRegExp(p) { return new RegExp("^" + escapeRegExpString(p)); }
<commit_msg>Fix indentation.<commit_after>var path = require("path"),
    fs = require("fs");

var BannerPlugin = require("webpack/lib/BannerPlugin");

module.exports = function(grunt) {
  grunt.loadNpmTasks('grunt-recess');
  grunt.loadNpmTasks('grunt-webpack');
  grunt.loadNpmTasks('grunt-preprocess');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-copy');

  // Ripple client dependencies
  var deps = ["deps/js/jquery.js",
              "deps/js/swfobject.js",
              "deps/js/jquery.easing.js",
              "deps/js/json.js",
              "deps/js/setImmediate.js",
              "deps/js/psm.js",
              "deps/js/underscore.js",
              "deps/js/downloadify.js",
              "deps/js/angular.js",
              "deps/js/store.js",
              "deps/js/ripple.js",
              "deps/js/ripple-sjcl.js",
              "deps/js/moment.js",
              "deps/js/bootstrap-modal.js",
              "deps/js/bootstrap-tooltip.js",
              "deps/js/bootstrap-popover.js",
              "deps/js/bootstrap-datepicker.js",
              "deps/js/jquery.qrcode.min.js",
              "deps/js/spin.js"];

  var deps_ie = ["compat/ie/base64/base64.js",
                 "compat/ie/ws/web_socket.js",
                 "compat/ie/ws/config.js",
                 "compat/ie/xdr/xdr.js"];

  /**
   * Returns true if the source is newer than the destination.
   */
  var isNewer = function (src,dest) {
    if (!fs.existsSync(dest)) {
      return true;
    }
    var fromstat = fs.statSync(src);
    var tostat = fs.statSync(dest);
    return fromstat.mtime > tostat.mtime;
  };

  /**
   * Where there are many files that compile to one, this returns true
   * if any of the input files are newer than the output.
   */
  var manyToOne = function (dest, src) {
    var compile = true;
    if (fs.existsSync(dest)) {
      var from = grunt.file.expand(src);
      var tostat = fs.statSync(dest);
      compile = false;
      for (var i = from.length - 1; i >= 0; i--) {
        if (fs.statSync(from[i]).mtime > tostat.mtime) {
          compile = true;
          break;
        }
      }
    }
    return [{dest:dest, src:compile?src:[]}];
  };

  grunt.registerTask("version", "Describes current git commit", function (prop) {
    var done = this.async();

    grunt.log.write("Version: ");

    grunt.util.spawn({
      cmd : "git",
      args : [ "describe", "--tags", "--always", "--dirty" ]
    }, function (err, result) {
      if (err) {
        grunt.log.error(err);
        return done(false);
      }

      grunt.config(prop || "meta.version", result.stdout);

      grunt.log.writeln(result.stdout.green);

      done(result);
    });
  });

  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    meta: {},
    recess: {
      dist: {
        src: ['src/less/ripple/desktop.less'],
        dest: 'build/dist/ripple-desktop.css',
        options: {
          compile: true
        }
      }
    },
    webpack: {
      options: {
        entry: "./src/js/entry/desktop.js",
        module: {
          loaders: [
            { test: /\.jade$/, loader: "jade-loader" }
          ],
          preLoaders: [
            {
              test: /\.js$/,
              include: pathToRegExp(path.join(__dirname, 'src', 'js')),
              loader: "jshint-loader"
            }
          ]
        },
        output: {
          path: "build/dist/"
        },
        cache: true,
        jshint: {
          "validthis": true,
          "laxcomma" : true,
          "laxbreak" : true,
          "browser"  : true,
          "eqnull"   : true,
          "debug"    : true,
          "devel"    : true,
          "boss"     : true,
          "expr"     : true,
          "asi"      : true,
          "sub"      : true
        },
        plugins: [
          new BannerPlugin("Ripple Client v<%= meta.version %>\nCopyright (c) <%= grunt.template.today('yyyy') %> <%= pkg.author.name %>\nLicensed under the <%= pkg.license %> license.")
        ]
      },
      desktop: {
        output: {
          filename: "<%= pkg.name %>-desktop.js"
        },
        optimize: {
          minimize: true
        }
      },
      desktop_debug: {
        output: {
          filename: "<%= pkg.name %>-desktop-debug.js"
        },
        debug: true,
        devtool: 'eval'
      }
    },
    concat: {
      deps: {
        src: deps,
        cwd: 'build/',
        dest: 'build/dist/deps.js',
        separator: ';'
      },
      deps_ie: {
        src: deps_ie,
        cwd: 'build/',
        dest: 'build/dist/deps_ie.js'
      },
      deps_debug: {
        src: deps,
        dest: 'build/dist/deps-debug.js',
        separator: ';'
      },
      deps_ie_debug: {
        src: deps_ie,
        dest: 'build/dist/deps_ie-debug.js'
      }
    },
    uglify: {
      // JavaScript dependencies
      deps: {
        expand: true,
        src: deps,
        dest: "build/",
        filter: function (from) {
          return isNewer(from, "build/"+from);
        }
      },
      deps_ie: {
        expand: true,
        src: deps_ie,
        dest: "build/",
        filter: function (from) {
          return isNewer(from, "build/"+from);
        }
      }
    },
    preprocess: {
      web: {
        src: 'index.html',
        dest: 'build/dist/index.html',
        options: {
          context: {
            MODE_RELEASE: true,
            TARGET_WEB: true,
            VERSION: "<%= meta.version %>"
          }
        }
      },
      web_debug: {
        src: 'index.html',
        dest: 'build/dist/index_debug.html',
        options: {
          context: {
            MODE_DEBUG: true,
            TARGET_WEB: true,
            VERSION: "<%= meta.version %>"
          }
        }
      }
    },
    copy: {
      web: {
        files: [
        ]
      },
      nw_linux: {
        files: [
          {expand: true, src: ['build/dist/*.js'], dest: 'build/bundle/nw-linux'},
          {expand: true, src: ['build/dist/*.css'], dest: 'build/bundle/nw-linux'},
          {expand: true, src: ['build/dist/*.html'], dest: 'build/bundle/nw-linux', flatten: true},
          {expand: true, src: ['fonts/*'], dest: 'build/bundle/nw-linux'},
          {expand: true, src: ['img/*'], dest: 'build/bundle/nw-linux'},
          {expand: true, src: ['deps/js/modernizr*.js'], dest: 'build/bundle/nw-linux'},
          {src: 'res/nw/package_linux.json', dest: 'build/bundle/nw-linux/package.json'}
        ]
      },
      nw_linux_debug: {
        files: [
          {expand: true, src: ['build/dist/*.js'], dest: 'build/bundle/nw-linux-debug'},
          {expand: true, src: ['build/dist/*.css'], dest: 'build/bundle/nw-linux-debug'},
          {expand: true, src: ['build/dist/*.html'], dest: 'build/bundle/nw-linux-debug', flatten: true},
          {expand: true, src: ['fonts/*'], dest: 'build/bundle/nw-linux-debug'},
          {expand: true, src: ['img/*'], dest: 'build/bundle/nw-linux-debug'},
          {expand: true, src: ['deps/js/modernizr*.js'], dest: 'build/bundle/nw-linux-debug'},
          {src: 'res/nw/package_linux_debug.json', dest: 'build/bundle/nw-linux-debug/package.json'}
        ]
      }
    },
    watch: {
      livereload: {
        options: {
          livereload: true
        },
        files: ['build/css/**/*.css'],
        tasks: []
      },
      scripts_debug: {
        files: ['src/js/**/*.js', 'src/jade/**/*.jade'],
        tasks: ['webpack:desktop_debug'],
        options: { nospawn: true, livereload: true }
      },
      deps: {
        files: ['<%= concat.deps.src %>'],
        tasks: ['concat:deps_debug']
      },
      styles: {
        files: 'src/less/**/*.less',
        options: {livereload:true},
        tasks: 'recess'
      }
    }
  });

  // Tasks
  grunt.registerTask('default', ['version',
                                 'preprocess',
                                 'webpack', 'recess',
                                 'uglify:deps',
                                 'concat:deps','concat:deps_debug',
                                 'uglify:deps_ie',
                                 'concat:deps_ie', 'concat:deps_ie_debug']);
  grunt.registerTask('deps', ['concat:deps', 'min:deps']);
  grunt.registerTask('dist', [//'default',
                              'copy:web', 'copy:nw_linux', 'copy:nw_linux_debug']);
};
// Helpers
function escapeRegExpString(str) { return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"); }
function pathToRegExp(p) { return new RegExp("^" + escapeRegExpString(p)); }
<|endoftext|>


<commit_before>'use strict';

module.exports = function(grunt) {

    // Project configuration.
    grunt.initConfig({
	jshint: {
	    options: {
		jshintrc: '.jshintrc'
	    },
	    gruntfile: {
		src: 'Gruntfile.js'
	    },
	    lib: {
		src: ['lib/**/*.js']
	    },
	    test: {
		src: ['test/**/*.js']
	    },
	    docco: {
		debug: {
		    src: ['lib/*.js'],
		    options: {
			output: 'docs/'
		    }
		}
	    }
	}
    });

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

    // Default task.
    grunt.registerTask('default', ['jshint']);
    grunt.registerTask('docco', ['docco']);
};
<commit_msg>Solved with the help of SO http://stackoverflow.com/questions/22285942/grunt-throw-recursive-process-nexttick-detected/22409382#22409382<commit_after>'use strict';

module.exports = function(grunt) {

    // Project configuration.
    grunt.initConfig({
	jshint: {
	    options: {
		jshintrc: '.jshintrc'
	    },
	    gruntfile: {
		src: 'Gruntfile.js'
	    },
	    lib: {
		src: ['lib/**/*.js']
	    },
	    test: {
		src: ['test/**/*.js']
	    }

	},
	docco: {
	    debug: {
		src: ['lib/*.js'],
		options: {
		    output: 'docs/'
		}
	    }
	}
    });

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

    // Default task.
    grunt.registerTask('default', ['jshint']);
    grunt.registerTask('docs', ['docco']);
};
<|endoftext|>


<commit_before>module.exports = function(grunt) {

  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-contrib-copy');
  grunt.loadNpmTasks('grunt-contrib-coffee');
  grunt.loadNpmTasks('grunt-contrib-compass');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-concat');

  grunt.loadNpmTasks('grunt-coffeelint');
  grunt.loadNpmTasks('grunt-html2js');
  grunt.loadNpmTasks('grunt-karma');

  var config = require('./misc/build-config.js')(grunt);

  grunt.initConfig({

    clean: {
      build: config.buildDirectory,
      release: config.releaseDirectory
    },

    // Build the foundation + custom files using compass
    compass: {
      main: {
        options: {
          config: config.compassConfigFile,
          cssDir: config.cssDirectory,
          sassDir: config.sassDirectory,
          force: true,
          environment: 'production'
        }
      }
    },

    // Compiles coffeescript
    coffee: {
      dev: {
        expand: true, // keeping the hierarchy while developing
        src: config.sourceFileFilter,
        dest: config.buildDirectory,
        ext: '.js'
      }
    },

    // Lint coffeescript files, with the 80l length rule ignored
    coffeelint: {
      options: {
        'max_line_length': {
          'level': 'ignore'
        }
      },
      src: {
        files: {
          src: config.sourceFileFilter
        }
      },
      tests: {
        files: {
          src: config.testFileFilter
        }
      }
    },

    // Creates the index page (ie, add js and css links in the template)
    index: {
      dev: {
        dir: config.buildDirectory,
        src: config.indexTask.dev
      },
      release: {
        dir: config.releaseDirectory,
        src: config.indexTask.release
      }
    },

    // Copy libs js/css and our assets over to the build directory
    copy: {
      libsJs: {
        files: [
          {
            src: config.libs.js,
            dest: config.buildDirectory,
            expand: true
          }
        ]
      },

      libsCss: {
        files: [
          {
            src: config.libs.css,
            dest: config.buildDirectory,
            expand: true
          }
        ]
      },
      // Using src=** and cwd so it doesn't include the src/ folder when copying
      assets: {
        files: [
          {
            src: ['**'],
            dest: config.buildDirectory,
            cwd: config.assetsDirectory,
            expand: true
          }
        ]
      },

      releaseAssets: {
        files: [
          {
            src: ['**'],
            dest: config.releaseDirectory,
            cwd: config.assetsDirectory,
            expand: true
          }
        ]
      },

      releaseCss: {
        files: [
          {
            src: ['**'],
            cwd: config.cssDirectory,
            dest: config.releaseDirectory + 'style/',
            expand: true
          }
        ]
      }
    },

    // This will concatenate all the .html files in the src folder and
    // create a js file to be used in an angular app
    html2js: {
      all: {
        options: {
          module: 'templates',
          base: 'src/templates'
        },
        src: config.templateFileFilter,
        dest: config.convertedTemplatesPath
      }
    },

    // Testing config
    karma: {
      options: {
        port: 9876,
        runnerPort: 9100,
        autoWatch: false,
        urlRoot: '/',
        browsers: ['Firefox'],
        reporters: 'dots',
        files: config.karmaFiles,
        preprocessors: {
          '**/*.coffee': 'coffee'
        },
        plugins: [
          'karma-mocha',
          'karma-firefox-launcher',
          'karma-coffee-preprocessor',
          'karma-phantomjs-launcher'
        ],
        frameworks: ['mocha']
      },
      dev: {
        background: true,
        singleRun: false
      },
      complete: {
        singleRun: true,
        background: false,
        browsers: ['PhantomJS', 'Firefox']
      }
    },

    // uglify our app (not vendors js) and adds a banner to it
    uglify: {
      release: {
        options: {
          banner: config.banner
        },
        files: {
          'release/scripts/app.js': config.ownJsToMinifyFilter,
        }
      }
    },

    // We only want 1 file for the libs so concatenate all of the minified one
    concat: {
      releaseLibs: {
        src: config.libs.jsMin,
        dest: config.releaseLibsMinPath
      }
    },

    // what to do when a file changes
    watch: {
      coffeeSrc: {
        files: config.sourceFileFilter,
        tasks: ['coffeelint:src', 'coffee', 'karma:dev:run']
      },

      coffeeTests: {
        files: config.testFileFilter,
        tasks: ['coffeelint:tests', 'karma:dev:run']
      },

      sass: {
        files: config.sassFileFilter,
        tasks: ['compass:main']
      },

      templates: {
        files: config.templateFileFilter,
        tasks: ['html2js']
      },

      index: {
        files: config.indexFileFilter,
        tasks: ['index:dev']
      }
    }

  });

  // Filter files according to the given regex
  function filterFor(files, regex) {
    return files.filter(function (file) {
      return file.match(regex);
    });
  }

  /**
   * The index.html template includes the stylesheet and javascript sources
   * based on dynamic names calculated in this Gruntfile. This task assembles
   * the list into variables for the template to use and then runs the
   * compilation.
   */
  grunt.registerMultiTask('index', 'Process index.html template', function () {
    // This regex will remove the 'root' path when inserting in the template
    var dirRE = new RegExp('^(build|release)\/', 'g');
    var jsFiles = filterFor(this.filesSrc, /\.js$/).map(function (file) {
      return file.replace(dirRE, '');
    });
    var cssFiles = filterFor(this.filesSrc, /\.css$/).map(function (file) {
      return file.replace(dirRE, '');
    });

    grunt.file.copy(config.indexFileFilter, this.data.dir + '/index.html', {
      process: function (contents, path) {
        return grunt.template.process(contents, {
          data: {
            scripts: jsFiles,
            styles: cssFiles
          }
        });
      }
    });
  });

  // Builds the app without running the test, used in other tasks
  grunt.registerTask(
    'build',
    [
      'html2js',
      'compass',
      'coffeelint:src',
      'coffee',
      'copy:libsJs',
      'copy:libsCss',
      'copy:assets',
      'index:dev'
    ]
  );

  // Task to run whil developing, will watch over changes and run tests, compile sass/etc
  grunt.registerTask(
    'dev',
    [
      'karma:dev', // starts the karma server and browser
      'build',
      'watch'
    ]
  );

  // Alias to run the full test suite
  grunt.registerTask('test', ['karma:complete']);

  // This will create a release folder, containing the app ready to be deployed
  grunt.registerTask(
    'release',
    [
      'clean',
      'build',
      'uglify',
      'concat',
      'copy:releaseAssets',
      'copy:releaseCss',
      'index:release',
      'clean:build'
    ]
  );

};<commit_msg>feat(build): add live reload<commit_after>module.exports = function(grunt) {

  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-contrib-copy');
  grunt.loadNpmTasks('grunt-contrib-coffee');
  grunt.loadNpmTasks('grunt-contrib-compass');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-concat');

  grunt.loadNpmTasks('grunt-coffeelint');
  grunt.loadNpmTasks('grunt-html2js');
  grunt.loadNpmTasks('grunt-karma');

  var config = require('./misc/build-config.js')(grunt);

  grunt.initConfig({

    clean: {
      build: config.buildDirectory,
      release: config.releaseDirectory
    },

    // Build the foundation + custom files using compass
    compass: {
      main: {
        options: {
          config: config.compassConfigFile,
          cssDir: config.cssDirectory,
          sassDir: config.sassDirectory,
          force: true,
          environment: 'production'
        }
      }
    },

    // Compiles coffeescript
    coffee: {
      dev: {
        expand: true, // keeping the hierarchy while developing
        src: config.sourceFileFilter,
        dest: config.buildDirectory,
        ext: '.js'
      }
    },

    // Lint coffeescript files, with the 80l length rule ignored
    coffeelint: {
      options: {
        'max_line_length': {
          'level': 'ignore'
        }
      },
      src: {
        files: {
          src: config.sourceFileFilter
        }
      },
      tests: {
        files: {
          src: config.testFileFilter
        }
      }
    },

    // Creates the index page (ie, add js and css links in the template)
    index: {
      dev: {
        dir: config.buildDirectory,
        src: config.indexTask.dev
      },
      release: {
        dir: config.releaseDirectory,
        src: config.indexTask.release
      }
    },

    // Copy libs js/css and our assets over to the build directory
    copy: {
      libsJs: {
        files: [
          {
            src: config.libs.js,
            dest: config.buildDirectory,
            expand: true
          }
        ]
      },

      libsCss: {
        files: [
          {
            src: config.libs.css,
            dest: config.buildDirectory,
            expand: true
          }
        ]
      },
      // Using src=** and cwd so it doesn't include the src/ folder when copying
      assets: {
        files: [
          {
            src: ['**'],
            dest: config.buildDirectory,
            cwd: config.assetsDirectory,
            expand: true
          }
        ]
      },

      releaseAssets: {
        files: [
          {
            src: ['**'],
            dest: config.releaseDirectory,
            cwd: config.assetsDirectory,
            expand: true
          }
        ]
      },

      releaseCss: {
        files: [
          {
            src: ['**'],
            cwd: config.cssDirectory,
            dest: config.releaseDirectory + 'style/',
            expand: true
          }
        ]
      }
    },

    // This will concatenate all the .html files in the src folder and
    // create a js file to be used in an angular app
    html2js: {
      all: {
        options: {
          module: 'templates',
          base: 'src/templates'
        },
        src: config.templateFileFilter,
        dest: config.convertedTemplatesPath
      }
    },

    // Testing config
    karma: {
      options: {
        port: 9876,
        runnerPort: 9100,
        autoWatch: false,
        urlRoot: '/',
        browsers: ['Firefox'],
        reporters: 'dots',
        files: config.karmaFiles,
        preprocessors: {
          '**/*.coffee': 'coffee'
        },
        plugins: [
          'karma-mocha',
          'karma-firefox-launcher',
          'karma-coffee-preprocessor',
          'karma-phantomjs-launcher'
        ],
        frameworks: ['mocha']
      },
      dev: {
        background: true,
        singleRun: false
      },
      complete: {
        singleRun: true,
        background: false,
        browsers: ['PhantomJS', 'Firefox']
      }
    },

    // uglify our app (not vendors js) and adds a banner to it
    uglify: {
      release: {
        options: {
          banner: config.banner
        },
        files: {
          'release/scripts/app.js': config.ownJsToMinifyFilter,
        }
      }
    },

    // We only want 1 file for the libs so concatenate all of the minified one
    concat: {
      releaseLibs: {
        src: config.libs.jsMin,
        dest: config.releaseLibsMinPath
      }
    },

    // what to do when a file changes
    watch: {
      options: {
        livereload: true,
      },

      coffeeSrc: {
        files: config.sourceFileFilter,
        tasks: ['coffeelint:src', 'coffee', 'karma:dev:run']
      },

      coffeeTests: {
        files: config.testFileFilter,
        tasks: ['coffeelint:tests', 'karma:dev:run'],
        options: {
          livereload: false
        }
      },

      sass: {
        files: config.sassFileFilter,
        tasks: ['compass:main']
      },

      templates: {
        files: config.templateFileFilter,
        tasks: ['html2js']
      },

      index: {
        files: config.indexFileFilter,
        tasks: ['index:dev']
      }
    }

  });

  // Filter files according to the given regex
  function filterFor(files, regex) {
    return files.filter(function (file) {
      return file.match(regex);
    });
  }

  /**
   * The index.html template includes the stylesheet and javascript sources
   * based on dynamic names calculated in this Gruntfile. This task assembles
   * the list into variables for the template to use and then runs the
   * compilation.
   */
  grunt.registerMultiTask('index', 'Process index.html template', function () {
    // This regex will remove the 'root' path when inserting in the template
    var dirRE = new RegExp('^(build|release)\/', 'g');

    var jsFiles = filterFor(this.filesSrc, /\.js$/).map(function (file) {
      return file.replace(dirRE, '');
    });
    var cssFiles = filterFor(this.filesSrc, /\.css$/).map(function (file) {
      return file.replace(dirRE, '');
    });

    if (this.target === 'dev') {
      jsFiles.push('http://localhost:35729/livereload.js');
    }

    grunt.file.copy(config.indexFileFilter, this.data.dir + '/index.html', {
      process: function (contents, path) {
        return grunt.template.process(contents, {
          data: {
            scripts: jsFiles,
            styles: cssFiles
          }
        });
      }
    });
  });

  // Builds the app without running the test, used in other tasks
  grunt.registerTask(
    'build',
    [
      'html2js',
      'compass',
      'coffeelint:src',
      'coffee',
      'copy:libsJs',
      'copy:libsCss',
      'copy:assets',
      'index:dev'
    ]
  );

  // Task to run whil developing, will watch over changes and run tests, compile sass/etc
  grunt.registerTask(
    'dev',
    [
      'karma:dev', // starts the karma server and browser
      'build',
      'watch'
    ]
  );

  // Alias to run the full test suite
  grunt.registerTask('test', ['karma:complete']);

  // This will create a release folder, containing the app ready to be deployed
  grunt.registerTask(
    'release',
    [
      'clean',
      'build',
      'uglify',
      'concat',
      'copy:releaseAssets',
      'copy:releaseCss',
      'index:release',
      'clean:build'
    ]
  );

};<|endoftext|>


<commit_before>module.exports = function(grunt) {
    'use strict';

    var version = grunt.option('release'),
        zipName = (version) ? version : 'DEV';

    // Project configuration.
    grunt.initConfig({
        connect: {
            dev: {
                options: {
                    port: 8580,
                    base: '.',
                    keepalive: true
                }
            },
            test: {
                options: {
                    port: 8581,
                    base: '.'
                }
            },
            prod: {
                options: {
                    port: process.env.PORT || 8585,
                    base: './dist/',
                    keepalive: true,
                    middleware: function(connect, options) {
                        // Return array of whatever middlewares you want
                        return [

                            function(req, res, next) {
                                res.setHeader('Content-Security-Policy', "default-src 'self'; object-src 'none'; connect-src 'self' https://keys.whiteout.io; img-src 'self' data:;");

                                return next();
                            },

                            // Serve static files.
                            connect.static(options.base)
                        ];
                    }
                }
            }
        },

        jshint: {
            all: ['Gruntfile.js', 'src/*.js', 'src/js/**/*.js', 'test/unit/*.js', 'test/integration/*.js'],
            options: {
                jshintrc: '.jshintrc'
            }
        },

        mocha: {
            all: {
                options: {
                    urls: [
                        'http://localhost:<%= connect.test.options.port %>/test/unit/index.html',
                        'http://localhost:<%= connect.test.options.port %>/test/integration/index.html'
                    ],
                    run: false,
                    reporter: 'Spec',
                    log: false,

                    // phanotmjs is soooo slow
                    timeout: 100000
                }
            }
        },

        clean: {
            dist: ['dist', 'src/lib/*.js', 'test/lib', 'test/integration/src']
        },
        sass: {
            dist: {
                files: {
                    'src/css/read-sandbox.css': 'src/sass/read-sandbox.scss',
                    'src/css/all.css': 'src/sass/all.scss'
                }
            }
        },
        autoprefixer: {
            options: {
                browsers: ['last 2 versions']
            },
            dist: {
                files: {
                    'src/css/read-sandbox.css': 'src/css/read-sandbox.css',
                    'src/css/all.css': 'src/css/all.css'
                }
            }
        },
        csso: {
            options: {
                banner: '/*! Copyright © 2013, Whiteout Networks GmbH. All rights reserved.*/\n'
            },
            dist: {
                files: {
                    'dist/css/read-sandbox.min.css': 'src/css/read-sandbox.css',
                    'dist/css/all.min.css': 'src/css/all.css'
                }
            }
        },
        watch: {
            css: {
                files: ['src/sass/**/*.scss'],
                tasks: ['dist-css']
            },
            js: {
                files: ['src/js/**/*.js'],
                tasks: ['copy:js']
            },
            lib: {
                files: ['src/lib/**/*.js'],
                tasks: ['copy:lib']
            },
            app: {
                files: ['src/*.js', 'src/**/*.html', 'src/**/*.json', 'src/img/**/*', 'src/font/**/*'],
                tasks: ['copy:app', 'copy:ca', 'copy:tpl', 'copy:img', 'copy:font', 'manifest-dev']
            }
        },
        copy: {
            npm: {
                expand: true,
                flatten: true,
                cwd: 'node_modules/',
                src: [
                    'requirejs/require.js',
                    'imap-client/src/*.js',
                    'imap-client/node_modules/browserbox/src/*.js',
                    'imap-client/node_modules/browserbox/node_modules/wo-imap-handler/src/*.js',
                    'imap-client/node_modules/browserbox/node_modules/mimefuncs/src/*.js',
                    'imap-client/node_modules/browserbox/node_modules/tcp-socket/src/*.js',
                    'imap-client/node_modules/browserbox/node_modules/wo-utf7/src/*.js',
                    'mailreader/src/*.js',
                    'mailreader/node_modules/mimeparser/src/*.js',
                    'mailreader/node_modules/mimeparser/node_modules/wo-addressparser/src/*.js',
                    'pgpbuilder/src/*.js',
                    'pgpbuilder/node_modules/mailbuild/src/*.js',
                    'pgpbuilder/node_modules/mailbuild/node_modules/mimetypes/src/*.js',
                    'pgpbuilder/node_modules/mailbuild/node_modules/punycode/punycode.min.js',
                    'pgpmailer/src/*.js',
                    'pgpmailer/node_modules/wo-smtpclient/src/*.js',
                    'pgpmailer/node_modules/wo-smtpclient/node_modules/wo-stringencoding/dist/stringencoding.js',
                    'axe-logger/axe.js',
                    'dompurify/purify.js',
                    'jquery/dist/jquery.min.js',
                    'ng-infinite-scroll/build/ng-infinite-scroll.min.js'
                ],
                dest: 'src/lib/'
            },
            npmDev: {
                expand: true,
                flatten: true,
                cwd: 'node_modules/',
                src: ['requirejs/require.js', 'mocha/mocha.css', 'mocha/mocha.js', 'chai/chai.js', 'sinon/pkg/sinon.js', 'angularjs/src/ngMock/angular-mocks.js', 'browsercrow/src/*.js', 'browsersmtp/src/*.js'],
                dest: 'test/lib/'
            },
            cryptoLib: {
                expand: true,
                cwd: 'node_modules/crypto-lib/src/',
                src: ['*.js'],
                dest: 'src/js/crypto/'
            },
            lib: {
                expand: true,
                cwd: 'src/lib/',
                src: ['**'],
                dest: 'dist/lib/'
            },
            js: {
                expand: true,
                cwd: 'src/js/',
                src: ['**'],
                dest: 'dist/js/'
            },
            font: {
                expand: true,
                cwd: 'src/font/',
                src: ['*'],
                dest: 'dist/font/'
            },
            img: {
                expand: true,
                cwd: 'src/img/',
                src: ['*'],
                dest: 'dist/img/'
            },
            tpl: {
                expand: true,
                cwd: 'src/tpl/',
                src: ['*'],
                dest: 'dist/tpl/'
            },
            ca: {
                expand: true,
                cwd: 'src/ca/',
                src: ['*'],
                dest: 'dist/ca/'
            },
            app: {
                expand: true,
                cwd: 'src/',
                src: ['*.html', '*.js', '*.json'],
                dest: 'dist/'
            },
            integration: {
                expand: true,
                cwd: 'src/',
                src: ['**'],
                dest: 'test/integration/src/'
            }
        },

        compress: {
            main: {
                options: {
                    mode: 'zip',
                    archive: 'release/whiteout-mail_' + zipName + '.zip'
                },
                expand: true,
                cwd: 'dist/',
                src: ['**/*'],
                dest: 'release/'
            },
            nodeWebkit: {
                options: {
                    mode: 'zip',
                    archive: 'release/whiteout-mail_' + zipName + '.nw'
                },
                expand: true,
                cwd: 'dist/',
                src: ['**/*'],
                dest: '/'
            }
        },

        nodewebkit: {
            options: {
                version: '0.9.2', // node-webkit version
                build_dir: './release/node-webkit/', // Where the build version of my node-webkit app is saved
                mac: true, // We want to build it for mac
                win: false, // We want to build it for win
                linux32: false, // We don't need linux32
                linux64: false, // We don't need linux64
            },
            src: ['./dist/**/*'] // Your node-webkit app
        },
    });

    // Load the plugin(s)
    grunt.loadNpmTasks('grunt-contrib-connect');
    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-mocha');
    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks('grunt-csso');
    grunt.loadNpmTasks('grunt-contrib-sass');
    grunt.loadNpmTasks('grunt-autoprefixer');
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.loadNpmTasks('grunt-contrib-compress');
    grunt.loadNpmTasks('grunt-node-webkit-builder');

    // Build tasks
    grunt.registerTask('dist-npm', ['copy:npm', 'copy:npmDev', 'copy:cryptoLib']);
    grunt.registerTask('dist-css', ['sass', 'autoprefixer', 'csso']);
    grunt.registerTask('dist-copy', ['copy']);
    grunt.registerTask('dist', ['clean', 'dist-npm', 'dist-css', 'dist-copy']);

    // Test/Dev tasks
    grunt.registerTask('dev', ['connect:dev']);
    grunt.registerTask('test', ['jshint', 'connect:test', 'mocha']);
    grunt.registerTask('prod', ['connect:prod']);

    //
    // Release tasks for Chrome App Release Channels
    //

    grunt.registerTask('manifest-dev', function() {
        patchManifest({
            suffix: ' (DEV)',
            version: '9999.9999.9999.9999'
        });
    });
    grunt.registerTask('manifest-test', function() {
        if (!version) {
            throw new Error('You must specify the version: "--release=1.0"');
        }

        patchManifest({
            suffix: ' (TEST)',
            client_id: '440907777130-bfpgo5fbo4f7hetrg3hn57qolrtubs0u.apps.googleusercontent.com',
            version: version,
            deleteKey: true
        });
    });
    grunt.registerTask('manifest-stable', function() {
        if (!version) {
            throw new Error('You must specify the version: "--release=1.0"');
        }

        patchManifest({
            version: version,
            deleteKey: true,
            keyServer: 'https://keys.whiteout.io/',
            keychainServer: 'https://keychain.whiteout.io/'
        });
    });

    function patchManifest(options) {
        var fs = require('fs'),
            path = './dist/manifest.json',
            manifest = require(path);

        if (options.version) {
            manifest.version = options.version;
        }
        if (options.suffix) {
            manifest.name += options.suffix;
        }
        if (options.client_id) {
            manifest.oauth2.client_id = options.client_id;
        }
        if (options.keyServer) {
            var ksIndex = manifest.permissions.indexOf('https://keys-test.whiteout.io/');
            manifest.permissions[ksIndex] = options.keyServer;
        }
        if (options.keychainServer) {
            var kcsIndex = manifest.permissions.indexOf('https://keychain-test.whiteout.io/');
            manifest.permissions[kcsIndex] = options.keychainServer;
        }
        if (options.deleteKey) {
            delete manifest.key;
        }

        fs.writeFileSync(path, JSON.stringify(manifest, null, 2));
    }

    grunt.registerTask('release-dev', ['dist', 'manifest-dev', 'compress']);
    grunt.registerTask('release-test', ['dist', 'manifest-test', 'compress']);
    grunt.registerTask('release-stable', ['dist', 'manifest-stable', 'compress']);
    grunt.registerTask('default', ['release-dev']);

};<commit_msg>add integration test copy step to watch task<commit_after>module.exports = function(grunt) {
    'use strict';

    var version = grunt.option('release'),
        zipName = (version) ? version : 'DEV';

    // Project configuration.
    grunt.initConfig({
        connect: {
            dev: {
                options: {
                    port: 8580,
                    base: '.',
                    keepalive: true
                }
            },
            test: {
                options: {
                    port: 8581,
                    base: '.'
                }
            },
            prod: {
                options: {
                    port: process.env.PORT || 8585,
                    base: './dist/',
                    keepalive: true,
                    middleware: function(connect, options) {
                        // Return array of whatever middlewares you want
                        return [

                            function(req, res, next) {
                                res.setHeader('Content-Security-Policy', "default-src 'self'; object-src 'none'; connect-src 'self' https://keys.whiteout.io; img-src 'self' data:;");

                                return next();
                            },

                            // Serve static files.
                            connect.static(options.base)
                        ];
                    }
                }
            }
        },

        jshint: {
            all: ['Gruntfile.js', 'src/*.js', 'src/js/**/*.js', 'test/unit/*.js', 'test/integration/*.js'],
            options: {
                jshintrc: '.jshintrc'
            }
        },

        mocha: {
            all: {
                options: {
                    urls: [
                        'http://localhost:<%= connect.test.options.port %>/test/unit/index.html',
                        'http://localhost:<%= connect.test.options.port %>/test/integration/index.html'
                    ],
                    run: false,
                    reporter: 'Spec',
                    log: false,

                    // phanotmjs is soooo slow
                    timeout: 100000
                }
            }
        },

        clean: {
            dist: ['dist', 'src/lib/*.js', 'test/lib', 'test/integration/src']
        },
        sass: {
            dist: {
                files: {
                    'src/css/read-sandbox.css': 'src/sass/read-sandbox.scss',
                    'src/css/all.css': 'src/sass/all.scss'
                }
            }
        },
        autoprefixer: {
            options: {
                browsers: ['last 2 versions']
            },
            dist: {
                files: {
                    'src/css/read-sandbox.css': 'src/css/read-sandbox.css',
                    'src/css/all.css': 'src/css/all.css'
                }
            }
        },
        csso: {
            options: {
                banner: '/*! Copyright © 2013, Whiteout Networks GmbH. All rights reserved.*/\n'
            },
            dist: {
                files: {
                    'dist/css/read-sandbox.min.css': 'src/css/read-sandbox.css',
                    'dist/css/all.min.css': 'src/css/all.css'
                }
            }
        },
        watch: {
            css: {
                files: ['src/sass/**/*.scss'],
                tasks: ['dist-css']
            },
            js: {
                files: ['src/js/**/*.js'],
                tasks: ['copy:js', 'copy:integration']
            },
            lib: {
                files: ['src/lib/**/*.js'],
                tasks: ['copy:lib']
            },
            app: {
                files: ['src/*.js', 'src/**/*.html', 'src/**/*.json', 'src/img/**/*', 'src/font/**/*'],
                tasks: ['copy:app', 'copy:ca', 'copy:tpl', 'copy:img', 'copy:font', 'manifest-dev']
            }
        },
        copy: {
            npm: {
                expand: true,
                flatten: true,
                cwd: 'node_modules/',
                src: [
                    'requirejs/require.js',
                    'imap-client/src/*.js',
                    'imap-client/node_modules/browserbox/src/*.js',
                    'imap-client/node_modules/browserbox/node_modules/wo-imap-handler/src/*.js',
                    'imap-client/node_modules/browserbox/node_modules/mimefuncs/src/*.js',
                    'imap-client/node_modules/browserbox/node_modules/tcp-socket/src/*.js',
                    'imap-client/node_modules/browserbox/node_modules/wo-utf7/src/*.js',
                    'mailreader/src/*.js',
                    'mailreader/node_modules/mimeparser/src/*.js',
                    'mailreader/node_modules/mimeparser/node_modules/wo-addressparser/src/*.js',
                    'pgpbuilder/src/*.js',
                    'pgpbuilder/node_modules/mailbuild/src/*.js',
                    'pgpbuilder/node_modules/mailbuild/node_modules/mimetypes/src/*.js',
                    'pgpbuilder/node_modules/mailbuild/node_modules/punycode/punycode.min.js',
                    'pgpmailer/src/*.js',
                    'pgpmailer/node_modules/wo-smtpclient/src/*.js',
                    'pgpmailer/node_modules/wo-smtpclient/node_modules/wo-stringencoding/dist/stringencoding.js',
                    'axe-logger/axe.js',
                    'dompurify/purify.js',
                    'jquery/dist/jquery.min.js',
                    'ng-infinite-scroll/build/ng-infinite-scroll.min.js'
                ],
                dest: 'src/lib/'
            },
            npmDev: {
                expand: true,
                flatten: true,
                cwd: 'node_modules/',
                src: ['requirejs/require.js', 'mocha/mocha.css', 'mocha/mocha.js', 'chai/chai.js', 'sinon/pkg/sinon.js', 'angularjs/src/ngMock/angular-mocks.js', 'browsercrow/src/*.js', 'browsersmtp/src/*.js'],
                dest: 'test/lib/'
            },
            cryptoLib: {
                expand: true,
                cwd: 'node_modules/crypto-lib/src/',
                src: ['*.js'],
                dest: 'src/js/crypto/'
            },
            lib: {
                expand: true,
                cwd: 'src/lib/',
                src: ['**'],
                dest: 'dist/lib/'
            },
            js: {
                expand: true,
                cwd: 'src/js/',
                src: ['**'],
                dest: 'dist/js/'
            },
            font: {
                expand: true,
                cwd: 'src/font/',
                src: ['*'],
                dest: 'dist/font/'
            },
            img: {
                expand: true,
                cwd: 'src/img/',
                src: ['*'],
                dest: 'dist/img/'
            },
            tpl: {
                expand: true,
                cwd: 'src/tpl/',
                src: ['*'],
                dest: 'dist/tpl/'
            },
            ca: {
                expand: true,
                cwd: 'src/ca/',
                src: ['*'],
                dest: 'dist/ca/'
            },
            app: {
                expand: true,
                cwd: 'src/',
                src: ['*.html', '*.js', '*.json'],
                dest: 'dist/'
            },
            integration: {
                expand: true,
                cwd: 'src/',
                src: ['**'],
                dest: 'test/integration/src/'
            }
        },

        compress: {
            main: {
                options: {
                    mode: 'zip',
                    archive: 'release/whiteout-mail_' + zipName + '.zip'
                },
                expand: true,
                cwd: 'dist/',
                src: ['**/*'],
                dest: 'release/'
            },
            nodeWebkit: {
                options: {
                    mode: 'zip',
                    archive: 'release/whiteout-mail_' + zipName + '.nw'
                },
                expand: true,
                cwd: 'dist/',
                src: ['**/*'],
                dest: '/'
            }
        },

        nodewebkit: {
            options: {
                version: '0.9.2', // node-webkit version
                build_dir: './release/node-webkit/', // Where the build version of my node-webkit app is saved
                mac: true, // We want to build it for mac
                win: false, // We want to build it for win
                linux32: false, // We don't need linux32
                linux64: false, // We don't need linux64
            },
            src: ['./dist/**/*'] // Your node-webkit app
        },
    });

    // Load the plugin(s)
    grunt.loadNpmTasks('grunt-contrib-connect');
    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-mocha');
    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks('grunt-csso');
    grunt.loadNpmTasks('grunt-contrib-sass');
    grunt.loadNpmTasks('grunt-autoprefixer');
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.loadNpmTasks('grunt-contrib-compress');
    grunt.loadNpmTasks('grunt-node-webkit-builder');

    // Build tasks
    grunt.registerTask('dist-npm', ['copy:npm', 'copy:npmDev', 'copy:cryptoLib']);
    grunt.registerTask('dist-css', ['sass', 'autoprefixer', 'csso']);
    grunt.registerTask('dist-copy', ['copy']);
    grunt.registerTask('dist', ['clean', 'dist-npm', 'dist-css', 'dist-copy']);

    // Test/Dev tasks
    grunt.registerTask('dev', ['connect:dev']);
    grunt.registerTask('test', ['jshint', 'connect:test', 'mocha']);
    grunt.registerTask('prod', ['connect:prod']);

    //
    // Release tasks for Chrome App Release Channels
    //

    grunt.registerTask('manifest-dev', function() {
        patchManifest({
            suffix: ' (DEV)',
            version: '9999.9999.9999.9999'
        });
    });
    grunt.registerTask('manifest-test', function() {
        if (!version) {
            throw new Error('You must specify the version: "--release=1.0"');
        }

        patchManifest({
            suffix: ' (TEST)',
            client_id: '440907777130-bfpgo5fbo4f7hetrg3hn57qolrtubs0u.apps.googleusercontent.com',
            version: version,
            deleteKey: true
        });
    });
    grunt.registerTask('manifest-stable', function() {
        if (!version) {
            throw new Error('You must specify the version: "--release=1.0"');
        }

        patchManifest({
            version: version,
            deleteKey: true,
            keyServer: 'https://keys.whiteout.io/',
            keychainServer: 'https://keychain.whiteout.io/'
        });
    });

    function patchManifest(options) {
        var fs = require('fs'),
            path = './dist/manifest.json',
            manifest = require(path);

        if (options.version) {
            manifest.version = options.version;
        }
        if (options.suffix) {
            manifest.name += options.suffix;
        }
        if (options.client_id) {
            manifest.oauth2.client_id = options.client_id;
        }
        if (options.keyServer) {
            var ksIndex = manifest.permissions.indexOf('https://keys-test.whiteout.io/');
            manifest.permissions[ksIndex] = options.keyServer;
        }
        if (options.keychainServer) {
            var kcsIndex = manifest.permissions.indexOf('https://keychain-test.whiteout.io/');
            manifest.permissions[kcsIndex] = options.keychainServer;
        }
        if (options.deleteKey) {
            delete manifest.key;
        }

        fs.writeFileSync(path, JSON.stringify(manifest, null, 2));
    }

    grunt.registerTask('release-dev', ['dist', 'manifest-dev', 'compress']);
    grunt.registerTask('release-test', ['dist', 'manifest-test', 'compress']);
    grunt.registerTask('release-stable', ['dist', 'manifest-stable', 'compress']);
    grunt.registerTask('default', ['release-dev']);

};<|endoftext|>


<commit_before>module.exports = function(grunt) {
	//load plugins for grunt
	[
		grunt.cafe.mocha,
		grunt.contrib.jshint,
		grunt.exec
	].forEach(function (task) {
		grunt.loadNpmTasks(task);
	});

	//configure plugins
}
<commit_msg>modified gruntfile<commit_after>module.exports = function(grunt) {
	//load plugins for grunt
	[
		grunt.cafe.mocha,
		grunt.contrib.jshint,
		grunt.exec
	].forEach(function (task) {
		grunt.loadNpmTasks(task);
	});

	//configure plugins
	grunt.initConfig({
		cafemocha: {
			all: { src: 'qa/test-*.js', options : {ul: 'tdd'} }
		},
		jshint: {
			app: ['meadowlark.js', 'public/js/**/*.js', 'lib/**/*.js'],
			qa: ['Gruntfile.js', 'public/qa/**/*.js', 'qa/**/*.js'],
			exec: { linkchecker: { cmd: 'linkchecker http://localhost/3000'}}
	},
	});

	//register tasks
	//grunt.registerTask('default', ['cafemocha', 'jshint', 'exec']);
	grunt.registerTask('default', ['cafemocha', 'jshint']);
};
<|endoftext|>


<commit_before>module.exports = function(grunt) {

	// I don't know if this is important
	grunt.initConfig({
		pkg: grunt.file.readJSON('package.json'),
	});

	// Loads the different modules used by this gruntfile
	// release
	grunt.loadNpmTasks('grunt-contrib-concat');
	grunt.loadNpmTasks('grunt-contrib-uglify');
	grunt.loadNpmTasks('grunt-sass');
	grunt.loadNpmTasks('grunt-ts');
	grunt.loadNpmTasks('grunt-angular-templates');

	// debug
	grunt.loadNpmTasks('grunt-concurrent');
	grunt.loadNpmTasks('grunt-contrib-connect');
	grunt.loadNpmTasks('grunt-contrib-jshint');
	grunt.loadNpmTasks('grunt-contrib-watch');
	grunt.loadNpmTasks('grunt-karma');
	grunt.loadNpmTasks('grunt-protractor-runner');
	grunt.loadNpmTasks('grunt-tslint');

	// load the configs of all tasks defined under /config
	var configs = require('load-grunt-configs')(grunt);
	grunt.initConfig(configs);

	// this task updates all distributions - launch it once before each release
	grunt.registerTask('dist', ["ts:dist", "ngtemplates:dist", 'concat:spe', 'uglify:spe', 'concat:standard', 'uglify:standard', 'sass:dist']);

	// use this tasks when you are developping
	grunt.registerTask('debug', ["dist", "ts:test", "connect:server", 'concurrent:debug']);
	// // use this one when you're coding e2e tests
	grunt.registerTask('e2e', ["dist", "ts:e2e", "connect", "protractor:singlerun", 'concurrent:e2e']);
	// this updates the dists and tests it, creates karma coverage
	grunt.registerTask('test', ['dist', "ts:test", 'karma:debug', 'karma:coverage', 'protractor:singlerun', 'jshint']);

	// used for travis integration
	grunt.registerTask('travis-karma', ["ts:test", 'karma:travis']);
	grunt.registerTask('travis-protractor', ["ts:e2e", "connect", "protractor:saucelab"]);
};
<commit_msg>grunt [add] task fort jenkins<commit_after>module.exports = function(grunt) {

	// I don't know if this is important
	grunt.initConfig({
		pkg: grunt.file.readJSON('package.json'),
	});

	// Loads the different modules used by this gruntfile
	// release
	grunt.loadNpmTasks('grunt-contrib-concat');
	grunt.loadNpmTasks('grunt-contrib-uglify');
	grunt.loadNpmTasks('grunt-sass');
	grunt.loadNpmTasks('grunt-ts');
	grunt.loadNpmTasks('grunt-angular-templates');

	// debug
	grunt.loadNpmTasks('grunt-concurrent');
	grunt.loadNpmTasks('grunt-contrib-connect');
	grunt.loadNpmTasks('grunt-contrib-jshint');
	grunt.loadNpmTasks('grunt-contrib-watch');
	grunt.loadNpmTasks('grunt-karma');
	grunt.loadNpmTasks('grunt-protractor-runner');
	grunt.loadNpmTasks('grunt-tslint');

	// load the configs of all tasks defined under /config
	var configs = require('load-grunt-configs')(grunt);
	grunt.initConfig(configs);

	// this task updates all distributions - launch it once before each release
	grunt.registerTask('dist', ["ts:dist", "ngtemplates:dist", 'concat:spe', 'uglify:spe', 'concat:standard', 'uglify:standard', 'sass:dist']);

	// use this tasks when you are developping
	grunt.registerTask('debug', ["dist", "ts:test", "connect:server", 'concurrent:debug']);
	// // use this one when you're coding e2e tests
	grunt.registerTask('e2e', ["dist", "ts:e2e", "connect", "protractor:singlerun", 'concurrent:e2e']);
	// this updates the dists and tests it, creates karma coverage
	grunt.registerTask('test', ['dist', "ts:test", 'karma:debug', 'karma:coverage', 'protractor:singlerun', 'jshint']);

	// used for travis integration
	grunt.registerTask('travis-karma', ["ts:test", 'karma:travis']);
	// grunt.registerTask('travis-protractor', ["ts:e2e", "connect", "protractor:saucelab"]);
	grunt.registerTask('jenkins-protractor', ["ts:e2e", "connect", "protractor:singlerun"]);
};
<|endoftext|>