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

    /**
     * Pull in the package.json file so we can read its metadata.
     */
    pkg: grunt.file.readJSON('package.json'),

    /**
     *
     *  Pull in config-specific vars
     *
     */
    config: grunt.file.readJSON('config.json'),

    env: {
      dev: {
        NODE_ENV: 'development',
      },
      dist: {
        NODE_ENV: 'production',
      },
    },

    /**
     * Copy dependencies into static paths
     */
    copy: {
      main: {
        files: [
          {
            expand: true,
            flatten: true,
            src: ['node_modules/respond.js/dest/*'],
            dest: '<%= config.frontEndPath %>/js/built/lib/respond/',
            filter: 'isFile',
          },
        ],
      },
    },

    /**
     * https://github.com/gruntjs/grunt-contrib-sass
     */
    sass: {
      dev: {
        options: {
          style: 'expanded',
        },
        files: {
          '<%= config.frontEndPath %>/css/style.css': '<%= config.frontEndPath %>/css/scss/main.scss',
        },
      },
    },

    /**
     * CSSMin: https://github.com/gruntjs/grunt-contrib-cssmin
     *
     * Minify CSS for production
     */
    cssmin: {
      target: {
        files: {
          '<%= config.frontEndPath %>/css/regulations.min.css': ['<%= config.frontEndPath %>/css/style.css'],
        },
      },
    },
    /**
     * ESLint: https://github.com/sindresorhus/grunt-eslint
     *
     * Validate files with ESLint.
     */
    eslint: {
      target: [
        'Gruntfile.js',
        '<%= config.frontEndPath %>/js/source/*.js',
        '<%= config.frontEndPath %>/js/source/events/**/*.js',
        '<%= config.frontEndPath %>/js/source/models/**/*.js',
        '<%= config.frontEndPath %>/js/source/views/**/*.js',
        '<%= config.frontEndPath %>/js/source/views/**/*.jsx',
      ],
    },

    /**
    * Browserify:
    *
    * Require('modules') in the browser/bundle up dependencies.
    */
    browserify: {
      dev: {
        files: {
          '<%= config.frontEndPath %>/js/built/regulations.js': ['<%= config.frontEndPath %>/js/source/regulations.js', '<%= config.frontEndPath %>/js/source/regulations.js'],
        },
        options: {
          transform: ['babelify', 'browserify-shim'],
          browserifyOptions: {
            debug: true,
          },
        },
      },
      dist: {
        files: {
          '<%= config.frontEndPath %>/js/built/regulations.min.js': ['<%= config.frontEndPath %>/js/source/regulations.js'],
        },
        options: {
          transform: ['babelify', 'browserify-shim'],
          browserifyOptions: {
            debug: true,
            extensions: ['.js', '.jsx'],
          },
          plugin: [
            [function minifyify(b) {
              b.plugin('minifyify', {
                map: '/static/regulations/js/built/regulations.min.map',
                output: grunt.template.process('<%= config.frontEndPath %>/js/built/regulations.min.map'),
              });
            }],
          ],
        },
      },
    },

    mocha_istanbul: {
      coverage: {
        src: ['<%= config.frontEndPath %>/js/unittests/specs/**/*.js'],
        options: {
          root: '<%= config.frontEndPath %>/js',
          scriptPath: require.resolve('isparta/lib/cli'),
          istanbulOptions: ['--include-all-sources'],
          mochaOptions: ['--compilers', 'js:babel-register'],
          nodeExec: require.resolve('.bin/babel-node'),
          coverageFolder: '<%= config.frontEndPath %>/js/unittests/coverage',
          coverage: false,
        },
      },
    },
  });

  /* eslint-disable global-require,import/no-extraneous-dependencies */
  grunt.event.on('coverage', (lcov, done) => {
    require('coveralls').handleInput(lcov, (err) => {
      if (err) {
        done(err);
      }
      done();
    });
  });
  /**
   * The above tasks are loaded here.
   */
  require('load-grunt-tasks')(grunt);
  /* eslint-enable */

  /**
   * Create task aliases by registering new tasks
   */
  grunt.registerTask('test', ['eslint', 'mocha_istanbul']);
  grunt.registerTask('test-js', ['eslint', 'mocha_istanbul']);
  grunt.registerTask('build-dev', ['env:dev', 'copy', 'browserify:dev', 'sass']);
  grunt.registerTask('build-dist', ['env:dist', 'copy', 'browserify:dist', 'sass', 'cssmin']);
  grunt.registerTask('default', ['build-dist']);
};
<commit_msg>Fix minification map address.<commit_after>module.exports = function toExport(grunt) {
  grunt.initConfig({

    /**
     * Pull in the package.json file so we can read its metadata.
     */
    pkg: grunt.file.readJSON('package.json'),

    /**
     *
     *  Pull in config-specific vars
     *
     */
    config: grunt.file.readJSON('config.json'),

    env: {
      dev: {
        NODE_ENV: 'development',
      },
      dist: {
        NODE_ENV: 'production',
      },
    },

    /**
     * Copy dependencies into static paths
     */
    copy: {
      main: {
        files: [
          {
            expand: true,
            flatten: true,
            src: ['node_modules/respond.js/dest/*'],
            dest: '<%= config.frontEndPath %>/js/built/lib/respond/',
            filter: 'isFile',
          },
        ],
      },
    },

    /**
     * https://github.com/gruntjs/grunt-contrib-sass
     */
    sass: {
      dev: {
        options: {
          style: 'expanded',
        },
        files: {
          '<%= config.frontEndPath %>/css/style.css': '<%= config.frontEndPath %>/css/scss/main.scss',
        },
      },
    },

    /**
     * CSSMin: https://github.com/gruntjs/grunt-contrib-cssmin
     *
     * Minify CSS for production
     */
    cssmin: {
      target: {
        files: {
          '<%= config.frontEndPath %>/css/regulations.min.css': ['<%= config.frontEndPath %>/css/style.css'],
        },
      },
    },
    /**
     * ESLint: https://github.com/sindresorhus/grunt-eslint
     *
     * Validate files with ESLint.
     */
    eslint: {
      target: [
        'Gruntfile.js',
        '<%= config.frontEndPath %>/js/source/*.js',
        '<%= config.frontEndPath %>/js/source/events/**/*.js',
        '<%= config.frontEndPath %>/js/source/models/**/*.js',
        '<%= config.frontEndPath %>/js/source/views/**/*.js',
        '<%= config.frontEndPath %>/js/source/views/**/*.jsx',
      ],
    },

    /**
    * Browserify:
    *
    * Require('modules') in the browser/bundle up dependencies.
    */
    browserify: {
      dev: {
        files: {
          '<%= config.frontEndPath %>/js/built/regulations.js': ['<%= config.frontEndPath %>/js/source/regulations.js', '<%= config.frontEndPath %>/js/source/regulations.js'],
        },
        options: {
          transform: ['babelify', 'browserify-shim'],
          browserifyOptions: {
            debug: true,
          },
        },
      },
      dist: {
        files: {
          '<%= config.frontEndPath %>/js/built/regulations.min.js': ['<%= config.frontEndPath %>/js/source/regulations.js'],
        },
        options: {
          transform: ['babelify', 'browserify-shim'],
          browserifyOptions: {
            debug: true,
            extensions: ['.js', '.jsx'],
          },
          plugin: [
            [function minifyify(b) {
              b.plugin('minifyify', {
                map: grunt.template.process('<%= config.frontEndPath %>/js/built/regulations.min.map'),
                output: grunt.template.process('<%= config.frontEndPath %>/js/built/regulations.min.map'),
              });
            }],
          ],
        },
      },
    },

    mocha_istanbul: {
      coverage: {
        src: ['<%= config.frontEndPath %>/js/unittests/specs/**/*.js'],
        options: {
          root: '<%= config.frontEndPath %>/js',
          scriptPath: require.resolve('isparta/lib/cli'),
          istanbulOptions: ['--include-all-sources'],
          mochaOptions: ['--compilers', 'js:babel-register'],
          nodeExec: require.resolve('.bin/babel-node'),
          coverageFolder: '<%= config.frontEndPath %>/js/unittests/coverage',
          coverage: false,
        },
      },
    },
  });

  /* eslint-disable global-require,import/no-extraneous-dependencies */
  grunt.event.on('coverage', (lcov, done) => {
    require('coveralls').handleInput(lcov, (err) => {
      if (err) {
        done(err);
      }
      done();
    });
  });
  /**
   * The above tasks are loaded here.
   */
  require('load-grunt-tasks')(grunt);
  /* eslint-enable */

  /**
   * Create task aliases by registering new tasks
   */
  grunt.registerTask('test', ['eslint', 'mocha_istanbul']);
  grunt.registerTask('test-js', ['eslint', 'mocha_istanbul']);
  grunt.registerTask('build-dev', ['env:dev', 'copy', 'browserify:dev', 'sass']);
  grunt.registerTask('build-dist', ['env:dist', 'copy', 'browserify:dist', 'sass', 'cssmin']);
  grunt.registerTask('default', ['build-dist']);
};
<|endoftext|>


<commit_before>/*global module:false*/
module.exports = function(grunt) {

  // Project configuration.
  grunt.initConfig({
    // Metadata.
    pkg: grunt.file.readJSON('package.json'),
    banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %>\n' +
      '<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' +
      '* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
      ' Released under the <%= pkg.license %> License */\n',
    // Task configuration.
    shell: {
      oldTests: {
        command: 'node test/server.js',
        options: {
          stdout: true,
          failOnError: true
        }
      },
      // these are old that should eventually be rewritten to take advantage of grunt and the current build process
      buildParser: {
        command: 'node src/build.js',
        options: {
          stdout: true
        }
      },
      bench: {
        command: 'node benchmark/server.js',
        options: {
          stdout: true
        }
      },
      doc: {
        command: 'node docs/build.js',
        options: {
          stdout: true
        }
      },
      gitAdd: {
        command: 'git add <%= compress.distTarBall.options.archive %> <%= compress.distZip.options.archive %>',
        options: {
          stdout: true
        }
      }
    },
    concat: {
      options: {
        banner: '<%= banner %>',
        stripBanners: true
      },
      core: {
        src: ['lib/dust.js'],
        dest: 'tmp/dust-core.js'
      },
      full: {
        src: ['lib/dust.js', 'lib/parser.js', 'lib/compiler.js'],
        dest: 'tmp/dust-full.js'
      }
    },
    copy: {
      core: {
        src: 'tmp/dust-core.js',
        dest: 'dist/dust-core.js'
      },
      coreMin: {
        src: 'tmp/dust-core.min.js',
        dest: 'dist/dust-core.min.js'
      },
      full: {
        src: 'tmp/dust-full.js',
        dest: 'dist/dust-full.js'
      },
      fullMin: {
        src: 'tmp/dust-full.min.js',
        dest: 'dist/dust-full.min.js'
      },
      license: {
        src: 'LICENSE',
        dest: 'dist/'
      }
    },
    uglify: {
      options: {
        banner: '<%= banner %>',
        mangle: {
          except: ['require', 'define', 'module', 'dust']
        }
      },
      core: {
        src: '<%= concat.core.dest %>',
        dest: 'tmp/dust-core.min.js'
      },
      full: {
        src: '<%= concat.full.dest %>',
        dest: 'tmp/dust-full.min.js'
      }
    },
    compress: {
      distTarBall: {
        options: {
          archive: 'archive/dust-<%= pkg.version %>.tar.gz',
          mode: 'tgz',
          pretty: true
        },
        files: [
          {expand: true, cwd: 'dist', src: ['**'], dest: 'dust-<%= pkg.version %>/', filter: 'isFile'}
        ]
      },
      distZip: {
        options: {
          archive: 'archive/dust-<%= pkg.version %>.zip',
          mode: 'zip',
          pretty: true
        },
        files: [
          {expand: true, cwd: 'dist', src: ['**'], dest: 'dust-<%= pkg.version %>/', filter: 'isFile'}
        ]
      }
    },
    clean: {
      build: ['tmp/*'],
      dist: ['dist/*'],
      specRunner: '_SpecRunner.html'
    },
    jshint: {
      options: {
        jshintrc: true
      },
      gruntfile: {
        src: 'Gruntfile.js'
      },
      libs: {
        src: ['lib/**/*.js', 'util/**/*.js', 'src/**/*.js', '!lib/parser.js'] // don't hint the parser which is autogenerated from pegjs
      }
    },
    connect: {
     testServer: {
       options: {
         port: 3000,
         keepalive: true
       }
     }
    },
    jasmine: {
      allTests: {
        src: 'tmp/dust-full.min.js',
        options: {
          specs: ['test/jasmine-test/spec/**/*.js'],
          template: require('grunt-template-jasmine-istanbul'),
          templateOptions: {
            coverage: 'tmp/coverage/coverage.json',
            report: 'tmp/coverage'
          }
        }
      }
    },
    watch: {
      gruntfile: {
        files: '<%= jshint.gruntfile.src %>',
        tasks: ['jshint:gruntfile']
      },
      lib_test: {
        files: ['<%= jshint.libs.src %>', '<%= jasmine.allTests.options.specs%>'],
        tasks: ['jshint:libs', 'jasmine']
      }
    },
    bump: {
      options: {
        files: ['package.json', 'bower.json'],
        updateConfigs: ['pkg']
      }
    },
    log: {
      coverage: {
        options: {
          message: 'Coverage is run with `grunt test`. Look inside tmp/coverage'
        }
      },
      copyForRelease: {
        options: {
          message: 'OK. Done copying version <%= pkg.version %> build from tmp to dist'
        }
      },
      testClient: {
        options: {
        message: 'go to http://localhost:<%= connect.testServer.options.port %>/_SpecRunner.html.\n Ctrl-C to kill the server.'
        }
      },
      release: {
        options: {
          message: ['OK. Done bumping, adding, committing, tagging and pushing the new version',
                    '',
                    'You still need to manually do the following:',
                    '  * npm publish'].join('\n')
        }
      }
    },
    testRhino : {
      files: ['test/rhino/lib/**/*.jar']
    }
  });

  grunt.registerMultiTask('testRhino', function(){
    var shellTaskConfig = grunt.config.get('shell'),
      commandList= [];

    //iterate over rhino jars - list is defined in task config
    this.files.forEach(function(fileGroup) {
      fileGroup.src.forEach(function(rhinoJar) {
        commandList.push('java -jar ' + rhinoJar + ' -f test/rhino/rhinoTest.js');
      });
    });

    grunt.log.ok(JSON.stringify(commandList));

    shellTaskConfig['rhinoTests'] = {
      command : commandList.join('&&'),
      options: {
        stdout: true,
        callback: function(err, stdout, stderr, cb) {
         if(err || stderr){
           grunt.warn('There are failing unit tests in Rhino');
         }
          cb();
        }
      }
    };
    grunt.config.set('shell', shellTaskConfig);
    grunt.task.run('shell:rhinoTests');
  });

  // These plugins provide necessary tasks.
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-jasmine');
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-connect');
  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-contrib-copy');
  grunt.loadNpmTasks('grunt-contrib-compress');
  grunt.loadNpmTasks('grunt-gh-pages');
  grunt.loadNpmTasks('grunt-bump');
  grunt.loadNpmTasks('grunt-shell');

  // Npm tasks
  grunt.registerTask('default', ['build']);
  grunt.registerTask('build', ['clean:build', 'jshint', 'shell:buildParser','concat', 'uglify']);

  grunt.registerTask('test', ['clean:specRunner', 'build', 'jasmine', 'shell:oldTests', 'testRhino']);
  grunt.registerTask('testNode', ['shell:oldTests']);
  grunt.registerTask('testClient', ['build', 'jasmine:allTests:build', 'log:testClient', 'connect:testServer']);

  grunt.registerTask('copyForRelease', ['clean:dist', 'copy:core', 'copy:coreMin', 'copy:full', 'copy:fullMin', 'copy:license', 'log:copyForRelease']);
  grunt.registerTask('buildRelease', ['test', 'copyForRelease', 'compress']);
  grunt.registerTask('releasePatch', ['bump-only:patch', 'buildRelease', 'shell:gitAdd:archive', 'bump-commit', 'log:release']);
  grunt.registerTask('releaseMinor', ['bump-only:minor', 'buildRelease', 'shell:gitAdd:archive', 'bump-commit', 'log:release']);
  // major release should probably be done with care
  // grunt.registerTask('releaseMajor', ['bump-only:major', 'buildRelease', 'bump-commit:major', 'log:release']);

  // Custom tasks
  grunt.registerMultiTask('log', 'Print some messages', function() {
    grunt.log.writeln(this.data.options.message);
  });
  grunt.registerTask('coverage', ['log:coverage']);

};
<commit_msg>turn off push, add all files on release and update release message with steps to push manually<commit_after>/*global module:false*/
module.exports = function(grunt) {

  // Project configuration.
  grunt.initConfig({
    // Metadata.
    pkg: grunt.file.readJSON('package.json'),
    banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %>\n' +
      '<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' +
      '* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
      ' Released under the <%= pkg.license %> License */\n',
    // Task configuration.
    shell: {
      oldTests: {
        command: 'node test/server.js',
        options: {
          stdout: true,
          failOnError: true
        }
      },
      // these are old that should eventually be rewritten to take advantage of grunt and the current build process
      buildParser: {
        command: 'node src/build.js',
        options: {
          stdout: true
        }
      },
      bench: {
        command: 'node benchmark/server.js',
        options: {
          stdout: true
        }
      },
      doc: {
        command: 'node docs/build.js',
        options: {
          stdout: true
        }
      },
      gitAdd: {
        command: 'git add <%= compress.distTarBall.options.archive %> <%= compress.distZip.options.archive %>',
        options: {
          stdout: true
        }
      }
    },
    concat: {
      options: {
        banner: '<%= banner %>',
        stripBanners: true
      },
      core: {
        src: ['lib/dust.js'],
        dest: 'tmp/dust-core.js'
      },
      full: {
        src: ['lib/dust.js', 'lib/parser.js', 'lib/compiler.js'],
        dest: 'tmp/dust-full.js'
      }
    },
    copy: {
      core: {
        src: 'tmp/dust-core.js',
        dest: 'dist/dust-core.js'
      },
      coreMin: {
        src: 'tmp/dust-core.min.js',
        dest: 'dist/dust-core.min.js'
      },
      full: {
        src: 'tmp/dust-full.js',
        dest: 'dist/dust-full.js'
      },
      fullMin: {
        src: 'tmp/dust-full.min.js',
        dest: 'dist/dust-full.min.js'
      },
      license: {
        src: 'LICENSE',
        dest: 'dist/'
      }
    },
    uglify: {
      options: {
        banner: '<%= banner %>',
        mangle: {
          except: ['require', 'define', 'module', 'dust']
        }
      },
      core: {
        src: '<%= concat.core.dest %>',
        dest: 'tmp/dust-core.min.js'
      },
      full: {
        src: '<%= concat.full.dest %>',
        dest: 'tmp/dust-full.min.js'
      }
    },
    compress: {
      distTarBall: {
        options: {
          archive: 'archive/dust-<%= pkg.version %>.tar.gz',
          mode: 'tgz',
          pretty: true
        },
        files: [
          {expand: true, cwd: 'dist', src: ['**'], dest: 'dust-<%= pkg.version %>/', filter: 'isFile'}
        ]
      },
      distZip: {
        options: {
          archive: 'archive/dust-<%= pkg.version %>.zip',
          mode: 'zip',
          pretty: true
        },
        files: [
          {expand: true, cwd: 'dist', src: ['**'], dest: 'dust-<%= pkg.version %>/', filter: 'isFile'}
        ]
      }
    },
    clean: {
      build: ['tmp/*'],
      dist: ['dist/*'],
      specRunner: '_SpecRunner.html'
    },
    jshint: {
      options: {
        jshintrc: true
      },
      gruntfile: {
        src: 'Gruntfile.js'
      },
      libs: {
        src: ['lib/**/*.js', 'util/**/*.js', 'src/**/*.js', '!lib/parser.js'] // don't hint the parser which is autogenerated from pegjs
      }
    },
    connect: {
     testServer: {
       options: {
         port: 3000,
         keepalive: true
       }
     }
    },
    jasmine: {
      allTests: {
        src: 'tmp/dust-full.min.js',
        options: {
          specs: ['test/jasmine-test/spec/**/*.js'],
          template: require('grunt-template-jasmine-istanbul'),
          templateOptions: {
            coverage: 'tmp/coverage/coverage.json',
            report: 'tmp/coverage'
          }
        }
      }
    },
    watch: {
      gruntfile: {
        files: '<%= jshint.gruntfile.src %>',
        tasks: ['jshint:gruntfile']
      },
      lib_test: {
        files: ['<%= jshint.libs.src %>', '<%= jasmine.allTests.options.specs%>'],
        tasks: ['jshint:libs', 'jasmine']
      }
    },
    bump: {
      options: {
        files: ['package.json', 'bower.json'],
        updateConfigs: ['pkg'],
        push: false,
        commitFiles: ['-a']
      }
    },
    log: {
      coverage: {
        options: {
          message: 'Coverage is run with `grunt test`. Look inside tmp/coverage'
        }
      },
      copyForRelease: {
        options: {
          message: 'OK. Done copying version <%= pkg.version %> build from tmp to dist'
        }
      },
      testClient: {
        options: {
        message: 'go to http://localhost:<%= connect.testServer.options.port %>/_SpecRunner.html.\n Ctrl-C to kill the server.'
        }
      },
      release: {
        options: {
          message: ['OK. Done bumping, adding, committing, tagging and pushing the new version',
                    '',
                    'You still need to manually do the following:',
                    '  * git push upstream && git push upstream --tags',
                    '  * npm publish'].join('\n')
        }
      }
    },
    testRhino : {
      files: ['test/rhino/lib/**/*.jar']
    }
  });

  grunt.registerMultiTask('testRhino', function(){
    var shellTaskConfig = grunt.config.get('shell'),
      commandList= [];

    //iterate over rhino jars - list is defined in task config
    this.files.forEach(function(fileGroup) {
      fileGroup.src.forEach(function(rhinoJar) {
        commandList.push('java -jar ' + rhinoJar + ' -f test/rhino/rhinoTest.js');
      });
    });

    grunt.log.ok(JSON.stringify(commandList));

    shellTaskConfig['rhinoTests'] = {
      command : commandList.join('&&'),
      options: {
        stdout: true,
        callback: function(err, stdout, stderr, cb) {
         if(err || stderr){
           grunt.warn('There are failing unit tests in Rhino');
         }
          cb();
        }
      }
    };
    grunt.config.set('shell', shellTaskConfig);
    grunt.task.run('shell:rhinoTests');
  });

  // These plugins provide necessary tasks.
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-jasmine');
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-connect');
  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-contrib-copy');
  grunt.loadNpmTasks('grunt-contrib-compress');
  grunt.loadNpmTasks('grunt-gh-pages');
  grunt.loadNpmTasks('grunt-bump');
  grunt.loadNpmTasks('grunt-shell');

  // Npm tasks
  grunt.registerTask('default', ['build']);
  grunt.registerTask('build', ['clean:build', 'jshint', 'shell:buildParser','concat', 'uglify']);

  grunt.registerTask('test', ['clean:specRunner', 'build', 'jasmine', 'shell:oldTests', 'testRhino']);
  grunt.registerTask('testNode', ['shell:oldTests']);
  grunt.registerTask('testClient', ['build', 'jasmine:allTests:build', 'log:testClient', 'connect:testServer']);

  grunt.registerTask('copyForRelease', ['clean:dist', 'copy:core', 'copy:coreMin', 'copy:full', 'copy:fullMin', 'copy:license', 'log:copyForRelease']);
  grunt.registerTask('buildRelease', ['test', 'copyForRelease', 'compress']);
  grunt.registerTask('releasePatch', ['bump-only:patch', 'buildRelease', 'shell:gitAdd:archive', 'bump-commit', 'log:release']);
  grunt.registerTask('releaseMinor', ['bump-only:minor', 'buildRelease', 'shell:gitAdd:archive', 'bump-commit', 'log:release']);
  // major release should probably be done with care
  // grunt.registerTask('releaseMajor', ['bump-only:major', 'buildRelease', 'bump-commit:major', 'log:release']);

  // Custom tasks
  grunt.registerMultiTask('log', 'Print some messages', function() {
    grunt.log.writeln(this.data.options.message);
  });
  grunt.registerTask('coverage', ['log:coverage']);

};
<|endoftext|>


<commit_before>/*jslint node: true */

module.exports = function(grunt) {
	"use strict";
	var apigee_conf = require('./grunt/apigee-config.js')
	var helper = require('./grunt/lib/helper-functions.js');
	var searchNReplace = require('./grunt/search-and-replace-files.js');
	require('time-grunt')(grunt);
	// Project configuration.
	grunt.initConfig({
		pkg: grunt.file.readJSON('package.json'),
		apigee_profiles : apigee_conf.profiles(grunt),//{
		    availabletasks: {
		        tasks: {}
		    },
			clean: ["target"],
			mkdir: {
				all: {
					options: {
						create: ['target', 'target/apiproxy/resources/java/', 'target/java/bin']
					},
				},
			},
			copy: {
				"java-jar" : {
						src: ['java/lib/*.jar', '!java/lib/expressions-1.0.0.jar', '!java/lib/message-flow-1.0.0.jar'],
						dest: 'target/apiproxy/resources/java/', filter: 'isFile', flatten: true, expand : true,
				},
				apiproxy: {
							src: 'apiproxy/**',
							dest: './target/',
				},
				"node-target": { // copy node folder to target for search and replace
							src: './node/**',
							dest: './target/'
				},
				"node-js-root": { //copy app.js and package.json
								expand : true,
								src: './target/node/*',
								dest: './target/apiproxy/resources/node/', filter: 'isFile', flatten: true
					},
			},
		// make a zipfile
		compress: {
		/** No longer required as importApiBundle will install npm modules directly via NPM API **/
		/*
			"node-modules": helper.setNodeResources('./target/node/node_modules/' ,{
									mode : 'zip',
									archive: './target/apiproxy/resources/node/node_modules.zip'
								}, [
								{expand: true, cwd: './target/node/node_modules/', src: ['**'], dest: 'node_modules/' } // makes all src relative to cwd
								]),
		*/
			"node-public": helper.setNodeResources('./target/node/public/', {
								mode : 'zip',
								archive: './target/apiproxy/resources/node/public.zip'
							},[
								{expand: true, cwd: './target/node/public/', src: ['**'], dest: 'public/' }, // makes all src relative to cwd
							]),

			"node-resources": helper.setNodeResources('./target/node/resources/', {
								mode : 'zip',
								archive: './target/apiproxy/resources/node/resources.zip'
							},[
								{expand: true, cwd: './target/node/resources/', src: ['**'], dest: 'resources/' }, // makes all src relative to cwd
							]),
			main: {
				options: {
					mode : 'zip',
					archive: "target/<%= apigee_profiles[grunt.option('env')].apiproxy %>.zip"
				},
				files: [
					{expand: true, cwd: 'target/apiproxy/', src: ['**'], dest: 'apiproxy/' }, // makes all src relative to cwd
					]
				}
		},
		// task for configuration management: search and replace elements within XML files
		xmlpoke: apigee_conf.xmlconfig(grunt.option('env'), grunt),
	    // Configure a mochaTest task
	    mochaTest: {
	    	test: {
	    		options: {
	    			reporter: 'spec', //supported reporters: tap
	    			timeout : 5000,
	    			quiet: false // Optionally suppress output to standard out (defaults to false)
	    		},
	    		src: ["tests/<%= apigee_profiles[grunt.option('env')].apiproxy %>**.js"]
	    	}
	    },
	    jshint: {
		    options: { //see options reference http://www.jshint.com/docs/options/
		    	curly: true,
		    	eqeqeq: true,
		    	eqnull: true,
		    	browser: true,
		    	asi : true,
		    	debug : true,
		    	undef : true,
		    	unused : true,
		    	maxcomplexity : 5,
		    	reporter: require('jshint-stylish')
		    },
		    all: ['Gruntfile.js', 'apiproxy/**/*.js', 'tests/**/*.js', 'tasks/*.js']
		},
	    eslint: {                               // task
	    	options: {
	            config: 'grunt/conf/eslint.json',     // custom config
	            rulesdir: ['grunt/conf/rules']        // custom rules
	        },
	        target: ['Gruntfile.js', 'target/apiproxy/**/*.js', 'tests/**/*.js', 'tasks/*.js']                 // array of files
	    },
		'string-replace': {
			dist : searchNReplace.searchAndReplaceFiles(grunt.option('env'), grunt)
		},
	    shell: {
	        options: {
	            stderr: false,
	            failOnError : true
	        },
	        // Remove comments to enable JavaCallout Policy
	        // javaCompile: {
	        //     command: 'javac -sourcepath ./java/src/**/*.java -d ./target/java/bin -cp java/lib/expressions-1.0.0.jar:java/lib/message-flow-1.0.0.jar:jar:java/lib/message-flow-1.0.1.jar java/src/com/example/SimpleJavaCallout.java',
	        // },
	        // javaJar : {
	        //     command: 'jar cvf target/apiproxy/resources/java/javaCallouts.jar -C target/java/bin .',
	        // },

	        //run jmeter tests from Grunt
/*	        "run_jmeter_tests" : {
	             command: 'mvn install -P <%= grunt.option("env") %>',
	        },*/
	    },
	    notify: {
	    	task_name: {
	    		options: {
	        	// Task-specific options go here.
	        }
		    },
		    ApiDeployed: {
		    	options: {
		    		message: 'Deployment is ready!'
		    	}
		    }
  		},
        complexity: {
            generic: {
                src: ['target/apiproxy/**/*.js', 'tests/**/*.js', 'tasks/*.js'],
                exclude: ['doNotTest.js'],
                options: {
                    breakOnErrors: true,
                    jsLintXML: 'report.xml',         // create XML JSLint-like report
                    checkstyleXML: 'checkstyle.xml', // create checkstyle report
                    errorsOnly: false,               // show only maintainability errors
                    cyclomatic: [3, 7, 12],          // or optionally a single value, like 3
                    halstead: [8, 13, 20],           // or optionally a single value, like 8
                    maintainability: 100,
                    hideComplexFunctions: false,      // only display maintainability
                    broadcast: false                 // broadcast data over event-bus
                }
            }
        },
	})

require('load-grunt-tasks')(grunt);
grunt.registerTask('buildApiBundle', 'Build zip without importing it to Edge', ['clean', 'saveGitRevision', 'mkdir','copy', 'xmlpoke', 'string-replace', 'jshint', 'eslint', 'complexity', /*'shell'*/ 'compress']);
	//delete and then import revision keeping same id
	grunt.registerTask('default', [ 'buildApiBundle', 'getDeployedApiRevisions', 'undeployApiRevision',
		'deleteApiRevision', 'importApiBundle', 'installNpmRevision', 'deployApiRevision', 'executeTests', /*'shell:run_jmeter_tests',*/ 'notify:ApiDeployed']);

	grunt.loadTasks('grunt/tasks');
	if(grunt.option.flags().indexOf('--help') === -1 && !grunt.option('env')) {
		grunt.fail.fatal('Invalid environment --env={env}.')
	}
};<commit_msg>adding license to Gruntfile.js<commit_after>/*jslint node: true */

/************************************************************************
The MIT License (MIT)

Copyright (c) 2014

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
**************************************************************************/

module.exports = function(grunt) {
	"use strict";
	var apigee_conf = require('./grunt/apigee-config.js')
	var helper = require('./grunt/lib/helper-functions.js');
	var searchNReplace = require('./grunt/search-and-replace-files.js');
	require('time-grunt')(grunt);
	// Project configuration.
	grunt.initConfig({
		pkg: grunt.file.readJSON('package.json'),
		apigee_profiles : apigee_conf.profiles(grunt),//{
		    availabletasks: {
		        tasks: {}
		    },
			clean: ["target"],
			mkdir: {
				all: {
					options: {
						create: ['target', 'target/apiproxy/resources/java/', 'target/java/bin']
					},
				},
			},
			copy: {
				"java-jar" : {
						src: ['java/lib/*.jar', '!java/lib/expressions-1.0.0.jar', '!java/lib/message-flow-1.0.0.jar'],
						dest: 'target/apiproxy/resources/java/', filter: 'isFile', flatten: true, expand : true,
				},
				apiproxy: {
							src: 'apiproxy/**',
							dest: './target/',
				},
				"node-target": { // copy node folder to target for search and replace
							src: './node/**',
							dest: './target/'
				},
				"node-js-root": { //copy app.js and package.json
								expand : true,
								src: './target/node/*',
								dest: './target/apiproxy/resources/node/', filter: 'isFile', flatten: true
					},
			},
		// make a zipfile
		compress: {
		/** No longer required as importApiBundle will install npm modules directly via NPM API **/
		/*
			"node-modules": helper.setNodeResources('./target/node/node_modules/' ,{
									mode : 'zip',
									archive: './target/apiproxy/resources/node/node_modules.zip'
								}, [
								{expand: true, cwd: './target/node/node_modules/', src: ['**'], dest: 'node_modules/' } // makes all src relative to cwd
								]),
		*/
			"node-public": helper.setNodeResources('./target/node/public/', {
								mode : 'zip',
								archive: './target/apiproxy/resources/node/public.zip'
							},[
								{expand: true, cwd: './target/node/public/', src: ['**'], dest: 'public/' }, // makes all src relative to cwd
							]),

			"node-resources": helper.setNodeResources('./target/node/resources/', {
								mode : 'zip',
								archive: './target/apiproxy/resources/node/resources.zip'
							},[
								{expand: true, cwd: './target/node/resources/', src: ['**'], dest: 'resources/' }, // makes all src relative to cwd
							]),
			main: {
				options: {
					mode : 'zip',
					archive: "target/<%= apigee_profiles[grunt.option('env')].apiproxy %>.zip"
				},
				files: [
					{expand: true, cwd: 'target/apiproxy/', src: ['**'], dest: 'apiproxy/' }, // makes all src relative to cwd
					]
				}
		},
		// task for configuration management: search and replace elements within XML files
		xmlpoke: apigee_conf.xmlconfig(grunt.option('env'), grunt),
	    // Configure a mochaTest task
	    mochaTest: {
	    	test: {
	    		options: {
	    			reporter: 'spec', //supported reporters: tap
	    			timeout : 5000,
	    			quiet: false // Optionally suppress output to standard out (defaults to false)
	    		},
	    		src: ["tests/<%= apigee_profiles[grunt.option('env')].apiproxy %>**.js"]
	    	}
	    },
	    jshint: {
		    options: { //see options reference http://www.jshint.com/docs/options/
		    	curly: true,
		    	eqeqeq: true,
		    	eqnull: true,
		    	browser: true,
		    	asi : true,
		    	debug : true,
		    	undef : true,
		    	unused : true,
		    	maxcomplexity : 5,
		    	reporter: require('jshint-stylish')
		    },
		    all: ['Gruntfile.js', 'apiproxy/**/*.js', 'tests/**/*.js', 'tasks/*.js']
		},
	    eslint: {                               // task
	    	options: {
	            config: 'grunt/conf/eslint.json',     // custom config
	            rulesdir: ['grunt/conf/rules']        // custom rules
	        },
	        target: ['Gruntfile.js', 'target/apiproxy/**/*.js', 'tests/**/*.js', 'tasks/*.js']                 // array of files
	    },
		'string-replace': {
			dist : searchNReplace.searchAndReplaceFiles(grunt.option('env'), grunt)
		},
	    shell: {
	        options: {
	            stderr: false,
	            failOnError : true
	        },
	        // Remove comments to enable JavaCallout Policy
	        // javaCompile: {
	        //     command: 'javac -sourcepath ./java/src/**/*.java -d ./target/java/bin -cp java/lib/expressions-1.0.0.jar:java/lib/message-flow-1.0.0.jar:jar:java/lib/message-flow-1.0.1.jar java/src/com/example/SimpleJavaCallout.java',
	        // },
	        // javaJar : {
	        //     command: 'jar cvf target/apiproxy/resources/java/javaCallouts.jar -C target/java/bin .',
	        // },

	        //run jmeter tests from Grunt
/*	        "run_jmeter_tests" : {
	             command: 'mvn install -P <%= grunt.option("env") %>',
	        },*/
	    },
	    notify: {
	    	task_name: {
	    		options: {
	        	// Task-specific options go here.
	        }
		    },
		    ApiDeployed: {
		    	options: {
		    		message: 'Deployment is ready!'
		    	}
		    }
  		},
        complexity: {
            generic: {
                src: ['target/apiproxy/**/*.js', 'tests/**/*.js', 'tasks/*.js'],
                exclude: ['doNotTest.js'],
                options: {
                    breakOnErrors: true,
                    jsLintXML: 'report.xml',         // create XML JSLint-like report
                    checkstyleXML: 'checkstyle.xml', // create checkstyle report
                    errorsOnly: false,               // show only maintainability errors
                    cyclomatic: [3, 7, 12],          // or optionally a single value, like 3
                    halstead: [8, 13, 20],           // or optionally a single value, like 8
                    maintainability: 100,
                    hideComplexFunctions: false,      // only display maintainability
                    broadcast: false                 // broadcast data over event-bus
                }
            }
        },
	})

require('load-grunt-tasks')(grunt);
grunt.registerTask('buildApiBundle', 'Build zip without importing it to Edge', ['clean', 'saveGitRevision', 'mkdir','copy', 'xmlpoke', 'string-replace', 'jshint', 'eslint', 'complexity', /*'shell'*/ 'compress']);
	//delete and then import revision keeping same id
	grunt.registerTask('default', [ 'buildApiBundle', 'getDeployedApiRevisions', 'undeployApiRevision',
		'deleteApiRevision', 'importApiBundle', 'installNpmRevision', 'deployApiRevision', 'executeTests', /*'shell:run_jmeter_tests',*/ 'notify:ApiDeployed']);

	grunt.loadTasks('grunt/tasks');
	if(grunt.option.flags().indexOf('--help') === -1 && !grunt.option('env')) {
		grunt.fail.fatal('Invalid environment --env={env}.')
	}
};<|endoftext|>


<commit_before>/* Copyright (c) 2012-2015 The TagSpaces Authors. All rights reserved.
 * Use of this source code is governed by a AGPL3 license that
 * can be found in the LICENSE file. */

'use strict';
module.exports = function(grunt) {
  if (!grunt.file.exists('developer.json')) {
    grunt.file.copy('developer.tmpl.json', 'developer.json');
  }
  grunt.initConfig({
    dev: grunt.file.readJSON('developer.json'),
    replace: {
      templates: {
        options: {
          variables: {
            VERSION: '<%= mainVersion %>',
            BUILD: '<%= subVersion %>',
            BID: '<%= buildId %>',
            APPNAME: '<%= name %>',
            APPDESCRIPTION: '<%= description %>',
            PACKAGE: '<%= package %>',
            PRODUCTION: 'false',
            DEFAULTLOCATIONS: '',
            DEFAULTPERSPECTIVES: "'perspectiveList', 'perspectiveGrid', 'perspectiveGraph'",
            ACTIVATEDPERSPECTIVES: "{ 'id': 'perspectiveList' }, { 'id': 'perspectiveGrid' }, { 'id': 'perspectiveGraph' }",
            MHTVIEWER: 'viewerBrowser',
            PDFVIEWER: 'viewerBrowser'
          },
          prefix: '@@'
        },
        files: [{
          src: 'default.settings.tmpl.js',
          dest: 'data/js/settings.default.js'
        }, {
          src: 'data/mozilla/mozilla.package.tmpl.json',
          dest: 'package.json'
        }, {
          src: 'data/chromium/chrome.manifest.tmpl.json',
          dest: 'data/manifest.json'
        }]
      },
    },
    jshint: {
      options: {
        jshintrc: true
      },
      all: {
        src: [
          'Gruntfile.js',
          'data/js/**/*.js',
          '!data/js/settings.default.js',
          'data/chromium/*.js',
          'data/cordova/*.js',
          'data/ext/editorHTML/*.js',
          'data/ext/editorJSON/*.js',
          'data/ext/editorODF/*.js',
          'data/ext/editorText/*.js',
          'data/ext/perspectiveGrid/*.js',
          'data/ext/perspectiveList/*.js',
          'data/ext/perspectiveGraph/*.js',
          'data/ext/perspectiveImageSwiper/*.js',
          'data/ext/viewerAudioVideo/*.js',
          'data/ext/viewerBrowser/*.js',
          'data/ext/viewerEPUB/*.js',
          'data/ext/viewerHTML/*.js',
          'data/ext/viewerImage/*.js',
          'data/ext/viewerMD/*.js',
          'data/ext/viewerMHTML/*.js',
          'data/ext/viewerPDF/*.js',
          'data/ext/viewerText/*.js',
          'data/ext/viewerURL/*.js',
          'data/ext/viewerZIP/*.js',
          'data/mozilla/**/*.js',
          '!data/mozilla/listen.js',
          '!data/mozilla/menuitems.js',
          '!data/mozilla/toolbarbutton.js',
          '!data/mozilla/unload+.js',
          '!data/mozilla/update.js',
          '!data/mozilla/userstyles.js',
          'data/node-webkit/*.js',
          'data/web/*.js',
          'data/pro/js/*.js',
        ]
      }
    },
    jscs: {
      options: {
        config: ".jscs.json",
        maxErrors: 10
      },
      files: {
        src: [
          'Gruntfile.js',
          'data/js/**/*.js',
          '!data/js/settings.default.js',
          'data/chromium/**/*.js',
          'data/cordova/*.js',
          '!data/cordova/cordova.api.3.4.js',
          'data/ext/editorHTML/*.js',
          'data/ext/editorJSON/*.js',
          'data/ext/editorODF/*.js',
          'data/ext/editorText/*.js',
          'data/ext/perspectiveGrid/*.js',
          'data/ext/perspectiveList/*.js',
          //'data/ext/perspectiveGraph/*.js',
          'data/ext/perspectiveImageSwiper/*.js',
          'data/ext/viewerAudioVideo/*.js',
          'data/ext/viewerBrowser/*.js',
          'data/ext/viewerEPUB/*.js',
          'data/ext/viewerHTML/*.js',
          'data/ext/viewerImage/*.js',
          'data/ext/viewerMD/*.js',
          'data/ext/viewerMHTML/*.js',
          'data/ext/viewerPDF/*.js',
          'data/ext/viewerText/*.js',
          'data/ext/viewerURL/*.js',
          'data/ext/viewerZIP/*.js',
          '!data/mozilla/*.js',
          'data/node-webkit/*.js',
          'data/web/*.js',
          'data/pro/js/*.js',
        ]
      }
    },
    fixmyjs: {
      options: {
        //config: '.jshintrc',
        //legacy: true,
        //dry: true
        //indentpref: 'spaces'
      },
      core: {
        files: [
          {
            expand: true,
            cwd: 'data/',
            //src: ['js/**/*.js', '!js/fileopener.js'],
            dest: 'data',
          }
        ]
      },
      extensions: {
        files: [{
          expand: true,
          cwd: 'data/',
          //src: ['ext/**/*.js', '!js/fileopener.js'],
          dest: 'data',
          ext: '.js'
        }]
      }
    },
    jsbeautifier : {
      files : [
        //'Gruntfile.js',
        //'data/js/**/*.js',
        //'!data/js/settings.default.js',
        //'data/chromium/**/*.js',
        //'data/cordova/**/*.js',
        //'data/ext/editorHTML/*.js',
        //'data/ext/editorJSON/*.js',
        //'data/ext/editorODF/*.js',
        //'data/ext/editorText/*.js',
        //'data/ext/perspectiveGrid/*.js',
        //'data/ext/perspectiveList/*.js',
        //'data/ext/viewerBrowser/*.js',
        //'data/ext/viewerHTML/*.js',
        //'data/ext/viewerImage/*.js',
        //'data/ext/viewerMD/*.js',
        //'data/ext/viewerMHTML/*.js',
        //'data/ext/viewerPDF/*.js',
        //'data/ext/viewerText/*.js',
        //'data/ext/viewerURL/*.js',
        //'data/mozilla/**/*.js',
        //'data/node-webkit/**/*.js',
        //'data/web/**/*.js',
        //'!data/web/webdavlib.js'
      ],
      options : {
        js: {
          "indent_size": 2,
          "indent_char": " ",
          "indent_level": 0,
          "preserve_newlines": true,
          "max_preserve_newlines": 2,
          "jslint_happy": false,
          "space_after_anon_function": false,
          "brace_style": "collapse",
          "keep_array_indentation": false,
          "keep_function_indentation": false,
          "space_before_conditional": true,
          "break_chained_methods": false,
          "eval_code": false,
          "unescape_strings": false,
          "wrap_line_length": 0
        }
      }
    },
    watch: {
      scripts: {
        files: ['Gruntfile.js', '{data/js,data/ext}/**/*.js'],
        tasks: ['default'],
        options: {
          spawn: false
        }
      }
    },
    shell: {
      jsdav: {
        command: 'node webdavserver.js',
        options: {
          execOptions: {
            maxBuffer: 1024 * 1024 * 1024
          }
        }
      },
      jsdoc: {
        command: 'node node_modules/jsdoc/jsdoc.js -c jsdoc.conf.json --verbose',
      },
      transifexpull: {
        command: 'tx pull -a --disable-overwrite',
      },
    },
    compress: {
      chrome: {
        options: {
          mode: 'zip',
          archive: 'backup.zip',
          pretty: true
        },
        files: [{
          expand: true,
          src: ['**/*'],
          cwd: 'data/'
        }]
      },
    },
  });
  //loading modules
  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-copy');
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-replace');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-compress');
  grunt.loadNpmTasks("grunt-jscs");
  grunt.loadNpmTasks('grunt-shell');
  grunt.loadNpmTasks('grunt-fixmyjs');
  grunt.loadNpmTasks('grunt-jsbeautifier');

  //tasks
  grunt.registerTask('checkStyle', ['jshint', 'jscs']);
  grunt.registerTask('jsfix', ['jsbeautifier', 'checkstyle']); // 'fixmyjs:core'
  grunt.registerTask('bumpVersion', ['init', 'replace:templates']);
  grunt.registerTask('default', ['help']);
  grunt.registerTask('runDav', ['shell:jsdav']),
  grunt.registerTask('updateI18N', ['shell:transifexpull']),
  grunt.registerTask('generateDocs', ['shell:jsdoc']),
  grunt.registerTask('help', 'Printing help for this script.', function() {
    grunt.log.writeln("Supported grunt tasks:");
    grunt.log.writeln(" * checkStyle - checking the javascript files complying with the coding standards");
    grunt.log.writeln(" * runDav - runs the webdav server");
    grunt.log.writeln(" * updateI18N - update the translations");
    grunt.log.writeln(" * generateDocs - generates the javascript docs");
    grunt.log.writeln(" * bumpVersion - update the current version from the packages.json accross the application");
  });

  grunt.registerTask('init', 'Initializing variables.', function() {
    grunt.log.writeln("Initializing builder...");
    var cfg = grunt.file.readJSON('package.json');
    grunt.config("buildId", formatDateTime(new Date(), true));
    grunt.config("subVersion", cfg.subversion);
    grunt.config("mainVersion", cfg.mainversion);
    grunt.config("package", cfg.name);
    grunt.config("name", cfg.fullName);
    grunt.config("description", cfg.description);

    function formatDateTime(date, includeTime, includeMS) {
      if ((date === undefined) || (date === "")) {
        return "";
      }
      var d = new Date(date);
      var cDate = d.getDate();
      cDate = cDate + "";
      if (cDate.length === 1) {
        cDate = "0" + cDate;
      }
      var cMonth = d.getMonth();
      cMonth++;
      cMonth = cMonth + "";
      if (cMonth.length === 1) {
        cMonth = "0" + cMonth;
      }
      var cYear = d.getFullYear();
      var cHour = d.getHours();
      cHour = cHour + "";
      if (cHour.length === 1) {
        cHour = "0" + cHour;
      }
      var cMinute = d.getMinutes();
      cMinute = cMinute + "";
      if (cMinute.length === 1) {
        cMinute = "0" + cMinute;
      }
      var cSecond = d.getSeconds();
      cSecond = cSecond + "";
      if (cSecond.length === 1) {
        cSecond = "0" + cSecond;
      }
      var time = "";
      if (includeTime) {
        time = cHour + "" + cMinute + "" + cSecond;
      }
      var milliseconds = "";
      if (includeMS) {
        milliseconds = d.getMilliseconds();
      }
      return cYear + "" + cMonth + "" + cDate + time + milliseconds;
    }
  });
};<commit_msg>adding package.json in tje data directory<commit_after>/* Copyright (c) 2012-2015 The TagSpaces Authors. All rights reserved.
 * Use of this source code is governed by a AGPL3 license that
 * can be found in the LICENSE file. */

'use strict';
module.exports = function(grunt) {
  if (!grunt.file.exists('developer.json')) {
    grunt.file.copy('developer.tmpl.json', 'developer.json');
  }
  grunt.initConfig({
    dev: grunt.file.readJSON('developer.json'),
    replace: {
      templates: {
        options: {
          variables: {
            VERSION: '<%= mainVersion %>',
            BUILD: '<%= subVersion %>',
            BID: '<%= buildId %>',
            APPNAME: '<%= name %>',
            APPDESCRIPTION: '<%= description %>',
            PACKAGE: '<%= package %>',
            PRODUCTION: 'false',
            DEFAULTLOCATIONS: '',
            DEFAULTPERSPECTIVES: "'perspectiveList', 'perspectiveGrid', 'perspectiveGraph'",
            ACTIVATEDPERSPECTIVES: "{ 'id': 'perspectiveList' }, { 'id': 'perspectiveGrid' }, { 'id': 'perspectiveGraph' }",
            MHTVIEWER: 'viewerBrowser',
            PDFVIEWER: 'viewerBrowser'
          },
          prefix: '@@'
        },
        files: [{
          src: 'default.settings.tmpl.js',
          dest: 'data/js/settings.default.js'
        }, {
          src: 'data/mozilla/mozilla.package.tmpl.json',
          dest: 'package.json'
        }, {
          src: 'data/node-webkit/package.tmpl.json',
          dest: 'data/package.json'
        }, {
          src: 'data/chromium/chrome.manifest.tmpl.json',
          dest: 'data/manifest.json'
        }]
      },
    },
    jshint: {
      options: {
        jshintrc: true
      },
      all: {
        src: [
          'Gruntfile.js',
          'data/js/**/*.js',
          '!data/js/settings.default.js',
          'data/chromium/*.js',
          'data/cordova/*.js',
          'data/ext/editorHTML/*.js',
          'data/ext/editorJSON/*.js',
          'data/ext/editorODF/*.js',
          'data/ext/editorText/*.js',
          'data/ext/perspectiveGrid/*.js',
          'data/ext/perspectiveList/*.js',
          'data/ext/perspectiveGraph/*.js',
          'data/ext/perspectiveImageSwiper/*.js',
          'data/ext/viewerAudioVideo/*.js',
          'data/ext/viewerBrowser/*.js',
          'data/ext/viewerEPUB/*.js',
          'data/ext/viewerHTML/*.js',
          'data/ext/viewerImage/*.js',
          'data/ext/viewerMD/*.js',
          'data/ext/viewerMHTML/*.js',
          'data/ext/viewerPDF/*.js',
          'data/ext/viewerText/*.js',
          'data/ext/viewerURL/*.js',
          'data/ext/viewerZIP/*.js',
          'data/mozilla/**/*.js',
          '!data/mozilla/listen.js',
          '!data/mozilla/menuitems.js',
          '!data/mozilla/toolbarbutton.js',
          '!data/mozilla/unload+.js',
          '!data/mozilla/update.js',
          '!data/mozilla/userstyles.js',
          'data/node-webkit/*.js',
          'data/web/*.js',
          'data/pro/js/*.js',
        ]
      }
    },
    jscs: {
      options: {
        config: ".jscs.json",
        maxErrors: 10
      },
      files: {
        src: [
          'Gruntfile.js',
          'data/js/**/*.js',
          '!data/js/settings.default.js',
          'data/chromium/**/*.js',
          'data/cordova/*.js',
          '!data/cordova/cordova.api.3.4.js',
          'data/ext/editorHTML/*.js',
          'data/ext/editorJSON/*.js',
          'data/ext/editorODF/*.js',
          'data/ext/editorText/*.js',
          'data/ext/perspectiveGrid/*.js',
          'data/ext/perspectiveList/*.js',
          //'data/ext/perspectiveGraph/*.js',
          'data/ext/perspectiveImageSwiper/*.js',
          'data/ext/viewerAudioVideo/*.js',
          'data/ext/viewerBrowser/*.js',
          'data/ext/viewerEPUB/*.js',
          'data/ext/viewerHTML/*.js',
          'data/ext/viewerImage/*.js',
          'data/ext/viewerMD/*.js',
          'data/ext/viewerMHTML/*.js',
          'data/ext/viewerPDF/*.js',
          'data/ext/viewerText/*.js',
          'data/ext/viewerURL/*.js',
          'data/ext/viewerZIP/*.js',
          '!data/mozilla/*.js',
          'data/node-webkit/*.js',
          'data/web/*.js',
          'data/pro/js/*.js',
        ]
      }
    },
    fixmyjs: {
      options: {
        //config: '.jshintrc',
        //legacy: true,
        //dry: true
        //indentpref: 'spaces'
      },
      core: {
        files: [
          {
            expand: true,
            cwd: 'data/',
            //src: ['js/**/*.js', '!js/fileopener.js'],
            dest: 'data',
          }
        ]
      },
      extensions: {
        files: [{
          expand: true,
          cwd: 'data/',
          //src: ['ext/**/*.js', '!js/fileopener.js'],
          dest: 'data',
          ext: '.js'
        }]
      }
    },
    jsbeautifier : {
      files : [
        //'Gruntfile.js',
        //'data/js/**/*.js',
        //'!data/js/settings.default.js',
        //'data/chromium/**/*.js',
        //'data/cordova/**/*.js',
        //'data/ext/editorHTML/*.js',
        //'data/ext/editorJSON/*.js',
        //'data/ext/editorODF/*.js',
        //'data/ext/editorText/*.js',
        //'data/ext/perspectiveGrid/*.js',
        //'data/ext/perspectiveList/*.js',
        //'data/ext/viewerBrowser/*.js',
        //'data/ext/viewerHTML/*.js',
        //'data/ext/viewerImage/*.js',
        //'data/ext/viewerMD/*.js',
        //'data/ext/viewerMHTML/*.js',
        //'data/ext/viewerPDF/*.js',
        //'data/ext/viewerText/*.js',
        //'data/ext/viewerURL/*.js',
        //'data/mozilla/**/*.js',
        //'data/node-webkit/**/*.js',
        //'data/web/**/*.js',
        //'!data/web/webdavlib.js'
      ],
      options : {
        js: {
          "indent_size": 2,
          "indent_char": " ",
          "indent_level": 0,
          "preserve_newlines": true,
          "max_preserve_newlines": 2,
          "jslint_happy": false,
          "space_after_anon_function": false,
          "brace_style": "collapse",
          "keep_array_indentation": false,
          "keep_function_indentation": false,
          "space_before_conditional": true,
          "break_chained_methods": false,
          "eval_code": false,
          "unescape_strings": false,
          "wrap_line_length": 0
        }
      }
    },
    watch: {
      scripts: {
        files: ['Gruntfile.js', '{data/js,data/ext}/**/*.js'],
        tasks: ['default'],
        options: {
          spawn: false
        }
      }
    },
    shell: {
      jsdav: {
        command: 'node webdavserver.js',
        options: {
          execOptions: {
            maxBuffer: 1024 * 1024 * 1024
          }
        }
      },
      jsdoc: {
        command: 'node node_modules/jsdoc/jsdoc.js -c jsdoc.conf.json --verbose',
      },
      transifexpull: {
        command: 'tx pull -a --disable-overwrite',
      },
    },
    compress: {
      chrome: {
        options: {
          mode: 'zip',
          archive: 'backup.zip',
          pretty: true
        },
        files: [{
          expand: true,
          src: ['**/*'],
          cwd: 'data/'
        }]
      },
    },
  });
  //loading modules
  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-copy');
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-replace');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-compress');
  grunt.loadNpmTasks("grunt-jscs");
  grunt.loadNpmTasks('grunt-shell');
  grunt.loadNpmTasks('grunt-fixmyjs');
  grunt.loadNpmTasks('grunt-jsbeautifier');

  //tasks
  grunt.registerTask('checkStyle', ['jshint', 'jscs']);
  grunt.registerTask('jsfix', ['jsbeautifier', 'checkstyle']); // 'fixmyjs:core'
  grunt.registerTask('bumpVersion', ['init', 'replace:templates']);
  grunt.registerTask('default', ['help']);
  grunt.registerTask('runDav', ['shell:jsdav']),
  grunt.registerTask('updateI18N', ['shell:transifexpull']),
  grunt.registerTask('generateDocs', ['shell:jsdoc']),
  grunt.registerTask('help', 'Printing help for this script.', function() {
    grunt.log.writeln("Supported grunt tasks:");
    grunt.log.writeln(" * checkStyle - checking the javascript files complying with the coding standards");
    grunt.log.writeln(" * runDav - runs the webdav server");
    grunt.log.writeln(" * updateI18N - update the translations");
    grunt.log.writeln(" * generateDocs - generates the javascript docs");
    grunt.log.writeln(" * bumpVersion - update the current version from the packages.json accross the application");
  });

  grunt.registerTask('init', 'Initializing variables.', function() {
    grunt.log.writeln("Initializing builder...");
    var cfg = grunt.file.readJSON('package.json');
    grunt.config("buildId", formatDateTime(new Date(), true));
    grunt.config("subVersion", cfg.subversion);
    grunt.config("mainVersion", cfg.mainversion);
    grunt.config("package", cfg.name);
    grunt.config("name", cfg.fullName);
    grunt.config("description", cfg.description);

    function formatDateTime(date, includeTime, includeMS) {
      if ((date === undefined) || (date === "")) {
        return "";
      }
      var d = new Date(date);
      var cDate = d.getDate();
      cDate = cDate + "";
      if (cDate.length === 1) {
        cDate = "0" + cDate;
      }
      var cMonth = d.getMonth();
      cMonth++;
      cMonth = cMonth + "";
      if (cMonth.length === 1) {
        cMonth = "0" + cMonth;
      }
      var cYear = d.getFullYear();
      var cHour = d.getHours();
      cHour = cHour + "";
      if (cHour.length === 1) {
        cHour = "0" + cHour;
      }
      var cMinute = d.getMinutes();
      cMinute = cMinute + "";
      if (cMinute.length === 1) {
        cMinute = "0" + cMinute;
      }
      var cSecond = d.getSeconds();
      cSecond = cSecond + "";
      if (cSecond.length === 1) {
        cSecond = "0" + cSecond;
      }
      var time = "";
      if (includeTime) {
        time = cHour + "" + cMinute + "" + cSecond;
      }
      var milliseconds = "";
      if (includeMS) {
        milliseconds = d.getMilliseconds();
      }
      return cYear + "" + cMonth + "" + cDate + time + milliseconds;
    }
  });
};<|endoftext|>


<commit_before>// Generated on 2014-11-09 using generator-angular 0.10.0
'use strict';

// # Globbing
// for performance reasons we're only matching one level down:
// 'test/spec/{,*/}*.js'
// use this if you want to recursively match all subfolders:
// 'test/spec/**/*.js'

module.exports = function (grunt) {

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

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

  // Configurable paths for the application
  var appConfig = {
    app: require('./bower.json').appPath || 'app',
    dist: 'dist'
  };

  // Define the configuration for all the tasks
  grunt.initConfig({

    // Project settings
    yeoman: appConfig,

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

    // The actual grunt server settings
    connect: {
      options: {
        port: 9000,
        // Change this to '0.0.0.0' to access the server from outside.
        hostname: 'localhost',
        livereload: 35729
      },
      livereload: {
        options: {
          open: true,
          middleware: function (connect) {
            return [
              connect.static('.tmp'),
              connect().use(
                '/bower_components',
                connect.static('./bower_components')
              ),
              connect.static(appConfig.app)
            ];
          }
        }
      },
      test: {
        options: {
          port: 9001,
          middleware: function (connect) {
            return [
              connect.static('.tmp'),
              connect.static('test'),
              connect().use(
                '/bower_components',
                connect.static('./bower_components')
              ),
              connect.static(appConfig.app)
            ];
          }
        }
      },
      dist: {
        options: {
          open: true,
          base: '<%= yeoman.dist %>'
        }
      }
    },

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

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

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

    // Automatically inject Bower components into the app
    wiredep: {
      app: {
        src: ['<%= yeoman.app %>/index.html'],
        ignorePath:  /\.\.\//
      },
      sass: {
        src: ['<%= yeoman.app %>/styles/{,*/}*.{scss,sass}'],
        ignorePath: /(\.\.\/){1,2}bower_components\//
      }
    },

    // Compiles Sass to CSS and generates necessary files if requested
    compass: {
      options: {
        sassDir: '<%= yeoman.app %>/styles',
        cssDir: '.tmp/styles',
        generatedImagesDir: '.tmp/images/generated',
        imagesDir: '<%= yeoman.app %>/images',
        javascriptsDir: '<%= yeoman.app %>/scripts',
        fontsDir: '<%= yeoman.app %>/styles/fonts',
        importPath: './bower_components',
        httpImagesPath: '/images',
        httpGeneratedImagesPath: '/images/generated',
        httpFontsPath: '/styles/fonts',
        relativeAssets: false,
        assetCacheBuster: false,
        raw: 'Sass::Script::Number.precision = 10\n'
      },
      dist: {
        options: {
          generatedImagesDir: '<%= yeoman.dist %>/images/generated'
        }
      },
      server: {
        options: {
          debugInfo: true
        }
      }
    },

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

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

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

    // The following *-min tasks will produce minified files in the dist folder
    // By default, your `index.html`'s <!-- Usemin block --> will take care of
    // minification. These next options are pre-configured if you do not wish
    // to use the Usemin blocks.
    // cssmin: {
    //   dist: {
    //     files: {
    //       '<%= yeoman.dist %>/styles/main.css': [
    //         '.tmp/styles/{,*/}*.css'
    //       ]
    //     }
    //   }
    // },
    // uglify: {
    //   dist: {
    //     files: {
    //       '<%= yeoman.dist %>/scripts/scripts.js': [
    //         '<%= yeoman.dist %>/scripts/scripts.js'
    //       ]
    //     }
    //   }
    // },
    // concat: {
    //   dist: {}
    // },

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

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

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

    // ng-annotate tries to make the code safe for minification automatically
    // by using the Angular long form for dependency injection.
    ngAnnotate: {
      dist: {
        files: [{
          expand: true,
          cwd: '.tmp/concat/scripts',
          src: ['*.js', '!oldieshim.js'],
          dest: '.tmp/concat/scripts'
        }]
      }
    },

    // Replace Google CDN references
    cdnify: {
      dist: {
        html: ['<%= yeoman.dist %>/*.html']
      }
    },

    // Copies remaining files to places other tasks can use
    copy: {
      dist: {
        files: [{
          expand: true,
          dot: true,
          cwd: '<%= yeoman.app %>',
          dest: '<%= yeoman.dist %>',
          src: [
            '*.{ico,png,txt}',
            '.htaccess',
            '*.html',
            'views/{,*/}*.html',
            'images/{,*/}*.{webp}',
            'fonts/{,*/}*.*'
          ]
        }, {
          expand: true,
          cwd: '.tmp/images',
          dest: '<%= yeoman.dist %>/images',
          src: ['generated/*']
        }, {
          expand: true,
          cwd: '.',
          src: 'bower_components/bootstrap-sass-official/assets/fonts/bootstrap/*',
          dest: '<%= yeoman.dist %>'
        }]
      },
      styles: {
        expand: true,
        cwd: '<%= yeoman.app %>/styles',
        dest: '.tmp/styles/',
        src: '{,*/}*.css'
      }
    },

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

    // Test settings
    karma: {
      unit: {
        configFile: 'test/karma.conf.js',
        singleRun: true
      }
    }
  });

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

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

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

  grunt.registerTask('test', [
    'clean:server',
    'concurrent:test',
    'autoprefixer',
    'connect:test',
    'karma'
  ]);

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

  grunt.registerTask('default', [
    'newer:jshint',
    'test',
    'build'
  ]);
};
<commit_msg>Screw it just disable tests for now.<commit_after>// Generated on 2014-11-09 using generator-angular 0.10.0
'use strict';

// # Globbing
// for performance reasons we're only matching one level down:
// 'test/spec/{,*/}*.js'
// use this if you want to recursively match all subfolders:
// 'test/spec/**/*.js'

module.exports = function (grunt) {

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

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

  // Configurable paths for the application
  var appConfig = {
    app: require('./bower.json').appPath || 'app',
    dist: 'dist'
  };

  // Define the configuration for all the tasks
  grunt.initConfig({

    // Project settings
    yeoman: appConfig,

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

    // The actual grunt server settings
    connect: {
      options: {
        port: 9000,
        // Change this to '0.0.0.0' to access the server from outside.
        hostname: 'localhost',
        livereload: 35729
      },
      livereload: {
        options: {
          open: true,
          middleware: function (connect) {
            return [
              connect.static('.tmp'),
              connect().use(
                '/bower_components',
                connect.static('./bower_components')
              ),
              connect.static(appConfig.app)
            ];
          }
        }
      },
      test: {
        options: {
          port: 9001,
          middleware: function (connect) {
            return [
              connect.static('.tmp'),
              connect.static('test'),
              connect().use(
                '/bower_components',
                connect.static('./bower_components')
              ),
              connect.static(appConfig.app)
            ];
          }
        }
      },
      dist: {
        options: {
          open: true,
          base: '<%= yeoman.dist %>'
        }
      }
    },

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

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

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

    // Automatically inject Bower components into the app
    wiredep: {
      app: {
        src: ['<%= yeoman.app %>/index.html'],
        ignorePath:  /\.\.\//
      },
      sass: {
        src: ['<%= yeoman.app %>/styles/{,*/}*.{scss,sass}'],
        ignorePath: /(\.\.\/){1,2}bower_components\//
      }
    },

    // Compiles Sass to CSS and generates necessary files if requested
    compass: {
      options: {
        sassDir: '<%= yeoman.app %>/styles',
        cssDir: '.tmp/styles',
        generatedImagesDir: '.tmp/images/generated',
        imagesDir: '<%= yeoman.app %>/images',
        javascriptsDir: '<%= yeoman.app %>/scripts',
        fontsDir: '<%= yeoman.app %>/styles/fonts',
        importPath: './bower_components',
        httpImagesPath: '/images',
        httpGeneratedImagesPath: '/images/generated',
        httpFontsPath: '/styles/fonts',
        relativeAssets: false,
        assetCacheBuster: false,
        raw: 'Sass::Script::Number.precision = 10\n'
      },
      dist: {
        options: {
          generatedImagesDir: '<%= yeoman.dist %>/images/generated'
        }
      },
      server: {
        options: {
          debugInfo: true
        }
      }
    },

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

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

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

    // The following *-min tasks will produce minified files in the dist folder
    // By default, your `index.html`'s <!-- Usemin block --> will take care of
    // minification. These next options are pre-configured if you do not wish
    // to use the Usemin blocks.
    // cssmin: {
    //   dist: {
    //     files: {
    //       '<%= yeoman.dist %>/styles/main.css': [
    //         '.tmp/styles/{,*/}*.css'
    //       ]
    //     }
    //   }
    // },
    // uglify: {
    //   dist: {
    //     files: {
    //       '<%= yeoman.dist %>/scripts/scripts.js': [
    //         '<%= yeoman.dist %>/scripts/scripts.js'
    //       ]
    //     }
    //   }
    // },
    // concat: {
    //   dist: {}
    // },

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

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

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

    // ng-annotate tries to make the code safe for minification automatically
    // by using the Angular long form for dependency injection.
    ngAnnotate: {
      dist: {
        files: [{
          expand: true,
          cwd: '.tmp/concat/scripts',
          src: ['*.js', '!oldieshim.js'],
          dest: '.tmp/concat/scripts'
        }]
      }
    },

    // Replace Google CDN references
    cdnify: {
      dist: {
        html: ['<%= yeoman.dist %>/*.html']
      }
    },

    // Copies remaining files to places other tasks can use
    copy: {
      dist: {
        files: [{
          expand: true,
          dot: true,
          cwd: '<%= yeoman.app %>',
          dest: '<%= yeoman.dist %>',
          src: [
            '*.{ico,png,txt}',
            '.htaccess',
            '*.html',
            'views/{,*/}*.html',
            'images/{,*/}*.{webp}',
            'fonts/{,*/}*.*'
          ]
        }, {
          expand: true,
          cwd: '.tmp/images',
          dest: '<%= yeoman.dist %>/images',
          src: ['generated/*']
        }, {
          expand: true,
          cwd: '.',
          src: 'bower_components/bootstrap-sass-official/assets/fonts/bootstrap/*',
          dest: '<%= yeoman.dist %>'
        }]
      },
      styles: {
        expand: true,
        cwd: '<%= yeoman.app %>/styles',
        dest: '.tmp/styles/',
        src: '{,*/}*.css'
      }
    },

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

    // Test settings
    karma: {
      unit: {
        configFile: 'test/karma.conf.js',
        singleRun: true
      }
    }
  });

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

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

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

  // grunt.registerTask('test', [
  //   'clean:server',
  //   'concurrent:test',
  //   'autoprefixer',
  //   'connect:test',
  //   'karma'
  // ]);

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

  grunt.registerTask('default', [
    'newer:jshint',
    // 'test',
    'build'
  ]);
};
<|endoftext|>


<commit_before>/* globals require */

var Q = require('q');
var shjs = require('shelljs');
var faithfulExec = require('faithful-exec');

var files = require('./files');

var metaBanner = '\
/**\n\
 * <%= pkg.description %>\n\
 * @version v<%= pkg.version %><%= buildTag %>\n\
 * @link <%= pkg.homepage %>\n\
 * @license MIT License, http://www.opensource.org/licenses/MIT\n\
 */';

var concatBanner = '\
<%= meta.banner %>\n\
\n\
(function (window, angular, undefined) {"use strict";\n';

var concatFooter = '\n\n})(window, window.angular);';

/* global module:false */
module.exports = function (grunt) {"use strict";

    require('load-grunt-tasks')(grunt);

    var releaseDirName = 'release';

    /**
     * Karma Config
     */

    var karmaConfigFiles = {
        ng149: 'config/karma-1.4.9.js',
        ng130: 'config/karma-1.3.0.js',
        ng1214: 'config/karma-1.2.14.js',
        ng115: 'config/karma-1.1.5.js',
    };

    var karmaTaskNames = Object.keys(karmaConfigFiles);
    var karmaTasks = karmaTaskNames.map(function (taskName) {
        return 'karma:' + taskName;
    });

    var karmaHeadless = [grunt.option('browser') || 'PhantomJS'];
    var karmaChrome = [grunt.option('browser') || 'Chrome'];

    var karmaTaskConfig = {
        options: {
            configFile: karmaConfigFiles[karmaTaskNames[0]],
            singleRun: true,
            exclude: [],
            frameworks: ['jasmine'],
            reporters: 'dots',
            port: 8080,
            colors: true,
            autoWatch: false,
            autoWatchatchInterval: 0,
            browsers: karmaHeadless,
        },
        unit: {
            browsers: karmaHeadless,
        },
        debug: {
            singleRun: false,
            background: false,
            browsers: karmaChrome,
        },
        background: {
            background: true,
            singleRun: false,
            browsers: karmaHeadless,
        },
        watch: {
            singleRun: false,
            autoWatch: true,
            autoWatchInterval: 1,
        },
    };

    karmaTaskNames.forEach(function (taskName) {
        karmaTaskConfig[taskName] = {
            configFile: karmaConfigFiles[taskName],
        };
    });

    /**
     * Grunt Task Config
     */

    grunt.initConfig({

        buildDir: 'build',
        pkg: grunt.file.readJSON('package.json'),
        buildTag: '-dev-' + grunt.template.today('yyyy-mm-dd'),
        meta: {
            banner: metaBanner,
        },

        clean: ['<%= buildDir %>'],

        concat: {
            options: {
                banner: concatBanner,
                footer: concatFooter,
            },
            build: {
                src: files.src,
                dest: '<%= buildDir %>/<%= pkg.name %>.js',
            },
        },

        uglify: {
            options: {
                banner: '<%= meta.banner %>\n',
            },
            build: {
                files: {
                    '<%= buildDir %>/<%= pkg.name %>.min.js': [
                        '<banner:meta.banner>',
                        '<%= concat.build.dest %>',
                    ],
                },
            },
        },

        release: {
            files: ['<%= pkg.name %>.js', '<%= pkg.name %>.min.js'],
            src: '<%= buildDir %>',
            dest: releaseDirName,
        },

        jshint: {
            all: files.jsHint,
            options: {
                eqnull: true,
                eqeqeq: true,
                multistr: true,
                validthis: true,
            },
        },

        watch: {
            files: files.watch,
            tasks: ['build', 'karma:background:run'],
        },

        connect: {
            server: {},
        },

        karma: karmaTaskConfig,

    });

    /**
     * Grunt Tasks
     */

    grunt.registerTask(
        'integrate',
        ['build', 'jshint'].concat(karmaTasks)
    );

    grunt.registerTask(
        'default',
        ['build', 'jshint', 'karma:unit']
    );

    grunt.registerTask(
        'build',
        'Perform a normal build',
        ['concat', 'uglify']
    );

    grunt.registerTask(
        'dist',
        'Perform a clean build',
        ['clean', 'build']
    );

    grunt.registerTask(
        'release',
        'Tag and perform a release',
        ['prepare-release', 'dist', 'perform-release']
    );

    grunt.registerTask(
        'dev',
        'Run dev server and watch for changes',
        ['build', 'connect:server', 'karma:background', 'watch']
    );

    grunt.registerTask(
        'prepare-release',
        gruntPrepareRelease
    );

    grunt.registerTask(
        'perform-release',
        gruntPerformRelease
    );

    /**
     * Grunt Task Functions
     */

    function gruntPrepareRelease () {

        var bower = grunt.file.readJSON('bower.json');
        var version = bower.version;

        if (version !== grunt.config('pkg.version')) {
            throw new Error('Version mismatch in bower.json');
        }

        function searchForExistingTag () {
            return exec('git tag -l \"' + version + '\"');
        }

        function setGruntConfig (searchResult) {

            if ('' !== searchResult.stdout.trim()) {
                throw new Error('Tag \'' + version + '\' already exists');
            }

            grunt.config('buildTag', '');
            grunt.config('buildDir', releaseDirName);

        }

        var done = this.async();

        ensureCleanMaster()
            .then(searchForExistingTag)
            .then(setGruntConfig)
            .then(function () {
                done();
            })
            .catch(handleAsyncError.bind(undefined, done))
            .done();

    }

    function gruntPerformRelease () {

        grunt.task.requires(['prepare-release', 'dist']);

        var version = grunt.config('pkg.version');
        var releaseDir = grunt.config('buildDir');

        function stageReleaseDir () {
            return system('git add \"' + releaseDir + '\"');
        }

        function commitStagedFiles () {
            return system('git commit -m \"release ' + version + '\"');
        }

        function createTag () {
            return system('git tag \"' + version + '\"');
        }

        var done = this.async();

        stageReleaseDir()
            .then(commitStagedFiles)
            .then(createTag)
            .then(function () {
                done();
            })
            .catch(handleAsyncError.bind(undefined, done))
            .done();

    }

    /**
     * Helper functions
     */

    function exec (cmd) {

        var deferred = Q.defer();

        faithfulExec(cmd)
            .then(function (result) {
                deferred.resolve(result);
            }, function (result) {
                deferred.reject(result);
            });

        return deferred.promise;

    }

    function handleAsyncError (done, error) {

        done = done || function () { };

        grunt.log.write(error + '\n');
        done(false);

    }

    function system (cmd) {

        function handleStdout (result) {
            grunt.log.write(result.stderr + result.stdout);
        }

        function handleStderr (result) {
            grunt.log.write(result.stderr + '\n');
            throw new Error('Failed to run \'' + cmd + '\'');
        }

        grunt.log.write('% ' + cmd + '\n');

        return exec(cmd)
            .then(handleStdout)
            .catch(handleStderr);

    }

    function ensureCleanMaster () {

        function assertMasterAndSetStatusPorcelain (result) {

            if ('refs/heads/master' !== result.stdout.trim()) {
                throw new Error('Not on master branch, aborting');
            }

            return exec('git status --porcelain');

        }

        function assertCleanWorkingCopy (result) {
            if ('' !== result.stdout.trim()) {
                throw new Error('Working copy is dirty, aborting');
            }
        }

        return exec('git symbolic-ref HEAD')
            .then(assertMasterAndSetStatusPorcelain)
            .then(assertCleanWorkingCopy);

    }

};<commit_msg>AngularJS v1.1.5 support removed temporarily<commit_after>/* globals require */

var Q = require('q');
var shjs = require('shelljs');
var faithfulExec = require('faithful-exec');

var files = require('./files');

var metaBanner = '\
/**\n\
 * <%= pkg.description %>\n\
 * @version v<%= pkg.version %><%= buildTag %>\n\
 * @link <%= pkg.homepage %>\n\
 * @license MIT License, http://www.opensource.org/licenses/MIT\n\
 */';

var concatBanner = '\
<%= meta.banner %>\n\
\n\
(function (window, angular, undefined) {"use strict";\n';

var concatFooter = '\n\n})(window, window.angular);';

/* global module:false */
module.exports = function (grunt) {"use strict";

    require('load-grunt-tasks')(grunt);

    var releaseDirName = 'release';

    /**
     * Karma Config
     */

    var karmaConfigFiles = {
        ng149: 'config/karma-1.4.9.js',
        ng130: 'config/karma-1.3.0.js',
        ng1214: 'config/karma-1.2.14.js',
    };

    var karmaTaskNames = Object.keys(karmaConfigFiles);
    var karmaTasks = karmaTaskNames.map(function (taskName) {
        return 'karma:' + taskName;
    });

    var karmaHeadless = [grunt.option('browser') || 'PhantomJS'];
    var karmaChrome = [grunt.option('browser') || 'Chrome'];

    var karmaTaskConfig = {
        options: {
            configFile: karmaConfigFiles[karmaTaskNames[0]],
            singleRun: true,
            exclude: [],
            frameworks: ['jasmine'],
            reporters: 'dots',
            port: 8080,
            colors: true,
            autoWatch: false,
            autoWatchatchInterval: 0,
            browsers: karmaHeadless,
        },
        unit: {
            browsers: karmaHeadless,
        },
        debug: {
            singleRun: false,
            background: false,
            browsers: karmaChrome,
        },
        background: {
            background: true,
            singleRun: false,
            browsers: karmaHeadless,
        },
        watch: {
            singleRun: false,
            autoWatch: true,
            autoWatchInterval: 1,
        },
    };

    karmaTaskNames.forEach(function (taskName) {
        karmaTaskConfig[taskName] = {
            configFile: karmaConfigFiles[taskName],
        };
    });

    /**
     * Grunt Task Config
     */

    grunt.initConfig({

        buildDir: 'build',
        pkg: grunt.file.readJSON('package.json'),
        buildTag: '-dev-' + grunt.template.today('yyyy-mm-dd'),
        meta: {
            banner: metaBanner,
        },

        clean: ['<%= buildDir %>'],

        concat: {
            options: {
                banner: concatBanner,
                footer: concatFooter,
            },
            build: {
                src: files.src,
                dest: '<%= buildDir %>/<%= pkg.name %>.js',
            },
        },

        uglify: {
            options: {
                banner: '<%= meta.banner %>\n',
            },
            build: {
                files: {
                    '<%= buildDir %>/<%= pkg.name %>.min.js': [
                        '<banner:meta.banner>',
                        '<%= concat.build.dest %>',
                    ],
                },
            },
        },

        release: {
            files: ['<%= pkg.name %>.js', '<%= pkg.name %>.min.js'],
            src: '<%= buildDir %>',
            dest: releaseDirName,
        },

        jshint: {
            all: files.jsHint,
            options: {
                eqnull: true,
                eqeqeq: true,
                multistr: true,
                validthis: true,
            },
        },

        watch: {
            files: files.watch,
            tasks: ['build', 'karma:background:run'],
        },

        connect: {
            server: {},
        },

        karma: karmaTaskConfig,

    });

    /**
     * Grunt Tasks
     */

    grunt.registerTask(
        'integrate',
        ['build', 'jshint'].concat(karmaTasks)
    );

    grunt.registerTask(
        'default',
        ['build', 'jshint', 'karma:unit']
    );

    grunt.registerTask(
        'build',
        'Perform a normal build',
        ['concat', 'uglify']
    );

    grunt.registerTask(
        'dist',
        'Perform a clean build',
        ['clean', 'build']
    );

    grunt.registerTask(
        'release',
        'Tag and perform a release',
        ['prepare-release', 'dist', 'perform-release']
    );

    grunt.registerTask(
        'dev',
        'Run dev server and watch for changes',
        ['build', 'connect:server', 'karma:background', 'watch']
    );

    grunt.registerTask(
        'prepare-release',
        gruntPrepareRelease
    );

    grunt.registerTask(
        'perform-release',
        gruntPerformRelease
    );

    /**
     * Grunt Task Functions
     */

    function gruntPrepareRelease () {

        var bower = grunt.file.readJSON('bower.json');
        var version = bower.version;

        if (version !== grunt.config('pkg.version')) {
            throw new Error('Version mismatch in bower.json');
        }

        function searchForExistingTag () {
            return exec('git tag -l \"' + version + '\"');
        }

        function setGruntConfig (searchResult) {

            if ('' !== searchResult.stdout.trim()) {
                throw new Error('Tag \'' + version + '\' already exists');
            }

            grunt.config('buildTag', '');
            grunt.config('buildDir', releaseDirName);

        }

        var done = this.async();

        ensureCleanMaster()
            .then(searchForExistingTag)
            .then(setGruntConfig)
            .then(function () {
                done();
            })
            .catch(handleAsyncError.bind(undefined, done))
            .done();

    }

    function gruntPerformRelease () {

        grunt.task.requires(['prepare-release', 'dist']);

        var version = grunt.config('pkg.version');
        var releaseDir = grunt.config('buildDir');

        function stageReleaseDir () {
            return system('git add \"' + releaseDir + '\"');
        }

        function commitStagedFiles () {
            return system('git commit -m \"release ' + version + '\"');
        }

        function createTag () {
            return system('git tag \"' + version + '\"');
        }

        var done = this.async();

        stageReleaseDir()
            .then(commitStagedFiles)
            .then(createTag)
            .then(function () {
                done();
            })
            .catch(handleAsyncError.bind(undefined, done))
            .done();

    }

    /**
     * Helper functions
     */

    function exec (cmd) {

        var deferred = Q.defer();

        faithfulExec(cmd)
            .then(function (result) {
                deferred.resolve(result);
            }, function (result) {
                deferred.reject(result);
            });

        return deferred.promise;

    }

    function handleAsyncError (done, error) {

        done = done || function () { };

        grunt.log.write(error + '\n');
        done(false);

    }

    function system (cmd) {

        function handleStdout (result) {
            grunt.log.write(result.stderr + result.stdout);
        }

        function handleStderr (result) {
            grunt.log.write(result.stderr + '\n');
            throw new Error('Failed to run \'' + cmd + '\'');
        }

        grunt.log.write('% ' + cmd + '\n');

        return exec(cmd)
            .then(handleStdout)
            .catch(handleStderr);

    }

    function ensureCleanMaster () {

        function assertMasterAndSetStatusPorcelain (result) {

            if ('refs/heads/master' !== result.stdout.trim()) {
                throw new Error('Not on master branch, aborting');
            }

            return exec('git status --porcelain');

        }

        function assertCleanWorkingCopy (result) {
            if ('' !== result.stdout.trim()) {
                throw new Error('Working copy is dirty, aborting');
            }
        }

        return exec('git symbolic-ref HEAD')
            .then(assertMasterAndSetStatusPorcelain)
            .then(assertCleanWorkingCopy);

    }

};<|endoftext|>